mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.35k stars 303 forks source link

rename_variants should honor export.rename #366

Open ralfbiedert opened 5 years ago

ralfbiedert commented 5 years ago

Current Behavior

We have a:

[export.rename]
"Result" = "g2om_result"

which produces:

typedef enum {
  Ok = 0,
} g2om_result;

If I now also specify

[enum]
rename_variants = "QualifiedScreamingSnakeCase"

My enums look like this

typedef enum {
  RESULT_OK = 0,
} g2om_result;

Expected Behavior

Instead, I would expect QualifiedScreamingSnakeCase to honor my renames, so that instead this enum is produced:

typedef enum {
   G2OM_RESULT_OK = 0,
} g2om_result;

Tested on

cbindgen version: 0.9

emilio commented 4 years ago

Hmm, maybe only for C? For C++ enum variants are not exposed in the top level scope.

Anyhow this seems a reasonable tweak, probably behind its own flag.