summaryrefslogtreecommitdiff
path: root/libbindgen/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libbindgen/tests')
-rw-r--r--libbindgen/tests/expectations/Cargo.toml11
-rw-r--r--libbindgen/tests/expectations/src/lib.rs0
-rw-r--r--libbindgen/tests/expectations/tests/accessors.rs204
-rw-r--r--libbindgen/tests/expectations/tests/annotation_hide.rs35
-rw-r--r--libbindgen/tests/expectations/tests/anon_enum.rs24
-rw-r--r--libbindgen/tests/expectations/tests/anon_enum_whitelist.rs11
-rw-r--r--libbindgen/tests/expectations/tests/anon_union.rs77
-rw-r--r--libbindgen/tests/expectations/tests/arg_keyword.rs10
-rw-r--r--libbindgen/tests/expectations/tests/base-to-derived.rs19
-rw-r--r--libbindgen/tests/expectations/tests/bitfield-enum-basic.rs77
-rw-r--r--libbindgen/tests/expectations/tests/blocks.rs9
-rw-r--r--libbindgen/tests/expectations/tests/class.rs127
-rw-r--r--libbindgen/tests/expectations/tests/class_nested.rs59
-rw-r--r--libbindgen/tests/expectations/tests/class_no_members.rs45
-rw-r--r--libbindgen/tests/expectations/tests/class_static.rs32
-rw-r--r--libbindgen/tests/expectations/tests/class_static_const.rs22
-rw-r--r--libbindgen/tests/expectations/tests/class_use_as.rs35
-rw-r--r--libbindgen/tests/expectations/tests/class_with_dtor.rs22
-rw-r--r--libbindgen/tests/expectations/tests/class_with_inner_struct.rs195
-rw-r--r--libbindgen/tests/expectations/tests/class_with_typedef.rs72
-rw-r--r--libbindgen/tests/expectations/tests/complex.rs64
-rw-r--r--libbindgen/tests/expectations/tests/complex_global.rs24
-rw-r--r--libbindgen/tests/expectations/tests/const_enum_unnamed.rs28
-rw-r--r--libbindgen/tests/expectations/tests/const_ptr.rs9
-rw-r--r--libbindgen/tests/expectations/tests/const_resolved_ty.rs9
-rw-r--r--libbindgen/tests/expectations/tests/const_tparam.rs12
-rw-r--r--libbindgen/tests/expectations/tests/convert-floats.rs30
-rw-r--r--libbindgen/tests/expectations/tests/crtp.rs43
-rw-r--r--libbindgen/tests/expectations/tests/decl_extern_int_twice.rs10
-rw-r--r--libbindgen/tests/expectations/tests/decl_ptr_to_array.rs10
-rw-r--r--libbindgen/tests/expectations/tests/duplicated_constants_in_ns.rs17
-rw-r--r--libbindgen/tests/expectations/tests/elaborated.rs11
-rw-r--r--libbindgen/tests/expectations/tests/empty_template_param_name.rs13
-rw-r--r--libbindgen/tests/expectations/tests/enum.rs12
-rw-r--r--libbindgen/tests/expectations/tests/enum_alias.rs9
-rw-r--r--libbindgen/tests/expectations/tests/enum_and_vtable_mangling.rs28
-rw-r--r--libbindgen/tests/expectations/tests/enum_dupe.rs10
-rw-r--r--libbindgen/tests/expectations/tests/enum_explicit_type.rs24
-rw-r--r--libbindgen/tests/expectations/tests/enum_negative.rs9
-rw-r--r--libbindgen/tests/expectations/tests/enum_packed.rs15
-rw-r--r--libbindgen/tests/expectations/tests/extern.rs9
-rw-r--r--libbindgen/tests/expectations/tests/float128.rs7
-rw-r--r--libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs17
-rw-r--r--libbindgen/tests/expectations/tests/forward-inherit-struct.rs18
-rw-r--r--libbindgen/tests/expectations/tests/forward_declared_struct.rs32
-rw-r--r--libbindgen/tests/expectations/tests/func_proto.rs9
-rw-r--r--libbindgen/tests/expectations/tests/func_ptr.rs15
-rw-r--r--libbindgen/tests/expectations/tests/func_ptr_in_struct.rs25
-rw-r--r--libbindgen/tests/expectations/tests/func_with_array_arg.rs9
-rw-r--r--libbindgen/tests/expectations/tests/func_with_func_ptr_arg.rs9
-rw-r--r--libbindgen/tests/expectations/tests/in_class_typedef.rs21
-rw-r--r--libbindgen/tests/expectations/tests/inherit-namespaced.rs18
-rw-r--r--libbindgen/tests/expectations/tests/inherit_named.rs17
-rw-r--r--libbindgen/tests/expectations/tests/inherit_typedef.rs33
-rw-r--r--libbindgen/tests/expectations/tests/inner_const.rs27
-rw-r--r--libbindgen/tests/expectations/tests/inner_template_self.rs25
-rw-r--r--libbindgen/tests/expectations/tests/int128_t.rs7
-rw-r--r--libbindgen/tests/expectations/tests/jsval_layout_opaque.rs200
-rw-r--r--libbindgen/tests/expectations/tests/keywords.rs202
-rw-r--r--libbindgen/tests/expectations/tests/macro-expr-basic.rs15
-rw-r--r--libbindgen/tests/expectations/tests/macro-redef.rs9
-rw-r--r--libbindgen/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs45
-rw-r--r--libbindgen/tests/expectations/tests/mutable.rs42
-rw-r--r--libbindgen/tests/expectations/tests/namespace.rs85
-rw-r--r--libbindgen/tests/expectations/tests/nested.rs59
-rw-r--r--libbindgen/tests/expectations/tests/nested_vtable.rs48
-rw-r--r--libbindgen/tests/expectations/tests/no-std.rs23
-rw-r--r--libbindgen/tests/expectations/tests/no_copy.rs13
-rw-r--r--libbindgen/tests/expectations/tests/nsStyleAutoArray.rs22
-rw-r--r--libbindgen/tests/expectations/tests/only_bitfields.rs45
-rw-r--r--libbindgen/tests/expectations/tests/opaque_in_struct.rs33
-rw-r--r--libbindgen/tests/expectations/tests/opaque_pointer.rs45
-rw-r--r--libbindgen/tests/expectations/tests/opaque_typedef.rs15
-rw-r--r--libbindgen/tests/expectations/tests/overflowed_enum.rs16
-rw-r--r--libbindgen/tests/expectations/tests/overloading.rs23
-rw-r--r--libbindgen/tests/expectations/tests/private.rs52
-rw-r--r--libbindgen/tests/expectations/tests/redeclaration.rs9
-rw-r--r--libbindgen/tests/expectations/tests/ref_argument_array.rs23
-rw-r--r--libbindgen/tests/expectations/tests/replace_template_alias.rs15
-rw-r--r--libbindgen/tests/expectations/tests/replaces_double.rs15
-rw-r--r--libbindgen/tests/expectations/tests/size_t_template.rs19
-rw-r--r--libbindgen/tests/expectations/tests/struct_containing_forward_declared_struct.rs32
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_anon_struct.rs33
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_anon_struct_array.rs48
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_anon_struct_pointer.rs33
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_anon_union.rs58
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_anon_unnamed_struct.rs33
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_anon_unnamed_union.rs58
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_bitfields.rs122
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_derive_debug.rs50
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_nesting.rs90
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_packing.rs20
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_struct.rs33
-rw-r--r--libbindgen/tests/expectations/tests/struct_with_typedef_template_arg.rs15
-rw-r--r--libbindgen/tests/expectations/tests/template.rs170
-rw-r--r--libbindgen/tests/expectations/tests/template_alias.rs12
-rw-r--r--libbindgen/tests/expectations/tests/template_alias_basic.rs7
-rw-r--r--libbindgen/tests/expectations/tests/template_alias_namespace.rs21
-rw-r--r--libbindgen/tests/expectations/tests/template_typedef_transitive_param.rs18
-rw-r--r--libbindgen/tests/expectations/tests/template_typedefs.rs22
-rw-r--r--libbindgen/tests/expectations/tests/type_alias_empty.rs7
-rw-r--r--libbindgen/tests/expectations/tests/typeref.rs96
-rw-r--r--libbindgen/tests/expectations/tests/union_dtor.rs42
-rw-r--r--libbindgen/tests/expectations/tests/union_fields.rs47
-rw-r--r--libbindgen/tests/expectations/tests/union_template.rs62
-rw-r--r--libbindgen/tests/expectations/tests/union_with_anon_struct.rs58
-rw-r--r--libbindgen/tests/expectations/tests/union_with_anon_struct_bitfield.rs86
-rw-r--r--libbindgen/tests/expectations/tests/union_with_anon_union.rs59
-rw-r--r--libbindgen/tests/expectations/tests/union_with_anon_unnamed_struct.rs61
-rw-r--r--libbindgen/tests/expectations/tests/union_with_anon_unnamed_union.rs60
-rw-r--r--libbindgen/tests/expectations/tests/union_with_big_member.rs75
-rw-r--r--libbindgen/tests/expectations/tests/union_with_nesting.rs89
-rw-r--r--libbindgen/tests/expectations/tests/unknown_attr.rs16
-rw-r--r--libbindgen/tests/expectations/tests/use-core.rs24
-rw-r--r--libbindgen/tests/expectations/tests/using.rs14
-rw-r--r--libbindgen/tests/expectations/tests/vector.rs19
-rw-r--r--libbindgen/tests/expectations/tests/virtual_dtor.rs19
-rw-r--r--libbindgen/tests/expectations/tests/virtual_overloaded.rs22
-rw-r--r--libbindgen/tests/expectations/tests/vtable_recursive_sig.rs35
-rw-r--r--libbindgen/tests/expectations/tests/weird_bitfields.rs128
-rw-r--r--libbindgen/tests/expectations/tests/what_is_going_on.rs28
-rw-r--r--libbindgen/tests/expectations/tests/whitelist_basic.rs18
-rw-r--r--libbindgen/tests/expectations/tests/whitelist_vars.rs10
-rw-r--r--libbindgen/tests/headers/accessors.hpp46
-rw-r--r--libbindgen/tests/headers/annotation_hide.hpp16
-rw-r--r--libbindgen/tests/headers/anon_enum.hpp5
-rw-r--r--libbindgen/tests/headers/anon_enum_whitelist.h6
-rw-r--r--libbindgen/tests/headers/anon_union.hpp20
-rw-r--r--libbindgen/tests/headers/arg_keyword.hpp1
-rw-r--r--libbindgen/tests/headers/base-to-derived.hpp19
-rw-r--r--libbindgen/tests/headers/bitfield-enum-basic.h27
-rw-r--r--libbindgen/tests/headers/blocks.h3
-rw-r--r--libbindgen/tests/headers/class.hpp29
-rw-r--r--libbindgen/tests/headers/class_nested.hpp24
-rw-r--r--libbindgen/tests/headers/class_no_members.hpp16
-rw-r--r--libbindgen/tests/headers/class_static.hpp7
-rw-r--r--libbindgen/tests/headers/class_static_const.hpp8
-rw-r--r--libbindgen/tests/headers/class_use_as.hpp15
-rw-r--r--libbindgen/tests/headers/class_with_dtor.hpp13
-rw-r--r--libbindgen/tests/headers/class_with_inner_struct.hpp43
-rw-r--r--libbindgen/tests/headers/class_with_typedef.hpp22
-rw-r--r--libbindgen/tests/headers/complex.h16
-rw-r--r--libbindgen/tests/headers/complex_global.h3
-rw-r--r--libbindgen/tests/headers/const_enum_unnamed.hpp9
-rw-r--r--libbindgen/tests/headers/const_ptr.hpp3
-rw-r--r--libbindgen/tests/headers/const_resolved_ty.h3
-rw-r--r--libbindgen/tests/headers/const_tparam.hpp5
-rw-r--r--libbindgen/tests/headers/convert-floats.h9
-rw-r--r--libbindgen/tests/headers/crtp.hpp12
-rw-r--r--libbindgen/tests/headers/decl_extern_int_twice.h2
-rw-r--r--libbindgen/tests/headers/decl_ptr_to_array.h1
-rw-r--r--libbindgen/tests/headers/duplicated_constants_in_ns.hpp7
-rw-r--r--libbindgen/tests/headers/elaborated.hpp5
-rw-r--r--libbindgen/tests/headers/empty_template_param_name.hpp4
-rw-r--r--libbindgen/tests/headers/enum.h9
-rw-r--r--libbindgen/tests/headers/enum_alias.hpp7
-rw-r--r--libbindgen/tests/headers/enum_and_vtable_mangling.hpp11
-rw-r--r--libbindgen/tests/headers/enum_dupe.h4
-rw-r--r--libbindgen/tests/headers/enum_explicit_type.hpp28
-rw-r--r--libbindgen/tests/headers/enum_negative.h4
-rw-r--r--libbindgen/tests/headers/enum_packed.h14
-rw-r--r--libbindgen/tests/headers/extern.hpp3
-rw-r--r--libbindgen/tests/headers/float128.hpp13
-rw-r--r--libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp8
-rw-r--r--libbindgen/tests/headers/forward-inherit-struct.hpp5
-rw-r--r--libbindgen/tests/headers/forward_declared_struct.h11
-rw-r--r--libbindgen/tests/headers/func_proto.h1
-rw-r--r--libbindgen/tests/headers/func_ptr.h1
-rw-r--r--libbindgen/tests/headers/func_ptr_in_struct.h6
-rw-r--r--libbindgen/tests/headers/func_with_array_arg.h1
-rw-r--r--libbindgen/tests/headers/func_with_func_ptr_arg.h1
-rw-r--r--libbindgen/tests/headers/in_class_typedef.hpp10
-rw-r--r--libbindgen/tests/headers/inherit-namespaced.hpp4
-rw-r--r--libbindgen/tests/headers/inherit_named.hpp5
-rw-r--r--libbindgen/tests/headers/inherit_typedef.hpp5
-rw-r--r--libbindgen/tests/headers/inner_const.hpp6
-rw-r--r--libbindgen/tests/headers/inner_template_self.hpp10
-rw-r--r--libbindgen/tests/headers/int128_t.h7
-rw-r--r--libbindgen/tests/headers/jsval_layout_opaque.hpp424
-rw-r--r--libbindgen/tests/headers/keywords.h49
-rw-r--r--libbindgen/tests/headers/macro-expr-basic.h14
-rw-r--r--libbindgen/tests/headers/macro-redef.h5
-rw-r--r--libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp3
-rw-r--r--libbindgen/tests/headers/mutable.hpp14
-rw-r--r--libbindgen/tests/headers/namespace.hpp47
-rw-r--r--libbindgen/tests/headers/nested.hpp15
-rw-r--r--libbindgen/tests/headers/nested_vtable.hpp8
-rw-r--r--libbindgen/tests/headers/no-std.h5
-rw-r--r--libbindgen/tests/headers/no_copy.hpp6
-rw-r--r--libbindgen/tests/headers/nsStyleAutoArray.hpp57
-rw-r--r--libbindgen/tests/headers/only_bitfields.hpp5
-rw-r--r--libbindgen/tests/headers/opaque_in_struct.hpp10
-rw-r--r--libbindgen/tests/headers/opaque_pointer.hpp22
-rw-r--r--libbindgen/tests/headers/opaque_typedef.hpp17
-rw-r--r--libbindgen/tests/headers/overflowed_enum.hpp12
-rw-r--r--libbindgen/tests/headers/overloading.hpp9
-rw-r--r--libbindgen/tests/headers/private.hpp21
-rw-r--r--libbindgen/tests/headers/redeclaration.hpp7
-rw-r--r--libbindgen/tests/headers/ref_argument_array.hpp6
-rw-r--r--libbindgen/tests/headers/replace_template_alias.hpp23
-rw-r--r--libbindgen/tests/headers/replaces_double.hpp20
-rw-r--r--libbindgen/tests/headers/size_t_template.hpp8
-rw-r--r--libbindgen/tests/headers/struct_containing_forward_declared_struct.h7
-rw-r--r--libbindgen/tests/headers/struct_with_anon_struct.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_struct_array.h10
-rw-r--r--libbindgen/tests/headers/struct_with_anon_struct_pointer.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_union.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_unnamed_struct.h6
-rw-r--r--libbindgen/tests/headers/struct_with_anon_unnamed_union.h6
-rw-r--r--libbindgen/tests/headers/struct_with_bitfields.h13
-rw-r--r--libbindgen/tests/headers/struct_with_derive_debug.h15
-rw-r--r--libbindgen/tests/headers/struct_with_nesting.h17
-rw-r--r--libbindgen/tests/headers/struct_with_packing.h4
-rw-r--r--libbindgen/tests/headers/struct_with_struct.h6
-rw-r--r--libbindgen/tests/headers/struct_with_typedef_template_arg.hpp4
-rw-r--r--libbindgen/tests/headers/template.hpp144
-rw-r--r--libbindgen/tests/headers/template_alias.hpp13
-rw-r--r--libbindgen/tests/headers/template_alias_basic.hpp4
-rw-r--r--libbindgen/tests/headers/template_alias_namespace.hpp13
-rw-r--r--libbindgen/tests/headers/template_typedef_transitive_param.hpp7
-rw-r--r--libbindgen/tests/headers/template_typedefs.hpp8
-rw-r--r--libbindgen/tests/headers/type_alias_empty.hpp10
-rw-r--r--libbindgen/tests/headers/typeref.hpp28
-rw-r--r--libbindgen/tests/headers/union_dtor.hpp5
-rw-r--r--libbindgen/tests/headers/union_fields.hpp5
-rw-r--r--libbindgen/tests/headers/union_template.hpp19
-rw-r--r--libbindgen/tests/headers/union_with_anon_struct.h6
-rw-r--r--libbindgen/tests/headers/union_with_anon_struct_bitfield.h8
-rw-r--r--libbindgen/tests/headers/union_with_anon_union.h6
-rw-r--r--libbindgen/tests/headers/union_with_anon_unnamed_struct.h9
-rw-r--r--libbindgen/tests/headers/union_with_anon_unnamed_union.h7
-rw-r--r--libbindgen/tests/headers/union_with_big_member.h14
-rw-r--r--libbindgen/tests/headers/union_with_nesting.h14
-rw-r--r--libbindgen/tests/headers/unknown_attr.h6
-rw-r--r--libbindgen/tests/headers/use-core.h8
-rw-r--r--libbindgen/tests/headers/using.hpp11
-rw-r--r--libbindgen/tests/headers/vector.hpp3
-rw-r--r--libbindgen/tests/headers/virtual_dtor.hpp3
-rw-r--r--libbindgen/tests/headers/virtual_overloaded.hpp5
-rw-r--r--libbindgen/tests/headers/vtable_recursive_sig.hpp11
-rw-r--r--libbindgen/tests/headers/weird_bitfields.hpp35
-rw-r--r--libbindgen/tests/headers/what_is_going_on.hpp19
-rw-r--r--libbindgen/tests/headers/whitelist_basic.hpp16
-rw-r--r--libbindgen/tests/headers/whitelist_vars.h4
-rw-r--r--libbindgen/tests/tests.rs138
-rw-r--r--libbindgen/tests/uses/.gitignore2
246 files changed, 6861 insertions, 0 deletions
diff --git a/libbindgen/tests/expectations/Cargo.toml b/libbindgen/tests/expectations/Cargo.toml
new file mode 100644
index 00000000..53f1b14f
--- /dev/null
+++ b/libbindgen/tests/expectations/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "tests_expectations"
+description = "bindgen results when ran on ../headers/*"
+version = "0.1.0"
+authors = [
+ "Jyun-Yan You <jyyou.tw@gmail.com>",
+ "Emilio Cobos Álvarez <ecoal95@gmail.com>",
+ "The Servo project developers",
+]
+
+[dependencies]
diff --git a/libbindgen/tests/expectations/src/lib.rs b/libbindgen/tests/expectations/src/lib.rs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/libbindgen/tests/expectations/src/lib.rs
diff --git a/libbindgen/tests/expectations/tests/accessors.rs b/libbindgen/tests/expectations/tests/accessors.rs
new file mode 100644
index 00000000..b721980c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/accessors.rs
@@ -0,0 +1,204 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct SomeAccessors {
+ pub mNoAccessor: ::std::os::raw::c_int,
+ /** <div rustbindgen accessor></div> */
+ pub mBothAccessors: ::std::os::raw::c_int,
+ /** <div rustbindgen accessor="unsafe"></div> */
+ pub mUnsafeAccessors: ::std::os::raw::c_int,
+ /** <div rustbindgen accessor="immutable"></div> */
+ pub mImmutableAccessor: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_SomeAccessors() {
+ assert_eq!(::std::mem::size_of::<SomeAccessors>() , 16usize);
+ assert_eq!(::std::mem::align_of::<SomeAccessors>() , 4usize);
+}
+impl Clone for SomeAccessors {
+ fn clone(&self) -> Self { *self }
+}
+impl SomeAccessors {
+ #[inline]
+ pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mBothAccessors
+ }
+ #[inline]
+ pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int {
+ &mut self.mBothAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mUnsafeAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mUnsafeAccessors_mut(&mut self)
+ -> &mut ::std::os::raw::c_int {
+ &mut self.mUnsafeAccessors
+ }
+ #[inline]
+ pub fn get_mImmutableAccessor(&self) -> &::std::os::raw::c_int {
+ &self.mImmutableAccessor
+ }
+}
+/** <div rustbindgen accessor></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct AllAccessors {
+ pub mBothAccessors: ::std::os::raw::c_int,
+ pub mAlsoBothAccessors: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_AllAccessors() {
+ assert_eq!(::std::mem::size_of::<AllAccessors>() , 8usize);
+ assert_eq!(::std::mem::align_of::<AllAccessors>() , 4usize);
+}
+impl Clone for AllAccessors {
+ fn clone(&self) -> Self { *self }
+}
+impl AllAccessors {
+ #[inline]
+ pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mBothAccessors
+ }
+ #[inline]
+ pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int {
+ &mut self.mBothAccessors
+ }
+ #[inline]
+ pub fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mAlsoBothAccessors
+ }
+ #[inline]
+ pub fn get_mAlsoBothAccessors_mut(&mut self)
+ -> &mut ::std::os::raw::c_int {
+ &mut self.mAlsoBothAccessors
+ }
+}
+/** <div rustbindgen accessor="unsafe"></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct AllUnsafeAccessors {
+ pub mBothAccessors: ::std::os::raw::c_int,
+ pub mAlsoBothAccessors: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_AllUnsafeAccessors() {
+ assert_eq!(::std::mem::size_of::<AllUnsafeAccessors>() , 8usize);
+ assert_eq!(::std::mem::align_of::<AllUnsafeAccessors>() , 4usize);
+}
+impl Clone for AllUnsafeAccessors {
+ fn clone(&self) -> Self { *self }
+}
+impl AllUnsafeAccessors {
+ #[inline]
+ pub unsafe fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mBothAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mBothAccessors_mut(&mut self)
+ -> &mut ::std::os::raw::c_int {
+ &mut self.mBothAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mAlsoBothAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mAlsoBothAccessors_mut(&mut self)
+ -> &mut ::std::os::raw::c_int {
+ &mut self.mAlsoBothAccessors
+ }
+}
+/** <div rustbindgen accessor></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct ContradictAccessors {
+ pub mBothAccessors: ::std::os::raw::c_int,
+ /** <div rustbindgen accessor="false"></div> */
+ pub mNoAccessors: ::std::os::raw::c_int,
+ /** <div rustbindgen accessor="unsafe"></div> */
+ pub mUnsafeAccessors: ::std::os::raw::c_int,
+ /** <div rustbindgen accessor="immutable"></div> */
+ pub mImmutableAccessor: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_ContradictAccessors() {
+ assert_eq!(::std::mem::size_of::<ContradictAccessors>() , 16usize);
+ assert_eq!(::std::mem::align_of::<ContradictAccessors>() , 4usize);
+}
+impl Clone for ContradictAccessors {
+ fn clone(&self) -> Self { *self }
+}
+impl ContradictAccessors {
+ #[inline]
+ pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mBothAccessors
+ }
+ #[inline]
+ pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int {
+ &mut self.mBothAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int {
+ &self.mUnsafeAccessors
+ }
+ #[inline]
+ pub unsafe fn get_mUnsafeAccessors_mut(&mut self)
+ -> &mut ::std::os::raw::c_int {
+ &mut self.mUnsafeAccessors
+ }
+ #[inline]
+ pub fn get_mImmutableAccessor(&self) -> &::std::os::raw::c_int {
+ &self.mImmutableAccessor
+ }
+}
+/** <div rustbindgen accessor replaces="Replaced"></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Replaced {
+ pub mAccessor: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_Replaced() {
+ assert_eq!(::std::mem::size_of::<Replaced>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Replaced>() , 4usize);
+}
+impl Clone for Replaced {
+ fn clone(&self) -> Self { *self }
+}
+impl Replaced {
+ #[inline]
+ pub fn get_mAccessor(&self) -> &::std::os::raw::c_int { &self.mAccessor }
+ #[inline]
+ pub fn get_mAccessor_mut(&mut self) -> &mut ::std::os::raw::c_int {
+ &mut self.mAccessor
+ }
+}
+/** <div rustbindgen accessor></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Wrapper {
+ pub mReplaced: Replaced,
+}
+#[test]
+fn bindgen_test_layout_Wrapper() {
+ assert_eq!(::std::mem::size_of::<Wrapper>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Wrapper>() , 4usize);
+}
+impl Clone for Wrapper {
+ fn clone(&self) -> Self { *self }
+}
+impl Wrapper {
+ #[inline]
+ pub fn get_mReplaced(&self) -> &Replaced { &self.mReplaced }
+ #[inline]
+ pub fn get_mReplaced_mut(&mut self) -> &mut Replaced {
+ &mut self.mReplaced
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/annotation_hide.rs b/libbindgen/tests/expectations/tests/annotation_hide.rs
new file mode 100644
index 00000000..dcaf7997
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/annotation_hide.rs
@@ -0,0 +1,35 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct D {
+ pub _bindgen_opaque_blob: u32,
+}
+#[test]
+fn bindgen_test_layout_D() {
+ assert_eq!(::std::mem::size_of::<D>() , 4usize);
+ assert_eq!(::std::mem::align_of::<D>() , 4usize);
+}
+impl Clone for D {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct NotAnnotated {
+ pub f: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_NotAnnotated() {
+ assert_eq!(::std::mem::size_of::<NotAnnotated>() , 4usize);
+ assert_eq!(::std::mem::align_of::<NotAnnotated>() , 4usize);
+}
+impl Clone for NotAnnotated {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/anon_enum.rs b/libbindgen/tests/expectations/tests/anon_enum.rs
new file mode 100644
index 00000000..075830e6
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/anon_enum.rs
@@ -0,0 +1,24 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Test {
+ pub foo: ::std::os::raw::c_int,
+ pub bar: f32,
+}
+pub const Test_T_NONE: Test__bindgen_ty_1 = Test__bindgen_ty_1::T_NONE;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Test__bindgen_ty_1 { T_NONE = 0, }
+#[test]
+fn bindgen_test_layout_Test() {
+ assert_eq!(::std::mem::size_of::<Test>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Test>() , 4usize);
+}
+impl Clone for Test {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/anon_enum_whitelist.rs b/libbindgen/tests/expectations/tests/anon_enum_whitelist.rs
new file mode 100644
index 00000000..b32396a0
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/anon_enum_whitelist.rs
@@ -0,0 +1,11 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const NODE_FLAG_FOO: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_FOO;
+pub const NODE_FLAG_BAR: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_BAR;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum _bindgen_ty_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, }
diff --git a/libbindgen/tests/expectations/tests/anon_union.rs b/libbindgen/tests/expectations/tests/anon_union.rs
new file mode 100644
index 00000000..8af416c3
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/anon_union.rs
@@ -0,0 +1,77 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct TErrorResult<T> {
+ pub mResult: ::std::os::raw::c_int,
+ pub __bindgen_anon_1: TErrorResult__bindgen_ty_1<T>,
+ pub mMightHaveUnreported: bool,
+ pub mUnionState: TErrorResult_UnionState,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState =
+ TErrorResult_UnionState::HasMessage;
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum TErrorResult_UnionState { HasMessage = 0, }
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct TErrorResult_Message<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct TErrorResult_DOMExceptionInfo<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct TErrorResult__bindgen_ty_1<T> {
+ pub mMessage: __BindgenUnionField<*mut TErrorResult_Message<T>>,
+ pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo<T>>,
+ pub bindgen_union_field: u64,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct ErrorResult {
+ pub _base: TErrorResult<::std::os::raw::c_int>,
+}
+#[test]
+fn bindgen_test_layout_ErrorResult() {
+ assert_eq!(::std::mem::size_of::<ErrorResult>() , 24usize);
+ assert_eq!(::std::mem::align_of::<ErrorResult>() , 8usize);
+}
+impl Clone for ErrorResult {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/arg_keyword.rs b/libbindgen/tests/expectations/tests/arg_keyword.rs
new file mode 100644
index 00000000..cb1cc432
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/arg_keyword.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "_Z3fooPKc"]
+ pub fn foo(type_: *const ::std::os::raw::c_char);
+}
diff --git a/libbindgen/tests/expectations/tests/base-to-derived.rs b/libbindgen/tests/expectations/tests/base-to-derived.rs
new file mode 100644
index 00000000..c2af2c43
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/base-to-derived.rs
@@ -0,0 +1,19 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct false_type {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_false_type() {
+ assert_eq!(::std::mem::size_of::<false_type>() , 1usize);
+ assert_eq!(::std::mem::align_of::<false_type>() , 1usize);
+}
+impl Clone for false_type {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/bitfield-enum-basic.rs b/libbindgen/tests/expectations/tests/bitfield-enum-basic.rs
new file mode 100644
index 00000000..03e07de6
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/bitfield-enum-basic.rs
@@ -0,0 +1,77 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const Foo_Bar: Foo = Foo(2);
+pub const Foo_Baz: Foo = Foo(4);
+pub const Foo_Duplicated: Foo = Foo(4);
+pub const Foo_Negative: Foo = Foo(-3);
+impl ::std::ops::BitOr<Foo> for Foo {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitor(self, other: Self) -> Self { Foo(self.0 | other.0) }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct Foo(pub i32);
+pub const Buz_Bar: Buz = Buz(2);
+pub const Buz_Baz: Buz = Buz(4);
+pub const Buz_Duplicated: Buz = Buz(4);
+pub const Buz_Negative: Buz = Buz(-3);
+impl ::std::ops::BitOr<Buz> for Buz {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitor(self, other: Self) -> Self { Buz(self.0 | other.0) }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct Buz(pub i8);
+pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
+pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2);
+impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitor(self, other: Self) -> Self { _bindgen_ty_1(self.0 | other.0) }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct _bindgen_ty_1(pub u32);
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Dummy {
+ pub _address: u8,
+}
+pub const Dummy_DUMMY_FOO: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(1);
+pub const Dummy_DUMMY_BAR: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(2);
+impl ::std::ops::BitOr<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 {
+ type
+ Output
+ =
+ Self;
+ #[inline]
+ fn bitor(self, other: Self) -> Self {
+ Dummy__bindgen_ty_1(self.0 | other.0)
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct Dummy__bindgen_ty_1(pub u32);
+#[test]
+fn bindgen_test_layout_Dummy() {
+ assert_eq!(::std::mem::size_of::<Dummy>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Dummy>() , 1usize);
+}
+impl Clone for Dummy {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/blocks.rs b/libbindgen/tests/expectations/tests/blocks.rs
new file mode 100644
index 00000000..528ea518
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/blocks.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn atexit_b(arg1: *mut ::std::os::raw::c_void);
+}
diff --git a/libbindgen/tests/expectations/tests/class.rs b/libbindgen/tests/expectations/tests/class.rs
new file mode 100644
index 00000000..579c24a4
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class.rs
@@ -0,0 +1,127 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+pub struct C {
+ pub a: ::std::os::raw::c_int,
+ pub big_array: [::std::os::raw::c_char; 33usize],
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 40usize);
+ assert_eq!(::std::mem::align_of::<C>() , 4usize);
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct WithDtor {
+ pub b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_WithDtor() {
+ assert_eq!(::std::mem::size_of::<WithDtor>() , 4usize);
+ assert_eq!(::std::mem::align_of::<WithDtor>() , 4usize);
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Union {
+ pub d: __BindgenUnionField<f32>,
+ pub i: __BindgenUnionField<::std::os::raw::c_int>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_Union() {
+ assert_eq!(::std::mem::size_of::<Union>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Union>() , 4usize);
+}
+impl Clone for Union {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct WithUnion {
+ pub data: Union,
+}
+#[test]
+fn bindgen_test_layout_WithUnion() {
+ assert_eq!(::std::mem::size_of::<WithUnion>() , 4usize);
+ assert_eq!(::std::mem::align_of::<WithUnion>() , 4usize);
+}
+impl Clone for WithUnion {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct RealAbstractionWithTonsOfMethods {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() {
+ assert_eq!(::std::mem::size_of::<RealAbstractionWithTonsOfMethods>() ,
+ 1usize);
+ assert_eq!(::std::mem::align_of::<RealAbstractionWithTonsOfMethods>() ,
+ 1usize);
+}
+extern "C" {
+ #[link_name = "_ZNK32RealAbstractionWithTonsOfMethods3barEv"]
+ pub fn RealAbstractionWithTonsOfMethods_bar(this:
+ *const RealAbstractionWithTonsOfMethods);
+}
+extern "C" {
+ #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEv"]
+ pub fn RealAbstractionWithTonsOfMethods_bar1(this:
+ *mut RealAbstractionWithTonsOfMethods);
+}
+extern "C" {
+ #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEi"]
+ pub fn RealAbstractionWithTonsOfMethods_bar2(this:
+ *mut RealAbstractionWithTonsOfMethods,
+ foo: ::std::os::raw::c_int);
+}
+extern "C" {
+ #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3staEv"]
+ pub fn RealAbstractionWithTonsOfMethods_sta();
+}
+impl Clone for RealAbstractionWithTonsOfMethods {
+ fn clone(&self) -> Self { *self }
+}
+impl RealAbstractionWithTonsOfMethods {
+ #[inline]
+ pub unsafe fn bar(&self) { RealAbstractionWithTonsOfMethods_bar(&*self) }
+ #[inline]
+ pub unsafe fn bar1(&mut self) {
+ RealAbstractionWithTonsOfMethods_bar1(&mut *self)
+ }
+ #[inline]
+ pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) {
+ RealAbstractionWithTonsOfMethods_bar2(&mut *self, foo)
+ }
+ #[inline]
+ pub unsafe fn sta() { RealAbstractionWithTonsOfMethods_sta() }
+}
diff --git a/libbindgen/tests/expectations/tests/class_nested.rs b/libbindgen/tests/expectations/tests/class_nested.rs
new file mode 100644
index 00000000..593e156d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_nested.rs
@@ -0,0 +1,59 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A {
+ pub member_a: ::std::os::raw::c_int,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A_B {
+ pub member_b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_A_B() {
+ assert_eq!(::std::mem::size_of::<A_B>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A_B>() , 4usize);
+}
+impl Clone for A_B {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_A() {
+ assert_eq!(::std::mem::size_of::<A>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A>() , 4usize);
+}
+impl Clone for A {
+ fn clone(&self) -> Self { *self }
+}
+extern "C" {
+ #[link_name = "var"]
+ pub static mut var: A_B;
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct D {
+ pub member: A_B,
+}
+#[test]
+fn bindgen_test_layout_D() {
+ assert_eq!(::std::mem::size_of::<D>() , 4usize);
+ assert_eq!(::std::mem::align_of::<D>() , 4usize);
+}
+impl Clone for D {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Templated<T> {
+ pub member: T,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Templated_Templated_inner<T> {
+ pub member_ptr: *mut T,
+}
diff --git a/libbindgen/tests/expectations/tests/class_no_members.rs b/libbindgen/tests/expectations/tests/class_no_members.rs
new file mode 100644
index 00000000..017f7c22
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_no_members.rs
@@ -0,0 +1,45 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct whatever {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_whatever() {
+ assert_eq!(::std::mem::size_of::<whatever>() , 1usize);
+ assert_eq!(::std::mem::align_of::<whatever>() , 1usize);
+}
+impl Clone for whatever {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct whatever_child {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_whatever_child() {
+ assert_eq!(::std::mem::size_of::<whatever_child>() , 1usize);
+ assert_eq!(::std::mem::align_of::<whatever_child>() , 1usize);
+}
+impl Clone for whatever_child {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct whatever_child_with_member {
+ pub m_member: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_whatever_child_with_member() {
+ assert_eq!(::std::mem::size_of::<whatever_child_with_member>() , 4usize);
+ assert_eq!(::std::mem::align_of::<whatever_child_with_member>() , 4usize);
+}
+impl Clone for whatever_child_with_member {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/class_static.rs b/libbindgen/tests/expectations/tests/class_static.rs
new file mode 100644
index 00000000..8108be2d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_static.rs
@@ -0,0 +1,32 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct MyClass {
+ pub _address: u8,
+}
+extern "C" {
+ #[link_name = "_ZN7MyClass7exampleE"]
+ pub static mut MyClass_example: *const ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "_ZN7MyClass26example_check_no_collisionE"]
+ pub static mut MyClass_example_check_no_collision:
+ *const ::std::os::raw::c_int;
+}
+#[test]
+fn bindgen_test_layout_MyClass() {
+ assert_eq!(::std::mem::size_of::<MyClass>() , 1usize);
+ assert_eq!(::std::mem::align_of::<MyClass>() , 1usize);
+}
+impl Clone for MyClass {
+ fn clone(&self) -> Self { *self }
+}
+extern "C" {
+ #[link_name = "_ZL26example_check_no_collision"]
+ pub static mut example_check_no_collision: *const ::std::os::raw::c_int;
+}
diff --git a/libbindgen/tests/expectations/tests/class_static_const.rs b/libbindgen/tests/expectations/tests/class_static_const.rs
new file mode 100644
index 00000000..eed6590c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_static_const.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A {
+ pub _address: u8,
+}
+pub const A_a: ::std::os::raw::c_int = 0;
+pub const A_b: i32 = 63;
+pub const A_c: u32 = 255;
+#[test]
+fn bindgen_test_layout_A() {
+ assert_eq!(::std::mem::size_of::<A>() , 1usize);
+ assert_eq!(::std::mem::align_of::<A>() , 1usize);
+}
+impl Clone for A {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/class_use_as.rs b/libbindgen/tests/expectations/tests/class_use_as.rs
new file mode 100644
index 00000000..c3843b31
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_use_as.rs
@@ -0,0 +1,35 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+/**
+ * <div rustbindgen="true" replaces="whatever"></div>
+ */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct whatever {
+ pub replacement: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_whatever() {
+ assert_eq!(::std::mem::size_of::<whatever>() , 4usize);
+ assert_eq!(::std::mem::align_of::<whatever>() , 4usize);
+}
+impl Clone for whatever {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct container {
+ pub c: whatever,
+}
+#[test]
+fn bindgen_test_layout_container() {
+ assert_eq!(::std::mem::size_of::<container>() , 4usize);
+ assert_eq!(::std::mem::align_of::<container>() , 4usize);
+}
+impl Clone for container {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/class_with_dtor.rs b/libbindgen/tests/expectations/tests/class_with_dtor.rs
new file mode 100644
index 00000000..8ed1ddf9
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_with_dtor.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct HandleWithDtor<T> {
+ pub ptr: *mut T,
+}
+pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>;
+#[repr(C)]
+#[derive(Debug)]
+pub struct WithoutDtor {
+ pub shouldBeWithDtor: HandleValue,
+}
+#[test]
+fn bindgen_test_layout_WithoutDtor() {
+ assert_eq!(::std::mem::size_of::<WithoutDtor>() , 8usize);
+ assert_eq!(::std::mem::align_of::<WithoutDtor>() , 8usize);
+}
diff --git a/libbindgen/tests/expectations/tests/class_with_inner_struct.rs b/libbindgen/tests/expectations/tests/class_with_inner_struct.rs
new file mode 100644
index 00000000..ab51396d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_with_inner_struct.rs
@@ -0,0 +1,195 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A {
+ pub c: ::std::os::raw::c_uint,
+ pub named_union: A__bindgen_ty_1,
+ pub __bindgen_anon_1: A__bindgen_ty_2,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A_Segment {
+ pub begin: ::std::os::raw::c_int,
+ pub end: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_A_Segment() {
+ assert_eq!(::std::mem::size_of::<A_Segment>() , 8usize);
+ assert_eq!(::std::mem::align_of::<A_Segment>() , 4usize);
+}
+impl Clone for A_Segment {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A__bindgen_ty_1 {
+ pub f: __BindgenUnionField<::std::os::raw::c_int>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_A__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<A__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A__bindgen_ty_1>() , 4usize);
+}
+impl Clone for A__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct A__bindgen_ty_2 {
+ pub d: __BindgenUnionField<::std::os::raw::c_int>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_A__bindgen_ty_2() {
+ assert_eq!(::std::mem::size_of::<A__bindgen_ty_2>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A__bindgen_ty_2>() , 4usize);
+}
+impl Clone for A__bindgen_ty_2 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_A() {
+ assert_eq!(::std::mem::size_of::<A>() , 12usize);
+ assert_eq!(::std::mem::align_of::<A>() , 4usize);
+}
+impl Clone for A {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct B {
+ pub d: ::std::os::raw::c_uint,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct B_Segment {
+ pub begin: ::std::os::raw::c_int,
+ pub end: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_B_Segment() {
+ assert_eq!(::std::mem::size_of::<B_Segment>() , 8usize);
+ assert_eq!(::std::mem::align_of::<B_Segment>() , 4usize);
+}
+impl Clone for B_Segment {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_B() {
+ assert_eq!(::std::mem::size_of::<B>() , 4usize);
+ assert_eq!(::std::mem::align_of::<B>() , 4usize);
+}
+impl Clone for B {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum StepSyntax {
+ Keyword = 0,
+ FunctionalWithoutKeyword = 1,
+ FunctionalWithStartKeyword = 2,
+ FunctionalWithEndKeyword = 3,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub d: ::std::os::raw::c_uint,
+ pub __bindgen_anon_1: C__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C__bindgen_ty_1 {
+ pub mFunc: __BindgenUnionField<C__bindgen_ty_1_1>,
+ pub __bindgen_anon_1: __BindgenUnionField<C__bindgen_ty_1_2>,
+ pub bindgen_union_field: [u32; 4usize],
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C__bindgen_ty_1_1 {
+ pub mX1: f32,
+ pub mY1: f32,
+ pub mX2: f32,
+ pub mY2: f32,
+}
+#[test]
+fn bindgen_test_layout_C__bindgen_ty_1_1() {
+ assert_eq!(::std::mem::size_of::<C__bindgen_ty_1_1>() , 16usize);
+ assert_eq!(::std::mem::align_of::<C__bindgen_ty_1_1>() , 4usize);
+}
+impl Clone for C__bindgen_ty_1_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C__bindgen_ty_1_2 {
+ pub mStepSyntax: StepSyntax,
+ pub mSteps: ::std::os::raw::c_uint,
+}
+#[test]
+fn bindgen_test_layout_C__bindgen_ty_1_2() {
+ assert_eq!(::std::mem::size_of::<C__bindgen_ty_1_2>() , 8usize);
+ assert_eq!(::std::mem::align_of::<C__bindgen_ty_1_2>() , 4usize);
+}
+impl Clone for C__bindgen_ty_1_2 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_C__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<C__bindgen_ty_1>() , 16usize);
+ assert_eq!(::std::mem::align_of::<C__bindgen_ty_1>() , 4usize);
+}
+impl Clone for C__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C_Segment {
+ pub begin: ::std::os::raw::c_int,
+ pub end: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_C_Segment() {
+ assert_eq!(::std::mem::size_of::<C_Segment>() , 8usize);
+ assert_eq!(::std::mem::align_of::<C_Segment>() , 4usize);
+}
+impl Clone for C_Segment {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 20usize);
+ assert_eq!(::std::mem::align_of::<C>() , 4usize);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/class_with_typedef.rs b/libbindgen/tests/expectations/tests/class_with_typedef.rs
new file mode 100644
index 00000000..bc19f2bd
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/class_with_typedef.rs
@@ -0,0 +1,72 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type AnotherInt = ::std::os::raw::c_int;
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub c: C_MyInt,
+ pub ptr: *mut C_MyInt,
+ pub arr: [C_MyInt; 10usize],
+ pub d: AnotherInt,
+ pub other_ptr: *mut AnotherInt,
+}
+pub type C_MyInt = ::std::os::raw::c_int;
+pub type C_Lookup = *const ::std::os::raw::c_char;
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 72usize);
+ assert_eq!(::std::mem::align_of::<C>() , 8usize);
+}
+extern "C" {
+ #[link_name = "_ZN1C6methodEi"]
+ pub fn C_method(this: *mut C, c: C_MyInt);
+}
+extern "C" {
+ #[link_name = "_ZN1C9methodRefERi"]
+ pub fn C_methodRef(this: *mut C, c: *mut C_MyInt);
+}
+extern "C" {
+ #[link_name = "_ZN1C16complexMethodRefERPKc"]
+ pub fn C_complexMethodRef(this: *mut C, c: *mut C_Lookup);
+}
+extern "C" {
+ #[link_name = "_ZN1C13anotherMethodEi"]
+ pub fn C_anotherMethod(this: *mut C, c: AnotherInt);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
+impl C {
+ #[inline]
+ pub unsafe fn method(&mut self, c: C_MyInt) { C_method(&mut *self, c) }
+ #[inline]
+ pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) {
+ C_methodRef(&mut *self, c)
+ }
+ #[inline]
+ pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) {
+ C_complexMethodRef(&mut *self, c)
+ }
+ #[inline]
+ pub unsafe fn anotherMethod(&mut self, c: AnotherInt) {
+ C_anotherMethod(&mut *self, c)
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct D {
+ pub _base: C,
+ pub ptr: *mut C_MyInt,
+}
+#[test]
+fn bindgen_test_layout_D() {
+ assert_eq!(::std::mem::size_of::<D>() , 80usize);
+ assert_eq!(::std::mem::align_of::<D>() , 8usize);
+}
+impl Clone for D {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/complex.rs b/libbindgen/tests/expectations/tests/complex.rs
new file mode 100644
index 00000000..f2a97952
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/complex.rs
@@ -0,0 +1,64 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
+#[repr(C)]
+pub struct __BindgenComplex<T> {
+ pub re: T,
+ pub im: T,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct TestDouble {
+ pub mMember: __BindgenComplex<f64>,
+}
+#[test]
+fn bindgen_test_layout_TestDouble() {
+ assert_eq!(::std::mem::size_of::<TestDouble>() , 16usize);
+ assert_eq!(::std::mem::align_of::<TestDouble>() , 8usize);
+}
+impl Clone for TestDouble {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct TestDoublePtr {
+ pub mMember: *mut __BindgenComplex<f64>,
+}
+#[test]
+fn bindgen_test_layout_TestDoublePtr() {
+ assert_eq!(::std::mem::size_of::<TestDoublePtr>() , 8usize);
+ assert_eq!(::std::mem::align_of::<TestDoublePtr>() , 8usize);
+}
+impl Clone for TestDoublePtr {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct TestFloat {
+ pub mMember: __BindgenComplex<f32>,
+}
+#[test]
+fn bindgen_test_layout_TestFloat() {
+ assert_eq!(::std::mem::size_of::<TestFloat>() , 8usize);
+ assert_eq!(::std::mem::align_of::<TestFloat>() , 4usize);
+}
+impl Clone for TestFloat {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct TestFloatPtr {
+ pub mMember: *mut __BindgenComplex<f32>,
+}
+#[test]
+fn bindgen_test_layout_TestFloatPtr() {
+ assert_eq!(::std::mem::size_of::<TestFloatPtr>() , 8usize);
+ assert_eq!(::std::mem::align_of::<TestFloatPtr>() , 8usize);
+}
+impl Clone for TestFloatPtr {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/complex_global.rs b/libbindgen/tests/expectations/tests/complex_global.rs
new file mode 100644
index 00000000..badc4d1f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/complex_global.rs
@@ -0,0 +1,24 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
+#[repr(C)]
+pub struct __BindgenComplex<T> {
+ pub re: T,
+ pub im: T,
+}
+extern "C" {
+ #[link_name = "globalValueFloat"]
+ pub static mut globalValueFloat: __BindgenComplex<f32>;
+}
+extern "C" {
+ #[link_name = "globalValueDouble"]
+ pub static mut globalValueDouble: __BindgenComplex<f64>;
+}
+extern "C" {
+ #[link_name = "globalValueLongDouble"]
+ pub static mut globalValueLongDouble: __BindgenComplex<f64>;
+}
diff --git a/libbindgen/tests/expectations/tests/const_enum_unnamed.rs b/libbindgen/tests/expectations/tests/const_enum_unnamed.rs
new file mode 100644
index 00000000..0bd3987a
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/const_enum_unnamed.rs
@@ -0,0 +1,28 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const FOO_BAR: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAR;
+pub const FOO_BAZ: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAZ;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum _bindgen_ty_1 { FOO_BAR = 0, FOO_BAZ = 1, }
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Foo {
+ pub _address: u8,
+}
+pub const Foo_FOO_BAR: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::FOO_BAR;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo__bindgen_ty_1 { FOO_BAR = 10, }
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(::std::mem::size_of::<Foo>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Foo>() , 1usize);
+}
+impl Clone for Foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/const_ptr.rs b/libbindgen/tests/expectations/tests/const_ptr.rs
new file mode 100644
index 00000000..89400df1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/const_ptr.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn foo(bar: *const ::std::os::raw::c_void);
+}
diff --git a/libbindgen/tests/expectations/tests/const_resolved_ty.rs b/libbindgen/tests/expectations/tests/const_resolved_ty.rs
new file mode 100644
index 00000000..77d8f438
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/const_resolved_ty.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn foo(foo: *const u8);
+}
diff --git a/libbindgen/tests/expectations/tests/const_tparam.rs b/libbindgen/tests/expectations/tests/const_tparam.rs
new file mode 100644
index 00000000..3ed10d28
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/const_tparam.rs
@@ -0,0 +1,12 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct C<T> {
+ pub foo: *const T,
+ pub bar: *mut T,
+}
diff --git a/libbindgen/tests/expectations/tests/convert-floats.rs b/libbindgen/tests/expectations/tests/convert-floats.rs
new file mode 100644
index 00000000..5cd38c13
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/convert-floats.rs
@@ -0,0 +1,30 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
+#[repr(C)]
+pub struct __BindgenComplex<T> {
+ pub re: T,
+ pub im: T,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: ::std::os::raw::c_float,
+ pub baz: ::std::os::raw::c_float,
+ pub bazz: ::std::os::raw::c_double,
+ pub bazzz: *mut ::std::os::raw::c_double,
+ pub complexFloat: __BindgenComplex<::std::os::raw::c_float>,
+ pub complexDouble: __BindgenComplex<::std::os::raw::c_double>,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 48usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 8usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/crtp.rs b/libbindgen/tests/expectations/tests/crtp.rs
new file mode 100644
index 00000000..e4a86b24
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/crtp.rs
@@ -0,0 +1,43 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Base<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Derived {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Derived() {
+ assert_eq!(::std::mem::size_of::<Derived>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Derived>() , 1usize);
+}
+impl Clone for Derived {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct BaseWithDestructor<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct DerivedFromBaseWithDestructor {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_DerivedFromBaseWithDestructor() {
+ assert_eq!(::std::mem::size_of::<DerivedFromBaseWithDestructor>() ,
+ 1usize);
+ assert_eq!(::std::mem::align_of::<DerivedFromBaseWithDestructor>() ,
+ 1usize);
+}
diff --git a/libbindgen/tests/expectations/tests/decl_extern_int_twice.rs b/libbindgen/tests/expectations/tests/decl_extern_int_twice.rs
new file mode 100644
index 00000000..603a51b1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/decl_extern_int_twice.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "foo"]
+ pub static mut foo: ::std::os::raw::c_int;
+}
diff --git a/libbindgen/tests/expectations/tests/decl_ptr_to_array.rs b/libbindgen/tests/expectations/tests/decl_ptr_to_array.rs
new file mode 100644
index 00000000..b8abedb5
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/decl_ptr_to_array.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "foo"]
+ pub static mut foo: *mut [::std::os::raw::c_int; 1usize];
+}
diff --git a/libbindgen/tests/expectations/tests/duplicated_constants_in_ns.rs b/libbindgen/tests/expectations/tests/duplicated_constants_in_ns.rs
new file mode 100644
index 00000000..cb69890c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/duplicated_constants_in_ns.rs
@@ -0,0 +1,17 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub mod root {
+ use root;
+ pub mod foo {
+ use root;
+ pub const FOO: ::std::os::raw::c_int = 4;
+ }
+ pub mod bar {
+ use root;
+ pub const FOO: ::std::os::raw::c_int = 5;
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/elaborated.rs b/libbindgen/tests/expectations/tests/elaborated.rs
new file mode 100644
index 00000000..db373d41
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/elaborated.rs
@@ -0,0 +1,11 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type whatever_t = ::std::os::raw::c_int;
+extern "C" {
+ #[link_name = "_Z9somethingPKi"]
+ pub fn something(wat: *const whatever_t);
+}
diff --git a/libbindgen/tests/expectations/tests/empty_template_param_name.rs b/libbindgen/tests/expectations/tests/empty_template_param_name.rs
new file mode 100644
index 00000000..e10b56db
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/empty_template_param_name.rs
@@ -0,0 +1,13 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type __void_t = ::std::os::raw::c_void;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct __iterator_traits<_Iterator> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<_Iterator>,
+}
diff --git a/libbindgen/tests/expectations/tests/enum.rs b/libbindgen/tests/expectations/tests/enum.rs
new file mode 100644
index 00000000..8138d697
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum.rs
@@ -0,0 +1,12 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo { Bar = 0, Qux = 1, }
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Neg { MinusOne = -1, One = 1, }
diff --git a/libbindgen/tests/expectations/tests/enum_alias.rs b/libbindgen/tests/expectations/tests/enum_alias.rs
new file mode 100644
index 00000000..7ea85598
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum_alias.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Bar { VAL = 0, }
diff --git a/libbindgen/tests/expectations/tests/enum_and_vtable_mangling.rs b/libbindgen/tests/expectations/tests/enum_and_vtable_mangling.rs
new file mode 100644
index 00000000..a55c344e
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum_and_vtable_mangling.rs
@@ -0,0 +1,28 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const match_: _bindgen_ty_1 = _bindgen_ty_1::match_;
+pub const whatever_else: _bindgen_ty_1 = _bindgen_ty_1::whatever_else;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum _bindgen_ty_1 { match_ = 0, whatever_else = 1, }
+#[repr(C)]
+pub struct C__bindgen_vtable {
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub vtable_: *const C__bindgen_vtable,
+ pub i: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 16usize);
+ assert_eq!(::std::mem::align_of::<C>() , 8usize);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/enum_dupe.rs b/libbindgen/tests/expectations/tests/enum_dupe.rs
new file mode 100644
index 00000000..322b89fc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum_dupe.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const Foo_Dupe: Foo = Foo::Bar;
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo { Bar = 1, }
diff --git a/libbindgen/tests/expectations/tests/enum_explicit_type.rs b/libbindgen/tests/expectations/tests/enum_explicit_type.rs
new file mode 100644
index 00000000..4e555d3a
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum_explicit_type.rs
@@ -0,0 +1,24 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo { Bar = 0, Qux = 1, }
+#[repr(i8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Neg { MinusOne = -1, One = 1, }
+#[repr(u16)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Bigger { Much = 255, Larger = 256, }
+#[repr(i64)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum MuchLong { MuchLow = -4294967296, }
+#[repr(i64)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum MuchLongLong { I64_MIN = -9223372036854775808, }
+#[repr(u64)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum MuchULongLong { MuchHigh = 4294967296, }
diff --git a/libbindgen/tests/expectations/tests/enum_negative.rs b/libbindgen/tests/expectations/tests/enum_negative.rs
new file mode 100644
index 00000000..74cf4f16
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum_negative.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo { Bar = -2, Qux = 1, }
diff --git a/libbindgen/tests/expectations/tests/enum_packed.rs b/libbindgen/tests/expectations/tests/enum_packed.rs
new file mode 100644
index 00000000..963763e1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/enum_packed.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo { Bar = 0, Qux = 1, }
+#[repr(i8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Neg { MinusOne = -1, One = 1, }
+#[repr(u16)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Bigger { Much = 255, Larger = 256, }
diff --git a/libbindgen/tests/expectations/tests/extern.rs b/libbindgen/tests/expectations/tests/extern.rs
new file mode 100644
index 00000000..e7ac7504
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/extern.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type foo =
+ ::std::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)
+ -> ::std::os::raw::c_int>;
diff --git a/libbindgen/tests/expectations/tests/float128.rs b/libbindgen/tests/expectations/tests/float128.rs
new file mode 100644
index 00000000..b4b7b2bc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/float128.rs
@@ -0,0 +1,7 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+
diff --git a/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs b/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs
new file mode 100644
index 00000000..84104971
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs
@@ -0,0 +1,17 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub _base: RootedBase<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RootedBase<T> {
+ pub foo: *mut T,
+ pub next: *mut Rooted<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/forward-inherit-struct.rs b/libbindgen/tests/expectations/tests/forward-inherit-struct.rs
new file mode 100644
index 00000000..e053adcd
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/forward-inherit-struct.rs
@@ -0,0 +1,18 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RootedBase<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/forward_declared_struct.rs b/libbindgen/tests/expectations/tests/forward_declared_struct.rs
new file mode 100644
index 00000000..5c2764e1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/forward_declared_struct.rs
@@ -0,0 +1,32 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct a {
+ pub b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_a() {
+ assert_eq!(::std::mem::size_of::<a>() , 4usize);
+ assert_eq!(::std::mem::align_of::<a>() , 4usize);
+}
+impl Clone for a {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct c {
+ pub d: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_c() {
+ assert_eq!(::std::mem::size_of::<c>() , 4usize);
+ assert_eq!(::std::mem::align_of::<c>() , 4usize);
+}
+impl Clone for c {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/func_proto.rs b/libbindgen/tests/expectations/tests/func_proto.rs
new file mode 100644
index 00000000..e7ac7504
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/func_proto.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type foo =
+ ::std::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)
+ -> ::std::os::raw::c_int>;
diff --git a/libbindgen/tests/expectations/tests/func_ptr.rs b/libbindgen/tests/expectations/tests/func_ptr.rs
new file mode 100644
index 00000000..87ec3e3d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/func_ptr.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "foo"]
+ pub static mut foo:
+ ::std::option::Option<unsafe extern "C" fn(x:
+ ::std::os::raw::c_int,
+ y:
+ ::std::os::raw::c_int)
+ -> ::std::os::raw::c_int>;
+}
diff --git a/libbindgen/tests/expectations/tests/func_ptr_in_struct.rs b/libbindgen/tests/expectations/tests/func_ptr_in_struct.rs
new file mode 100644
index 00000000..dcae771b
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/func_ptr_in_struct.rs
@@ -0,0 +1,25 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum baz { }
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Foo {
+ pub bar: ::std::option::Option<unsafe extern "C" fn(x:
+ ::std::os::raw::c_int,
+ y:
+ ::std::os::raw::c_int)
+ -> baz>,
+}
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(::std::mem::size_of::<Foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Foo>() , 8usize);
+}
+impl Clone for Foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/func_with_array_arg.rs b/libbindgen/tests/expectations/tests/func_with_array_arg.rs
new file mode 100644
index 00000000..1528e0ba
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/func_with_array_arg.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn f(x: *mut ::std::os::raw::c_int);
+}
diff --git a/libbindgen/tests/expectations/tests/func_with_func_ptr_arg.rs b/libbindgen/tests/expectations/tests/func_with_func_ptr_arg.rs
new file mode 100644
index 00000000..4ac25286
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/func_with_func_ptr_arg.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn foo(bar: ::std::option::Option<unsafe extern "C" fn()>);
+}
diff --git a/libbindgen/tests/expectations/tests/in_class_typedef.rs b/libbindgen/tests/expectations/tests/in_class_typedef.rs
new file mode 100644
index 00000000..4e95ca8c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/in_class_typedef.rs
@@ -0,0 +1,21 @@
+/* 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_elem_type<T> = T;
+pub type Foo_ptr_type<T> = *mut T;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Foo_Bar<T> {
+ pub x: ::std::os::raw::c_int,
+ pub y: ::std::os::raw::c_int,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/inherit-namespaced.rs b/libbindgen/tests/expectations/tests/inherit-namespaced.rs
new file mode 100644
index 00000000..a58058b0
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/inherit-namespaced.rs
@@ -0,0 +1,18 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RootedBase<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/inherit_named.rs b/libbindgen/tests/expectations/tests/inherit_named.rs
new file mode 100644
index 00000000..8081c649
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/inherit_named.rs
@@ -0,0 +1,17 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Wohoo<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Weeee<T> {
+ pub _base: T,
+}
diff --git a/libbindgen/tests/expectations/tests/inherit_typedef.rs b/libbindgen/tests/expectations/tests/inherit_typedef.rs
new file mode 100644
index 00000000..ca9041e2
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/inherit_typedef.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Foo {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(::std::mem::size_of::<Foo>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Foo>() , 1usize);
+}
+impl Clone for Foo {
+ fn clone(&self) -> Self { *self }
+}
+pub type TypedefedFoo = Foo;
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Bar {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(::std::mem::size_of::<Bar>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Bar>() , 1usize);
+}
+impl Clone for Bar {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/inner_const.rs b/libbindgen/tests/expectations/tests/inner_const.rs
new file mode 100644
index 00000000..666b8ce2
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/inner_const.rs
@@ -0,0 +1,27 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Foo {
+ pub bar: ::std::os::raw::c_int,
+}
+extern "C" {
+ #[link_name = "_ZN3Foo3BOOE"]
+ pub static mut Foo_BOO: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "_ZN3Foo8whateverE"]
+ pub static mut Foo_whatever: Foo;
+}
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(::std::mem::size_of::<Foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Foo>() , 4usize);
+}
+impl Clone for Foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/inner_template_self.rs b/libbindgen/tests/expectations/tests/inner_template_self.rs
new file mode 100644
index 00000000..b965b92d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/inner_template_self.rs
@@ -0,0 +1,25 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct LinkedList<T> {
+ pub next: *mut LinkedList<T>,
+ pub prev: *mut LinkedList<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct InstantiateIt {
+ pub m_list: LinkedList<::std::os::raw::c_int>,
+}
+#[test]
+fn bindgen_test_layout_InstantiateIt() {
+ assert_eq!(::std::mem::size_of::<InstantiateIt>() , 16usize);
+ assert_eq!(::std::mem::align_of::<InstantiateIt>() , 8usize);
+}
+impl Clone for InstantiateIt {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/int128_t.rs b/libbindgen/tests/expectations/tests/int128_t.rs
new file mode 100644
index 00000000..b4b7b2bc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/int128_t.rs
@@ -0,0 +1,7 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+
diff --git a/libbindgen/tests/expectations/tests/jsval_layout_opaque.rs b/libbindgen/tests/expectations/tests/jsval_layout_opaque.rs
new file mode 100644
index 00000000..91f898af
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/jsval_layout_opaque.rs
@@ -0,0 +1,200 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47;
+pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327;
+pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328;
+#[repr(u8)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum JSValueType {
+ JSVAL_TYPE_DOUBLE = 0,
+ JSVAL_TYPE_INT32 = 1,
+ JSVAL_TYPE_UNDEFINED = 2,
+ JSVAL_TYPE_BOOLEAN = 3,
+ JSVAL_TYPE_MAGIC = 4,
+ JSVAL_TYPE_STRING = 5,
+ JSVAL_TYPE_SYMBOL = 6,
+ JSVAL_TYPE_NULL = 7,
+ JSVAL_TYPE_OBJECT = 8,
+ JSVAL_TYPE_UNKNOWN = 32,
+ JSVAL_TYPE_MISSING = 33,
+}
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum JSValueTag {
+ JSVAL_TAG_MAX_DOUBLE = 131056,
+ JSVAL_TAG_INT32 = 131057,
+ JSVAL_TAG_UNDEFINED = 131058,
+ JSVAL_TAG_STRING = 131061,
+ JSVAL_TAG_SYMBOL = 131062,
+ JSVAL_TAG_BOOLEAN = 131059,
+ JSVAL_TAG_MAGIC = 131060,
+ JSVAL_TAG_NULL = 131063,
+ JSVAL_TAG_OBJECT = 131064,
+}
+#[repr(u64)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum JSValueShiftedTag {
+ JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663,
+ JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696,
+ JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024,
+ JSVAL_SHIFTED_TAG_STRING = 18445195961337643008,
+ JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336,
+ JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352,
+ JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680,
+ JSVAL_SHIFTED_TAG_NULL = 18445477436314353664,
+ JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992,
+}
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum JSWhyMagic {
+ JS_ELEMENTS_HOLE = 0,
+ JS_NO_ITER_VALUE = 1,
+ JS_GENERATOR_CLOSING = 2,
+ JS_NO_CONSTANT = 3,
+ JS_THIS_POISON = 4,
+ JS_ARG_POISON = 5,
+ JS_SERIALIZE_NO_NODE = 6,
+ JS_LAZY_ARGUMENTS = 7,
+ JS_OPTIMIZED_ARGUMENTS = 8,
+ JS_IS_CONSTRUCTING = 9,
+ JS_OVERWRITTEN_CALLEE = 10,
+ JS_BLOCK_NEEDS_CLONE = 11,
+ JS_HASH_KEY_EMPTY = 12,
+ JS_ION_ERROR = 13,
+ JS_ION_BAILOUT = 14,
+ JS_OPTIMIZED_OUT = 15,
+ JS_UNINITIALIZED_LEXICAL = 16,
+ JS_GENERIC_MAGIC = 17,
+ JS_WHY_MAGIC_COUNT = 18,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct jsval_layout {
+ pub asBits: __BindgenUnionField<u64>,
+ pub debugView: __BindgenUnionField<jsval_layout__bindgen_ty_1>,
+ pub s: __BindgenUnionField<jsval_layout__bindgen_ty_2>,
+ pub asDouble: __BindgenUnionField<f64>,
+ pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub asWord: __BindgenUnionField<usize>,
+ pub asUIntPtr: __BindgenUnionField<usize>,
+ pub bindgen_union_field: u64,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct jsval_layout__bindgen_ty_1 {
+ pub _bitfield_1: u64,
+}
+#[test]
+fn bindgen_test_layout_jsval_layout__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_1>() , 8usize);
+}
+impl Clone for jsval_layout__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+impl jsval_layout__bindgen_ty_1 {
+ #[inline]
+ pub fn payload47(&self) -> u64 {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 &
+ (140737488355327usize as u64)) >>
+ 0u32) as u64)
+ }
+ }
+ #[inline]
+ pub fn set_payload47(&mut self, val: u64) {
+ self._bitfield_1 &= !(140737488355327usize as u64);
+ self._bitfield_1 |=
+ ((val as u64 as u64) << 0u32) & (140737488355327usize as u64);
+ }
+ #[inline]
+ pub fn tag(&self) -> JSValueTag {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 &
+ (18446603336221196288usize as u64)) >>
+ 47u32) as u32)
+ }
+ }
+ #[inline]
+ pub fn set_tag(&mut self, val: JSValueTag) {
+ self._bitfield_1 &= !(18446603336221196288usize as u64);
+ self._bitfield_1 |=
+ ((val as u32 as u64) << 47u32) &
+ (18446603336221196288usize as u64);
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct jsval_layout__bindgen_ty_2 {
+ pub payload: jsval_layout__bindgen_ty_2_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct jsval_layout__bindgen_ty_2_1 {
+ pub i32: __BindgenUnionField<i32>,
+ pub u32: __BindgenUnionField<u32>,
+ pub why: __BindgenUnionField<JSWhyMagic>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_jsval_layout__bindgen_ty_2_1() {
+ assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_2_1>() ,
+ 4usize);
+ assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_2_1>() ,
+ 4usize);
+}
+impl Clone for jsval_layout__bindgen_ty_2_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_jsval_layout__bindgen_ty_2() {
+ assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_2>() , 4usize);
+ assert_eq!(::std::mem::align_of::<jsval_layout__bindgen_ty_2>() , 4usize);
+}
+impl Clone for jsval_layout__bindgen_ty_2 {
+ fn clone(&self) -> Self { *self }
+}
+impl Clone for jsval_layout {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Value {
+ pub data: jsval_layout,
+}
+#[test]
+fn bindgen_test_layout_Value() {
+ assert_eq!(::std::mem::size_of::<Value>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Value>() , 8usize);
+}
+impl Clone for Value {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/keywords.rs b/libbindgen/tests/expectations/tests/keywords.rs
new file mode 100644
index 00000000..5b75389e
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/keywords.rs
@@ -0,0 +1,202 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "u8"]
+ pub static mut u8: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "u16"]
+ pub static mut u16: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "u32"]
+ pub static mut u32: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "u64"]
+ pub static mut u64: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "i8"]
+ pub static mut i8: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "i16"]
+ pub static mut i16: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "i32"]
+ pub static mut i32: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "i64"]
+ pub static mut i64: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "f32"]
+ pub static mut f32: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "f64"]
+ pub static mut f64: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "usize"]
+ pub static mut usize: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "isize"]
+ pub static mut isize: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "as"]
+ pub static mut as_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "box"]
+ pub static mut box_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "crate"]
+ pub static mut crate_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "false"]
+ pub static mut false_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "fn"]
+ pub static mut fn_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "impl"]
+ pub static mut impl_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "in"]
+ pub static mut in_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "let"]
+ pub static mut let_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "loop"]
+ pub static mut loop_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "match"]
+ pub static mut match_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "mod"]
+ pub static mut mod_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "move"]
+ pub static mut move_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "mut"]
+ pub static mut mut_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "pub"]
+ pub static mut pub_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "ref"]
+ pub static mut ref_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "self"]
+ pub static mut self_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "Self"]
+ pub static mut Self_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "super"]
+ pub static mut super_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "trait"]
+ pub static mut trait_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "true"]
+ pub static mut true_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "type"]
+ pub static mut type_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "unsafe"]
+ pub static mut unsafe_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "use"]
+ pub static mut use_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "where"]
+ pub static mut where_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "abstract"]
+ pub static mut abstract_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "alignof"]
+ pub static mut alignof_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "become"]
+ pub static mut become_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "final"]
+ pub static mut final_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "macro"]
+ pub static mut macro_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "offsetof"]
+ pub static mut offsetof_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "override"]
+ pub static mut override_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "priv"]
+ pub static mut priv_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "proc"]
+ pub static mut proc_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "pure"]
+ pub static mut pure_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "unsized"]
+ pub static mut unsized_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "virtual"]
+ pub static mut virtual_: ::std::os::raw::c_int;
+}
+extern "C" {
+ #[link_name = "yield"]
+ pub static mut yield_: ::std::os::raw::c_int;
+}
diff --git a/libbindgen/tests/expectations/tests/macro-expr-basic.rs b/libbindgen/tests/expectations/tests/macro-expr-basic.rs
new file mode 100644
index 00000000..355294e7
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/macro-expr-basic.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const FOO: ::std::os::raw::c_uint = 1;
+pub const BAR: ::std::os::raw::c_uint = 4;
+pub const BAZ: ::std::os::raw::c_uint = 5;
+pub const MIN: ::std::os::raw::c_longlong = -9223372036854775808;
+pub const BARR: ::std::os::raw::c_uint = 1;
+pub const BAZZ: ::std::os::raw::c_uint = 7;
+pub const I_RAN_OUT_OF_DUMB_NAMES: ::std::os::raw::c_uint = 7;
+pub const HAZ_A_COMMENT: ::std::os::raw::c_uint = 1;
+pub const HAZ_A_COMMENT_INSIDE: ::std::os::raw::c_uint = 2;
diff --git a/libbindgen/tests/expectations/tests/macro-redef.rs b/libbindgen/tests/expectations/tests/macro-redef.rs
new file mode 100644
index 00000000..881a44ae
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/macro-redef.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const FOO: ::std::os::raw::c_uint = 4;
+pub const BAR: ::std::os::raw::c_uint = 5;
+pub const BAZ: ::std::os::raw::c_uint = 6;
diff --git a/libbindgen/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs b/libbindgen/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs
new file mode 100644
index 00000000..5e9cf522
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs
@@ -0,0 +1,45 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Foo {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Foo() {
+ assert_eq!(::std::mem::size_of::<Foo>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Foo>() , 1usize);
+}
+impl Clone for Foo {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Bar {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(::std::mem::size_of::<Bar>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Bar>() , 1usize);
+}
+impl Clone for Bar {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Baz {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Baz() {
+ assert_eq!(::std::mem::size_of::<Baz>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Baz>() , 1usize);
+}
+impl Clone for Baz {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/mutable.rs b/libbindgen/tests/expectations/tests/mutable.rs
new file mode 100644
index 00000000..0d0d6ea3
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/mutable.rs
@@ -0,0 +1,42 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub m_member: ::std::os::raw::c_int,
+ pub m_other: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 8usize);
+ assert_eq!(::std::mem::align_of::<C>() , 4usize);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct NonCopiable {
+ pub m_member: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_NonCopiable() {
+ assert_eq!(::std::mem::size_of::<NonCopiable>() , 4usize);
+ assert_eq!(::std::mem::align_of::<NonCopiable>() , 4usize);
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct NonCopiableWithNonCopiableMutableMember {
+ pub m_member: NonCopiable,
+}
+#[test]
+fn bindgen_test_layout_NonCopiableWithNonCopiableMutableMember() {
+ assert_eq!(::std::mem::size_of::<NonCopiableWithNonCopiableMutableMember>()
+ , 4usize);
+ assert_eq!(::std::mem::align_of::<NonCopiableWithNonCopiableMutableMember>()
+ , 4usize);
+}
diff --git a/libbindgen/tests/expectations/tests/namespace.rs b/libbindgen/tests/expectations/tests/namespace.rs
new file mode 100644
index 00000000..bc8bae68
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/namespace.rs
@@ -0,0 +1,85 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub mod root {
+ use root;
+ extern "C" {
+ #[link_name = "_Z9top_levelv"]
+ pub fn top_level();
+ }
+ pub mod whatever {
+ use root;
+ pub type whatever_int_t = ::std::os::raw::c_int;
+ extern "C" {
+ #[link_name = "_ZN8whatever11in_whateverEv"]
+ pub fn in_whatever();
+ }
+ }
+ pub mod _bindgen_mod_id_13 {
+ use root;
+ pub mod empty {
+ use root;
+ }
+ extern "C" {
+ #[link_name = "_ZN12_GLOBAL__N_13fooEv"]
+ pub fn foo();
+ }
+ #[repr(C)]
+ #[derive(Debug, Copy)]
+ pub struct A {
+ pub b: root::whatever::whatever_int_t,
+ }
+ #[test]
+ fn bindgen_test_layout_A() {
+ assert_eq!(::std::mem::size_of::<A>() , 4usize);
+ assert_eq!(::std::mem::align_of::<A>() , 4usize);
+ }
+ impl Clone for A {
+ fn clone(&self) -> Self { *self }
+ }
+ }
+ #[repr(C)]
+ #[derive(Debug)]
+ pub struct C<T> {
+ pub _base: root::_bindgen_mod_id_13::A,
+ pub m_c: T,
+ pub m_c_ptr: *mut T,
+ pub m_c_arr: [T; 10usize],
+ }
+ pub mod w {
+ use root;
+ pub type whatever_int_t = ::std::os::raw::c_uint;
+ #[repr(C)]
+ #[derive(Debug)]
+ pub struct D<T> {
+ pub m_c: root::C<T>,
+ }
+ extern "C" {
+ #[link_name = "_ZN1w3hehEv"]
+ pub fn heh() -> root::w::whatever_int_t;
+ }
+ extern "C" {
+ #[link_name = "_ZN1w3fooEv"]
+ pub fn foo() -> root::C<::std::os::raw::c_int>;
+ }
+ extern "C" {
+ #[link_name = "_ZN1w4barrEv"]
+ pub fn barr() -> root::C<f32>;
+ }
+ }
+}
+extern "C" {
+ #[link_name = "_Z9top_levelv"]
+ pub fn top_level();
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct C<T> {
+ pub _base: root::_bindgen_mod_id_13::A,
+ pub m_c: T,
+ pub m_c_ptr: *mut T,
+ pub m_c_arr: [T; 10usize],
+}
diff --git a/libbindgen/tests/expectations/tests/nested.rs b/libbindgen/tests/expectations/tests/nested.rs
new file mode 100644
index 00000000..fdd435aa
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/nested.rs
@@ -0,0 +1,59 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Calc {
+ pub w: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_Calc() {
+ assert_eq!(::std::mem::size_of::<Calc>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Calc>() , 4usize);
+}
+impl Clone for Calc {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Test {
+ pub _address: u8,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Test_Size {
+ pub mWidth: Test_Size_Dimension,
+ pub mHeight: Test_Size_Dimension,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Test_Size_Dimension {
+ pub _base: Calc,
+}
+#[test]
+fn bindgen_test_layout_Test_Size_Dimension() {
+ assert_eq!(::std::mem::size_of::<Test_Size_Dimension>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Test_Size_Dimension>() , 4usize);
+}
+impl Clone for Test_Size_Dimension {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_Test_Size() {
+ assert_eq!(::std::mem::size_of::<Test_Size>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Test_Size>() , 4usize);
+}
+impl Clone for Test_Size {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_Test() {
+ assert_eq!(::std::mem::size_of::<Test>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Test>() , 1usize);
+}
+impl Clone for Test {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/nested_vtable.rs b/libbindgen/tests/expectations/tests/nested_vtable.rs
new file mode 100644
index 00000000..d74ad55f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/nested_vtable.rs
@@ -0,0 +1,48 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct nsISupports__bindgen_vtable {
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct nsISupports {
+ pub vtable_: *const nsISupports__bindgen_vtable,
+}
+#[test]
+fn bindgen_test_layout_nsISupports() {
+ assert_eq!(::std::mem::size_of::<nsISupports>() , 8usize);
+ assert_eq!(::std::mem::align_of::<nsISupports>() , 8usize);
+}
+impl Clone for nsISupports {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct nsIRunnable {
+ pub _base: nsISupports,
+}
+#[test]
+fn bindgen_test_layout_nsIRunnable() {
+ assert_eq!(::std::mem::size_of::<nsIRunnable>() , 8usize);
+ assert_eq!(::std::mem::align_of::<nsIRunnable>() , 8usize);
+}
+impl Clone for nsIRunnable {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Runnable {
+ pub _base: nsIRunnable,
+}
+#[test]
+fn bindgen_test_layout_Runnable() {
+ assert_eq!(::std::mem::size_of::<Runnable>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Runnable>() , 8usize);
+}
+impl Clone for Runnable {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/no-std.rs b/libbindgen/tests/expectations/tests/no-std.rs
new file mode 100644
index 00000000..f50a889d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/no-std.rs
@@ -0,0 +1,23 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+#![no_std]
+mod libc { pub type c_int = i32; pub enum c_void {} }
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: libc::c_int,
+ pub b: libc::c_int,
+ pub bar: *mut libc::c_void,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::core::mem::size_of::<foo>() , 16usize);
+ assert_eq!(::core::mem::align_of::<foo>() , 8usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/no_copy.rs b/libbindgen/tests/expectations/tests/no_copy.rs
new file mode 100644
index 00000000..53ab9677
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/no_copy.rs
@@ -0,0 +1,13 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+/** <div rustbindgen nocopy></div> */
+#[repr(C)]
+#[derive(Debug)]
+pub struct CopiableButWait<T> {
+ pub whatever: ::std::os::raw::c_int,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/nsStyleAutoArray.rs b/libbindgen/tests/expectations/tests/nsStyleAutoArray.rs
new file mode 100644
index 00000000..c150ec46
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/nsStyleAutoArray.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsTArray<T> {
+ pub mBuff: *mut T,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsStyleAutoArray<T> {
+ pub mFirstElement: T,
+ pub mOtherElements: nsTArray<T>,
+}
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum nsStyleAutoArray_WithSingleInitialElement {
+ WITH_SINGLE_INITIAL_ELEMENT = 0,
+}
diff --git a/libbindgen/tests/expectations/tests/only_bitfields.rs b/libbindgen/tests/expectations/tests/only_bitfields.rs
new file mode 100644
index 00000000..68968826
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/only_bitfields.rs
@@ -0,0 +1,45 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub _bitfield_1: u8,
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 1usize);
+ assert_eq!(::std::mem::align_of::<C>() , 1usize);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
+impl C {
+ #[inline]
+ pub fn a(&self) -> bool {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >>
+ 0u32) as u8)
+ }
+ }
+ #[inline]
+ pub fn set_a(&mut self, val: bool) {
+ self._bitfield_1 &= !(1usize as u8);
+ self._bitfield_1 |= ((val as u8 as u8) << 0u32) & (1usize as u8);
+ }
+ #[inline]
+ pub fn b(&self) -> bool {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (254usize as u8)) >>
+ 1u32) as u8)
+ }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: bool) {
+ self._bitfield_1 &= !(254usize as u8);
+ self._bitfield_1 |= ((val as u8 as u8) << 1u32) & (254usize as u8);
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/opaque_in_struct.rs b/libbindgen/tests/expectations/tests/opaque_in_struct.rs
new file mode 100644
index 00000000..d537f5c7
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/opaque_in_struct.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+/** <div rustbindgen opaque> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct opaque {
+ pub _bindgen_opaque_blob: u32,
+}
+#[test]
+fn bindgen_test_layout_opaque() {
+ assert_eq!(::std::mem::size_of::<opaque>() , 4usize);
+ assert_eq!(::std::mem::align_of::<opaque>() , 4usize);
+}
+impl Clone for opaque {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct container {
+ pub contained: u32,
+}
+#[test]
+fn bindgen_test_layout_container() {
+ assert_eq!(::std::mem::size_of::<container>() , 4usize);
+ assert_eq!(::std::mem::align_of::<container>() , 4usize);
+}
+impl Clone for container {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/opaque_pointer.rs b/libbindgen/tests/expectations/tests/opaque_pointer.rs
new file mode 100644
index 00000000..067f55bd
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/opaque_pointer.rs
@@ -0,0 +1,45 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct OtherOpaque {
+ pub _bindgen_opaque_blob: u32,
+}
+#[test]
+fn bindgen_test_layout_OtherOpaque() {
+ assert_eq!(::std::mem::size_of::<OtherOpaque>() , 4usize);
+ assert_eq!(::std::mem::align_of::<OtherOpaque>() , 4usize);
+}
+impl Clone for OtherOpaque {
+ fn clone(&self) -> Self { *self }
+}
+/**
+ * <div rustbindgen opaque></div>
+ */
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Opaque<T> {
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct WithOpaquePtr {
+ pub whatever: *mut Opaque<::std::os::raw::c_int>,
+ pub other: u32,
+ pub t: u32,
+}
+#[test]
+fn bindgen_test_layout_WithOpaquePtr() {
+ assert_eq!(::std::mem::size_of::<WithOpaquePtr>() , 16usize);
+ assert_eq!(::std::mem::align_of::<WithOpaquePtr>() , 8usize);
+}
+impl Clone for WithOpaquePtr {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/opaque_typedef.rs b/libbindgen/tests/expectations/tests/opaque_typedef.rs
new file mode 100644
index 00000000..c45cbc6f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/opaque_typedef.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct RandomTemplate<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+/** <div rustbindgen opaque></div> */
+pub type ShouldBeOpaque = [u8; 0usize];
+pub type ShouldNotBeOpaque = RandomTemplate<f32>;
diff --git a/libbindgen/tests/expectations/tests/overflowed_enum.rs b/libbindgen/tests/expectations/tests/overflowed_enum.rs
new file mode 100644
index 00000000..9e1f8a7f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/overflowed_enum.rs
@@ -0,0 +1,16 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Foo {
+ BAP_ARM = 9698489,
+ BAP_X86 = 11960045,
+ BAP_X86_64 = 3128633167,
+}
+#[repr(u16)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum Bar { One = 1, Big = 2, }
diff --git a/libbindgen/tests/expectations/tests/overloading.rs b/libbindgen/tests/expectations/tests/overloading.rs
new file mode 100644
index 00000000..4e138e7d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/overloading.rs
@@ -0,0 +1,23 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ #[link_name = "_Z8Evaluatec"]
+ pub fn Evaluate(r: ::std::os::raw::c_char) -> bool;
+}
+extern "C" {
+ #[link_name = "_Z8Evaluateii"]
+ pub fn Evaluate1(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int)
+ -> bool;
+}
+extern "C" {
+ #[link_name = "_ZN3foo10MyFunctionEv"]
+ pub fn MyFunction();
+}
+extern "C" {
+ #[link_name = "_ZN3bar10MyFunctionEv"]
+ pub fn MyFunction1();
+}
diff --git a/libbindgen/tests/expectations/tests/private.rs b/libbindgen/tests/expectations/tests/private.rs
new file mode 100644
index 00000000..c4ac37d1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/private.rs
@@ -0,0 +1,52 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct HasPrivate {
+ pub mNotPrivate: ::std::os::raw::c_int,
+ /** <div rustbindgen private></div> */
+ mIsPrivate: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_HasPrivate() {
+ assert_eq!(::std::mem::size_of::<HasPrivate>() , 8usize);
+ assert_eq!(::std::mem::align_of::<HasPrivate>() , 4usize);
+}
+impl Clone for HasPrivate {
+ fn clone(&self) -> Self { *self }
+}
+/** <div rustbindgen private></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct VeryPrivate {
+ mIsPrivate: ::std::os::raw::c_int,
+ mIsAlsoPrivate: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_VeryPrivate() {
+ assert_eq!(::std::mem::size_of::<VeryPrivate>() , 8usize);
+ assert_eq!(::std::mem::align_of::<VeryPrivate>() , 4usize);
+}
+impl Clone for VeryPrivate {
+ fn clone(&self) -> Self { *self }
+}
+/** <div rustbindgen private></div> */
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct ContradictPrivate {
+ /** <div rustbindgen private="false"></div> */
+ pub mNotPrivate: ::std::os::raw::c_int,
+ mIsPrivate: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_ContradictPrivate() {
+ assert_eq!(::std::mem::size_of::<ContradictPrivate>() , 8usize);
+ assert_eq!(::std::mem::align_of::<ContradictPrivate>() , 4usize);
+}
+impl Clone for ContradictPrivate {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/redeclaration.rs b/libbindgen/tests/expectations/tests/redeclaration.rs
new file mode 100644
index 00000000..0d7e585c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/redeclaration.rs
@@ -0,0 +1,9 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+extern "C" {
+ pub fn foo();
+}
diff --git a/libbindgen/tests/expectations/tests/ref_argument_array.rs b/libbindgen/tests/expectations/tests/ref_argument_array.rs
new file mode 100644
index 00000000..c88492d7
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/ref_argument_array.rs
@@ -0,0 +1,23 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const NSID_LENGTH: ::std::os::raw::c_uint = 10;
+#[repr(C)]
+pub struct nsID__bindgen_vtable {
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct nsID {
+ pub vtable_: *const nsID__bindgen_vtable,
+}
+#[test]
+fn bindgen_test_layout_nsID() {
+ assert_eq!(::std::mem::size_of::<nsID>() , 8usize);
+ assert_eq!(::std::mem::align_of::<nsID>() , 8usize);
+}
+impl Clone for nsID {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/replace_template_alias.rs b/libbindgen/tests/expectations/tests/replace_template_alias.rs
new file mode 100644
index 00000000..61a2fbcc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/replace_template_alias.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub ptr: MaybeWrapped<T>,
+}
+/// But the replacement type does use T!
+///
+/// <div rustbindgen replaces="MaybeWrapped" />
+pub type MaybeWrapped<T> = T;
diff --git a/libbindgen/tests/expectations/tests/replaces_double.rs b/libbindgen/tests/expectations/tests/replaces_double.rs
new file mode 100644
index 00000000..50dafd42
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/replaces_double.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub ptr: Rooted_MaybeWrapped<T>,
+}
+/**
+ * <div rustbindgen replaces="Rooted_MaybeWrapped"></div>
+ */
+pub type Rooted_MaybeWrapped<T> = T;
diff --git a/libbindgen/tests/expectations/tests/size_t_template.rs b/libbindgen/tests/expectations/tests/size_t_template.rs
new file mode 100644
index 00000000..78351ecc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/size_t_template.rs
@@ -0,0 +1,19 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub arr: [u32; 3usize],
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 12usize);
+ assert_eq!(::std::mem::align_of::<C>() , 4usize);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_containing_forward_declared_struct.rs b/libbindgen/tests/expectations/tests/struct_containing_forward_declared_struct.rs
new file mode 100644
index 00000000..388cc595
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_containing_forward_declared_struct.rs
@@ -0,0 +1,32 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct a {
+ pub val_a: *mut a_b,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct a_b {
+ pub val_b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_a_b() {
+ assert_eq!(::std::mem::size_of::<a_b>() , 4usize);
+ assert_eq!(::std::mem::align_of::<a_b>() , 4usize);
+}
+impl Clone for a_b {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_a() {
+ assert_eq!(::std::mem::size_of::<a>() , 8usize);
+ assert_eq!(::std::mem::align_of::<a>() , 8usize);
+}
+impl Clone for a {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_anon_struct.rs b/libbindgen/tests/expectations/tests/struct_with_anon_struct.rs
new file mode 100644
index 00000000..1c49675d
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_anon_struct.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: ::std::os::raw::c_int,
+ pub b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_anon_struct_array.rs b/libbindgen/tests/expectations/tests/struct_with_anon_struct_array.rs
new file mode 100644
index 00000000..6e1c0315
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_anon_struct_array.rs
@@ -0,0 +1,48 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: [foo__bindgen_ty_1; 2usize],
+ pub baz: [[[foo__bindgen_ty_2; 4usize]; 3usize]; 2usize],
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: ::std::os::raw::c_int,
+ pub b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_2 {
+ pub a: ::std::os::raw::c_int,
+ pub b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_2() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_2>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_2>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_2 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 208usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/libbindgen/tests/expectations/tests/struct_with_anon_struct_pointer.rs
new file mode 100644
index 00000000..aa77d4b6
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_anon_struct_pointer.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: *mut foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: ::std::os::raw::c_int,
+ pub b: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 8usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_anon_union.rs b/libbindgen/tests/expectations/tests/struct_with_anon_union.rs
new file mode 100644
index 00000000..0d2e937a
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_anon_union.rs
@@ -0,0 +1,58 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_struct.rs
new file mode 100644
index 00000000..1b77fccc
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_struct.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub __bindgen_anon_1: foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: ::std::os::raw::c_uint,
+ pub b: ::std::os::raw::c_uint,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_union.rs
new file mode 100644
index 00000000..2914eb41
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_union.rs
@@ -0,0 +1,58 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub __bindgen_anon_1: foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_bitfields.rs b/libbindgen/tests/expectations/tests/struct_with_bitfields.rs
new file mode 100644
index 00000000..3fb83a47
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_bitfields.rs
@@ -0,0 +1,122 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct bitfield {
+ pub _bitfield_1: u8,
+ pub e: ::std::os::raw::c_int,
+ pub _bitfield_2: u8,
+ pub _bitfield_3: u32,
+}
+#[test]
+fn bindgen_test_layout_bitfield() {
+ assert_eq!(::std::mem::size_of::<bitfield>() , 16usize);
+ assert_eq!(::std::mem::align_of::<bitfield>() , 4usize);
+}
+impl Clone for bitfield {
+ fn clone(&self) -> Self { *self }
+}
+impl bitfield {
+ #[inline]
+ pub fn a(&self) -> ::std::os::raw::c_ushort {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (1usize as u8)) >>
+ 0u32) as u16)
+ }
+ }
+ #[inline]
+ pub fn set_a(&mut self, val: ::std::os::raw::c_ushort) {
+ self._bitfield_1 &= !(1usize as u8);
+ self._bitfield_1 |= ((val as u16 as u8) << 0u32) & (1usize as u8);
+ }
+ #[inline]
+ pub fn b(&self) -> ::std::os::raw::c_ushort {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (2usize as u8)) >>
+ 1u32) as u16)
+ }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: ::std::os::raw::c_ushort) {
+ self._bitfield_1 &= !(2usize as u8);
+ self._bitfield_1 |= ((val as u16 as u8) << 1u32) & (2usize as u8);
+ }
+ #[inline]
+ pub fn c(&self) -> ::std::os::raw::c_ushort {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (4usize as u8)) >>
+ 2u32) as u16)
+ }
+ }
+ #[inline]
+ pub fn set_c(&mut self, val: ::std::os::raw::c_ushort) {
+ self._bitfield_1 &= !(4usize as u8);
+ self._bitfield_1 |= ((val as u16 as u8) << 2u32) & (4usize as u8);
+ }
+ #[inline]
+ pub fn at_offset_3(&self) -> ::std::os::raw::c_ushort {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (8usize as u8)) >>
+ 3u32) as u16)
+ }
+ }
+ #[inline]
+ pub fn set_at_offset_3(&mut self, val: ::std::os::raw::c_ushort) {
+ self._bitfield_1 &= !(8usize as u8);
+ self._bitfield_1 |= ((val as u16 as u8) << 3u32) & (8usize as u8);
+ }
+ #[inline]
+ pub fn at_offset_4(&self) -> ::std::os::raw::c_ushort {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (48usize as u8)) >>
+ 4u32) as u16)
+ }
+ }
+ #[inline]
+ pub fn set_at_offset_4(&mut self, val: ::std::os::raw::c_ushort) {
+ self._bitfield_1 &= !(48usize as u8);
+ self._bitfield_1 |= ((val as u16 as u8) << 4u32) & (48usize as u8);
+ }
+ #[inline]
+ pub fn d(&self) -> ::std::os::raw::c_ushort {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (192usize as u8)) >>
+ 6u32) as u16)
+ }
+ }
+ #[inline]
+ pub fn set_d(&mut self, val: ::std::os::raw::c_ushort) {
+ self._bitfield_1 &= !(192usize as u8);
+ self._bitfield_1 |= ((val as u16 as u8) << 6u32) & (192usize as u8);
+ }
+ #[inline]
+ pub fn f(&self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_2 & (3usize as u8)) >>
+ 0u32) as u32)
+ }
+ }
+ #[inline]
+ pub fn set_f(&mut self, val: ::std::os::raw::c_uint) {
+ self._bitfield_2 &= !(3usize as u8);
+ self._bitfield_2 |= ((val as u32 as u8) << 0u32) & (3usize as u8);
+ }
+ #[inline]
+ pub fn g(&self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_3 &
+ (4294967295usize as u32)) >> 0u32) as
+ u32)
+ }
+ }
+ #[inline]
+ pub fn set_g(&mut self, val: ::std::os::raw::c_uint) {
+ self._bitfield_3 &= !(4294967295usize as u32);
+ self._bitfield_3 |=
+ ((val as u32 as u32) << 0u32) & (4294967295usize as u32);
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_derive_debug.rs b/libbindgen/tests/expectations/tests/struct_with_derive_debug.rs
new file mode 100644
index 00000000..52906a81
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_derive_debug.rs
@@ -0,0 +1,50 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct LittleArray {
+ pub a: [::std::os::raw::c_int; 32usize],
+}
+#[test]
+fn bindgen_test_layout_LittleArray() {
+ assert_eq!(::std::mem::size_of::<LittleArray>() , 128usize);
+ assert_eq!(::std::mem::align_of::<LittleArray>() , 4usize);
+}
+impl Clone for LittleArray {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+pub struct BigArray {
+ pub a: [::std::os::raw::c_int; 33usize],
+}
+#[test]
+fn bindgen_test_layout_BigArray() {
+ assert_eq!(::std::mem::size_of::<BigArray>() , 132usize);
+ assert_eq!(::std::mem::align_of::<BigArray>() , 4usize);
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct WithLittleArray {
+ pub a: LittleArray,
+}
+#[test]
+fn bindgen_test_layout_WithLittleArray() {
+ assert_eq!(::std::mem::size_of::<WithLittleArray>() , 128usize);
+ assert_eq!(::std::mem::align_of::<WithLittleArray>() , 4usize);
+}
+impl Clone for WithLittleArray {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+pub struct WithBigArray {
+ pub a: BigArray,
+}
+#[test]
+fn bindgen_test_layout_WithBigArray() {
+ assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize);
+ assert_eq!(::std::mem::align_of::<WithBigArray>() , 4usize);
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_nesting.rs b/libbindgen/tests/expectations/tests/struct_with_nesting.rs
new file mode 100644
index 00000000..97a0949e
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_nesting.rs
@@ -0,0 +1,90 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: ::std::os::raw::c_uint,
+ pub __bindgen_anon_1: foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub b: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_1_1>,
+ pub __bindgen_anon_2: __BindgenUnionField<foo__bindgen_ty_1_2>,
+ pub bindgen_union_field: u32,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1_1 {
+ pub c1: ::std::os::raw::c_ushort,
+ pub c2: ::std::os::raw::c_ushort,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1_1>() , 2usize);
+}
+impl Clone for foo__bindgen_ty_1_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1_2 {
+ pub d1: ::std::os::raw::c_uchar,
+ pub d2: ::std::os::raw::c_uchar,
+ pub d3: ::std::os::raw::c_uchar,
+ pub d4: ::std::os::raw::c_uchar,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1_2() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1_2>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1_2>() , 1usize);
+}
+impl Clone for foo__bindgen_ty_1_2 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_packing.rs b/libbindgen/tests/expectations/tests/struct_with_packing.rs
new file mode 100644
index 00000000..93fc3f11
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_packing.rs
@@ -0,0 +1,20 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C, packed)]
+#[derive(Debug, Copy)]
+pub struct a {
+ pub b: ::std::os::raw::c_char,
+ pub c: ::std::os::raw::c_short,
+}
+#[test]
+fn bindgen_test_layout_a() {
+ assert_eq!(::std::mem::size_of::<a>() , 3usize);
+ assert_eq!(::std::mem::align_of::<a>() , 1usize);
+}
+impl Clone for a {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_struct.rs b/libbindgen/tests/expectations/tests/struct_with_struct.rs
new file mode 100644
index 00000000..c8cdc927
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_struct.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: foo__bindgen_ty_1,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub x: ::std::os::raw::c_uint,
+ pub y: ::std::os::raw::c_uint,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/struct_with_typedef_template_arg.rs b/libbindgen/tests/expectations/tests/struct_with_typedef_template_arg.rs
new file mode 100644
index 00000000..6f8d71f1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/struct_with_typedef_template_arg.rs
@@ -0,0 +1,15 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Proxy<T, Args> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+ pub _phantom_1: ::std::marker::PhantomData<Args>,
+}
+pub type Proxy_foo<T> =
+ ::std::option::Option<unsafe extern "C" fn(bar: *mut T)>;
diff --git a/libbindgen/tests/expectations/tests/template.rs b/libbindgen/tests/expectations/tests/template.rs
new file mode 100644
index 00000000..76afc879
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/template.rs
@@ -0,0 +1,170 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct Foo<T, U> {
+ pub m_member: T,
+ pub m_member_ptr: *mut T,
+ pub m_member_arr: [T; 1usize],
+ pub _phantom_1: ::std::marker::PhantomData<U>,
+}
+extern "C" {
+ #[link_name = "_Z3bar3FooIiiE"]
+ pub fn bar(foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>);
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct D<T> {
+ pub m_foo: D_MyFoo,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+pub type D_MyFoo = Foo<::std::os::raw::c_int, ::std::os::raw::c_int>;
+#[repr(C)]
+#[derive(Debug)]
+pub struct D_U<T, Z> {
+ pub m_nested_foo: D_MyFoo,
+ pub m_baz: Z,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub prev: *mut T,
+ pub next: *mut Rooted<*mut ::std::os::raw::c_void>,
+ pub ptr: T,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct RootedContainer {
+ pub root: Rooted<*mut ::std::os::raw::c_void>,
+}
+#[test]
+fn bindgen_test_layout_RootedContainer() {
+ assert_eq!(::std::mem::size_of::<RootedContainer>() , 24usize);
+ assert_eq!(::std::mem::align_of::<RootedContainer>() , 8usize);
+}
+impl Clone for RootedContainer {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct WithDtor<T> {
+ pub member: T,
+}
+pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>;
+#[repr(C)]
+#[derive(Debug)]
+pub struct PODButContainsDtor {
+ pub member: WithDtorIntFwd,
+}
+#[test]
+fn bindgen_test_layout_PODButContainsDtor() {
+ assert_eq!(::std::mem::size_of::<PODButContainsDtor>() , 4usize);
+ assert_eq!(::std::mem::align_of::<PODButContainsDtor>() , 4usize);
+}
+/** <div rustbindgen opaque> */
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Opaque<T> {
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct POD {
+ pub opaque_member: u32,
+}
+#[test]
+fn bindgen_test_layout_POD() {
+ assert_eq!(::std::mem::size_of::<POD>() , 4usize);
+ assert_eq!(::std::mem::align_of::<POD>() , 4usize);
+}
+impl Clone for POD {
+ fn clone(&self) -> Self { *self }
+}
+/**
+ * <div rustbindgen replaces="NestedReplaced"></div>
+ */
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct NestedReplaced<T> {
+ pub buff: *mut T,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct NestedBase<T, U> {
+ pub buff: *mut T,
+ pub _phantom_1: ::std::marker::PhantomData<U>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Incomplete<T> {
+ pub d: T,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct NestedContainer<T> {
+ pub c: T,
+ pub nested: NestedReplaced<T>,
+ pub inc: Incomplete<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Untemplated {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Untemplated() {
+ assert_eq!(::std::mem::size_of::<Untemplated>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Untemplated>() , 1usize);
+}
+impl Clone for Untemplated {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Templated<T> {
+ pub m_untemplated: Untemplated,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+/**
+ * If the replacement doesn't happen at the parse level the container would be
+ * copy and the replacement wouldn't, so this wouldn't compile.
+ *
+ * <div rustbindgen replaces="ReplacedWithoutDestructor"></div>
+ */
+#[repr(C)]
+#[derive(Debug)]
+pub struct ReplacedWithoutDestructor<T> {
+ pub buff: *mut T,
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct ShouldNotBeCopiable<T> {
+ pub m_member: ReplacedWithoutDestructor<T>,
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct ShouldNotBeCopiableAsWell<U> {
+ pub m_member: ReplacedWithoutDestructorFwd<U>,
+}
+/**
+ * If the replacement doesn't happen at the parse level the container would be
+ * copy and the replacement wouldn't, so this wouldn't compile.
+ *
+ * <div rustbindgen replaces="ReplacedWithoutDestructorFwd"></div>
+ */
+#[repr(C)]
+#[derive(Debug)]
+pub struct ReplacedWithoutDestructorFwd<T> {
+ pub buff: *mut T,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct TemplateWithVar<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/template_alias.rs b/libbindgen/tests/expectations/tests/template_alias.rs
new file mode 100644
index 00000000..6457381f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/template_alias.rs
@@ -0,0 +1,12 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type Wrapped<T> = T;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Rooted<T> {
+ pub ptr: Wrapped<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/template_alias_basic.rs b/libbindgen/tests/expectations/tests/template_alias_basic.rs
new file mode 100644
index 00000000..656fff33
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/template_alias_basic.rs
@@ -0,0 +1,7 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type Wrapped<T> = T;
diff --git a/libbindgen/tests/expectations/tests/template_alias_namespace.rs b/libbindgen/tests/expectations/tests/template_alias_namespace.rs
new file mode 100644
index 00000000..475c2b05
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/template_alias_namespace.rs
@@ -0,0 +1,21 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub mod root {
+ use root;
+ pub mod JS {
+ use root;
+ pub mod detail {
+ use root;
+ pub type Wrapped<T> = T;
+ }
+ #[repr(C)]
+ #[derive(Debug, Copy, Clone)]
+ pub struct Rooted<T> {
+ pub ptr: root::JS::detail::Wrapped<T>,
+ }
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/template_typedef_transitive_param.rs b/libbindgen/tests/expectations/tests/template_typedef_transitive_param.rs
new file mode 100644
index 00000000..166ddc3c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/template_typedef_transitive_param.rs
@@ -0,0 +1,18 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Wrapper<T> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Wrapper_Wrapped<T> {
+ pub t: T,
+}
+pub type Wrapper_Type<T> = Wrapper_Wrapped<T>;
diff --git a/libbindgen/tests/expectations/tests/template_typedefs.rs b/libbindgen/tests/expectations/tests/template_typedefs.rs
new file mode 100644
index 00000000..5f0d80b9
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/template_typedefs.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type foo =
+ ::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int)>;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Foo<T, U> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+ pub _phantom_1: ::std::marker::PhantomData<U>,
+}
+pub type Foo_Char<T> = T;
+pub type Foo_FooPtrTypedef<T> = *mut Foo_Char<T>;
+pub type Foo_nsCOMArrayEnumFunc<T> =
+ ::std::option::Option<unsafe extern "C" fn(aElement: *mut T,
+ aData:
+ *mut ::std::os::raw::c_void)
+ -> bool>;
diff --git a/libbindgen/tests/expectations/tests/type_alias_empty.rs b/libbindgen/tests/expectations/tests/type_alias_empty.rs
new file mode 100644
index 00000000..47e36006
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/type_alias_empty.rs
@@ -0,0 +1,7 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type bool_constant = ();
diff --git a/libbindgen/tests/expectations/tests/typeref.rs b/libbindgen/tests/expectations/tests/typeref.rs
new file mode 100644
index 00000000..da944146
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/typeref.rs
@@ -0,0 +1,96 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct nsFoo {
+ pub mBar: StyleShapeSource<::std::os::raw::c_int>,
+}
+#[test]
+fn bindgen_test_layout_nsFoo() {
+ assert_eq!(::std::mem::size_of::<nsFoo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<nsFoo>() , 8usize);
+}
+impl Clone for nsFoo {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct FragmentOrURL {
+ pub mIsLocalRef: bool,
+}
+#[test]
+fn bindgen_test_layout_FragmentOrURL() {
+ assert_eq!(::std::mem::size_of::<FragmentOrURL>() , 1usize);
+ assert_eq!(::std::mem::align_of::<FragmentOrURL>() , 1usize);
+}
+impl Clone for FragmentOrURL {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Position {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_Position() {
+ assert_eq!(::std::mem::size_of::<Position>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Position>() , 1usize);
+}
+impl Clone for Position {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Bar {
+ pub mFoo: *mut nsFoo,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(::std::mem::size_of::<Bar>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Bar>() , 8usize);
+}
+impl Clone for Bar {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleShapeSource<ReferenceBox> {
+ pub __bindgen_anon_1: StyleShapeSource__bindgen_ty_1<ReferenceBox>,
+ pub _phantom_0: ::std::marker::PhantomData<ReferenceBox>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleShapeSource__bindgen_ty_1<ReferenceBox> {
+ pub mPosition: __BindgenUnionField<*mut Position>,
+ pub mFragmentOrURL: __BindgenUnionField<*mut FragmentOrURL>,
+ pub bindgen_union_field: u64,
+ pub _phantom_0: ::std::marker::PhantomData<ReferenceBox>,
+}
diff --git a/libbindgen/tests/expectations/tests/union_dtor.rs b/libbindgen/tests/expectations/tests/union_dtor.rs
new file mode 100644
index 00000000..9be626ff
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_dtor.rs
@@ -0,0 +1,42 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct UnionWithDtor {
+ pub mFoo: __BindgenUnionField<::std::os::raw::c_int>,
+ pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub bindgen_union_field: u64,
+}
+#[test]
+fn bindgen_test_layout_UnionWithDtor() {
+ assert_eq!(::std::mem::size_of::<UnionWithDtor>() , 8usize);
+ assert_eq!(::std::mem::align_of::<UnionWithDtor>() , 8usize);
+}
diff --git a/libbindgen/tests/expectations/tests/union_fields.rs b/libbindgen/tests/expectations/tests/union_fields.rs
new file mode 100644
index 00000000..495e80f9
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_fields.rs
@@ -0,0 +1,47 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct _bindgen_ty_1 {
+ pub mInt: __BindgenUnionField<::std::os::raw::c_int>,
+ pub mFloat: __BindgenUnionField<f32>,
+ pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub bindgen_union_field: u64,
+}
+#[test]
+fn bindgen_test_layout__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<_bindgen_ty_1>() , 8usize);
+}
+impl Clone for _bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+pub type nsStyleUnion = _bindgen_ty_1;
diff --git a/libbindgen/tests/expectations/tests/union_template.rs b/libbindgen/tests/expectations/tests/union_template.rs
new file mode 100644
index 00000000..fc92afb8
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_template.rs
@@ -0,0 +1,62 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct NastyStruct<T> {
+ pub mIsSome: bool,
+ pub mStorage: NastyStruct__bindgen_ty_1<T>,
+ pub __bindgen_anon_1: NastyStruct__bindgen_ty_2<T>,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct NastyStruct__bindgen_ty_1<T> {
+ pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>,
+ pub bindgen_union_field: u64,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct NastyStruct__bindgen_ty_2<T> {
+ pub wat: __BindgenUnionField<::std::os::raw::c_short>,
+ pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>,
+ pub bindgen_union_field: u64,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Whatever<T> {
+ pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub mInt: __BindgenUnionField<::std::os::raw::c_int>,
+ pub bindgen_union_field: u64,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_anon_struct.rs b/libbindgen/tests/expectations/tests/union_with_anon_struct.rs
new file mode 100644
index 00000000..f0a21512
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_anon_struct.rs
@@ -0,0 +1,58 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: __BindgenUnionField<foo__bindgen_ty_1>,
+ pub bindgen_union_field: [u32; 2usize],
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: ::std::os::raw::c_uint,
+ pub b: ::std::os::raw::c_uint,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/libbindgen/tests/expectations/tests/union_with_anon_struct_bitfield.rs
new file mode 100644
index 00000000..548b0dc4
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_anon_struct_bitfield.rs
@@ -0,0 +1,86 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: __BindgenUnionField<::std::os::raw::c_int>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_1>,
+ pub bindgen_union_field: u32,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub _bitfield_1: u32,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+impl foo__bindgen_ty_1 {
+ #[inline]
+ pub fn b(&self) -> ::std::os::raw::c_int {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (127usize as u32)) >>
+ 0u32) as u32)
+ }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: ::std::os::raw::c_int) {
+ self._bitfield_1 &= !(127usize as u32);
+ self._bitfield_1 |= ((val as u32 as u32) << 0u32) & (127usize as u32);
+ }
+ #[inline]
+ pub fn c(&self) -> ::std::os::raw::c_int {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 &
+ (4294967168usize as u32)) >> 7u32) as
+ u32)
+ }
+ }
+ #[inline]
+ pub fn set_c(&mut self, val: ::std::os::raw::c_int) {
+ self._bitfield_1 &= !(4294967168usize as u32);
+ self._bitfield_1 |=
+ ((val as u32 as u32) << 7u32) & (4294967168usize as u32);
+ }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_anon_union.rs b/libbindgen/tests/expectations/tests/union_with_anon_union.rs
new file mode 100644
index 00000000..95278556
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_anon_union.rs
@@ -0,0 +1,59 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub bar: __BindgenUnionField<foo__bindgen_ty_1>,
+ pub bindgen_union_field: u32,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub a: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub bindgen_union_field: u32,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/libbindgen/tests/expectations/tests/union_with_anon_unnamed_struct.rs
new file mode 100644
index 00000000..2d6fab97
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_anon_unnamed_struct.rs
@@ -0,0 +1,61 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct pixel {
+ pub rgba: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub __bindgen_anon_1: __BindgenUnionField<pixel__bindgen_ty_1>,
+ pub bindgen_union_field: u32,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct pixel__bindgen_ty_1 {
+ pub r: ::std::os::raw::c_uchar,
+ pub g: ::std::os::raw::c_uchar,
+ pub b: ::std::os::raw::c_uchar,
+ pub a: ::std::os::raw::c_uchar,
+}
+#[test]
+fn bindgen_test_layout_pixel__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<pixel__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<pixel__bindgen_ty_1>() , 1usize);
+}
+impl Clone for pixel__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_pixel() {
+ assert_eq!(::std::mem::size_of::<pixel>() , 4usize);
+ assert_eq!(::std::mem::align_of::<pixel>() , 4usize);
+}
+impl Clone for pixel {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_anon_unnamed_union.rs b/libbindgen/tests/expectations/tests/union_with_anon_unnamed_union.rs
new file mode 100644
index 00000000..eb214017
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_anon_unnamed_union.rs
@@ -0,0 +1,60 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_1>,
+ pub bindgen_union_field: u32,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub c: __BindgenUnionField<::std::os::raw::c_uchar>,
+ pub bindgen_union_field: u16,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 2usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 2usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_big_member.rs b/libbindgen/tests/expectations/tests/union_with_big_member.rs
new file mode 100644
index 00000000..b921f33c
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_big_member.rs
@@ -0,0 +1,75 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Copy)]
+pub struct WithBigArray {
+ pub a: __BindgenUnionField<::std::os::raw::c_int>,
+ pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>,
+ pub bindgen_union_field: [u32; 33usize],
+}
+#[test]
+fn bindgen_test_layout_WithBigArray() {
+ assert_eq!(::std::mem::size_of::<WithBigArray>() , 132usize);
+ assert_eq!(::std::mem::align_of::<WithBigArray>() , 4usize);
+}
+impl Clone for WithBigArray {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct WithBigArray2 {
+ pub a: __BindgenUnionField<::std::os::raw::c_int>,
+ pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>,
+ pub bindgen_union_field: [u32; 9usize],
+}
+#[test]
+fn bindgen_test_layout_WithBigArray2() {
+ assert_eq!(::std::mem::size_of::<WithBigArray2>() , 36usize);
+ assert_eq!(::std::mem::align_of::<WithBigArray2>() , 4usize);
+}
+impl Clone for WithBigArray2 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Copy)]
+pub struct WithBigMember {
+ pub a: __BindgenUnionField<::std::os::raw::c_int>,
+ pub b: __BindgenUnionField<WithBigArray>,
+ pub bindgen_union_field: [u32; 33usize],
+}
+#[test]
+fn bindgen_test_layout_WithBigMember() {
+ assert_eq!(::std::mem::size_of::<WithBigMember>() , 132usize);
+ assert_eq!(::std::mem::align_of::<WithBigMember>() , 4usize);
+}
+impl Clone for WithBigMember {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/union_with_nesting.rs b/libbindgen/tests/expectations/tests/union_with_nesting.rs
new file mode 100644
index 00000000..61c08a2a
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/union_with_nesting.rs
@@ -0,0 +1,89 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
+impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: __BindgenUnionField<::std::os::raw::c_uint>,
+ pub __bindgen_anon_1: __BindgenUnionField<foo__bindgen_ty_1>,
+ pub bindgen_union_field: u32,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1 {
+ pub __bindgen_anon_1: foo__bindgen_ty_1_1,
+ pub __bindgen_anon_2: foo__bindgen_ty_1_2,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1_1 {
+ pub b1: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub b2: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub bindgen_union_field: u16,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1_1>() , 2usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1_1>() , 2usize);
+}
+impl Clone for foo__bindgen_ty_1_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo__bindgen_ty_1_2 {
+ pub c1: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub c2: __BindgenUnionField<::std::os::raw::c_ushort>,
+ pub bindgen_union_field: u16,
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1_2() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1_2>() , 2usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1_2>() , 2usize);
+}
+impl Clone for foo__bindgen_ty_1_2 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo__bindgen_ty_1() {
+ assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo__bindgen_ty_1>() , 2usize);
+}
+impl Clone for foo__bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 4usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 4usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/unknown_attr.rs b/libbindgen/tests/expectations/tests/unknown_attr.rs
new file mode 100644
index 00000000..fd9cce45
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/unknown_attr.rs
@@ -0,0 +1,16 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct _bindgen_ty_1 {
+ pub __clang_max_align_nonce1: ::std::os::raw::c_longlong,
+ pub __clang_max_align_nonce2: f64,
+}
+impl Clone for _bindgen_ty_1 {
+ fn clone(&self) -> Self { *self }
+}
+pub type max_align_t = _bindgen_ty_1;
diff --git a/libbindgen/tests/expectations/tests/use-core.rs b/libbindgen/tests/expectations/tests/use-core.rs
new file mode 100644
index 00000000..b0900f5f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/use-core.rs
@@ -0,0 +1,24 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+extern crate core;
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub a: ::std::os::raw::c_int,
+ pub b: ::std::os::raw::c_int,
+ pub bar: *mut ::std::os::raw::c_void,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::core::mem::size_of::<foo>() , 16usize);
+ assert_eq!(::core::mem::align_of::<foo>() , 8usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
+pub type fooFunction =
+ ::core::option::Option<unsafe extern "C" fn(bar: ::std::os::raw::c_int)>;
diff --git a/libbindgen/tests/expectations/tests/using.rs b/libbindgen/tests/expectations/tests/using.rs
new file mode 100644
index 00000000..dbb6c84f
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/using.rs
@@ -0,0 +1,14 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Point<T> {
+ pub x: T,
+ pub y: T,
+}
+pub type IntPoint2D = Point<::std::os::raw::c_int>;
+pub type IntVec2D = Point<::std::os::raw::c_int>;
diff --git a/libbindgen/tests/expectations/tests/vector.rs b/libbindgen/tests/expectations/tests/vector.rs
new file mode 100644
index 00000000..b8ca5735
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/vector.rs
@@ -0,0 +1,19 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct foo {
+ pub mMember: [::std::os::raw::c_longlong; 1usize],
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(::std::mem::size_of::<foo>() , 8usize);
+ assert_eq!(::std::mem::align_of::<foo>() , 8usize);
+}
+impl Clone for foo {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/virtual_dtor.rs b/libbindgen/tests/expectations/tests/virtual_dtor.rs
new file mode 100644
index 00000000..9571f084
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/virtual_dtor.rs
@@ -0,0 +1,19 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct nsSlots__bindgen_vtable {
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct nsSlots {
+ pub vtable_: *const nsSlots__bindgen_vtable,
+}
+#[test]
+fn bindgen_test_layout_nsSlots() {
+ assert_eq!(::std::mem::size_of::<nsSlots>() , 8usize);
+ assert_eq!(::std::mem::align_of::<nsSlots>() , 8usize);
+}
diff --git a/libbindgen/tests/expectations/tests/virtual_overloaded.rs b/libbindgen/tests/expectations/tests/virtual_overloaded.rs
new file mode 100644
index 00000000..7833cdbf
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/virtual_overloaded.rs
@@ -0,0 +1,22 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct C__bindgen_vtable {
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct C {
+ pub vtable_: *const C__bindgen_vtable,
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(::std::mem::size_of::<C>() , 8usize);
+ assert_eq!(::std::mem::align_of::<C>() , 8usize);
+}
+impl Clone for C {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs b/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs
new file mode 100644
index 00000000..ce62eeb0
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs
@@ -0,0 +1,35 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Derived {
+ pub _base: Base,
+}
+#[test]
+fn bindgen_test_layout_Derived() {
+ assert_eq!(::std::mem::size_of::<Derived>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Derived>() , 8usize);
+}
+impl Clone for Derived {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
+pub struct Base__bindgen_vtable {
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Base {
+ pub vtable_: *const Base__bindgen_vtable,
+}
+#[test]
+fn bindgen_test_layout_Base() {
+ assert_eq!(::std::mem::size_of::<Base>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Base>() , 8usize);
+}
+impl Clone for Base {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/weird_bitfields.rs b/libbindgen/tests/expectations/tests/weird_bitfields.rs
new file mode 100644
index 00000000..56ee76a5
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/weird_bitfields.rs
@@ -0,0 +1,128 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(u32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub enum nsStyleSVGOpacitySource {
+ eStyleSVGOpacitySource_Normal = 0,
+ eStyleSVGOpacitySource_ContextFillOpacity = 1,
+ eStyleSVGOpacitySource_ContextStrokeOpacity = 2,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Weird {
+ pub mStrokeDasharrayLength: ::std::os::raw::c_uint,
+ pub _bitfield_1: u32,
+ pub mClipRule: ::std::os::raw::c_uchar,
+ pub mColorInterpolation: ::std::os::raw::c_uchar,
+ pub mColorInterpolationFilters: ::std::os::raw::c_uchar,
+ pub mFillRule: ::std::os::raw::c_uchar,
+ pub mImageRendering: ::std::os::raw::c_uchar,
+ pub mPaintOrder: ::std::os::raw::c_uchar,
+ pub mShapeRendering: ::std::os::raw::c_uchar,
+ pub mStrokeLinecap: ::std::os::raw::c_uchar,
+ pub mStrokeLinejoin: ::std::os::raw::c_uchar,
+ pub mTextAnchor: ::std::os::raw::c_uchar,
+ pub mTextRendering: ::std::os::raw::c_uchar,
+ pub _bitfield_2: u16,
+}
+#[test]
+fn bindgen_test_layout_Weird() {
+ assert_eq!(::std::mem::size_of::<Weird>() , 24usize);
+ assert_eq!(::std::mem::align_of::<Weird>() , 4usize);
+}
+impl Clone for Weird {
+ fn clone(&self) -> Self { *self }
+}
+impl Weird {
+ #[inline]
+ pub fn bitTest(&self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 & (65535usize as u32)) >>
+ 0u32) as u32)
+ }
+ }
+ #[inline]
+ pub fn set_bitTest(&mut self, val: ::std::os::raw::c_uint) {
+ self._bitfield_1 &= !(65535usize as u32);
+ self._bitfield_1 |=
+ ((val as u32 as u32) << 0u32) & (65535usize as u32);
+ }
+ #[inline]
+ pub fn bitTest2(&self) -> ::std::os::raw::c_uint {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_1 &
+ (2147418112usize as u32)) >> 16u32) as
+ u32)
+ }
+ }
+ #[inline]
+ pub fn set_bitTest2(&mut self, val: ::std::os::raw::c_uint) {
+ self._bitfield_1 &= !(2147418112usize as u32);
+ self._bitfield_1 |=
+ ((val as u32 as u32) << 16u32) & (2147418112usize as u32);
+ }
+ #[inline]
+ pub fn mFillOpacitySource(&self) -> nsStyleSVGOpacitySource {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_2 & (7usize as u16)) >>
+ 0u32) as u32)
+ }
+ }
+ #[inline]
+ pub fn set_mFillOpacitySource(&mut self, val: nsStyleSVGOpacitySource) {
+ self._bitfield_2 &= !(7usize as u16);
+ self._bitfield_2 |= ((val as u32 as u16) << 0u32) & (7usize as u16);
+ }
+ #[inline]
+ pub fn mStrokeOpacitySource(&self) -> nsStyleSVGOpacitySource {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_2 & (56usize as u16)) >>
+ 3u32) as u32)
+ }
+ }
+ #[inline]
+ pub fn set_mStrokeOpacitySource(&mut self, val: nsStyleSVGOpacitySource) {
+ self._bitfield_2 &= !(56usize as u16);
+ self._bitfield_2 |= ((val as u32 as u16) << 3u32) & (56usize as u16);
+ }
+ #[inline]
+ pub fn mStrokeDasharrayFromObject(&self) -> bool {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_2 & (64usize as u16)) >>
+ 6u32) as u8)
+ }
+ }
+ #[inline]
+ pub fn set_mStrokeDasharrayFromObject(&mut self, val: bool) {
+ self._bitfield_2 &= !(64usize as u16);
+ self._bitfield_2 |= ((val as u8 as u16) << 6u32) & (64usize as u16);
+ }
+ #[inline]
+ pub fn mStrokeDashoffsetFromObject(&self) -> bool {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_2 & (128usize as u16)) >>
+ 7u32) as u8)
+ }
+ }
+ #[inline]
+ pub fn set_mStrokeDashoffsetFromObject(&mut self, val: bool) {
+ self._bitfield_2 &= !(128usize as u16);
+ self._bitfield_2 |= ((val as u8 as u16) << 7u32) & (128usize as u16);
+ }
+ #[inline]
+ pub fn mStrokeWidthFromObject(&self) -> bool {
+ unsafe {
+ ::std::mem::transmute(((self._bitfield_2 & (256usize as u16)) >>
+ 8u32) as u8)
+ }
+ }
+ #[inline]
+ pub fn set_mStrokeWidthFromObject(&mut self, val: bool) {
+ self._bitfield_2 &= !(256usize as u16);
+ self._bitfield_2 |= ((val as u8 as u16) << 8u32) & (256usize as u16);
+ }
+}
diff --git a/libbindgen/tests/expectations/tests/what_is_going_on.rs b/libbindgen/tests/expectations/tests/what_is_going_on.rs
new file mode 100644
index 00000000..6f1998d1
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/what_is_going_on.rs
@@ -0,0 +1,28 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct UnknownUnits {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_UnknownUnits() {
+ assert_eq!(::std::mem::size_of::<UnknownUnits>() , 1usize);
+ assert_eq!(::std::mem::align_of::<UnknownUnits>() , 1usize);
+}
+impl Clone for UnknownUnits {
+ fn clone(&self) -> Self { *self }
+}
+pub type Float = f32;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct PointTyped<units, F> {
+ pub x: F,
+ pub y: F,
+ pub _phantom_0: ::std::marker::PhantomData<units>,
+}
+pub type IntPoint = PointTyped<UnknownUnits, f32>;
diff --git a/libbindgen/tests/expectations/tests/whitelist_basic.rs b/libbindgen/tests/expectations/tests/whitelist_basic.rs
new file mode 100644
index 00000000..0104f049
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/whitelist_basic.rs
@@ -0,0 +1,18 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct WhitelistMe<T> {
+ pub foo: ::std::os::raw::c_int,
+ pub bar: WhitelistMe_Inner<T>,
+ pub _phantom_0: ::std::marker::PhantomData<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct WhitelistMe_Inner<T> {
+ pub bar: T,
+}
diff --git a/libbindgen/tests/expectations/tests/whitelist_vars.rs b/libbindgen/tests/expectations/tests/whitelist_vars.rs
new file mode 100644
index 00000000..f7af24b2
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/whitelist_vars.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub const NONE: ::std::os::raw::c_uint = 0;
+pub const FOO: ::std::os::raw::c_uint = 5;
+pub const FOOB: ::std::os::raw::c_int = -2;
+pub const FOOBAR: ::std::os::raw::c_int = -10;
diff --git a/libbindgen/tests/headers/accessors.hpp b/libbindgen/tests/headers/accessors.hpp
new file mode 100644
index 00000000..4c23e35d
--- /dev/null
+++ b/libbindgen/tests/headers/accessors.hpp
@@ -0,0 +1,46 @@
+struct SomeAccessors {
+ int mNoAccessor;
+ /** <div rustbindgen accessor></div> */
+ int mBothAccessors;
+ /** <div rustbindgen accessor="unsafe"></div> */
+ int mUnsafeAccessors;
+ /** <div rustbindgen accessor="immutable"></div> */
+ int mImmutableAccessor;
+};
+
+/** <div rustbindgen accessor></div> */
+struct AllAccessors {
+ int mBothAccessors;
+ int mAlsoBothAccessors;
+};
+
+/** <div rustbindgen accessor="unsafe"></div> */
+struct AllUnsafeAccessors {
+ int mBothAccessors;
+ int mAlsoBothAccessors;
+};
+
+/** <div rustbindgen accessor></div> */
+struct ContradictAccessors {
+ int mBothAccessors;
+ /** <div rustbindgen accessor="false"></div> */
+ int mNoAccessors;
+ /** <div rustbindgen accessor="unsafe"></div> */
+ int mUnsafeAccessors;
+ /** <div rustbindgen accessor="immutable"></div> */
+ int mImmutableAccessor;
+};
+
+/** <div rustbindgen accessor replaces="Replaced"></div> */
+struct Replacing {
+ int mAccessor;
+};
+
+struct Replaced {
+ int noOp;
+};
+
+/** <div rustbindgen accessor></div> */
+struct Wrapper {
+ Replaced mReplaced;
+};
diff --git a/libbindgen/tests/headers/annotation_hide.hpp b/libbindgen/tests/headers/annotation_hide.hpp
new file mode 100644
index 00000000..3c82c9a2
--- /dev/null
+++ b/libbindgen/tests/headers/annotation_hide.hpp
@@ -0,0 +1,16 @@
+
+/**
+ * <div rustbindgen="true" hide="true"></div>
+ */
+struct C;
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+struct D {
+ int a;
+};
+
+struct NotAnnotated {
+ int f;
+};
diff --git a/libbindgen/tests/headers/anon_enum.hpp b/libbindgen/tests/headers/anon_enum.hpp
new file mode 100644
index 00000000..c7405202
--- /dev/null
+++ b/libbindgen/tests/headers/anon_enum.hpp
@@ -0,0 +1,5 @@
+struct Test {
+ int foo;
+ float bar;
+ enum { T_NONE };
+};
diff --git a/libbindgen/tests/headers/anon_enum_whitelist.h b/libbindgen/tests/headers/anon_enum_whitelist.h
new file mode 100644
index 00000000..15cda6b1
--- /dev/null
+++ b/libbindgen/tests/headers/anon_enum_whitelist.h
@@ -0,0 +1,6 @@
+// bindgen-flags: --whitelist-var NODE_.*
+
+enum {
+ NODE_FLAG_FOO,
+ NODE_FLAG_BAR,
+};
diff --git a/libbindgen/tests/headers/anon_union.hpp b/libbindgen/tests/headers/anon_union.hpp
new file mode 100644
index 00000000..126f6a6e
--- /dev/null
+++ b/libbindgen/tests/headers/anon_union.hpp
@@ -0,0 +1,20 @@
+template<typename T>
+struct TErrorResult {
+ enum UnionState {
+ HasMessage,
+ HasException,
+ };
+ int mResult;
+ struct Message;
+ struct DOMExceptionInfo;
+ union {
+ Message* mMessage;
+ DOMExceptionInfo* mDOMExceptionInfo;
+ };
+
+ bool mMightHaveUnreported;
+ UnionState mUnionState;
+};
+
+struct ErrorResult : public TErrorResult<int> {
+};
diff --git a/libbindgen/tests/headers/arg_keyword.hpp b/libbindgen/tests/headers/arg_keyword.hpp
new file mode 100644
index 00000000..9f0af850
--- /dev/null
+++ b/libbindgen/tests/headers/arg_keyword.hpp
@@ -0,0 +1 @@
+void foo(const char* type);
diff --git a/libbindgen/tests/headers/base-to-derived.hpp b/libbindgen/tests/headers/base-to-derived.hpp
new file mode 100644
index 00000000..ea31e0f2
--- /dev/null
+++ b/libbindgen/tests/headers/base-to-derived.hpp
@@ -0,0 +1,19 @@
+// bindgen-flags: -- -std=c++11
+
+struct false_type {};
+
+template<typename _From, typename _To, bool>
+struct __is_base_to_derived_ref;
+
+template<typename _From, typename _To>
+struct __is_base_to_derived_ref<_From, _To, true>
+{
+ typedef _To type;
+
+ static constexpr bool value = type::value;
+};
+
+template<typename _From, typename _To>
+struct __is_base_to_derived_ref<_From, _To, false>
+: public false_type
+{ };
diff --git a/libbindgen/tests/headers/bitfield-enum-basic.h b/libbindgen/tests/headers/bitfield-enum-basic.h
new file mode 100644
index 00000000..364bebf2
--- /dev/null
+++ b/libbindgen/tests/headers/bitfield-enum-basic.h
@@ -0,0 +1,27 @@
+// bindgen-flags: --bitfield-enum "Foo|Buz|NS_.*|DUMMY_.*" -- -std=c++11
+
+enum Foo {
+ Bar = 1 << 1,
+ Baz = 1 << 2,
+ Duplicated = 1 << 2,
+ Negative = -3,
+};
+
+enum class Buz : signed char {
+ Bar = 1 << 1,
+ Baz = 1 << 2,
+ Duplicated = 1 << 2,
+ Negative = -3,
+};
+
+enum {
+ NS_FOO = 1 << 0,
+ NS_BAR = 1 << 1,
+};
+
+class Dummy {
+ enum {
+ DUMMY_FOO = 1 << 0,
+ DUMMY_BAR = 1 << 1,
+ };
+};
diff --git a/libbindgen/tests/headers/blocks.h b/libbindgen/tests/headers/blocks.h
new file mode 100644
index 00000000..80420e6e
--- /dev/null
+++ b/libbindgen/tests/headers/blocks.h
@@ -0,0 +1,3 @@
+// bindgen-flags: -- -fblocks
+
+void atexit_b(void (^)(void));
diff --git a/libbindgen/tests/headers/class.hpp b/libbindgen/tests/headers/class.hpp
new file mode 100644
index 00000000..e753f186
--- /dev/null
+++ b/libbindgen/tests/headers/class.hpp
@@ -0,0 +1,29 @@
+class C {
+ int a;
+ // More than rust limits (32)
+ char big_array[33];
+};
+
+class WithDtor {
+ int b;
+
+ ~WithDtor() {}
+};
+
+union Union {
+ float d;
+ int i;
+};
+
+class WithUnion {
+ Union data;
+};
+
+class RealAbstractionWithTonsOfMethods {
+ void foo();
+public:
+ void bar() const;
+ void bar();
+ void bar(int foo);
+ static void sta();
+};
diff --git a/libbindgen/tests/headers/class_nested.hpp b/libbindgen/tests/headers/class_nested.hpp
new file mode 100644
index 00000000..ab38d500
--- /dev/null
+++ b/libbindgen/tests/headers/class_nested.hpp
@@ -0,0 +1,24 @@
+class A {
+public:
+ int member_a;
+ class B {
+ int member_b;
+ };
+};
+
+A::B var;
+
+class D {
+ A::B member;
+};
+
+template<typename T>
+class Templated {
+ T member;
+
+ class Templated_inner {
+ public:
+ T* member_ptr;
+ void get() {}
+ };
+};
diff --git a/libbindgen/tests/headers/class_no_members.hpp b/libbindgen/tests/headers/class_no_members.hpp
new file mode 100644
index 00000000..a4483558
--- /dev/null
+++ b/libbindgen/tests/headers/class_no_members.hpp
@@ -0,0 +1,16 @@
+// bindgen-flags: -- -std=c++11
+
+class whatever {
+};
+
+class whatever_child: public whatever {
+};
+
+class whatever_child_with_member: public whatever {
+public:
+ int m_member;
+};
+
+static_assert(sizeof(whatever) == 1, "Testing!");
+static_assert(sizeof(whatever_child) == 1, "Testing!");
+static_assert(sizeof(whatever_child_with_member) == 4, "Testing!");
diff --git a/libbindgen/tests/headers/class_static.hpp b/libbindgen/tests/headers/class_static.hpp
new file mode 100644
index 00000000..21ab2321
--- /dev/null
+++ b/libbindgen/tests/headers/class_static.hpp
@@ -0,0 +1,7 @@
+class MyClass {
+public:
+ static const int* example;
+ static const int* example_check_no_collision;
+};
+
+static const int* example_check_no_collision;
diff --git a/libbindgen/tests/headers/class_static_const.hpp b/libbindgen/tests/headers/class_static_const.hpp
new file mode 100644
index 00000000..150afe8b
--- /dev/null
+++ b/libbindgen/tests/headers/class_static_const.hpp
@@ -0,0 +1,8 @@
+using int32_t = int;
+typedef unsigned int uint32_t;
+
+class A {
+ static const int a = 0;
+ static const int32_t b = 077;
+ static const uint32_t c = 0xff;
+};
diff --git a/libbindgen/tests/headers/class_use_as.hpp b/libbindgen/tests/headers/class_use_as.hpp
new file mode 100644
index 00000000..a4e36ded
--- /dev/null
+++ b/libbindgen/tests/headers/class_use_as.hpp
@@ -0,0 +1,15 @@
+
+/**
+ * <div rustbindgen="true" replaces="whatever"></div>
+ */
+struct whatever_replacement {
+ int replacement;
+};
+
+struct whatever {
+ int b;
+};
+
+struct container {
+ whatever c;
+};
diff --git a/libbindgen/tests/headers/class_with_dtor.hpp b/libbindgen/tests/headers/class_with_dtor.hpp
new file mode 100644
index 00000000..b9bf74e1
--- /dev/null
+++ b/libbindgen/tests/headers/class_with_dtor.hpp
@@ -0,0 +1,13 @@
+
+
+template <typename T>
+class HandleWithDtor {
+ T* ptr;
+ ~HandleWithDtor() {}
+};
+
+typedef HandleWithDtor<int> HandleValue;
+
+class WithoutDtor {
+ HandleValue shouldBeWithDtor;
+};
diff --git a/libbindgen/tests/headers/class_with_inner_struct.hpp b/libbindgen/tests/headers/class_with_inner_struct.hpp
new file mode 100644
index 00000000..ec729fe6
--- /dev/null
+++ b/libbindgen/tests/headers/class_with_inner_struct.hpp
@@ -0,0 +1,43 @@
+// bindgen-flags: -- -std=c++11
+
+class A {
+ unsigned c;
+ struct Segment { int begin, end; };
+ union {
+ int f;
+ } named_union;
+ union {
+ int d;
+ };
+};
+
+class B {
+ unsigned d;
+ struct Segment { int begin, end; };
+};
+
+
+enum class StepSyntax {
+ Keyword, // step-start and step-end
+ FunctionalWithoutKeyword, // steps(...)
+ FunctionalWithStartKeyword, // steps(..., start)
+ FunctionalWithEndKeyword, // steps(..., end)
+};
+
+class C {
+ unsigned d;
+ union {
+ struct {
+ float mX1;
+ float mY1;
+ float mX2;
+ float mY2;
+ } mFunc;
+ struct {
+ StepSyntax mStepSyntax;
+ unsigned int mSteps;
+ };
+ };
+ // To ensure it doesn't collide
+ struct Segment { int begin, end; };
+};
diff --git a/libbindgen/tests/headers/class_with_typedef.hpp b/libbindgen/tests/headers/class_with_typedef.hpp
new file mode 100644
index 00000000..8707cffe
--- /dev/null
+++ b/libbindgen/tests/headers/class_with_typedef.hpp
@@ -0,0 +1,22 @@
+typedef int AnotherInt;
+
+class C {
+public:
+ typedef int MyInt;
+ typedef const char* Lookup;
+ MyInt c;
+ MyInt* ptr;
+ MyInt arr[10];
+ AnotherInt d;
+ AnotherInt* other_ptr;
+
+ void method(MyInt c);
+ void methodRef(MyInt& c);
+ void complexMethodRef(Lookup& c);
+ void anotherMethod(AnotherInt c);
+};
+
+class D: public C {
+public:
+ MyInt* ptr;
+};
diff --git a/libbindgen/tests/headers/complex.h b/libbindgen/tests/headers/complex.h
new file mode 100644
index 00000000..04877a4e
--- /dev/null
+++ b/libbindgen/tests/headers/complex.h
@@ -0,0 +1,16 @@
+
+#define COMPLEX_TEST(ty_, name_) \
+ struct Test##name_ { \
+ ty_ _Complex mMember; \
+ \
+ }; \
+ struct Test##name_##Ptr { \
+ ty_ _Complex* mMember; \
+ };
+
+COMPLEX_TEST(double, Double)
+COMPLEX_TEST(float, Float)
+
+// FIXME: 128-byte-aligned in some machines
+// which we can't support right now in Rust.
+// COMPLEX_TEST(long double, LongDouble)
diff --git a/libbindgen/tests/headers/complex_global.h b/libbindgen/tests/headers/complex_global.h
new file mode 100644
index 00000000..d9f9fb01
--- /dev/null
+++ b/libbindgen/tests/headers/complex_global.h
@@ -0,0 +1,3 @@
+float _Complex globalValueFloat;
+double _Complex globalValueDouble;
+long double _Complex globalValueLongDouble;
diff --git a/libbindgen/tests/headers/const_enum_unnamed.hpp b/libbindgen/tests/headers/const_enum_unnamed.hpp
new file mode 100644
index 00000000..eb139434
--- /dev/null
+++ b/libbindgen/tests/headers/const_enum_unnamed.hpp
@@ -0,0 +1,9 @@
+
+enum {
+ FOO_BAR,
+ FOO_BAZ,
+};
+
+class Foo {
+ enum { FOO_BAR = 10 };
+};
diff --git a/libbindgen/tests/headers/const_ptr.hpp b/libbindgen/tests/headers/const_ptr.hpp
new file mode 100644
index 00000000..66744f8b
--- /dev/null
+++ b/libbindgen/tests/headers/const_ptr.hpp
@@ -0,0 +1,3 @@
+extern "C" {
+ void foo(const void* bar);
+}
diff --git a/libbindgen/tests/headers/const_resolved_ty.h b/libbindgen/tests/headers/const_resolved_ty.h
new file mode 100644
index 00000000..2521e61c
--- /dev/null
+++ b/libbindgen/tests/headers/const_resolved_ty.h
@@ -0,0 +1,3 @@
+typedef unsigned char uint8_t;
+
+void foo(const uint8_t* foo);
diff --git a/libbindgen/tests/headers/const_tparam.hpp b/libbindgen/tests/headers/const_tparam.hpp
new file mode 100644
index 00000000..05f26e4a
--- /dev/null
+++ b/libbindgen/tests/headers/const_tparam.hpp
@@ -0,0 +1,5 @@
+template<typename T>
+class C {
+ const T* const foo;
+ const T* bar;
+};
diff --git a/libbindgen/tests/headers/convert-floats.h b/libbindgen/tests/headers/convert-floats.h
new file mode 100644
index 00000000..08d9fe0b
--- /dev/null
+++ b/libbindgen/tests/headers/convert-floats.h
@@ -0,0 +1,9 @@
+// bindgen-flags: --no-convert-floats
+
+struct foo {
+ float bar, baz;
+ double bazz;
+ long double* bazzz;
+ float _Complex complexFloat;
+ double _Complex complexDouble;
+};
diff --git a/libbindgen/tests/headers/crtp.hpp b/libbindgen/tests/headers/crtp.hpp
new file mode 100644
index 00000000..a5477c54
--- /dev/null
+++ b/libbindgen/tests/headers/crtp.hpp
@@ -0,0 +1,12 @@
+template<class T>
+class Base {};
+
+class Derived : public Base<Derived> {};
+
+template<class T>
+class BaseWithDestructor {
+ ~BaseWithDestructor();
+};
+
+class DerivedFromBaseWithDestructor :
+ public BaseWithDestructor<DerivedFromBaseWithDestructor> {};
diff --git a/libbindgen/tests/headers/decl_extern_int_twice.h b/libbindgen/tests/headers/decl_extern_int_twice.h
new file mode 100644
index 00000000..06f80e87
--- /dev/null
+++ b/libbindgen/tests/headers/decl_extern_int_twice.h
@@ -0,0 +1,2 @@
+extern int foo;
+extern int foo;
diff --git a/libbindgen/tests/headers/decl_ptr_to_array.h b/libbindgen/tests/headers/decl_ptr_to_array.h
new file mode 100644
index 00000000..3222cbd4
--- /dev/null
+++ b/libbindgen/tests/headers/decl_ptr_to_array.h
@@ -0,0 +1 @@
+int (*foo)[1];
diff --git a/libbindgen/tests/headers/duplicated_constants_in_ns.hpp b/libbindgen/tests/headers/duplicated_constants_in_ns.hpp
new file mode 100644
index 00000000..bb343641
--- /dev/null
+++ b/libbindgen/tests/headers/duplicated_constants_in_ns.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --enable-cxx-namespaces
+namespace foo {
+ const int FOO = 4;
+}
+namespace bar {
+ const int FOO = 5;
+}
diff --git a/libbindgen/tests/headers/elaborated.hpp b/libbindgen/tests/headers/elaborated.hpp
new file mode 100644
index 00000000..4bfbff23
--- /dev/null
+++ b/libbindgen/tests/headers/elaborated.hpp
@@ -0,0 +1,5 @@
+namespace whatever {
+ typedef int whatever_t;
+}
+
+void something(const whatever::whatever_t *wat);
diff --git a/libbindgen/tests/headers/empty_template_param_name.hpp b/libbindgen/tests/headers/empty_template_param_name.hpp
new file mode 100644
index 00000000..b3360bc9
--- /dev/null
+++ b/libbindgen/tests/headers/empty_template_param_name.hpp
@@ -0,0 +1,4 @@
+template<typename...> using __void_t = void;
+
+template<typename _Iterator, typename = __void_t<>>
+ struct __iterator_traits { };
diff --git a/libbindgen/tests/headers/enum.h b/libbindgen/tests/headers/enum.h
new file mode 100644
index 00000000..f2d301e7
--- /dev/null
+++ b/libbindgen/tests/headers/enum.h
@@ -0,0 +1,9 @@
+enum Foo {
+ Bar = 0,
+ Qux
+};
+
+enum Neg {
+ MinusOne = -1,
+ One = 1,
+};
diff --git a/libbindgen/tests/headers/enum_alias.hpp b/libbindgen/tests/headers/enum_alias.hpp
new file mode 100644
index 00000000..658f8fde
--- /dev/null
+++ b/libbindgen/tests/headers/enum_alias.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: -- -std=c++11
+
+typedef unsigned char uint8_t;
+
+enum Bar : uint8_t {
+ VAL
+};
diff --git a/libbindgen/tests/headers/enum_and_vtable_mangling.hpp b/libbindgen/tests/headers/enum_and_vtable_mangling.hpp
new file mode 100644
index 00000000..3abd6a29
--- /dev/null
+++ b/libbindgen/tests/headers/enum_and_vtable_mangling.hpp
@@ -0,0 +1,11 @@
+
+enum {
+ match,
+ whatever_else,
+};
+
+class C {
+ int i;
+public:
+ virtual void match() { };
+};
diff --git a/libbindgen/tests/headers/enum_dupe.h b/libbindgen/tests/headers/enum_dupe.h
new file mode 100644
index 00000000..6d3591d5
--- /dev/null
+++ b/libbindgen/tests/headers/enum_dupe.h
@@ -0,0 +1,4 @@
+enum Foo {
+ Bar = 1,
+ Dupe = 1
+};
diff --git a/libbindgen/tests/headers/enum_explicit_type.hpp b/libbindgen/tests/headers/enum_explicit_type.hpp
new file mode 100644
index 00000000..78eadd40
--- /dev/null
+++ b/libbindgen/tests/headers/enum_explicit_type.hpp
@@ -0,0 +1,28 @@
+// bindgen-flags: -- -std=c++11
+
+enum Foo: unsigned char {
+ Bar = 0,
+ Qux
+};
+
+enum Neg: char {
+ MinusOne = -1,
+ One = 1,
+};
+
+enum Bigger: unsigned short {
+ Much = 255,
+ Larger
+};
+
+enum MuchLong: long {
+ MuchLow = -4294967296,
+};
+
+enum MuchLongLong: long long {
+ I64_MIN = 1ll << 63,
+};
+
+enum MuchULongLong: unsigned long long {
+ MuchHigh = 4294967296,
+};
diff --git a/libbindgen/tests/headers/enum_negative.h b/libbindgen/tests/headers/enum_negative.h
new file mode 100644
index 00000000..6cbdfe04
--- /dev/null
+++ b/libbindgen/tests/headers/enum_negative.h
@@ -0,0 +1,4 @@
+enum Foo {
+ Bar = -2,
+ Qux = 1,
+};
diff --git a/libbindgen/tests/headers/enum_packed.h b/libbindgen/tests/headers/enum_packed.h
new file mode 100644
index 00000000..8654d110
--- /dev/null
+++ b/libbindgen/tests/headers/enum_packed.h
@@ -0,0 +1,14 @@
+enum __attribute__((packed)) Foo {
+ Bar = 0,
+ Qux
+};
+
+enum __attribute__((packed)) Neg {
+ MinusOne = -1,
+ One = 1,
+};
+
+enum __attribute__((packed)) Bigger {
+ Much = 255,
+ Larger
+};
diff --git a/libbindgen/tests/headers/extern.hpp b/libbindgen/tests/headers/extern.hpp
new file mode 100644
index 00000000..0779e038
--- /dev/null
+++ b/libbindgen/tests/headers/extern.hpp
@@ -0,0 +1,3 @@
+extern "C" {
+#include "func_proto.h"
+}
diff --git a/libbindgen/tests/headers/float128.hpp b/libbindgen/tests/headers/float128.hpp
new file mode 100644
index 00000000..f554e88e
--- /dev/null
+++ b/libbindgen/tests/headers/float128.hpp
@@ -0,0 +1,13 @@
+// FIXME: libclang < 3.9 does not expose `__float128` in its interface, so this
+// test will fail. Once we remove support for `--features llvm_stable` and
+// require libclang >= 3.9, we can reenable this test.
+//
+// static __float128 global = 1.0;
+
+// FIXME: We have no way to get 128 bit aligned structs in Rust at the moment,
+// and therefore the generated layout tests for this struct will fail. When we
+// can enforce 128 bit alignment, we can re-enable this test.
+//
+// struct A {
+// __float128 f;
+// };
diff --git a/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp b/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp
new file mode 100644
index 00000000..437fff5d
--- /dev/null
+++ b/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp
@@ -0,0 +1,8 @@
+template <typename> class Rooted;
+namespace js {
+ template <typename T> class RootedBase {
+ T* foo;
+ Rooted<T>* next;
+ };
+}
+template <typename T> class Rooted : js::RootedBase<T> {};
diff --git a/libbindgen/tests/headers/forward-inherit-struct.hpp b/libbindgen/tests/headers/forward-inherit-struct.hpp
new file mode 100644
index 00000000..ac7aef5e
--- /dev/null
+++ b/libbindgen/tests/headers/forward-inherit-struct.hpp
@@ -0,0 +1,5 @@
+template <typename> class Rooted;
+namespace js {
+ template <typename T> class RootedBase {};
+}
+template <typename T> class Rooted : js::RootedBase<T> {};
diff --git a/libbindgen/tests/headers/forward_declared_struct.h b/libbindgen/tests/headers/forward_declared_struct.h
new file mode 100644
index 00000000..2a69450c
--- /dev/null
+++ b/libbindgen/tests/headers/forward_declared_struct.h
@@ -0,0 +1,11 @@
+struct a;
+
+struct a {
+ int b;
+};
+
+struct c {
+ int d;
+};
+
+struct c; \ No newline at end of file
diff --git a/libbindgen/tests/headers/func_proto.h b/libbindgen/tests/headers/func_proto.h
new file mode 100644
index 00000000..51139ca9
--- /dev/null
+++ b/libbindgen/tests/headers/func_proto.h
@@ -0,0 +1 @@
+typedef int foo(int bar);
diff --git a/libbindgen/tests/headers/func_ptr.h b/libbindgen/tests/headers/func_ptr.h
new file mode 100644
index 00000000..a4662f3d
--- /dev/null
+++ b/libbindgen/tests/headers/func_ptr.h
@@ -0,0 +1 @@
+int (*foo) (int x, int y);
diff --git a/libbindgen/tests/headers/func_ptr_in_struct.h b/libbindgen/tests/headers/func_ptr_in_struct.h
new file mode 100644
index 00000000..988db5b3
--- /dev/null
+++ b/libbindgen/tests/headers/func_ptr_in_struct.h
@@ -0,0 +1,6 @@
+
+enum baz;
+
+struct Foo {
+ enum baz (*bar) (int x, int y);
+};
diff --git a/libbindgen/tests/headers/func_with_array_arg.h b/libbindgen/tests/headers/func_with_array_arg.h
new file mode 100644
index 00000000..1b81702b
--- /dev/null
+++ b/libbindgen/tests/headers/func_with_array_arg.h
@@ -0,0 +1 @@
+void f(int x[2]);
diff --git a/libbindgen/tests/headers/func_with_func_ptr_arg.h b/libbindgen/tests/headers/func_with_func_ptr_arg.h
new file mode 100644
index 00000000..629c84ab
--- /dev/null
+++ b/libbindgen/tests/headers/func_with_func_ptr_arg.h
@@ -0,0 +1 @@
+void foo(void (*bar)());
diff --git a/libbindgen/tests/headers/in_class_typedef.hpp b/libbindgen/tests/headers/in_class_typedef.hpp
new file mode 100644
index 00000000..dda7472d
--- /dev/null
+++ b/libbindgen/tests/headers/in_class_typedef.hpp
@@ -0,0 +1,10 @@
+
+template<typename T>
+class Foo {
+ typedef T elem_type;
+ typedef T* ptr_type;
+
+ typedef struct Bar {
+ int x, y;
+ } Bar;
+};
diff --git a/libbindgen/tests/headers/inherit-namespaced.hpp b/libbindgen/tests/headers/inherit-namespaced.hpp
new file mode 100644
index 00000000..61eafd5a
--- /dev/null
+++ b/libbindgen/tests/headers/inherit-namespaced.hpp
@@ -0,0 +1,4 @@
+namespace js {
+ template <typename T> class RootedBase {};
+}
+template <typename T> class Rooted : js::RootedBase<T> {};
diff --git a/libbindgen/tests/headers/inherit_named.hpp b/libbindgen/tests/headers/inherit_named.hpp
new file mode 100644
index 00000000..9881d1b6
--- /dev/null
+++ b/libbindgen/tests/headers/inherit_named.hpp
@@ -0,0 +1,5 @@
+template<typename T>
+class Wohoo {};
+
+template<typename T>
+class Weeee : public T {};
diff --git a/libbindgen/tests/headers/inherit_typedef.hpp b/libbindgen/tests/headers/inherit_typedef.hpp
new file mode 100644
index 00000000..8d699e82
--- /dev/null
+++ b/libbindgen/tests/headers/inherit_typedef.hpp
@@ -0,0 +1,5 @@
+struct Foo {};
+
+typedef Foo TypedefedFoo;
+
+struct Bar: public TypedefedFoo {};
diff --git a/libbindgen/tests/headers/inner_const.hpp b/libbindgen/tests/headers/inner_const.hpp
new file mode 100644
index 00000000..25c2e603
--- /dev/null
+++ b/libbindgen/tests/headers/inner_const.hpp
@@ -0,0 +1,6 @@
+
+class Foo {
+ static int BOO;
+ static Foo whatever;
+ int bar;
+};
diff --git a/libbindgen/tests/headers/inner_template_self.hpp b/libbindgen/tests/headers/inner_template_self.hpp
new file mode 100644
index 00000000..1ae5af06
--- /dev/null
+++ b/libbindgen/tests/headers/inner_template_self.hpp
@@ -0,0 +1,10 @@
+
+template <typename T>
+class LinkedList {
+ LinkedList<T>* next;
+ LinkedList* prev;
+};
+
+class InstantiateIt {
+ LinkedList<int> m_list;
+};
diff --git a/libbindgen/tests/headers/int128_t.h b/libbindgen/tests/headers/int128_t.h
new file mode 100644
index 00000000..eece252c
--- /dev/null
+++ b/libbindgen/tests/headers/int128_t.h
@@ -0,0 +1,7 @@
+/**
+ * FIXME: Uncomment this once we can generate the proper alignment for the type,
+ * i.e., when we use u128/i128.
+struct Foo {
+ __int128 foo;
+};
+ */
diff --git a/libbindgen/tests/headers/jsval_layout_opaque.hpp b/libbindgen/tests/headers/jsval_layout_opaque.hpp
new file mode 100644
index 00000000..85c5be63
--- /dev/null
+++ b/libbindgen/tests/headers/jsval_layout_opaque.hpp
@@ -0,0 +1,424 @@
+// bindgen-flags: --no-unstable-rust -- -std=c++11
+
+/**
+ * These typedefs are hacky, but keep our tests consistent across 64-bit
+ * platforms, otherwise the id's change and our CI is unhappy.
+ */
+typedef unsigned char uint8_t;
+typedef int int32_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef unsigned long long size_t;
+typedef unsigned long long uintptr_t;
+
+
+#define JS_PUNBOX64
+#define IS_LITTLE_ENDIAN
+
+/*
+ * Try to get jsvals 64-bit aligned. We could almost assert that all values are
+ * aligned, but MSVC and GCC occasionally break alignment.
+ */
+#if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__)
+# define JSVAL_ALIGNMENT __attribute__((aligned (8)))
+#elif defined(_MSC_VER)
+ /*
+ * Structs can be aligned with MSVC, but not if they are used as parameters,
+ * so we just don't try to align.
+ */
+# define JSVAL_ALIGNMENT
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+# define JSVAL_ALIGNMENT
+#elif defined(__HP_cc) || defined(__HP_aCC)
+# define JSVAL_ALIGNMENT
+#endif
+
+#if defined(JS_PUNBOX64)
+# define JSVAL_TAG_SHIFT 47
+#endif
+
+/*
+ * We try to use enums so that printing a jsval_layout in the debugger shows
+ * nice symbolic type tags, however we can only do this when we can force the
+ * underlying type of the enum to be the desired size.
+ */
+#if !defined(__SUNPRO_CC) && !defined(__xlC__)
+
+#if defined(_MSC_VER)
+# define JS_ENUM_HEADER(id, type) enum id : type
+# define JS_ENUM_FOOTER(id)
+#else
+# define JS_ENUM_HEADER(id, type) enum id
+# define JS_ENUM_FOOTER(id) __attribute__((packed))
+#endif
+
+/* Remember to propagate changes to the C defines below. */
+JS_ENUM_HEADER(JSValueType, uint8_t)
+{
+ JSVAL_TYPE_DOUBLE = 0x00,
+ JSVAL_TYPE_INT32 = 0x01,
+ JSVAL_TYPE_UNDEFINED = 0x02,
+ JSVAL_TYPE_BOOLEAN = 0x03,
+ JSVAL_TYPE_MAGIC = 0x04,
+ JSVAL_TYPE_STRING = 0x05,
+ JSVAL_TYPE_SYMBOL = 0x06,
+ JSVAL_TYPE_NULL = 0x07,
+ JSVAL_TYPE_OBJECT = 0x08,
+
+ /* These never appear in a jsval; they are only provided as an out-of-band value. */
+ JSVAL_TYPE_UNKNOWN = 0x20,
+ JSVAL_TYPE_MISSING = 0x21
+} JS_ENUM_FOOTER(JSValueType);
+
+static_assert(sizeof(JSValueType) == 1,
+ "compiler typed enum support is apparently buggy");
+
+#if defined(JS_NUNBOX32)
+
+/* Remember to propagate changes to the C defines below. */
+JS_ENUM_HEADER(JSValueTag, uint32_t)
+{
+ JSVAL_TAG_CLEAR = 0xFFFFFF80,
+ JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32,
+ JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED,
+ JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING,
+ JSVAL_TAG_SYMBOL = JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL,
+ JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN,
+ JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC,
+ JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL,
+ JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT
+} JS_ENUM_FOOTER(JSValueTag);
+
+static_assert(sizeof(JSValueTag) == sizeof(uint32_t),
+ "compiler typed enum support is apparently buggy");
+
+#elif defined(JS_PUNBOX64)
+
+/* Remember to propagate changes to the C defines below. */
+JS_ENUM_HEADER(JSValueTag, uint32_t)
+{
+ JSVAL_TAG_MAX_DOUBLE = 0x1FFF0,
+ JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32,
+ JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED,
+ JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING,
+ JSVAL_TAG_SYMBOL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL,
+ JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN,
+ JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC,
+ JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL,
+ JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT
+} JS_ENUM_FOOTER(JSValueTag);
+
+static_assert(sizeof(JSValueTag) == sizeof(uint32_t),
+ "compiler typed enum support is apparently buggy");
+
+JS_ENUM_HEADER(JSValueShiftedTag, uint64_t)
+{
+ JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF),
+ JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_SYMBOL = (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT),
+ JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT)
+} JS_ENUM_FOOTER(JSValueShiftedTag);
+
+static_assert(sizeof(JSValueShiftedTag) == sizeof(uint64_t),
+ "compiler typed enum support is apparently buggy");
+
+#endif
+
+/*
+ * All our supported compilers implement C++11 |enum Foo : T| syntax, so don't
+ * expose these macros. (This macro exists *only* because gcc bug 51242
+ * <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242> makes bit-fields of
+ * typed enums trigger a warning that can't be turned off. Don't expose it
+ * beyond this file!)
+ */
+#undef JS_ENUM_HEADER
+#undef JS_ENUM_FOOTER
+
+#else /* !defined(__SUNPRO_CC) && !defined(__xlC__) */
+
+typedef uint8_t JSValueType;
+#define JSVAL_TYPE_DOUBLE ((uint8_t)0x00)
+#define JSVAL_TYPE_INT32 ((uint8_t)0x01)
+#define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02)
+#define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03)
+#define JSVAL_TYPE_MAGIC ((uint8_t)0x04)
+#define JSVAL_TYPE_STRING ((uint8_t)0x05)
+#define JSVAL_TYPE_SYMBOL ((uint8_t)0x06)
+#define JSVAL_TYPE_NULL ((uint8_t)0x07)
+#define JSVAL_TYPE_OBJECT ((uint8_t)0x08)
+#define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20)
+
+#if defined(JS_NUNBOX32)
+
+typedef uint32_t JSValueTag;
+#define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80))
+#define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32))
+#define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED))
+#define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING))
+#define JSVAL_TAG_SYMBOL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL))
+#define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN))
+#define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC))
+#define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL))
+#define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT))
+
+#elif defined(JS_PUNBOX64)
+
+typedef uint32_t JSValueTag;
+#define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0))
+#define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32)
+#define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED)
+#define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING)
+#define JSVAL_TAG_SYMBOL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL)
+#define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN)
+#define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC)
+#define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL)
+#define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT)
+
+typedef uint64_t JSValueShiftedTag;
+#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF)
+#define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_SYMBOL (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT)
+#define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT)
+
+#endif /* JS_PUNBOX64 */
+#endif /* !defined(__SUNPRO_CC) && !defined(__xlC__) */
+
+#if defined(JS_NUNBOX32)
+
+#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type)))
+
+#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL
+#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT
+#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32
+#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING
+
+#elif defined(JS_PUNBOX64)
+
+#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL
+#define JSVAL_TAG_MASK 0xFFFF800000000000LL
+#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type)))
+#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT)
+
+#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL
+#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT
+#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32
+#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING
+
+#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL
+#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT
+#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED
+#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING
+
+#endif /* JS_PUNBOX64 */
+
+typedef enum JSWhyMagic
+{
+ /** a hole in a native object's elements */
+ JS_ELEMENTS_HOLE,
+
+ /** there is not a pending iterator value */
+ JS_NO_ITER_VALUE,
+
+ /** exception value thrown when closing a generator */
+ JS_GENERATOR_CLOSING,
+
+ /** compiler sentinel value */
+ JS_NO_CONSTANT,
+
+ /** used in debug builds to catch tracing errors */
+ JS_THIS_POISON,
+
+ /** used in debug builds to catch tracing errors */
+ JS_ARG_POISON,
+
+ /** an empty subnode in the AST serializer */
+ JS_SERIALIZE_NO_NODE,
+
+ /** lazy arguments value on the stack */
+ JS_LAZY_ARGUMENTS,
+
+ /** optimized-away 'arguments' value */
+ JS_OPTIMIZED_ARGUMENTS,
+
+ /** magic value passed to natives to indicate construction */
+ JS_IS_CONSTRUCTING,
+
+ /** arguments.callee has been overwritten */
+ JS_OVERWRITTEN_CALLEE,
+
+ /** value of static block object slot */
+ JS_BLOCK_NEEDS_CLONE,
+
+ /** see class js::HashableValue */
+ JS_HASH_KEY_EMPTY,
+
+ /** error while running Ion code */
+ JS_ION_ERROR,
+
+ /** missing recover instruction result */
+ JS_ION_BAILOUT,
+
+ /** optimized out slot */
+ JS_OPTIMIZED_OUT,
+
+ /** uninitialized lexical bindings that produce ReferenceError on touch. */
+ JS_UNINITIALIZED_LEXICAL,
+
+ /** for local use */
+ JS_GENERIC_MAGIC,
+
+ JS_WHY_MAGIC_COUNT
+} JSWhyMagic;
+
+#if defined(IS_LITTLE_ENDIAN)
+# if defined(JS_NUNBOX32)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ struct {
+ union {
+ int32_t i32;
+ uint32_t u32;
+ uint32_t boo; // Don't use |bool| -- it must be four bytes.
+ JSString* str;
+ JS::Symbol* sym;
+ JSObject* obj;
+ js::gc::Cell* cell;
+ void* ptr;
+ JSWhyMagic why;
+ size_t word;
+ uintptr_t uintptr;
+ } payload;
+ JSValueTag tag;
+ } s;
+ double asDouble;
+ void* asPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# elif defined(JS_PUNBOX64)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+#if !defined(_WIN64)
+ /* MSVC does not pack these correctly :-( */
+ struct {
+ uint64_t payload47 : 47;
+ JSValueTag tag : 17;
+ } debugView;
+#endif
+ struct {
+ union {
+ int32_t i32;
+ uint32_t u32;
+ JSWhyMagic why;
+ } payload;
+ } s;
+ double asDouble;
+ void* asPtr;
+ size_t asWord;
+ uintptr_t asUIntPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# endif /* JS_PUNBOX64 */
+#else /* defined(IS_LITTLE_ENDIAN) */
+# if defined(JS_NUNBOX32)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ struct {
+ JSValueTag tag;
+ union {
+ int32_t i32;
+ uint32_t u32;
+ uint32_t boo; // Don't use |bool| -- it must be four bytes.
+ JSString* str;
+ JS::Symbol* sym;
+ JSObject* obj;
+ js::gc::Cell* cell;
+ void* ptr;
+ JSWhyMagic why;
+ size_t word;
+ uintptr_t uintptr;
+ } payload;
+ } s;
+ double asDouble;
+ void* asPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# elif defined(JS_PUNBOX64)
+typedef union jsval_layout
+{
+ uint64_t asBits;
+ struct {
+ JSValueTag tag : 17;
+ uint64_t payload47 : 47;
+ } debugView;
+ struct {
+ uint32_t padding;
+ union {
+ int32_t i32;
+ uint32_t u32;
+ JSWhyMagic why;
+ } payload;
+ } s;
+ double asDouble;
+ void* asPtr;
+ size_t asWord;
+ uintptr_t asUIntPtr;
+} JSVAL_ALIGNMENT jsval_layout;
+# endif /* JS_PUNBOX64 */
+#endif /* defined(IS_LITTLE_ENDIAN) */
+
+/*
+ * For codesize purposes on some platforms, it's important that the
+ * compiler know that JS::Values constructed from constant values can be
+ * folded to constant bit patterns at compile time, rather than
+ * constructed at runtime. Doing this requires a fair amount of C++11
+ * features, which are not supported on all of our compilers. Set up
+ * some defines and helper macros in an attempt to confine the ugliness
+ * here, rather than scattering it all about the file. The important
+ * features are:
+ *
+ * - constexpr;
+ * - defaulted functions;
+ * - C99-style designated initializers.
+ */
+#if defined(__clang__)
+# if __has_feature(cxx_constexpr) && __has_feature(cxx_defaulted_functions)
+# define JS_VALUE_IS_CONSTEXPR
+# endif
+#elif defined(__GNUC__)
+/*
+ * We need 4.5 for defaulted functions, 4.6 for constexpr, 4.7 because 4.6
+ * doesn't understand |(X) { .field = ... }| syntax, and 4.7.3 because
+ * versions prior to that have bugs in the C++ front-end that cause crashes.
+ */
+# if MOZ_GCC_VERSION_AT_LEAST(4, 7, 3)
+# define JS_VALUE_IS_CONSTEXPR
+# endif
+#endif
+
+#if defined(JS_VALUE_IS_CONSTEXPR)
+# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \
+ return (jsval_layout) { .asBits = (BITS) }
+# define JS_VALUE_CONSTEXPR MOZ_CONSTEXPR
+# define JS_VALUE_CONSTEXPR_VAR MOZ_CONSTEXPR_VAR
+#else
+# define JS_RETURN_LAYOUT_FROM_BITS(BITS) \
+ jsval_layout l; \
+ l.asBits = (BITS); \
+ return l;
+# define JS_VALUE_CONSTEXPR
+# define JS_VALUE_CONSTEXPR_VAR const
+#endif
+
+struct Value {
+ jsval_layout data;
+};
diff --git a/libbindgen/tests/headers/keywords.h b/libbindgen/tests/headers/keywords.h
new file mode 100644
index 00000000..8699ce5f
--- /dev/null
+++ b/libbindgen/tests/headers/keywords.h
@@ -0,0 +1,49 @@
+int u8;
+int u16;
+int u32;
+int u64;
+int i8;
+int i16;
+int i32;
+int i64;
+int f32;
+int f64;
+int usize;
+int isize;
+int as;
+int box;
+int crate;
+int false;
+int fn;
+int impl;
+int in;
+int let;
+int loop;
+int match;
+int mod;
+int move;
+int mut;
+int pub;
+int ref;
+int self;
+int Self;
+int super;
+int trait;
+int true;
+int type;
+int unsafe;
+int use;
+int where;
+int abstract;
+int alignof;
+int become;
+int final;
+int macro;
+int offsetof;
+int override;
+int priv;
+int proc;
+int pure;
+int unsized;
+int virtual;
+int yield;
diff --git a/libbindgen/tests/headers/macro-expr-basic.h b/libbindgen/tests/headers/macro-expr-basic.h
new file mode 100644
index 00000000..d2de7fdf
--- /dev/null
+++ b/libbindgen/tests/headers/macro-expr-basic.h
@@ -0,0 +1,14 @@
+#define FOO 1
+#define BAR 4
+#define BAZ (FOO + BAR)
+
+#define MIN (1 << 63)
+
+#define BARR (1 << 0)
+#define BAZZ ((1 << 1) + BAZ)
+#define I_RAN_OUT_OF_DUMB_NAMES (BARR | BAZZ)
+
+/* I haz a comment */
+#define HAZ_A_COMMENT BARR
+
+#define HAZ_A_COMMENT_INSIDE (/* comment for real */ BARR + FOO)
diff --git a/libbindgen/tests/headers/macro-redef.h b/libbindgen/tests/headers/macro-redef.h
new file mode 100644
index 00000000..0180d2ab
--- /dev/null
+++ b/libbindgen/tests/headers/macro-redef.h
@@ -0,0 +1,5 @@
+#define FOO 4
+#define BAR (1 + FOO)
+#undef FOO
+#define FOO 5
+#define BAZ (1 + FOO)
diff --git a/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp b/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp
new file mode 100644
index 00000000..1e2b133a
--- /dev/null
+++ b/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp
@@ -0,0 +1,3 @@
+struct Foo {};
+struct Bar {};
+struct Baz : public Foo, public Bar {};
diff --git a/libbindgen/tests/headers/mutable.hpp b/libbindgen/tests/headers/mutable.hpp
new file mode 100644
index 00000000..b61a1031
--- /dev/null
+++ b/libbindgen/tests/headers/mutable.hpp
@@ -0,0 +1,14 @@
+class C {
+ mutable int m_member;
+ int m_other;
+};
+
+class NonCopiable {
+ mutable int m_member;
+
+ ~NonCopiable() {};
+};
+
+class NonCopiableWithNonCopiableMutableMember {
+ mutable NonCopiable m_member;
+};
diff --git a/libbindgen/tests/headers/namespace.hpp b/libbindgen/tests/headers/namespace.hpp
new file mode 100644
index 00000000..65788539
--- /dev/null
+++ b/libbindgen/tests/headers/namespace.hpp
@@ -0,0 +1,47 @@
+// bindgen-flags: --enable-cxx-namespaces
+
+void top_level();
+
+namespace whatever {
+ typedef int whatever_int_t;
+
+ void in_whatever();
+}
+
+namespace {
+ namespace empty {}
+
+ void foo();
+ struct A {
+ whatever::whatever_int_t b;
+ public:
+ int lets_hope_this_works();
+ };
+}
+
+template<typename T>
+class C: public A {
+ T m_c;
+ T* m_c_ptr;
+ T m_c_arr[10];
+};
+
+
+template<>
+class C<int>;
+
+
+namespace w {
+ typedef unsigned int whatever_int_t;
+
+ template<typename T>
+ class D {
+ C<T> m_c;
+ };
+
+ whatever_int_t heh(); // this should return w::whatever_int_t, and not whatever::whatever_int_t
+
+ C<int> foo();
+
+ C<float> barr(); // <- This is the problematic one
+}
diff --git a/libbindgen/tests/headers/nested.hpp b/libbindgen/tests/headers/nested.hpp
new file mode 100644
index 00000000..299e1768
--- /dev/null
+++ b/libbindgen/tests/headers/nested.hpp
@@ -0,0 +1,15 @@
+
+class Calc {
+ int w;
+};
+
+class Test {
+public:
+ struct Size;
+ friend struct Size;
+ struct Size {
+ struct Dimension : public Calc {
+ };
+ Dimension mWidth, mHeight;
+ };
+};
diff --git a/libbindgen/tests/headers/nested_vtable.hpp b/libbindgen/tests/headers/nested_vtable.hpp
new file mode 100644
index 00000000..87d6ce1f
--- /dev/null
+++ b/libbindgen/tests/headers/nested_vtable.hpp
@@ -0,0 +1,8 @@
+class nsISupports {
+public:
+ virtual nsISupports* QueryInterface();
+};
+
+class nsIRunnable : public nsISupports {};
+
+class Runnable : public nsIRunnable {};
diff --git a/libbindgen/tests/headers/no-std.h b/libbindgen/tests/headers/no-std.h
new file mode 100644
index 00000000..7bee9657
--- /dev/null
+++ b/libbindgen/tests/headers/no-std.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --ctypes-prefix "libc" --use-core --raw-line "#![no_std]" --raw-line "mod libc { pub type c_int = i32; pub enum c_void {} }"
+struct foo {
+ int a, b;
+ void* bar;
+};
diff --git a/libbindgen/tests/headers/no_copy.hpp b/libbindgen/tests/headers/no_copy.hpp
new file mode 100644
index 00000000..349e428e
--- /dev/null
+++ b/libbindgen/tests/headers/no_copy.hpp
@@ -0,0 +1,6 @@
+
+/** <div rustbindgen nocopy></div> */
+template<typename T>
+class CopiableButWait {
+ int whatever;
+};
diff --git a/libbindgen/tests/headers/nsStyleAutoArray.hpp b/libbindgen/tests/headers/nsStyleAutoArray.hpp
new file mode 100644
index 00000000..950152c0
--- /dev/null
+++ b/libbindgen/tests/headers/nsStyleAutoArray.hpp
@@ -0,0 +1,57 @@
+
+template<typename T>
+class nsTArray {
+ T* mBuff;
+};
+
+template<typename T>
+class nsStyleAutoArray
+{
+public:
+ // This constructor places a single element in mFirstElement.
+ enum WithSingleInitialElement { WITH_SINGLE_INITIAL_ELEMENT };
+ explicit nsStyleAutoArray(WithSingleInitialElement) {}
+ nsStyleAutoArray(const nsStyleAutoArray& aOther) { *this = aOther; }
+ nsStyleAutoArray& operator=(const nsStyleAutoArray& aOther) {
+ mFirstElement = aOther.mFirstElement;
+ mOtherElements = aOther.mOtherElements;
+ return *this;
+ }
+
+ bool operator==(const nsStyleAutoArray& aOther) const {
+ return Length() == aOther.Length() &&
+ mFirstElement == aOther.mFirstElement &&
+ mOtherElements == aOther.mOtherElements;
+ }
+ bool operator!=(const nsStyleAutoArray& aOther) const {
+ return !(*this == aOther);
+ }
+
+ unsigned long Length() const {
+ return mOtherElements.Length() + 1;
+ }
+ const T& operator[](unsigned long aIndex) const {
+ return aIndex == 0 ? mFirstElement : mOtherElements[aIndex - 1];
+ }
+ T& operator[](unsigned long aIndex) {
+ return aIndex == 0 ? mFirstElement : mOtherElements[aIndex - 1];
+ }
+
+ void EnsureLengthAtLeast(unsigned long aMinLen) {
+ if (aMinLen > 0) {
+ mOtherElements.EnsureLengthAtLeast(aMinLen - 1);
+ }
+ }
+
+ void SetLengthNonZero(unsigned long aNewLen) {
+ mOtherElements.SetLength(aNewLen - 1);
+ }
+
+ void TruncateLengthNonZero(unsigned long aNewLen) {
+ mOtherElements.TruncateLength(aNewLen - 1);
+ }
+
+private:
+ T mFirstElement;
+ nsTArray<T> mOtherElements;
+};
diff --git a/libbindgen/tests/headers/only_bitfields.hpp b/libbindgen/tests/headers/only_bitfields.hpp
new file mode 100644
index 00000000..84db0586
--- /dev/null
+++ b/libbindgen/tests/headers/only_bitfields.hpp
@@ -0,0 +1,5 @@
+// bindgen-flags: --no-unstable-rust
+class C {
+ bool a: 1;
+ bool b: 7;
+};
diff --git a/libbindgen/tests/headers/opaque_in_struct.hpp b/libbindgen/tests/headers/opaque_in_struct.hpp
new file mode 100644
index 00000000..3cffeb20
--- /dev/null
+++ b/libbindgen/tests/headers/opaque_in_struct.hpp
@@ -0,0 +1,10 @@
+
+
+/** <div rustbindgen opaque> */
+typedef struct opaque {
+ int waht;
+} opaque;
+
+struct container {
+ opaque contained;
+};
diff --git a/libbindgen/tests/headers/opaque_pointer.hpp b/libbindgen/tests/headers/opaque_pointer.hpp
new file mode 100644
index 00000000..53f8ce1f
--- /dev/null
+++ b/libbindgen/tests/headers/opaque_pointer.hpp
@@ -0,0 +1,22 @@
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+struct OtherOpaque {
+ int c;
+};
+
+/**
+ * <div rustbindgen opaque></div>
+ */
+template <typename T>
+struct Opaque {
+ T whatever;
+};
+
+struct WithOpaquePtr {
+ Opaque<int>* whatever;
+ Opaque<float> other;
+ OtherOpaque t;
+};
+
diff --git a/libbindgen/tests/headers/opaque_typedef.hpp b/libbindgen/tests/headers/opaque_typedef.hpp
new file mode 100644
index 00000000..25640738
--- /dev/null
+++ b/libbindgen/tests/headers/opaque_typedef.hpp
@@ -0,0 +1,17 @@
+// bindgen-flags: -- -std=c++11
+template<typename T>
+class RandomTemplate;
+
+template<int i>
+class Wat;
+
+template<int i>
+class Wat3;
+
+template<>
+class Wat3<3>;
+
+/** <div rustbindgen opaque></div> */
+typedef RandomTemplate<int> ShouldBeOpaque;
+
+typedef RandomTemplate<float> ShouldNotBeOpaque;
diff --git a/libbindgen/tests/headers/overflowed_enum.hpp b/libbindgen/tests/headers/overflowed_enum.hpp
new file mode 100644
index 00000000..1f2075a5
--- /dev/null
+++ b/libbindgen/tests/headers/overflowed_enum.hpp
@@ -0,0 +1,12 @@
+// bindgen-flags: -- -std=c++11 -Wno-narrowing
+
+enum Foo {
+ BAP_ARM = 0x93fcb9,
+ BAP_X86 = 0xb67eed,
+ BAP_X86_64 = 0xba7b274f,
+};
+
+enum Bar: unsigned short {
+ One = 1,
+ Big = 65538,
+};
diff --git a/libbindgen/tests/headers/overloading.hpp b/libbindgen/tests/headers/overloading.hpp
new file mode 100644
index 00000000..3c2b0487
--- /dev/null
+++ b/libbindgen/tests/headers/overloading.hpp
@@ -0,0 +1,9 @@
+extern bool Evaluate(char r);
+extern bool Evaluate(int x, int y);
+
+namespace foo {
+ extern void MyFunction();
+}
+namespace bar {
+ extern void MyFunction();
+}
diff --git a/libbindgen/tests/headers/private.hpp b/libbindgen/tests/headers/private.hpp
new file mode 100644
index 00000000..c0f3ce7f
--- /dev/null
+++ b/libbindgen/tests/headers/private.hpp
@@ -0,0 +1,21 @@
+
+struct HasPrivate {
+ int mNotPrivate;
+ /** <div rustbindgen private></div> */
+ int mIsPrivate;
+};
+
+
+/** <div rustbindgen private></div> */
+struct VeryPrivate {
+ int mIsPrivate;
+ int mIsAlsoPrivate;
+};
+
+
+/** <div rustbindgen private></div> */
+struct ContradictPrivate {
+ /** <div rustbindgen private="false"></div> */
+ int mNotPrivate;
+ int mIsPrivate;
+};
diff --git a/libbindgen/tests/headers/redeclaration.hpp b/libbindgen/tests/headers/redeclaration.hpp
new file mode 100644
index 00000000..d536b158
--- /dev/null
+++ b/libbindgen/tests/headers/redeclaration.hpp
@@ -0,0 +1,7 @@
+extern "C" {
+ void foo();
+}
+
+extern "C" {
+ void foo();
+}
diff --git a/libbindgen/tests/headers/ref_argument_array.hpp b/libbindgen/tests/headers/ref_argument_array.hpp
new file mode 100644
index 00000000..dc73fd62
--- /dev/null
+++ b/libbindgen/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;
+};
diff --git a/libbindgen/tests/headers/replace_template_alias.hpp b/libbindgen/tests/headers/replace_template_alias.hpp
new file mode 100644
index 00000000..6ceae4e5
--- /dev/null
+++ b/libbindgen/tests/headers/replace_template_alias.hpp
@@ -0,0 +1,23 @@
+// bindgen-flags: -- --std=c++14
+
+namespace JS {
+namespace detail {
+
+/// Notice how this doesn't use T.
+template <typename T>
+using MaybeWrapped = int;
+
+}
+
+template <typename T>
+class Rooted {
+ detail::MaybeWrapped<T> ptr;
+};
+
+}
+
+/// But the replacement type does use T!
+///
+/// <div rustbindgen replaces="MaybeWrapped" />
+template <typename T>
+using replaces_MaybeWrapped = T;
diff --git a/libbindgen/tests/headers/replaces_double.hpp b/libbindgen/tests/headers/replaces_double.hpp
new file mode 100644
index 00000000..1a78b0d9
--- /dev/null
+++ b/libbindgen/tests/headers/replaces_double.hpp
@@ -0,0 +1,20 @@
+// bindgen-flags: --blacklist-type Wrapper -- --std=c++11
+
+template<typename T>
+struct Wrapper {
+ struct Wrapped {
+ T t;
+ };
+ using Type = Wrapped;
+};
+
+template<typename T>
+class Rooted {
+ using MaybeWrapped = typename Wrapper<T>::Type;
+ MaybeWrapped ptr;
+
+ /**
+ * <div rustbindgen replaces="Rooted_MaybeWrapped"></div>
+ */
+ using MaybeWrapped_simple = T;
+};
diff --git a/libbindgen/tests/headers/size_t_template.hpp b/libbindgen/tests/headers/size_t_template.hpp
new file mode 100644
index 00000000..6045c698
--- /dev/null
+++ b/libbindgen/tests/headers/size_t_template.hpp
@@ -0,0 +1,8 @@
+template<typename T, unsigned long N>
+class Array {
+ T inner[N];
+};
+
+class C {
+ Array<int, 3> arr;
+};
diff --git a/libbindgen/tests/headers/struct_containing_forward_declared_struct.h b/libbindgen/tests/headers/struct_containing_forward_declared_struct.h
new file mode 100644
index 00000000..d38aca2f
--- /dev/null
+++ b/libbindgen/tests/headers/struct_containing_forward_declared_struct.h
@@ -0,0 +1,7 @@
+struct a {
+ struct b* val_a;
+};
+
+struct b {
+ int val_b;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_struct.h b/libbindgen/tests/headers/struct_with_anon_struct.h
new file mode 100644
index 00000000..1617d7a8
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_struct.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ int a;
+ int b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_struct_array.h b/libbindgen/tests/headers/struct_with_anon_struct_array.h
new file mode 100644
index 00000000..9ea977e8
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_struct_array.h
@@ -0,0 +1,10 @@
+struct foo {
+ struct {
+ int a;
+ int b;
+ } bar[2];
+ struct {
+ int a;
+ int b;
+ } baz[2][3][4];
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_struct_pointer.h b/libbindgen/tests/headers/struct_with_anon_struct_pointer.h
new file mode 100644
index 00000000..0c486d84
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_struct_pointer.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ int a;
+ int b;
+ } *bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_union.h b/libbindgen/tests/headers/struct_with_anon_union.h
new file mode 100644
index 00000000..3a92b940
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_union.h
@@ -0,0 +1,6 @@
+struct foo {
+ union {
+ unsigned int a;
+ unsigned short b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h b/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h
new file mode 100644
index 00000000..f8ac4225
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ unsigned int a;
+ unsigned int b;
+ };
+};
diff --git a/libbindgen/tests/headers/struct_with_anon_unnamed_union.h b/libbindgen/tests/headers/struct_with_anon_unnamed_union.h
new file mode 100644
index 00000000..7158e727
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_anon_unnamed_union.h
@@ -0,0 +1,6 @@
+struct foo {
+ union {
+ unsigned int a;
+ unsigned short b;
+ };
+};
diff --git a/libbindgen/tests/headers/struct_with_bitfields.h b/libbindgen/tests/headers/struct_with_bitfields.h
new file mode 100644
index 00000000..107fb136
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_bitfields.h
@@ -0,0 +1,13 @@
+// bindgen-flags: --no-unstable-rust
+struct bitfield {
+ unsigned short
+ a :1,
+ b :1,
+ c :1,
+ :1,
+ :2,
+ d :2;
+ int e;
+ unsigned int f : 2;
+ unsigned int g : 32;
+};
diff --git a/libbindgen/tests/headers/struct_with_derive_debug.h b/libbindgen/tests/headers/struct_with_derive_debug.h
new file mode 100644
index 00000000..98ba1b3d
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_derive_debug.h
@@ -0,0 +1,15 @@
+struct LittleArray {
+ int a[32];
+};
+
+struct BigArray{
+ int a[33];
+};
+
+struct WithLittleArray {
+ struct LittleArray a;
+};
+
+struct WithBigArray {
+ struct BigArray a;
+};
diff --git a/libbindgen/tests/headers/struct_with_nesting.h b/libbindgen/tests/headers/struct_with_nesting.h
new file mode 100644
index 00000000..9d7fa176
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_nesting.h
@@ -0,0 +1,17 @@
+struct foo {
+ unsigned int a;
+ union {
+ unsigned int b;
+ struct {
+ unsigned short c1;
+ unsigned short c2;
+ };
+
+ struct {
+ unsigned char d1;
+ unsigned char d2;
+ unsigned char d3;
+ unsigned char d4;
+ };
+ };
+};
diff --git a/libbindgen/tests/headers/struct_with_packing.h b/libbindgen/tests/headers/struct_with_packing.h
new file mode 100644
index 00000000..1b9fe131
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_packing.h
@@ -0,0 +1,4 @@
+struct a {
+ char b;
+ short c;
+} __attribute__((packed));
diff --git a/libbindgen/tests/headers/struct_with_struct.h b/libbindgen/tests/headers/struct_with_struct.h
new file mode 100644
index 00000000..78b1cc81
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_struct.h
@@ -0,0 +1,6 @@
+struct foo {
+ struct {
+ unsigned int x;
+ unsigned int y;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp b/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp
new file mode 100644
index 00000000..7fed21ab
--- /dev/null
+++ b/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp
@@ -0,0 +1,4 @@
+template<typename T, typename ...Args>
+struct Proxy {
+ typedef void (*foo)(T* bar);
+};
diff --git a/libbindgen/tests/headers/template.hpp b/libbindgen/tests/headers/template.hpp
new file mode 100644
index 00000000..c13643c3
--- /dev/null
+++ b/libbindgen/tests/headers/template.hpp
@@ -0,0 +1,144 @@
+template<typename T, typename U> class Foo {
+ T m_member;
+ T* m_member_ptr;
+ T m_member_arr[1];
+};
+
+void bar(Foo<int, int> foo);
+
+template<typename T>
+class D {
+ typedef Foo<int, int> MyFoo;
+
+ MyFoo m_foo;
+
+ template<typename Z>
+ class U {
+ MyFoo m_nested_foo;
+ Z m_baz;
+ };
+};
+
+template<typename T>
+class Rooted {
+ T* prev;
+ Rooted<void*>* next;
+ T ptr;
+};
+
+class RootedContainer {
+ Rooted<void*> root;
+};
+
+template<typename T>
+class WithDtor;
+
+typedef WithDtor<int> WithDtorIntFwd;
+
+template<typename T>
+class WithDtor {
+ T member;
+ ~WithDtor() {}
+};
+
+class PODButContainsDtor {
+ WithDtorIntFwd member;
+};
+
+
+/** <div rustbindgen opaque> */
+template<typename T>
+class Opaque {
+ T member;
+};
+
+class POD {
+ Opaque<int> opaque_member;
+};
+
+/**
+ * <div rustbindgen replaces="NestedReplaced"></div>
+ */
+template<typename T>
+class Nested {
+ T* buff;
+};
+
+template<typename T, typename U>
+class NestedBase {
+ T* buff;
+};
+
+template<typename T>
+class NestedReplaced: public NestedBase<T, int> {
+};
+
+template<typename T>
+class Incomplete;
+
+template<typename T>
+class NestedContainer {
+ T c;
+private:
+ NestedReplaced<T> nested;
+ Incomplete<T> inc;
+};
+
+template<typename T>
+class Incomplete {
+ T d;
+};
+
+class Untemplated {};
+
+template<typename T>
+class Templated {
+ Untemplated m_untemplated;
+};
+
+/**
+ * If the replacement doesn't happen at the parse level the container would be
+ * copy and the replacement wouldn't, so this wouldn't compile.
+ *
+ * <div rustbindgen replaces="ReplacedWithoutDestructor"></div>
+ */
+template<typename T>
+class ReplacedWithDestructor {
+ T* buff;
+ ~ReplacedWithDestructor() {};
+};
+
+template<typename T>
+class ReplacedWithoutDestructor {
+ T* buff;
+};
+
+template<typename T>
+class ReplacedWithoutDestructorFwd;
+
+template<typename T>
+class ShouldNotBeCopiable {
+ ReplacedWithoutDestructor<T> m_member;
+};
+
+template<typename U>
+class ShouldNotBeCopiableAsWell {
+ ReplacedWithoutDestructorFwd<U> m_member;
+};
+
+/**
+ * If the replacement doesn't happen at the parse level the container would be
+ * copy and the replacement wouldn't, so this wouldn't compile.
+ *
+ * <div rustbindgen replaces="ReplacedWithoutDestructorFwd"></div>
+ */
+template<typename T>
+class ReplacedWithDestructorDeclaredAfter {
+ T* buff;
+ ~ReplacedWithDestructorDeclaredAfter() {};
+};
+
+template<typename T>
+class TemplateWithVar {
+ static T var = 0;
+};
diff --git a/libbindgen/tests/headers/template_alias.hpp b/libbindgen/tests/headers/template_alias.hpp
new file mode 100644
index 00000000..646d9f40
--- /dev/null
+++ b/libbindgen/tests/headers/template_alias.hpp
@@ -0,0 +1,13 @@
+// bindgen-flags: -- -std=c++14
+
+namespace JS {
+namespace detail {
+ template <typename T>
+ using Wrapped = T;
+}
+
+template <typename T>
+struct Rooted {
+ detail::Wrapped<T> ptr;
+};
+}
diff --git a/libbindgen/tests/headers/template_alias_basic.hpp b/libbindgen/tests/headers/template_alias_basic.hpp
new file mode 100644
index 00000000..964f6e27
--- /dev/null
+++ b/libbindgen/tests/headers/template_alias_basic.hpp
@@ -0,0 +1,4 @@
+// bindgen-flags: -- -std=c++11
+
+template<typename T>
+using Wrapped = T;
diff --git a/libbindgen/tests/headers/template_alias_namespace.hpp b/libbindgen/tests/headers/template_alias_namespace.hpp
new file mode 100644
index 00000000..bd637166
--- /dev/null
+++ b/libbindgen/tests/headers/template_alias_namespace.hpp
@@ -0,0 +1,13 @@
+// bindgen-flags: --enable-cxx-namespaces -- -std=c++14
+
+namespace JS {
+namespace detail {
+ template <typename T>
+ using Wrapped = T;
+}
+
+template <typename T>
+struct Rooted {
+ detail::Wrapped<T> ptr;
+};
+}
diff --git a/libbindgen/tests/headers/template_typedef_transitive_param.hpp b/libbindgen/tests/headers/template_typedef_transitive_param.hpp
new file mode 100644
index 00000000..2269ac36
--- /dev/null
+++ b/libbindgen/tests/headers/template_typedef_transitive_param.hpp
@@ -0,0 +1,7 @@
+template<typename T>
+struct Wrapper {
+ struct Wrapped {
+ T t;
+ };
+ using Type = Wrapped;
+};
diff --git a/libbindgen/tests/headers/template_typedefs.hpp b/libbindgen/tests/headers/template_typedefs.hpp
new file mode 100644
index 00000000..5e13dcd8
--- /dev/null
+++ b/libbindgen/tests/headers/template_typedefs.hpp
@@ -0,0 +1,8 @@
+typedef void (*foo)(int);
+
+template<typename T, typename U>
+class Foo {
+ typedef T Char;
+ typedef Char* FooPtrTypedef;
+ typedef bool (*nsCOMArrayEnumFunc)(T* aElement, void* aData);
+};
diff --git a/libbindgen/tests/headers/type_alias_empty.hpp b/libbindgen/tests/headers/type_alias_empty.hpp
new file mode 100644
index 00000000..f0760c8f
--- /dev/null
+++ b/libbindgen/tests/headers/type_alias_empty.hpp
@@ -0,0 +1,10 @@
+// bindgen-flags: --whitelist-type bool_constant -- -std=c++11
+
+// NB: The --whitelist-type is done to trigger the traversal of the types on
+// codegen in order to trigger #67.
+
+template<typename T, T Val>
+struct integral_constant {};
+
+template<bool B>
+using bool_constant = integral_constant<bool, B>;
diff --git a/libbindgen/tests/headers/typeref.hpp b/libbindgen/tests/headers/typeref.hpp
new file mode 100644
index 00000000..b94c98ef
--- /dev/null
+++ b/libbindgen/tests/headers/typeref.hpp
@@ -0,0 +1,28 @@
+struct nsFoo;
+
+namespace mozilla {
+
+struct FragmentOrURL { bool mIsLocalRef; };
+struct Position { };
+
+} // namespace mozilla
+
+class Bar {
+ nsFoo* mFoo;
+};
+
+namespace mozilla {
+
+template<typename ReferenceBox>
+struct StyleShapeSource {
+ union {
+ Position* mPosition;
+ FragmentOrURL* mFragmentOrURL;
+ };
+};
+
+} // namespace mozilla
+
+struct nsFoo {
+ mozilla::StyleShapeSource<int> mBar;
+};
diff --git a/libbindgen/tests/headers/union_dtor.hpp b/libbindgen/tests/headers/union_dtor.hpp
new file mode 100644
index 00000000..399dc89d
--- /dev/null
+++ b/libbindgen/tests/headers/union_dtor.hpp
@@ -0,0 +1,5 @@
+union UnionWithDtor {
+ ~UnionWithDtor();
+ int mFoo;
+ void* mBar;
+};
diff --git a/libbindgen/tests/headers/union_fields.hpp b/libbindgen/tests/headers/union_fields.hpp
new file mode 100644
index 00000000..aec3a7fd
--- /dev/null
+++ b/libbindgen/tests/headers/union_fields.hpp
@@ -0,0 +1,5 @@
+typedef union {
+ int mInt;
+ float mFloat;
+ void* mPointer;
+} nsStyleUnion;
diff --git a/libbindgen/tests/headers/union_template.hpp b/libbindgen/tests/headers/union_template.hpp
new file mode 100644
index 00000000..0d0a9bb3
--- /dev/null
+++ b/libbindgen/tests/headers/union_template.hpp
@@ -0,0 +1,19 @@
+template<typename T>
+struct NastyStruct {
+ bool mIsSome;
+ union {
+ void* mFoo;
+ unsigned long mDummy;
+ } mStorage;
+
+ union {
+ short wat;
+ int* wut;
+ };
+};
+
+template<typename T>
+union Whatever {
+ void* mTPtr;
+ int mInt;
+};
diff --git a/libbindgen/tests/headers/union_with_anon_struct.h b/libbindgen/tests/headers/union_with_anon_struct.h
new file mode 100644
index 00000000..7f8dec95
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_struct.h
@@ -0,0 +1,6 @@
+union foo {
+ struct {
+ unsigned int a;
+ unsigned int b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/union_with_anon_struct_bitfield.h b/libbindgen/tests/headers/union_with_anon_struct_bitfield.h
new file mode 100644
index 00000000..24c7dce8
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_struct_bitfield.h
@@ -0,0 +1,8 @@
+// bindgen-flags: --no-unstable-rust
+union foo {
+ int a;
+ struct {
+ int b : 7;
+ int c : 25;
+ };
+};
diff --git a/libbindgen/tests/headers/union_with_anon_union.h b/libbindgen/tests/headers/union_with_anon_union.h
new file mode 100644
index 00000000..212431b8
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_union.h
@@ -0,0 +1,6 @@
+union foo {
+ union {
+ unsigned int a;
+ unsigned short b;
+ } bar;
+};
diff --git a/libbindgen/tests/headers/union_with_anon_unnamed_struct.h b/libbindgen/tests/headers/union_with_anon_unnamed_struct.h
new file mode 100644
index 00000000..79558049
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_unnamed_struct.h
@@ -0,0 +1,9 @@
+union pixel {
+ unsigned int rgba;
+ struct {
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ unsigned char a;
+ };
+};
diff --git a/libbindgen/tests/headers/union_with_anon_unnamed_union.h b/libbindgen/tests/headers/union_with_anon_unnamed_union.h
new file mode 100644
index 00000000..7580771a
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_anon_unnamed_union.h
@@ -0,0 +1,7 @@
+union foo {
+ unsigned int a;
+ union {
+ unsigned short b;
+ unsigned char c;
+ };
+};
diff --git a/libbindgen/tests/headers/union_with_big_member.h b/libbindgen/tests/headers/union_with_big_member.h
new file mode 100644
index 00000000..6347d6ca
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_big_member.h
@@ -0,0 +1,14 @@
+union WithBigArray {
+ int a;
+ int b[33];
+};
+
+union WithBigArray2 {
+ int a;
+ char b[33];
+};
+
+union WithBigMember {
+ int a;
+ union WithBigArray b;
+};
diff --git a/libbindgen/tests/headers/union_with_nesting.h b/libbindgen/tests/headers/union_with_nesting.h
new file mode 100644
index 00000000..cd907d57
--- /dev/null
+++ b/libbindgen/tests/headers/union_with_nesting.h
@@ -0,0 +1,14 @@
+union foo {
+ unsigned int a;
+ struct {
+ union {
+ unsigned short b1;
+ unsigned short b2;
+ };
+
+ union {
+ unsigned short c1;
+ unsigned short c2;
+ };
+ };
+};
diff --git a/libbindgen/tests/headers/unknown_attr.h b/libbindgen/tests/headers/unknown_attr.h
new file mode 100644
index 00000000..f87e9f0b
--- /dev/null
+++ b/libbindgen/tests/headers/unknown_attr.h
@@ -0,0 +1,6 @@
+typedef struct {
+ long long __clang_max_align_nonce1
+ __attribute__((__aligned__(__alignof__(long long))));
+ long double __clang_max_align_nonce2
+ __attribute__((__aligned__(__alignof__(long double))));
+} max_align_t;
diff --git a/libbindgen/tests/headers/use-core.h b/libbindgen/tests/headers/use-core.h
new file mode 100644
index 00000000..42bb10d9
--- /dev/null
+++ b/libbindgen/tests/headers/use-core.h
@@ -0,0 +1,8 @@
+// bindgen-flags: --use-core --raw-line "extern crate core;"
+
+struct foo {
+ int a, b;
+ void* bar;
+};
+
+typedef void (*fooFunction)(int bar);
diff --git a/libbindgen/tests/headers/using.hpp b/libbindgen/tests/headers/using.hpp
new file mode 100644
index 00000000..ba07b9c8
--- /dev/null
+++ b/libbindgen/tests/headers/using.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: -- -std=c++11
+
+template<typename T>
+class Point {
+ T x;
+ T y;
+};
+
+typedef Point<int> IntPoint2D;
+
+using IntVec2D = Point<int>;
diff --git a/libbindgen/tests/headers/vector.hpp b/libbindgen/tests/headers/vector.hpp
new file mode 100644
index 00000000..4707f77f
--- /dev/null
+++ b/libbindgen/tests/headers/vector.hpp
@@ -0,0 +1,3 @@
+struct foo {
+ __attribute__((__vector_size__(1 * sizeof(long long)))) long long mMember;
+};
diff --git a/libbindgen/tests/headers/virtual_dtor.hpp b/libbindgen/tests/headers/virtual_dtor.hpp
new file mode 100644
index 00000000..c35dcab1
--- /dev/null
+++ b/libbindgen/tests/headers/virtual_dtor.hpp
@@ -0,0 +1,3 @@
+struct nsSlots {
+ virtual ~nsSlots();
+};
diff --git a/libbindgen/tests/headers/virtual_overloaded.hpp b/libbindgen/tests/headers/virtual_overloaded.hpp
new file mode 100644
index 00000000..8aea8a19
--- /dev/null
+++ b/libbindgen/tests/headers/virtual_overloaded.hpp
@@ -0,0 +1,5 @@
+class C {
+public:
+ virtual void do_thing(char) { };
+ virtual void do_thing(int) { };
+};
diff --git a/libbindgen/tests/headers/vtable_recursive_sig.hpp b/libbindgen/tests/headers/vtable_recursive_sig.hpp
new file mode 100644
index 00000000..8729be00
--- /dev/null
+++ b/libbindgen/tests/headers/vtable_recursive_sig.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: -- -std=c++11
+
+class Derived;
+class Base {
+public:
+ virtual Derived* AsDerived() { return nullptr; }
+};
+
+class Derived final : public Base {
+ virtual Derived* AsDerived() override { return this; }
+};
diff --git a/libbindgen/tests/headers/weird_bitfields.hpp b/libbindgen/tests/headers/weird_bitfields.hpp
new file mode 100644
index 00000000..755681c1
--- /dev/null
+++ b/libbindgen/tests/headers/weird_bitfields.hpp
@@ -0,0 +1,35 @@
+// bindgen-flags: --no-unstable-rust
+// You can guess where this is taken from...
+enum nsStyleSVGOpacitySource {
+ eStyleSVGOpacitySource_Normal,
+ eStyleSVGOpacitySource_ContextFillOpacity,
+ eStyleSVGOpacitySource_ContextStrokeOpacity
+};
+
+class Weird {
+ unsigned int mStrokeDasharrayLength;
+ unsigned int bitTest: 16;
+ unsigned int bitTest2: 15;
+ unsigned char mClipRule; // [inherited]
+ unsigned char mColorInterpolation; // [inherited] see nsStyleConsts.h
+ unsigned char mColorInterpolationFilters; // [inherited] see nsStyleConsts.h
+ unsigned char mFillRule; // [inherited] see nsStyleConsts.h
+ unsigned char mImageRendering; // [inherited] see nsStyleConsts.h
+ unsigned char mPaintOrder; // [inherited] see nsStyleConsts.h
+ unsigned char mShapeRendering; // [inherited] see nsStyleConsts.h
+ unsigned char mStrokeLinecap; // [inherited] see nsStyleConsts.h
+ unsigned char mStrokeLinejoin; // [inherited] see nsStyleConsts.h
+ unsigned char mTextAnchor; // [inherited] see nsStyleConsts.h
+ unsigned char mTextRendering; // [inherited] see nsStyleConsts.h
+
+ // In SVG glyphs, whether we inherit fill or stroke opacity from the outer
+ // text object.
+ // Use 3 bits to avoid signedness problems in MSVC.
+ nsStyleSVGOpacitySource mFillOpacitySource : 3;
+ nsStyleSVGOpacitySource mStrokeOpacitySource : 3;
+
+ // SVG glyph outer object inheritance for other properties
+ bool mStrokeDasharrayFromObject : 1;
+ bool mStrokeDashoffsetFromObject : 1;
+ bool mStrokeWidthFromObject : 1;
+};
diff --git a/libbindgen/tests/headers/what_is_going_on.hpp b/libbindgen/tests/headers/what_is_going_on.hpp
new file mode 100644
index 00000000..078c1ad5
--- /dev/null
+++ b/libbindgen/tests/headers/what_is_going_on.hpp
@@ -0,0 +1,19 @@
+
+struct UnknownUnits {};
+typedef float Float;
+
+template<class units, class F = Float>
+struct PointTyped {
+ F x;
+ F y;
+
+ static PointTyped<units, F> FromUnknownPoint(const PointTyped<UnknownUnits, F>& aPoint) {
+ return PointTyped<units, F>(aPoint.x, aPoint.y);
+ }
+
+ PointTyped<UnknownUnits, F> ToUnknownPoint() const {
+ return PointTyped<UnknownUnits, F>(this->x, this->y);
+ }
+};
+
+typedef PointTyped<UnknownUnits> IntPoint;
diff --git a/libbindgen/tests/headers/whitelist_basic.hpp b/libbindgen/tests/headers/whitelist_basic.hpp
new file mode 100644
index 00000000..8424f75a
--- /dev/null
+++ b/libbindgen/tests/headers/whitelist_basic.hpp
@@ -0,0 +1,16 @@
+// bindgen-flags: --whitelist-type WhitelistMe
+
+template<typename T>
+class WhitelistMe {
+ class Inner {
+ T bar;
+ };
+
+ int foo;
+ Inner bar;
+};
+
+struct DontWhitelistMe {
+ void* foo;
+ double _Complex noComplexGenerated;
+};
diff --git a/libbindgen/tests/headers/whitelist_vars.h b/libbindgen/tests/headers/whitelist_vars.h
new file mode 100644
index 00000000..07fa2815
--- /dev/null
+++ b/libbindgen/tests/headers/whitelist_vars.h
@@ -0,0 +1,4 @@
+#define NONE 0
+#define FOO 5
+#define FOOB -2
+#define FOOBAR (-10)
diff --git a/libbindgen/tests/tests.rs b/libbindgen/tests/tests.rs
new file mode 100644
index 00000000..c9826260
--- /dev/null
+++ b/libbindgen/tests/tests.rs
@@ -0,0 +1,138 @@
+extern crate clap;
+extern crate diff;
+#[macro_use]
+extern crate env_logger;
+extern crate libbindgen;
+extern crate log;
+extern crate shlex;
+
+use std::env;
+use std::fs;
+use std::io::{BufRead, BufReader, Error, ErrorKind, Read};
+use std::path::{Path, PathBuf};
+
+#[path="../../src/options.rs"]
+mod options;
+use options::builder_from_flags;
+
+fn compare_generated_header(header: &PathBuf,
+ builder: libbindgen::Builder)
+ -> Result<(), Error> {
+ let file_name = try!(header.file_name()
+ .ok_or(Error::new(ErrorKind::Other, "spawn_bindgen expects a file")));
+
+ let mut expected = PathBuf::from(header);
+ expected.pop();
+ expected.pop();
+ expected.push("expectations");
+ expected.push("tests");
+ expected.push(file_name);
+ expected.set_extension("rs");
+
+ // We skip the generate() error here so we get a full diff below
+ let output = match builder.generate() {
+ Ok(bindings) => bindings.to_string(),
+ Err(_) => "".to_string(),
+ };
+
+ let mut buffer = String::new();
+ let f = try!(fs::File::open(&expected));
+ let _ = try!(BufReader::new(f).read_to_string(&mut buffer));
+
+ if output == buffer {
+ return Ok(());
+ }
+
+ println!("diff expected generated");
+ println!("--- expected: {:?}", expected);
+ println!("+++ generated from: {:?}", header);
+
+ for diff in diff::lines(&buffer, &output) {
+ match diff {
+ diff::Result::Left(l) => println!("-{}", l),
+ diff::Result::Both(l, _) => println!(" {}", l),
+ diff::Result::Right(r) => println!("+{}", r),
+ }
+ }
+ Err(Error::new(ErrorKind::Other, "Header and binding differ!"))
+}
+
+fn create_bindgen_builder(header: &PathBuf)
+ -> Result<libbindgen::Builder, Error> {
+ let source = try!(fs::File::open(header));
+ let reader = BufReader::new(source);
+
+ // Scoop up bindgen-flags from test header
+ let line: String = try!(reader.lines().take(1).collect());
+ let flags: Vec<String> = if line.contains("bindgen-flags:") {
+ line.split("bindgen-flags:").last().and_then(shlex::split)
+ } else {
+ None
+ }.unwrap_or(Vec::with_capacity(2));
+
+ // Fool builder_from_flags() into believing it has real env::args_os...
+ // - add "bindgen" as executable name 0th element
+ // - add header filename as 1st element
+ // - prepend raw lines so they're in the right order for expected output
+ // - append the test header's bindgen flags
+ let header_str = try!(header.to_str()
+ .ok_or(Error::new(ErrorKind::Other, "Invalid header file name")));
+
+ let prepend = [
+ "bindgen",
+ header_str,
+ "--raw-line", "",
+ "--raw-line", "#![allow(non_snake_case)]",
+ "--raw-line", "",
+ ];
+
+ let args = prepend.into_iter()
+ .map(ToString::to_string)
+ .chain(flags.into_iter());
+
+ builder_from_flags(args).map(|(builder, _)| builder.no_unstable_rust())
+}
+
+#[test]
+fn run_bindgen_tests() {
+ log::set_logger(|max_log_level| {
+ use env_logger::Logger;
+ let env_logger = Logger::new();
+ max_log_level.set(env_logger.filter());
+ Box::new(env_logger)
+ })
+ .expect("Failed to set logger.");
+
+ let manifest_env = env::var("CARGO_MANIFEST_DIR")
+ .expect("CARGO_MANIFEST_DIR not set!");
+ let manifest_dir = Path::new(&manifest_env);
+ let headers_dir = manifest_dir.join("tests").join("headers");
+
+ let entries = fs::read_dir(&headers_dir)
+ .expect("Couldn't read headers dir")
+ .map(|result| result.expect("Couldn't read header file"));
+
+ let headers: Vec<_> = entries.filter_map(|entry| {
+ match entry.path().extension().and_then(|s| s.to_str()) {
+ Some("h") | Some("hpp") => Some(entry.path()),
+ _ => None,
+ }
+ })
+ .collect();
+
+ let failures: Vec<_> = headers.iter()
+ .filter_map(|header| {
+ create_bindgen_builder(header)
+ .and_then(|builder| compare_generated_header(header, builder))
+ .err()
+ })
+ .collect();
+
+ let num_failures = failures.len();
+
+ if num_failures > 0 {
+ panic!("{} test{} failed!",
+ num_failures,
+ if num_failures > 1 {"s"} else {""});
+ }
+}
diff --git a/libbindgen/tests/uses/.gitignore b/libbindgen/tests/uses/.gitignore
new file mode 100644
index 00000000..40d7cb4c
--- /dev/null
+++ b/libbindgen/tests/uses/.gitignore
@@ -0,0 +1,2 @@
+*.c
+*.cpp