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

Support aggregate constant initialization #2371

Merged
merged 2 commits into from
Mar 9, 2023
Merged

Support aggregate constant initialization #2371

merged 2 commits into from
Mar 9, 2023

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Mar 9, 2023

The Windows API has a few constants that are more than just plain primitive literals. This update picks up support for the new Constant attribute that provides an initializer syntax for such structs. You can see this in action in the SECURITY_NT_AUTHORITY constant that is now present in both the windows and windows-sys crates. It turns the following metadata:

[Constant("{0, 0, 0, 0, 0, 5}")]
public static SID_IDENTIFIER_AUTHORITY SECURITY_NT_AUTHORITY;

...into this Rust constant:

pub const SECURITY_NT_AUTHORITY: SID_IDENTIFIER_AUTHORITY = SID_IDENTIFIER_AUTHORITY { Value: [0, 0, 0, 0, 0, 5] };

The next update to the Win32 metadata will introduce a bunch of additional constants that were previously missing. The constant parser is a bit simplistic but will do for now until I have better support for metadata generation and can write isolated tests for it.

@kennykerr kennykerr merged commit 1ade3a6 into master Mar 9, 2023
@kennykerr kennykerr deleted the constant branch March 9, 2023 19:54
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.

1 participant