summaryrefslogtreecommitdiff
path: root/libbindgen/src/codegen/mod.rs
diff options
context:
space:
mode:
authorArtem Biryukov <impowski@protonmail.ch>2016-11-20 11:50:23 +0300
committerArtem Biryukov <impowski@protonmail.ch>2016-11-20 11:52:25 +0300
commitbed241ea45ce82a283f9c5cda3f98bd6969e53c2 (patch)
treed2ba9a843039eeae41c709a809add195a1fc460d /libbindgen/src/codegen/mod.rs
parent515ef38574845b0fbac1bea72269b44bd0642b75 (diff)
Take out template arguments and make unique names
Diffstat (limited to 'libbindgen/src/codegen/mod.rs')
-rw-r--r--libbindgen/src/codegen/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index 8b54ab00..c99caf9e 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -655,13 +655,25 @@ impl CodeGenerator for CompInfo {
// also don't output template specializations, neither total or partial.
//
// TODO: Generate layout tests for template specializations, yay!
+
+ // TODO (imp): I will keep it like that right now and move it to function later
if self.has_non_type_template_params() ||
self.is_template_specialization() {
let layout = item.kind().expect_type().layout(ctx);
let canonical_name = item.canonical_name(ctx);
if let Some(layout) = layout {
- let fn_name = format!("bindgen_test_layout_template_{}", canonical_name);
+
+ let mut types = String::new();
+
+ for arg in self.template_args() {
+ if let Some(name) = ctx.resolve_type(*arg).name() {
+ // hope this isn't bad
+ types.push_str(format!("{}_", name).as_str());
+ }
+ }
+
+ let fn_name = format!("bindgen_test_layout_template_{}_{}", canonical_name, types);
let fn_name = ctx.rust_ident_raw(&fn_name);
let ident = item.to_rust_ty(ctx);
let prefix = ctx.trait_prefix();