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

Produce conservative enum definitions in standalone code generation #2430

Merged
merged 2 commits into from
Apr 5, 2023

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Apr 5, 2023

Unscoped enumeration types are now generated without generating all of the enumerator constants. Practically, this means that if you directly or indirectly refer to a type like WIN32_ERROR - with its many constants - that you will only get the WIN32_ERROR type itself and will need to request any constants directly. This can greatly reduce the overall size of the code produced with standalone code generation.

Fixes: #2409

@kennykerr kennykerr changed the title Standalone code generation now produces conservative enum definitions Produce conservative enum definitions in standalone code generation Apr 5, 2023
@kennykerr kennykerr merged commit ae209ab into master Apr 5, 2023
@kennykerr kennykerr deleted the standalone-enums branch April 5, 2023 18:47
@@ -19,6 +19,7 @@ pub fn standalone(names: &[&str]) -> String {

let mut type_names = BTreeSet::new();
let mut core_types = BTreeSet::new();
let mut enums = BTreeMap::new();
Copy link
Collaborator

Choose a reason for hiding this comment

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

@kennykerr I think you might have meant this to be a Vec? Otherwise this will overwrite the entry instead of adding to it:

enums.insert(enum_name, type_name.name);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, good catch - will fix asap.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here's the fix: #2434 - I use sorted containers to ensure that the generated code is reproducible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great, thanks!

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.

Feature request: windows_bindgen::standalone should allow specifying specific enum constants
2 participants