Skip to content

Commit

Permalink
Respect remove_underscores config when prefixing name to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
adamski authored and emilio committed Aug 24, 2021
1 parent 41506d5 commit cbd4260
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bindgen/ir/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,18 @@ impl Item for Enum {
if config.enumeration.prefix_with_name
|| self.annotations.bool("prefix-with-name").unwrap_or(false)
{
let separator = if config.export.mangle.remove_underscores {
""
} else {
"_"
};

for variant in &mut self.variants {
variant.export_name = format!("{}_{}", self.export_name, variant.export_name);
variant.export_name =
format!("{}{}{}", self.export_name, separator, variant.export_name);
if let VariantBody::Body { ref mut body, .. } = variant.body {
body.export_name = format!("{}_{}", self.export_name, body.export_name());
body.export_name =
format!("{}{}{}", self.export_name, separator, body.export_name());
}
}
}
Expand Down

0 comments on commit cbd4260

Please sign in to comment.