summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/ty.rs15
-rw-r--r--tests/expectations/tests/template-fun-ty.rs31
-rw-r--r--tests/headers/template-fun-ty.hpp16
3 files changed, 61 insertions, 1 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index 8d01d905..1246057b 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -588,7 +588,20 @@ impl Type {
let kind = match ty_kind {
CXType_Unexposed if *ty != canonical_ty &&
- canonical_ty.kind() != CXType_Invalid => {
+ canonical_ty.kind() != CXType_Invalid &&
+ // Sometime clang desugars some types more than
+ // what we need, specially with function
+ // pointers.
+ //
+ // We should also try the solution of inverting
+ // those checks instead of doing this, that is,
+ // something like:
+ //
+ // CXType_Unexposed if ty.ret_type().is_some()
+ // => { ... }
+ //
+ // etc.
+ !canonical_ty.spelling().contains("type-parameter") => {
debug!("Looking for canonical type: {:?}", canonical_ty);
return Self::from_clang_ty(potential_id,
&canonical_ty,
diff --git a/tests/expectations/tests/template-fun-ty.rs b/tests/expectations/tests/template-fun-ty.rs
new file mode 100644
index 00000000..c2a8a028
--- /dev/null
+++ b/tests/expectations/tests/template-fun-ty.rs
@@ -0,0 +1,31 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Foo<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+pub type Foo_FunctionPtr<T> =
+ ::std::option::Option<unsafe extern "C" fn() -> T>;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RefPtr<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RefPtr_Proxy<T, R, Args> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+ pub _phantom_1: ::std::marker::PhantomData<R>,
+ pub _phantom_2: ::std::marker::PhantomData<Args>,
+}
+pub type RefPtr_Proxy_member_function<R, Args> =
+ ::std::option::Option<unsafe extern "C" fn(arg1: Args) -> R>;
+pub type Returner<T> = ::std::option::Option<unsafe extern "C" fn() -> T>;
diff --git a/tests/headers/template-fun-ty.hpp b/tests/headers/template-fun-ty.hpp
new file mode 100644
index 00000000..1e8e1c25
--- /dev/null
+++ b/tests/headers/template-fun-ty.hpp
@@ -0,0 +1,16 @@
+template <typename T>
+class Foo
+{
+ typedef T (FunctionPtr)();
+};
+
+template<typename T>
+class RefPtr {
+ template<typename R, typename... Args>
+ class Proxy {
+ typedef R (T::*member_function)(Args...);
+ };
+};
+
+template<typename T>
+using Returner = T(*)();