Skip to content

Unable to rename enums #3154

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

Open
guusw opened this issue Feb 25, 2025 · 0 comments
Open

Unable to rename enums #3154

guusw opened this issue Feb 25, 2025 · 0 comments

Comments

@guusw
Copy link

guusw commented Feb 25, 2025

I have an enum like this in C:

enum SHType : uint8_t {
  None,
  Any,
  Enum,
  Bool,
  ...
}

Turns into:

pub const SHType_None: SHType = 0;
pub const SHType_Any: SHType = 1;
pub const SHType_Enum: SHType = 2;
pub const SHType_Bool: SHType = 3;
...
pub type SHType = u8;

Which when used inside match blocks will generate:

warning: constant in pattern `SHType_Float3` should have an upper case name
   --> src\widgets\var_util.rs:194:9
    |
194 |         SHType_Float3 => {
    |         ^^^^^^^^^^^^^ help: convert the identifier to upper case: `SHTYPE_FLOAT3`

I have tried to use ParseCallbacks with enum_variant_name to rename the enum, but it only works on the variant part, not the type (turns into SHType_FLOAT3, instead of SHTYPE_FLOAT3)
I also tried to use item_name in addition which kind of works except it renames the actual type also to SHTYPE, which I want to keep regular, I just want to rename the constants. Anything I'm missing in bindgen that can do this or is it just something that is not possible yet?

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

No branches or pull requests

1 participant