From 735c741bfa07b532f434430faddce6ad42509054 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 19 Jun 2017 14:01:46 -0700 Subject: [PATCH] Ensure that every item is in some module's children list Previously, if an item's parent was not a module (eg a nested class definition whose parent it the outer class definition) and the parent was not whitelisted but the item was transitively whitelisted, then we could generate uses of the item without emitting any definition for it. This could happen because we were relying on the outer type calling for code generation on its inner types, but that relies on us doing code generation for the outer type, which won't happen if the outer type is not whitelisted. This commit avoids this gotcha by ensuring that all items end up in a module's children list, and so will be code generated even if their parent is not whitelisted. Fixes #769 --- src/codegen/mod.rs | 17 +- src/ir/context.rs | 21 +- tests/expectations/tests/16-byte-alignment.rs | 56 +++--- .../expectations/tests/381-decltype-alias.rs | 2 +- tests/expectations/tests/anon_enum.rs | 8 +- tests/expectations/tests/anon_enum_trait.rs | 14 +- .../tests/anon_struct_in_union.rs | 22 +-- tests/expectations/tests/anon_union.rs | 18 +- .../expectations/tests/bitfield-enum-basic.rs | 10 +- .../tests/bitfield-method-same-name.rs | 24 +-- tests/expectations/tests/class.rs | 32 +-- tests/expectations/tests/class_nested.rs | 24 +-- tests/expectations/tests/class_static.rs | 10 +- .../expectations/tests/class_static_const.rs | 6 +- tests/expectations/tests/class_with_dtor.rs | 2 +- .../tests/class_with_inner_struct.rs | 50 ++--- .../expectations/tests/class_with_typedef.rs | 36 ++-- .../expectations/tests/const_enum_unnamed.rs | 8 +- .../tests/constant-non-specialized-tp.rs | 4 +- tests/expectations/tests/constructor-tp.rs | 8 +- tests/expectations/tests/constructors.rs | 26 +-- tests/expectations/tests/crtp.rs | 4 +- .../tests/default-template-parameter.rs | 2 +- .../tests/enum_in_template_with_typedef.rs | 10 +- .../tests/forward-declaration-autoptr.rs | 9 + .../tests/gen-constructors-neg.rs | 4 + tests/expectations/tests/gen-constructors.rs | 8 +- .../expectations/tests/gen-destructors-neg.rs | 4 + tests/expectations/tests/gen-destructors.rs | 8 +- tests/expectations/tests/generate-inline.rs | 8 +- tests/expectations/tests/in_class_typedef.rs | 10 +- tests/expectations/tests/inner_const.rs | 10 +- .../expectations/tests/inner_template_self.rs | 9 + tests/expectations/tests/issue-372.rs | 11 ++ tests/expectations/tests/issue-410.rs | 10 +- tests/expectations/tests/issue-447.rs | 16 +- tests/expectations/tests/issue-493.rs | 32 +-- .../tests/issue-544-stylo-creduce-2.rs | 4 +- ...ate-params-causing-layout-test-failures.rs | 2 +- .../tests/issue-573-layout-test-failures.rs | 8 + .../issue-574-assertion-failure-in-codegen.rs | 8 + ...issue-584-stylo-template-analysis-panic.rs | 10 +- ...e-638-stylo-cannot-find-T-in-this-scope.rs | 2 +- .../tests/issue-639-typedef-anon-field.rs | 20 +- .../tests/issue-643-inner-struct.rs | 16 +- ...ue-645-cannot-find-type-T-in-this-scope.rs | 2 +- tests/expectations/tests/issue-674-1.rs | 11 +- tests/expectations/tests/issue-674-2.rs | 22 ++- tests/expectations/tests/issue-674-3.rs | 11 +- .../issue-691-template-parameter-virtual.rs | 2 +- .../tests/issue-769-bad-instantiation-test.rs | 43 ++++ tests/expectations/tests/issue_311.rs | 10 +- .../expectations/tests/jsval_layout_opaque.rs | 34 ++-- tests/expectations/tests/layout_array.rs | 22 +-- .../tests/layout_array_too_long.rs | 46 ++--- tests/expectations/tests/layout_eth_conf.rs | 158 +++++++-------- .../tests/layout_large_align_field.rs | 46 ++--- tests/expectations/tests/layout_mbuf.rs | 184 +++++++++--------- tests/expectations/tests/libclang-4/auto.rs | 2 +- .../tests/libclang-4/const_bool.rs | 2 +- .../partial-specialization-and-inheritance.rs | 10 +- .../type_alias_template_specialized.rs | 11 ++ .../tests/maddness-is-avoidable.rs | 4 +- tests/expectations/tests/method-mangling.rs | 8 +- tests/expectations/tests/namespace.rs | 12 +- tests/expectations/tests/nested.rs | 22 +-- tests/expectations/tests/nested_vtable.rs | 5 + .../tests/nested_within_namespace.rs | 10 +- tests/expectations/tests/non-type-params.rs | 20 +- tests/expectations/tests/nsStyleAutoArray.rs | 10 +- tests/expectations/tests/opaque_pointer.rs | 8 + tests/expectations/tests/public-dtor.rs | 8 +- .../expectations/tests/ref_argument_array.rs | 6 + tests/expectations/tests/replace_use.rs | 9 + tests/expectations/tests/replaces_double.rs | 14 +- tests/expectations/tests/size_t_template.rs | 9 + .../tests/struct_with_anon_struct.rs | 10 +- .../tests/struct_with_anon_struct_array.rs | 12 +- .../tests/struct_with_anon_struct_pointer.rs | 10 +- .../tests/struct_with_anon_union.rs | 10 +- .../tests/struct_with_anon_unnamed_struct.rs | 10 +- .../tests/struct_with_anon_unnamed_union.rs | 10 +- .../expectations/tests/struct_with_nesting.rs | 28 +-- .../expectations/tests/struct_with_struct.rs | 10 +- .../tests/struct_with_typedef_template_arg.rs | 4 +- tests/expectations/tests/template-fun-ty.rs | 12 +- .../tests/template-param-usage-10.rs | 14 +- .../tests/template-param-usage-2.rs | 12 +- .../tests/template-param-usage-3.rs | 12 +- .../tests/template-param-usage-4.rs | 10 +- .../tests/template-param-usage-5.rs | 2 +- .../tests/template-param-usage-6.rs | 2 +- .../tests/template-param-usage-8.rs | 4 +- .../tests/template-param-usage-9.rs | 10 +- tests/expectations/tests/template-with-var.rs | 11 ++ tests/expectations/tests/template.rs | 42 ++-- .../template_typedef_transitive_param.rs | 10 +- tests/expectations/tests/template_typedefs.rs | 10 +- .../expectations/tests/templateref_opaque.rs | 4 +- tests/expectations/tests/typeref.rs | 21 +- tests/expectations/tests/union_dtor.rs | 8 +- tests/expectations/tests/union_template.rs | 14 +- .../tests/union_with_anon_struct.rs | 12 +- .../tests/union_with_anon_struct_bitfield.rs | 14 +- .../tests/union_with_anon_union.rs | 12 +- .../tests/union_with_anon_unnamed_struct.rs | 14 +- .../tests/union_with_anon_unnamed_union.rs | 14 +- .../expectations/tests/union_with_nesting.rs | 26 +-- tests/expectations/tests/var-tracing.rs | 16 +- tests/expectations/tests/variadic-method.rs | 8 +- tests/expectations/tests/virtual_dtor.rs | 4 + tests/expectations/tests/whitelist_basic.rs | 14 +- .../issue-769-bad-instantiation-test.hpp | 11 ++ tests/headers/template-with-var.hpp | 7 + tests/headers/template.hpp | 5 - 115 files changed, 1072 insertions(+), 771 deletions(-) create mode 100644 tests/expectations/tests/issue-769-bad-instantiation-test.rs create mode 100644 tests/expectations/tests/template-with-var.rs create mode 100644 tests/headers/issue-769-bad-instantiation-test.hpp create mode 100644 tests/headers/template-with-var.hpp diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index bd5b1f3b0a..f3755bf1c2 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -435,6 +435,16 @@ impl CodeGenerator for Var { } result.saw_var(&canonical_name); + // We can't generate bindings to static variables of templates. The + // number of actual variables for a single declaration are open ended + // and we don't know what instantiations do or don't exist. + let type_params = item.all_template_params(ctx); + if let Some(params) = type_params { + if !params.is_empty() { + return; + } + } + let ty = self.ty().to_rust_ty_or_opaque(ctx, &()); if let Some(val) = self.val() { @@ -759,8 +769,11 @@ impl CodeGenerator for TemplateInstantiation { let align = layout.align; let name = item.canonical_name(ctx); - let fn_name = format!("__bindgen_test_layout_{}_instantiation_{}", - name, item.exposed_id(ctx)); + let mut fn_name = format!("__bindgen_test_layout_{}_instantiation", name); + let times_seen = result.overload_number(&fn_name); + if times_seen > 0 { + write!(&mut fn_name, "_{}", times_seen).unwrap(); + } let fn_name = ctx.rust_ident_raw(&fn_name); diff --git a/src/ir/context.rs b/src/ir/context.rs index a5ae19625e..29d6b4b752 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -348,14 +348,31 @@ impl<'ctx> BindgenContext<'ctx> { let is_template_instantiation = is_type && item.expect_type().is_template_instantiation(); - // Be sure to track all the generated children under namespace, even - // those generated after resolving typerefs, etc. + // Ensure that every item (other than the root module) is in a module's + // children list. if item.id() != item.parent_id() { + let mut added_as_child = false; + if let Some(mut parent) = self.items.get_mut(&item.parent_id()) { if let Some(mut module) = parent.as_module_mut() { module.children_mut().push(item.id()); + added_as_child = true; } } + + if !added_as_child { + if let Some(mut current_module) = self.items.get_mut(&self.current_module) { + current_module.as_module_mut() + .expect("self.current_module should always be a module") + .children_mut() + .push(item.id()); + added_as_child = true; + } + } + + assert!(added_as_child, + "We should have added the item as a child of its parent \ + module or the current module"); } if is_type && item.expect_type().is_comp() { diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index c60d69c3a8..f074af0543 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -30,20 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct rte_ipv4_tuple { - pub src_addr: u32, - pub dst_addr: u32, - pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_ipv4_tuple__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub sctp_tag: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, @@ -76,6 +62,13 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_ipv4_tuple__bindgen_ty_1 { + pub __bindgen_anon_1: __BindgenUnionField, + pub sctp_tag: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize @@ -95,6 +88,13 @@ fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { impl Clone for rte_ipv4_tuple__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_ipv4_tuple { + pub src_addr: u32, + pub dst_addr: u32, + pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1, +} #[test] fn bindgen_test_layout_rte_ipv4_tuple() { assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( @@ -117,20 +117,6 @@ impl Clone for rte_ipv4_tuple { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct rte_ipv6_tuple { - pub src_addr: [u8; 16usize], - pub dst_addr: [u8; 16usize], - pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_ipv6_tuple__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub sctp_tag: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { pub dport: u16, pub sport: u16, @@ -163,6 +149,13 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_ipv6_tuple__bindgen_ty_1 { + pub __bindgen_anon_1: __BindgenUnionField, + pub sctp_tag: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize @@ -182,6 +175,13 @@ fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { impl Clone for rte_ipv6_tuple__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_ipv6_tuple { + pub src_addr: [u8; 16usize], + pub dst_addr: [u8; 16usize], + pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1, +} #[test] fn bindgen_test_layout_rte_ipv6_tuple() { assert_eq!(::std::mem::size_of::() , 36usize , concat ! ( diff --git a/tests/expectations/tests/381-decltype-alias.rs b/tests/expectations/tests/381-decltype-alias.rs index 7f2bb8787b..febf179152 100644 --- a/tests/expectations/tests/381-decltype-alias.rs +++ b/tests/expectations/tests/381-decltype-alias.rs @@ -4,9 +4,9 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type std_allocator_traits___size_type<_Alloc> = _Alloc; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct std_allocator_traits { pub _address: u8, } -pub type std_allocator_traits___size_type<_Alloc> = _Alloc; diff --git a/tests/expectations/tests/anon_enum.rs b/tests/expectations/tests/anon_enum.rs index 715688ff59..52b3ae573a 100644 --- a/tests/expectations/tests/anon_enum.rs +++ b/tests/expectations/tests/anon_enum.rs @@ -4,16 +4,16 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +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, } #[repr(C)] #[derive(Debug, Default, 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::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs index 699d49c2d7..33e0ca5a3f 100644 --- a/tests/expectations/tests/anon_enum_trait.rs +++ b/tests/expectations/tests/anon_enum_trait.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct DataType { - pub _address: u8, -} pub type DataType_value_type<_Tp> = _Tp; pub type DataType_work_type<_Tp> = DataType_value_type<_Tp>; pub type DataType_channel_type<_Tp> = DataType_value_type<_Tp>; @@ -27,8 +22,8 @@ pub const DataType_type_: DataType__bindgen_ty_1 = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum DataType__bindgen_ty_1 { generic_type = 0, } #[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo { +#[derive(Debug, Default, Copy, Clone)] +pub struct DataType { pub _address: u8, } pub const Foo_Bar: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::Bar; @@ -36,6 +31,11 @@ pub const Foo_Baz: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::Bar; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum Foo__bindgen_ty_1 { Bar = 0, } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Foo { + pub _address: u8, +} #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index bfb100152d..0d5f51d32c 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -30,17 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct s { - pub u: s__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct s__bindgen_ty_1 { - pub field: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct s__bindgen_ty_1_inner { pub b: ::std::os::raw::c_int, } @@ -61,6 +50,12 @@ fn bindgen_test_layout_s__bindgen_ty_1_inner() { impl Clone for s__bindgen_ty_1_inner { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct s__bindgen_ty_1 { + pub field: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_s__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -76,6 +71,11 @@ fn bindgen_test_layout_s__bindgen_ty_1() { impl Clone for s__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct s { + pub u: s__bindgen_ty_1, +} #[test] fn bindgen_test_layout_s() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index 5a12dcccca..00c2391ed9 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -28,14 +28,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { fmt.write_str("__BindgenUnionField") } } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TErrorResult { - pub mResult: ::std::os::raw::c_int, - pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, - pub mMightHaveUnreported: bool, - pub mUnionState: TErrorResult_UnionState, -} pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState = TErrorResult_UnionState::HasMessage; #[repr(i32)] @@ -58,6 +50,14 @@ pub struct TErrorResult__bindgen_ty_1 { pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, pub bindgen_union_field: u64, } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct TErrorResult { + pub mResult: ::std::os::raw::c_int, + pub __bindgen_anon_1: TErrorResult__bindgen_ty_1, + pub mMightHaveUnreported: bool, + pub mUnionState: TErrorResult_UnionState, +} impl Default for TErrorResult { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } @@ -80,7 +80,7 @@ impl Default for ErrorResult { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_TErrorResult_instantiation_1() { +fn __bindgen_test_layout_TErrorResult_instantiation() { assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( TErrorResult ) )); diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs index ebb3fef43e..ed526cd8eb 100644 --- a/tests/expectations/tests/bitfield-enum-basic.rs +++ b/tests/expectations/tests/bitfield-enum-basic.rs @@ -95,11 +95,6 @@ impl ::std::ops::BitAndAssign for _bindgen_ty_1 { #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct _bindgen_ty_1(pub ::std::os::raw::c_uint); -#[repr(C)] -#[derive(Debug, Default, 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 for Dummy__bindgen_ty_1 { @@ -133,6 +128,11 @@ impl ::std::ops::BitAndAssign for Dummy__bindgen_ty_1 { #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Dummy__bindgen_ty_1(pub ::std::os::raw::c_uint); +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Dummy { + pub _address: u8, +} #[test] fn bindgen_test_layout_Dummy() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/bitfield-method-same-name.rs b/tests/expectations/tests/bitfield-method-same-name.rs index 74dd11e29e..eb8996741f 100644 --- a/tests/expectations/tests/bitfield-method-same-name.rs +++ b/tests/expectations/tests/bitfield-method-same-name.rs @@ -4,6 +4,18 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3Foo4typeEv"] + pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_char; +} +extern "C" { + #[link_name = "_ZN3Foo9set_type_Ec"] + pub fn Foo_set_type_(this: *mut Foo, c: ::std::os::raw::c_char); +} +extern "C" { + #[link_name = "_ZN3Foo8set_typeEc"] + pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { @@ -17,18 +29,6 @@ fn bindgen_test_layout_Foo() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Foo ) )); } -extern "C" { - #[link_name = "_ZN3Foo4typeEv"] - pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_char; -} -extern "C" { - #[link_name = "_ZN3Foo9set_type_Ec"] - pub fn Foo_set_type_(this: *mut Foo, c: ::std::os::raw::c_char); -} -extern "C" { - #[link_name = "_ZN3Foo8set_typeEc"] - pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char); -} impl Clone for Foo { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index 43e67153ac..076605479f 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -242,22 +242,6 @@ fn bindgen_test_layout_WithUnion() { impl Clone for WithUnion { fn clone(&self) -> Self { *self } } -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct RealAbstractionWithTonsOfMethods { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() { - assert_eq!(::std::mem::size_of::() , - 1usize , concat ! ( - "Size of: " , stringify ! ( RealAbstractionWithTonsOfMethods ) - )); - assert_eq! (::std::mem::align_of::() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( - RealAbstractionWithTonsOfMethods ) )); -} extern "C" { #[link_name = "_ZNK32RealAbstractionWithTonsOfMethods3barEv"] pub fn RealAbstractionWithTonsOfMethods_bar(this: @@ -278,6 +262,22 @@ extern "C" { #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3staEv"] pub fn RealAbstractionWithTonsOfMethods_sta(); } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct RealAbstractionWithTonsOfMethods { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_RealAbstractionWithTonsOfMethods() { + assert_eq!(::std::mem::size_of::() , + 1usize , concat ! ( + "Size of: " , stringify ! ( RealAbstractionWithTonsOfMethods ) + )); + assert_eq! (::std::mem::align_of::() , + 1usize , concat ! ( + "Alignment of " , stringify ! ( + RealAbstractionWithTonsOfMethods ) )); +} impl Clone for RealAbstractionWithTonsOfMethods { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs index 5ab0c91868..9f533f2e54 100644 --- a/tests/expectations/tests/class_nested.rs +++ b/tests/expectations/tests/class_nested.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A { - pub member_a: ::std::os::raw::c_int, -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct A_B { @@ -58,6 +53,11 @@ pub struct A_D { impl Default for A_D { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct A { + pub member_a: ::std::os::raw::c_int, +} #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -78,7 +78,7 @@ extern "C" { pub static mut var: A_B; } #[test] -fn __bindgen_test_layout_A_D_instantiation_1() { +fn __bindgen_test_layout_A_D_instantiation() { assert_eq!(::std::mem::size_of::>() , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( @@ -114,12 +114,6 @@ impl Clone for D { } #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Templated { - pub member: T, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct Templated_Templated_inner { pub member_ptr: *mut T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, @@ -127,6 +121,12 @@ pub struct Templated_Templated_inner { impl Default for Templated_Templated_inner { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Templated { + pub member: T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} impl Default for Templated { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs index b48fd0522c..0b81dfc954 100644 --- a/tests/expectations/tests/class_static.rs +++ b/tests/expectations/tests/class_static.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct MyClass { - pub _address: u8, -} extern "C" { #[link_name = "_ZN7MyClass7exampleE"] pub static mut MyClass_example: *const ::std::os::raw::c_int; @@ -18,6 +13,11 @@ extern "C" { pub static mut MyClass_example_check_no_collision: *const ::std::os::raw::c_int; } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct MyClass { + pub _address: u8, +} #[test] fn bindgen_test_layout_MyClass() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs index b8e91bd334..e461702577 100644 --- a/tests/expectations/tests/class_static_const.rs +++ b/tests/expectations/tests/class_static_const.rs @@ -4,14 +4,14 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub const A_a: ::std::os::raw::c_int = 0; +pub const A_b: i32 = 63; +pub const A_c: u32 = 255; #[repr(C)] #[derive(Debug, Default, 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::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs index c3cd31f2d5..d291a983d8 100644 --- a/tests/expectations/tests/class_with_dtor.rs +++ b/tests/expectations/tests/class_with_dtor.rs @@ -35,7 +35,7 @@ impl Default for WithoutDtor { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_HandleWithDtor_instantiation_1() { +fn __bindgen_test_layout_HandleWithDtor_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index f4b03b4e46..005c32a6ae 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -30,13 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, 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, Default, Copy)] pub struct A_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, @@ -103,6 +96,13 @@ fn bindgen_test_layout_A__bindgen_ty_2() { impl Clone for A__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, 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, +} #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( @@ -124,11 +124,6 @@ impl Clone for A { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct B { - pub d: ::std::os::raw::c_uint, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct B_Segment { pub begin: ::std::os::raw::c_int, pub end: ::std::os::raw::c_int, @@ -153,6 +148,11 @@ fn bindgen_test_layout_B_Segment() { impl Clone for B_Segment { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct B { + pub d: ::std::os::raw::c_uint, +} #[test] fn bindgen_test_layout_B() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -177,19 +177,6 @@ pub enum StepSyntax { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct C { - pub d: ::std::os::raw::c_uint, - pub __bindgen_anon_1: C__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct C__bindgen_ty_1 { - pub mFunc: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: [u32; 4usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct C__bindgen_ty_1__bindgen_ty_1 { pub mX1: f32, pub mY1: f32, @@ -267,6 +254,13 @@ impl Clone for C__bindgen_ty_1__bindgen_ty_2 { impl Default for C__bindgen_ty_1__bindgen_ty_2 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct C__bindgen_ty_1 { + pub mFunc: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: [u32; 4usize], +} #[test] fn bindgen_test_layout_C__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( @@ -308,6 +302,12 @@ fn bindgen_test_layout_C_Segment() { impl Clone for C_Segment { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct C { + pub d: ::std::os::raw::c_uint, + pub __bindgen_anon_1: C__bindgen_ty_1, +} #[test] fn bindgen_test_layout_C() { assert_eq!(::std::mem::size_of::() , 20usize , concat ! ( diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs index 9dba86759c..0363778d0c 100644 --- a/tests/expectations/tests/class_with_typedef.rs +++ b/tests/expectations/tests/class_with_typedef.rs @@ -5,6 +5,24 @@ pub type AnotherInt = ::std::os::raw::c_int; +pub type C_MyInt = ::std::os::raw::c_int; +pub type C_Lookup = *const ::std::os::raw::c_char; +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); +} #[repr(C)] #[derive(Debug, Copy)] pub struct C { @@ -14,8 +32,6 @@ pub struct C { 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::() , 72usize , concat ! ( @@ -46,22 +62,6 @@ fn bindgen_test_layout_C() { "Alignment of field: " , stringify ! ( C ) , "::" , stringify ! ( other_ptr ) )); } -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 } } diff --git a/tests/expectations/tests/const_enum_unnamed.rs b/tests/expectations/tests/const_enum_unnamed.rs index 98c6240fa2..da51523240 100644 --- a/tests/expectations/tests/const_enum_unnamed.rs +++ b/tests/expectations/tests/const_enum_unnamed.rs @@ -9,15 +9,15 @@ 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, } +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, } #[repr(C)] #[derive(Debug, Default, 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::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/constant-non-specialized-tp.rs b/tests/expectations/tests/constant-non-specialized-tp.rs index 8be8e5d3b2..7588a02e7a 100644 --- a/tests/expectations/tests/constant-non-specialized-tp.rs +++ b/tests/expectations/tests/constant-non-specialized-tp.rs @@ -11,11 +11,11 @@ pub struct Test { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct Outer { +pub struct Outer_Inner { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct Outer_Inner { +pub struct Outer { pub _address: u8, } diff --git a/tests/expectations/tests/constructor-tp.rs b/tests/expectations/tests/constructor-tp.rs index 7ce4b9b32b..a0673f8c8c 100644 --- a/tests/expectations/tests/constructor-tp.rs +++ b/tests/expectations/tests/constructor-tp.rs @@ -9,6 +9,10 @@ pub struct Foo { pub _address: u8, } +extern "C" { + #[link_name = "_ZN3BarC1Ev"] + pub fn Bar_Bar(this: *mut Bar); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Bar { @@ -21,10 +25,6 @@ fn bindgen_test_layout_Bar() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Bar ) )); } -extern "C" { - #[link_name = "_ZN3BarC1Ev"] - pub fn Bar_Bar(this: *mut Bar); -} impl Clone for Bar { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/constructors.rs b/tests/expectations/tests/constructors.rs index c267ce1c52..66e1c99069 100644 --- a/tests/expectations/tests/constructors.rs +++ b/tests/expectations/tests/constructors.rs @@ -4,6 +4,15 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN12TestOverloadC1Ei"] + pub fn TestOverload_TestOverload(this: *mut TestOverload, + arg1: ::std::os::raw::c_int); +} +extern "C" { + #[link_name = "_ZN12TestOverloadC1Ed"] + pub fn TestOverload_TestOverload1(this: *mut TestOverload, arg1: f64); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct TestOverload { @@ -16,15 +25,6 @@ fn bindgen_test_layout_TestOverload() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( TestOverload ) )); } -extern "C" { - #[link_name = "_ZN12TestOverloadC1Ei"] - pub fn TestOverload_TestOverload(this: *mut TestOverload, - arg1: ::std::os::raw::c_int); -} -extern "C" { - #[link_name = "_ZN12TestOverloadC1Ed"] - pub fn TestOverload_TestOverload1(this: *mut TestOverload, arg1: f64); -} impl Clone for TestOverload { fn clone(&self) -> Self { *self } } @@ -42,6 +42,10 @@ impl TestOverload { __bindgen_tmp } } +extern "C" { + #[link_name = "_ZN16TestPublicNoArgsC1Ev"] + pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct TestPublicNoArgs { @@ -54,10 +58,6 @@ fn bindgen_test_layout_TestPublicNoArgs() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( TestPublicNoArgs ) )); } -extern "C" { - #[link_name = "_ZN16TestPublicNoArgsC1Ev"] - pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs); -} impl Clone for TestPublicNoArgs { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/crtp.rs b/tests/expectations/tests/crtp.rs index 03fef4cd93..f76f78f83e 100644 --- a/tests/expectations/tests/crtp.rs +++ b/tests/expectations/tests/crtp.rs @@ -51,7 +51,7 @@ impl Default for DerivedFromBaseWithDestructor { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_Base_instantiation_1() { +fn __bindgen_test_layout_Base_instantiation() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( "Size of template specialization: " , stringify ! ( Base ) )); assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( @@ -59,7 +59,7 @@ fn __bindgen_test_layout_Base_instantiation_1() { )); } #[test] -fn __bindgen_test_layout_BaseWithDestructor_instantiation_2() { +fn __bindgen_test_layout_BaseWithDestructor_instantiation() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( "Size of template specialization: " , stringify ! ( diff --git a/tests/expectations/tests/default-template-parameter.rs b/tests/expectations/tests/default-template-parameter.rs index 5781c7fb35..e57761ce15 100644 --- a/tests/expectations/tests/default-template-parameter.rs +++ b/tests/expectations/tests/default-template-parameter.rs @@ -16,7 +16,7 @@ impl Default for Foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_Foo_instantiation_1() { +fn __bindgen_test_layout_Foo_instantiation() { assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( diff --git a/tests/expectations/tests/enum_in_template_with_typedef.rs b/tests/expectations/tests/enum_in_template_with_typedef.rs index 8c8195354e..bd0fcecfca 100644 --- a/tests/expectations/tests/enum_in_template_with_typedef.rs +++ b/tests/expectations/tests/enum_in_template_with_typedef.rs @@ -4,14 +4,14 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct std_fbstring_core { - pub _address: u8, -} pub type std_fbstring_core_category_type = u8; pub const std_fbstring_core_Category_Bar: std_fbstring_core_Category = std_fbstring_core_Category::Foo; #[repr(u8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum std_fbstring_core_Category { Foo = 0, } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct std_fbstring_core { + pub _address: u8, +} diff --git a/tests/expectations/tests/forward-declaration-autoptr.rs b/tests/expectations/tests/forward-declaration-autoptr.rs index 3d2708d557..df519fe907 100644 --- a/tests/expectations/tests/forward-declaration-autoptr.rs +++ b/tests/expectations/tests/forward-declaration-autoptr.rs @@ -41,3 +41,12 @@ impl Clone for Bar { impl Default for Bar { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_RefPtr_instantiation() { + assert_eq!(::std::mem::size_of::>() , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( RefPtr + ) )); + assert_eq!(::std::mem::align_of::>() , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + RefPtr ) )); +} diff --git a/tests/expectations/tests/gen-constructors-neg.rs b/tests/expectations/tests/gen-constructors-neg.rs index c894b95c97..84962ef0e5 100644 --- a/tests/expectations/tests/gen-constructors-neg.rs +++ b/tests/expectations/tests/gen-constructors-neg.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3FooC1Ei"] + pub fn Foo_Foo(this: *mut Foo, a: ::std::os::raw::c_int); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { diff --git a/tests/expectations/tests/gen-constructors.rs b/tests/expectations/tests/gen-constructors.rs index d04398647b..c79ccd5191 100644 --- a/tests/expectations/tests/gen-constructors.rs +++ b/tests/expectations/tests/gen-constructors.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3FooC1Ei"] + pub fn Foo_Foo(this: *mut Foo, a: ::std::os::raw::c_int); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { @@ -16,10 +20,6 @@ fn bindgen_test_layout_Foo() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Foo ) )); } -extern "C" { - #[link_name = "_ZN3FooC1Ei"] - pub fn Foo_Foo(this: *mut Foo, a: ::std::os::raw::c_int); -} impl Clone for Foo { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/gen-destructors-neg.rs b/tests/expectations/tests/gen-destructors-neg.rs index 64373d7510..5cf416a6e7 100644 --- a/tests/expectations/tests/gen-destructors-neg.rs +++ b/tests/expectations/tests/gen-destructors-neg.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3FooD1Ev"] + pub fn Foo_Foo_destructor(this: *mut Foo); +} #[repr(C)] #[derive(Debug, Default)] pub struct Foo { diff --git a/tests/expectations/tests/gen-destructors.rs b/tests/expectations/tests/gen-destructors.rs index 711d6f2311..3f5d79df0d 100644 --- a/tests/expectations/tests/gen-destructors.rs +++ b/tests/expectations/tests/gen-destructors.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3FooD1Ev"] + pub fn Foo_Foo_destructor(this: *mut Foo); +} #[repr(C)] #[derive(Debug, Default)] pub struct Foo { @@ -21,10 +25,6 @@ fn bindgen_test_layout_Foo() { "Alignment of field: " , stringify ! ( Foo ) , "::" , stringify ! ( bar ) )); } -extern "C" { - #[link_name = "_ZN3FooD1Ev"] - pub fn Foo_Foo_destructor(this: *mut Foo); -} impl Foo { #[inline] pub unsafe fn destruct(&mut self) { Foo_Foo_destructor(self) } diff --git a/tests/expectations/tests/generate-inline.rs b/tests/expectations/tests/generate-inline.rs index 15f944d35a..abb539e7e2 100644 --- a/tests/expectations/tests/generate-inline.rs +++ b/tests/expectations/tests/generate-inline.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3Foo3barEv"] + pub fn Foo_bar() -> ::std::os::raw::c_int; +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { @@ -16,10 +20,6 @@ fn bindgen_test_layout_Foo() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Foo ) )); } -extern "C" { - #[link_name = "_ZN3Foo3barEv"] - pub fn Foo_bar() -> ::std::os::raw::c_int; -} impl Clone for Foo { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/in_class_typedef.rs b/tests/expectations/tests/in_class_typedef.rs index 92a23ad31c..aafc030d3c 100644 --- a/tests/expectations/tests/in_class_typedef.rs +++ b/tests/expectations/tests/in_class_typedef.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} pub type Foo_elem_type = T; pub type Foo_ptr_type = *mut T; #[repr(C)] @@ -17,3 +12,8 @@ pub struct Foo_Bar { pub x: ::std::os::raw::c_int, pub y: ::std::os::raw::c_int, } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Foo { + pub _address: u8, +} diff --git a/tests/expectations/tests/inner_const.rs b/tests/expectations/tests/inner_const.rs index dd92dac9ac..edcc7620f4 100644 --- a/tests/expectations/tests/inner_const.rs +++ b/tests/expectations/tests/inner_const.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, 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; @@ -17,6 +12,11 @@ extern "C" { #[link_name = "_ZN3Foo8whateverE"] pub static mut Foo_whatever: Foo; } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Foo { + pub bar: ::std::os::raw::c_int, +} #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/inner_template_self.rs b/tests/expectations/tests/inner_template_self.rs index e1a5302fba..26b35d8a73 100644 --- a/tests/expectations/tests/inner_template_self.rs +++ b/tests/expectations/tests/inner_template_self.rs @@ -36,3 +36,12 @@ impl Clone for InstantiateIt { impl Default for InstantiateIt { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_LinkedList_instantiation() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of template specialization: " , stringify ! ( LinkedList + ) )); + assert_eq!(::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + LinkedList ) )); +} diff --git a/tests/expectations/tests/issue-372.rs b/tests/expectations/tests/issue-372.rs index 8a11592475..687ae25f75 100644 --- a/tests/expectations/tests/issue-372.rs +++ b/tests/expectations/tests/issue-372.rs @@ -101,4 +101,15 @@ pub mod root { impl Default for F { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } + #[test] + fn __bindgen_test_layout_C_instantiation() { + assert_eq!(::std::mem::size_of::<[u64; 33usize]>() , 264usize , concat + ! ( + "Size of template specialization: " , stringify ! ( + [u64; 33usize] ) )); + assert_eq!(::std::mem::align_of::<[u64; 33usize]>() , 8usize , concat + ! ( + "Alignment of template specialization: " , stringify ! ( + [u64; 33usize] ) )); + } } diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs index 9f0b9a14b4..d209eccf5a 100644 --- a/tests/expectations/tests/issue-410.rs +++ b/tests/expectations/tests/issue-410.rs @@ -11,6 +11,11 @@ pub mod root { pub mod JS { #[allow(unused_imports)] use self::super::super::root; + extern "C" { + #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"] + pub fn Value_a(this: *mut root::JS::Value, + arg1: root::JSWhyMagic); + } #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Value { @@ -23,11 +28,6 @@ pub mod root { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Value ) )); } - extern "C" { - #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"] - pub fn Value_a(this: *mut root::JS::Value, - arg1: root::JSWhyMagic); - } impl Clone for Value { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs index 4a7f07edb9..6392d6065a 100644 --- a/tests/expectations/tests/issue-447.rs +++ b/tests/expectations/tests/issue-447.rs @@ -35,6 +35,14 @@ pub mod root { } } } + extern "C" { + #[link_name = + "_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"] + pub fn JSAutoCompartment_JSAutoCompartment(this: + *mut root::JSAutoCompartment, + arg1: + root::mozilla::detail::GuardObjectNotifier); + } #[repr(C)] #[derive(Debug, Default, Copy)] pub struct JSAutoCompartment { @@ -49,14 +57,6 @@ pub mod root { concat ! ( "Alignment of " , stringify ! ( JSAutoCompartment ) )); } - extern "C" { - #[link_name = - "_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"] - pub fn JSAutoCompartment_JSAutoCompartment(this: - *mut root::JSAutoCompartment, - arg1: - root::mozilla::detail::GuardObjectNotifier); - } impl Clone for JSAutoCompartment { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs index 89f03457cc..5572dc9ffe 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -28,11 +28,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { fmt.write_str("__BindgenUnionField") } } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct basic_string { - pub _address: u8, -} pub type basic_string_size_type = ::std::os::raw::c_ulonglong; pub type basic_string_value_type = ::std::os::raw::c_char; pub type basic_string_pointer = *mut basic_string_value_type; @@ -52,18 +47,18 @@ pub const basic_string___min_cap: basic_string__bindgen_ty_1 = #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } #[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct basic_string___short { - pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, - pub __data_: *mut basic_string_value_type, -} -#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct basic_string___short__bindgen_ty_1 { pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>, pub __lx: __BindgenUnionField, pub bindgen_union_field: u8, } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct basic_string___short { + pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, + pub __data_: *mut basic_string_value_type, +} impl Default for basic_string___short { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } @@ -92,11 +87,6 @@ impl Default for basic_string___raw { } #[repr(C)] #[derive(Copy, Clone)] -pub struct basic_string___rep { - pub __bindgen_anon_1: basic_string___rep__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] pub struct basic_string___rep__bindgen_ty_1 { pub __l: __BindgenUnionField, pub __s: __BindgenUnionField, @@ -106,6 +96,16 @@ pub struct basic_string___rep__bindgen_ty_1 { impl Default for basic_string___rep__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct basic_string___rep { + pub __bindgen_anon_1: basic_string___rep__bindgen_ty_1, +} impl Default for basic_string___rep { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct basic_string { + pub _address: u8, +} diff --git a/tests/expectations/tests/issue-544-stylo-creduce-2.rs b/tests/expectations/tests/issue-544-stylo-creduce-2.rs index e217fe249d..98b6862b71 100644 --- a/tests/expectations/tests/issue-544-stylo-creduce-2.rs +++ b/tests/expectations/tests/issue-544-stylo-creduce-2.rs @@ -4,12 +4,12 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type Foo_FirstAlias = [u8; 0usize]; +pub type Foo_SecondAlias = [u8; 0usize]; #[repr(C)] pub struct Foo { pub member: Foo_SecondAlias, } -pub type Foo_FirstAlias = [u8; 0usize]; -pub type Foo_SecondAlias = [u8; 0usize]; impl Default for Foo { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs b/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs index 11d60e04f9..1a783f7d49 100644 --- a/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs +++ b/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs @@ -32,7 +32,7 @@ impl Default for JS_AutoIdVector { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_JS_Base_instantiation_2() { +fn __bindgen_test_layout_JS_Base_instantiation() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( "Size of template specialization: " , stringify ! ( JS_Base ) )); diff --git a/tests/expectations/tests/issue-573-layout-test-failures.rs b/tests/expectations/tests/issue-573-layout-test-failures.rs index f82b902dea..7d87aabec0 100644 --- a/tests/expectations/tests/issue-573-layout-test-failures.rs +++ b/tests/expectations/tests/issue-573-layout-test-failures.rs @@ -28,3 +28,11 @@ fn bindgen_test_layout_AutoIdVector() { impl Default for AutoIdVector { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_Outer_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( Outer ) )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( Outer + ) )); +} diff --git a/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs b/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs index 610c0c83cf..a895434d81 100644 --- a/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs +++ b/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs @@ -36,3 +36,11 @@ extern "C" { #[link_name = "AutoIdVector"] pub static mut AutoIdVector: _bindgen_ty_1; } +#[test] +fn __bindgen_test_layout_a_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( a ) )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( a ) + )); +} diff --git a/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs b/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs index b7fa68a340..e9cb527c93 100644 --- a/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs +++ b/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs @@ -23,12 +23,12 @@ impl Clone for b { impl Default for b { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +pub type A_a = b; #[repr(C)] #[derive(Debug, Default, Copy)] pub struct A { pub _address: u8, } -pub type A_a = b; #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( @@ -79,3 +79,11 @@ extern "C" { #[link_name = "_Z25Servo_Element_GetSnapshotv"] pub fn Servo_Element_GetSnapshot() -> A; } +#[test] +fn __bindgen_test_layout_f_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( f ) )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( f ) + )); +} diff --git a/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs b/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs index 4bda092739..4983475d02 100644 --- a/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs +++ b/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs @@ -13,13 +13,13 @@ pub struct RefPtr { impl Default for RefPtr { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +pub type UsesRefPtrWithAliasedTypeParam_V = U; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UsesRefPtrWithAliasedTypeParam { pub member: RefPtr>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -pub type UsesRefPtrWithAliasedTypeParam_V = U; impl Default for UsesRefPtrWithAliasedTypeParam { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/issue-639-typedef-anon-field.rs b/tests/expectations/tests/issue-639-typedef-anon-field.rs index e67400cc82..cdcb91ae5e 100644 --- a/tests/expectations/tests/issue-639-typedef-anon-field.rs +++ b/tests/expectations/tests/issue-639-typedef-anon-field.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo { - pub bar: Foo_Bar, -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo_Bar { @@ -29,6 +24,11 @@ fn bindgen_test_layout_Foo_Bar() { impl Clone for Foo_Bar { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Foo { + pub bar: Foo_Bar, +} #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( @@ -46,11 +46,6 @@ impl Clone for Foo { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct Baz { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct Baz_Bar { pub abc: ::std::os::raw::c_int, } @@ -69,6 +64,11 @@ fn bindgen_test_layout_Baz_Bar() { impl Clone for Baz_Bar { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Baz { + pub _address: u8, +} #[test] fn bindgen_test_layout_Baz() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs index a222500354..4e05abf096 100644 --- a/tests/expectations/tests/issue-643-inner-struct.rs +++ b/tests/expectations/tests/issue-643-inner-struct.rs @@ -38,14 +38,6 @@ impl ::std::clone::Clone for __IncompleteArrayField { } impl ::std::marker::Copy for __IncompleteArrayField { } #[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_ring { - pub memzone: *mut rte_memzone, - pub prod: rte_ring_prod, - pub cons: rte_ring_cons, - pub ring: __IncompleteArrayField<*mut ::std::os::raw::c_void>, -} -#[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_ring_prod { pub watermark: ::std::os::raw::c_uint, @@ -85,6 +77,14 @@ fn bindgen_test_layout_rte_ring_cons() { impl Clone for rte_ring_cons { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Copy)] +pub struct rte_ring { + pub memzone: *mut rte_memzone, + pub prod: rte_ring_prod, + pub cons: rte_ring_cons, + pub ring: __IncompleteArrayField<*mut ::std::os::raw::c_void>, +} #[test] fn bindgen_test_layout_rte_ring() { assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( diff --git a/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs b/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs index d705ffa34c..e35a19b537 100644 --- a/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs +++ b/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs @@ -5,13 +5,13 @@ #[derive(Clone, Copy, Debug)] pub struct RefPtr(T); +pub type HasRefPtr_TypedefOfT = T; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct HasRefPtr { pub refptr_member: RefPtr>, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -pub type HasRefPtr_TypedefOfT = T; impl Default for HasRefPtr { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/issue-674-1.rs b/tests/expectations/tests/issue-674-1.rs index 01257c2377..56246c8981 100644 --- a/tests/expectations/tests/issue-674-1.rs +++ b/tests/expectations/tests/issue-674-1.rs @@ -11,12 +11,12 @@ pub mod root { pub mod mozilla { #[allow(unused_imports)] use self::super::super::root; + pub type Maybe_ValueType = T; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Maybe { pub _address: u8, } - pub type Maybe_ValueType = T; impl Default for Maybe { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } @@ -43,4 +43,13 @@ pub mod root { impl Clone for CapturingContentInfo { fn clone(&self) -> Self { *self } } + #[test] + fn __bindgen_test_layout_Maybe_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( u8 ) + )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( u8 + ) )); + } } diff --git a/tests/expectations/tests/issue-674-2.rs b/tests/expectations/tests/issue-674-2.rs index 819eff05db..0f5718e742 100644 --- a/tests/expectations/tests/issue-674-2.rs +++ b/tests/expectations/tests/issue-674-2.rs @@ -11,12 +11,12 @@ pub mod root { pub mod JS { #[allow(unused_imports)] use self::super::super::root; + pub type Rooted_ElementType = T; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Rooted { pub _address: u8, } - pub type Rooted_ElementType = T; impl Default for Rooted { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } @@ -66,4 +66,24 @@ pub mod root { pub struct StaticRefPtr { pub _address: u8, } + #[test] + fn __bindgen_test_layout_Rooted_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( u8 ) + )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( u8 + ) )); + } + #[test] + fn __bindgen_test_layout_StaticRefPtr_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + root::StaticRefPtr ) )); + assert_eq!(::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::StaticRefPtr ) )); + } } diff --git a/tests/expectations/tests/issue-674-3.rs b/tests/expectations/tests/issue-674-3.rs index 6e915a18af..7c1c934148 100644 --- a/tests/expectations/tests/issue-674-3.rs +++ b/tests/expectations/tests/issue-674-3.rs @@ -8,12 +8,12 @@ pub mod root { #[allow(unused_imports)] use self::super::root; + pub type nsRefPtrHashtable_UserDataType = *mut PtrType; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsRefPtrHashtable { pub _address: u8, } - pub type nsRefPtrHashtable_UserDataType = *mut PtrType; impl Default for nsRefPtrHashtable { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } @@ -57,4 +57,13 @@ pub mod root { impl Clone for nsCSSValue { fn clone(&self) -> Self { *self } } + #[test] + fn __bindgen_test_layout_nsRefPtrHashtable_instantiation() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( u8 ) + )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( u8 + ) )); + } } diff --git a/tests/expectations/tests/issue-691-template-parameter-virtual.rs b/tests/expectations/tests/issue-691-template-parameter-virtual.rs index b0bcb54124..de43c0363f 100644 --- a/tests/expectations/tests/issue-691-template-parameter-virtual.rs +++ b/tests/expectations/tests/issue-691-template-parameter-virtual.rs @@ -51,7 +51,7 @@ impl Default for ServoElementSnapshotTable { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_Set_instantiation_1() { +fn __bindgen_test_layout_Set_instantiation() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( Set ) )); assert_eq!(::std::mem::align_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/issue-769-bad-instantiation-test.rs b/tests/expectations/tests/issue-769-bad-instantiation-test.rs new file mode 100644 index 0000000000..f797cdff45 --- /dev/null +++ b/tests/expectations/tests/issue-769-bad-instantiation-test.rs @@ -0,0 +1,43 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::root; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub member: T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, + } + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type AutoValueVector_Alias = ::std::os::raw::c_int; + #[test] + fn __bindgen_test_layout_Rooted_instantiation() { + assert_eq!(::std::mem::size_of::>() + , 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::Rooted<::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::>() + , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::Rooted<::std::os::raw::c_int> ) )); + } + #[test] + fn __bindgen_test_layout_Rooted_instantiation_1() { + assert_eq!(::std::mem::size_of::>() + , 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( + root::Rooted ) )); + assert_eq!(::std::mem::align_of::>() + , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + root::Rooted ) )); + } +} diff --git a/tests/expectations/tests/issue_311.rs b/tests/expectations/tests/issue_311.rs index c5ecb96665..86d421d438 100644 --- a/tests/expectations/tests/issue_311.rs +++ b/tests/expectations/tests/issue_311.rs @@ -10,11 +10,6 @@ pub mod root { use self::super::root; #[repr(C)] #[derive(Debug, Default, Copy)] - pub struct jsval_layout { - pub __bindgen_anon_1: root::jsval_layout__bindgen_ty_1, - } - #[repr(C)] - #[derive(Debug, Default, Copy)] pub struct jsval_layout__bindgen_ty_1 { pub _address: u8, } @@ -32,6 +27,11 @@ pub mod root { impl Clone for jsval_layout__bindgen_ty_1 { fn clone(&self) -> Self { *self } } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct jsval_layout { + pub __bindgen_anon_1: root::jsval_layout__bindgen_ty_1, + } #[test] fn bindgen_test_layout_jsval_layout() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index 02e282a616..c0826c5575 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -96,18 +96,6 @@ pub enum JSWhyMagic { JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct jsval_layout { - pub asBits: __BindgenUnionField, - pub debugView: __BindgenUnionField, - pub s: __BindgenUnionField, - pub asDouble: __BindgenUnionField, - pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub asWord: __BindgenUnionField, - pub asUIntPtr: __BindgenUnionField, - pub bindgen_union_field: u64, -} -#[repr(C)] #[derive(Debug, Copy)] pub struct jsval_layout__bindgen_ty_1 { pub _bitfield_1: u64, @@ -197,11 +185,6 @@ impl jsval_layout__bindgen_ty_1 { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct jsval_layout__bindgen_ty_2 { - pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { pub i32: __BindgenUnionField, pub u32: __BindgenUnionField, @@ -243,6 +226,11 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct jsval_layout__bindgen_ty_2 { + pub payload: jsval_layout__bindgen_ty_2__bindgen_ty_1, +} #[test] fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 4usize , @@ -262,6 +250,18 @@ fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { impl Clone for jsval_layout__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct jsval_layout { + pub asBits: __BindgenUnionField, + pub debugView: __BindgenUnionField, + pub s: __BindgenUnionField, + pub asDouble: __BindgenUnionField, + pub asPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub asWord: __BindgenUnionField, + pub asUIntPtr: __BindgenUnionField, + pub bindgen_union_field: u64, +} #[test] fn bindgen_test_layout_jsval_layout() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index 3ca0ffe83b..ceb5d4246a 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -187,17 +187,6 @@ impl Clone for rte_mempool_ops_table { impl Default for rte_mempool_ops_table { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -/** - * Structure to hold malloc heap - */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct malloc_heap { - pub lock: rte_spinlock_t, - pub free_head: [malloc_heap__bindgen_ty_1; 13usize], - pub alloc_count: ::std::os::raw::c_uint, - pub total_size: usize, -} #[repr(C)] #[derive(Debug, Copy)] pub struct malloc_heap__bindgen_ty_1 { @@ -225,6 +214,17 @@ impl Clone for malloc_heap__bindgen_ty_1 { impl Default for malloc_heap__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +/** + * Structure to hold malloc heap + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct malloc_heap { + pub lock: rte_spinlock_t, + pub free_head: [malloc_heap__bindgen_ty_1; 13usize], + pub alloc_count: ::std::os::raw::c_uint, + pub total_size: usize, +} #[test] fn bindgen_test_layout_malloc_heap() { assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index 2dae536ae8..5078091897 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -93,29 +93,6 @@ fn bindgen_test_layout_ip_frag_key() { impl Clone for ip_frag_key { fn clone(&self) -> Self { *self } } -/** - * @internal Fragmented packet to reassemble. - * First two entries in the frags[] array are for the last and first fragments. - */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ip_frag_pkt { - /**< LRU list */ - pub lru: ip_frag_pkt__bindgen_ty_1, - /**< fragmentation key */ - pub key: ip_frag_key, - /**< creation timestamp */ - pub start: u64, - /**< expected reassembled size */ - pub total_size: u32, - /**< size of fragments received */ - pub frag_size: u32, - /**< index of next entry to fill */ - pub last_idx: u32, - /**< fragments */ - pub frags: [ip_frag; 4usize], - pub __bindgen_padding_0: [u64; 6usize], -} #[repr(C)] #[derive(Debug, Copy)] pub struct ip_frag_pkt__bindgen_ty_1 { @@ -150,6 +127,29 @@ impl Clone for ip_frag_pkt__bindgen_ty_1 { impl Default for ip_frag_pkt__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +/** + * @internal Fragmented packet to reassemble. + * First two entries in the frags[] array are for the last and first fragments. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ip_frag_pkt { + /**< LRU list */ + pub lru: ip_frag_pkt__bindgen_ty_1, + /**< fragmentation key */ + pub key: ip_frag_key, + /**< creation timestamp */ + pub start: u64, + /**< expected reassembled size */ + pub total_size: u32, + /**< size of fragments received */ + pub frag_size: u32, + /**< index of next entry to fill */ + pub last_idx: u32, + /**< fragments */ + pub frags: [ip_frag; 4usize], + pub __bindgen_padding_0: [u64; 6usize], +} #[test] fn bindgen_test_layout_ip_frag_pkt() { assert_eq!(::std::mem::size_of::() , 192usize , concat ! ( diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 0c8619acc2..c5959d6185 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -623,31 +623,6 @@ pub enum rte_eth_nb_pools { ETH_32_POOLS = 32, ETH_64_POOLS = 64, } -/** - * A structure used to configure the VMDQ+DCB feature - * of an Ethernet port. - * - * Using this feature, packets are routed to a pool of queues, based - * on the vlan id in the vlan tag, and then to a specific queue within - * that pool, using the user priority vlan tag field. - * - * A default pool may be used, if desired, to route all traffic which - * does not match the vlan filter rules. - */ -#[repr(C)] -pub struct rte_eth_vmdq_dcb_conf { - /**< With DCB, 16 or 32 pools */ - pub nb_queue_pools: rte_eth_nb_pools, - /**< If non-zero, use a default pool */ - pub enable_default_pool: u8, - /**< The default pool, if applicable */ - pub default_pool: u8, - /**< We can have up to 64 filters/mappings */ - pub nb_pool_maps: u8, - /**< VMDq vlan pool maps. */ - pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], - pub dcb_tc: [u8; 8usize], -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { @@ -682,6 +657,31 @@ fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() { impl Clone for rte_eth_vmdq_dcb_conf__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +/** + * A structure used to configure the VMDQ+DCB feature + * of an Ethernet port. + * + * Using this feature, packets are routed to a pool of queues, based + * on the vlan id in the vlan tag, and then to a specific queue within + * that pool, using the user priority vlan tag field. + * + * A default pool may be used, if desired, to route all traffic which + * does not match the vlan filter rules. + */ +#[repr(C)] +pub struct rte_eth_vmdq_dcb_conf { + /**< With DCB, 16 or 32 pools */ + pub nb_queue_pools: rte_eth_nb_pools, + /**< If non-zero, use a default pool */ + pub enable_default_pool: u8, + /**< The default pool, if applicable */ + pub default_pool: u8, + /**< We can have up to 64 filters/mappings */ + pub nb_pool_maps: u8, + /**< VMDq vlan pool maps. */ + pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], + pub dcb_tc: [u8; 8usize], +} #[test] fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { assert_eq!(::std::mem::size_of::() , 1040usize , @@ -849,23 +849,6 @@ impl Default for rte_eth_vmdq_tx_conf { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[repr(C)] -pub struct rte_eth_vmdq_rx_conf { - /**< VMDq only mode, 8 or 64 pools */ - pub nb_queue_pools: rte_eth_nb_pools, - /**< If non-zero, use a default pool */ - pub enable_default_pool: u8, - /**< The default pool, if applicable */ - pub default_pool: u8, - /**< Enable VT loop back */ - pub enable_loop_back: u8, - /**< We can have up to 64 filters/mappings */ - pub nb_pool_maps: u8, - /**< Flags from ETH_VMDQ_ACCEPT_* */ - pub rx_mode: u32, - /**< VMDq vlan pool maps. */ - pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], -} -#[repr(C)] #[derive(Debug, Default, Copy)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { /**< The vlan id of the received frame */ @@ -899,6 +882,23 @@ fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() { impl Clone for rte_eth_vmdq_rx_conf__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +pub struct rte_eth_vmdq_rx_conf { + /**< VMDq only mode, 8 or 64 pools */ + pub nb_queue_pools: rte_eth_nb_pools, + /**< If non-zero, use a default pool */ + pub enable_default_pool: u8, + /**< The default pool, if applicable */ + pub default_pool: u8, + /**< Enable VT loop back */ + pub enable_loop_back: u8, + /**< We can have up to 64 filters/mappings */ + pub nb_pool_maps: u8, + /**< Flags from ETH_VMDQ_ACCEPT_* */ + pub rx_mode: u32, + /**< VMDq vlan pool maps. */ + pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], +} #[test] fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { assert_eq!(::std::mem::size_of::() , 1040usize , @@ -1386,43 +1386,6 @@ fn bindgen_test_layout_rte_intr_conf() { impl Clone for rte_intr_conf { fn clone(&self) -> Self { *self } } -/** - * A structure used to configure an Ethernet port. - * Depending upon the RX multi-queue mode, extra advanced - * configuration settings may be needed. - */ -#[repr(C)] -pub struct rte_eth_conf { - /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be - used. ETH_LINK_SPEED_FIXED disables link - autonegotiation, and a unique speed shall be - set. Otherwise, the bitmap defines the set of - speeds to be advertised. If the special value - ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - supported are advertised. */ - pub link_speeds: u32, - /**< Port RX configuration. */ - pub rxmode: rte_eth_rxmode, - /**< Port TX configuration. */ - pub txmode: rte_eth_txmode, - /**< Loopback operation mode. By default the value - is 0, meaning the loopback mode is disabled. - Read the datasheet of given ethernet controller - for details. The possible values of this field - are defined in implementation of each driver. */ - pub lpbk_mode: u32, - /**< Port RX filtering configuration (union). */ - pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - /**< Port TX DCB configuration (union). */ - pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, - /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC - is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */ - pub dcb_capability_en: u32, - /**< FDIR configuration. */ - pub fdir_conf: rte_fdir_conf, - /**< Interrupt mode configuration. */ - pub intr_conf: rte_intr_conf, -} #[repr(C)] pub struct rte_eth_conf__bindgen_ty_1 { /**< Port RSS configuration */ @@ -1507,6 +1470,43 @@ fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { impl Clone for rte_eth_conf__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +/** + * A structure used to configure an Ethernet port. + * Depending upon the RX multi-queue mode, extra advanced + * configuration settings may be needed. + */ +#[repr(C)] +pub struct rte_eth_conf { + /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be + used. ETH_LINK_SPEED_FIXED disables link + autonegotiation, and a unique speed shall be + set. Otherwise, the bitmap defines the set of + speeds to be advertised. If the special value + ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + supported are advertised. */ + pub link_speeds: u32, + /**< Port RX configuration. */ + pub rxmode: rte_eth_rxmode, + /**< Port TX configuration. */ + pub txmode: rte_eth_txmode, + /**< Loopback operation mode. By default the value + is 0, meaning the loopback mode is disabled. + Read the datasheet of given ethernet controller + for details. The possible values of this field + are defined in implementation of each driver. */ + pub lpbk_mode: u32, + /**< Port RX filtering configuration (union). */ + pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, + /**< Port TX DCB configuration (union). */ + pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, + /** Currently,Priority Flow Control(PFC) are supported,if DCB with PFC + is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. */ + pub dcb_capability_en: u32, + /**< FDIR configuration. */ + pub fdir_conf: rte_fdir_conf, + /**< Interrupt mode configuration. */ + pub intr_conf: rte_intr_conf, +} #[test] fn bindgen_test_layout_rte_eth_conf() { assert_eq!(::std::mem::size_of::() , 2944usize , concat ! ( diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index 098686898d..8768c19d77 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -126,29 +126,6 @@ fn bindgen_test_layout_ip_frag_key() { impl Clone for ip_frag_key { fn clone(&self) -> Self { *self } } -/** - * @internal Fragmented packet to reassemble. - * First two entries in the frags[] array are for the last and first fragments. - */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ip_frag_pkt { - /**< LRU list */ - pub lru: ip_frag_pkt__bindgen_ty_1, - /**< fragmentation key */ - pub key: ip_frag_key, - /**< creation timestamp */ - pub start: u64, - /**< expected reassembled size */ - pub total_size: u32, - /**< size of fragments received */ - pub frag_size: u32, - /**< index of next entry to fill */ - pub last_idx: u32, - /**< fragments */ - pub frags: [ip_frag; 4usize], - pub __bindgen_padding_0: [u64; 6usize], -} #[repr(C)] #[derive(Debug, Copy)] pub struct ip_frag_pkt__bindgen_ty_1 { @@ -183,6 +160,29 @@ impl Clone for ip_frag_pkt__bindgen_ty_1 { impl Default for ip_frag_pkt__bindgen_ty_1 { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +/** + * @internal Fragmented packet to reassemble. + * First two entries in the frags[] array are for the last and first fragments. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct ip_frag_pkt { + /**< LRU list */ + pub lru: ip_frag_pkt__bindgen_ty_1, + /**< fragmentation key */ + pub key: ip_frag_key, + /**< creation timestamp */ + pub start: u64, + /**< expected reassembled size */ + pub total_size: u32, + /**< size of fragments received */ + pub frag_size: u32, + /**< index of next entry to fill */ + pub last_idx: u32, + /**< fragments */ + pub frags: [ip_frag; 4usize], + pub __bindgen_padding_0: [u64; 6usize], +} #[test] fn bindgen_test_layout_ip_frag_pkt() { assert_eq!(::std::mem::size_of::() , 192usize , concat ! ( diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index faf9002f57..850469dfc3 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -58,56 +58,6 @@ fn bindgen_test_layout_rte_atomic16_t() { impl Clone for rte_atomic16_t { fn clone(&self) -> Self { *self } } -/** - * The generic rte_mbuf, containing a packet mbuf. - */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_mbuf { - pub cacheline0: MARKER, - /**< Virtual address of segment buffer. */ - pub buf_addr: *mut ::std::os::raw::c_void, - /**< Physical address of segment buffer. */ - pub buf_physaddr: phys_addr_t, - /**< Length of segment buffer. */ - pub buf_len: u16, - pub rearm_data: MARKER8, - pub data_off: u16, - pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - /**< Number of segments. */ - pub nb_segs: u8, - /**< Input port. */ - pub port: u8, - /**< Offload features. */ - pub ol_flags: u64, - pub rx_descriptor_fields1: MARKER, - pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - /**< Total pkt len: sum of all segments. */ - pub pkt_len: u32, - /**< Amount of data in segment buffer. */ - pub data_len: u16, - /** VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. */ - pub vlan_tci: u16, - /**< hash information */ - pub hash: rte_mbuf__bindgen_ty_3, - /**< Sequence number. See also rte_reorder_insert() */ - pub seqn: u32, - /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. */ - pub vlan_tci_outer: u16, - pub cacheline1: MARKER, - pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - /**< Pool from which mbuf was allocated. */ - pub pool: *mut rte_mempool, - /**< Next segment of scattered packet. */ - pub next: *mut rte_mbuf, - pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, - /** Size of the application private data. In case of an indirect - * mbuf, it stores the direct mbuf private data size. */ - pub priv_size: u16, - /** Timesync flags for use with IEEE1588. */ - pub timesync: u16, - pub __bindgen_padding_0: [u32; 7usize], -} /** * 16-bit Reference counter. * It should only be accessed using the following functions: @@ -149,14 +99,6 @@ impl Clone for rte_mbuf__bindgen_ty_1 { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_2 { - /**< L2/L3/L4 and tunnel information. */ - pub packet_type: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 { pub _bitfield_1: [u8; 4usize], pub __bindgen_align: [u32; 0usize], @@ -398,6 +340,14 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 { (251658240u64 as u32)) } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_mbuf__bindgen_ty_2 { + /**< L2/L3/L4 and tunnel information. */ + pub packet_type: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { assert_eq!(::std::mem::size_of::() , 4usize , @@ -417,32 +367,6 @@ impl Clone for rte_mbuf__bindgen_ty_2 { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_3 { - /**< RSS hash result if RSS enabled */ - pub rss: __BindgenUnionField, - /**< Filter identifier if FDIR enabled */ - pub fdir: __BindgenUnionField, - /**< Hierarchical scheduler */ - pub sched: __BindgenUnionField, - /**< User defined tags. See rte_distributor_process() */ - pub usr: __BindgenUnionField, - pub bindgen_union_field: [u32; 2usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { - pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, - pub hi: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { - pub __bindgen_anon_1: __BindgenUnionField, - pub lo: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { pub hash: u16, pub id: u16, @@ -482,6 +406,13 @@ impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { + pub __bindgen_anon_1: __BindgenUnionField, + pub lo: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() @@ -505,6 +436,12 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 { + pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1, + pub hi: u32, +} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , @@ -557,6 +494,19 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() { impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_mbuf__bindgen_ty_3 { + /**< RSS hash result if RSS enabled */ + pub rss: __BindgenUnionField, + /**< Filter identifier if FDIR enabled */ + pub fdir: __BindgenUnionField, + /**< Hierarchical scheduler */ + pub sched: __BindgenUnionField, + /**< User defined tags. See rte_distributor_process() */ + pub usr: __BindgenUnionField, + pub bindgen_union_field: [u32; 2usize], +} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { assert_eq!(::std::mem::size_of::() , 8usize , @@ -622,14 +572,6 @@ impl Clone for rte_mbuf__bindgen_ty_4 { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_5 { - /**< combined for easy fetch */ - pub tx_offload: __BindgenUnionField, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 { pub _bitfield_1: [u16; 4usize], pub __bindgen_align: [u64; 0usize], @@ -840,6 +782,14 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 { (71494644084506624u64 as u64)) } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct rte_mbuf__bindgen_ty_5 { + /**< combined for easy fetch */ + pub tx_offload: __BindgenUnionField, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u64, +} #[test] fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { assert_eq!(::std::mem::size_of::() , 8usize , @@ -857,6 +807,56 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { impl Clone for rte_mbuf__bindgen_ty_5 { fn clone(&self) -> Self { *self } } +/** + * The generic rte_mbuf, containing a packet mbuf. + */ +#[repr(C)] +#[derive(Debug, Copy)] +pub struct rte_mbuf { + pub cacheline0: MARKER, + /**< Virtual address of segment buffer. */ + pub buf_addr: *mut ::std::os::raw::c_void, + /**< Physical address of segment buffer. */ + pub buf_physaddr: phys_addr_t, + /**< Length of segment buffer. */ + pub buf_len: u16, + pub rearm_data: MARKER8, + pub data_off: u16, + pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, + /**< Number of segments. */ + pub nb_segs: u8, + /**< Input port. */ + pub port: u8, + /**< Offload features. */ + pub ol_flags: u64, + pub rx_descriptor_fields1: MARKER, + pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, + /**< Total pkt len: sum of all segments. */ + pub pkt_len: u32, + /**< Amount of data in segment buffer. */ + pub data_len: u16, + /** VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. */ + pub vlan_tci: u16, + /**< hash information */ + pub hash: rte_mbuf__bindgen_ty_3, + /**< Sequence number. See also rte_reorder_insert() */ + pub seqn: u32, + /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. */ + pub vlan_tci_outer: u16, + pub cacheline1: MARKER, + pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, + /**< Pool from which mbuf was allocated. */ + pub pool: *mut rte_mempool, + /**< Next segment of scattered packet. */ + pub next: *mut rte_mbuf, + pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, + /** Size of the application private data. In case of an indirect + * mbuf, it stores the direct mbuf private data size. */ + pub priv_size: u16, + /** Timesync flags for use with IEEE1588. */ + pub timesync: u16, + pub __bindgen_padding_0: [u32; 7usize], +} #[test] fn bindgen_test_layout_rte_mbuf() { assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( diff --git a/tests/expectations/tests/libclang-4/auto.rs b/tests/expectations/tests/libclang-4/auto.rs index 70743067e8..3d1dd69dc2 100644 --- a/tests/expectations/tests/libclang-4/auto.rs +++ b/tests/expectations/tests/libclang-4/auto.rs @@ -4,12 +4,12 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub const Foo_kFoo: bool = true; #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { pub _address: u8, } -pub const Foo_kFoo: bool = true; #[test] fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/libclang-4/const_bool.rs b/tests/expectations/tests/libclang-4/const_bool.rs index fd0273aa70..142dda6718 100644 --- a/tests/expectations/tests/libclang-4/const_bool.rs +++ b/tests/expectations/tests/libclang-4/const_bool.rs @@ -5,12 +5,12 @@ pub const k: bool = true; +pub const A_k: bool = false; #[repr(C)] #[derive(Debug, Default, Copy)] pub struct A { pub _address: u8, } -pub const A_k: bool = false; #[test] fn bindgen_test_layout_A() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs index ec399304cd..0568af86ca 100644 --- a/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs +++ b/tests/expectations/tests/libclang-4/partial-specialization-and-inheritance.rs @@ -15,7 +15,7 @@ pub struct Derived { pub b: bool, } #[test] -fn __bindgen_test_layout__bindgen_ty_id_20_instantiation_1() { +fn __bindgen_test_layout__bindgen_ty_id_20_instantiation() { assert_eq!(::std::mem::size_of::<[u32; 2usize]>() , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( [u32; 2usize] ) )); @@ -23,15 +23,15 @@ fn __bindgen_test_layout__bindgen_ty_id_20_instantiation_1() { "Alignment of template specialization: " , stringify ! ( [u32; 2usize] ) )); } +extern "C" { + #[link_name = "_ZN5Usage13static_memberE"] + pub static mut Usage_static_member: [u32; 2usize]; +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Usage { pub _address: u8, } -extern "C" { - #[link_name = "_ZN5Usage13static_memberE"] - pub static mut Usage_static_member: [u32; 2usize]; -} #[test] fn bindgen_test_layout_Usage() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs index e88178cf3f..19e2a0dda0 100644 --- a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs @@ -29,3 +29,14 @@ impl Default for Rooted { } ///
pub type MaybeWrapped
= a; +#[test] +fn __bindgen_test_layout_MaybeWrapped_instantiation() { + assert_eq!(::std::mem::size_of::>() , + 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( + MaybeWrapped<::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::>() , + 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + MaybeWrapped<::std::os::raw::c_int> ) )); +} diff --git a/tests/expectations/tests/maddness-is-avoidable.rs b/tests/expectations/tests/maddness-is-avoidable.rs index b1eea1d093..fa4f74e49c 100644 --- a/tests/expectations/tests/maddness-is-avoidable.rs +++ b/tests/expectations/tests/maddness-is-avoidable.rs @@ -6,11 +6,11 @@ #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr { +pub struct RefPtr_Proxy { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr_Proxy { +pub struct RefPtr { pub _address: u8, } diff --git a/tests/expectations/tests/method-mangling.rs b/tests/expectations/tests/method-mangling.rs index 765ca5fbae..06840cf5bd 100644 --- a/tests/expectations/tests/method-mangling.rs +++ b/tests/expectations/tests/method-mangling.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3Foo4typeEv"] + pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_int; +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Foo { @@ -16,10 +20,6 @@ fn bindgen_test_layout_Foo() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Foo ) )); } -extern "C" { - #[link_name = "_ZN3Foo4typeEv"] - pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_int; -} impl Clone for Foo { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs index 1e954298e3..14045f4c4a 100644 --- a/tests/expectations/tests/namespace.rs +++ b/tests/expectations/tests/namespace.rs @@ -28,6 +28,12 @@ pub mod root { #[link_name = "_ZN12_GLOBAL__N_13fooEv"] pub fn foo(); } + extern "C" { + #[link_name = "_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"] + pub fn A_lets_hope_this_works(this: + *mut root::_bindgen_mod_id_13::A) + -> ::std::os::raw::c_int; + } #[repr(C)] #[derive(Debug, Default, Copy)] pub struct A { @@ -45,12 +51,6 @@ pub mod root { "Alignment of field: " , stringify ! ( A ) , "::" , stringify ! ( b ) )); } - extern "C" { - #[link_name = "_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"] - pub fn A_lets_hope_this_works(this: - *mut root::_bindgen_mod_id_13::A) - -> ::std::os::raw::c_int; - } impl Clone for A { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/nested.rs b/tests/expectations/tests/nested.rs index 929732f68b..fa87cb005e 100644 --- a/tests/expectations/tests/nested.rs +++ b/tests/expectations/tests/nested.rs @@ -26,17 +26,6 @@ impl Clone for Calc { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct Test { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Test_Size { - pub mWidth: Test_Size_Dimension, - pub mHeight: Test_Size_Dimension, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct Test_Size_Dimension { pub _base: Calc, } @@ -51,6 +40,12 @@ fn bindgen_test_layout_Test_Size_Dimension() { impl Clone for Test_Size_Dimension { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Test_Size { + pub mWidth: Test_Size_Dimension, + pub mHeight: Test_Size_Dimension, +} #[test] fn bindgen_test_layout_Test_Size() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( @@ -71,6 +66,11 @@ fn bindgen_test_layout_Test_Size() { impl Clone for Test_Size { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct Test { + pub _address: u8, +} #[test] fn bindgen_test_layout_Test() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/nested_vtable.rs b/tests/expectations/tests/nested_vtable.rs index dae737d45e..5448b870d0 100644 --- a/tests/expectations/tests/nested_vtable.rs +++ b/tests/expectations/tests/nested_vtable.rs @@ -4,6 +4,11 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN11nsISupports14QueryInterfaceEv"] + pub fn nsISupports_QueryInterface(this: *mut ::std::os::raw::c_void) + -> *mut nsISupports; +} #[repr(C)] pub struct nsISupports__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] diff --git a/tests/expectations/tests/nested_within_namespace.rs b/tests/expectations/tests/nested_within_namespace.rs index 8021b831f2..8c5d0e5f52 100644 --- a/tests/expectations/tests/nested_within_namespace.rs +++ b/tests/expectations/tests/nested_within_namespace.rs @@ -13,11 +13,6 @@ pub mod root { use self::super::super::root; #[repr(C)] #[derive(Debug, Default, Copy)] - pub struct Bar { - pub foo: ::std::os::raw::c_int, - } - #[repr(C)] - #[derive(Debug, Default, Copy)] pub struct Bar_Baz { pub foo: ::std::os::raw::c_int, } @@ -36,6 +31,11 @@ pub mod root { impl Clone for Bar_Baz { fn clone(&self) -> Self { *self } } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub foo: ::std::os::raw::c_int, + } #[test] fn bindgen_test_layout_Bar() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/non-type-params.rs b/tests/expectations/tests/non-type-params.rs index c7ac4e8571..34864993ea 100644 --- a/tests/expectations/tests/non-type-params.rs +++ b/tests/expectations/tests/non-type-params.rs @@ -38,7 +38,7 @@ impl Default for UsesArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } #[test] -fn __bindgen_test_layout_Array_instantiation_1() { +fn __bindgen_test_layout_Array_instantiation() { assert_eq!(::std::mem::size_of::<[u32; 4usize]>() , 16usize , concat ! ( "Size of template specialization: " , stringify ! ( [u32; 4usize] ) )); @@ -46,3 +46,21 @@ fn __bindgen_test_layout_Array_instantiation_1() { "Alignment of template specialization: " , stringify ! ( [u32; 4usize] ) )); } +#[test] +fn __bindgen_test_layout_Array_instantiation_1() { + assert_eq!(::std::mem::size_of::<[u8; 16usize]>() , 16usize , concat ! ( + "Size of template specialization: " , stringify ! ( + [u8; 16usize] ) )); + assert_eq!(::std::mem::align_of::<[u8; 16usize]>() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + [u8; 16usize] ) )); +} +#[test] +fn __bindgen_test_layout_Array_instantiation_2() { + assert_eq!(::std::mem::size_of::<[u8; 8usize]>() , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + [u8; 8usize] ) )); + assert_eq!(::std::mem::align_of::<[u8; 8usize]>() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + [u8; 8usize] ) )); +} diff --git a/tests/expectations/tests/nsStyleAutoArray.rs b/tests/expectations/tests/nsStyleAutoArray.rs index d9287e00ba..d8681a5a89 100644 --- a/tests/expectations/tests/nsStyleAutoArray.rs +++ b/tests/expectations/tests/nsStyleAutoArray.rs @@ -13,6 +13,11 @@ pub struct nsTArray { impl Default for nsTArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum nsStyleAutoArray_WithSingleInitialElement { + WITH_SINGLE_INITIAL_ELEMENT = 0, +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsStyleAutoArray { @@ -20,11 +25,6 @@ pub struct nsStyleAutoArray { pub mOtherElements: nsTArray, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum nsStyleAutoArray_WithSingleInitialElement { - WITH_SINGLE_INITIAL_ELEMENT = 0, -} impl Default for nsStyleAutoArray { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 3462f4c35d..1222b37491 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -67,3 +67,11 @@ impl Clone for WithOpaquePtr { impl Default for WithOpaquePtr { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_Opaque_instantiation() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( u32 ) )); + assert_eq!(::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( u32 ) + )); +} diff --git a/tests/expectations/tests/public-dtor.rs b/tests/expectations/tests/public-dtor.rs index bf8f1e58ce..53ab6db283 100644 --- a/tests/expectations/tests/public-dtor.rs +++ b/tests/expectations/tests/public-dtor.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN2cv6StringD1Ev"] + pub fn cv_String_String_destructor(this: *mut cv_String); +} #[repr(C)] #[derive(Debug, Default)] pub struct cv_String { @@ -16,10 +20,6 @@ fn bindgen_test_layout_cv_String() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( cv_String ) )); } -extern "C" { - #[link_name = "_ZN2cv6StringD1Ev"] - pub fn cv_String_String_destructor(this: *mut cv_String); -} impl cv_String { #[inline] pub unsafe fn destruct(&mut self) { cv_String_String_destructor(self) } diff --git a/tests/expectations/tests/ref_argument_array.rs b/tests/expectations/tests/ref_argument_array.rs index 251879186c..a841fdec68 100644 --- a/tests/expectations/tests/ref_argument_array.rs +++ b/tests/expectations/tests/ref_argument_array.rs @@ -5,6 +5,12 @@ pub const NSID_LENGTH: ::std::os::raw::c_uint = 10; +extern "C" { + #[link_name = "_ZN4nsID16ToProvidedStringERA10_c"] + pub fn nsID_ToProvidedString(this: *mut ::std::os::raw::c_void, + aDest: + *mut [::std::os::raw::c_char; 10usize]); +} #[repr(C)] pub struct nsID__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index 0c35be5680..4d31353049 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -35,3 +35,12 @@ impl Clone for Test { impl Default for Test { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_nsTArray_instantiation() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( nsTArray ) + )); + assert_eq!(::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + nsTArray ) )); +} diff --git a/tests/expectations/tests/replaces_double.rs b/tests/expectations/tests/replaces_double.rs index aab511ec05..4b5c280343 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -6,14 +6,24 @@ #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub ptr: Rooted_MaybeWrapped, +pub struct Wrapper_Wrapped { + pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } +impl Default for Wrapper_Wrapped { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +pub type Wrapper_Type = Wrapper_Wrapped; /** *
*/ pub type Rooted_MaybeWrapped = T; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Rooted { + pub ptr: Rooted_MaybeWrapped, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} impl Default for Rooted { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/size_t_template.rs b/tests/expectations/tests/size_t_template.rs index 937a8c7224..47e75edb6e 100644 --- a/tests/expectations/tests/size_t_template.rs +++ b/tests/expectations/tests/size_t_template.rs @@ -23,3 +23,12 @@ fn bindgen_test_layout_C() { impl Default for C { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_Array_instantiation() { + assert_eq!(::std::mem::size_of::<[u32; 3usize]>() , 12usize , concat ! ( + "Size of template specialization: " , stringify ! ( + [u32; 3usize] ) )); + assert_eq!(::std::mem::align_of::<[u32; 3usize]>() , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + [u32; 3usize] ) )); +} diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/tests/expectations/tests/struct_with_anon_struct.rs index 015e7d868e..2b96918cc6 100644 --- a/tests/expectations/tests/struct_with_anon_struct.rs +++ b/tests/expectations/tests/struct_with_anon_struct.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo { - pub bar: foo__bindgen_ty_1, -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { @@ -35,6 +30,11 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub bar: foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_anon_struct_array.rs b/tests/expectations/tests/struct_with_anon_struct_array.rs index 8934e8a6d6..d47f4ec9bc 100644 --- a/tests/expectations/tests/struct_with_anon_struct_array.rs +++ b/tests/expectations/tests/struct_with_anon_struct_array.rs @@ -4,12 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo { - pub bar: [foo__bindgen_ty_1; 2usize], - pub baz: [[[foo__bindgen_ty_2; 4usize]; 3usize]; 2usize], -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { @@ -62,6 +56,12 @@ fn bindgen_test_layout_foo__bindgen_ty_2() { impl Clone for foo__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub bar: [foo__bindgen_ty_1; 2usize], + pub baz: [[[foo__bindgen_ty_2; 4usize]; 3usize]; 2usize], +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 208usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/tests/expectations/tests/struct_with_anon_struct_pointer.rs index cba5b8a601..b258fcf6c7 100644 --- a/tests/expectations/tests/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/tests/struct_with_anon_struct_pointer.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Copy)] -pub struct foo { - pub bar: *mut foo__bindgen_ty_1, -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { @@ -35,6 +30,11 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Copy)] +pub struct foo { + pub bar: *mut foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index 5984ba6e59..8bfbf11d51 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -30,11 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub bar: foo__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, @@ -60,6 +55,11 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub bar: foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs index a7374bc444..fe26468d3c 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo { - pub __bindgen_anon_1: foo__bindgen_ty_1, -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { @@ -35,6 +30,11 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub __bindgen_anon_1: foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs index 09dbbb59f1..a08a9221bb 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -30,11 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub __bindgen_anon_1: foo__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, @@ -60,6 +55,11 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub __bindgen_anon_1: foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index 1a8e887d05..2d834bf890 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -30,20 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub a: ::std::os::raw::c_uint, - pub __bindgen_anon_1: foo__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo__bindgen_ty_1 { - pub b: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub __bindgen_anon_2: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1__bindgen_ty_1 { pub c1: ::std::os::raw::c_ushort, pub c2: ::std::os::raw::c_ushort, @@ -120,6 +106,14 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo__bindgen_ty_1 { + pub b: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub __bindgen_anon_2: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! @@ -135,6 +129,12 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub a: ::std::os::raw::c_uint, + pub __bindgen_anon_1: foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_struct.rs b/tests/expectations/tests/struct_with_struct.rs index 1ad359f37d..193e82dce1 100644 --- a/tests/expectations/tests/struct_with_struct.rs +++ b/tests/expectations/tests/struct_with_struct.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo { - pub bar: foo__bindgen_ty_1, -} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { @@ -35,6 +30,11 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub bar: foo__bindgen_ty_1, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/struct_with_typedef_template_arg.rs b/tests/expectations/tests/struct_with_typedef_template_arg.rs index 9066e037c7..379c7932e4 100644 --- a/tests/expectations/tests/struct_with_typedef_template_arg.rs +++ b/tests/expectations/tests/struct_with_typedef_template_arg.rs @@ -4,10 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type Proxy_foo = + ::std::option::Option; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Proxy { pub _address: u8, } -pub type Proxy_foo = - ::std::option::Option; diff --git a/tests/expectations/tests/template-fun-ty.rs b/tests/expectations/tests/template-fun-ty.rs index 30571266a1..1489cdcaac 100644 --- a/tests/expectations/tests/template-fun-ty.rs +++ b/tests/expectations/tests/template-fun-ty.rs @@ -4,23 +4,23 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type Foo_FunctionPtr = + ::std::option::Option T>; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } -pub type Foo_FunctionPtr = - ::std::option::Option T>; +pub type RefPtr_Proxy_member_function = + ::std::option::Option R>; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr { +pub struct RefPtr_Proxy { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr_Proxy { +pub struct RefPtr { pub _address: u8, } -pub type RefPtr_Proxy_member_function = - ::std::option::Option R>; pub type Returner = ::std::option::Option T>; diff --git a/tests/expectations/tests/template-param-usage-10.rs b/tests/expectations/tests/template-param-usage-10.rs index a01597c12f..4308a7b352 100644 --- a/tests/expectations/tests/template-param-usage-10.rs +++ b/tests/expectations/tests/template-param-usage-10.rs @@ -4,13 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DoublyIndirectUsage { - pub doubly_indirect: DoublyIndirectUsage_IndirectUsage, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, - pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, -} pub type DoublyIndirectUsage_Aliased = T; pub type DoublyIndirectUsage_Typedefed = U; #[repr(C)] @@ -24,6 +17,13 @@ pub struct DoublyIndirectUsage_IndirectUsage { impl Default for DoublyIndirectUsage_IndirectUsage { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct DoublyIndirectUsage { + pub doubly_indirect: DoublyIndirectUsage_IndirectUsage, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, + pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} impl Default for DoublyIndirectUsage { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/template-param-usage-2.rs b/tests/expectations/tests/template-param-usage-2.rs index d017976b05..bcd99b5816 100644 --- a/tests/expectations/tests/template-param-usage-2.rs +++ b/tests/expectations/tests/template-param-usage-2.rs @@ -4,12 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter { - pub t: T, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UsesTemplateParameter_AlsoUsesTemplateParameter { @@ -19,6 +13,12 @@ pub struct UsesTemplateParameter_AlsoUsesTemplateParameter { impl Default for UsesTemplateParameter_AlsoUsesTemplateParameter { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct UsesTemplateParameter { + pub t: T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} impl Default for UsesTemplateParameter { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/template-param-usage-3.rs b/tests/expectations/tests/template-param-usage-3.rs index 85a96d542c..e93043dedc 100644 --- a/tests/expectations/tests/template-param-usage-3.rs +++ b/tests/expectations/tests/template-param-usage-3.rs @@ -4,12 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter { - pub t: T, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { @@ -22,6 +16,12 @@ impl Default for UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct UsesTemplateParameter { + pub t: T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} impl Default for UsesTemplateParameter { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/template-param-usage-4.rs b/tests/expectations/tests/template-param-usage-4.rs index 5e9e004c42..99a65ff90f 100644 --- a/tests/expectations/tests/template-param-usage-4.rs +++ b/tests/expectations/tests/template-param-usage-4.rs @@ -4,17 +4,17 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct UsesTemplateParameter_DoesNotUseTemplateParameters { + pub x: ::std::os::raw::c_int, +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UsesTemplateParameter { pub t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct UsesTemplateParameter_DoesNotUseTemplateParameters { - pub x: ::std::os::raw::c_int, -} impl Default for UsesTemplateParameter { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/template-param-usage-5.rs b/tests/expectations/tests/template-param-usage-5.rs index 375a60dfd4..374e1f8ab6 100644 --- a/tests/expectations/tests/template-param-usage-5.rs +++ b/tests/expectations/tests/template-param-usage-5.rs @@ -4,13 +4,13 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type IndirectlyUsesTemplateParameter_Aliased = T; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct IndirectlyUsesTemplateParameter { pub aliased: IndirectlyUsesTemplateParameter_Aliased, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -pub type IndirectlyUsesTemplateParameter_Aliased = T; impl Default for IndirectlyUsesTemplateParameter { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/template-param-usage-6.rs b/tests/expectations/tests/template-param-usage-6.rs index f76e6326e6..34a8345006 100644 --- a/tests/expectations/tests/template-param-usage-6.rs +++ b/tests/expectations/tests/template-param-usage-6.rs @@ -4,9 +4,9 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type DoesNotUseTemplateParameter_ButAliasDoesUseIt = T; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct DoesNotUseTemplateParameter { pub x: ::std::os::raw::c_int, } -pub type DoesNotUseTemplateParameter_ButAliasDoesUseIt = T; diff --git a/tests/expectations/tests/template-param-usage-8.rs b/tests/expectations/tests/template-param-usage-8.rs index 9a0f428faa..c7a1443475 100644 --- a/tests/expectations/tests/template-param-usage-8.rs +++ b/tests/expectations/tests/template-param-usage-8.rs @@ -4,6 +4,8 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type IndirectUsage_Typedefed = T; +pub type IndirectUsage_Aliased = U; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct IndirectUsage { @@ -12,8 +14,6 @@ pub struct IndirectUsage { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -pub type IndirectUsage_Typedefed = T; -pub type IndirectUsage_Aliased = U; impl Default for IndirectUsage { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/template-param-usage-9.rs b/tests/expectations/tests/template-param-usage-9.rs index 88fea7254d..a8f5534fce 100644 --- a/tests/expectations/tests/template-param-usage-9.rs +++ b/tests/expectations/tests/template-param-usage-9.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct DoesNotUse { - pub _address: u8, -} pub type DoesNotUse_Aliased = T; pub type DoesNotUse_Typedefed = U; #[repr(C)] @@ -22,3 +17,8 @@ pub struct DoesNotUse_IndirectUsage { impl Default for DoesNotUse_IndirectUsage { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct DoesNotUse { + pub _address: u8, +} diff --git a/tests/expectations/tests/template-with-var.rs b/tests/expectations/tests/template-with-var.rs new file mode 100644 index 0000000000..0b0a8cb6b2 --- /dev/null +++ b/tests/expectations/tests/template-with-var.rs @@ -0,0 +1,11 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct TemplateWithVar { + pub _address: u8, +} diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 5eed8c47a9..5e6627db28 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -19,11 +19,6 @@ extern "C" { #[link_name = "_Z3bar3FooIiiE"] pub fn bar(foo: Foo<::std::os::raw::c_int>); } -#[repr(C)] -#[derive(Debug)] -pub struct D { - pub m_foo: D_MyFoo, -} pub type D_MyFoo = Foo<::std::os::raw::c_int>; #[repr(C)] #[derive(Debug)] @@ -35,6 +30,11 @@ pub struct D_U { impl Default for D_U { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug)] +pub struct D { + pub m_foo: D_MyFoo, +} impl Default for D { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } @@ -239,13 +239,8 @@ pub struct ReplacedWithoutDestructorFwd { impl Default for ReplacedWithoutDestructorFwd { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct TemplateWithVar { - pub _address: u8, -} #[test] -fn __bindgen_test_layout_Foo_instantiation_1() { +fn __bindgen_test_layout_Foo_instantiation() { assert_eq!(::std::mem::size_of::>() , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( @@ -256,7 +251,7 @@ fn __bindgen_test_layout_Foo_instantiation_1() { Foo<::std::os::raw::c_int> ) )); } #[test] -fn __bindgen_test_layout_Foo_instantiation_2() { +fn __bindgen_test_layout_Foo_instantiation_1() { assert_eq!(::std::mem::size_of::>() , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( @@ -267,7 +262,18 @@ fn __bindgen_test_layout_Foo_instantiation_2() { Foo<::std::os::raw::c_int> ) )); } #[test] -fn __bindgen_test_layout_Rooted_instantiation_3() { +fn __bindgen_test_layout_Rooted_instantiation() { + assert_eq!(::std::mem::size_of::>() , + 24usize , concat ! ( + "Size of template specialization: " , stringify ! ( + Rooted<*mut ::std::os::raw::c_void> ) )); + assert_eq!(::std::mem::align_of::>() , + 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + Rooted<*mut ::std::os::raw::c_void> ) )); +} +#[test] +fn __bindgen_test_layout_Rooted_instantiation_1() { assert_eq!(::std::mem::size_of::>() , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( @@ -278,7 +284,7 @@ fn __bindgen_test_layout_Rooted_instantiation_3() { Rooted<*mut ::std::os::raw::c_void> ) )); } #[test] -fn __bindgen_test_layout_WithDtor_instantiation_4() { +fn __bindgen_test_layout_WithDtor_instantiation() { assert_eq!(::std::mem::size_of::>() , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( @@ -288,3 +294,11 @@ fn __bindgen_test_layout_WithDtor_instantiation_4() { "Alignment of template specialization: " , stringify ! ( WithDtor<::std::os::raw::c_int> ) )); } +#[test] +fn __bindgen_test_layout_Opaque_instantiation() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( u32 ) )); + assert_eq!(::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( u32 ) + )); +} diff --git a/tests/expectations/tests/template_typedef_transitive_param.rs b/tests/expectations/tests/template_typedef_transitive_param.rs index 05604223a0..3f98985472 100644 --- a/tests/expectations/tests/template_typedef_transitive_param.rs +++ b/tests/expectations/tests/template_typedef_transitive_param.rs @@ -4,11 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Wrapper { - pub _address: u8, -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Wrapper_Wrapped { @@ -19,3 +14,8 @@ impl Default for Wrapper_Wrapped { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } pub type Wrapper_Type = Wrapper_Wrapped; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Wrapper { + pub _address: u8, +} diff --git a/tests/expectations/tests/template_typedefs.rs b/tests/expectations/tests/template_typedefs.rs index d18783ad96..3dcfce5c17 100644 --- a/tests/expectations/tests/template_typedefs.rs +++ b/tests/expectations/tests/template_typedefs.rs @@ -6,11 +6,6 @@ pub type foo = ::std::option::Option; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} pub type Foo_Char = T; pub type Foo_FooPtrTypedef = *mut Foo_Char; pub type Foo_nsCOMArrayEnumFunc = @@ -18,3 +13,8 @@ pub type Foo_nsCOMArrayEnumFunc = aData: *mut ::std::os::raw::c_void) -> bool>; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Foo { + pub _address: u8, +} diff --git a/tests/expectations/tests/templateref_opaque.rs b/tests/expectations/tests/templateref_opaque.rs index 5f6a7459f8..4940dc6e13 100644 --- a/tests/expectations/tests/templateref_opaque.rs +++ b/tests/expectations/tests/templateref_opaque.rs @@ -4,15 +4,15 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub type detail_PointerType_Type = *mut T; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct detail_PointerType { pub _address: u8, } -pub type detail_PointerType_Type = *mut T; +pub type UniquePtr_Pointer = detail_PointerType; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct UniquePtr { pub _address: u8, } -pub type UniquePtr_Pointer = detail_PointerType; diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index b5be5557f2..45b37ba583 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -90,17 +90,17 @@ impl Clone for mozilla_Position { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct mozilla_StyleShapeSource { - pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] pub struct mozilla_StyleShapeSource__bindgen_ty_1 { pub mPosition: __BindgenUnionField<*mut mozilla_Position>, pub mFragmentOrURL: __BindgenUnionField<*mut mozilla_FragmentOrURL>, pub bindgen_union_field: u64, } #[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct mozilla_StyleShapeSource { + pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, +} +#[repr(C)] #[derive(Debug, Copy)] pub struct Bar { pub mFoo: *mut nsFoo, @@ -123,3 +123,14 @@ impl Clone for Bar { impl Default for Bar { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[test] +fn __bindgen_test_layout_mozilla_StyleShapeSource_instantiation() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + mozilla_StyleShapeSource ) )); + assert_eq!(::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + mozilla_StyleShapeSource ) )); +} diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs index 429ec082af..b952708a59 100644 --- a/tests/expectations/tests/union_dtor.rs +++ b/tests/expectations/tests/union_dtor.rs @@ -28,6 +28,10 @@ impl ::std::fmt::Debug for __BindgenUnionField { fmt.write_str("__BindgenUnionField") } } +extern "C" { + #[link_name = "_ZN13UnionWithDtorD1Ev"] + pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); +} #[repr(C)] #[derive(Debug, Default)] pub struct UnionWithDtor { @@ -52,10 +56,6 @@ fn bindgen_test_layout_UnionWithDtor() { "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" , stringify ! ( mBar ) )); } -extern "C" { - #[link_name = "_ZN13UnionWithDtorD1Ev"] - pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); -} impl UnionWithDtor { #[inline] pub unsafe fn destruct(&mut self) { diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs index 7f30e7b49f..5fb0ff3e2e 100644 --- a/tests/expectations/tests/union_template.rs +++ b/tests/expectations/tests/union_template.rs @@ -30,13 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -pub struct NastyStruct { - pub mIsSome: bool, - pub mStorage: NastyStruct__bindgen_ty_1, - pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] pub struct NastyStruct__bindgen_ty_1 { pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>, @@ -51,6 +44,13 @@ pub struct NastyStruct__bindgen_ty_2 { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] +pub struct NastyStruct { + pub mIsSome: bool, + pub mStorage: NastyStruct__bindgen_ty_1, + pub __bindgen_anon_1: NastyStruct__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] pub struct Whatever { pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>, pub mInt: __BindgenUnionField<::std::os::raw::c_int>, diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index f0bb68d577..ee3709d8e3 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -30,12 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub bar: __BindgenUnionField, - pub bindgen_union_field: [u32; 2usize], -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { pub a: ::std::os::raw::c_uint, pub b: ::std::os::raw::c_uint, @@ -60,6 +54,12 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub bar: __BindgenUnionField, + pub bindgen_union_field: [u32; 2usize], +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index a60d111561..dd20f92a9e 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -30,13 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { pub _bitfield_1: u32, pub __bindgen_align: [u32; 0usize], @@ -113,6 +106,13 @@ impl foo__bindgen_ty_1 { ((c as u32 as u32) << 7usize) & (4294967168u64 as u32)) } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs index 668160a772..8e670842d3 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -30,12 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub bar: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { pub a: __BindgenUnionField<::std::os::raw::c_uint>, pub b: __BindgenUnionField<::std::os::raw::c_ushort>, @@ -61,6 +55,12 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub bar: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index 98524422d1..0f694a7b4a 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -30,13 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct pixel { - pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct pixel__bindgen_ty_1 { pub r: ::std::os::raw::c_uchar, pub g: ::std::os::raw::c_uchar, @@ -74,6 +67,13 @@ fn bindgen_test_layout_pixel__bindgen_ty_1() { impl Clone for pixel__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct pixel { + pub rgba: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_pixel() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs index 1a6f5f4535..61c71d0c3a 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -30,13 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1 { pub b: __BindgenUnionField<::std::os::raw::c_ushort>, pub c: __BindgenUnionField<::std::os::raw::c_uchar>, @@ -62,6 +55,13 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs index 7e32f0c0d9..c0886b0722 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -30,19 +30,6 @@ impl ::std::fmt::Debug for __BindgenUnionField { } #[repr(C)] #[derive(Debug, Default, Copy)] -pub struct foo { - pub a: __BindgenUnionField<::std::os::raw::c_uint>, - pub __bindgen_anon_1: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo__bindgen_ty_1 { - pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, - pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] pub struct foo__bindgen_ty_1__bindgen_ty_1 { pub b1: __BindgenUnionField<::std::os::raw::c_ushort>, pub b2: __BindgenUnionField<::std::os::raw::c_ushort>, @@ -107,6 +94,12 @@ fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo__bindgen_ty_1 { + pub __bindgen_anon_1: foo__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: foo__bindgen_ty_1__bindgen_ty_2, +} #[test] fn bindgen_test_layout_foo__bindgen_ty_1() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! @@ -117,6 +110,13 @@ fn bindgen_test_layout_foo__bindgen_ty_1() { impl Clone for foo__bindgen_ty_1 { fn clone(&self) -> Self { *self } } +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct foo { + pub a: __BindgenUnionField<::std::os::raw::c_uint>, + pub __bindgen_anon_1: __BindgenUnionField, + pub bindgen_union_field: u32, +} #[test] fn bindgen_test_layout_foo() { assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( diff --git a/tests/expectations/tests/var-tracing.rs b/tests/expectations/tests/var-tracing.rs index 3eb93b04dd..4445cfe3f2 100644 --- a/tests/expectations/tests/var-tracing.rs +++ b/tests/expectations/tests/var-tracing.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN3BarC1Ei"] + pub fn Bar_Bar(this: *mut Bar, baz: ::std::os::raw::c_int); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Bar { @@ -21,10 +25,6 @@ fn bindgen_test_layout_Bar() { "Alignment of field: " , stringify ! ( Bar ) , "::" , stringify ! ( m_baz ) )); } -extern "C" { - #[link_name = "_ZN3BarC1Ei"] - pub fn Bar_Bar(this: *mut Bar, baz: ::std::os::raw::c_int); -} impl Clone for Bar { fn clone(&self) -> Self { *self } } @@ -36,15 +36,15 @@ impl Bar { __bindgen_tmp } } +extern "C" { + #[link_name = "_ZN3Baz3FOOE"] + pub static mut Baz_FOO: [Bar; 0usize]; +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Baz { pub _address: u8, } -extern "C" { - #[link_name = "_ZN3Baz3FOOE"] - pub static mut Baz_FOO: [Bar; 0usize]; -} #[test] fn bindgen_test_layout_Baz() { assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( diff --git a/tests/expectations/tests/variadic-method.rs b/tests/expectations/tests/variadic-method.rs index a68dd1c9cb..a391c31e43 100644 --- a/tests/expectations/tests/variadic-method.rs +++ b/tests/expectations/tests/variadic-method.rs @@ -8,6 +8,10 @@ extern "C" { #[link_name = "_Z3fooPKcz"] pub fn foo(fmt: *const ::std::os::raw::c_char, ...); } +extern "C" { + #[link_name = "_ZN3Bar3fooEPKcz"] + pub fn Bar_foo(this: *mut Bar, fmt: *const ::std::os::raw::c_char, ...); +} #[repr(C)] #[derive(Debug, Default, Copy)] pub struct Bar { @@ -20,10 +24,6 @@ fn bindgen_test_layout_Bar() { assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( "Alignment of " , stringify ! ( Bar ) )); } -extern "C" { - #[link_name = "_ZN3Bar3fooEPKcz"] - pub fn Bar_foo(this: *mut Bar, fmt: *const ::std::os::raw::c_char, ...); -} impl Clone for Bar { fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/virtual_dtor.rs b/tests/expectations/tests/virtual_dtor.rs index 9a6ee13ee9..1fa5e53378 100644 --- a/tests/expectations/tests/virtual_dtor.rs +++ b/tests/expectations/tests/virtual_dtor.rs @@ -4,6 +4,10 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +extern "C" { + #[link_name = "_ZN7nsSlotsD0Ev"] + pub fn nsSlots_nsSlots_destructor(this: *mut nsSlots); +} #[repr(C)] pub struct nsSlots__bindgen_vtable(::std::os::raw::c_void); #[repr(C)] diff --git a/tests/expectations/tests/whitelist_basic.rs b/tests/expectations/tests/whitelist_basic.rs index af151e3e4d..880b020aba 100644 --- a/tests/expectations/tests/whitelist_basic.rs +++ b/tests/expectations/tests/whitelist_basic.rs @@ -4,13 +4,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct WhitelistMe { - pub foo: ::std::os::raw::c_int, - pub bar: WhitelistMe_Inner, - pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct WhitelistMe_Inner { @@ -20,6 +13,13 @@ pub struct WhitelistMe_Inner { impl Default for WhitelistMe_Inner { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct WhitelistMe { + pub foo: ::std::os::raw::c_int, + pub bar: WhitelistMe_Inner, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} impl Default for WhitelistMe { fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/headers/issue-769-bad-instantiation-test.hpp b/tests/headers/issue-769-bad-instantiation-test.hpp new file mode 100644 index 0000000000..1be89a6628 --- /dev/null +++ b/tests/headers/issue-769-bad-instantiation-test.hpp @@ -0,0 +1,11 @@ +// bindgen-flags: --enable-cxx-namespaces --whitelist-type Rooted + +template +class Rooted { + T member; +}; + +class AutoValueVector : Rooted { + using Alias = int; + using RootedAlias = Rooted; +}; diff --git a/tests/headers/template-with-var.hpp b/tests/headers/template-with-var.hpp new file mode 100644 index 0000000000..88f60d211e --- /dev/null +++ b/tests/headers/template-with-var.hpp @@ -0,0 +1,7 @@ +template +class TemplateWithVar { + // We shouldn't generate bindings for this because there are potentially + // many instantiations of this variable, but we can't know which ones exist + // or don't. + static T var = 0; +}; diff --git a/tests/headers/template.hpp b/tests/headers/template.hpp index c13643c398..29a0792bb9 100644 --- a/tests/headers/template.hpp +++ b/tests/headers/template.hpp @@ -137,8 +137,3 @@ class ReplacedWithDestructorDeclaredAfter { T* buff; ~ReplacedWithDestructorDeclaredAfter() {}; }; - -template -class TemplateWithVar { - static T var = 0; -};