summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-03-24 01:02:41 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-03-24 01:02:41 +0100
commit0632095b95231c0ce73c5240d8bae9611e97bc6a (patch)
treeb667a23c59bff681160174d1494f58ad33478fec
parent744ce6de08684b386dfb6e36b54f639e223184ed (diff)
gen: Handle correctly namespaced pointers to template parameters
-rw-r--r--src/gen.rs14
-rw-r--r--tests/headers/namespace.hpp (renamed from tests/headers/namespace.h)2
-rw-r--r--tests/headers/template.hpp2
3 files changed, 15 insertions, 3 deletions
diff --git a/src/gen.rs b/src/gen.rs
index 8a350adc..bfe06c39 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -107,8 +107,10 @@ fn rust_type_id(ctx: &mut GenCtx, name: &str) -> String {
"uint32_t" => "u32".to_owned(),
"int64_t" => "i64".to_owned(),
"uint64_t" => "u64".to_owned(),
- "size_t" => "usize".to_owned(),
- "ssize_t" => "isize".to_owned(),
+ "uintptr_t"
+ | "size_t" => "usize".to_owned(),
+ "intptr_t"
+ | "ssize_t" => "isize".to_owned(),
_ => first(rust_id(ctx, name))
}
}
@@ -1063,7 +1065,13 @@ fn cstruct_to_rs(ctx: &mut GenCtx, name: &str, ci: CompInfo) -> Vec<P<ast::Item>
};
// If the member is not a template argument, it needs the full path.
- let needs_full_path = !template_args.iter().any(|arg| *arg == f_ty);
+ let needs_full_path = !template_args.iter().any(|arg| {
+ f_ty == *arg || match f_ty {
+ TPtr(ref t, _, _, _) => **t == *arg,
+ TArray(ref t, _, _) => **t == *arg,
+ _ => false,
+ }
+ });
let f_ty = P(cty_to_rs(ctx, &f_ty, f.bitfields.is_none(), needs_full_path));
fields.push(respan(ctx.span, ast::StructField_ {
diff --git a/tests/headers/namespace.h b/tests/headers/namespace.hpp
index 055e7258..90c95d39 100644
--- a/tests/headers/namespace.h
+++ b/tests/headers/namespace.hpp
@@ -22,6 +22,8 @@ namespace {
template<typename T>
class C: public A {
T m_c;
+ T* m_c_ptr;
+ T m_c_arr[10];
};
diff --git a/tests/headers/template.hpp b/tests/headers/template.hpp
index 80825b74..f9483faa 100644
--- a/tests/headers/template.hpp
+++ b/tests/headers/template.hpp
@@ -1,5 +1,7 @@
template<typename T> class Foo {
T m_member;
+ T* m_member_ptr;
+ T m_member_arr[1];
};
void bar(Foo<int> foo);