-
Notifications
You must be signed in to change notification settings - Fork 120
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
base: main
Are you sure you want to change the base?
Conversation
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); ```
{ | ||
"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_", |
There was a problem hiding this comment.
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 UINT32
s don't appear to be parsed by enums.json
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 UINT32
s not being parsed, only #define
s? Is there any plan/solution for that?
There was a problem hiding this comment.
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:
win32metadata/sources/MetadataUtils/ConstantsScraper.cs
Lines 32 to 34 in 2e6b619
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 enum
s as well?
For #474 (comment).
For
DXC_FOURCC
it would have been awesome if we could have something like the following, ifconst
methods were supported: