-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #543 - th0rex:master, r=emilio
Add option to not add enum name to bitfield or constant variants Many C libraries prefix the variants of their enums already, because C enums are not scoped. That means if bindgen prefixes them again that can lead to ugly names like `cs_arch_CS_ARCH_ARM`. The `cs_arch_` part comes from the name of the enum itself and `CS_ARCH_ARM` is the name of the actual variant. This pull request introduces a variable for changing this behaviour, alongside command line flags and a test case. If `prepend_enum_names` is set to false the resulting variant name will be `CS_ARCH_ARM` instead of `cs_arch_CS_ARCH_ARM` as it is now. If there is anything that could be improved, or this toggle already exists (I have not found anything like that), please let me know.
- Loading branch information
Showing
5 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(non_snake_case)] | ||
|
||
|
||
pub const FOO_BAR: foo = 0; | ||
pub const FOO_BAZ: foo = 1; | ||
pub type foo = ::std::os::raw::c_uint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// bindgen-flags: --constified-enum foo --no-prepend-enum-name | ||
|
||
enum foo { | ||
FOO_BAR, | ||
FOO_BAZ, | ||
}; |