summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <me@emiliocobos.me>2016-04-13 16:12:31 +0200
committerEmilio Cobos Álvarez <me@emiliocobos.me>2016-04-13 16:12:31 +0200
commit841bdadded39c92473f7d74b6c9dc960340e7d4c (patch)
treee0c945e2de7becf164c22dec1751b768f6f559e9
parentce3aef67f398a3a25a52051d52bfbeba6c5ca5d6 (diff)
gen: Add enum variant and vtable member mangling
-rw-r--r--src/gen.rs11
-rw-r--r--tests/headers/enum_and_vtable_mangling.hpp11
2 files changed, 19 insertions, 3 deletions
diff --git a/src/gen.rs b/src/gen.rs
index 5e189337..142f8fd9 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -900,8 +900,11 @@ fn cstruct_to_rs(ctx: &mut GenCtx, name: &str, ci: CompInfo) -> Vec<P<ast::Item>
},
_ => unreachable!()
};
+
+ let name = first(rust_id(ctx, &vm.name));
+
let field = ast::StructField_ {
- kind: ast::NamedField(ctx.ext_cx.ident_of(&vm.name), ast::Visibility::Public),
+ kind: ast::NamedField(ctx.ext_cx.ident_of(&name), ast::Visibility::Public),
id: ast::DUMMY_NODE_ID,
ty: P(ty),
attrs: vec!(),
@@ -1478,7 +1481,8 @@ fn cenum_to_rs(ctx: &mut GenCtx,
ctx.ext_cx.ident_of(enum_repr))));
for item in enum_items {
let value = cenum_value_to_int_lit(ctx, enum_is_signed, layout.size, item.val);
- items.push(ctx.ext_cx.item_const(ctx.span, ctx.ext_cx.ident_of(&item.name), enum_ty.clone(), value));
+ let name = first(rust_id(ctx, &item.name));
+ items.push(ctx.ext_cx.item_const(ctx.span, ctx.ext_cx.ident_of(&name), enum_ty.clone(), value));
}
return items;
}
@@ -1486,7 +1490,8 @@ fn cenum_to_rs(ctx: &mut GenCtx,
let mut variants = vec![];
let mut found_values = HashMap::new();
for item in enum_items {
- let name = ctx.ext_cx.ident_of(&item.name);
+ let name = first(rust_id(ctx, &item.name));
+ let name = ctx.ext_cx.ident_of(&name);
if let Some(orig) = found_values.get(&item.val) {
let value = ctx.ext_cx.expr_path(
ctx.ext_cx.path(ctx.span, vec![enum_name, *orig]));
diff --git a/tests/headers/enum_and_vtable_mangling.hpp b/tests/headers/enum_and_vtable_mangling.hpp
new file mode 100644
index 00000000..3abd6a29
--- /dev/null
+++ b/tests/headers/enum_and_vtable_mangling.hpp
@@ -0,0 +1,11 @@
+
+enum {
+ match,
+ whatever_else,
+};
+
+class C {
+ int i;
+public:
+ virtual void match() { };
+};