aboutsummaryrefslogtreecommitdiff
path: root/src/ir/enum_ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/enum_ty.rs')
-rw-r--r--src/ir/enum_ty.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs
index dde4bb1..15d4136 100644
--- a/src/ir/enum_ty.rs
+++ b/src/ir/enum_ty.rs
@@ -118,7 +118,7 @@ impl Enum {
}
});
- let name = ctx
+ let new_name = ctx
.parse_callbacks()
.and_then(|callbacks| {
callbacks.enum_variant_name(type_name, &name, val)
@@ -130,10 +130,11 @@ impl Enum {
.last()
.cloned()
})
- .unwrap_or(name);
+ .unwrap_or_else(|| name.clone());
let comment = cursor.raw_comment();
variants.push(EnumVariant::new(
+ new_name,
name,
comment,
val,
@@ -152,7 +153,7 @@ impl Enum {
enums: &RegexSet,
item: &Item,
) -> bool {
- let path = item.path_for_whitelisting(ctx);
+ let path = item.path_for_allowlisting(ctx);
let enum_ty = item.expect_type();
if enums.matches(&path[1..].join("::")) {
@@ -224,6 +225,9 @@ pub struct EnumVariant {
/// The name of the variant.
name: String,
+ /// The original name of the variant (without user mangling)
+ name_for_allowlisting: String,
+
/// An optional doc comment.
comment: Option<String>,
@@ -251,12 +255,14 @@ impl EnumVariant {
/// Construct a new enumeration variant from the given parts.
pub fn new(
name: String,
+ name_for_allowlisting: String,
comment: Option<String>,
val: EnumVariantValue,
custom_behavior: Option<EnumVariantCustomBehavior>,
) -> Self {
EnumVariant {
name,
+ name_for_allowlisting,
comment,
val,
custom_behavior,
@@ -268,6 +274,11 @@ impl EnumVariant {
&self.name
}
+ /// Get this variant's name.
+ pub fn name_for_allowlisting(&self) -> &str {
+ &self.name_for_allowlisting
+ }
+
/// Get this variant's value.
pub fn val(&self) -> EnumVariantValue {
self.val