Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXC: Annotate new struct fields and enums #1989

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarijnS95
Copy link
Contributor

@MarijnS95 MarijnS95 commented Aug 30, 2024

For #474 (comment).

For DXC_FOURCC it would have been awesome if we could have something like the following, if const methods were supported:

public static const uint DXC_FOURCC(char ch0, char ch1, char ch2, char ch3) => ch0 | (ch1 << 8) | (ch2 << 16) | (ch3 << 24);

For `DXC_FOURCC` it would have been awesome if we could have something
like the following, if `const` methods were supported:

```cs
public static const uint DXC_FOURCC(char ch0, char ch1, char ch2, char ch3) => ch0 | (ch1 << 8) | (ch2 << 16) | (ch3 << 24);
```
@MarijnS95 MarijnS95 marked this pull request as ready for review September 3, 2024 18:49
Comment on lines +28814 to +28838
{
"name": "DxcValidatorFlags",
"flags": true,
"autoPopulate": {
"filter": "DxcValidatorFlags_",
"header": "dxcapi.h"
},
"uses": [
{
"interface": "IDxcValidator",
"method": "Validate",
"parameter": "Flags"
},
{
"interface": "IDxcValidator2",
"method": "ValidateWithDebug",
"parameter": "Flags"
}
]
},
{
"name": "DxcVersionInfoFlags",
"flags": true,
"autoPopulate": {
"filter": "DxcVersionInfoFlags_",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately both these static const UINT32s don't appear to be parsed by enums.json?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems more like a ClangSharp limitation than enums.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, either way it's something that I expected to show up, but it didn't. Should I manually declare "members", while leaving "autoPopulate" in place in hopes of getting a compilation conflict when ClangSharp can provide these to us, or is it a fix you can do elsewhere in the tooling?

As this PR shows we used to have manual fields for DXC_CP_ too (now unnecessary), while also relying on autoPopulate without conflicts being generated?

Copy link
Collaborator

@mikebattista mikebattista Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you can manually declare the missing members together with autoPopulate. The sets will be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Fixed it by removing it, because they can be autodetected.

I don't remember the status of this PR: I think I got stuck on the static const UINT32s not being parsed, only #defines? Is there any plan/solution for that?

Copy link
Contributor Author

@MarijnS95 MarijnS95 Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems more like a ClangSharp limitation than enums.json.

@mikebattista Am I right to assume that ClangSharp emits whatever it finds after preprocessing? I'd assume that all the preprocessor directives are flattened out, which is why the ConstantsScraper specifically looks for #define in source files:

private static readonly Regex DefineRegex =
new Regex(
@"^\s*#\s*define\s+([_A-Za-z][\dA-Za-z_]+)\s+(.+)");

This is the only code that looks at autoPopulate. Assuming that "actual C constants" are extracted from ClangSharp and written elsewhere (could it be ConstantWriter?), is this where we should insert extra logic to turn static const definitions into grouped enums as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants