summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-08-15 13:05:45 -0700
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-08-15 13:08:22 -0700
commit52fd1771877b6f8a81b47edc08313f56e50c5d96 (patch)
tree54ff01c464fe010c435db43c2a43ec5f751e814f
parentf3ce8f26a08b28a0f6b6d2936c2c2676f200c63a (diff)
parser: If we find no declarations, check for primitive type before going down the hack version.
-rw-r--r--src/parser.rs15
-rw-r--r--tests/expectations/ref_argument_array.rs27
-rw-r--r--tests/headers/ref_argument_array.hpp6
3 files changed, 44 insertions, 4 deletions
diff --git a/src/parser.rs b/src/parser.rs
index bb1e535d..49d62b81 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -340,8 +340,9 @@ fn mk_fn_sig_resolving_typedefs(ctx: &mut ClangParserCtx,
// get parameter names and types.
cursor.args().iter().map(|arg| {
let arg_name = arg.spelling();
- let is_class_typedef = arg.cur_type().sanitized_spelling_in(typedefs);
- (arg_name, conv_ty_resolving_typedefs(ctx, &arg.cur_type(), arg, is_class_typedef))
+ let arg_ty = arg.cur_type();
+ let is_class_typedef = arg_ty.sanitized_spelling_in(typedefs);
+ (arg_name, conv_ty_resolving_typedefs(ctx, &arg_ty, arg, is_class_typedef))
}).collect()
}
_ => {
@@ -450,8 +451,14 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
TNamed(ti)
}
CXCursor_NoDeclFound => {
- let layout = Layout::from_ty(&ty);
- TNamed(Rc::new(RefCell::new(TypeInfo::new(ty.spelling().replace("const ", ""), ctx.current_module_id, TVoid, layout))))
+ let canonical = ty.canonical_type();
+ let kind = canonical.kind();
+ if kind != CXType_Invalid && kind != CXType_Unexposed {
+ conv_ty_resolving_typedefs(ctx, &canonical, &ty_decl, resolve_typedefs)
+ } else {
+ let layout = Layout::from_ty(ty);
+ TNamed(Rc::new(RefCell::new(TypeInfo::new(ty.spelling().replace("const ", ""), ctx.current_module_id, TVoid, layout))))
+ }
}
_ => {
let fail = ctx.options.fail_on_unknown_type;
diff --git a/tests/expectations/ref_argument_array.rs b/tests/expectations/ref_argument_array.rs
new file mode 100644
index 00000000..9660fbf2
--- /dev/null
+++ b/tests/expectations/ref_argument_array.rs
@@ -0,0 +1,27 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const NSID_LENGTH: ::std::os::raw::c_uint = 10;
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Struct_nsID {
+ pub _vftable: *const _vftable_Struct_nsID,
+}
+#[repr(C)]
+pub struct _vftable_Struct_nsID {
+ pub ToProvidedString: unsafe extern "C" fn(this:
+ *mut ::std::os::raw::c_void,
+ aDest:
+ *mut [::std::os::raw::c_char; 10usize]),
+}
+impl ::std::clone::Clone for Struct_nsID {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_Struct_nsID() {
+ assert_eq!(::std::mem::size_of::<Struct_nsID>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Struct_nsID>() , 8usize);
+}
diff --git a/tests/headers/ref_argument_array.hpp b/tests/headers/ref_argument_array.hpp
new file mode 100644
index 00000000..dc73fd62
--- /dev/null
+++ b/tests/headers/ref_argument_array.hpp
@@ -0,0 +1,6 @@
+
+#define NSID_LENGTH 10
+class nsID {
+public:
+ virtual void ToProvidedString(char (&aDest)[NSID_LENGTH]) = 0;
+};