From ab6c81a36c8904efa518716275189afde165535b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 6 Apr 2017 17:27:13 -0700 Subject: [PATCH 1/7] Provide better diagnostics for assertions in the template analysis This replaces various `unwrap` calls with `expect` calls that have better diagnostic messages if/when they fail. --- src/ir/named.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ir/named.rs b/src/ir/named.rs index 7cae195bf0..598041ea0d 100644 --- a/src/ir/named.rs +++ b/src/ir/named.rs @@ -377,8 +377,13 @@ impl<'ctx, 'gen> MonotoneFramework for UsedTemplateParameters<'ctx, 'gen> { // on other hash map entries. We *must* put it back into the hash map at // the end of this method. This allows us to side-step HashMap's lack of // an analog to slice::split_at_mut. - let mut used_by_this_id = - self.used.get_mut(&id).unwrap().take().unwrap(); + let mut used_by_this_id = self.used + .get_mut(&id) + .expect("Should have a set of used template params for every item \ + id") + .take() + .expect("Should maintain the invariant that all used template param \ + sets are `Some` upon entry of `constrain`"); let original_len = used_by_this_id.len(); @@ -415,27 +420,31 @@ impl<'ctx, 'gen> MonotoneFramework for UsedTemplateParameters<'ctx, 'gen> { // Otherwise, add the union of each of its referent item's template // parameter usage. _ => { - item.trace(self.ctx, - &mut |sub_id, edge_kind| { + item.trace(self.ctx, &mut |sub_id, edge_kind| { if sub_id == id || !Self::consider_edge(edge_kind) { return; } let used_by_sub_id = self.used[&sub_id] .as_ref() - .unwrap() + .expect("Because sub_id != id, and all used template \ + param sets other than id's are `Some`, \ + sub_id's used template param set should be \ + `Some`") .iter() .cloned(); used_by_this_id.extend(used_by_sub_id); - }, - &()); + }, &()); } } let new_len = used_by_this_id.len(); - assert!(new_len >= original_len); + assert!(new_len >= original_len, + "This is the property that ensures this function is monotone -- \ + if it doesn't hold, the analysis might never terminate!"); // Put the set back in the hash map and restore our invariant. + debug_assert!(self.used[&id].is_none()); self.used.insert(id, Some(used_by_this_id)); debug_assert!(self.used.values().all(|v| v.is_some())); From 26c48b3d6d34c28926f53875720b8d1ac4423296 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 6 Apr 2017 14:38:05 -0700 Subject: [PATCH 2/7] Clean up testing-only cargo features This commit ensures that all of the cargo features we have that only exist for CI/testing purposes, and aren't for external consumption, have a "testing_only_" prefix. --- CONTRIBUTING.md | 8 ++++---- Cargo.toml | 10 ++++++---- ci/assert-docs.sh | 2 +- ci/test.sh | 4 ++-- src/ir/context.rs | 7 +++++-- src/lib.rs | 8 ++++---- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0aad4f2cee..1d78497e6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,12 +65,12 @@ $ export LD_LIBRARY_PATH=path/to/clang-3.9/lib # for Linux $ export DYLD_LIBRARY_PATH=path/to/clang-3.9/lib # for macOS ``` -Additionally, you may want to build and test with the `docs_` feature to ensure -that you aren't forgetting to document types and functions. CI will catch it if -you forget, but the turn around will be a lot slower ;) +Additionally, you may want to build and test with the `testing_only_docs` +feature to ensure that you aren't forgetting to document types and functions. CI +will catch it if you forget, but the turn around will be a lot slower ;) ``` -$ cargo build --features docs_ +$ cargo build --features testing_only_docs ``` ## Testing diff --git a/Cargo.toml b/Cargo.toml index 868c147c52..df5124d43b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,10 +65,12 @@ features = ["with-syntex"] version = "0.29" [features] -assert_no_dangling_items = [] default = ["logging"] -testing_only_llvm_stable = [] logging = ["env_logger", "log"] static = [] -# This feature only exists for CI -- don't use it! -docs_ = [] + +# These features only exist for CI testing -- don't use them if you're not hacking +# on bindgen! +testing_only_assert_no_dangling_items = [] +testing_only_docs = [] +testing_only_llvm_stable = [] diff --git a/ci/assert-docs.sh b/ci/assert-docs.sh index aa4b90ac04..d5757403ec 100755 --- a/ci/assert-docs.sh +++ b/ci/assert-docs.sh @@ -3,4 +3,4 @@ set -xeu cd "$(dirname "$0")/.." -cargo build --features "$BINDGEN_FEATURES docs_" +cargo build --features "$BINDGEN_FEATURES testing_only_docs" diff --git a/ci/test.sh b/ci/test.sh index 9bfccfd8f1..ed31db6c8a 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -6,10 +6,10 @@ cd "$(dirname "$0")/.." # Regenerate the test headers' bindings in debug and release modes, and assert # that we always get the expected generated bindings. -cargo test --features "$BINDGEN_FEATURES assert_no_dangling_items" +cargo test --features "$BINDGEN_FEATURES testing_only_assert_no_dangling_items" ./ci/assert-no-diff.sh -cargo test --release --features "$BINDGEN_FEATURES assert_no_dangling_items" +cargo test --release --features "$BINDGEN_FEATURES testing_only_assert_no_dangling_items" ./ci/assert-no-diff.sh # Now test the expectations' size and alignment tests. diff --git a/src/ir/context.rs b/src/ir/context.rs index 32ee5bd04a..9ff5a3305e 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -584,9 +584,12 @@ impl<'ctx> BindgenContext<'ctx> { ret } - /// This function trying to find any dangling references inside of `items` + /// When the `testing_only_assert_no_dangling_items` feature is enabled, + /// this function walks the IR graph and asserts that we do not have any + /// edges referencing an ItemId for which we do not have an associated IR + /// item. fn assert_no_dangling_references(&self) { - if cfg!(feature = "assert_no_dangling_items") { + if cfg!(feature = "testing_only_assert_no_dangling_items") { for _ in self.assert_no_dangling_item_traversal() { // The iterator's next method does the asserting for us. } diff --git a/src/lib.rs b/src/lib.rs index e6a66dfc42..6637304ba7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,15 +38,15 @@ extern crate log; mod log_stubs; // A macro to declare an internal module for which we *must* provide -// documentation for. If we are building with the "docs_" feature, then the -// module is declared public, and our `#![deny(missing_docs)]` pragma applies to -// it. This feature is used in CI, so we won't let anything slip by +// documentation for. If we are building with the "testing_only_docs" feature, +// then the module is declared public, and our `#![deny(missing_docs)]` pragma +// applies to it. This feature is used in CI, so we won't let anything slip by // undocumented. Normal builds, however, will leave the module private, so that // we don't expose internals to library consumers. macro_rules! doc_mod { ($m:ident, $doc_mod_name:ident) => { cfg_if! { - if #[cfg(feature = "docs_")] { + if #[cfg(feature = "testing_only_docs")] { pub mod $doc_mod_name { //! Autogenerated documentation module. pub use super::$m::*; From 42153ce8ab00b21a9c693ee2563c751ae1db21c3 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 6 Apr 2017 15:21:33 -0700 Subject: [PATCH 3/7] Define extra assertion macros This commit defines a new set of assertion macros that are only checked in testing/CI when the `testing_only_extra_assertions` feature is enabled. This makes it so that *users* of bindgen that happen to be making a debug build don't enable all these extra and expensive assertions. Additionally, this removes the `testing_only_assert_no_dangling_items` feature, and runs the assertions that were previously gated on that feature when the new `testing_only_extra_assertions` feature is enabled. --- Cargo.toml | 2 +- ci/test.sh | 7 +++++-- src/codegen/mod.rs | 2 +- src/extra_assertions.rs | 30 ++++++++++++++++++++++++++++++ src/ir/context.rs | 9 ++++----- src/ir/item.rs | 6 +++--- src/ir/named.rs | 4 ++-- src/lib.rs | 3 +++ 8 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 src/extra_assertions.rs diff --git a/Cargo.toml b/Cargo.toml index df5124d43b..62a95d5e1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,6 @@ static = [] # These features only exist for CI testing -- don't use them if you're not hacking # on bindgen! -testing_only_assert_no_dangling_items = [] testing_only_docs = [] +testing_only_extra_assertions = [] testing_only_llvm_stable = [] diff --git a/ci/test.sh b/ci/test.sh index ed31db6c8a..f14b7b9687 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -6,10 +6,13 @@ cd "$(dirname "$0")/.." # Regenerate the test headers' bindings in debug and release modes, and assert # that we always get the expected generated bindings. -cargo test --features "$BINDGEN_FEATURES testing_only_assert_no_dangling_items" +cargo test --features "$BINDGEN_FEATURES" +./ci/assert-no-diff.sh + +cargo test --features "$BINDGEN_FEATURES testing_only_extra_assertions" ./ci/assert-no-diff.sh -cargo test --release --features "$BINDGEN_FEATURES testing_only_assert_no_dangling_items" +cargo test --release --features "$BINDGEN_FEATURES testing_only_extra_assertions" ./ci/assert-no-diff.sh # Now test the expectations' size and alignment tests. diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index ee4a9d4e78..5a89e5c864 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -2642,7 +2642,7 @@ impl TryToRustTy for TemplateInstantiation { // This can happen if we generated an opaque type for a partial // template specialization, and we've hit an instantiation of // that partial specialization. - debug_assert!(ctx.resolve_type_through_type_refs(decl) + extra_assert!(ctx.resolve_type_through_type_refs(decl) .is_opaque()); return Err(error::Error::InstantiationOfOpaqueType); } diff --git a/src/extra_assertions.rs b/src/extra_assertions.rs new file mode 100644 index 0000000000..b89c718a48 --- /dev/null +++ b/src/extra_assertions.rs @@ -0,0 +1,30 @@ +//! Macros for defining extra assertions that should only be checked in testing +//! and/or CI when the `testing_only_extra_assertions` feature is enabled. + +#[macro_export] +macro_rules! extra_assert { + ( $cond:expr ) => { + if cfg!(feature = "testing_only_extra_assertions") { + assert!($cond); + } + }; + ( $cond:expr , $( $arg:tt )+ ) => { + if cfg!(feature = "testing_only_extra_assertions") { + assert!($cond, $( $arg )* ) + } + }; +} + +#[macro_export] +macro_rules! extra_assert_eq { + ( $lhs:expr , $rhs:expr ) => { + if cfg!(feature = "testing_only_extra_assertions") { + assert_eq!($lhs, $rhs); + } + }; + ( $lhs:expr , $rhs:expr , $( $arg:tt )+ ) => { + if cfg!(feature = "testing_only_extra_assertions") { + assert!($lhs, $rhs, $( $arg )* ); + } + }; +} diff --git a/src/ir/context.rs b/src/ir/context.rs index 9ff5a3305e..9b9ad8bd29 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -584,12 +584,11 @@ impl<'ctx> BindgenContext<'ctx> { ret } - /// When the `testing_only_assert_no_dangling_items` feature is enabled, - /// this function walks the IR graph and asserts that we do not have any - /// edges referencing an ItemId for which we do not have an associated IR - /// item. + /// When the `testing_only_extra_assertions` feature is enabled, this + /// function walks the IR graph and asserts that we do not have any edges + /// referencing an ItemId for which we do not have an associated IR item. fn assert_no_dangling_references(&self) { - if cfg!(feature = "testing_only_assert_no_dangling_items") { + if cfg!(feature = "testing_only_extra_assertions") { for _ in self.assert_no_dangling_item_traversal() { // The iterator's next method does the asserting for us. } diff --git a/src/ir/item.rs b/src/ir/item.rs index 5477dee9dd..5e806de97c 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -70,7 +70,7 @@ pub trait ItemAncestors { } cfg_if! { - if #[cfg(debug_assertions)] { + if #[cfg(testing_only_extra_assertions)] { type DebugOnlyItemSet = ItemSet; } else { struct DebugOnlyItemSet; @@ -123,7 +123,7 @@ impl<'a, 'b> Iterator for ItemAncestorsIter<'a, 'b> } else { self.item = item.parent_id(); - debug_assert!(!self.seen.contains(&item.id())); + extra_assert!(!self.seen.contains(&item.id())); self.seen.insert(item.id()); Some(item.id()) @@ -614,7 +614,7 @@ impl Item { let mut item = self; loop { - debug_assert!(!targets_seen.contains(&item.id())); + extra_assert!(!targets_seen.contains(&item.id())); targets_seen.insert(item.id()); if self.annotations().use_instead_of().is_some() { diff --git a/src/ir/named.rs b/src/ir/named.rs index 598041ea0d..67b369155a 100644 --- a/src/ir/named.rs +++ b/src/ir/named.rs @@ -371,7 +371,7 @@ impl<'ctx, 'gen> MonotoneFramework for UsedTemplateParameters<'ctx, 'gen> { fn constrain(&mut self, id: ItemId) -> bool { // Invariant: all hash map entries' values are `Some` upon entering and // exiting this method. - debug_assert!(self.used.values().all(|v| v.is_some())); + extra_assert!(self.used.values().all(|v| v.is_some())); // Take the set for this id out of the hash map while we mutate it based // on other hash map entries. We *must* put it back into the hash map at @@ -446,7 +446,7 @@ impl<'ctx, 'gen> MonotoneFramework for UsedTemplateParameters<'ctx, 'gen> { // Put the set back in the hash map and restore our invariant. debug_assert!(self.used[&id].is_none()); self.used.insert(id, Some(used_by_this_id)); - debug_assert!(self.used.values().all(|v| v.is_some())); + extra_assert!(self.used.values().all(|v| v.is_some())); new_len != original_len } diff --git a/src/lib.rs b/src/lib.rs index 6637304ba7..44cf91938a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,9 @@ extern crate log; #[macro_use] mod log_stubs; +#[macro_use] +mod extra_assertions; + // A macro to declare an internal module for which we *must* provide // documentation for. If we are building with the "testing_only_docs" feature, // then the module is declared public, and our `#![deny(missing_docs)]` pragma From 30a0b9487e9e80a6584bd59e89fc087e820873ca Mon Sep 17 00:00:00 2001 From: Dominik Boehi Date: Sat, 8 Apr 2017 00:14:38 +0200 Subject: [PATCH 4/7] Omit accessor functions for large bitfields --- src/codegen/mod.rs | 3 +- tests/expectations/tests/bitfield-large.rs | 32 ++++++++++++++++++++++ tests/headers/bitfield-large.hpp | 9 ++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/expectations/tests/bitfield-large.rs create mode 100644 tests/headers/bitfield-large.hpp diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 5a89e5c864..6dadd6f7ac 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -924,8 +924,7 @@ fn flush_bitfields<'a, I>(ctx: &BindgenContext, 4 => quote_ty!(ctx.ext_cx(), u32), 2 => quote_ty!(ctx.ext_cx(), u16), 1 => quote_ty!(ctx.ext_cx(), u8), - _ => panic!("physical field containing bitfields should be sized \ - 8, 4, 2, or 1 bytes") + _ => return field }; let bitfield_int_ty = BlobTyBuilder::new(bitfield_layout).build(); diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs new file mode 100644 index 0000000000..d4fe96948a --- /dev/null +++ b/tests/expectations/tests/bitfield-large.rs @@ -0,0 +1,32 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct HasBigBitfield { + pub _bitfield_1: [u8; 16usize], +} +#[test] +fn bindgen_test_layout_HasBigBitfield() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( HasBigBitfield ) )); +} +impl Clone for HasBigBitfield { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct HasTwoBigBitfields { + pub _bitfield_1: [u8; 16usize], +} +#[test] +fn bindgen_test_layout_HasTwoBigBitfields() { + assert_eq!(::std::mem::size_of::() , 16usize , concat + ! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) )); +} +impl Clone for HasTwoBigBitfields { + fn clone(&self) -> Self { *self } +} diff --git a/tests/headers/bitfield-large.hpp b/tests/headers/bitfield-large.hpp new file mode 100644 index 0000000000..2e34927929 --- /dev/null +++ b/tests/headers/bitfield-large.hpp @@ -0,0 +1,9 @@ +struct HasBigBitfield { + __int128 x : 128; +}; + + +struct HasTwoBigBitfields { + __int128 x : 80; + __int128 y : 48; +}; From a25dc4bea5374d27510efabe9828a3f86e2f24e7 Mon Sep 17 00:00:00 2001 From: Dominik Boehi Date: Sat, 8 Apr 2017 00:25:11 +0200 Subject: [PATCH 5/7] Move check for field size outside loop --- src/codegen/mod.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 6dadd6f7ac..579e9de12e 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -913,19 +913,20 @@ fn flush_bitfields<'a, I>(ctx: &BindgenContext, .pub_() .build_ty(field_ty.clone()); + let field_int_ty = match field_layout.size { + 8 => quote_ty!(ctx.ext_cx(), u64), + 4 => quote_ty!(ctx.ext_cx(), u32), + 2 => quote_ty!(ctx.ext_cx(), u16), + 1 => quote_ty!(ctx.ext_cx(), u8), + _ => return field + }; + for (name, offset, width, bitfield_ty, bitfield_layout) in bitfields { let prefix = ctx.trait_prefix(); let getter_name = bitfield_getter_name(ctx, parent, name); let setter_name = bitfield_setter_name(ctx, parent, name); let field_ident = ctx.ext_cx().ident_of(field_name); - let field_int_ty = match field_layout.size { - 8 => quote_ty!(ctx.ext_cx(), u64), - 4 => quote_ty!(ctx.ext_cx(), u32), - 2 => quote_ty!(ctx.ext_cx(), u16), - 1 => quote_ty!(ctx.ext_cx(), u8), - _ => return field - }; let bitfield_int_ty = BlobTyBuilder::new(bitfield_layout).build(); let mask: usize = ((1usize << width) - 1usize) << offset; From 598ab2ee9cf674f7f2f89e76b2e321f7e618622a Mon Sep 17 00:00:00 2001 From: framlog Date: Sun, 12 Mar 2017 18:20:40 +0800 Subject: [PATCH 6/7] make allowing non naming conventions everywhere --- src/codegen/mod.rs | 30 +- src/ir/context.rs | 31 +- src/lib.rs | 7 +- tests/expectations/tests/16-byte-alignment.rs | 467 +-- .../expectations/tests/381-decltype-alias.rs | 21 +- tests/expectations/tests/accessors.rs | 544 ++-- tests/expectations/tests/annotation_hide.rs | 79 +- tests/expectations/tests/anon_enum.rs | 73 +- tests/expectations/tests/anon_enum_trait.rs | 91 +- .../expectations/tests/anon_enum_whitelist.rs | 21 +- .../tests/anon_struct_in_union.rs | 184 +- tests/expectations/tests/anon_union.rs | 179 +- .../tests/anonymous-template-types.rs | 61 +- tests/expectations/tests/arg_keyword.rs | 17 +- tests/expectations/tests/auto.rs | 57 +- .../bad-namespace-parenthood-inheritance.rs | 33 +- tests/expectations/tests/base-to-derived.rs | 37 +- .../expectations/tests/bitfield-enum-basic.rs | 153 +- tests/expectations/tests/bitfield-large.rs | 60 +- .../tests/bitfield-method-same-name.rs | 119 +- tests/expectations/tests/bitfield_align.rs | 1036 +++---- .../tests/bitfield_method_mangling.rs | 114 +- tests/expectations/tests/blocks.rs | 15 +- tests/expectations/tests/builtin-template.rs | 13 +- tests/expectations/tests/c-empty-layout.rs | 35 +- tests/expectations/tests/call-conv-field.rs | 80 +- .../canonical_path_without_namespacing.rs | 45 +- tests/expectations/tests/char.rs | 185 +- tests/expectations/tests/class.rs | 596 ++-- tests/expectations/tests/class_nested.rs | 253 +- tests/expectations/tests/class_no_members.rs | 116 +- tests/expectations/tests/class_static.rs | 64 +- .../expectations/tests/class_static_const.rs | 43 +- tests/expectations/tests/class_use_as.rs | 89 +- tests/expectations/tests/class_with_dtor.rs | 87 +- .../tests/class_with_inner_struct.rs | 653 ++-- .../expectations/tests/class_with_typedef.rs | 211 +- tests/expectations/tests/complex.rs | 191 +- tests/expectations/tests/complex_global.rs | 43 +- .../expectations/tests/const_array_fn_arg.rs | 15 +- tests/expectations/tests/const_bool.rs | 45 +- .../expectations/tests/const_enum_unnamed.rs | 55 +- tests/expectations/tests/const_ptr.rs | 15 +- tests/expectations/tests/const_resolved_ty.rs | 15 +- tests/expectations/tests/const_tparam.rs | 25 +- tests/expectations/tests/constant-evaluate.rs | 37 +- .../tests/constant-non-specialized-tp.rs | 37 +- .../expectations/tests/constify-all-enums.rs | 61 +- tests/expectations/tests/constify-enum.rs | 35 +- tests/expectations/tests/constructor-tp.rs | 69 +- tests/expectations/tests/constructors.rs | 132 +- tests/expectations/tests/convert-floats.rs | 125 +- tests/expectations/tests/cpp-empty-layout.rs | 37 +- tests/expectations/tests/crtp.rs | 139 +- tests/expectations/tests/dash_language.rs | 19 +- .../tests/decl_extern_int_twice.rs | 17 +- tests/expectations/tests/decl_ptr_to_array.rs | 17 +- .../tests/default-template-parameter.rs | 55 +- tests/expectations/tests/derive-fn-ptr.rs | 103 +- .../expectations/tests/disable-namespacing.rs | 13 +- .../duplicated-namespaces-definitions.rs | 4 - .../tests/duplicated-namespaces.rs | 4 - .../tests/duplicated_constants_in_ns.rs | 4 - tests/expectations/tests/elaborated.rs | 19 +- .../tests/empty_template_param_name.rs | 21 +- tests/expectations/tests/enum.rs | 23 +- tests/expectations/tests/enum_alias.rs | 17 +- .../tests/enum_and_vtable_mangling.rs | 68 +- tests/expectations/tests/enum_dupe.rs | 19 +- .../expectations/tests/enum_explicit_type.rs | 45 +- .../tests/enum_in_template_with_typedef.rs | 29 +- tests/expectations/tests/enum_negative.rs | 17 +- tests/expectations/tests/enum_packed.rs | 27 +- .../tests/eval-variadic-template-parameter.rs | 19 +- tests/expectations/tests/extern.rs | 17 +- tests/expectations/tests/float128.rs | 4 - .../tests/forward-declaration-autoptr.rs | 75 +- tests/expectations/tests/forward-enum-decl.rs | 17 +- .../forward-inherit-struct-with-fields.rs | 41 +- .../tests/forward-inherit-struct.rs | 33 +- .../tests/forward_declared_complex_types.rs | 125 +- .../tests/forward_declared_struct.rs | 85 +- tests/expectations/tests/func_proto.rs | 17 +- tests/expectations/tests/func_ptr.rs | 25 +- .../expectations/tests/func_ptr_in_struct.rs | 65 +- .../expectations/tests/func_with_array_arg.rs | 15 +- .../tests/func_with_func_ptr_arg.rs | 15 +- .../tests/gen-constructors-neg.rs | 37 +- tests/expectations/tests/gen-constructors.rs | 59 +- .../expectations/tests/gen-destructors-neg.rs | 41 +- tests/expectations/tests/gen-destructors.rs | 57 +- tests/expectations/tests/generate-inline.rs | 61 +- tests/expectations/tests/in_class_typedef.rs | 33 +- tests/expectations/tests/infinite-macro.rs | 15 +- .../expectations/tests/inherit-namespaced.rs | 33 +- tests/expectations/tests/inherit_named.rs | 33 +- tests/expectations/tests/inherit_typedef.rs | 69 +- tests/expectations/tests/inline-function.rs | 10 +- tests/expectations/tests/inline_namespace.rs | 4 - .../tests/inline_namespace_conservative.rs | 4 - .../tests/inline_namespace_whitelist.rs | 4 - tests/expectations/tests/inner_const.rs | 63 +- .../expectations/tests/inner_template_self.rs | 71 +- tests/expectations/tests/int128_t.rs | 4 - tests/expectations/tests/issue-358.rs | 39 +- tests/expectations/tests/issue-372.rs | 4 - tests/expectations/tests/issue-410.rs | 4 - tests/expectations/tests/issue-446.rs | 39 +- tests/expectations/tests/issue-447.rs | 4 - tests/expectations/tests/issue-493.rs | 219 +- .../tests/issue-544-stylo-creduce-2.rs | 25 +- .../tests/issue-544-stylo-creduce.rs | 19 +- ...ate-params-causing-layout-test-failures.rs | 80 +- .../tests/issue-573-layout-test-failures.rs | 55 +- .../issue-574-assertion-failure-in-codegen.rs | 71 +- tests/expectations/tests/issue_311.rs | 4 - tests/expectations/tests/issue_315.rs | 15 +- .../expectations/tests/jsval_layout_opaque.rs | 594 ++-- tests/expectations/tests/keywords.rs | 399 +-- tests/expectations/tests/layout.rs | 97 +- tests/expectations/tests/layout_align.rs | 269 +- tests/expectations/tests/layout_arp.rs | 255 +- tests/expectations/tests/layout_array.rs | 463 +-- .../tests/layout_array_too_long.rs | 405 +-- .../tests/layout_cmdline_token.rs | 355 +-- tests/expectations/tests/layout_eth_conf.rs | 2664 +++++++++-------- tests/expectations/tests/layout_kni_mbuf.rs | 223 +- .../tests/layout_large_align_field.rs | 829 ++--- tests/expectations/tests/layout_mbuf.rs | 1599 +++++----- tests/expectations/tests/macro-expr-basic.rs | 27 +- tests/expectations/tests/macro-redef.rs | 17 +- tests/expectations/tests/macro_const.rs | 23 +- .../tests/maddness-is-avoidable.rs | 27 +- tests/expectations/tests/method-mangling.rs | 55 +- .../expectations/tests/module-whitelisted.rs | 4 - tests/expectations/tests/msvc-no-usr.rs | 47 +- .../multiple-inherit-empty-correct-layout.rs | 97 +- tests/expectations/tests/mutable.rs | 138 +- tests/expectations/tests/namespace.rs | 10 +- tests/expectations/tests/nested.rs | 162 +- tests/expectations/tests/nested_vtable.rs | 119 +- .../tests/nested_within_namespace.rs | 4 - tests/expectations/tests/no-comments.rs | 47 +- tests/expectations/tests/no-derive-debug.rs | 62 +- tests/expectations/tests/no-derive-default.rs | 62 +- .../tests/no-recursive-whitelisting.rs | 54 +- tests/expectations/tests/no-std.rs | 78 +- tests/expectations/tests/no_copy.rs | 21 +- tests/expectations/tests/non-type-params.rs | 93 +- tests/expectations/tests/nsStyleAutoArray.rs | 51 +- tests/expectations/tests/objc_category.rs | 32 +- tests/expectations/tests/objc_class.rs | 28 +- tests/expectations/tests/objc_class_method.rs | 92 +- tests/expectations/tests/objc_interface.rs | 18 +- .../expectations/tests/objc_interface_type.rs | 72 +- tests/expectations/tests/objc_method.rs | 80 +- tests/expectations/tests/objc_protocol.rs | 18 +- tests/expectations/tests/objc_sel_and_id.rs | 30 +- tests/expectations/tests/objc_whitelist.rs | 53 +- tests/expectations/tests/only_bitfields.rs | 107 +- tests/expectations/tests/opaque-tracing.rs | 45 +- tests/expectations/tests/opaque_in_struct.rs | 79 +- tests/expectations/tests/opaque_pointer.rs | 125 +- tests/expectations/tests/opaque_typedef.rs | 23 +- tests/expectations/tests/overflowed_enum.rs | 27 +- tests/expectations/tests/overloading.rs | 41 +- .../partial-specialization-and-inheritance.rs | 85 +- tests/expectations/tests/prepend_enum_name.rs | 17 +- tests/expectations/tests/private.rs | 171 +- tests/expectations/tests/public-dtor.rs | 49 +- tests/expectations/tests/redeclaration.rs | 15 +- .../expectations/tests/ref_argument_array.rs | 49 +- .../tests/reparented_replacement.rs | 4 - .../tests/replace_template_alias.rs | 27 +- tests/expectations/tests/replace_use.rs | 65 +- tests/expectations/tests/replaces_double.rs | 27 +- .../tests/resolved_type_def_function.rs | 17 +- ...ame_struct_name_in_different_namespaces.rs | 65 +- tests/expectations/tests/size_t_template.rs | 45 +- ...ruct_containing_forward_declared_struct.rs | 93 +- tests/expectations/tests/struct_typedef.rs | 119 +- tests/expectations/tests/struct_typedef_ns.rs | 14 +- .../tests/struct_with_anon_struct.rs | 101 +- .../tests/struct_with_anon_struct_array.rs | 167 +- .../tests/struct_with_anon_struct_pointer.rs | 107 +- .../tests/struct_with_anon_union.rs | 153 +- .../tests/struct_with_anon_unnamed_struct.rs | 91 +- .../tests/struct_with_anon_unnamed_union.rs | 143 +- .../tests/struct_with_bitfields.rs | 265 +- .../tests/struct_with_derive_debug.rs | 165 +- .../expectations/tests/struct_with_nesting.rs | 303 +- .../expectations/tests/struct_with_packing.rs | 57 +- .../expectations/tests/struct_with_struct.rs | 101 +- .../tests/struct_with_typedef_template_arg.rs | 21 +- tests/expectations/tests/template-fun-ty.rs | 47 +- .../tests/template-param-usage-0.rs | 23 +- .../tests/template-param-usage-1.rs | 19 +- .../tests/template-param-usage-10.rs | 45 +- .../tests/template-param-usage-11.rs | 19 +- .../tests/template-param-usage-12.rs | 41 +- .../tests/template-param-usage-13.rs | 35 +- .../tests/template-param-usage-14.rs | 35 +- .../tests/template-param-usage-15.rs | 41 +- .../tests/template-param-usage-2.rs | 39 +- .../tests/template-param-usage-3.rs | 43 +- .../tests/template-param-usage-4.rs | 33 +- .../tests/template-param-usage-5.rs | 25 +- .../tests/template-param-usage-6.rs | 21 +- .../tests/template-param-usage-7.rs | 28 +- .../tests/template-param-usage-8.rs | 29 +- .../tests/template-param-usage-9.rs | 39 +- tests/expectations/tests/template.rs | 508 ++-- tests/expectations/tests/template_alias.rs | 25 +- .../tests/template_alias_basic.rs | 13 +- .../tests/template_alias_namespace.rs | 4 - .../tests/template_partial_specification.rs | 10 +- .../template_typedef_transitive_param.rs | 35 +- tests/expectations/tests/template_typedefs.rs | 36 +- .../expectations/tests/templateref_opaque.rs | 31 +- ...type-referenced-by-whitelisted-function.rs | 54 +- tests/expectations/tests/type_alias_empty.rs | 13 +- ..._alias_partial_template_especialization.rs | 25 +- .../tests/type_alias_template_specialized.rs | 51 +- .../tests/typedefd-array-as-function-arg.rs | 17 +- tests/expectations/tests/typeref.rs | 250 +- tests/expectations/tests/union-in-ns.rs | 4 - tests/expectations/tests/union_dtor.rs | 124 +- tests/expectations/tests/union_fields.rs | 123 +- tests/expectations/tests/union_template.rs | 113 +- .../tests/union_with_anon_struct.rs | 153 +- .../tests/union_with_anon_struct_bitfield.rs | 203 +- .../tests/union_with_anon_union.rs | 155 +- .../tests/union_with_anon_unnamed_struct.rs | 180 +- .../tests/union_with_anon_unnamed_union.rs | 157 +- .../tests/union_with_big_member.rs | 231 +- .../expectations/tests/union_with_nesting.rs | 267 +- tests/expectations/tests/unknown_attr.rs | 63 +- tests/expectations/tests/use-core.rs | 196 +- tests/expectations/tests/using.rs | 29 +- tests/expectations/tests/var-tracing.rs | 107 +- tests/expectations/tests/variadic-method.rs | 54 +- .../tests/variadic_template_function.rs | 19 +- tests/expectations/tests/vector.rs | 47 +- tests/expectations/tests/virtual_dtor.rs | 41 +- .../expectations/tests/virtual_inheritance.rs | 191 +- .../expectations/tests/virtual_overloaded.rs | 47 +- .../tests/vtable_recursive_sig.rs | 83 +- tests/expectations/tests/weird_bitfields.rs | 452 +-- tests/expectations/tests/what_is_going_on.rs | 59 +- .../tests/whitelist-namespaces-basic.rs | 4 - .../tests/whitelist-namespaces.rs | 4 - tests/expectations/tests/whitelist_basic.rs | 41 +- tests/expectations/tests/whitelist_fix.rs | 14 +- tests/expectations/tests/whitelist_vars.rs | 19 +- tests/tests.rs | 22 +- 255 files changed, 13903 insertions(+), 12914 deletions(-) diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 579e9de12e..20a1987a64 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -39,7 +39,7 @@ use syntax::codemap::{Span, respan}; use syntax::ptr::P; fn root_import_depth(ctx: &BindgenContext, item: &Item) -> usize { - if !ctx.options().enable_cxx_namespaces { + if !(item.id() == ctx.root_module() || ctx.options().enable_cxx_namespaces) { return 0; } @@ -51,7 +51,7 @@ fn root_import_depth(ctx: &BindgenContext, item: &Item) -> usize { fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec { let mut path = vec![ctx.rust_ident_raw("self")]; - if ctx.options().enable_cxx_namespaces { + if item.id() == ctx.root_module() || ctx.options().enable_cxx_namespaces { let super_ = ctx.rust_ident_raw("super"); for _ in 0..root_import_depth(ctx, item) { @@ -63,14 +63,18 @@ fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec { } fn root_import(ctx: &BindgenContext, module: &Item) -> P { - assert!(ctx.options().enable_cxx_namespaces, "Somebody messed it up"); + assert!(module.id() == ctx.root_module() || ctx.options().enable_cxx_namespaces, "Somebody messed it up"); assert!(module.is_module()); let mut path = top_level_path(ctx, module); - let root = ctx.root_module().canonical_name(ctx); - let root_ident = ctx.rust_ident(&root); - path.push(root_ident); + if module.id() == ctx.root_module() && !ctx.options().enable_cxx_namespaces { + path.push(ctx.rust_ident_raw("*")); + } else { + let root = ctx.root_module().canonical_name(ctx); + let root_ident = ctx.rust_ident(&root); + path.push(root_ident); + } let use_root = aster::AstBuilder::new() .item() @@ -361,7 +365,11 @@ impl CodeGenerator for Module { } } - if item.id() == ctx.root_module() { + if item.id() == ctx.sentinel_module() { + if result.saw_objc { + utils::prepend_objc_header(ctx, &mut *result); + } + } else if item.id() == ctx.root_module() { if result.saw_union && !ctx.options().unstable_rust { utils::prepend_union_types(ctx, &mut *result); } @@ -371,13 +379,11 @@ impl CodeGenerator for Module { if ctx.need_bindegen_complex_type() { utils::prepend_complex_type(ctx, &mut *result); } - if result.saw_objc { - utils::prepend_objc_header(ctx, &mut *result); - } } }; - if !ctx.options().enable_cxx_namespaces || + let item_id = item.id(); + if item_id == ctx.sentinel_module() || (item_id != ctx.root_module() && !ctx.options().enable_cxx_namespaces) || (self.is_inline() && !ctx.options().conservative_inline_namespaces) { codegen_self(result, &mut false); return; @@ -2950,7 +2956,7 @@ pub fn codegen(context: &mut BindgenContext) -> Vec> { } } - context.resolve_item(context.root_module()) + context.resolve_item(context.sentinel_module()) .codegen(context, &mut result, &whitelisted_items, &()); result.items diff --git a/src/ir/context.rs b/src/ir/context.rs index 9b9ad8bd29..1fc67fa4e8 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -111,6 +111,10 @@ pub struct BindgenContext<'ctx> { /// A cursor to module map. Similar reason than above. modules: HashMap, + /// The sentinel module is the real root for the whole generated code. + /// It's always inline and should have exactly one child, namely the root_module. + sentinel_module: ItemId, + /// The root module, this is guaranteed to be an item of kind Module. root_module: ItemId, @@ -186,13 +190,21 @@ impl<'ctx> BindgenContext<'ctx> { parse_options) .expect("TranslationUnit::parse failed"); - let root_module = Self::build_root_module(ItemId(0)); + let mut sentinel_module = Self::build_sentinel_module(ItemId(0)); + let root_module = Self::build_root_module(ItemId(1), ItemId(1)); + + { + let mut sm = sentinel_module.as_module_mut().unwrap(); + sm.children_mut().push(ItemId(1)); + } + let mut me = BindgenContext { items: Default::default(), types: Default::default(), named_types: Default::default(), modules: Default::default(), - next_item_id: ItemId(1), + next_item_id: ItemId(2), + sentinel_module: sentinel_module.id(), root_module: root_module.id(), current_module: root_module.id(), currently_parsed_types: vec![], @@ -208,6 +220,7 @@ impl<'ctx> BindgenContext<'ctx> { used_template_parameters: None, }; + me.add_item(sentinel_module, None, None); me.add_item(root_module, None, None); me @@ -662,11 +675,21 @@ impl<'ctx> BindgenContext<'ctx> { assert!(old_item.is_none(), "Inserted type twice?"); } - fn build_root_module(id: ItemId) -> Item { - let module = Module::new(Some("root".into()), ModuleKind::Normal); + fn build_sentinel_module(id: ItemId) -> Item { + let module = Module::new(Some("".into()), ModuleKind::Inline); Item::new(id, None, None, id, ItemKind::Module(module)) } + fn build_root_module(id: ItemId, parent_id: ItemId) -> Item { + let module = Module::new(Some("root".into()), ModuleKind::Normal); + Item::new(id, None, None, parent_id, ItemKind::Module(module)) + } + + /// Get the sentinel module + pub fn sentinel_module(&self) -> ItemId { + self.sentinel_module + } + /// Get the root module. pub fn root_module(&self) -> ItemId { self.root_module diff --git a/src/lib.rs b/src/lib.rs index 44cf91938a..b8c1a78ac3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -818,8 +818,7 @@ impl<'ctx> Bindings<'ctx> { /// Write these bindings as source text to the given `Write`able. pub fn write<'a>(&self, mut writer: Box) -> io::Result<()> { - try!(writer.write("/* automatically generated by rust-bindgen */\n\n" - .as_bytes())); + try!(write!(writer, "/* automatically generated by rust-bindgen */\n\n")); for line in self.context.options().raw_lines.iter() { try!(writer.write(line.as_bytes())); @@ -829,6 +828,10 @@ impl<'ctx> Bindings<'ctx> { try!(writer.write("\n".as_bytes())); } + if !self.context.options().enable_cxx_namespaces && !self.module.items.is_empty() { + try!(write!(writer, "pub use self::root::*;\n\n")); + } + let mut ps = pprust::rust_printer(writer); try!(ps.print_mod(&self.module, &[])); try!(ps.print_remaining_comments()); diff --git a/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs index 2ab00679b9..abc61e9c57 100644 --- a/tests/expectations/tests/16-byte-alignment.rs +++ b/tests/expectations/tests/16-byte-alignment.rs @@ -1,232 +1,245 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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, + } + #[test] + fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . dport as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( dport ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . sport as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( sport ) )); + } + impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1 ) ) . + sctp_tag as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv4_tuple__bindgen_ty_1 ) , "::" , stringify ! ( + sctp_tag ) )); + } + impl Clone for rte_ipv4_tuple__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_ipv4_tuple() { + assert_eq!(::std::mem::size_of::() , 12usize , concat + ! ( "Size of: " , stringify ! ( rte_ipv4_tuple ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_ipv4_tuple ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple ) ) . src_addr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , + "::" , stringify ! ( src_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv4_tuple ) ) . dst_addr as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , + "::" , stringify ! ( dst_addr ) )); + } + impl Clone for rte_ipv4_tuple { + 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, + } + #[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, + } + #[test] + fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . dport as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( dport ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) + ) . sport as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , + stringify ! ( sport ) )); + } + impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1 ) ) . + sctp_tag as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_ipv6_tuple__bindgen_ty_1 ) , "::" , stringify ! ( + sctp_tag ) )); + } + impl Clone for rte_ipv6_tuple__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_ipv6_tuple() { + assert_eq!(::std::mem::size_of::() , 36usize , concat + ! ( "Size of: " , stringify ! ( rte_ipv6_tuple ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_ipv6_tuple ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple ) ) . src_addr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , + "::" , stringify ! ( src_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ipv6_tuple ) ) . dst_addr as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , + "::" , stringify ! ( dst_addr ) )); + } + impl Clone for rte_ipv6_tuple { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Copy)] + pub struct rte_thash_tuple { + pub v4: __BindgenUnionField, + pub v6: __BindgenUnionField, + pub bindgen_union_field: [u8; 48usize], + } + #[test] + fn bindgen_test_layout_rte_thash_tuple() { + assert_eq!(::std::mem::size_of::() , 48usize , concat + ! ( "Size of: " , stringify ! ( rte_thash_tuple ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_thash_tuple ) , + "::" , stringify ! ( v4 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_thash_tuple ) , + "::" , stringify ! ( v6 ) )); + } + impl Clone for rte_thash_tuple { + fn clone(&self) -> Self { *self } + } + impl Default for rte_thash_tuple { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -} -#[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, -} -#[test] -fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . dport as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( dport ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . sport as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( sport ) )); -} -impl Clone for rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_ipv4_tuple__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv4_tuple__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple__bindgen_ty_1 ) ) . - sctp_tag as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv4_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag - ) )); -} -impl Clone for rte_ipv4_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_ipv4_tuple() { - assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv4_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple ) ) . src_addr as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" - , stringify ! ( src_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv4_tuple ) ) . dst_addr as * const - _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv4_tuple ) , "::" - , stringify ! ( dst_addr ) )); -} -impl Clone for rte_ipv4_tuple { - 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, -} -#[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, -} -#[test] -fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . dport as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( dport ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) - ) . sport as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( sport ) )); -} -impl Clone for rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_ipv6_tuple__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize - , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv6_tuple__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple__bindgen_ty_1 ) ) . - sctp_tag as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_ipv6_tuple__bindgen_ty_1 ) , "::" , stringify ! ( sctp_tag - ) )); -} -impl Clone for rte_ipv6_tuple__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_ipv6_tuple() { - assert_eq!(::std::mem::size_of::() , 36usize , concat ! ( - "Size of: " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_ipv6_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple ) ) . src_addr as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" - , stringify ! ( src_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ipv6_tuple ) ) . dst_addr as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ipv6_tuple ) , "::" - , stringify ! ( dst_addr ) )); -} -impl Clone for rte_ipv6_tuple { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Copy)] -pub struct rte_thash_tuple { - pub v4: __BindgenUnionField, - pub v6: __BindgenUnionField, - pub bindgen_union_field: [u8; 48usize], -} -#[test] -fn bindgen_test_layout_rte_thash_tuple() { - assert_eq!(::std::mem::size_of::() , 48usize , concat ! ( - "Size of: " , stringify ! ( rte_thash_tuple ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v4 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_thash_tuple ) ) . v6 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_thash_tuple ) , - "::" , stringify ! ( v6 ) )); -} -impl Clone for rte_thash_tuple { - fn clone(&self) -> Self { *self } -} -impl Default for rte_thash_tuple { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/381-decltype-alias.rs b/tests/expectations/tests/381-decltype-alias.rs index 632cdd312b..f4bca13e37 100644 --- a/tests/expectations/tests/381-decltype-alias.rs +++ b/tests/expectations/tests/381-decltype-alias.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct std_allocator_traits { - pub _address: u8, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct std_allocator_traits { + pub _address: u8, + } + pub type std_allocator_traits___size_type<_Alloc> = _Alloc; } -pub type std_allocator_traits___size_type<_Alloc> = _Alloc; diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index 753188bdd0..c53e43fefb 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -1,289 +1,305 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct SomeAccessors { - pub mNoAccessor: ::std::os::raw::c_int, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct SomeAccessors { + pub mNoAccessor: ::std::os::raw::c_int, + /**
*/ + pub mBothAccessors: ::std::os::raw::c_int, + /**
*/ + pub mUnsafeAccessors: ::std::os::raw::c_int, + /**
*/ + pub mImmutableAccessor: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_SomeAccessors() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! + ( "Size of: " , stringify ! ( SomeAccessors ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( SomeAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mNoAccessor as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( SomeAccessors ) , + "::" , stringify ! ( mNoAccessor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mBothAccessors as + * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( SomeAccessors ) , + "::" , stringify ! ( mBothAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . mUnsafeAccessors + as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( SomeAccessors ) , + "::" , stringify ! ( mUnsafeAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const SomeAccessors ) ) . + mImmutableAccessor as * const _ as usize } , 12usize , + concat ! ( + "Alignment of field: " , stringify ! ( SomeAccessors ) , + "::" , stringify ! ( mImmutableAccessor ) )); + } + impl Clone for SomeAccessors { + fn clone(&self) -> Self { *self } + } + impl SomeAccessors { + #[inline] + pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { + &self.mBothAccessors + } + #[inline] + pub fn get_mBothAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mBothAccessors + } + #[inline] + pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int { + &self.mUnsafeAccessors + } + #[inline] + pub unsafe fn get_mUnsafeAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mUnsafeAccessors + } + #[inline] + pub fn get_mImmutableAccessor(&self) -> &::std::os::raw::c_int { + &self.mImmutableAccessor + } + } /**
*/ - pub mBothAccessors: ::std::os::raw::c_int, - /**
*/ - pub mUnsafeAccessors: ::std::os::raw::c_int, - /**
*/ - pub mImmutableAccessor: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_SomeAccessors() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( SomeAccessors ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( SomeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mNoAccessor as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mNoAccessor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mBothAccessors as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mUnsafeAccessors as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mUnsafeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const SomeAccessors ) ) . mImmutableAccessor as - * const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( SomeAccessors ) , "::" - , stringify ! ( mImmutableAccessor ) )); -} -impl Clone for SomeAccessors { - fn clone(&self) -> Self { *self } -} -impl SomeAccessors { - #[inline] - pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { - &self.mBothAccessors + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct AllAccessors { + pub mBothAccessors: ::std::os::raw::c_int, + pub mAlsoBothAccessors: ::std::os::raw::c_int, } - #[inline] - pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { - &mut self.mBothAccessors + #[test] + fn bindgen_test_layout_AllAccessors() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( AllAccessors ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( AllAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const AllAccessors ) ) . mBothAccessors as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( AllAccessors ) , + "::" , stringify ! ( mBothAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const AllAccessors ) ) . mAlsoBothAccessors + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( AllAccessors ) , + "::" , stringify ! ( mAlsoBothAccessors ) )); } - #[inline] - pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int { - &self.mUnsafeAccessors + impl Clone for AllAccessors { + fn clone(&self) -> Self { *self } } - #[inline] - pub unsafe fn get_mUnsafeAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { - &mut self.mUnsafeAccessors + impl AllAccessors { + #[inline] + pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { + &self.mBothAccessors + } + #[inline] + pub fn get_mBothAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mBothAccessors + } + #[inline] + pub fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int { + &self.mAlsoBothAccessors + } + #[inline] + pub fn get_mAlsoBothAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mAlsoBothAccessors + } } - #[inline] - pub fn get_mImmutableAccessor(&self) -> &::std::os::raw::c_int { - &self.mImmutableAccessor + /**
*/ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct AllUnsafeAccessors { + pub mBothAccessors: ::std::os::raw::c_int, + pub mAlsoBothAccessors: ::std::os::raw::c_int, } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct AllAccessors { - pub mBothAccessors: ::std::os::raw::c_int, - pub mAlsoBothAccessors: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_AllAccessors() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( AllAccessors ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( AllAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllAccessors ) ) . mBothAccessors as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( AllAccessors ) , "::" , - stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllAccessors ) ) . mAlsoBothAccessors as - * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( AllAccessors ) , "::" , - stringify ! ( mAlsoBothAccessors ) )); -} -impl Clone for AllAccessors { - fn clone(&self) -> Self { *self } -} -impl AllAccessors { - #[inline] - pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { - &self.mBothAccessors + #[test] + fn bindgen_test_layout_AllUnsafeAccessors() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( AllUnsafeAccessors ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( AllUnsafeAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const AllUnsafeAccessors ) ) . + mBothAccessors as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( AllUnsafeAccessors + ) , "::" , stringify ! ( mBothAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const AllUnsafeAccessors ) ) . + mAlsoBothAccessors as * const _ as usize } , 4usize , + concat ! ( + "Alignment of field: " , stringify ! ( AllUnsafeAccessors + ) , "::" , stringify ! ( mAlsoBothAccessors ) )); } - #[inline] - pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { - &mut self.mBothAccessors + impl Clone for AllUnsafeAccessors { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int { - &self.mAlsoBothAccessors + impl AllUnsafeAccessors { + #[inline] + pub unsafe fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { + &self.mBothAccessors + } + #[inline] + pub unsafe fn get_mBothAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mBothAccessors + } + #[inline] + pub unsafe fn get_mAlsoBothAccessors(&self) + -> &::std::os::raw::c_int { + &self.mAlsoBothAccessors + } + #[inline] + pub unsafe fn get_mAlsoBothAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mAlsoBothAccessors + } } - #[inline] - pub fn get_mAlsoBothAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { - &mut self.mAlsoBothAccessors + /**
*/ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct ContradictAccessors { + pub mBothAccessors: ::std::os::raw::c_int, + /**
*/ + pub mNoAccessors: ::std::os::raw::c_int, + /**
*/ + pub mUnsafeAccessors: ::std::os::raw::c_int, + /**
*/ + pub mImmutableAccessor: ::std::os::raw::c_int, } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct AllUnsafeAccessors { - pub mBothAccessors: ::std::os::raw::c_int, - pub mAlsoBothAccessors: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_AllUnsafeAccessors() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( AllUnsafeAccessors ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( AllUnsafeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllUnsafeAccessors ) ) . mBothAccessors - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( AllUnsafeAccessors ) , - "::" , stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AllUnsafeAccessors ) ) . - mAlsoBothAccessors as * const _ as usize } , 4usize , concat ! - ( - "Alignment of field: " , stringify ! ( AllUnsafeAccessors ) , - "::" , stringify ! ( mAlsoBothAccessors ) )); -} -impl Clone for AllUnsafeAccessors { - fn clone(&self) -> Self { *self } -} -impl AllUnsafeAccessors { - #[inline] - pub unsafe fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { - &self.mBothAccessors + #[test] + fn bindgen_test_layout_ContradictAccessors() { + assert_eq!(::std::mem::size_of::() , 16usize , + concat ! ( + "Size of: " , stringify ! ( ContradictAccessors ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( ContradictAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . + mBothAccessors as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( ContradictAccessors + ) , "::" , stringify ! ( mBothAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . + mNoAccessors as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( ContradictAccessors + ) , "::" , stringify ! ( mNoAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . + mUnsafeAccessors as * const _ as usize } , 8usize , concat + ! ( + "Alignment of field: " , stringify ! ( ContradictAccessors + ) , "::" , stringify ! ( mUnsafeAccessors ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictAccessors ) ) . + mImmutableAccessor as * const _ as usize } , 12usize , + concat ! ( + "Alignment of field: " , stringify ! ( ContradictAccessors + ) , "::" , stringify ! ( mImmutableAccessor ) )); } - #[inline] - pub unsafe fn get_mBothAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { - &mut self.mBothAccessors + impl Clone for ContradictAccessors { + fn clone(&self) -> Self { *self } } - #[inline] - pub unsafe fn get_mAlsoBothAccessors(&self) -> &::std::os::raw::c_int { - &self.mAlsoBothAccessors + impl ContradictAccessors { + #[inline] + pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { + &self.mBothAccessors + } + #[inline] + pub fn get_mBothAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mBothAccessors + } + #[inline] + pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int { + &self.mUnsafeAccessors + } + #[inline] + pub unsafe fn get_mUnsafeAccessors_mut(&mut self) + -> &mut ::std::os::raw::c_int { + &mut self.mUnsafeAccessors + } + #[inline] + pub fn get_mImmutableAccessor(&self) -> &::std::os::raw::c_int { + &self.mImmutableAccessor + } } - #[inline] - pub unsafe fn get_mAlsoBothAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { - &mut self.mAlsoBothAccessors + /**
*/ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Replaced { + pub mAccessor: ::std::os::raw::c_int, } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct ContradictAccessors { - pub mBothAccessors: ::std::os::raw::c_int, - /**
*/ - pub mNoAccessors: ::std::os::raw::c_int, - /**
*/ - pub mUnsafeAccessors: ::std::os::raw::c_int, - /**
*/ - pub mImmutableAccessor: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_ContradictAccessors() { - assert_eq!(::std::mem::size_of::() , 16usize , concat - ! ( "Size of: " , stringify ! ( ContradictAccessors ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( ContradictAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . mBothAccessors - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mBothAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . mNoAccessors as - * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mNoAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . - mUnsafeAccessors as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mUnsafeAccessors ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictAccessors ) ) . - mImmutableAccessor as * const _ as usize } , 12usize , concat - ! ( - "Alignment of field: " , stringify ! ( ContradictAccessors ) , - "::" , stringify ! ( mImmutableAccessor ) )); -} -impl Clone for ContradictAccessors { - fn clone(&self) -> Self { *self } -} -impl ContradictAccessors { - #[inline] - pub fn get_mBothAccessors(&self) -> &::std::os::raw::c_int { - &self.mBothAccessors + #[test] + fn bindgen_test_layout_Replaced() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Replaced ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Replaced ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Replaced ) ) . mAccessor as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Replaced ) , "::" , + stringify ! ( mAccessor ) )); } - #[inline] - pub fn get_mBothAccessors_mut(&mut self) -> &mut ::std::os::raw::c_int { - &mut self.mBothAccessors + impl Clone for Replaced { + fn clone(&self) -> Self { *self } } - #[inline] - pub unsafe fn get_mUnsafeAccessors(&self) -> &::std::os::raw::c_int { - &self.mUnsafeAccessors + impl Replaced { + #[inline] + pub fn get_mAccessor(&self) -> &::std::os::raw::c_int { + &self.mAccessor + } + #[inline] + pub fn get_mAccessor_mut(&mut self) -> &mut ::std::os::raw::c_int { + &mut self.mAccessor + } } - #[inline] - pub unsafe fn get_mUnsafeAccessors_mut(&mut self) - -> &mut ::std::os::raw::c_int { - &mut self.mUnsafeAccessors + /**
*/ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Wrapper { + pub mReplaced: Replaced, } - #[inline] - pub fn get_mImmutableAccessor(&self) -> &::std::os::raw::c_int { - &self.mImmutableAccessor + #[test] + fn bindgen_test_layout_Wrapper() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Wrapper ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Wrapper ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Wrapper ) ) . mReplaced as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Wrapper ) , "::" , + stringify ! ( mReplaced ) )); } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Replaced { - pub mAccessor: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Replaced() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Replaced ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Replaced ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Replaced ) ) . mAccessor as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Replaced ) , "::" , - stringify ! ( mAccessor ) )); -} -impl Clone for Replaced { - fn clone(&self) -> Self { *self } -} -impl Replaced { - #[inline] - pub fn get_mAccessor(&self) -> &::std::os::raw::c_int { &self.mAccessor } - #[inline] - pub fn get_mAccessor_mut(&mut self) -> &mut ::std::os::raw::c_int { - &mut self.mAccessor + impl Clone for Wrapper { + fn clone(&self) -> Self { *self } } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Wrapper { - pub mReplaced: Replaced, -} -#[test] -fn bindgen_test_layout_Wrapper() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Wrapper ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Wrapper ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Wrapper ) ) . mReplaced as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Wrapper ) , "::" , - stringify ! ( mReplaced ) )); -} -impl Clone for Wrapper { - fn clone(&self) -> Self { *self } -} -impl Wrapper { - #[inline] - pub fn get_mReplaced(&self) -> &Replaced { &self.mReplaced } - #[inline] - pub fn get_mReplaced_mut(&mut self) -> &mut Replaced { - &mut self.mReplaced + impl Wrapper { + #[inline] + pub fn get_mReplaced(&self) -> &Replaced { &self.mReplaced } + #[inline] + pub fn get_mReplaced_mut(&mut self) -> &mut Replaced { + &mut self.mReplaced + } } } diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs index 1ad8fd8337..17dfa74480 100644 --- a/tests/expectations/tests/annotation_hide.rs +++ b/tests/expectations/tests/annotation_hide.rs @@ -1,44 +1,47 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** *
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct D { - pub _bindgen_opaque_blob: u32, -} -#[test] -fn bindgen_test_layout_D() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); -} -impl Clone for D { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct NotAnnotated { - pub f: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_NotAnnotated() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( NotAnnotated ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( NotAnnotated ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const NotAnnotated ) ) . f as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( NotAnnotated ) , "::" , - stringify ! ( f ) )); -} -impl Clone for NotAnnotated { - fn clone(&self) -> Self { *self } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct D { + pub _bindgen_opaque_blob: u32, + } + #[test] + fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( D ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( D ) )); + } + impl Clone for D { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct NotAnnotated { + pub f: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_NotAnnotated() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( NotAnnotated ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( NotAnnotated ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const NotAnnotated ) ) . f as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( NotAnnotated ) , + "::" , stringify ! ( f ) )); + } + impl Clone for NotAnnotated { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/anon_enum.rs b/tests/expectations/tests/anon_enum.rs index 71abc77be8..ee30ec8c5a 100644 --- a/tests/expectations/tests/anon_enum.rs +++ b/tests/expectations/tests/anon_enum.rs @@ -1,39 +1,42 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . bar as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for Test { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( Test ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Test ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . foo as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . bar as * const _ as usize + } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for Test { + fn clone(&self) -> Self { *self } + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Baz { Foo = 0, Bar = 1, } } -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Baz { Foo = 0, Bar = 1, } diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs index 92c697a884..3e4c9f9869 100644 --- a/tests/expectations/tests/anon_enum_trait.rs +++ b/tests/expectations/tests/anon_enum_trait.rs @@ -1,48 +1,51 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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>; -pub type DataType_vec_type<_Tp> = DataType_value_type<_Tp>; -pub const DataType_generic_type: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_depth: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_channels: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_fmt: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -pub const DataType_type_: DataType__bindgen_ty_1 = - DataType__bindgen_ty_1::generic_type; -#[repr(i32)] -#[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 { - pub _address: u8, -} -pub const Foo_Bar: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::Bar; -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, } -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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>; + pub type DataType_vec_type<_Tp> = DataType_value_type<_Tp>; + pub const DataType_generic_type: DataType__bindgen_ty_1 = + DataType__bindgen_ty_1::generic_type; + pub const DataType_depth: DataType__bindgen_ty_1 = + DataType__bindgen_ty_1::generic_type; + pub const DataType_channels: DataType__bindgen_ty_1 = + DataType__bindgen_ty_1::generic_type; + pub const DataType_fmt: DataType__bindgen_ty_1 = + DataType__bindgen_ty_1::generic_type; + pub const DataType_type_: DataType__bindgen_ty_1 = + DataType__bindgen_ty_1::generic_type; + #[repr(i32)] + #[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 { + pub _address: u8, + } + pub const Foo_Bar: Foo__bindgen_ty_1 = Foo__bindgen_ty_1::Bar; + 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, } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/anon_enum_whitelist.rs b/tests/expectations/tests/anon_enum_whitelist.rs index b32396a035..6af50d6cdf 100644 --- a/tests/expectations/tests/anon_enum_whitelist.rs +++ b/tests/expectations/tests/anon_enum_whitelist.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const NODE_FLAG_FOO: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_FOO; -pub const NODE_FLAG_BAR: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_BAR; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const NODE_FLAG_FOO: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_FOO; + pub const NODE_FLAG_BAR: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_BAR; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { NODE_FLAG_FOO = 0, NODE_FLAG_BAR = 1, } +} diff --git a/tests/expectations/tests/anon_struct_in_union.rs b/tests/expectations/tests/anon_struct_in_union.rs index 97a342cfff..751333d9b7 100644 --- a/tests/expectations/tests/anon_struct_in_union.rs +++ b/tests/expectations/tests/anon_struct_in_union.rs @@ -1,92 +1,102 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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, + } + #[test] + fn bindgen_test_layout_s__bindgen_ty_1_inner() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( s__bindgen_ty_1_inner ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const s__bindgen_ty_1_inner ) ) . b as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + s__bindgen_ty_1_inner ) , "::" , stringify ! ( b ) )); + } + impl Clone for s__bindgen_ty_1_inner { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_s__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat + ! ( "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( s__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const s__bindgen_ty_1 ) ) . field as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( s__bindgen_ty_1 ) , + "::" , stringify ! ( field ) )); + } + impl Clone for s__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_s() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( s ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( s ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const s ) ) . u as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( s ) , "::" , + stringify ! ( u ) )); + } + impl Clone for s { + fn clone(&self) -> Self { *self } } -} -#[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, -} -#[test] -fn bindgen_test_layout_s__bindgen_ty_1_inner() { - assert_eq!(::std::mem::size_of::() , 4usize , - concat ! ( "Size of: " , stringify ! ( s__bindgen_ty_1_inner ) - )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( s__bindgen_ty_1_inner ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const s__bindgen_ty_1_inner ) ) . b as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s__bindgen_ty_1_inner ) - , "::" , stringify ! ( b ) )); -} -impl Clone for s__bindgen_ty_1_inner { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_s__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! - ( "Alignment of " , stringify ! ( s__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const s__bindgen_ty_1 ) ) . field as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s__bindgen_ty_1 ) , - "::" , stringify ! ( field ) )); -} -impl Clone for s__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_s() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( s ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( s ) )); - assert_eq! (unsafe { & ( * ( 0 as * const s ) ) . u as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( s ) , "::" , stringify - ! ( u ) )); -} -impl Clone for s { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs index eb600cc737..163f22599c 100644 --- a/tests/expectations/tests/anon_union.rs +++ b/tests/expectations/tests/anon_union.rs @@ -1,90 +1,99 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum TErrorResult_UnionState { HasMessage = 0, } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct TErrorResult_Message { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct TErrorResult_DOMExceptionInfo { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct TErrorResult__bindgen_ty_1 { + pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, + pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, + pub bindgen_union_field: u64, + } + impl Default for TErrorResult { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct ErrorResult { + pub _base: TErrorResult, + } + #[test] + fn bindgen_test_layout_ErrorResult() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( + "Size of: " , stringify ! ( ErrorResult ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( ErrorResult ) )); + } + impl Clone for ErrorResult { + fn clone(&self) -> Self { *self } + } + impl Default for ErrorResult { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn __bindgen_test_layout_TErrorResult_instantiation_22() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! + ( + "Size of template specialization: " , stringify ! ( + TErrorResult ) )); + assert_eq!(::std::mem::align_of::() , 8usize , concat ! + ( + "Alignment of template specialization: " , stringify ! ( + TErrorResult ) )); } -} -#[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)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum TErrorResult_UnionState { HasMessage = 0, } -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct TErrorResult_Message { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct TErrorResult_DOMExceptionInfo { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct TErrorResult__bindgen_ty_1 { - pub mMessage: __BindgenUnionField<*mut TErrorResult_Message>, - pub mDOMExceptionInfo: __BindgenUnionField<*mut TErrorResult_DOMExceptionInfo>, - pub bindgen_union_field: u64, -} -impl Default for TErrorResult { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ErrorResult { - pub _base: TErrorResult, -} -#[test] -fn bindgen_test_layout_ErrorResult() { - assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( - "Size of: " , stringify ! ( ErrorResult ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ErrorResult ) )); -} -impl Clone for ErrorResult { - fn clone(&self) -> Self { *self } -} -impl Default for ErrorResult { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn __bindgen_test_layout_TErrorResult_instantiation_21() { - assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( - "Size of template specialization: " , stringify ! ( - TErrorResult ) )); - assert_eq!(::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - TErrorResult ) )); } diff --git a/tests/expectations/tests/anonymous-template-types.rs b/tests/expectations/tests/anonymous-template-types.rs index c225b69d27..6b7c57e232 100644 --- a/tests/expectations/tests/anonymous-template-types.rs +++ b/tests/expectations/tests/anonymous-template-types.rs @@ -1,33 +1,36 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Foo { - pub t_member: T, -} -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Bar { - pub member: ::std::os::raw::c_char, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Quux { - pub v_member: V, -} -impl Default for Quux { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Lobo { - pub also_member: ::std::os::raw::c_char, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Foo { + pub t_member: T, + } + impl Default for Foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Bar { + pub member: ::std::os::raw::c_char, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Quux { + pub v_member: V, + } + impl Default for Quux { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Lobo { + pub also_member: ::std::os::raw::c_char, + } + pub type AliasWithAnonType = ::std::os::raw::c_char; } -pub type AliasWithAnonType = ::std::os::raw::c_char; diff --git a/tests/expectations/tests/arg_keyword.rs b/tests/expectations/tests/arg_keyword.rs index cb1cc4327a..99bfc2752a 100644 --- a/tests/expectations/tests/arg_keyword.rs +++ b/tests/expectations/tests/arg_keyword.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "_Z3fooPKc"] - pub fn foo(type_: *const ::std::os::raw::c_char); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "_Z3fooPKc"] + pub fn foo(type_: *const ::std::os::raw::c_char); + } } diff --git a/tests/expectations/tests/auto.rs b/tests/expectations/tests/auto.rs index 7f9bbf44ad..2df47126c2 100644 --- a/tests/expectations/tests/auto.rs +++ b/tests/expectations/tests/auto.rs @@ -1,31 +1,34 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Bar { - pub _address: u8, -} -extern "C" { - #[link_name = "_Z5Test2v"] - pub fn Test2() -> ::std::os::raw::c_uint; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Bar { + pub _address: u8, + } + extern "C" { + #[link_name = "_Z5Test2v"] + pub fn Test2() -> ::std::os::raw::c_uint; + } } diff --git a/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs b/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs index 9ff4af1f06..f7e01c7676 100644 --- a/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs +++ b/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs @@ -1,19 +1,22 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct std_char_traits { - pub _address: u8, -} -impl Default for std_char_traits { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct __gnu_cxx_char_traits { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct std_char_traits { + pub _address: u8, + } + impl Default for std_char_traits { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct __gnu_cxx_char_traits { + pub _address: u8, + } } diff --git a/tests/expectations/tests/base-to-derived.rs b/tests/expectations/tests/base-to-derived.rs index 6ff4ce9a97..3ded25a78d 100644 --- a/tests/expectations/tests/base-to-derived.rs +++ b/tests/expectations/tests/base-to-derived.rs @@ -1,21 +1,24 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct false_type { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_false_type() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( false_type ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( false_type ) )); -} -impl Clone for false_type { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct false_type { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_false_type() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( false_type ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( false_type ) )); + } + impl Clone for false_type { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/tests/expectations/tests/bitfield-enum-basic.rs index a3eb0d7ad8..e849818286 100644 --- a/tests/expectations/tests/bitfield-enum-basic.rs +++ b/tests/expectations/tests/bitfield-enum-basic.rs @@ -1,79 +1,84 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const Foo_Bar: Foo = Foo(2); -pub const Foo_Baz: Foo = Foo(4); -pub const Foo_Duplicated: Foo = Foo(4); -pub const Foo_Negative: Foo = Foo(-3); -impl ::std::ops::BitOr for Foo { - type - Output - = - Self; - #[inline] - fn bitor(self, other: Self) -> Self { Foo(self.0 | other.0) } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct Foo(pub ::std::os::raw::c_int); -pub const Buz_Bar: Buz = Buz(2); -pub const Buz_Baz: Buz = Buz(4); -pub const Buz_Duplicated: Buz = Buz(4); -pub const Buz_Negative: Buz = Buz(-3); -impl ::std::ops::BitOr for Buz { - type - Output - = - Self; - #[inline] - fn bitor(self, other: Self) -> Self { Buz(self.0 | other.0) } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct Buz(pub ::std::os::raw::c_schar); -pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1); -pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2); -impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 { - type - Output - = - Self; - #[inline] - fn bitor(self, other: Self) -> Self { _bindgen_ty_1(self.0 | other.0) } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct _bindgen_ty_1(pub ::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 { - type - Output - = - Self; - #[inline] - fn bitor(self, other: Self) -> Self { - Dummy__bindgen_ty_1(self.0 | other.0) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const Foo_Bar: Foo = Foo(2); + pub const Foo_Baz: Foo = Foo(4); + pub const Foo_Duplicated: Foo = Foo(4); + pub const Foo_Negative: Foo = Foo(-3); + impl ::std::ops::BitOr for Foo { + type + Output + = + Self; + #[inline] + fn bitor(self, other: Self) -> Self { Foo(self.0 | other.0) } + } + #[repr(C)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub struct Foo(pub ::std::os::raw::c_int); + pub const Buz_Bar: Buz = Buz(2); + pub const Buz_Baz: Buz = Buz(4); + pub const Buz_Duplicated: Buz = Buz(4); + pub const Buz_Negative: Buz = Buz(-3); + impl ::std::ops::BitOr for Buz { + type + Output + = + Self; + #[inline] + fn bitor(self, other: Self) -> Self { Buz(self.0 | other.0) } + } + #[repr(C)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub struct Buz(pub ::std::os::raw::c_schar); + pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1); + pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2); + impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 { + type + Output + = + Self; + #[inline] + fn bitor(self, other: Self) -> Self { + _bindgen_ty_1(self.0 | other.0) + } + } + #[repr(C)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub struct _bindgen_ty_1(pub ::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 { + type + Output + = + Self; + #[inline] + fn bitor(self, other: Self) -> Self { + Dummy__bindgen_ty_1(self.0 | other.0) + } + } + #[repr(C)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub struct Dummy__bindgen_ty_1(pub ::std::os::raw::c_uint); + #[test] + fn bindgen_test_layout_Dummy() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Dummy ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Dummy ) )); + } + impl Clone for Dummy { + fn clone(&self) -> Self { *self } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub struct Dummy__bindgen_ty_1(pub ::std::os::raw::c_uint); -#[test] -fn bindgen_test_layout_Dummy() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Dummy ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Dummy ) )); -} -impl Clone for Dummy { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs index d4fe96948a..aa16c81ed0 100644 --- a/tests/expectations/tests/bitfield-large.rs +++ b/tests/expectations/tests/bitfield-large.rs @@ -1,32 +1,36 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct HasBigBitfield { - pub _bitfield_1: [u8; 16usize], -} -#[test] -fn bindgen_test_layout_HasBigBitfield() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( HasBigBitfield ) )); -} -impl Clone for HasBigBitfield { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct HasTwoBigBitfields { - pub _bitfield_1: [u8; 16usize], -} -#[test] -fn bindgen_test_layout_HasTwoBigBitfields() { - assert_eq!(::std::mem::size_of::() , 16usize , concat - ! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) )); -} -impl Clone for HasTwoBigBitfields { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct HasBigBitfield { + pub _bitfield_1: [u8; 16usize], + } + #[test] + fn bindgen_test_layout_HasBigBitfield() { + assert_eq!(::std::mem::size_of::() , 16usize , concat + ! ( "Size of: " , stringify ! ( HasBigBitfield ) )); + } + impl Clone for HasBigBitfield { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct HasTwoBigBitfields { + pub _bitfield_1: [u8; 16usize], + } + #[test] + fn bindgen_test_layout_HasTwoBigBitfields() { + assert_eq!(::std::mem::size_of::() , 16usize , + concat ! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) + )); + } + impl Clone for HasTwoBigBitfields { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/bitfield-method-same-name.rs b/tests/expectations/tests/bitfield-method-same-name.rs index ab74b1e5cc..e2211fcec2 100644 --- a/tests/expectations/tests/bitfield-method-same-name.rs +++ b/tests/expectations/tests/bitfield-method-same-name.rs @@ -1,67 +1,70 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo { - pub _bitfield_1: u8, - pub __bindgen_align: [u8; 0usize], -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( 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 } -} -impl Foo { - #[inline] - pub fn type__bindgen_bitfield(&self) -> ::std::os::raw::c_char { - let mask = 7usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u8) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Foo { + pub _bitfield_1: u8, + pub __bindgen_align: [u8; 0usize], + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( 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; } - #[inline] - pub fn set_type__bindgen_bitfield(&mut self, - val: ::std::os::raw::c_char) { - let mask = 7usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + extern "C" { + #[link_name = "_ZN3Foo9set_type_Ec"] + pub fn Foo_set_type_(this: *mut Foo, c: ::std::os::raw::c_char); } - #[inline] - pub unsafe fn type_(&mut self) -> ::std::os::raw::c_char { - Foo_type(self) + extern "C" { + #[link_name = "_ZN3Foo8set_typeEc"] + pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char); } - #[inline] - pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_char) { - Foo_set_type_(self, c) + impl Clone for Foo { + fn clone(&self) -> Self { *self } } - #[inline] - pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_char) { - Foo_set_type(self, c) + impl Foo { + #[inline] + pub fn type__bindgen_bitfield(&self) -> ::std::os::raw::c_char { + let mask = 7usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_type__bindgen_bitfield(&mut self, + val: ::std::os::raw::c_char) { + let mask = 7usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub unsafe fn type_(&mut self) -> ::std::os::raw::c_char { + Foo_type(self) + } + #[inline] + pub unsafe fn set_type_(&mut self, c: ::std::os::raw::c_char) { + Foo_set_type_(self, c) + } + #[inline] + pub unsafe fn set_type(&mut self, c: ::std::os::raw::c_char) { + Foo_set_type(self, c) + } } } diff --git a/tests/expectations/tests/bitfield_align.rs b/tests/expectations/tests/bitfield_align.rs index 5151bc4d56..94414125b8 100644 --- a/tests/expectations/tests/bitfield_align.rs +++ b/tests/expectations/tests/bitfield_align.rs @@ -1,520 +1,526 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A { - pub x: ::std::os::raw::c_uchar, - pub _bitfield_1: [u8; 2usize], - pub y: ::std::os::raw::c_uchar, - pub __bindgen_align: [u32; 0usize], -} -#[test] -fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . x as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( x ) )); - assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . y as * const _ as usize - } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( y ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } -} -impl A { - #[inline] - pub fn b1(&self) -> ::std::os::raw::c_uint { - let mask = 1usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b1(&mut self, val: ::std::os::raw::c_uint) { - let mask = 1usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b2(&self) -> ::std::os::raw::c_uint { - let mask = 2usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b2(&mut self, val: ::std::os::raw::c_uint) { - let mask = 2usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b3(&self) -> ::std::os::raw::c_uint { - let mask = 4usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 2usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b3(&mut self, val: ::std::os::raw::c_uint) { - let mask = 4usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 2usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b4(&self) -> ::std::os::raw::c_uint { - let mask = 8usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 3usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b4(&mut self, val: ::std::os::raw::c_uint) { - let mask = 8usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 3usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b5(&self) -> ::std::os::raw::c_uint { - let mask = 16usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 4usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b5(&mut self, val: ::std::os::raw::c_uint) { - let mask = 16usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 4usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b6(&self) -> ::std::os::raw::c_uint { - let mask = 32usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 5usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b6(&mut self, val: ::std::os::raw::c_uint) { - let mask = 32usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 5usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b7(&self) -> ::std::os::raw::c_uint { - let mask = 64usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 6usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b7(&mut self, val: ::std::os::raw::c_uint) { - let mask = 64usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 6usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b8(&self) -> ::std::os::raw::c_uint { - let mask = 128usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 7usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b8(&mut self, val: ::std::os::raw::c_uint) { - let mask = 128usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 7usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b9(&self) -> ::std::os::raw::c_uint { - let mask = 256usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 8usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b9(&mut self, val: ::std::os::raw::c_uint) { - let mask = 256usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 8usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b10(&self) -> ::std::os::raw::c_uint { - let mask = 512usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 9usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b10(&mut self, val: ::std::os::raw::c_uint) { - let mask = 512usize as u16; - let val = val as u32 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 9usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct B { - pub _bitfield_1: u32, - pub __bindgen_align: [u32; 0usize], -} -#[test] -fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); -} -impl Clone for B { - fn clone(&self) -> Self { *self } -} -impl B { - #[inline] - pub fn foo(&self) -> ::std::os::raw::c_uint { - let mask = 2147483647usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_foo(&mut self, val: ::std::os::raw::c_uint) { - let mask = 2147483647usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn bar(&self) -> ::std::os::raw::c_uchar { - let mask = 2147483648usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 31usize; - unsafe { ::std::mem::transmute(val as u8) } - } - #[inline] - pub fn set_bar(&mut self, val: ::std::os::raw::c_uchar) { - let mask = 2147483648usize as u32; - let val = val as u8 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 31usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct C { - pub x: ::std::os::raw::c_uchar, - pub _bitfield_1: u8, - pub baz: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . x as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( x ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . baz as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( baz ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } -} -impl C { - #[inline] - pub fn b1(&self) -> ::std::os::raw::c_uint { - let mask = 1usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b1(&mut self, val: ::std::os::raw::c_uint) { - let mask = 1usize as u8; - let val = val as u32 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b2(&self) -> ::std::os::raw::c_uint { - let mask = 2usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_b2(&mut self, val: ::std::os::raw::c_uint) { - let mask = 2usize as u8; - let val = val as u32 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Date1 { - pub _bitfield_1: [u8; 2usize], - pub _bitfield_2: u8, - pub __bindgen_align: [u16; 0usize], -} -#[test] -fn bindgen_test_layout_Date1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Date1 ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( - "Alignment of " , stringify ! ( Date1 ) )); -} -impl Clone for Date1 { - fn clone(&self) -> Self { *self } -} -impl Date1 { - #[inline] - pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort { - let mask = 7usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nWeekDay(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 7usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort { - let mask = 504usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 3usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nMonthDay(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 504usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 3usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn nMonth(&self) -> ::std::os::raw::c_ushort { - let mask = 15872usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 9usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nMonth(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 15872usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 9usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn nYear(&self) -> ::std::os::raw::c_ushort { - let mask = 255usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nYear(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 255usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; - } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Date2 { - pub _bitfield_1: [u8; 2usize], - pub _bitfield_2: u8, - pub byte: ::std::os::raw::c_uchar, - pub __bindgen_align: [u16; 0usize], -} -#[test] -fn bindgen_test_layout_Date2() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Date2 ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( - "Alignment of " , stringify ! ( Date2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Date2 ) ) . byte as * const _ as usize } - , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( Date2 ) , "::" , - stringify ! ( byte ) )); -} -impl Clone for Date2 { - fn clone(&self) -> Self { *self } -} -impl Date2 { - #[inline] - pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort { - let mask = 7usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nWeekDay(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 7usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort { - let mask = 504usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 3usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nMonthDay(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 504usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 3usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn nMonth(&self) -> ::std::os::raw::c_ushort { - let mask = 15872usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 9usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nMonth(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 15872usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 9usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn nYear(&self) -> ::std::os::raw::c_ushort { - let mask = 255usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_nYear(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 255usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct A { + pub x: ::std::os::raw::c_uchar, + pub _bitfield_1: [u8; 2usize], + pub y: ::std::os::raw::c_uchar, + pub __bindgen_align: [u32; 0usize], + } + #[test] + fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . x as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( x ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . y as * const _ as usize } , + 3usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( y ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } + impl A { + #[inline] + pub fn b1(&self) -> ::std::os::raw::c_uint { + let mask = 1usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b1(&mut self, val: ::std::os::raw::c_uint) { + let mask = 1usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b2(&self) -> ::std::os::raw::c_uint { + let mask = 2usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b2(&mut self, val: ::std::os::raw::c_uint) { + let mask = 2usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b3(&self) -> ::std::os::raw::c_uint { + let mask = 4usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b3(&mut self, val: ::std::os::raw::c_uint) { + let mask = 4usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 2usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b4(&self) -> ::std::os::raw::c_uint { + let mask = 8usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 3usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b4(&mut self, val: ::std::os::raw::c_uint) { + let mask = 8usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 3usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b5(&self) -> ::std::os::raw::c_uint { + let mask = 16usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 4usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b5(&mut self, val: ::std::os::raw::c_uint) { + let mask = 16usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 4usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b6(&self) -> ::std::os::raw::c_uint { + let mask = 32usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 5usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b6(&mut self, val: ::std::os::raw::c_uint) { + let mask = 32usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 5usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b7(&self) -> ::std::os::raw::c_uint { + let mask = 64usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 6usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b7(&mut self, val: ::std::os::raw::c_uint) { + let mask = 64usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 6usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b8(&self) -> ::std::os::raw::c_uint { + let mask = 128usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b8(&mut self, val: ::std::os::raw::c_uint) { + let mask = 128usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 7usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b9(&self) -> ::std::os::raw::c_uint { + let mask = 256usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 8usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b9(&mut self, val: ::std::os::raw::c_uint) { + let mask = 256usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 8usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b10(&self) -> ::std::os::raw::c_uint { + let mask = 512usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 9usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b10(&mut self, val: ::std::os::raw::c_uint) { + let mask = 512usize as u16; + let val = val as u32 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 9usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct B { + pub _bitfield_1: u32, + pub __bindgen_align: [u32; 0usize], + } + #[test] + fn bindgen_test_layout_B() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( B ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( B ) )); + } + impl Clone for B { + fn clone(&self) -> Self { *self } + } + impl B { + #[inline] + pub fn foo(&self) -> ::std::os::raw::c_uint { + let mask = 2147483647usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_foo(&mut self, val: ::std::os::raw::c_uint) { + let mask = 2147483647usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn bar(&self) -> ::std::os::raw::c_uchar { + let mask = 2147483648usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 31usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_bar(&mut self, val: ::std::os::raw::c_uchar) { + let mask = 2147483648usize as u32; + let val = val as u8 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 31usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct C { + pub x: ::std::os::raw::c_uchar, + pub _bitfield_1: u8, + pub baz: ::std::os::raw::c_uint, + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . x as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( x ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . baz as * const _ as usize } , + 4usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for C { + fn clone(&self) -> Self { *self } + } + impl C { + #[inline] + pub fn b1(&self) -> ::std::os::raw::c_uint { + let mask = 1usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b1(&mut self, val: ::std::os::raw::c_uint) { + let mask = 1usize as u8; + let val = val as u32 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b2(&self) -> ::std::os::raw::c_uint { + let mask = 2usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b2(&mut self, val: ::std::os::raw::c_uint) { + let mask = 2usize as u8; + let val = val as u32 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Date1 { + pub _bitfield_1: [u8; 2usize], + pub _bitfield_2: u8, + pub __bindgen_align: [u16; 0usize], + } + #[test] + fn bindgen_test_layout_Date1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Date1 ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( + "Alignment of " , stringify ! ( Date1 ) )); + } + impl Clone for Date1 { + fn clone(&self) -> Self { *self } + } + impl Date1 { + #[inline] + pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort { + let mask = 7usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nWeekDay(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 7usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort { + let mask = 504usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 3usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nMonthDay(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 504usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 3usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn nMonth(&self) -> ::std::os::raw::c_ushort { + let mask = 15872usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 9usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nMonth(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 15872usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 9usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn nYear(&self) -> ::std::os::raw::c_ushort { + let mask = 255usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nYear(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 255usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Date2 { + pub _bitfield_1: [u8; 2usize], + pub _bitfield_2: u8, + pub byte: ::std::os::raw::c_uchar, + pub __bindgen_align: [u16; 0usize], + } + #[test] + fn bindgen_test_layout_Date2() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Date2 ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( + "Alignment of " , stringify ! ( Date2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Date2 ) ) . byte as * const _ as + usize } , 3usize , concat ! ( + "Alignment of field: " , stringify ! ( Date2 ) , "::" , + stringify ! ( byte ) )); + } + impl Clone for Date2 { + fn clone(&self) -> Self { *self } + } + impl Date2 { + #[inline] + pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort { + let mask = 7usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nWeekDay(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 7usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort { + let mask = 504usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 3usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nMonthDay(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 504usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 3usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn nMonth(&self) -> ::std::os::raw::c_ushort { + let mask = 15872usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 9usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nMonth(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 15872usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 9usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn nYear(&self) -> ::std::os::raw::c_ushort { + let mask = 255usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_nYear(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 255usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } } } diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs index 16076f0c31..48d6426190 100644 --- a/tests/expectations/tests/bitfield_method_mangling.rs +++ b/tests/expectations/tests/bitfield_method_mangling.rs @@ -1,63 +1,67 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct mach_msg_type_descriptor_t { - pub _bitfield_1: u32, - pub __bindgen_align: [u32; 0usize], -} -#[test] -fn bindgen_test_layout_mach_msg_type_descriptor_t() { - assert_eq!(::std::mem::size_of::() , 4usize , - concat ! ( - "Size of: " , stringify ! ( mach_msg_type_descriptor_t ) )); - assert_eq! (::std::mem::align_of::() , 4usize - , concat ! ( - "Alignment of " , stringify ! ( mach_msg_type_descriptor_t ) - )); -} -impl Clone for mach_msg_type_descriptor_t { - fn clone(&self) -> Self { *self } -} -impl mach_msg_type_descriptor_t { - #[inline] - pub fn pad3(&self) -> ::std::os::raw::c_uint { - let mask = 16777215usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct mach_msg_type_descriptor_t { + pub _bitfield_1: u32, + pub __bindgen_align: [u32; 0usize], } - #[inline] - pub fn set_pad3(&mut self, val: ::std::os::raw::c_uint) { - let mask = 16777215usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[test] + fn bindgen_test_layout_mach_msg_type_descriptor_t() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( mach_msg_type_descriptor_t ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( mach_msg_type_descriptor_t + ) )); } - #[inline] - pub fn type_(&self) -> ::std::os::raw::c_uint { - let mask = 4278190080usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 24usize; - unsafe { ::std::mem::transmute(val as u32) } + impl Clone for mach_msg_type_descriptor_t { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn set_type(&mut self, val: ::std::os::raw::c_uint) { - let mask = 4278190080usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 24usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + impl mach_msg_type_descriptor_t { + #[inline] + pub fn pad3(&self) -> ::std::os::raw::c_uint { + let mask = 16777215usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_pad3(&mut self, val: ::std::os::raw::c_uint) { + let mask = 16777215usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn type_(&self) -> ::std::os::raw::c_uint { + let mask = 4278190080usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 24usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_type(&mut self, val: ::std::os::raw::c_uint) { + let mask = 4278190080usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 24usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } } } diff --git a/tests/expectations/tests/blocks.rs b/tests/expectations/tests/blocks.rs index 528ea5182a..ed102a4ca8 100644 --- a/tests/expectations/tests/blocks.rs +++ b/tests/expectations/tests/blocks.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn atexit_b(arg1: *mut ::std::os::raw::c_void); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn atexit_b(arg1: *mut ::std::os::raw::c_void); + } } diff --git a/tests/expectations/tests/builtin-template.rs b/tests/expectations/tests/builtin-template.rs index 44cda83cf4..1452df7ad9 100644 --- a/tests/expectations/tests/builtin-template.rs +++ b/tests/expectations/tests/builtin-template.rs @@ -1,7 +1,10 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type std_make_integer_sequence = u8; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type std_make_integer_sequence = u8; +} diff --git a/tests/expectations/tests/c-empty-layout.rs b/tests/expectations/tests/c-empty-layout.rs index 7dc16d489f..17087bea1e 100644 --- a/tests/expectations/tests/c-empty-layout.rs +++ b/tests/expectations/tests/c-empty-layout.rs @@ -1,20 +1,23 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo { -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 0usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Foo { + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 0usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/call-conv-field.rs b/tests/expectations/tests/call-conv-field.rs index d6aa9e4e31..85ce826aff 100644 --- a/tests/expectations/tests/call-conv-field.rs +++ b/tests/expectations/tests/call-conv-field.rs @@ -1,42 +1,46 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Copy)] -pub struct JNINativeInterface_ { - pub GetVersion: ::std::option::Option ::std::os::raw::c_int>, - pub __hack: ::std::os::raw::c_ulonglong, -} -#[test] -fn bindgen_test_layout_JNINativeInterface_() { - assert_eq!(::std::mem::size_of::() , 16usize , concat - ! ( "Size of: " , stringify ! ( JNINativeInterface_ ) )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( JNINativeInterface_ ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JNINativeInterface_ ) ) . GetVersion as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( JNINativeInterface_ ) , - "::" , stringify ! ( GetVersion ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JNINativeInterface_ ) ) . __hack as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( JNINativeInterface_ ) , - "::" , stringify ! ( __hack ) )); -} -impl Clone for JNINativeInterface_ { - fn clone(&self) -> Self { *self } -} -impl Default for JNINativeInterface_ { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -extern "stdcall" { - #[link_name = "_bar@0"] - pub fn bar(); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Copy)] + pub struct JNINativeInterface_ { + pub GetVersion: ::std::option::Option ::std::os::raw::c_int>, + pub __hack: ::std::os::raw::c_ulonglong, + } + #[test] + fn bindgen_test_layout_JNINativeInterface_() { + assert_eq!(::std::mem::size_of::() , 16usize , + concat ! ( + "Size of: " , stringify ! ( JNINativeInterface_ ) )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( JNINativeInterface_ ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const JNINativeInterface_ ) ) . GetVersion + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( JNINativeInterface_ + ) , "::" , stringify ! ( GetVersion ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const JNINativeInterface_ ) ) . __hack as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( JNINativeInterface_ + ) , "::" , stringify ! ( __hack ) )); + } + impl Clone for JNINativeInterface_ { + fn clone(&self) -> Self { *self } + } + impl Default for JNINativeInterface_ { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + extern "stdcall" { + #[link_name = "_bar@0"] + pub fn bar(); + } } diff --git a/tests/expectations/tests/canonical_path_without_namespacing.rs b/tests/expectations/tests/canonical_path_without_namespacing.rs index 43bec38d2f..ebd0a1d06f 100644 --- a/tests/expectations/tests/canonical_path_without_namespacing.rs +++ b/tests/expectations/tests/canonical_path_without_namespacing.rs @@ -1,25 +1,28 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Bar { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); -} -impl Clone for Bar { - fn clone(&self) -> Self { *self } -} -extern "C" { - #[link_name = "_Z3bazPN3foo3BarE"] - pub fn baz(arg1: *mut Bar); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + } + impl Clone for Bar { + fn clone(&self) -> Self { *self } + } + extern "C" { + #[link_name = "_Z3bazPN3foo3BarE"] + pub fn baz(arg1: *mut Bar); + } } diff --git a/tests/expectations/tests/char.rs b/tests/expectations/tests/char.rs index 5541d492c4..501a3bcf10 100644 --- a/tests/expectations/tests/char.rs +++ b/tests/expectations/tests/char.rs @@ -1,95 +1,98 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type Char = ::std::os::raw::c_char; -pub type SChar = ::std::os::raw::c_schar; -pub type UChar = ::std::os::raw::c_uchar; -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Test { - pub ch: ::std::os::raw::c_char, - pub u: ::std::os::raw::c_uchar, - pub d: ::std::os::raw::c_schar, - pub cch: ::std::os::raw::c_char, - pub cu: ::std::os::raw::c_uchar, - pub cd: ::std::os::raw::c_schar, - pub Cch: Char, - pub Cu: UChar, - pub Cd: SChar, - pub Ccch: Char, - pub Ccu: UChar, - pub Ccd: SChar, -} -#[test] -fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . ch as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( ch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . u as * const _ as usize } , - 1usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( u ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . d as * const _ as usize } , - 2usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cch as * const _ as usize } , - 3usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cu as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . cd as * const _ as usize } , - 5usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( cd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cch as * const _ as usize } , - 6usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cu as * const _ as usize } , - 7usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Cd as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Cd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccch as * const _ as usize } , - 9usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccch ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccu as * const _ as usize } , - 10usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccu ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . Ccd as * const _ as usize } , - 11usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( Ccd ) )); -} -impl Clone for Test { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type Char = ::std::os::raw::c_char; + pub type SChar = ::std::os::raw::c_schar; + pub type UChar = ::std::os::raw::c_uchar; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Test { + pub ch: ::std::os::raw::c_char, + pub u: ::std::os::raw::c_uchar, + pub d: ::std::os::raw::c_schar, + pub cch: ::std::os::raw::c_char, + pub cu: ::std::os::raw::c_uchar, + pub cd: ::std::os::raw::c_schar, + pub Cch: Char, + pub Cu: UChar, + pub Cd: SChar, + pub Ccch: Char, + pub Ccu: UChar, + pub Ccd: SChar, + } + #[test] + fn bindgen_test_layout_Test() { + assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( + "Size of: " , stringify ! ( Test ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Test ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . ch as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( ch ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . u as * const _ as usize } + , 1usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( u ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . d as * const _ as usize } + , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( d ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . cch as * const _ as usize + } , 3usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( cch ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . cu as * const _ as usize } + , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( cu ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . cd as * const _ as usize } + , 5usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( cd ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . Cch as * const _ as usize + } , 6usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( Cch ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . Cu as * const _ as usize } + , 7usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( Cu ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . Cd as * const _ as usize } + , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( Cd ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . Ccch as * const _ as usize + } , 9usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( Ccch ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . Ccu as * const _ as usize + } , 10usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( Ccu ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . Ccd as * const _ as usize + } , 11usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( Ccd ) )); + } + impl Clone for Test { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs index 56353a5e3a..4d4d5a4184 100644 --- a/tests/expectations/tests/class.rs +++ b/tests/expectations/tests/class.rs @@ -1,297 +1,313 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData); -impl __IncompleteArrayField { - #[inline] - pub fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut_ptr(&mut self) -> *mut T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) - } - #[inline] - pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + #[derive(Default)] + pub struct __IncompleteArrayField(::std::marker::PhantomData); + impl __IncompleteArrayField { + #[inline] + pub fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } } -} -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__IncompleteArrayField") + impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } } -} -impl ::std::clone::Clone for __IncompleteArrayField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __IncompleteArrayField { } -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") + impl ::std::clone::Clone for __IncompleteArrayField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __IncompleteArrayField { } + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + pub struct C { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . big_array as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( big_array ) )); + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + pub struct C_with_zero_length_array { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, + } + #[test] + fn bindgen_test_layout_C_with_zero_length_array() { + assert_eq!(::std::mem::size_of::() , 40usize + , concat ! ( + "Size of: " , stringify ! ( C_with_zero_length_array ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( C_with_zero_length_array ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . a as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + C_with_zero_length_array ) , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . + big_array as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + C_with_zero_length_array ) , "::" , stringify ! ( + big_array ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_with_zero_length_array ) ) . + zero_length_array as * const _ as usize } , 37usize , + concat ! ( + "Alignment of field: " , stringify ! ( + C_with_zero_length_array ) , "::" , stringify ! ( + zero_length_array ) )); + } + impl Default for C_with_zero_length_array { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + pub struct C_with_incomplete_array { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, + } + #[test] + fn bindgen_test_layout_C_with_incomplete_array() { + assert_eq!(::std::mem::size_of::() , 40usize + , concat ! ( + "Size of: " , stringify ! ( C_with_incomplete_array ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( C_with_incomplete_array ) + )); + } + impl Default for C_with_incomplete_array { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + pub struct C_with_zero_length_array_and_incomplete_array { + pub a: ::std::os::raw::c_int, + pub big_array: [::std::os::raw::c_char; 33usize], + pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, + pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, + } + #[test] + fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() { + assert_eq!(::std::mem::size_of::() + , 40usize , concat ! ( + "Size of: " , stringify ! ( + C_with_zero_length_array_and_incomplete_array ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + C_with_zero_length_array_and_incomplete_array ) )); + } + impl Default for C_with_zero_length_array_and_incomplete_array { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default)] + pub struct WithDtor { + pub b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_WithDtor() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( WithDtor ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithDtor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithDtor ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithDtor ) , "::" , + stringify ! ( b ) )); + } + #[repr(C)] + pub struct IncompleteArrayNonCopiable { + pub whatever: *mut ::std::os::raw::c_void, + pub incomplete_array: __IncompleteArrayField, + } + #[test] + fn bindgen_test_layout_IncompleteArrayNonCopiable() { + assert_eq!(::std::mem::size_of::() , + 8usize , concat ! ( + "Size of: " , stringify ! ( IncompleteArrayNonCopiable ) + )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( IncompleteArrayNonCopiable + ) )); + } + impl Default for IncompleteArrayNonCopiable { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Union { + pub d: __BindgenUnionField, + pub i: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_Union() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Union ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Union ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Union ) ) . d as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Union ) , "::" , + stringify ! ( d ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Union ) ) . i as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Union ) , "::" , + stringify ! ( i ) )); + } + impl Clone for Union { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct WithUnion { + pub data: Union, + } + #[test] + fn bindgen_test_layout_WithUnion() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( WithUnion ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( WithUnion ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithUnion ) ) . data as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithUnion ) , "::" + , stringify ! ( data ) )); + } + 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: + *const RealAbstractionWithTonsOfMethods); + } + extern "C" { + #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEv"] + pub fn RealAbstractionWithTonsOfMethods_bar1(this: + *mut RealAbstractionWithTonsOfMethods); + } + extern "C" { + #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEi"] + pub fn RealAbstractionWithTonsOfMethods_bar2(this: + *mut RealAbstractionWithTonsOfMethods, + foo: + ::std::os::raw::c_int); + } + extern "C" { + #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3staEv"] + pub fn RealAbstractionWithTonsOfMethods_sta(); + } + impl Clone for RealAbstractionWithTonsOfMethods { + fn clone(&self) -> Self { *self } + } + impl RealAbstractionWithTonsOfMethods { + #[inline] + pub unsafe fn bar(&self) { + RealAbstractionWithTonsOfMethods_bar(self) + } + #[inline] + pub unsafe fn bar1(&mut self) { + RealAbstractionWithTonsOfMethods_bar1(self) + } + #[inline] + pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { + RealAbstractionWithTonsOfMethods_bar2(self, foo) + } + #[inline] + pub unsafe fn sta() { RealAbstractionWithTonsOfMethods_sta() } } -} -#[repr(C)] -pub struct C { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . a as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . big_array as * const _ as usize } - , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( big_array ) )); -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -pub struct C_with_zero_length_array { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], - pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_zero_length_array() { - assert_eq!(::std::mem::size_of::() , 40usize , - concat ! ( - "Size of: " , stringify ! ( C_with_zero_length_array ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( C_with_zero_length_array ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_with_zero_length_array ) ) . a as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C_with_zero_length_array ) , "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_with_zero_length_array ) ) . big_array - as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C_with_zero_length_array ) , "::" , stringify ! ( big_array ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_with_zero_length_array ) ) . - zero_length_array as * const _ as usize } , 37usize , concat ! - ( - "Alignment of field: " , stringify ! ( - C_with_zero_length_array ) , "::" , stringify ! ( - zero_length_array ) )); -} -impl Default for C_with_zero_length_array { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -pub struct C_with_incomplete_array { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], - pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_incomplete_array() { - assert_eq!(::std::mem::size_of::() , 40usize , - concat ! ( - "Size of: " , stringify ! ( C_with_incomplete_array ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( C_with_incomplete_array ) )); -} -impl Default for C_with_incomplete_array { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -pub struct C_with_zero_length_array_and_incomplete_array { - pub a: ::std::os::raw::c_int, - pub big_array: [::std::os::raw::c_char; 33usize], - pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>, - pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>, -} -#[test] -fn bindgen_test_layout_C_with_zero_length_array_and_incomplete_array() { - assert_eq!(::std::mem::size_of::() - , 40usize , concat ! ( - "Size of: " , stringify ! ( - C_with_zero_length_array_and_incomplete_array ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - C_with_zero_length_array_and_incomplete_array ) )); -} -impl Default for C_with_zero_length_array_and_incomplete_array { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct WithDtor { - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_WithDtor() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( WithDtor ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithDtor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithDtor ) ) . b as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithDtor ) , "::" , - stringify ! ( b ) )); -} -#[repr(C)] -pub struct IncompleteArrayNonCopiable { - pub whatever: *mut ::std::os::raw::c_void, - pub incomplete_array: __IncompleteArrayField, -} -#[test] -fn bindgen_test_layout_IncompleteArrayNonCopiable() { - assert_eq!(::std::mem::size_of::() , 8usize , - concat ! ( - "Size of: " , stringify ! ( IncompleteArrayNonCopiable ) )); - assert_eq! (::std::mem::align_of::() , 8usize - , concat ! ( - "Alignment of " , stringify ! ( IncompleteArrayNonCopiable ) - )); -} -impl Default for IncompleteArrayNonCopiable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Union { - pub d: __BindgenUnionField, - pub i: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_Union() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Union ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Union ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Union ) ) . d as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Union ) , "::" , - stringify ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Union ) ) . i as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Union ) , "::" , - stringify ! ( i ) )); -} -impl Clone for Union { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct WithUnion { - pub data: Union, -} -#[test] -fn bindgen_test_layout_WithUnion() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( WithUnion ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithUnion ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithUnion ) ) . data as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithUnion ) , "::" , - stringify ! ( data ) )); -} -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: - *const RealAbstractionWithTonsOfMethods); -} -extern "C" { - #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEv"] - pub fn RealAbstractionWithTonsOfMethods_bar1(this: - *mut RealAbstractionWithTonsOfMethods); -} -extern "C" { - #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3barEi"] - pub fn RealAbstractionWithTonsOfMethods_bar2(this: - *mut RealAbstractionWithTonsOfMethods, - foo: ::std::os::raw::c_int); -} -extern "C" { - #[link_name = "_ZN32RealAbstractionWithTonsOfMethods3staEv"] - pub fn RealAbstractionWithTonsOfMethods_sta(); -} -impl Clone for RealAbstractionWithTonsOfMethods { - fn clone(&self) -> Self { *self } -} -impl RealAbstractionWithTonsOfMethods { - #[inline] - pub unsafe fn bar(&self) { RealAbstractionWithTonsOfMethods_bar(self) } - #[inline] - pub unsafe fn bar1(&mut self) { - RealAbstractionWithTonsOfMethods_bar1(self) - } - #[inline] - pub unsafe fn bar2(&mut self, foo: ::std::os::raw::c_int) { - RealAbstractionWithTonsOfMethods_bar2(self, foo) - } - #[inline] - pub unsafe fn sta() { RealAbstractionWithTonsOfMethods_sta() } } diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs index b92976f6a0..2ac306540b 100644 --- a/tests/expectations/tests/class_nested.rs +++ b/tests/expectations/tests/class_nested.rs @@ -1,129 +1,132 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 { - pub member_b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_A_B() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A_B ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A_B ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_B ) ) . member_b as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A_B ) , "::" , - stringify ! ( member_b ) )); -} -impl Clone for A_B { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A_C { - pub baz: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_A_C() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A_C ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A_C ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_C ) ) . baz as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A_C ) , "::" , - stringify ! ( baz ) )); -} -impl Clone for A_C { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct A_D { - pub foo: T, -} -impl Default for A_D { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . member_a as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( member_a ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } -} -extern "C" { - #[link_name = "var"] - pub static mut var: A_B; -} -#[test] -fn __bindgen_test_layout_A_D_instantiation_16() { - assert_eq!(::std::mem::size_of::>() , 4usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - A_D<::std::os::raw::c_int> ) )); - assert_eq!(::std::mem::align_of::>() , 4usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - A_D<::std::os::raw::c_int> ) )); -} -extern "C" { - #[link_name = "baz"] - pub static mut baz: A_D<::std::os::raw::c_int>; -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct D { - pub member: A_B, -} -#[test] -fn bindgen_test_layout_D() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const D ) ) . member as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( D ) , "::" , stringify - ! ( member ) )); -} -impl Clone for D { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Templated { - pub member: T, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Templated_Templated_inner { - pub member_ptr: *mut T, -} -impl Default for Templated_Templated_inner { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for Templated { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 { + pub member_b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_A_B() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A_B ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A_B ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A_B ) ) . member_b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A_B ) , "::" , + stringify ! ( member_b ) )); + } + impl Clone for A_B { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct A_C { + pub baz: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_A_C() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A_C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A_C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A_C ) ) . baz as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A_C ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for A_C { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct A_D { + pub foo: T, + } + impl Default for A_D { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . member_a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( member_a ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } + extern "C" { + #[link_name = "var"] + pub static mut var: A_B; + } + #[test] + fn __bindgen_test_layout_A_D_instantiation_17() { + assert_eq!(::std::mem::size_of::>() , + 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( + A_D<::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::>() , + 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + A_D<::std::os::raw::c_int> ) )); + } + extern "C" { + #[link_name = "baz"] + pub static mut baz: A_D<::std::os::raw::c_int>; + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct D { + pub member: A_B, + } + #[test] + fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( D ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( D ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const D ) ) . member as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( D ) , "::" , + stringify ! ( member ) )); + } + impl Clone for D { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Templated { + pub member: T, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Templated_Templated_inner { + pub member_ptr: *mut T, + } + impl Default for Templated_Templated_inner { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl Default for Templated { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/class_no_members.rs b/tests/expectations/tests/class_no_members.rs index ad532100ec..5d7caf1da3 100644 --- a/tests/expectations/tests/class_no_members.rs +++ b/tests/expectations/tests/class_no_members.rs @@ -1,60 +1,64 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct whatever { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_whatever() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( whatever ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( whatever ) )); -} -impl Clone for whatever { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct whatever_child { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_whatever_child() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( whatever_child ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( whatever_child ) )); -} -impl Clone for whatever_child { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct whatever_child_with_member { - pub m_member: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_whatever_child_with_member() { - assert_eq!(::std::mem::size_of::() , 4usize , - concat ! ( - "Size of: " , stringify ! ( whatever_child_with_member ) )); - assert_eq! (::std::mem::align_of::() , 4usize - , concat ! ( - "Alignment of " , stringify ! ( whatever_child_with_member ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const whatever_child_with_member ) ) . m_member - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - whatever_child_with_member ) , "::" , stringify ! ( m_member ) - )); -} -impl Clone for whatever_child_with_member { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct whatever { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_whatever() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( whatever ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( whatever ) )); + } + impl Clone for whatever { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct whatever_child { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_whatever_child() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! + ( "Size of: " , stringify ! ( whatever_child ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat + ! ( "Alignment of " , stringify ! ( whatever_child ) )); + } + impl Clone for whatever_child { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct whatever_child_with_member { + pub m_member: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_whatever_child_with_member() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( whatever_child_with_member ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( whatever_child_with_member + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const whatever_child_with_member ) ) . + m_member as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + whatever_child_with_member ) , "::" , stringify ! ( + m_member ) )); + } + impl Clone for whatever_child_with_member { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/class_static.rs b/tests/expectations/tests/class_static.rs index 521621a760..613666e23c 100644 --- a/tests/expectations/tests/class_static.rs +++ b/tests/expectations/tests/class_static.rs @@ -1,34 +1,38 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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; -} -extern "C" { - #[link_name = "_ZN7MyClass26example_check_no_collisionE"] - pub static mut MyClass_example_check_no_collision: - *const ::std::os::raw::c_int; -} -#[test] -fn bindgen_test_layout_MyClass() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( MyClass ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( MyClass ) )); -} -impl Clone for MyClass { - fn clone(&self) -> Self { *self } -} -extern "C" { - #[link_name = "_ZL26example_check_no_collision"] - pub static mut example_check_no_collision: *const ::std::os::raw::c_int; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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; + } + extern "C" { + #[link_name = "_ZN7MyClass26example_check_no_collisionE"] + pub static mut MyClass_example_check_no_collision: + *const ::std::os::raw::c_int; + } + #[test] + fn bindgen_test_layout_MyClass() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( MyClass ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( MyClass ) )); + } + impl Clone for MyClass { + fn clone(&self) -> Self { *self } + } + extern "C" { + #[link_name = "_ZL26example_check_no_collision"] + pub static mut example_check_no_collision: + *const ::std::os::raw::c_int; + } } diff --git a/tests/expectations/tests/class_static_const.rs b/tests/expectations/tests/class_static_const.rs index 4b0108a17d..88521bbc87 100644 --- a/tests/expectations/tests/class_static_const.rs +++ b/tests/expectations/tests/class_static_const.rs @@ -1,24 +1,27 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index f4db9013cb..20d35e7a6c 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -1,49 +1,52 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** *
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct whatever { - pub replacement: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_whatever() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( whatever ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( whatever ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const whatever ) ) . replacement as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( whatever ) , "::" , - stringify ! ( replacement ) )); -} -impl Clone for whatever { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct container { - pub c: whatever, -} -#[test] -fn bindgen_test_layout_container() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( container ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( container ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const container ) ) . c as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( container ) , "::" , - stringify ! ( c ) )); -} -impl Clone for container { - fn clone(&self) -> Self { *self } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct whatever { + pub replacement: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_whatever() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( whatever ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( whatever ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const whatever ) ) . replacement as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( whatever ) , "::" , + stringify ! ( replacement ) )); + } + impl Clone for whatever { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct container { + pub c: whatever, + } + #[test] + fn bindgen_test_layout_container() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( container ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( container ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const container ) ) . c as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( container ) , "::" + , stringify ! ( c ) )); + } + impl Clone for container { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs index 495889f256..a1da804307 100644 --- a/tests/expectations/tests/class_with_dtor.rs +++ b/tests/expectations/tests/class_with_dtor.rs @@ -1,46 +1,49 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug)] -pub struct HandleWithDtor { - pub ptr: *mut T, -} -impl Default for HandleWithDtor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>; -#[repr(C)] -#[derive(Debug)] -pub struct WithoutDtor { - pub shouldBeWithDtor: HandleValue, -} -#[test] -fn bindgen_test_layout_WithoutDtor() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( WithoutDtor ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( WithoutDtor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithoutDtor ) ) . shouldBeWithDtor as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithoutDtor ) , "::" , - stringify ! ( shouldBeWithDtor ) )); -} -impl Default for WithoutDtor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn __bindgen_test_layout_HandleWithDtor_instantiation_10() { - assert_eq!(::std::mem::size_of::>() - , 8usize , concat ! ( - "Size of template specialization: " , stringify ! ( - HandleWithDtor<::std::os::raw::c_int> ) )); - assert_eq!(::std::mem::align_of::>() - , 8usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - HandleWithDtor<::std::os::raw::c_int> ) )); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug)] + pub struct HandleWithDtor { + pub ptr: *mut T, + } + impl Default for HandleWithDtor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>; + #[repr(C)] + #[derive(Debug)] + pub struct WithoutDtor { + pub shouldBeWithDtor: HandleValue, + } + #[test] + fn bindgen_test_layout_WithoutDtor() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( WithoutDtor ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( WithoutDtor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithoutDtor ) ) . shouldBeWithDtor as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithoutDtor ) , + "::" , stringify ! ( shouldBeWithDtor ) )); + } + impl Default for WithoutDtor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn __bindgen_test_layout_HandleWithDtor_instantiation_11() { + assert_eq!(::std::mem::size_of::>() + , 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + HandleWithDtor<::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::>() + , 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + HandleWithDtor<::std::os::raw::c_int> ) )); + } } diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/tests/expectations/tests/class_with_inner_struct.rs index a99aada553..a6a725b10c 100644 --- a/tests/expectations/tests/class_with_inner_struct.rs +++ b/tests/expectations/tests/class_with_inner_struct.rs @@ -1,324 +1,339 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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, + } + #[test] + fn bindgen_test_layout_A_Segment() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( A_Segment ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A_Segment ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A_Segment ) ) . begin as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A_Segment ) , "::" + , stringify ! ( begin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A_Segment ) ) . end as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( A_Segment ) , "::" + , stringify ! ( end ) )); + } + impl Clone for A_Segment { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct A__bindgen_ty_1 { + pub f: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_A__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , concat + ! ( "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( A__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A__bindgen_ty_1 ) ) . f as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A__bindgen_ty_1 ) , + "::" , stringify ! ( f ) )); + } + impl Clone for A__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct A__bindgen_ty_2 { + pub d: __BindgenUnionField<::std::os::raw::c_int>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_A__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize , concat + ! ( "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( A__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A__bindgen_ty_2 ) ) . d as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A__bindgen_ty_2 ) , + "::" , stringify ! ( d ) )); + } + impl Clone for A__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::
() , 12usize , concat ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . c as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( c ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . named_union as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( named_union ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } + #[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, + } + #[test] + fn bindgen_test_layout_B_Segment() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( B_Segment ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( B_Segment ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const B_Segment ) ) . begin as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( B_Segment ) , "::" + , stringify ! ( begin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const B_Segment ) ) . end as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( B_Segment ) , "::" + , stringify ! ( end ) )); + } + impl Clone for B_Segment { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_B() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( B ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( B ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const B ) ) . d as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( B ) , "::" , + stringify ! ( d ) )); + } + impl Clone for B { + fn clone(&self) -> Self { *self } + } + #[repr(i32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum StepSyntax { + Keyword = 0, + FunctionalWithoutKeyword = 1, + FunctionalWithStartKeyword = 2, + FunctionalWithEndKeyword = 3, + } + #[repr(C)] + #[derive(Debug, 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, + pub mX2: f32, + pub mY2: f32, + } + #[test] + fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 16usize , concat ! ( + "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . + mX1 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . + mY1 as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . + mX2 as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX2 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . + mY2 as * const _ as usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY2 + ) )); + } + impl Clone for C__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct C__bindgen_ty_1__bindgen_ty_2 { + pub mStepSyntax: StepSyntax, + pub mSteps: ::std::os::raw::c_uint, + } + #[test] + fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 8usize , concat ! ( + "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . + mStepSyntax as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + mStepSyntax ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . + mSteps as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + mSteps ) )); + } + impl Clone for C__bindgen_ty_1__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + impl Default for C__bindgen_ty_1__bindgen_ty_2 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn bindgen_test_layout_C__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 16usize , concat + ! ( "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( C__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C__bindgen_ty_1 ) ) . mFunc as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C__bindgen_ty_1 ) , + "::" , stringify ! ( mFunc ) )); + } + impl Clone for C__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct C_Segment { + pub begin: ::std::os::raw::c_int, + pub end: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_C_Segment() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( C_Segment ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C_Segment ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_Segment ) ) . begin as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C_Segment ) , "::" + , stringify ! ( begin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C_Segment ) ) . end as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( C_Segment ) , "::" + , stringify ! ( end ) )); + } + impl Clone for C_Segment { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 20usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . d as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( d ) )); + } + impl Clone for C { + 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, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A_Segment { - pub begin: ::std::os::raw::c_int, - pub end: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_A_Segment() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( A_Segment ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( A_Segment ) , "::" , - stringify ! ( end ) )); -} -impl Clone for A_Segment { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A__bindgen_ty_1 { - pub f: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_A__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! - ( "Alignment of " , stringify ! ( A__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A__bindgen_ty_1 ) ) . f as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A__bindgen_ty_1 ) , - "::" , stringify ! ( f ) )); -} -impl Clone for A__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A__bindgen_ty_2 { - pub d: __BindgenUnionField<::std::os::raw::c_int>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_A__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! - ( "Alignment of " , stringify ! ( A__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A__bindgen_ty_2 ) ) . d as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A__bindgen_ty_2 ) , - "::" , stringify ! ( d ) )); -} -impl Clone for A__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { & ( * ( 0 as * const A ) ) . c as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( c ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . named_union as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( named_union ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } -} -#[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, -} -#[test] -fn bindgen_test_layout_B_Segment() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( B_Segment ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( B_Segment ) , "::" , - stringify ! ( end ) )); -} -impl Clone for B_Segment { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); - assert_eq! (unsafe { & ( * ( 0 as * const B ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( B ) , "::" , stringify - ! ( d ) )); -} -impl Clone for B { - fn clone(&self) -> Self { *self } -} -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum StepSyntax { - Keyword = 0, - FunctionalWithoutKeyword = 1, - FunctionalWithStartKeyword = 2, - FunctionalWithEndKeyword = 3, -} -#[repr(C)] -#[derive(Debug, 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, - pub mX2: f32, - pub mY2: f32, -} -#[test] -fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_1 - ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY1 - as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mX2 - as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mX2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_1 ) ) . mY2 - as * const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( mY2 ) - )); -} -impl Clone for C__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct C__bindgen_ty_1__bindgen_ty_2 { - pub mStepSyntax: StepSyntax, - pub mSteps: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_C__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , 8usize - , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , - 4usize , concat ! ( - "Alignment of " , stringify ! ( C__bindgen_ty_1__bindgen_ty_2 - ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . - mStepSyntax as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( - mStepSyntax ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1__bindgen_ty_2 ) ) . - mSteps as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - C__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( mSteps - ) )); -} -impl Clone for C__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -impl Default for C__bindgen_ty_1__bindgen_ty_2 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn bindgen_test_layout_C__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! - ( "Alignment of " , stringify ! ( C__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C__bindgen_ty_1 ) ) . mFunc as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C__bindgen_ty_1 ) , - "::" , stringify ! ( mFunc ) )); -} -impl Clone for C__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct C_Segment { - pub begin: ::std::os::raw::c_int, - pub end: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_C_Segment() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C_Segment ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C_Segment ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_Segment ) ) . begin as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C_Segment ) , "::" , - stringify ! ( begin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C_Segment ) ) . end as * const _ as usize - } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C_Segment ) , "::" , - stringify ! ( end ) )); -} -impl Clone for C_Segment { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 20usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( d ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/class_with_typedef.rs b/tests/expectations/tests/class_with_typedef.rs index 642a72875f..410e425d0e 100644 --- a/tests/expectations/tests/class_with_typedef.rs +++ b/tests/expectations/tests/class_with_typedef.rs @@ -1,110 +1,115 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type AnotherInt = ::std::os::raw::c_int; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct C { - pub c: C_MyInt, - pub ptr: *mut C_MyInt, - pub arr: [C_MyInt; 10usize], - pub d: AnotherInt, - pub other_ptr: *mut AnotherInt, -} -pub type C_MyInt = ::std::os::raw::c_int; -pub type C_Lookup = *const ::std::os::raw::c_char; -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 72usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . c as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( c ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . ptr as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( ptr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( arr ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . d as * const _ as usize - } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( d ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . other_ptr as * const _ as usize } - , 64usize , concat ! ( - "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 } -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl C { - #[inline] - pub unsafe fn method(&mut self, c: C_MyInt) { C_method(self, c) } - #[inline] - pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) { - C_methodRef(self, c) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type AnotherInt = ::std::os::raw::c_int; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct C { + pub c: C_MyInt, + pub ptr: *mut C_MyInt, + pub arr: [C_MyInt; 10usize], + pub d: AnotherInt, + pub other_ptr: *mut AnotherInt, } - #[inline] - pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) { - C_complexMethodRef(self, c) + 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 ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . c as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( c ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . ptr as * const _ as usize } , + 8usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( ptr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , + 16usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( arr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . d as * const _ as usize } , + 56usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( d ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . other_ptr as * const _ as + usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( other_ptr ) )); } - #[inline] - pub unsafe fn anotherMethod(&mut self, c: AnotherInt) { - C_anotherMethod(self, c) + extern "C" { + #[link_name = "_ZN1C6methodEi"] + pub fn C_method(this: *mut C, c: C_MyInt); + } + extern "C" { + #[link_name = "_ZN1C9methodRefERi"] + pub fn C_methodRef(this: *mut C, c: *mut C_MyInt); + } + extern "C" { + #[link_name = "_ZN1C16complexMethodRefERPKc"] + pub fn C_complexMethodRef(this: *mut C, c: *mut C_Lookup); + } + extern "C" { + #[link_name = "_ZN1C13anotherMethodEi"] + pub fn C_anotherMethod(this: *mut C, c: AnotherInt); + } + impl Clone for C { + fn clone(&self) -> Self { *self } + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl C { + #[inline] + pub unsafe fn method(&mut self, c: C_MyInt) { C_method(self, c) } + #[inline] + pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) { + C_methodRef(self, c) + } + #[inline] + pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) { + C_complexMethodRef(self, c) + } + #[inline] + pub unsafe fn anotherMethod(&mut self, c: AnotherInt) { + C_anotherMethod(self, c) + } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct D { + pub _base: C, + pub ptr: *mut C_MyInt, + } + #[test] + fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::() , 80usize , concat ! ( + "Size of: " , stringify ! ( D ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( D ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const D ) ) . ptr as * const _ as usize } , + 72usize , concat ! ( + "Alignment of field: " , stringify ! ( D ) , "::" , + stringify ! ( ptr ) )); + } + impl Clone for D { + fn clone(&self) -> Self { *self } + } + impl Default for D { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct D { - pub _base: C, - pub ptr: *mut C_MyInt, -} -#[test] -fn bindgen_test_layout_D() { - assert_eq!(::std::mem::size_of::() , 80usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const D ) ) . ptr as * const _ as usize } , - 72usize , concat ! ( - "Alignment of field: " , stringify ! ( D ) , "::" , stringify - ! ( ptr ) )); -} -impl Clone for D { - fn clone(&self) -> Self { *self } -} -impl Default for D { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/complex.rs b/tests/expectations/tests/complex.rs index d250f6b118..a0ec255fe7 100644 --- a/tests/expectations/tests/complex.rs +++ b/tests/expectations/tests/complex.rs @@ -1,98 +1,101 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] -#[repr(C)] -pub struct __BindgenComplex { - pub re: T, - pub im: T, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct TestDouble { - pub mMember: __BindgenComplex, -} -#[test] -fn bindgen_test_layout_TestDouble() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( TestDouble ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( TestDouble ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestDouble ) ) . mMember as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestDouble ) , "::" , - stringify ! ( mMember ) )); -} -impl Clone for TestDouble { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct TestDoublePtr { - pub mMember: *mut __BindgenComplex, -} -#[test] -fn bindgen_test_layout_TestDoublePtr() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestDoublePtr ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( TestDoublePtr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestDoublePtr ) ) . mMember as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestDoublePtr ) , "::" - , stringify ! ( mMember ) )); -} -impl Clone for TestDoublePtr { - fn clone(&self) -> Self { *self } -} -impl Default for TestDoublePtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct TestFloat { - pub mMember: __BindgenComplex, -} -#[test] -fn bindgen_test_layout_TestFloat() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestFloat ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( TestFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestFloat ) ) . mMember as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestFloat ) , "::" , - stringify ! ( mMember ) )); -} -impl Clone for TestFloat { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct TestFloatPtr { - pub mMember: *mut __BindgenComplex, -} -#[test] -fn bindgen_test_layout_TestFloatPtr() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( TestFloatPtr ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( TestFloatPtr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const TestFloatPtr ) ) . mMember as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( TestFloatPtr ) , "::" , - stringify ! ( mMember ) )); -} -impl Clone for TestFloatPtr { - fn clone(&self) -> Self { *self } -} -impl Default for TestFloatPtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] + #[repr(C)] + pub struct __BindgenComplex { + pub re: T, + pub im: T, + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct TestDouble { + pub mMember: __BindgenComplex, + } + #[test] + fn bindgen_test_layout_TestDouble() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( TestDouble ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( TestDouble ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const TestDouble ) ) . mMember as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( TestDouble ) , "::" + , stringify ! ( mMember ) )); + } + impl Clone for TestDouble { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct TestDoublePtr { + pub mMember: *mut __BindgenComplex, + } + #[test] + fn bindgen_test_layout_TestDoublePtr() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! + ( "Size of: " , stringify ! ( TestDoublePtr ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat + ! ( "Alignment of " , stringify ! ( TestDoublePtr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const TestDoublePtr ) ) . mMember as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( TestDoublePtr ) , + "::" , stringify ! ( mMember ) )); + } + impl Clone for TestDoublePtr { + fn clone(&self) -> Self { *self } + } + impl Default for TestDoublePtr { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct TestFloat { + pub mMember: __BindgenComplex, + } + #[test] + fn bindgen_test_layout_TestFloat() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( TestFloat ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( TestFloat ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const TestFloat ) ) . mMember as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( TestFloat ) , "::" + , stringify ! ( mMember ) )); + } + impl Clone for TestFloat { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct TestFloatPtr { + pub mMember: *mut __BindgenComplex, + } + #[test] + fn bindgen_test_layout_TestFloatPtr() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( TestFloatPtr ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( TestFloatPtr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const TestFloatPtr ) ) . mMember as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( TestFloatPtr ) , + "::" , stringify ! ( mMember ) )); + } + impl Clone for TestFloatPtr { + fn clone(&self) -> Self { *self } + } + impl Default for TestFloatPtr { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/complex_global.rs b/tests/expectations/tests/complex_global.rs index badc4d1f31..ac4a98a8e7 100644 --- a/tests/expectations/tests/complex_global.rs +++ b/tests/expectations/tests/complex_global.rs @@ -1,24 +1,27 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] -#[repr(C)] -pub struct __BindgenComplex { - pub re: T, - pub im: T, -} -extern "C" { - #[link_name = "globalValueFloat"] - pub static mut globalValueFloat: __BindgenComplex; -} -extern "C" { - #[link_name = "globalValueDouble"] - pub static mut globalValueDouble: __BindgenComplex; -} -extern "C" { - #[link_name = "globalValueLongDouble"] - pub static mut globalValueLongDouble: __BindgenComplex; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] + #[repr(C)] + pub struct __BindgenComplex { + pub re: T, + pub im: T, + } + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "globalValueFloat"] + pub static mut globalValueFloat: __BindgenComplex; + } + extern "C" { + #[link_name = "globalValueDouble"] + pub static mut globalValueDouble: __BindgenComplex; + } + extern "C" { + #[link_name = "globalValueLongDouble"] + pub static mut globalValueLongDouble: __BindgenComplex; + } } diff --git a/tests/expectations/tests/const_array_fn_arg.rs b/tests/expectations/tests/const_array_fn_arg.rs index 623d28b202..b8b09c7670 100644 --- a/tests/expectations/tests/const_array_fn_arg.rs +++ b/tests/expectations/tests/const_array_fn_arg.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn f(a: *const ::std::os::raw::c_int); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn f(a: *const ::std::os::raw::c_int); + } } diff --git a/tests/expectations/tests/const_bool.rs b/tests/expectations/tests/const_bool.rs index de9e81b02e..489166fa95 100644 --- a/tests/expectations/tests/const_bool.rs +++ b/tests/expectations/tests/const_bool.rs @@ -1,25 +1,28 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const k: bool = true; -#[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 ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const k: bool = true; + #[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 ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } + pub type foo = bool; + pub const k2: foo = true; } -pub type foo = bool; -pub const k2: foo = true; diff --git a/tests/expectations/tests/const_enum_unnamed.rs b/tests/expectations/tests/const_enum_unnamed.rs index b6f61b356d..71a544cb55 100644 --- a/tests/expectations/tests/const_enum_unnamed.rs +++ b/tests/expectations/tests/const_enum_unnamed.rs @@ -1,30 +1,33 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const FOO_BAR: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAR; -pub const FOO_BAZ: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAZ; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { FOO_BAR = 0, FOO_BAZ = 1, } -#[repr(C)] -#[derive(Debug, 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 ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const FOO_BAR: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAR; + pub const FOO_BAZ: _bindgen_ty_1 = _bindgen_ty_1::FOO_BAZ; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { FOO_BAR = 0, FOO_BAZ = 1, } + #[repr(C)] + #[derive(Debug, 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 ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/const_ptr.rs b/tests/expectations/tests/const_ptr.rs index 89400df17c..3825c97537 100644 --- a/tests/expectations/tests/const_ptr.rs +++ b/tests/expectations/tests/const_ptr.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn foo(bar: *const ::std::os::raw::c_void); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn foo(bar: *const ::std::os::raw::c_void); + } } diff --git a/tests/expectations/tests/const_resolved_ty.rs b/tests/expectations/tests/const_resolved_ty.rs index 77d8f43823..a5e2b5e5af 100644 --- a/tests/expectations/tests/const_resolved_ty.rs +++ b/tests/expectations/tests/const_resolved_ty.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn foo(foo: *const u8); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn foo(foo: *const u8); + } } diff --git a/tests/expectations/tests/const_tparam.rs b/tests/expectations/tests/const_tparam.rs index f47ca08244..74626a5ef2 100644 --- a/tests/expectations/tests/const_tparam.rs +++ b/tests/expectations/tests/const_tparam.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct C { - pub foo: *const T, - pub bar: *mut T, -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct C { + pub foo: *const T, + pub bar: *mut T, + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/constant-evaluate.rs b/tests/expectations/tests/constant-evaluate.rs index cdf097a2d8..a712c95863 100644 --- a/tests/expectations/tests/constant-evaluate.rs +++ b/tests/expectations/tests/constant-evaluate.rs @@ -1,20 +1,23 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo; -pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { foo = 4, bar = 8, } -pub type EasyToOverflow = ::std::os::raw::c_ulonglong; -pub const k: EasyToOverflow = 2147483648; -pub const k_expr: EasyToOverflow = 0; -pub const BAZ: ::std::os::raw::c_longlong = 24; -pub const fuzz: f64 = 51.; -pub const BAZZ: ::std::os::raw::c_char = 53; -pub const WAT: ::std::os::raw::c_char = 0; -pub const bytestring: &'static [u8; 4usize] = b"Foo\x00"; -pub const NOT_UTF8: [u8; 5usize] = [240, 40, 140, 40, 0]; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo; + pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { foo = 4, bar = 8, } + pub type EasyToOverflow = ::std::os::raw::c_ulonglong; + pub const k: EasyToOverflow = 2147483648; + pub const k_expr: EasyToOverflow = 0; + pub const BAZ: ::std::os::raw::c_longlong = 24; + pub const fuzz: f64 = 51.; + pub const BAZZ: ::std::os::raw::c_char = 53; + pub const WAT: ::std::os::raw::c_char = 0; + pub const bytestring: &'static [u8; 4usize] = b"Foo\x00"; + pub const NOT_UTF8: [u8; 5usize] = [240, 40, 140, 40, 0]; +} diff --git a/tests/expectations/tests/constant-non-specialized-tp.rs b/tests/expectations/tests/constant-non-specialized-tp.rs index a17e261ba7..785b3cd45c 100644 --- a/tests/expectations/tests/constant-non-specialized-tp.rs +++ b/tests/expectations/tests/constant-non-specialized-tp.rs @@ -1,21 +1,24 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Test { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Outer { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Outer_Inner { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Test { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Outer { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Outer_Inner { + pub _address: u8, + } } diff --git a/tests/expectations/tests/constify-all-enums.rs b/tests/expectations/tests/constify-all-enums.rs index e1210d9a1f..07e9eb5bdf 100644 --- a/tests/expectations/tests/constify-all-enums.rs +++ b/tests/expectations/tests/constify-all-enums.rs @@ -1,33 +1,36 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const foo_THIS: foo = 0; -pub const foo_SHOULD_BE: foo = 1; -pub const foo_A_CONSTANT: foo = 2; -pub type foo = ::std::os::raw::c_uint; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct bar { - pub this_should_work: foo, -} -#[test] -fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . this_should_work as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( this_should_work ) )); -} -impl Clone for bar { - fn clone(&self) -> Self { *self } -} -impl Default for bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const foo_THIS: foo = 0; + pub const foo_SHOULD_BE: foo = 1; + pub const foo_A_CONSTANT: foo = 2; + pub type foo = ::std::os::raw::c_uint; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct bar { + pub this_should_work: foo, + } + #[test] + fn bindgen_test_layout_bar() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( bar ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . this_should_work as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( bar ) , "::" , + stringify ! ( this_should_work ) )); + } + impl Clone for bar { + fn clone(&self) -> Self { *self } + } + impl Default for bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs index 989c5197ac..a1853a3d56 100644 --- a/tests/expectations/tests/constify-enum.rs +++ b/tests/expectations/tests/constify-enum.rs @@ -1,20 +1,23 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const nsCSSPropertyID_eCSSProperty_COUNT_unexistingVariantValue: - nsCSSPropertyID = - nsCSSPropertyID::eCSSProperty_COUNT_unexistingVariantValue; -pub const nsCSSPropertyID_eCSSProperty_COUNT: nsCSSPropertyID = - nsCSSPropertyID::eCSSPropertyAlias_aa; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum nsCSSPropertyID { - eCSSProperty_a = 0, - eCSSProperty_b = 1, - eCSSPropertyAlias_aa = 2, - eCSSPropertyAlias_bb = 3, - eCSSProperty_COUNT_unexistingVariantValue = 4, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const nsCSSPropertyID_eCSSProperty_COUNT_unexistingVariantValue: + nsCSSPropertyID = + nsCSSPropertyID::eCSSProperty_COUNT_unexistingVariantValue; + pub const nsCSSPropertyID_eCSSProperty_COUNT: nsCSSPropertyID = + nsCSSPropertyID::eCSSPropertyAlias_aa; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum nsCSSPropertyID { + eCSSProperty_a = 0, + eCSSProperty_b = 1, + eCSSPropertyAlias_aa = 2, + eCSSPropertyAlias_bb = 3, + eCSSProperty_COUNT_unexistingVariantValue = 4, + } } diff --git a/tests/expectations/tests/constructor-tp.rs b/tests/expectations/tests/constructor-tp.rs index 6ba52f22d1..a371b2445f 100644 --- a/tests/expectations/tests/constructor-tp.rs +++ b/tests/expectations/tests/constructor-tp.rs @@ -1,38 +1,41 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Bar { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( 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 } -} -impl Bar { - #[inline] - pub unsafe fn new() -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - Bar_Bar(&mut __bindgen_tmp); - __bindgen_tmp +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Foo { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( 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 } + } + impl Bar { + #[inline] + pub unsafe fn new() -> Self { + let mut __bindgen_tmp = ::std::mem::uninitialized(); + Bar_Bar(&mut __bindgen_tmp); + __bindgen_tmp + } } } diff --git a/tests/expectations/tests/constructors.rs b/tests/expectations/tests/constructors.rs index 13a4dcf877..2a17e84323 100644 --- a/tests/expectations/tests/constructors.rs +++ b/tests/expectations/tests/constructors.rs @@ -1,71 +1,75 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct TestOverload { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_TestOverload() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( 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 } -} -impl TestOverload { - #[inline] - pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - TestOverload_TestOverload(&mut __bindgen_tmp, arg1); - __bindgen_tmp +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct TestOverload { + pub _address: u8, } - #[inline] - pub unsafe fn new1(arg1: f64) -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - TestOverload_TestOverload1(&mut __bindgen_tmp, arg1); - __bindgen_tmp + #[test] + fn bindgen_test_layout_TestOverload() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( TestOverload ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! + ( "Alignment of " , stringify ! ( TestOverload ) )); } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct TestPublicNoArgs { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_TestPublicNoArgs() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( 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 } -} -impl TestPublicNoArgs { - #[inline] - pub unsafe fn new() -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp); - __bindgen_tmp + 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 } + } + impl TestOverload { + #[inline] + pub unsafe fn new(arg1: ::std::os::raw::c_int) -> Self { + let mut __bindgen_tmp = ::std::mem::uninitialized(); + TestOverload_TestOverload(&mut __bindgen_tmp, arg1); + __bindgen_tmp + } + #[inline] + pub unsafe fn new1(arg1: f64) -> Self { + let mut __bindgen_tmp = ::std::mem::uninitialized(); + TestOverload_TestOverload1(&mut __bindgen_tmp, arg1); + __bindgen_tmp + } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct TestPublicNoArgs { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_TestPublicNoArgs() { + assert_eq!(::std::mem::size_of::() , 1usize , concat + ! ( "Size of: " , stringify ! ( 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 } + } + impl TestPublicNoArgs { + #[inline] + pub unsafe fn new() -> Self { + let mut __bindgen_tmp = ::std::mem::uninitialized(); + TestPublicNoArgs_TestPublicNoArgs(&mut __bindgen_tmp); + __bindgen_tmp + } } } diff --git a/tests/expectations/tests/convert-floats.rs b/tests/expectations/tests/convert-floats.rs index ba35da3314..e16e9cbd4c 100644 --- a/tests/expectations/tests/convert-floats.rs +++ b/tests/expectations/tests/convert-floats.rs @@ -1,65 +1,68 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] -#[repr(C)] -pub struct __BindgenComplex { - pub re: T, - pub im: T, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct foo { - pub bar: ::std::os::raw::c_float, - pub baz: ::std::os::raw::c_float, - pub bazz: ::std::os::raw::c_double, - pub bazzz: *mut ::std::os::raw::c_double, - pub complexFloat: __BindgenComplex<::std::os::raw::c_float>, - pub complexDouble: __BindgenComplex<::std::os::raw::c_double>, -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 48usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( baz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bazz as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bazz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bazzz as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bazzz ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . complexFloat as * const _ as - usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( complexFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . complexDouble as * const _ as - usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( complexDouble ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } -} -impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] + #[repr(C)] + pub struct __BindgenComplex { + pub re: T, + pub im: T, + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct foo { + pub bar: ::std::os::raw::c_float, + pub baz: ::std::os::raw::c_float, + pub bazz: ::std::os::raw::c_double, + pub bazzz: *mut ::std::os::raw::c_double, + pub complexFloat: __BindgenComplex<::std::os::raw::c_float>, + pub complexDouble: __BindgenComplex<::std::os::raw::c_double>, + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 48usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } + , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( baz ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bazz as * const _ as usize + } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bazz ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bazzz as * const _ as usize + } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bazzz ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . complexFloat as * const _ + as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( complexFloat ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . complexDouble as * const _ + as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( complexDouble ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } + impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/cpp-empty-layout.rs b/tests/expectations/tests/cpp-empty-layout.rs index fbeb3d5e52..e57b8b577a 100644 --- a/tests/expectations/tests/cpp-empty-layout.rs +++ b/tests/expectations/tests/cpp-empty-layout.rs @@ -1,21 +1,24 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/crtp.rs b/tests/expectations/tests/crtp.rs index 8a83e19850..3b9b4a8356 100644 --- a/tests/expectations/tests/crtp.rs +++ b/tests/expectations/tests/crtp.rs @@ -1,71 +1,76 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Base { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Derived { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Derived() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Derived ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Derived ) )); -} -impl Clone for Derived { - fn clone(&self) -> Self { *self } -} -impl Default for Derived { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct BaseWithDestructor { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug)] -pub struct DerivedFromBaseWithDestructor { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_DerivedFromBaseWithDestructor() { - assert_eq!(::std::mem::size_of::() , 1usize - , concat ! ( - "Size of: " , stringify ! ( DerivedFromBaseWithDestructor ) )); - assert_eq! (::std::mem::align_of::() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( DerivedFromBaseWithDestructor - ) )); -} -impl Default for DerivedFromBaseWithDestructor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn __bindgen_test_layout_Base_instantiation_9() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( Base ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( Base ) - )); -} -#[test] -fn __bindgen_test_layout_BaseWithDestructor_instantiation_12() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! - ( - "Size of template specialization: " , stringify ! ( - BaseWithDestructor ) )); - assert_eq!(::std::mem::align_of::() , 1usize , concat - ! ( - "Alignment of template specialization: " , stringify ! ( - BaseWithDestructor ) )); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Base { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Derived { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Derived() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Derived ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Derived ) )); + } + impl Clone for Derived { + fn clone(&self) -> Self { *self } + } + impl Default for Derived { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default)] + pub struct BaseWithDestructor { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug)] + pub struct DerivedFromBaseWithDestructor { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_DerivedFromBaseWithDestructor() { + assert_eq!(::std::mem::size_of::() , + 1usize , concat ! ( + "Size of: " , stringify ! ( DerivedFromBaseWithDestructor ) + )); + assert_eq! (::std::mem::align_of::() , + 1usize , concat ! ( + "Alignment of " , stringify ! ( + DerivedFromBaseWithDestructor ) )); + } + impl Default for DerivedFromBaseWithDestructor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn __bindgen_test_layout_Base_instantiation_10() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( Base ) + )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + Base ) )); + } + #[test] + fn __bindgen_test_layout_BaseWithDestructor_instantiation_13() { + assert_eq!(::std::mem::size_of::() , 1usize , + concat ! ( + "Size of template specialization: " , stringify ! ( + BaseWithDestructor ) )); + assert_eq!(::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of template specialization: " , stringify ! ( + BaseWithDestructor ) )); + } } diff --git a/tests/expectations/tests/dash_language.rs b/tests/expectations/tests/dash_language.rs index 385c39c6a3..294b37ccae 100644 --- a/tests/expectations/tests/dash_language.rs +++ b/tests/expectations/tests/dash_language.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub bar: ::std::os::raw::c_int, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Foo { + pub bar: ::std::os::raw::c_int, + } } diff --git a/tests/expectations/tests/decl_extern_int_twice.rs b/tests/expectations/tests/decl_extern_int_twice.rs index 603a51b14f..8913d3450b 100644 --- a/tests/expectations/tests/decl_extern_int_twice.rs +++ b/tests/expectations/tests/decl_extern_int_twice.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "foo"] - pub static mut foo: ::std::os::raw::c_int; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "foo"] + pub static mut foo: ::std::os::raw::c_int; + } } diff --git a/tests/expectations/tests/decl_ptr_to_array.rs b/tests/expectations/tests/decl_ptr_to_array.rs index b8abedb5c3..2356ebb952 100644 --- a/tests/expectations/tests/decl_ptr_to_array.rs +++ b/tests/expectations/tests/decl_ptr_to_array.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "foo"] - pub static mut foo: *mut [::std::os::raw::c_int; 1usize]; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "foo"] + pub static mut foo: *mut [::std::os::raw::c_int; 1usize]; + } } diff --git a/tests/expectations/tests/default-template-parameter.rs b/tests/expectations/tests/default-template-parameter.rs index af4616ff9b..8fbc98a6d3 100644 --- a/tests/expectations/tests/default-template-parameter.rs +++ b/tests/expectations/tests/default-template-parameter.rs @@ -1,30 +1,33 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Foo { - pub t: T, - pub u: U, -} -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn __bindgen_test_layout_Foo_instantiation_6() { - assert_eq!(::std::mem::size_of::>() , - 8usize , concat ! ( - "Size of template specialization: " , stringify ! ( - Foo ) )); - assert_eq!(::std::mem::align_of::>() , - 4usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - Foo ) )); -} -extern "C" { - #[link_name = "_ZL3bar"] - pub static mut bar: Foo; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Foo { + pub t: T, + pub u: U, + } + impl Default for Foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn __bindgen_test_layout_Foo_instantiation_7() { + assert_eq!(::std::mem::size_of::>() , + 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + Foo ) )); + assert_eq!(::std::mem::align_of::>() + , 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + Foo ) )); + } + extern "C" { + #[link_name = "_ZL3bar"] + pub static mut bar: Foo; + } } diff --git a/tests/expectations/tests/derive-fn-ptr.rs b/tests/expectations/tests/derive-fn-ptr.rs index b6a4f3516a..1ff5c6506d 100644 --- a/tests/expectations/tests/derive-fn-ptr.rs +++ b/tests/expectations/tests/derive-fn-ptr.rs @@ -1,46 +1,65 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type my_fun_t = - ::std::option::Option; -#[repr(C)] -#[derive(Copy)] -pub struct Foo { - pub callback: my_fun_t, -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . callback as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( callback ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } -} -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type my_fun_t = + ::std::option::Option; + #[repr(C)] + #[derive(Copy)] + pub struct Foo { + pub callback: my_fun_t, + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . callback as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Foo ) , "::" , + stringify ! ( callback ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } + impl Default for Foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/disable-namespacing.rs b/tests/expectations/tests/disable-namespacing.rs index 5c166946d9..a781d52dc1 100644 --- a/tests/expectations/tests/disable-namespacing.rs +++ b/tests/expectations/tests/disable-namespacing.rs @@ -1,7 +1,10 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type Baz = ::std::os::raw::c_int; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type Baz = ::std::os::raw::c_int; +} diff --git a/tests/expectations/tests/duplicated-namespaces-definitions.rs b/tests/expectations/tests/duplicated-namespaces-definitions.rs index faba454d2a..6fb6d0b200 100644 --- a/tests/expectations/tests/duplicated-namespaces-definitions.rs +++ b/tests/expectations/tests/duplicated-namespaces-definitions.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/duplicated-namespaces.rs b/tests/expectations/tests/duplicated-namespaces.rs index 7416dad9d6..82622bac30 100644 --- a/tests/expectations/tests/duplicated-namespaces.rs +++ b/tests/expectations/tests/duplicated-namespaces.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/duplicated_constants_in_ns.rs b/tests/expectations/tests/duplicated_constants_in_ns.rs index 226765b645..c35514f8a9 100644 --- a/tests/expectations/tests/duplicated_constants_in_ns.rs +++ b/tests/expectations/tests/duplicated_constants_in_ns.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/elaborated.rs b/tests/expectations/tests/elaborated.rs index 0e8f4ee55f..9a172c2a61 100644 --- a/tests/expectations/tests/elaborated.rs +++ b/tests/expectations/tests/elaborated.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type whatever_whatever_t = ::std::os::raw::c_int; -extern "C" { - #[link_name = "_Z9somethingPKi"] - pub fn something(wat: *const whatever_whatever_t); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type whatever_whatever_t = ::std::os::raw::c_int; + extern "C" { + #[link_name = "_Z9somethingPKi"] + pub fn something(wat: *const whatever_whatever_t); + } } diff --git a/tests/expectations/tests/empty_template_param_name.rs b/tests/expectations/tests/empty_template_param_name.rs index 2bd5a570c9..7f2428572d 100644 --- a/tests/expectations/tests/empty_template_param_name.rs +++ b/tests/expectations/tests/empty_template_param_name.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type __void_t = ::std::os::raw::c_void; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct __iterator_traits { - pub _address: u8, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type __void_t = ::std::os::raw::c_void; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct __iterator_traits { + pub _address: u8, + } } diff --git a/tests/expectations/tests/enum.rs b/tests/expectations/tests/enum.rs index 8138d69781..c34261131e 100644 --- a/tests/expectations/tests/enum.rs +++ b/tests/expectations/tests/enum.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 0, Qux = 1, } -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Neg { MinusOne = -1, One = 1, } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Foo { Bar = 0, Qux = 1, } + #[repr(i32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Neg { MinusOne = -1, One = 1, } +} diff --git a/tests/expectations/tests/enum_alias.rs b/tests/expectations/tests/enum_alias.rs index 7ea8559863..2f2eadde7c 100644 --- a/tests/expectations/tests/enum_alias.rs +++ b/tests/expectations/tests/enum_alias.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(u8)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bar { VAL = 0, } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(u8)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Bar { VAL = 0, } +} diff --git a/tests/expectations/tests/enum_and_vtable_mangling.rs b/tests/expectations/tests/enum_and_vtable_mangling.rs index b34e217f4a..21d9b26662 100644 --- a/tests/expectations/tests/enum_and_vtable_mangling.rs +++ b/tests/expectations/tests/enum_and_vtable_mangling.rs @@ -1,36 +1,40 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const match_: _bindgen_ty_1 = _bindgen_ty_1::match_; -pub const whatever_else: _bindgen_ty_1 = _bindgen_ty_1::whatever_else; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { match_ = 0, whatever_else = 1, } -#[repr(C)] -pub struct C__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct C { - pub vtable_: *const C__bindgen_vtable, - pub i: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . i as * const _ as usize - } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( i ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const match_: _bindgen_ty_1 = _bindgen_ty_1::match_; + pub const whatever_else: _bindgen_ty_1 = _bindgen_ty_1::whatever_else; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { match_ = 0, whatever_else = 1, } + #[repr(C)] + pub struct C__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct C { + pub vtable_: *const C__bindgen_vtable, + pub i: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . i as * const _ as usize } , + 8usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( i ) )); + } + impl Clone for C { + fn clone(&self) -> Self { *self } + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/enum_dupe.rs b/tests/expectations/tests/enum_dupe.rs index 322b89fc7c..ceac64802e 100644 --- a/tests/expectations/tests/enum_dupe.rs +++ b/tests/expectations/tests/enum_dupe.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const Foo_Dupe: Foo = Foo::Bar; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 1, } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const Foo_Dupe: Foo = Foo::Bar; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Foo { Bar = 1, } +} diff --git a/tests/expectations/tests/enum_explicit_type.rs b/tests/expectations/tests/enum_explicit_type.rs index 4e555d3a69..617a0a843f 100644 --- a/tests/expectations/tests/enum_explicit_type.rs +++ b/tests/expectations/tests/enum_explicit_type.rs @@ -1,24 +1,27 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(u8)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 0, Qux = 1, } -#[repr(i8)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Neg { MinusOne = -1, One = 1, } -#[repr(u16)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bigger { Much = 255, Larger = 256, } -#[repr(i64)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum MuchLong { MuchLow = -4294967296, } -#[repr(i64)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum MuchLongLong { I64_MIN = -9223372036854775808, } -#[repr(u64)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum MuchULongLong { MuchHigh = 4294967296, } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(u8)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Foo { Bar = 0, Qux = 1, } + #[repr(i8)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Neg { MinusOne = -1, One = 1, } + #[repr(u16)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Bigger { Much = 255, Larger = 256, } + #[repr(i64)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum MuchLong { MuchLow = -4294967296, } + #[repr(i64)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum MuchLongLong { I64_MIN = -9223372036854775808, } + #[repr(u64)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum MuchULongLong { MuchHigh = 4294967296, } +} diff --git a/tests/expectations/tests/enum_in_template_with_typedef.rs b/tests/expectations/tests/enum_in_template_with_typedef.rs index 2b95696399..c6a85ac1fe 100644 --- a/tests/expectations/tests/enum_in_template_with_typedef.rs +++ b/tests/expectations/tests/enum_in_template_with_typedef.rs @@ -1,17 +1,20 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct std_fbstring_core { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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, } } -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, } diff --git a/tests/expectations/tests/enum_negative.rs b/tests/expectations/tests/enum_negative.rs index 74cf4f1688..fc3599d879 100644 --- a/tests/expectations/tests/enum_negative.rs +++ b/tests/expectations/tests/enum_negative.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = -2, Qux = 1, } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(i32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Foo { Bar = -2, Qux = 1, } +} diff --git a/tests/expectations/tests/enum_packed.rs b/tests/expectations/tests/enum_packed.rs index 963763e18b..8bbd642e57 100644 --- a/tests/expectations/tests/enum_packed.rs +++ b/tests/expectations/tests/enum_packed.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(u8)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { Bar = 0, Qux = 1, } -#[repr(i8)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Neg { MinusOne = -1, One = 1, } -#[repr(u16)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bigger { Much = 255, Larger = 256, } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(u8)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Foo { Bar = 0, Qux = 1, } + #[repr(i8)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Neg { MinusOne = -1, One = 1, } + #[repr(u16)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Bigger { Much = 255, Larger = 256, } +} diff --git a/tests/expectations/tests/eval-variadic-template-parameter.rs b/tests/expectations/tests/eval-variadic-template-parameter.rs index 701aab9fec..8536172182 100644 --- a/tests/expectations/tests/eval-variadic-template-parameter.rs +++ b/tests/expectations/tests/eval-variadic-template-parameter.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct B { - pub _address: u8, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct B { + pub _address: u8, + } } diff --git a/tests/expectations/tests/extern.rs b/tests/expectations/tests/extern.rs index e7ac750494..e6637578eb 100644 --- a/tests/expectations/tests/extern.rs +++ b/tests/expectations/tests/extern.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type foo = - ::std::option::Option ::std::os::raw::c_int>; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type foo = + ::std::option::Option ::std::os::raw::c_int>; +} diff --git a/tests/expectations/tests/float128.rs b/tests/expectations/tests/float128.rs index b4b7b2bcee..46f5571808 100644 --- a/tests/expectations/tests/float128.rs +++ b/tests/expectations/tests/float128.rs @@ -1,7 +1,3 @@ /* automatically generated by rust-bindgen */ -#![allow(non_snake_case)] - - - diff --git a/tests/expectations/tests/forward-declaration-autoptr.rs b/tests/expectations/tests/forward-declaration-autoptr.rs index b05984c8c8..7d2349a467 100644 --- a/tests/expectations/tests/forward-declaration-autoptr.rs +++ b/tests/expectations/tests/forward-declaration-autoptr.rs @@ -1,40 +1,43 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Foo([u8; 0]); -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct RefPtr { - pub m_inner: *mut T, -} -impl Default for RefPtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Bar { - pub m_member: RefPtr, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . m_member as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( m_member ) )); -} -impl Clone for Bar { - fn clone(&self) -> Self { *self } -} -impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Foo([u8; 0]); + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct RefPtr { + pub m_inner: *mut T, + } + impl Default for RefPtr { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Bar { + pub m_member: RefPtr, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . m_member as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Bar ) , "::" , + stringify ! ( m_member ) )); + } + impl Clone for Bar { + fn clone(&self) -> Self { *self } + } + impl Default for Bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/forward-enum-decl.rs b/tests/expectations/tests/forward-enum-decl.rs index 7f2d937a98..11eead50e4 100644 --- a/tests/expectations/tests/forward-enum-decl.rs +++ b/tests/expectations/tests/forward-enum-decl.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum CSSPseudoClassType { empty = 0, link = 1, } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(i32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum CSSPseudoClassType { empty = 0, link = 1, } +} diff --git a/tests/expectations/tests/forward-inherit-struct-with-fields.rs b/tests/expectations/tests/forward-inherit-struct-with-fields.rs index ce61a5459c..db5ad9a40b 100644 --- a/tests/expectations/tests/forward-inherit-struct-with-fields.rs +++ b/tests/expectations/tests/forward-inherit-struct-with-fields.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub _base: js_RootedBase, -} -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct js_RootedBase { - pub foo: *mut T, - pub next: *mut Rooted, -} -impl Default for js_RootedBase { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub _base: js_RootedBase, + } + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct js_RootedBase { + pub foo: *mut T, + pub next: *mut Rooted, + } + impl Default for js_RootedBase { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/forward-inherit-struct.rs b/tests/expectations/tests/forward-inherit-struct.rs index 322854dd85..bea131ced8 100644 --- a/tests/expectations/tests/forward-inherit-struct.rs +++ b/tests/expectations/tests/forward-inherit-struct.rs @@ -1,19 +1,22 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub _address: u8, -} -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct js_RootedBase { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub _address: u8, + } + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct js_RootedBase { + pub _address: u8, + } } diff --git a/tests/expectations/tests/forward_declared_complex_types.rs b/tests/expectations/tests/forward_declared_complex_types.rs index a6e67f7b77..a3fb5825fb 100644 --- a/tests/expectations/tests/forward_declared_complex_types.rs +++ b/tests/expectations/tests/forward_declared_complex_types.rs @@ -1,65 +1,68 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo_empty { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Foo_empty() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Foo_empty ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo_empty ) )); -} -impl Clone for Foo_empty { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Foo([u8; 0]); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Bar { - pub f: *mut Foo, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . f as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( f ) )); -} -impl Clone for Bar { - fn clone(&self) -> Self { *self } -} -impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -extern "C" { - #[link_name = "_Z10baz_structP3Foo"] - pub fn baz_struct(f: *mut Foo); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Union([u8; 0]); -extern "C" { - #[link_name = "_Z9baz_unionP5Union"] - pub fn baz_union(u: *mut Union); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Quux([u8; 0]); -extern "C" { - #[link_name = "_Z9baz_classP4Quux"] - pub fn baz_class(q: *mut Quux); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Foo_empty { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Foo_empty() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Foo_empty ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo_empty ) )); + } + impl Clone for Foo_empty { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Foo([u8; 0]); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Bar { + pub f: *mut Foo, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . f as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Bar ) , "::" , + stringify ! ( f ) )); + } + impl Clone for Bar { + fn clone(&self) -> Self { *self } + } + impl Default for Bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + extern "C" { + #[link_name = "_Z10baz_structP3Foo"] + pub fn baz_struct(f: *mut Foo); + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Union([u8; 0]); + extern "C" { + #[link_name = "_Z9baz_unionP5Union"] + pub fn baz_union(u: *mut Union); + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Quux([u8; 0]); + extern "C" { + #[link_name = "_Z9baz_classP4Quux"] + pub fn baz_class(q: *mut Quux); + } } diff --git a/tests/expectations/tests/forward_declared_struct.rs b/tests/expectations/tests/forward_declared_struct.rs index ec8b15d1e3..aaf04bfbcb 100644 --- a/tests/expectations/tests/forward_declared_struct.rs +++ b/tests/expectations/tests/forward_declared_struct.rs @@ -1,44 +1,49 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct a { - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_a() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( a ) )); - assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . b as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( b ) )); -} -impl Clone for a { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct c { - pub d: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_c() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( c ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( c ) )); - assert_eq! (unsafe { & ( * ( 0 as * const c ) ) . d as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( c ) , "::" , stringify - ! ( d ) )); -} -impl Clone for c { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct a { + pub b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_a() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( a ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const a ) ) . b as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( a ) , "::" , + stringify ! ( b ) )); + } + impl Clone for a { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct c { + pub d: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_c() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( c ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( c ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const c ) ) . d as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( c ) , "::" , + stringify ! ( d ) )); + } + impl Clone for c { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/func_proto.rs b/tests/expectations/tests/func_proto.rs index e7ac750494..e6637578eb 100644 --- a/tests/expectations/tests/func_proto.rs +++ b/tests/expectations/tests/func_proto.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type foo = - ::std::option::Option ::std::os::raw::c_int>; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type foo = + ::std::option::Option ::std::os::raw::c_int>; +} diff --git a/tests/expectations/tests/func_ptr.rs b/tests/expectations/tests/func_ptr.rs index 87ec3e3dcf..d58837dc98 100644 --- a/tests/expectations/tests/func_ptr.rs +++ b/tests/expectations/tests/func_ptr.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "foo"] - pub static mut foo: - ::std::option::Option ::std::os::raw::c_int>; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "foo"] + pub static mut foo: + ::std::option::Option ::std::os::raw::c_int>; + } } diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/tests/expectations/tests/func_ptr_in_struct.rs index ce14586615..9b00c4cad3 100644 --- a/tests/expectations/tests/func_ptr_in_struct.rs +++ b/tests/expectations/tests/func_ptr_in_struct.rs @@ -1,35 +1,38 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum baz { } -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Foo { - pub bar: ::std::option::Option baz>, -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } -} -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum baz { } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Foo { + pub bar: ::std::option::Option baz>, + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } + impl Default for Foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/func_with_array_arg.rs b/tests/expectations/tests/func_with_array_arg.rs index 1528e0baaa..51915be100 100644 --- a/tests/expectations/tests/func_with_array_arg.rs +++ b/tests/expectations/tests/func_with_array_arg.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn f(x: *mut ::std::os::raw::c_int); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn f(x: *mut ::std::os::raw::c_int); + } } diff --git a/tests/expectations/tests/func_with_func_ptr_arg.rs b/tests/expectations/tests/func_with_func_ptr_arg.rs index 4ac2528674..6da6c192bb 100644 --- a/tests/expectations/tests/func_with_func_ptr_arg.rs +++ b/tests/expectations/tests/func_with_func_ptr_arg.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn foo(bar: ::std::option::Option); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn foo(bar: ::std::option::Option); + } } diff --git a/tests/expectations/tests/gen-constructors-neg.rs b/tests/expectations/tests/gen-constructors-neg.rs index fbeb3d5e52..e57b8b577a 100644 --- a/tests/expectations/tests/gen-constructors-neg.rs +++ b/tests/expectations/tests/gen-constructors-neg.rs @@ -1,21 +1,24 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/gen-constructors.rs b/tests/expectations/tests/gen-constructors.rs index 72c2fc5300..87f9d95838 100644 --- a/tests/expectations/tests/gen-constructors.rs +++ b/tests/expectations/tests/gen-constructors.rs @@ -1,33 +1,36 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( 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 } -} -impl Foo { - #[inline] - pub unsafe fn new(a: ::std::os::raw::c_int) -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - Foo_Foo(&mut __bindgen_tmp, a); - __bindgen_tmp +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( 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 } + } + impl Foo { + #[inline] + pub unsafe fn new(a: ::std::os::raw::c_int) -> Self { + let mut __bindgen_tmp = ::std::mem::uninitialized(); + Foo_Foo(&mut __bindgen_tmp, a); + __bindgen_tmp + } } } diff --git a/tests/expectations/tests/gen-destructors-neg.rs b/tests/expectations/tests/gen-destructors-neg.rs index 4aaec83a39..130422b919 100644 --- a/tests/expectations/tests/gen-destructors-neg.rs +++ b/tests/expectations/tests/gen-destructors-neg.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default)] -pub struct Foo { - pub bar: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default)] + pub struct Foo { + pub bar: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Foo ) , "::" , + stringify ! ( bar ) )); + } } diff --git a/tests/expectations/tests/gen-destructors.rs b/tests/expectations/tests/gen-destructors.rs index 7ec13b03d6..8b597cae01 100644 --- a/tests/expectations/tests/gen-destructors.rs +++ b/tests/expectations/tests/gen-destructors.rs @@ -1,31 +1,34 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default)] -pub struct Foo { - pub bar: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "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) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default)] + pub struct Foo { + pub bar: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "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 7205741496..e3886fc2fa 100644 --- a/tests/expectations/tests/generate-inline.rs +++ b/tests/expectations/tests/generate-inline.rs @@ -1,33 +1,36 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( 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 } -} -impl Foo { - #[inline] - pub unsafe fn bar() -> ::std::os::raw::c_int { Foo_bar() } -} -extern "C" { - #[link_name = "_Z3foov"] - pub fn foo() -> ::std::os::raw::c_int; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( 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 } + } + impl Foo { + #[inline] + pub unsafe fn bar() -> ::std::os::raw::c_int { Foo_bar() } + } + extern "C" { + #[link_name = "_Z3foov"] + pub fn foo() -> ::std::os::raw::c_int; + } } diff --git a/tests/expectations/tests/in_class_typedef.rs b/tests/expectations/tests/in_class_typedef.rs index 613c8cab72..3421722dbe 100644 --- a/tests/expectations/tests/in_class_typedef.rs +++ b/tests/expectations/tests/in_class_typedef.rs @@ -1,19 +1,22 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo_Bar { - pub x: ::std::os::raw::c_int, - pub y: ::std::os::raw::c_int, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Foo_Bar { + pub x: ::std::os::raw::c_int, + pub y: ::std::os::raw::c_int, + } } diff --git a/tests/expectations/tests/infinite-macro.rs b/tests/expectations/tests/infinite-macro.rs index 4f74bf903c..6455aa90df 100644 --- a/tests/expectations/tests/infinite-macro.rs +++ b/tests/expectations/tests/infinite-macro.rs @@ -1,8 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const INFINITY: f64 = ::std::f64::INFINITY; -pub const NAN: f64 = ::std::f64::NAN; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const INFINITY: f64 = ::std::f64::INFINITY; + pub const NAN: f64 = ::std::f64::NAN; +} diff --git a/tests/expectations/tests/inherit-namespaced.rs b/tests/expectations/tests/inherit-namespaced.rs index fcd8de9731..25f9d969b6 100644 --- a/tests/expectations/tests/inherit-namespaced.rs +++ b/tests/expectations/tests/inherit-namespaced.rs @@ -1,19 +1,22 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct js_RootedBase { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub _address: u8, -} -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct js_RootedBase { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub _address: u8, + } + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/inherit_named.rs b/tests/expectations/tests/inherit_named.rs index 703df9ea54..e9584221bd 100644 --- a/tests/expectations/tests/inherit_named.rs +++ b/tests/expectations/tests/inherit_named.rs @@ -1,19 +1,22 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Wohoo { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Weeee { - pub _base: T, -} -impl Default for Weeee { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Wohoo { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Weeee { + pub _base: T, + } + impl Default for Weeee { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/inherit_typedef.rs b/tests/expectations/tests/inherit_typedef.rs index 76d7c35f8c..66cfc1423a 100644 --- a/tests/expectations/tests/inherit_typedef.rs +++ b/tests/expectations/tests/inherit_typedef.rs @@ -1,37 +1,40 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } -} -pub type TypedefedFoo = Foo; -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Bar { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); -} -impl Clone for Bar { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } + pub type TypedefedFoo = Foo; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + } + impl Clone for Bar { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/inline-function.rs b/tests/expectations/tests/inline-function.rs index b4b7b2bcee..6e573b6a56 100644 --- a/tests/expectations/tests/inline-function.rs +++ b/tests/expectations/tests/inline-function.rs @@ -1,7 +1,9 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - - +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; +} diff --git a/tests/expectations/tests/inline_namespace.rs b/tests/expectations/tests/inline_namespace.rs index d62fb862f1..b0b6524e7d 100644 --- a/tests/expectations/tests/inline_namespace.rs +++ b/tests/expectations/tests/inline_namespace.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/inline_namespace_conservative.rs b/tests/expectations/tests/inline_namespace_conservative.rs index 267f28cfa3..1d6c4c8918 100644 --- a/tests/expectations/tests/inline_namespace_conservative.rs +++ b/tests/expectations/tests/inline_namespace_conservative.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/inline_namespace_whitelist.rs b/tests/expectations/tests/inline_namespace_whitelist.rs index 9601268471..69c4dede82 100644 --- a/tests/expectations/tests/inline_namespace_whitelist.rs +++ b/tests/expectations/tests/inline_namespace_whitelist.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/inner_const.rs b/tests/expectations/tests/inner_const.rs index fd2793a434..1bea1bc0ad 100644 --- a/tests/expectations/tests/inner_const.rs +++ b/tests/expectations/tests/inner_const.rs @@ -1,34 +1,37 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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; -} -extern "C" { - #[link_name = "_ZN3Foo8whateverE"] - pub static mut Foo_whatever: Foo; -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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; + } + extern "C" { + #[link_name = "_ZN3Foo8whateverE"] + pub static mut Foo_whatever: Foo; + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/inner_template_self.rs b/tests/expectations/tests/inner_template_self.rs index d75c280d05..9ccb6402c4 100644 --- a/tests/expectations/tests/inner_template_self.rs +++ b/tests/expectations/tests/inner_template_self.rs @@ -1,38 +1,41 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct LinkedList { - pub next: *mut LinkedList, - pub prev: *mut LinkedList, -} -impl Default for LinkedList { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct InstantiateIt { - pub m_list: LinkedList, -} -#[test] -fn bindgen_test_layout_InstantiateIt() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( InstantiateIt ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( InstantiateIt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const InstantiateIt ) ) . m_list as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( InstantiateIt ) , "::" - , stringify ! ( m_list ) )); -} -impl Clone for InstantiateIt { - fn clone(&self) -> Self { *self } -} -impl Default for InstantiateIt { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct LinkedList { + pub next: *mut LinkedList, + pub prev: *mut LinkedList, + } + impl Default for LinkedList { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct InstantiateIt { + pub m_list: LinkedList, + } + #[test] + fn bindgen_test_layout_InstantiateIt() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! + ( "Size of: " , stringify ! ( InstantiateIt ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat + ! ( "Alignment of " , stringify ! ( InstantiateIt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const InstantiateIt ) ) . m_list as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( InstantiateIt ) , + "::" , stringify ! ( m_list ) )); + } + impl Clone for InstantiateIt { + fn clone(&self) -> Self { *self } + } + impl Default for InstantiateIt { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/int128_t.rs b/tests/expectations/tests/int128_t.rs index b4b7b2bcee..46f5571808 100644 --- a/tests/expectations/tests/int128_t.rs +++ b/tests/expectations/tests/int128_t.rs @@ -1,7 +1,3 @@ /* automatically generated by rust-bindgen */ -#![allow(non_snake_case)] - - - diff --git a/tests/expectations/tests/issue-358.rs b/tests/expectations/tests/issue-358.rs index d01ae8007a..c60696b3e1 100644 --- a/tests/expectations/tests/issue-358.rs +++ b/tests/expectations/tests/issue-358.rs @@ -1,22 +1,25 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct JS_PersistentRooted { - pub _base: a, -} -impl Default for JS_PersistentRooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct a { - pub b: *mut a, -} -impl Default for a { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct JS_PersistentRooted { + pub _base: a, + } + impl Default for JS_PersistentRooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct a { + pub b: *mut a, + } + impl Default for a { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/issue-372.rs b/tests/expectations/tests/issue-372.rs index 3f4592f368..726d608a3e 100644 --- a/tests/expectations/tests/issue-372.rs +++ b/tests/expectations/tests/issue-372.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs index 8833ef4e51..322a748519 100644 --- a/tests/expectations/tests/issue-410.rs +++ b/tests/expectations/tests/issue-410.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/issue-446.rs b/tests/expectations/tests/issue-446.rs index 13204c1ac2..5aee46fa10 100644 --- a/tests/expectations/tests/issue-446.rs +++ b/tests/expectations/tests/issue-446.rs @@ -1,22 +1,25 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct List { - pub next: *mut List, -} -impl Default for List { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct PersistentRooted { - pub root_list: List, -} -impl Default for PersistentRooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct List { + pub next: *mut List, + } + impl Default for List { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct PersistentRooted { + pub root_list: List, + } + impl Default for PersistentRooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs index 619a17b812..ed001c2037 100644 --- a/tests/expectations/tests/issue-447.rs +++ b/tests/expectations/tests/issue-447.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs index 04fa1d8cc5..7209a6deee 100644 --- a/tests/expectations/tests/issue-493.rs +++ b/tests/expectations/tests/issue-493.rs @@ -1,111 +1,118 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct basic_string___long { + pub __cap_: basic_string_size_type, + pub __size_: basic_string_size_type, + pub __data_: basic_string_pointer, + } + impl Default for basic_string___long { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub const basic_string___min_cap: basic_string__bindgen_ty_1 = + basic_string__bindgen_ty_1::__min_cap; + #[repr(i32)] + #[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, + } + impl Default for basic_string___short { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Copy, Clone)] + pub struct basic_string___ulx { + pub __lx: __BindgenUnionField, + pub __lxx: __BindgenUnionField, + pub bindgen_union_field: [u8; 0usize], + } + impl Default for basic_string___ulx { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub const basic_string___n_words: basic_string__bindgen_ty_2 = + basic_string__bindgen_ty_2::__n_words; + #[repr(i32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum basic_string__bindgen_ty_2 { __n_words = 0, } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct basic_string___raw { + pub __words: *mut basic_string_size_type, + } + impl Default for basic_string___raw { + 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, + } + #[repr(C)] + #[derive(Copy, Clone)] + pub struct basic_string___rep__bindgen_ty_1 { + pub __l: __BindgenUnionField, + pub __s: __BindgenUnionField, + pub __r: __BindgenUnionField, + pub bindgen_union_field: [u8; 0usize], + } + impl Default for basic_string___rep__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + 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, -} -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; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct basic_string___long { - pub __cap_: basic_string_size_type, - pub __size_: basic_string_size_type, - pub __data_: basic_string_pointer, -} -impl Default for basic_string___long { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -pub const basic_string___min_cap: basic_string__bindgen_ty_1 = - basic_string__bindgen_ty_1::__min_cap; -#[repr(i32)] -#[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, -} -impl Default for basic_string___short { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct basic_string___ulx { - pub __lx: __BindgenUnionField, - pub __lxx: __BindgenUnionField, - pub bindgen_union_field: [u8; 0usize], -} -impl Default for basic_string___ulx { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -pub const basic_string___n_words: basic_string__bindgen_ty_2 = - basic_string__bindgen_ty_2::__n_words; -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum basic_string__bindgen_ty_2 { __n_words = 0, } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct basic_string___raw { - pub __words: *mut basic_string_size_type, -} -impl Default for basic_string___raw { - 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, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct basic_string___rep__bindgen_ty_1 { - pub __l: __BindgenUnionField, - pub __s: __BindgenUnionField, - pub __r: __BindgenUnionField, - pub bindgen_union_field: [u8; 0usize], -} -impl Default for basic_string___rep__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for basic_string___rep { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/issue-544-stylo-creduce-2.rs b/tests/expectations/tests/issue-544-stylo-creduce-2.rs index c0fae8452e..2d7ba0d8b1 100644 --- a/tests/expectations/tests/issue-544-stylo-creduce-2.rs +++ b/tests/expectations/tests/issue-544-stylo-creduce-2.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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-544-stylo-creduce.rs b/tests/expectations/tests/issue-544-stylo-creduce.rs index fb543cba63..8fdead640f 100644 --- a/tests/expectations/tests/issue-544-stylo-creduce.rs +++ b/tests/expectations/tests/issue-544-stylo-creduce.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct a { - pub _address: u8, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct a { + pub _address: u8, + } } 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 c4ce513902..eed4e054de 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 @@ -1,42 +1,46 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const ENUM_VARIANT_1: _bindgen_ty_1 = _bindgen_ty_1::ENUM_VARIANT_1; -pub const ENUM_VARIANT_2: _bindgen_ty_1 = _bindgen_ty_1::ENUM_VARIANT_2; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { ENUM_VARIANT_1 = 0, ENUM_VARIANT_2 = 1, } -pub type JS_Alias = u8; -#[repr(C)] -pub struct JS_Base { - pub f: JS_Alias, -} -impl Default for JS_Base { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -pub struct JS_AutoIdVector { - pub _base: JS_Base, -} -#[test] -fn bindgen_test_layout_JS_AutoIdVector() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( JS_AutoIdVector ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( JS_AutoIdVector ) )); -} -impl Default for JS_AutoIdVector { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn __bindgen_test_layout_JS_Base_instantiation_20() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of template specialization: " , stringify ! ( JS_Base ) - )); - assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - JS_Base ) )); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const ENUM_VARIANT_1: _bindgen_ty_1 = _bindgen_ty_1::ENUM_VARIANT_1; + pub const ENUM_VARIANT_2: _bindgen_ty_1 = _bindgen_ty_1::ENUM_VARIANT_2; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { ENUM_VARIANT_1 = 0, ENUM_VARIANT_2 = 1, } + pub type JS_Alias = u8; + #[repr(C)] + pub struct JS_Base { + pub f: JS_Alias, + } + impl Default for JS_Base { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + pub struct JS_AutoIdVector { + pub _base: JS_Base, + } + #[test] + fn bindgen_test_layout_JS_AutoIdVector() { + assert_eq!(::std::mem::size_of::() , 1usize , concat + ! ( "Size of: " , stringify ! ( JS_AutoIdVector ) )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( JS_AutoIdVector ) )); + } + impl Default for JS_AutoIdVector { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn __bindgen_test_layout_JS_Base_instantiation_21() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of template specialization: " , stringify ! ( JS_Base + ) )); + assert_eq!(::std::mem::align_of::() , 1usize , concat ! ( + "Alignment 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 dc582c1b67..8185d13ebf 100644 --- a/tests/expectations/tests/issue-573-layout-test-failures.rs +++ b/tests/expectations/tests/issue-573-layout-test-failures.rs @@ -1,30 +1,33 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Default)] -pub struct Outer { - pub i: u8, -} -#[repr(C)] -pub struct AutoIdVector { - pub ar: Outer, -} -#[test] -fn bindgen_test_layout_AutoIdVector() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( AutoIdVector ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( AutoIdVector ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const AutoIdVector ) ) . ar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( AutoIdVector ) , "::" , - stringify ! ( ar ) )); -} -impl Default for AutoIdVector { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Default)] + pub struct Outer { + pub i: u8, + } + #[repr(C)] + pub struct AutoIdVector { + pub ar: Outer, + } + #[test] + fn bindgen_test_layout_AutoIdVector() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( AutoIdVector ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! + ( "Alignment of " , stringify ! ( AutoIdVector ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const AutoIdVector ) ) . ar as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( AutoIdVector ) , + "::" , stringify ! ( ar ) )); + } + impl Default for AutoIdVector { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } 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 084cdb62c9..f4a839073d 100644 --- a/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs +++ b/tests/expectations/tests/issue-574-assertion-failure-in-codegen.rs @@ -1,38 +1,41 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct a { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct _bindgen_ty_1 { - pub ar: a, -} -#[test] -fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 1usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 1usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . ar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( ar ) )); -} -impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl Default for _bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -extern "C" { - #[link_name = "AutoIdVector"] - pub static mut AutoIdVector: _bindgen_ty_1; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct a { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct _bindgen_ty_1 { + pub ar: a, + } + #[test] + fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 1usize , concat ! + ( "Size of: " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 1usize , concat + ! ( "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . ar as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , + "::" , stringify ! ( ar ) )); + } + impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Default for _bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + extern "C" { + #[link_name = "AutoIdVector"] + pub static mut AutoIdVector: _bindgen_ty_1; + } } diff --git a/tests/expectations/tests/issue_311.rs b/tests/expectations/tests/issue_311.rs index 0510f1c1f9..ca3a7a3774 100644 --- a/tests/expectations/tests/issue_311.rs +++ b/tests/expectations/tests/issue_311.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/issue_315.rs b/tests/expectations/tests/issue_315.rs index a5ab63fca1..608eb8325b 100644 --- a/tests/expectations/tests/issue_315.rs +++ b/tests/expectations/tests/issue_315.rs @@ -1,8 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -///
-pub type c
= a; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + ///
+ pub type c
= a; +} diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index b34b02652d..076c25a5f1 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -1,301 +1,311 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } } -} -pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; -pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = 140737488355327; -pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328; -#[repr(u8)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum JSValueType { - JSVAL_TYPE_DOUBLE = 0, - JSVAL_TYPE_INT32 = 1, - JSVAL_TYPE_UNDEFINED = 2, - JSVAL_TYPE_BOOLEAN = 3, - JSVAL_TYPE_MAGIC = 4, - JSVAL_TYPE_STRING = 5, - JSVAL_TYPE_SYMBOL = 6, - JSVAL_TYPE_NULL = 7, - JSVAL_TYPE_OBJECT = 8, - JSVAL_TYPE_UNKNOWN = 32, - JSVAL_TYPE_MISSING = 33, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum JSValueTag { - JSVAL_TAG_MAX_DOUBLE = 131056, - JSVAL_TAG_INT32 = 131057, - JSVAL_TAG_UNDEFINED = 131058, - JSVAL_TAG_STRING = 131061, - JSVAL_TAG_SYMBOL = 131062, - JSVAL_TAG_BOOLEAN = 131059, - JSVAL_TAG_MAGIC = 131060, - JSVAL_TAG_NULL = 131063, - JSVAL_TAG_OBJECT = 131064, -} -#[repr(u64)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum JSValueShiftedTag { - JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663, - JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696, - JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024, - JSVAL_SHIFTED_TAG_STRING = 18445195961337643008, - JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336, - JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352, - JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680, - JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, - JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum JSWhyMagic { - JS_ELEMENTS_HOLE = 0, - JS_NO_ITER_VALUE = 1, - JS_GENERATOR_CLOSING = 2, - JS_NO_CONSTANT = 3, - JS_THIS_POISON = 4, - JS_ARG_POISON = 5, - JS_SERIALIZE_NO_NODE = 6, - JS_LAZY_ARGUMENTS = 7, - JS_OPTIMIZED_ARGUMENTS = 8, - JS_IS_CONSTRUCTING = 9, - JS_OVERWRITTEN_CALLEE = 10, - JS_BLOCK_NEEDS_CLONE = 11, - JS_HASH_KEY_EMPTY = 12, - JS_ION_ERROR = 13, - JS_ION_BAILOUT = 14, - JS_OPTIMIZED_OUT = 15, - JS_UNINITIALIZED_LEXICAL = 16, - JS_GENERIC_MAGIC = 17, - JS_WHY_MAGIC_COUNT = 18, -} -#[repr(C)] -#[derive(Debug, 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, - pub __bindgen_align: [u64; 0usize], -} -#[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , - concat ! ( - "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 8usize - , concat ! ( - "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 ) - )); -} -impl Clone for jsval_layout__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl Default for jsval_layout__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl jsval_layout__bindgen_ty_1 { - #[inline] - pub fn payload47(&self) -> u64 { - let mask = 140737488355327usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u64) } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } } - #[inline] - pub fn set_payload47(&mut self, val: u64) { - let mask = 140737488355327usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } } - #[inline] - pub fn tag(&self) -> JSValueTag { - let mask = 18446603336221196288usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 47usize; - unsafe { ::std::mem::transmute(val as u32) } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } } - #[inline] - pub fn set_tag(&mut self, val: JSValueTag) { - let mask = 18446603336221196288usize as u64; - let val = val as u32 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 47usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[allow(unused_imports)] + use self::super::*; + pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47; + pub const JSVAL_PAYLOAD_MASK: ::std::os::raw::c_ulonglong = + 140737488355327; + pub const JSVAL_TAG_MASK: ::std::os::raw::c_longlong = -140737488355328; + #[repr(u8)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSValueType { + JSVAL_TYPE_DOUBLE = 0, + JSVAL_TYPE_INT32 = 1, + JSVAL_TYPE_UNDEFINED = 2, + JSVAL_TYPE_BOOLEAN = 3, + JSVAL_TYPE_MAGIC = 4, + JSVAL_TYPE_STRING = 5, + JSVAL_TYPE_SYMBOL = 6, + JSVAL_TYPE_NULL = 7, + JSVAL_TYPE_OBJECT = 8, + JSVAL_TYPE_UNKNOWN = 32, + JSVAL_TYPE_MISSING = 33, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSValueTag { + JSVAL_TAG_MAX_DOUBLE = 131056, + JSVAL_TAG_INT32 = 131057, + JSVAL_TAG_UNDEFINED = 131058, + JSVAL_TAG_STRING = 131061, + JSVAL_TAG_SYMBOL = 131062, + JSVAL_TAG_BOOLEAN = 131059, + JSVAL_TAG_MAGIC = 131060, + JSVAL_TAG_NULL = 131063, + JSVAL_TAG_OBJECT = 131064, + } + #[repr(u64)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSValueShiftedTag { + JSVAL_SHIFTED_TAG_MAX_DOUBLE = 18444492278190833663, + JSVAL_SHIFTED_TAG_INT32 = 18444633011384221696, + JSVAL_SHIFTED_TAG_UNDEFINED = 18444773748872577024, + JSVAL_SHIFTED_TAG_STRING = 18445195961337643008, + JSVAL_SHIFTED_TAG_SYMBOL = 18445336698825998336, + JSVAL_SHIFTED_TAG_BOOLEAN = 18444914486360932352, + JSVAL_SHIFTED_TAG_MAGIC = 18445055223849287680, + JSVAL_SHIFTED_TAG_NULL = 18445477436314353664, + JSVAL_SHIFTED_TAG_OBJECT = 18445618173802708992, + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum JSWhyMagic { + JS_ELEMENTS_HOLE = 0, + JS_NO_ITER_VALUE = 1, + JS_GENERATOR_CLOSING = 2, + JS_NO_CONSTANT = 3, + JS_THIS_POISON = 4, + JS_ARG_POISON = 5, + JS_SERIALIZE_NO_NODE = 6, + JS_LAZY_ARGUMENTS = 7, + JS_OPTIMIZED_ARGUMENTS = 8, + JS_IS_CONSTRUCTING = 9, + JS_OVERWRITTEN_CALLEE = 10, + JS_BLOCK_NEEDS_CLONE = 11, + JS_HASH_KEY_EMPTY = 12, + JS_ION_ERROR = 13, + JS_ION_BAILOUT = 14, + JS_OPTIMIZED_OUT = 15, + JS_UNINITIALIZED_LEXICAL = 16, + JS_GENERIC_MAGIC = 17, + JS_WHY_MAGIC_COUNT = 18, + } + #[repr(C)] + #[derive(Debug, 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, + pub __bindgen_align: [u64; 0usize], + } + #[test] + fn bindgen_test_layout_jsval_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 8usize , concat ! ( + "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 + ) )); + } + impl Clone for jsval_layout__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Default for jsval_layout__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl jsval_layout__bindgen_ty_1 { + #[inline] + pub fn payload47(&self) -> u64 { + let mask = 140737488355327usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_payload47(&mut self, val: u64) { + let mask = 140737488355327usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn tag(&self) -> JSValueTag { + let mask = 18446603336221196288usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 47usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_tag(&mut self, val: JSValueTag) { + let mask = 18446603336221196288usize as u64; + let val = val as u32 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 47usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[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, + pub why: __BindgenUnionField, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 + ) ) . i32 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , + stringify ! ( i32 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 + ) ) . u32 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , + stringify ! ( u32 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 + ) ) . why as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , + stringify ! ( why ) )); + } + impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( jsval_layout__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_2 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout__bindgen_ty_2 ) ) . + payload as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + jsval_layout__bindgen_ty_2 ) , "::" , stringify ! ( + payload ) )); + } + impl Clone for jsval_layout__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_jsval_layout() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( jsval_layout ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( jsval_layout ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asBits as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( asBits ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . debugView as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( debugView ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . s as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( s ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asDouble as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( asDouble ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asPtr as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( asPtr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asWord as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( asWord ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const jsval_layout ) ) . asUIntPtr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( jsval_layout ) , + "::" , stringify ! ( asUIntPtr ) )); + } + impl Clone for jsval_layout { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Value { + pub data: jsval_layout, + } + #[test] + fn bindgen_test_layout_Value() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Value ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Value ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Value ) ) . data as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Value ) , "::" , + stringify ! ( data ) )); + } + impl Clone for Value { + 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, -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 { - pub i32: __BindgenUnionField, - pub u32: __BindgenUnionField, - pub why: __BindgenUnionField, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - jsval_layout__bindgen_ty_2__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - jsval_layout__bindgen_ty_2__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) - . i32 as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , stringify - ! ( i32 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) - . u32 as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , stringify - ! ( u32 ) )); - assert_eq! (unsafe { - & ( - * ( 0 as * const jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ) - . why as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - jsval_layout__bindgen_ty_2__bindgen_ty_1 ) , "::" , stringify - ! ( why ) )); -} -impl Clone for jsval_layout__bindgen_ty_2__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_jsval_layout__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , 4usize , - concat ! ( - "Size of: " , stringify ! ( jsval_layout__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 4usize - , concat ! ( - "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout__bindgen_ty_2 ) ) . payload - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - jsval_layout__bindgen_ty_2 ) , "::" , stringify ! ( payload ) - )); -} -impl Clone for jsval_layout__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_jsval_layout() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( jsval_layout ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( jsval_layout ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . asBits as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( asBits ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . debugView as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( debugView ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . s as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( s ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . asDouble as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( asDouble ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . asPtr as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( asPtr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . asWord as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( asWord ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const jsval_layout ) ) . asUIntPtr as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( jsval_layout ) , "::" , - stringify ! ( asUIntPtr ) )); -} -impl Clone for jsval_layout { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Value { - pub data: jsval_layout, -} -#[test] -fn bindgen_test_layout_Value() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Value ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Value ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Value ) ) . data as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Value ) , "::" , - stringify ! ( data ) )); -} -impl Clone for Value { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/keywords.rs b/tests/expectations/tests/keywords.rs index 5b75389e00..de15dd33a9 100644 --- a/tests/expectations/tests/keywords.rs +++ b/tests/expectations/tests/keywords.rs @@ -1,202 +1,205 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "u8"] - pub static mut u8: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "u16"] - pub static mut u16: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "u32"] - pub static mut u32: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "u64"] - pub static mut u64: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "i8"] - pub static mut i8: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "i16"] - pub static mut i16: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "i32"] - pub static mut i32: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "i64"] - pub static mut i64: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "f32"] - pub static mut f32: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "f64"] - pub static mut f64: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "usize"] - pub static mut usize: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "isize"] - pub static mut isize: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "as"] - pub static mut as_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "box"] - pub static mut box_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "crate"] - pub static mut crate_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "false"] - pub static mut false_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "fn"] - pub static mut fn_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "impl"] - pub static mut impl_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "in"] - pub static mut in_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "let"] - pub static mut let_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "loop"] - pub static mut loop_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "match"] - pub static mut match_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "mod"] - pub static mut mod_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "move"] - pub static mut move_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "mut"] - pub static mut mut_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "pub"] - pub static mut pub_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "ref"] - pub static mut ref_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "self"] - pub static mut self_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "Self"] - pub static mut Self_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "super"] - pub static mut super_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "trait"] - pub static mut trait_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "true"] - pub static mut true_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "type"] - pub static mut type_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "unsafe"] - pub static mut unsafe_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "use"] - pub static mut use_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "where"] - pub static mut where_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "abstract"] - pub static mut abstract_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "alignof"] - pub static mut alignof_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "become"] - pub static mut become_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "final"] - pub static mut final_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "macro"] - pub static mut macro_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "offsetof"] - pub static mut offsetof_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "override"] - pub static mut override_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "priv"] - pub static mut priv_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "proc"] - pub static mut proc_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "pure"] - pub static mut pure_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "unsized"] - pub static mut unsized_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "virtual"] - pub static mut virtual_: ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "yield"] - pub static mut yield_: ::std::os::raw::c_int; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "u8"] + pub static mut u8: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "u16"] + pub static mut u16: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "u32"] + pub static mut u32: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "u64"] + pub static mut u64: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "i8"] + pub static mut i8: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "i16"] + pub static mut i16: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "i32"] + pub static mut i32: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "i64"] + pub static mut i64: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "f32"] + pub static mut f32: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "f64"] + pub static mut f64: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "usize"] + pub static mut usize: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "isize"] + pub static mut isize: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "as"] + pub static mut as_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "box"] + pub static mut box_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "crate"] + pub static mut crate_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "false"] + pub static mut false_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "fn"] + pub static mut fn_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "impl"] + pub static mut impl_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "in"] + pub static mut in_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "let"] + pub static mut let_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "loop"] + pub static mut loop_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "match"] + pub static mut match_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "mod"] + pub static mut mod_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "move"] + pub static mut move_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "mut"] + pub static mut mut_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "pub"] + pub static mut pub_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "ref"] + pub static mut ref_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "self"] + pub static mut self_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "Self"] + pub static mut Self_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "super"] + pub static mut super_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "trait"] + pub static mut trait_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "true"] + pub static mut true_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "type"] + pub static mut type_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "unsafe"] + pub static mut unsafe_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "use"] + pub static mut use_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "where"] + pub static mut where_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "abstract"] + pub static mut abstract_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "alignof"] + pub static mut alignof_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "become"] + pub static mut become_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "final"] + pub static mut final_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "macro"] + pub static mut macro_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "offsetof"] + pub static mut offsetof_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "override"] + pub static mut override_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "priv"] + pub static mut priv_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "proc"] + pub static mut proc_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "pure"] + pub static mut pure_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "unsized"] + pub static mut unsized_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "virtual"] + pub static mut virtual_: ::std::os::raw::c_int; + } + extern "C" { + #[link_name = "yield"] + pub static mut yield_: ::std::os::raw::c_int; + } } diff --git a/tests/expectations/tests/layout.rs b/tests/expectations/tests/layout.rs index 115a108a2e..27a08d5d6e 100644 --- a/tests/expectations/tests/layout.rs +++ b/tests/expectations/tests/layout.rs @@ -1,55 +1,60 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData); -impl __IncompleteArrayField { - #[inline] - pub fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + #[derive(Default)] + pub struct __IncompleteArrayField(::std::marker::PhantomData); + impl __IncompleteArrayField { + #[inline] + pub fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } } - #[inline] - pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut_ptr(&mut self) -> *mut T { - ::std::mem::transmute(self) + impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } } - #[inline] - pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) + impl ::std::clone::Clone for __IncompleteArrayField { + #[inline] + fn clone(&self) -> Self { Self::new() } } - #[inline] - pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + impl ::std::marker::Copy for __IncompleteArrayField { } + #[allow(unused_imports)] + use self::super::*; + #[repr(C, packed)] + #[derive(Debug, Default, Copy)] + pub struct header { + pub proto: ::std::os::raw::c_char, + pub size: ::std::os::raw::c_uint, + pub data: __IncompleteArrayField<::std::os::raw::c_uchar>, + pub __bindgen_padding_0: [u8; 11usize], } -} -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__IncompleteArrayField") + #[test] + fn bindgen_test_layout_header() { + assert_eq!(::std::mem::size_of::
() , 16usize , concat ! ( + "Size of: " , stringify ! ( header ) )); + } + impl Clone for header { + fn clone(&self) -> Self { *self } } -} -impl ::std::clone::Clone for __IncompleteArrayField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __IncompleteArrayField { } -#[repr(C, packed)] -#[derive(Debug, Default, Copy)] -pub struct header { - pub proto: ::std::os::raw::c_char, - pub size: ::std::os::raw::c_uint, - pub data: __IncompleteArrayField<::std::os::raw::c_uchar>, - pub __bindgen_padding_0: [u8; 11usize], -} -#[test] -fn bindgen_test_layout_header() { - assert_eq!(::std::mem::size_of::
() , 16usize , concat ! ( - "Size of: " , stringify ! ( header ) )); -} -impl Clone for header { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs index ea1103a06e..0519293326 100644 --- a/tests/expectations/tests/layout_align.rs +++ b/tests/expectations/tests/layout_align.rs @@ -1,147 +1,152 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData); -impl __IncompleteArrayField { - #[inline] - pub fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + #[derive(Default)] + pub struct __IncompleteArrayField(::std::marker::PhantomData); + impl __IncompleteArrayField { + #[inline] + pub fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } } - #[inline] - pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut_ptr(&mut self) -> *mut T { - ::std::mem::transmute(self) + impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } } - #[inline] - pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) + impl ::std::clone::Clone for __IncompleteArrayField { + #[inline] + fn clone(&self) -> Self { Self::new() } } - #[inline] - pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + impl ::std::marker::Copy for __IncompleteArrayField { } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_kni_fifo { + /**< Next position to be written*/ + pub write: ::std::os::raw::c_uint, + /**< Next position to be read */ + pub read: ::std::os::raw::c_uint, + /**< Circular buffer length */ + pub len: ::std::os::raw::c_uint, + /**< Pointer size - for 32/64 bit OS */ + pub elem_size: ::std::os::raw::c_uint, + /**< The buffer contains mbuf pointers */ + pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, + pub __bindgen_align: [u64; 0usize], } -} -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__IncompleteArrayField") + #[test] + fn bindgen_test_layout_rte_kni_fifo() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! + ( "Size of: " , stringify ! ( rte_kni_fifo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( rte_kni_fifo ) )); } -} -impl ::std::clone::Clone for __IncompleteArrayField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __IncompleteArrayField { } -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_kni_fifo { - /**< Next position to be written*/ - pub write: ::std::os::raw::c_uint, - /**< Next position to be read */ - pub read: ::std::os::raw::c_uint, - /**< Circular buffer length */ - pub len: ::std::os::raw::c_uint, - /**< Pointer size - for 32/64 bit OS */ - pub elem_size: ::std::os::raw::c_uint, - /**< The buffer contains mbuf pointers */ - pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, - pub __bindgen_align: [u64; 0usize], -} -#[test] -fn bindgen_test_layout_rte_kni_fifo() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( rte_kni_fifo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( rte_kni_fifo ) )); -} -impl Clone for rte_kni_fifo { - fn clone(&self) -> Self { *self } -} -impl Default for rte_kni_fifo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_eth_link { - /**< ETH_SPEED_NUM_ */ - pub link_speed: u32, - pub _bitfield_1: u8, - pub __bindgen_padding_0: [u8; 3usize], - pub __bindgen_align: [u64; 0usize], -} -#[test] -fn bindgen_test_layout_rte_eth_link() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( rte_eth_link ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( rte_eth_link ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_link ) ) . link_speed as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_link ) , "::" , - stringify ! ( link_speed ) )); -} -impl Clone for rte_eth_link { - fn clone(&self) -> Self { *self } -} -impl rte_eth_link { - #[inline] - pub fn link_duplex(&self) -> u16 { - let mask = 1usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } + impl Clone for rte_kni_fifo { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn set_link_duplex(&mut self, val: u16) { - let mask = 1usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + impl Default for rte_kni_fifo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } - #[inline] - pub fn link_autoneg(&self) -> u16 { - let mask = 2usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u16) } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_eth_link { + /**< ETH_SPEED_NUM_ */ + pub link_speed: u32, + pub _bitfield_1: u8, + pub __bindgen_padding_0: [u8; 3usize], + pub __bindgen_align: [u64; 0usize], } - #[inline] - pub fn set_link_autoneg(&mut self, val: u16) { - let mask = 2usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[test] + fn bindgen_test_layout_rte_eth_link() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_link ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( rte_eth_link ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_link ) ) . link_speed as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_link ) , + "::" , stringify ! ( link_speed ) )); } - #[inline] - pub fn link_status(&self) -> u16 { - let mask = 4usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 2usize; - unsafe { ::std::mem::transmute(val as u16) } + impl Clone for rte_eth_link { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn set_link_status(&mut self, val: u16) { - let mask = 4usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 2usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + impl rte_eth_link { + #[inline] + pub fn link_duplex(&self) -> u16 { + let mask = 1usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_link_duplex(&mut self, val: u16) { + let mask = 1usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn link_autoneg(&self) -> u16 { + let mask = 2usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_link_autoneg(&mut self, val: u16) { + let mask = 2usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn link_status(&self) -> u16 { + let mask = 4usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_link_status(&mut self, val: u16) { + let mask = 4usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 2usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } } } diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index f3c59eb412..e63f23647f 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -1,18 +1,20 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const ETHER_ADDR_LEN: ::std::os::raw::c_uint = 6; -pub const ARP_HRD_ETHER: ::std::os::raw::c_uint = 1; -pub const ARP_OP_REQUEST: ::std::os::raw::c_uint = 1; -pub const ARP_OP_REPLY: ::std::os::raw::c_uint = 2; -pub const ARP_OP_REVREQUEST: ::std::os::raw::c_uint = 3; -pub const ARP_OP_REVREPLY: ::std::os::raw::c_uint = 4; -pub const ARP_OP_INVREQUEST: ::std::os::raw::c_uint = 8; -pub const ARP_OP_INVREPLY: ::std::os::raw::c_uint = 9; -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const ETHER_ADDR_LEN: ::std::os::raw::c_uint = 6; + pub const ARP_HRD_ETHER: ::std::os::raw::c_uint = 1; + pub const ARP_OP_REQUEST: ::std::os::raw::c_uint = 1; + pub const ARP_OP_REPLY: ::std::os::raw::c_uint = 2; + pub const ARP_OP_REVREQUEST: ::std::os::raw::c_uint = 3; + pub const ARP_OP_REVREPLY: ::std::os::raw::c_uint = 4; + pub const ARP_OP_INVREQUEST: ::std::os::raw::c_uint = 8; + pub const ARP_OP_INVREPLY: ::std::os::raw::c_uint = 9; + /** * Ethernet address: * A universally administered address is uniquely assigned to a device by its * manufacturer. The first three octets (in transmission order) contain the @@ -23,122 +25,123 @@ pub const ARP_OP_INVREPLY: ::std::os::raw::c_uint = 9; * administrator and does not contain OUIs. * See http://standards.ieee.org/regauth/groupmac/tutorial.html */ -#[repr(C, packed)] -#[derive(Debug, Default, Copy)] -pub struct ether_addr { - /**< Addr bytes in tx order */ - pub addr_bytes: [u8; 6usize], -} -#[test] -fn bindgen_test_layout_ether_addr() { - assert_eq!(::std::mem::size_of::() , 6usize , concat ! ( - "Size of: " , stringify ! ( ether_addr ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( ether_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ether_addr ) ) . addr_bytes as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ether_addr ) , "::" , - stringify ! ( addr_bytes ) )); -} -impl Clone for ether_addr { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C, packed)] + #[derive(Debug, Default, Copy)] + pub struct ether_addr { + /**< Addr bytes in tx order */ + pub addr_bytes: [u8; 6usize], + } + #[test] + fn bindgen_test_layout_ether_addr() { + assert_eq!(::std::mem::size_of::() , 6usize , concat ! ( + "Size of: " , stringify ! ( ether_addr ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( ether_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ether_addr ) ) . addr_bytes as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ether_addr ) , "::" + , stringify ! ( addr_bytes ) )); + } + impl Clone for ether_addr { + fn clone(&self) -> Self { *self } + } + /** * ARP header IPv4 payload. */ -#[repr(C, packed)] -#[derive(Debug, Default, Copy)] -pub struct arp_ipv4 { - /**< sender hardware address */ - pub arp_sha: ether_addr, - /**< sender IP address */ - pub arp_sip: u32, - /**< target hardware address */ - pub arp_tha: ether_addr, - /**< target IP address */ - pub arp_tip: u32, -} -#[test] -fn bindgen_test_layout_arp_ipv4() { - assert_eq!(::std::mem::size_of::() , 20usize , concat ! ( - "Size of: " , stringify ! ( arp_ipv4 ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( arp_ipv4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_sha as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_sha ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_sip as * const _ as - usize } , 6usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_sip ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_tha as * const _ as - usize } , 10usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_tha ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_ipv4 ) ) . arp_tip as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , - stringify ! ( arp_tip ) )); -} -impl Clone for arp_ipv4 { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C, packed)] + #[derive(Debug, Default, Copy)] + pub struct arp_ipv4 { + /**< sender hardware address */ + pub arp_sha: ether_addr, + /**< sender IP address */ + pub arp_sip: u32, + /**< target hardware address */ + pub arp_tha: ether_addr, + /**< target IP address */ + pub arp_tip: u32, + } + #[test] + fn bindgen_test_layout_arp_ipv4() { + assert_eq!(::std::mem::size_of::() , 20usize , concat ! ( + "Size of: " , stringify ! ( arp_ipv4 ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( arp_ipv4 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_sha as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , + stringify ! ( arp_sha ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_sip as * const _ + as usize } , 6usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , + stringify ! ( arp_sip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_tha as * const _ + as usize } , 10usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , + stringify ! ( arp_tha ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_ipv4 ) ) . arp_tip as * const _ + as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_ipv4 ) , "::" , + stringify ! ( arp_tip ) )); + } + impl Clone for arp_ipv4 { + fn clone(&self) -> Self { *self } + } + /** * ARP header. */ -#[repr(C, packed)] -#[derive(Debug, Default, Copy)] -pub struct arp_hdr { - pub arp_hrd: u16, - pub arp_pro: u16, - pub arp_hln: u8, - pub arp_pln: u8, - pub arp_op: u16, - pub arp_data: arp_ipv4, -} -#[test] -fn bindgen_test_layout_arp_hdr() { - assert_eq!(::std::mem::size_of::() , 28usize , concat ! ( - "Size of: " , stringify ! ( arp_hdr ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( arp_hdr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_hrd as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_hrd ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_pro as * const _ as - usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_pro ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_hln as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_hln ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_pln as * const _ as - usize } , 5usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_pln ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_op as * const _ as - usize } , 6usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_op ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const arp_hdr ) ) . arp_data as * const _ as - usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , - stringify ! ( arp_data ) )); -} -impl Clone for arp_hdr { - fn clone(&self) -> Self { *self } + #[repr(C, packed)] + #[derive(Debug, Default, Copy)] + pub struct arp_hdr { + pub arp_hrd: u16, + pub arp_pro: u16, + pub arp_hln: u8, + pub arp_pln: u8, + pub arp_op: u16, + pub arp_data: arp_ipv4, + } + #[test] + fn bindgen_test_layout_arp_hdr() { + assert_eq!(::std::mem::size_of::() , 28usize , concat ! ( + "Size of: " , stringify ! ( arp_hdr ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( arp_hdr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_hrd as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , + stringify ! ( arp_hrd ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_pro as * const _ as + usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , + stringify ! ( arp_pro ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_hln as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , + stringify ! ( arp_hln ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_pln as * const _ as + usize } , 5usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , + stringify ! ( arp_pln ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_op as * const _ as + usize } , 6usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , + stringify ! ( arp_op ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const arp_hdr ) ) . arp_data as * const _ + as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( arp_hdr ) , "::" , + stringify ! ( arp_data ) )); + } + impl Clone for arp_hdr { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index 2cc8578519..9e79848b9f 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -1,17 +1,19 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; -pub const RTE_MEMPOOL_OPS_NAMESIZE: ::std::os::raw::c_uint = 32; -pub const RTE_MEMPOOL_MAX_OPS_IDX: ::std::os::raw::c_uint = 16; -pub const RTE_HEAP_NUM_FREELISTS: ::std::os::raw::c_uint = 13; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct rte_mempool([u8; 0]); -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; + pub const RTE_MEMPOOL_OPS_NAMESIZE: ::std::os::raw::c_uint = 32; + pub const RTE_MEMPOOL_MAX_OPS_IDX: ::std::os::raw::c_uint = 16; + pub const RTE_HEAP_NUM_FREELISTS: ::std::os::raw::c_uint = 13; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct rte_mempool([u8; 0]); + /** * Prototype for implementation specific data provisioning function. * * The function should provide the implementation specific memory for @@ -21,122 +23,123 @@ pub struct rte_mempool([u8; 0]); * will be transparent to the application programmer. * This function should set mp->pool_data. */ -pub type rte_mempool_alloc_t = - ::std::option::Option ::std::os::raw::c_int>; -/** + pub type rte_mempool_alloc_t = + ::std::option::Option ::std::os::raw::c_int>; + /** * Free the opaque private data pointed to by mp->pool_data pointer. */ -pub type rte_mempool_free_t = - ::std::option::Option; -/** + pub type rte_mempool_free_t = + ::std::option::Option; + /** * Enqueue an object into the external pool. */ -pub type rte_mempool_enqueue_t = - ::std::option::Option ::std::os::raw::c_int>; -/** + pub type rte_mempool_enqueue_t = + ::std::option::Option ::std::os::raw::c_int>; + /** * Dequeue an object from the external pool. */ -pub type rte_mempool_dequeue_t = - ::std::option::Option ::std::os::raw::c_int>; -/** + pub type rte_mempool_dequeue_t = + ::std::option::Option ::std::os::raw::c_int>; + /** * Return the number of available objects in the external pool. */ -pub type rte_mempool_get_count = - ::std::option::Option ::std::os::raw::c_uint>; -/** Structure defining mempool operations structure */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_mempool_ops { - /**< Name of mempool ops struct. */ - pub name: [::std::os::raw::c_char; 32usize], - /**< Allocate private data. */ - pub alloc: rte_mempool_alloc_t, - /**< Free the external pool. */ - pub free: rte_mempool_free_t, - /**< Enqueue an object. */ - pub enqueue: rte_mempool_enqueue_t, - /**< Dequeue an object. */ - pub dequeue: rte_mempool_dequeue_t, - /**< Get qty of available objs. */ - pub get_count: rte_mempool_get_count, - pub __bindgen_padding_0: [u64; 7usize], -} -#[test] -fn bindgen_test_layout_rte_mempool_ops() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! - ( "Size of: " , stringify ! ( rte_mempool_ops ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops ) ) . name as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops ) , - "::" , stringify ! ( name ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops ) ) . alloc as * const _ - as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops ) , - "::" , stringify ! ( alloc ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops ) ) . free as * const _ - as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops ) , - "::" , stringify ! ( free ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops ) ) . enqueue as * const - _ as usize } , 48usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops ) , - "::" , stringify ! ( enqueue ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops ) ) . dequeue as * const - _ as usize } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops ) , - "::" , stringify ! ( dequeue ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops ) ) . get_count as * - const _ as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops ) , - "::" , stringify ! ( get_count ) )); -} -impl Clone for rte_mempool_ops { - fn clone(&self) -> Self { *self } -} -impl Default for rte_mempool_ops { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** + pub type rte_mempool_get_count = + ::std::option::Option ::std::os::raw::c_uint>; + /** Structure defining mempool operations structure */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_mempool_ops { + /**< Name of mempool ops struct. */ + pub name: [::std::os::raw::c_char; 32usize], + /**< Allocate private data. */ + pub alloc: rte_mempool_alloc_t, + /**< Free the external pool. */ + pub free: rte_mempool_free_t, + /**< Enqueue an object. */ + pub enqueue: rte_mempool_enqueue_t, + /**< Dequeue an object. */ + pub dequeue: rte_mempool_dequeue_t, + /**< Get qty of available objs. */ + pub get_count: rte_mempool_get_count, + pub __bindgen_padding_0: [u64; 7usize], + } + #[test] + fn bindgen_test_layout_rte_mempool_ops() { + assert_eq!(::std::mem::size_of::() , 128usize , + concat ! ( "Size of: " , stringify ! ( rte_mempool_ops ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . name as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mempool_ops ) , + "::" , stringify ! ( name ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . alloc as * + const _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mempool_ops ) , + "::" , stringify ! ( alloc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . free as * const + _ as usize } , 40usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mempool_ops ) , + "::" , stringify ! ( free ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . enqueue as * + const _ as usize } , 48usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mempool_ops ) , + "::" , stringify ! ( enqueue ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . dequeue as * + const _ as usize } , 56usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mempool_ops ) , + "::" , stringify ! ( dequeue ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops ) ) . get_count as * + const _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mempool_ops ) , + "::" , stringify ! ( get_count ) )); + } + impl Clone for rte_mempool_ops { + fn clone(&self) -> Self { *self } + } + impl Default for rte_mempool_ops { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** * The rte_spinlock_t type. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_spinlock_t { - /**< lock status 0 = unlocked, 1 = locked */ - pub locked: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_rte_spinlock_t() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( rte_spinlock_t ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_spinlock_t ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_spinlock_t ) ) . locked as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_spinlock_t ) , "::" - , stringify ! ( locked ) )); -} -impl Clone for rte_spinlock_t { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_spinlock_t { + /**< lock status 0 = unlocked, 1 = locked */ + pub locked: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_rte_spinlock_t() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( rte_spinlock_t ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_spinlock_t ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_spinlock_t ) ) . locked as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_spinlock_t ) , + "::" , stringify ! ( locked ) )); + } + impl Clone for rte_spinlock_t { + fn clone(&self) -> Self { *self } + } + /** * Structure storing the table of registered ops structs, each of which contain * the function pointers for the mempool ops functions. * Each process has its own storage for this ops struct array so that @@ -145,120 +148,122 @@ impl Clone for rte_spinlock_t { * any function pointers stored directly in the mempool struct would not be. * This results in us simply having "ops_index" in the mempool struct. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_mempool_ops_table { - /**< Spinlock for add/delete. */ - pub sl: rte_spinlock_t, - /**< Number of used ops structs in the table. */ - pub num_ops: u32, - pub __bindgen_padding_0: [u64; 7usize], - /** + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_mempool_ops_table { + /**< Spinlock for add/delete. */ + pub sl: rte_spinlock_t, + /**< Number of used ops structs in the table. */ + pub num_ops: u32, + pub __bindgen_padding_0: [u64; 7usize], + /** * Storage for all possible ops structs. */ - pub ops: [rte_mempool_ops; 16usize], -} -#[test] -fn bindgen_test_layout_rte_mempool_ops_table() { - assert_eq!(::std::mem::size_of::() , 2112usize , - concat ! ( "Size of: " , stringify ! ( rte_mempool_ops_table ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops_table ) ) . sl as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops_table ) - , "::" , stringify ! ( sl ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops_table ) ) . num_ops as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops_table ) - , "::" , stringify ! ( num_ops ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mempool_ops_table ) ) . ops as * - const _ as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mempool_ops_table ) - , "::" , stringify ! ( ops ) )); -} -impl Clone for rte_mempool_ops_table { - fn clone(&self) -> Self { *self } -} -impl Default for rte_mempool_ops_table { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** + pub ops: [rte_mempool_ops; 16usize], + } + #[test] + fn bindgen_test_layout_rte_mempool_ops_table() { + assert_eq!(::std::mem::size_of::() , 2112usize + , concat ! ( + "Size of: " , stringify ! ( rte_mempool_ops_table ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops_table ) ) . sl as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mempool_ops_table ) , "::" , stringify ! ( sl ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops_table ) ) . num_ops + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mempool_ops_table ) , "::" , stringify ! ( num_ops ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mempool_ops_table ) ) . ops as * + const _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mempool_ops_table ) , "::" , stringify ! ( ops ) )); + } + impl Clone for rte_mempool_ops_table { + fn clone(&self) -> Self { *self } + } + 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 { - pub lh_first: *mut malloc_elem, -} -#[test] -fn bindgen_test_layout_malloc_heap__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , - concat ! ( - "Size of: " , stringify ! ( malloc_heap__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( malloc_heap__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const malloc_heap__bindgen_ty_1 ) ) . lh_first - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - malloc_heap__bindgen_ty_1 ) , "::" , stringify ! ( lh_first ) - )); -} -impl Clone for malloc_heap__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl Default for malloc_heap__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn bindgen_test_layout_malloc_heap() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( - "Size of: " , stringify ! ( malloc_heap ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const malloc_heap ) ) . lock as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( malloc_heap ) , "::" , - stringify ! ( lock ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const malloc_heap ) ) . free_head as * const _ - as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( malloc_heap ) , "::" , - stringify ! ( free_head ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const malloc_heap ) ) . alloc_count as * const - _ as usize } , 112usize , concat ! ( - "Alignment of field: " , stringify ! ( malloc_heap ) , "::" , - stringify ! ( alloc_count ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const malloc_heap ) ) . total_size as * const _ - as usize } , 120usize , concat ! ( - "Alignment of field: " , stringify ! ( malloc_heap ) , "::" , - stringify ! ( total_size ) )); -} -impl Clone for malloc_heap { - fn clone(&self) -> Self { *self } -} -impl Default for malloc_heap { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct malloc_elem { - pub _address: u8, -} -impl Clone for malloc_elem { - fn clone(&self) -> Self { *self } + #[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 { + pub lh_first: *mut malloc_elem, + } + #[test] + fn bindgen_test_layout_malloc_heap__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize + , concat ! ( + "Size of: " , stringify ! ( malloc_heap__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( malloc_heap__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap__bindgen_ty_1 ) ) . + lh_first as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + malloc_heap__bindgen_ty_1 ) , "::" , stringify ! ( + lh_first ) )); + } + impl Clone for malloc_heap__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Default for malloc_heap__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn bindgen_test_layout_malloc_heap() { + assert_eq!(::std::mem::size_of::() , 128usize , concat ! + ( "Size of: " , stringify ! ( malloc_heap ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . lock as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( malloc_heap ) , + "::" , stringify ! ( lock ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . free_head as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( malloc_heap ) , + "::" , stringify ! ( free_head ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . alloc_count as * + const _ as usize } , 112usize , concat ! ( + "Alignment of field: " , stringify ! ( malloc_heap ) , + "::" , stringify ! ( alloc_count ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const malloc_heap ) ) . total_size as * + const _ as usize } , 120usize , concat ! ( + "Alignment of field: " , stringify ! ( malloc_heap ) , + "::" , stringify ! ( total_size ) )); + } + impl Clone for malloc_heap { + fn clone(&self) -> Self { *self } + } + impl Default for malloc_heap { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct malloc_elem { + pub _address: u8, + } + impl Clone for malloc_elem { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index c395f08d77..d97edf7ca7 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -1,207 +1,212 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; -pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: ::std::os::raw::c_uint = 4; -pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX; -pub const IP_FIRST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_FIRST_FRAG_IDX; -pub const IP_MIN_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MIN_FRAG_NUM; -pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { - IP_LAST_FRAG_IDX = 0, - IP_FIRST_FRAG_IDX = 1, - IP_MIN_FRAG_NUM = 2, - IP_MAX_FRAG_NUM = 4, -} -/** @internal fragmented mbuf */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ip_frag { - /**< offset into the packet */ - pub ofs: u16, - /**< length of fragment */ - pub len: u16, - /**< fragment mbuf */ - pub mb: *mut rte_mbuf, -} -#[test] -fn bindgen_test_layout_ip_frag() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( ip_frag ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ip_frag ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag ) ) . ofs as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag ) , "::" , - stringify ! ( ofs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag ) ) . len as * const _ as usize } - , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag ) , "::" , - stringify ! ( len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag ) ) . mb as * const _ as usize } - , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag ) , "::" , - stringify ! ( mb ) )); -} -impl Clone for ip_frag { - fn clone(&self) -> Self { *self } -} -impl Default for ip_frag { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** @internal to uniquely indetify fragmented datagram. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct ip_frag_key { - /**< src address, first 8 bytes used for IPv4 */ - pub src_dst: [u64; 4usize], - /**< dst address */ - pub id: u32, - /**< src/dst key length */ - pub key_len: u32, -} -#[test] -fn bindgen_test_layout_ip_frag_key() { - assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( - "Size of: " , stringify ! ( ip_frag_key ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ip_frag_key ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_key ) ) . src_dst as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , - stringify ! ( src_dst ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_key ) ) . id as * const _ as - usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , - stringify ! ( id ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_key ) ) . key_len as * const _ as - usize } , 36usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , - stringify ! ( key_len ) )); -} -impl Clone for ip_frag_key { - fn clone(&self) -> Self { *self } -} -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; + pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: ::std::os::raw::c_uint = 4; + pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = + _bindgen_ty_1::IP_LAST_FRAG_IDX; + pub const IP_FIRST_FRAG_IDX: _bindgen_ty_1 = + _bindgen_ty_1::IP_FIRST_FRAG_IDX; + pub const IP_MIN_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MIN_FRAG_NUM; + pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { + IP_LAST_FRAG_IDX = 0, + IP_FIRST_FRAG_IDX = 1, + IP_MIN_FRAG_NUM = 2, + IP_MAX_FRAG_NUM = 4, + } + /** @internal fragmented mbuf */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct ip_frag { + /**< offset into the packet */ + pub ofs: u16, + /**< length of fragment */ + pub len: u16, + /**< fragment mbuf */ + pub mb: *mut rte_mbuf, + } + #[test] + fn bindgen_test_layout_ip_frag() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( ip_frag ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( ip_frag ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . ofs as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( ofs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . len as * const _ as + usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . mb as * const _ as + usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( mb ) )); + } + impl Clone for ip_frag { + fn clone(&self) -> Self { *self } + } + impl Default for ip_frag { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** @internal to uniquely indetify fragmented datagram. */ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct ip_frag_key { + /**< src address, first 8 bytes used for IPv4 */ + pub src_dst: [u64; 4usize], + /**< dst address */ + pub id: u32, + /**< src/dst key length */ + pub key_len: u32, + } + #[test] + fn bindgen_test_layout_ip_frag_key() { + assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( + "Size of: " , stringify ! ( ip_frag_key ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( ip_frag_key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . src_dst as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , + "::" , stringify ! ( src_dst ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . id as * const _ as + usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , + "::" , stringify ! ( id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . key_len as * const + _ as usize } , 36usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , + "::" , stringify ! ( key_len ) )); + } + 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 { - pub tqe_next: *mut ip_frag_pkt, - pub tqe_prev: *mut *mut ip_frag_pkt, -} -#[test] -fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 16usize , - concat ! ( - "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_next - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_next ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_prev - as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_prev ) - )); -} -impl Clone for ip_frag_pkt__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl Default for ip_frag_pkt__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn bindgen_test_layout_ip_frag_pkt() { - assert_eq!(::std::mem::size_of::() , 192usize , concat ! ( - "Size of: " , stringify ! ( ip_frag_pkt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . lru as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( lru ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . key as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( key ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . start as * const _ as - usize } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( start ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . total_size as * const _ - as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( total_size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . frag_size as * const _ - as usize } , 68usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( frag_size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . last_idx as * const _ - as usize } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( last_idx ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . frags as * const _ as - usize } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( frags ) )); -} -impl Clone for ip_frag_pkt { - fn clone(&self) -> Self { *self } -} -impl Default for ip_frag_pkt { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/**< fragment mbuf */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf { - pub _address: u8, -} -impl Clone for rte_mbuf { - fn clone(&self) -> Self { *self } + #[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 { + pub tqe_next: *mut ip_frag_pkt, + pub tqe_prev: *mut *mut ip_frag_pkt, + } + #[test] + fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 16usize , concat ! ( + "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( ip_frag_pkt__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . + tqe_next as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( + tqe_next ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . + tqe_prev as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( + tqe_prev ) )); + } + impl Clone for ip_frag_pkt__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Default for ip_frag_pkt__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn bindgen_test_layout_ip_frag_pkt() { + assert_eq!(::std::mem::size_of::() , 192usize , concat ! + ( "Size of: " , stringify ! ( ip_frag_pkt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . lru as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( lru ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . key as * const _ as + usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . start as * const _ + as usize } , 56usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( start ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . total_size as * + const _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( total_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . frag_size as * + const _ as usize } , 68usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( frag_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . last_idx as * const + _ as usize } , 72usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( last_idx ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . frags as * const _ + as usize } , 80usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( frags ) )); + } + impl Clone for ip_frag_pkt { + fn clone(&self) -> Self { *self } + } + impl Default for ip_frag_pkt { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /**< fragment mbuf */ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_mbuf { + pub _address: u8, + } + impl Clone for rte_mbuf { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs index 791ea9b3e2..d61a249ebb 100644 --- a/tests/expectations/tests/layout_cmdline_token.rs +++ b/tests/expectations/tests/layout_cmdline_token.rs @@ -1,44 +1,48 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** * Stores a pointer to the ops struct, and the offset: the place to * write the parsed result in the destination structure. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct cmdline_token_hdr { - pub ops: *mut cmdline_token_ops, - pub offset: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_cmdline_token_hdr() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! - ( "Size of: " , stringify ! ( cmdline_token_hdr ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat - ! ( "Alignment of " , stringify ! ( cmdline_token_hdr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_hdr ) ) . ops as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_hdr ) , - "::" , stringify ! ( ops ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_hdr ) ) . offset as * const - _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_hdr ) , - "::" , stringify ! ( offset ) )); -} -impl Clone for cmdline_token_hdr { - fn clone(&self) -> Self { *self } -} -impl Default for cmdline_token_hdr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; -/** + #[repr(C)] + #[derive(Debug, Copy)] + pub struct cmdline_token_hdr { + pub ops: *mut cmdline_token_ops, + pub offset: ::std::os::raw::c_uint, + } + #[test] + fn bindgen_test_layout_cmdline_token_hdr() { + assert_eq!(::std::mem::size_of::() , 16usize , + concat ! ( "Size of: " , stringify ! ( cmdline_token_hdr ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( cmdline_token_hdr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr ) ) . ops as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_hdr ) + , "::" , stringify ! ( ops ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_hdr ) ) . offset as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_hdr ) + , "::" , stringify ! ( offset ) )); + } + impl Clone for cmdline_token_hdr { + fn clone(&self) -> Self { *self } + } + impl Default for cmdline_token_hdr { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; + /** * A token is defined by this structure. * * parse() takes the token as first argument, then the source buffer @@ -57,139 +61,150 @@ pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; * get_help() fills the dstbuf with the help for the token. It returns * -1 on error and 0 on success. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct cmdline_token_ops { - /** parse(token ptr, buf, res pts, buf len) */ - pub parse: ::std::option::Option ::std::os::raw::c_int>, - /** return the num of possible choices for this token */ - pub complete_get_nb: ::std::option::Option ::std::os::raw::c_int>, - /** return the elt x for this token (token, idx, dstbuf, size) */ - pub complete_get_elt: ::std::option::Option ::std::os::raw::c_int>, - /** get help for this token (token, dstbuf, size) */ - pub get_help: ::std::option::Option ::std::os::raw::c_int>, -} -#[test] -fn bindgen_test_layout_cmdline_token_ops() { - assert_eq!(::std::mem::size_of::() , 32usize , concat ! - ( "Size of: " , stringify ! ( cmdline_token_ops ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat - ! ( "Alignment of " , stringify ! ( cmdline_token_ops ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_ops ) ) . parse as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_ops ) , - "::" , stringify ! ( parse ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_ops ) ) . complete_get_nb - as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_ops ) , - "::" , stringify ! ( complete_get_nb ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_ops ) ) . complete_get_elt - as * const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_ops ) , - "::" , stringify ! ( complete_get_elt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_ops ) ) . get_help as * - const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_ops ) , - "::" , stringify ! ( get_help ) )); -} -impl Clone for cmdline_token_ops { - fn clone(&self) -> Self { *self } -} -impl Default for cmdline_token_ops { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum cmdline_numtype { - UINT8 = 0, - UINT16 = 1, - UINT32 = 2, - UINT64 = 3, - INT8 = 4, - INT16 = 5, - INT32 = 6, - INT64 = 7, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct cmdline_token_num_data { - pub type_: cmdline_numtype, -} -#[test] -fn bindgen_test_layout_cmdline_token_num_data() { - assert_eq!(::std::mem::size_of::() , 4usize , - concat ! ( "Size of: " , stringify ! ( cmdline_token_num_data ) - )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( cmdline_token_num_data ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_num_data ) ) . type_ as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_num_data - ) , "::" , stringify ! ( type_ ) )); -} -impl Clone for cmdline_token_num_data { - fn clone(&self) -> Self { *self } -} -impl Default for cmdline_token_num_data { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct cmdline_token_num { - pub hdr: cmdline_token_hdr, - pub num_data: cmdline_token_num_data, -} -#[test] -fn bindgen_test_layout_cmdline_token_num() { - assert_eq!(::std::mem::size_of::() , 24usize , concat ! - ( "Size of: " , stringify ! ( cmdline_token_num ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat - ! ( "Alignment of " , stringify ! ( cmdline_token_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_num ) ) . hdr as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_num ) , - "::" , stringify ! ( hdr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const cmdline_token_num ) ) . num_data as * - const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( cmdline_token_num ) , - "::" , stringify ! ( num_data ) )); -} -impl Clone for cmdline_token_num { - fn clone(&self) -> Self { *self } -} -impl Default for cmdline_token_num { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct cmdline_token_ops { + /** parse(token ptr, buf, res pts, buf len) */ + pub parse: ::std::option::Option ::std::os::raw::c_int>, + /** return the num of possible choices for this token */ + pub complete_get_nb: ::std::option::Option + ::std::os::raw::c_int>, + /** return the elt x for this token (token, idx, dstbuf, size) */ + pub complete_get_elt: ::std::option::Option + ::std::os::raw::c_int>, + /** get help for this token (token, dstbuf, size) */ + pub get_help: ::std::option::Option ::std::os::raw::c_int>, + } + #[test] + fn bindgen_test_layout_cmdline_token_ops() { + assert_eq!(::std::mem::size_of::() , 32usize , + concat ! ( "Size of: " , stringify ! ( cmdline_token_ops ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( cmdline_token_ops ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_ops ) ) . parse as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_ops ) + , "::" , stringify ! ( parse ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_ops ) ) . + complete_get_nb as * const _ as usize } , 8usize , concat + ! ( + "Alignment of field: " , stringify ! ( cmdline_token_ops ) + , "::" , stringify ! ( complete_get_nb ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_ops ) ) . + complete_get_elt as * const _ as usize } , 16usize , + concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_ops ) + , "::" , stringify ! ( complete_get_elt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_ops ) ) . get_help as * + const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_ops ) + , "::" , stringify ! ( get_help ) )); + } + impl Clone for cmdline_token_ops { + fn clone(&self) -> Self { *self } + } + impl Default for cmdline_token_ops { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum cmdline_numtype { + UINT8 = 0, + UINT16 = 1, + UINT32 = 2, + UINT64 = 3, + INT8 = 4, + INT16 = 5, + INT32 = 6, + INT64 = 7, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct cmdline_token_num_data { + pub type_: cmdline_numtype, + } + #[test] + fn bindgen_test_layout_cmdline_token_num_data() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( cmdline_token_num_data ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( cmdline_token_num_data ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_num_data ) ) . type_ as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + cmdline_token_num_data ) , "::" , stringify ! ( type_ ) + )); + } + impl Clone for cmdline_token_num_data { + fn clone(&self) -> Self { *self } + } + impl Default for cmdline_token_num_data { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct cmdline_token_num { + pub hdr: cmdline_token_hdr, + pub num_data: cmdline_token_num_data, + } + #[test] + fn bindgen_test_layout_cmdline_token_num() { + assert_eq!(::std::mem::size_of::() , 24usize , + concat ! ( "Size of: " , stringify ! ( cmdline_token_num ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( cmdline_token_num ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_num ) ) . hdr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_num ) + , "::" , stringify ! ( hdr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const cmdline_token_num ) ) . num_data as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( cmdline_token_num ) + , "::" , stringify ! ( num_data ) )); + } + impl Clone for cmdline_token_num { + fn clone(&self) -> Self { *self } + } + impl Default for cmdline_token_num { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type cmdline_parse_token_num_t = cmdline_token_num; } -pub type cmdline_parse_token_num_t = cmdline_token_num; diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 4503fb823c..ad1c81ea04 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -1,391 +1,397 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } } -} -pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1; -pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2; -pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4; -pub const ETH_VMDQ_MAX_VLAN_FILTERS: ::std::os::raw::c_uint = 64; -pub const ETH_DCB_NUM_USER_PRIORITIES: ::std::os::raw::c_uint = 8; -pub const ETH_VMDQ_DCB_NUM_QUEUES: ::std::os::raw::c_uint = 128; -pub const ETH_DCB_NUM_QUEUES: ::std::os::raw::c_uint = 128; -pub const RTE_ETH_FDIR_MAX_FLEXLEN: ::std::os::raw::c_uint = 16; -pub const RTE_ETH_INSET_SIZE_MAX: ::std::os::raw::c_uint = 128; -pub const RTE_ETH_FLOW_UNKNOWN: ::std::os::raw::c_uint = 0; -pub const RTE_ETH_FLOW_RAW: ::std::os::raw::c_uint = 1; -pub const RTE_ETH_FLOW_IPV4: ::std::os::raw::c_uint = 2; -pub const RTE_ETH_FLOW_FRAG_IPV4: ::std::os::raw::c_uint = 3; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: ::std::os::raw::c_uint = 4; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: ::std::os::raw::c_uint = 5; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: ::std::os::raw::c_uint = 6; -pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: ::std::os::raw::c_uint = 7; -pub const RTE_ETH_FLOW_IPV6: ::std::os::raw::c_uint = 8; -pub const RTE_ETH_FLOW_FRAG_IPV6: ::std::os::raw::c_uint = 9; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: ::std::os::raw::c_uint = 10; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: ::std::os::raw::c_uint = 11; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: ::std::os::raw::c_uint = 12; -pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: ::std::os::raw::c_uint = 13; -pub const RTE_ETH_FLOW_L2_PAYLOAD: ::std::os::raw::c_uint = 14; -pub const RTE_ETH_FLOW_IPV6_EX: ::std::os::raw::c_uint = 15; -pub const RTE_ETH_FLOW_IPV6_TCP_EX: ::std::os::raw::c_uint = 16; -pub const RTE_ETH_FLOW_IPV6_UDP_EX: ::std::os::raw::c_uint = 17; -pub const RTE_ETH_FLOW_PORT: ::std::os::raw::c_uint = 18; -pub const RTE_ETH_FLOW_VXLAN: ::std::os::raw::c_uint = 19; -pub const RTE_ETH_FLOW_GENEVE: ::std::os::raw::c_uint = 20; -pub const RTE_ETH_FLOW_NVGRE: ::std::os::raw::c_uint = 21; -pub const RTE_ETH_FLOW_MAX: ::std::os::raw::c_uint = 22; -#[repr(u32)] -/** + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1; + pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2; + pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4; + pub const ETH_VMDQ_MAX_VLAN_FILTERS: ::std::os::raw::c_uint = 64; + pub const ETH_DCB_NUM_USER_PRIORITIES: ::std::os::raw::c_uint = 8; + pub const ETH_VMDQ_DCB_NUM_QUEUES: ::std::os::raw::c_uint = 128; + pub const ETH_DCB_NUM_QUEUES: ::std::os::raw::c_uint = 128; + pub const RTE_ETH_FDIR_MAX_FLEXLEN: ::std::os::raw::c_uint = 16; + pub const RTE_ETH_INSET_SIZE_MAX: ::std::os::raw::c_uint = 128; + pub const RTE_ETH_FLOW_UNKNOWN: ::std::os::raw::c_uint = 0; + pub const RTE_ETH_FLOW_RAW: ::std::os::raw::c_uint = 1; + pub const RTE_ETH_FLOW_IPV4: ::std::os::raw::c_uint = 2; + pub const RTE_ETH_FLOW_FRAG_IPV4: ::std::os::raw::c_uint = 3; + pub const RTE_ETH_FLOW_NONFRAG_IPV4_TCP: ::std::os::raw::c_uint = 4; + pub const RTE_ETH_FLOW_NONFRAG_IPV4_UDP: ::std::os::raw::c_uint = 5; + pub const RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: ::std::os::raw::c_uint = 6; + pub const RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: ::std::os::raw::c_uint = 7; + pub const RTE_ETH_FLOW_IPV6: ::std::os::raw::c_uint = 8; + pub const RTE_ETH_FLOW_FRAG_IPV6: ::std::os::raw::c_uint = 9; + pub const RTE_ETH_FLOW_NONFRAG_IPV6_TCP: ::std::os::raw::c_uint = 10; + pub const RTE_ETH_FLOW_NONFRAG_IPV6_UDP: ::std::os::raw::c_uint = 11; + pub const RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: ::std::os::raw::c_uint = 12; + pub const RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: ::std::os::raw::c_uint = 13; + pub const RTE_ETH_FLOW_L2_PAYLOAD: ::std::os::raw::c_uint = 14; + pub const RTE_ETH_FLOW_IPV6_EX: ::std::os::raw::c_uint = 15; + pub const RTE_ETH_FLOW_IPV6_TCP_EX: ::std::os::raw::c_uint = 16; + pub const RTE_ETH_FLOW_IPV6_UDP_EX: ::std::os::raw::c_uint = 17; + pub const RTE_ETH_FLOW_PORT: ::std::os::raw::c_uint = 18; + pub const RTE_ETH_FLOW_VXLAN: ::std::os::raw::c_uint = 19; + pub const RTE_ETH_FLOW_GENEVE: ::std::os::raw::c_uint = 20; + pub const RTE_ETH_FLOW_NVGRE: ::std::os::raw::c_uint = 21; + pub const RTE_ETH_FLOW_MAX: ::std::os::raw::c_uint = 22; + #[repr(u32)] + /** * A set of values to identify what method is to be used to route * packets to multiple queues. */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_eth_rx_mq_mode { - ETH_MQ_RX_NONE = 0, - ETH_MQ_RX_RSS = 1, - ETH_MQ_RX_DCB = 2, - ETH_MQ_RX_DCB_RSS = 3, - ETH_MQ_RX_VMDQ_ONLY = 4, - ETH_MQ_RX_VMDQ_RSS = 5, - ETH_MQ_RX_VMDQ_DCB = 6, - ETH_MQ_RX_VMDQ_DCB_RSS = 7, -} -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_eth_rx_mq_mode { + ETH_MQ_RX_NONE = 0, + ETH_MQ_RX_RSS = 1, + ETH_MQ_RX_DCB = 2, + ETH_MQ_RX_DCB_RSS = 3, + ETH_MQ_RX_VMDQ_ONLY = 4, + ETH_MQ_RX_VMDQ_RSS = 5, + ETH_MQ_RX_VMDQ_DCB = 6, + ETH_MQ_RX_VMDQ_DCB_RSS = 7, + } + /** * A structure used to configure the RX features of an Ethernet port. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_rxmode { - /** The multi-queue packet distribution mode to be used, e.g. RSS. */ - pub mq_mode: rte_eth_rx_mq_mode, - /**< Only used if jumbo_frame enabled. */ - pub max_rx_pkt_len: u32, - /**< hdr buf size (header_split enabled).*/ - pub split_hdr_size: u16, - pub _bitfield_1: [u8; 2usize], -} -#[test] -fn bindgen_test_layout_rte_eth_rxmode() { - assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( - "Size of: " , stringify ! ( rte_eth_rxmode ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_eth_rxmode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_rxmode ) ) . mq_mode as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , "::" - , stringify ! ( mq_mode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_rxmode ) ) . max_rx_pkt_len as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , "::" - , stringify ! ( max_rx_pkt_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_rxmode ) ) . split_hdr_size as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , "::" - , stringify ! ( split_hdr_size ) )); -} -impl Clone for rte_eth_rxmode { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_rxmode { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl rte_eth_rxmode { - #[inline] - pub fn header_split(&self) -> u16 { - let mask = 1usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_header_split(&mut self, val: u16) { - let mask = 1usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_ip_checksum(&self) -> u16 { - let mask = 2usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_hw_ip_checksum(&mut self, val: u16) { - let mask = 2usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_vlan_filter(&self) -> u16 { - let mask = 4usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 2usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_hw_vlan_filter(&mut self, val: u16) { - let mask = 4usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 2usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_vlan_strip(&self) -> u16 { - let mask = 8usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 3usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_hw_vlan_strip(&mut self, val: u16) { - let mask = 8usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 3usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_vlan_extend(&self) -> u16 { - let mask = 16usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 4usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_hw_vlan_extend(&mut self, val: u16) { - let mask = 16usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 4usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn jumbo_frame(&self) -> u16 { - let mask = 32usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 5usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_jumbo_frame(&mut self, val: u16) { - let mask = 32usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 5usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_strip_crc(&self) -> u16 { - let mask = 64usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 6usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_hw_strip_crc(&mut self, val: u16) { - let mask = 64usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 6usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn enable_scatter(&self) -> u16 { - let mask = 128usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 7usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_enable_scatter(&mut self, val: u16) { - let mask = 128usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 7usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn enable_lro(&self) -> u16 { - let mask = 256usize as u16; - let field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 8usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_enable_lro(&mut self, val: u16) { - let mask = 256usize as u16; - let val = val as u16 as u16; - let mut field_val: u16 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 8usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_rxmode { + /** The multi-queue packet distribution mode to be used, e.g. RSS. */ + pub mq_mode: rte_eth_rx_mq_mode, + /**< Only used if jumbo_frame enabled. */ + pub max_rx_pkt_len: u32, + /**< hdr buf size (header_split enabled).*/ + pub split_hdr_size: u16, + pub _bitfield_1: [u8; 2usize], } -} -#[repr(u32)] -/** + #[test] + fn bindgen_test_layout_rte_eth_rxmode() { + assert_eq!(::std::mem::size_of::() , 12usize , concat + ! ( "Size of: " , stringify ! ( rte_eth_rxmode ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_eth_rxmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . mq_mode as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , + "::" , stringify ! ( mq_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . max_rx_pkt_len + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , + "::" , stringify ! ( max_rx_pkt_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rxmode ) ) . split_hdr_size + as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rxmode ) , + "::" , stringify ! ( split_hdr_size ) )); + } + impl Clone for rte_eth_rxmode { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_rxmode { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl rte_eth_rxmode { + #[inline] + pub fn header_split(&self) -> u16 { + let mask = 1usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_header_split(&mut self, val: u16) { + let mask = 1usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_ip_checksum(&self) -> u16 { + let mask = 2usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_ip_checksum(&mut self, val: u16) { + let mask = 2usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_vlan_filter(&self) -> u16 { + let mask = 4usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_vlan_filter(&mut self, val: u16) { + let mask = 4usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 2usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_vlan_strip(&self) -> u16 { + let mask = 8usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 3usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_vlan_strip(&mut self, val: u16) { + let mask = 8usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 3usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_vlan_extend(&self) -> u16 { + let mask = 16usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 4usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_vlan_extend(&mut self, val: u16) { + let mask = 16usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 4usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn jumbo_frame(&self) -> u16 { + let mask = 32usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 5usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_jumbo_frame(&mut self, val: u16) { + let mask = 32usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 5usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_strip_crc(&self) -> u16 { + let mask = 64usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 6usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_hw_strip_crc(&mut self, val: u16) { + let mask = 64usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 6usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn enable_scatter(&self) -> u16 { + let mask = 128usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_enable_scatter(&mut self, val: u16) { + let mask = 128usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 7usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn enable_lro(&self) -> u16 { + let mask = 256usize as u16; + let field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 8usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_enable_lro(&mut self, val: u16) { + let mask = 256usize as u16; + let val = val as u16 as u16; + let mut field_val: u16 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 8usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[repr(u32)] + /** * A set of values to identify what method is to be used to transmit * packets using multi-TCs. */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_eth_tx_mq_mode { - ETH_MQ_TX_NONE = 0, - ETH_MQ_TX_DCB = 1, - ETH_MQ_TX_VMDQ_DCB = 2, - ETH_MQ_TX_VMDQ_ONLY = 3, -} -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_eth_tx_mq_mode { + ETH_MQ_TX_NONE = 0, + ETH_MQ_TX_DCB = 1, + ETH_MQ_TX_VMDQ_DCB = 2, + ETH_MQ_TX_VMDQ_ONLY = 3, + } + /** * A structure used to configure the TX features of an Ethernet port. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_txmode { - /**< TX multi-queues mode. */ - pub mq_mode: rte_eth_tx_mq_mode, - pub pvid: u16, - pub _bitfield_1: u8, - pub __bindgen_padding_0: u8, -} -#[test] -fn bindgen_test_layout_rte_eth_txmode() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( rte_eth_txmode ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_eth_txmode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_txmode ) ) . mq_mode as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_txmode ) , "::" - , stringify ! ( mq_mode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_txmode ) ) . pvid as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_txmode ) , "::" - , stringify ! ( pvid ) )); -} -impl Clone for rte_eth_txmode { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_txmode { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl rte_eth_txmode { - #[inline] - pub fn hw_vlan_reject_tagged(&self) -> u8 { - let mask = 1usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u8) } - } - #[inline] - pub fn set_hw_vlan_reject_tagged(&mut self, val: u8) { - let mask = 1usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_vlan_reject_untagged(&self) -> u8 { - let mask = 2usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u8) } - } - #[inline] - pub fn set_hw_vlan_reject_untagged(&mut self, val: u8) { - let mask = 2usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn hw_vlan_insert_pvid(&self) -> u8 { - let mask = 4usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 2usize; - unsafe { ::std::mem::transmute(val as u8) } - } - #[inline] - pub fn set_hw_vlan_insert_pvid(&mut self, val: u8) { - let mask = 4usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 2usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_txmode { + /**< TX multi-queues mode. */ + pub mq_mode: rte_eth_tx_mq_mode, + pub pvid: u16, + pub _bitfield_1: u8, + pub __bindgen_padding_0: u8, } -} -/** + #[test] + fn bindgen_test_layout_rte_eth_txmode() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! + ( "Size of: " , stringify ! ( rte_eth_txmode ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_eth_txmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_txmode ) ) . mq_mode as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_txmode ) , + "::" , stringify ! ( mq_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_txmode ) ) . pvid as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_txmode ) , + "::" , stringify ! ( pvid ) )); + } + impl Clone for rte_eth_txmode { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_txmode { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl rte_eth_txmode { + #[inline] + pub fn hw_vlan_reject_tagged(&self) -> u8 { + let mask = 1usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_hw_vlan_reject_tagged(&mut self, val: u8) { + let mask = 1usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_vlan_reject_untagged(&self) -> u8 { + let mask = 2usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_hw_vlan_reject_untagged(&mut self, val: u8) { + let mask = 2usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn hw_vlan_insert_pvid(&self) -> u8 { + let mask = 4usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_hw_vlan_insert_pvid(&mut self, val: u8) { + let mask = 4usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 2usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + /** * A structure used to configure the Receive Side Scaling (RSS) feature * of an Ethernet port. * If not NULL, the *rss_key* pointer of the *rss_conf* structure points @@ -402,64 +408,66 @@ impl rte_eth_txmode { * types of IPv4/IPv6 packets to which the RSS hashing must be applied. * Supplying an *rss_hf* equal to zero disables the RSS feature. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_rss_conf { - /**< If not NULL, 40-byte hash key. */ - pub rss_key: *mut u8, - /**< hash key length in bytes. */ - pub rss_key_len: u8, - /**< Hash functions to apply - see below. */ - pub rss_hf: u64, -} -#[test] -fn bindgen_test_layout_rte_eth_rss_conf() { - assert_eq!(::std::mem::size_of::() , 24usize , concat ! - ( "Size of: " , stringify ! ( rte_eth_rss_conf ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! - ( "Alignment of " , stringify ! ( rte_eth_rss_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) , - "::" , stringify ! ( rss_key ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key_len as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) , - "::" , stringify ! ( rss_key_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_hf as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) , - "::" , stringify ! ( rss_hf ) )); -} -impl Clone for rte_eth_rss_conf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_rss_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(u32)] -/** + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_rss_conf { + /**< If not NULL, 40-byte hash key. */ + pub rss_key: *mut u8, + /**< hash key length in bytes. */ + pub rss_key_len: u8, + /**< Hash functions to apply - see below. */ + pub rss_hf: u64, + } + #[test] + fn bindgen_test_layout_rte_eth_rss_conf() { + assert_eq!(::std::mem::size_of::() , 24usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_rss_conf ) + )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_rss_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) + , "::" , stringify ! ( rss_key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_key_len as + * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) + , "::" , stringify ! ( rss_key_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_rss_conf ) ) . rss_hf as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_rss_conf ) + , "::" , stringify ! ( rss_hf ) )); + } + impl Clone for rte_eth_rss_conf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_rss_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(u32)] + /** * This enum indicates the possible number of traffic classes * in DCB configratioins */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_eth_nb_tcs { ETH_4_TCS = 4, ETH_8_TCS = 8, } -#[repr(u32)] -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_eth_nb_tcs { ETH_4_TCS = 4, ETH_8_TCS = 8, } + #[repr(u32)] + /** * This enum indicates the possible number of queue pools * in VMDQ configurations. */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_eth_nb_pools { - ETH_8_POOLS = 8, - ETH_16_POOLS = 16, - ETH_32_POOLS = 32, - ETH_64_POOLS = 64, -} -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_eth_nb_pools { + ETH_8_POOLS = 8, + ETH_16_POOLS = 16, + ETH_32_POOLS = 32, + ETH_64_POOLS = 64, + } + /** * A structure used to configure the VMDQ+DCB feature * of an Ethernet port. * @@ -470,931 +478,983 @@ pub enum rte_eth_nb_pools { * 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 { - /**< The vlan id of the received frame */ - pub vlan_id: u16, - /**< Bitmask of pools for packet rx */ - pub pools: u64, -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 16usize , concat ! ( - "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf__bindgen_ty_1 - ) )); - assert_eq! (::std::mem::align_of::() - , 8usize , concat ! ( - "Alignment of " , stringify ! ( - rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) ) . - vlan_id as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) , "::" , stringify ! ( - vlan_id ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) ) . - pools as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) , "::" , stringify ! ( - pools ) )); -} -impl Clone for rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { - assert_eq!(::std::mem::size_of::() , 1040usize , - concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_vmdq_dcb_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . - nb_queue_pools as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - , "::" , stringify ! ( nb_queue_pools ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . - enable_default_pool as * const _ as usize } , 4usize , concat - ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - , "::" , stringify ! ( enable_default_pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . default_pool - as * const _ as usize } , 5usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - , "::" , stringify ! ( default_pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . nb_pool_maps - as * const _ as usize } , 6usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - , "::" , stringify ! ( nb_pool_maps ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . pool_map as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - , "::" , stringify ! ( pool_map ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . dcb_tc as * - const _ as usize } , 1032usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_dcb_conf ) - , "::" , stringify ! ( dcb_tc ) )); -} -impl Default for rte_eth_vmdq_dcb_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_dcb_rx_conf { - /**< Possible DCB TCs, 4 or 8 TCs */ - pub nb_tcs: rte_eth_nb_tcs, - /** Traffic class each UP mapped to. */ - pub dcb_tc: [u8; 8usize], -} -#[test] -fn bindgen_test_layout_rte_eth_dcb_rx_conf() { - assert_eq!(::std::mem::size_of::() , 12usize , concat - ! ( "Size of: " , stringify ! ( rte_eth_dcb_rx_conf ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_dcb_rx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . nb_tcs as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_dcb_rx_conf ) , - "::" , stringify ! ( nb_tcs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . dcb_tc as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_dcb_rx_conf ) , - "::" , stringify ! ( dcb_tc ) )); -} -impl Clone for rte_eth_dcb_rx_conf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_dcb_rx_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_vmdq_dcb_tx_conf { - /**< With DCB, 16 or 32 pools. */ - pub nb_queue_pools: rte_eth_nb_pools, - /** Traffic class each UP mapped to. */ - pub dcb_tc: [u8; 8usize], -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() { - assert_eq!(::std::mem::size_of::() , 12usize , - concat ! ( - "Size of: " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . - nb_queue_pools as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_vmdq_dcb_tx_conf ) , "::" , stringify ! ( - nb_queue_pools ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . dcb_tc as - * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_vmdq_dcb_tx_conf ) , "::" , stringify ! ( dcb_tc ) )); -} -impl Clone for rte_eth_vmdq_dcb_tx_conf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_vmdq_dcb_tx_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_dcb_tx_conf { - /**< Possible DCB TCs, 4 or 8 TCs. */ - pub nb_tcs: rte_eth_nb_tcs, - /** Traffic class each UP mapped to. */ - pub dcb_tc: [u8; 8usize], -} -#[test] -fn bindgen_test_layout_rte_eth_dcb_tx_conf() { - assert_eq!(::std::mem::size_of::() , 12usize , concat - ! ( "Size of: " , stringify ! ( rte_eth_dcb_tx_conf ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_dcb_tx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . nb_tcs as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_dcb_tx_conf ) , - "::" , stringify ! ( nb_tcs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . dcb_tc as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_dcb_tx_conf ) , - "::" , stringify ! ( dcb_tc ) )); -} -impl Clone for rte_eth_dcb_tx_conf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_dcb_tx_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_vmdq_tx_conf { - /**< VMDq mode, 64 pools. */ - pub nb_queue_pools: rte_eth_nb_pools, -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_tx_conf() { - assert_eq!(::std::mem::size_of::() , 4usize , concat - ! ( "Size of: " , stringify ! ( rte_eth_vmdq_tx_conf ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_vmdq_tx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_tx_conf ) ) . nb_queue_pools - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_tx_conf ) - , "::" , stringify ! ( nb_queue_pools ) )); -} -impl Clone for rte_eth_vmdq_tx_conf { - fn clone(&self) -> Self { *self } -} -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 */ - pub vlan_id: u16, - /**< Bitmask of pools for packet rx */ - pub pools: u64, -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 16usize , concat ! ( - "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf__bindgen_ty_1 - ) )); - assert_eq! (::std::mem::align_of::() , - 8usize , concat ! ( - "Alignment of " , stringify ! ( - rte_eth_vmdq_rx_conf__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) ) . - vlan_id as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_vmdq_rx_conf__bindgen_ty_1 ) , "::" , stringify ! ( - vlan_id ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) ) . - pools as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_vmdq_rx_conf__bindgen_ty_1 ) , "::" , stringify ! ( - pools ) )); -} -impl Clone for rte_eth_vmdq_rx_conf__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { - assert_eq!(::std::mem::size_of::() , 1040usize , - concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf ) - )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_vmdq_rx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . nb_queue_pools - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( nb_queue_pools ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . - enable_default_pool as * const _ as usize } , 4usize , concat - ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( enable_default_pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . default_pool - as * const _ as usize } , 5usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( default_pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . - enable_loop_back as * const _ as usize } , 6usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( enable_loop_back ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . nb_pool_maps - as * const _ as usize } , 7usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( nb_pool_maps ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . rx_mode as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( rx_mode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . pool_map as * - const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_vmdq_rx_conf ) - , "::" , stringify ! ( pool_map ) )); -} -impl Default for rte_eth_vmdq_rx_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(u32)] -/** + #[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 { + /**< The vlan id of the received frame */ + pub vlan_id: u16, + /**< Bitmask of pools for packet rx */ + pub pools: u64, + } + #[test] + fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 16usize , concat ! ( + "Size of: " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 8usize , concat ! ( + "Alignment of " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) + ) . vlan_id as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) , "::" , stringify ! + ( vlan_id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) + ) . pools as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf__bindgen_ty_1 ) , "::" , stringify ! + ( pools ) )); + } + impl Clone for rte_eth_vmdq_dcb_conf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() { + assert_eq!(::std::mem::size_of::() , 1040usize + , concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf ) )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_dcb_conf ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf ) , "::" , stringify ! ( + nb_queue_pools ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + enable_default_pool as * const _ as usize } , 4usize , + concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf ) , "::" , stringify ! ( + enable_default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + default_pool as * const _ as usize } , 5usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf ) , "::" , stringify ! ( + default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . + nb_pool_maps as * const _ as usize } , 6usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf ) , "::" , stringify ! ( + nb_pool_maps ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . pool_map + as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf ) , "::" , stringify ! ( pool_map ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_conf ) ) . dcb_tc as + * const _ as usize } , 1032usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_conf ) , "::" , stringify ! ( dcb_tc ) + )); + } + impl Default for rte_eth_vmdq_dcb_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_dcb_rx_conf { + /**< Possible DCB TCs, 4 or 8 TCs */ + pub nb_tcs: rte_eth_nb_tcs, + /** Traffic class each UP mapped to. */ + pub dcb_tc: [u8; 8usize], + } + #[test] + fn bindgen_test_layout_rte_eth_dcb_rx_conf() { + assert_eq!(::std::mem::size_of::() , 12usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_dcb_rx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_dcb_rx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . nb_tcs as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_rx_conf + ) , "::" , stringify ! ( nb_tcs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_rx_conf ) ) . dcb_tc as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_rx_conf + ) , "::" , stringify ! ( dcb_tc ) )); + } + impl Clone for rte_eth_dcb_rx_conf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_dcb_rx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_vmdq_dcb_tx_conf { + /**< With DCB, 16 or 32 pools. */ + pub nb_queue_pools: rte_eth_nb_pools, + /** Traffic class each UP mapped to. */ + pub dcb_tc: [u8; 8usize], + } + #[test] + fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() { + assert_eq!(::std::mem::size_of::() , 12usize + , concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_tx_conf ) , "::" , stringify ! ( + nb_queue_pools ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_dcb_tx_conf ) ) . dcb_tc + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_dcb_tx_conf ) , "::" , stringify ! ( dcb_tc ) + )); + } + impl Clone for rte_eth_vmdq_dcb_tx_conf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_vmdq_dcb_tx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_dcb_tx_conf { + /**< Possible DCB TCs, 4 or 8 TCs. */ + pub nb_tcs: rte_eth_nb_tcs, + /** Traffic class each UP mapped to. */ + pub dcb_tc: [u8; 8usize], + } + #[test] + fn bindgen_test_layout_rte_eth_dcb_tx_conf() { + assert_eq!(::std::mem::size_of::() , 12usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_dcb_tx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . nb_tcs as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_tx_conf + ) , "::" , stringify ! ( nb_tcs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_dcb_tx_conf ) ) . dcb_tc as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_dcb_tx_conf + ) , "::" , stringify ! ( dcb_tc ) )); + } + impl Clone for rte_eth_dcb_tx_conf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_dcb_tx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_vmdq_tx_conf { + /**< VMDq mode, 64 pools. */ + pub nb_queue_pools: rte_eth_nb_pools, + } + #[test] + fn bindgen_test_layout_rte_eth_vmdq_tx_conf() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_tx_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_tx_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_tx_conf ) , "::" , stringify ! ( + nb_queue_pools ) )); + } + impl Clone for rte_eth_vmdq_tx_conf { + fn clone(&self) -> Self { *self } + } + 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 */ + pub vlan_id: u16, + /**< Bitmask of pools for packet rx */ + pub pools: u64, + } + #[test] + fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 16usize , concat ! ( + "Size of: " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 8usize , concat ! ( + "Alignment of " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) + ) . vlan_id as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) , "::" , stringify ! + ( vlan_id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf__bindgen_ty_1 ) + ) . pools as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf__bindgen_ty_1 ) , "::" , stringify ! + ( pools ) )); + } + impl Clone for rte_eth_vmdq_rx_conf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_eth_vmdq_rx_conf() { + assert_eq!(::std::mem::size_of::() , 1040usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf ) )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_vmdq_rx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + nb_queue_pools as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( + nb_queue_pools ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + enable_default_pool as * const _ as usize } , 4usize , + concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( + enable_default_pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + default_pool as * const _ as usize } , 5usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( default_pool + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + enable_loop_back as * const _ as usize } , 6usize , concat + ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( + enable_loop_back ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . + nb_pool_maps as * const _ as usize } , 7usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( nb_pool_maps + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . rx_mode as + * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( rx_mode ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_vmdq_rx_conf ) ) . pool_map + as * const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_vmdq_rx_conf ) , "::" , stringify ! ( pool_map ) + )); + } + impl Default for rte_eth_vmdq_rx_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(u32)] + /** * Flow Director setting modes: none, signature or perfect. */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_fdir_mode { - RTE_FDIR_MODE_NONE = 0, - RTE_FDIR_MODE_SIGNATURE = 1, - RTE_FDIR_MODE_PERFECT = 2, - RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - RTE_FDIR_MODE_PERFECT_TUNNEL = 4, -} -#[repr(u32)] -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_fdir_mode { + RTE_FDIR_MODE_NONE = 0, + RTE_FDIR_MODE_SIGNATURE = 1, + RTE_FDIR_MODE_PERFECT = 2, + RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, + RTE_FDIR_MODE_PERFECT_TUNNEL = 4, + } + #[repr(u32)] + /** * Memory space that can be configured to store Flow Director filters * in the board memory. */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_fdir_pballoc_type { - RTE_FDIR_PBALLOC_64K = 0, - RTE_FDIR_PBALLOC_128K = 1, - RTE_FDIR_PBALLOC_256K = 2, -} -#[repr(u32)] -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_fdir_pballoc_type { + RTE_FDIR_PBALLOC_64K = 0, + RTE_FDIR_PBALLOC_128K = 1, + RTE_FDIR_PBALLOC_256K = 2, + } + #[repr(u32)] + /** * Select report mode of FDIR hash information in RX descriptors. */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_fdir_status_mode { - RTE_FDIR_NO_REPORT_STATUS = 0, - RTE_FDIR_REPORT_STATUS = 1, - RTE_FDIR_REPORT_STATUS_ALWAYS = 2, -} -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_fdir_status_mode { + RTE_FDIR_NO_REPORT_STATUS = 0, + RTE_FDIR_REPORT_STATUS = 1, + RTE_FDIR_REPORT_STATUS_ALWAYS = 2, + } + /** * A structure used to define the input for IPV4 flow */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_eth_ipv4_flow { - /**< IPv4 source address in big endian. */ - pub src_ip: u32, - /**< IPv4 destination address in big endian. */ - pub dst_ip: u32, - /**< Type of service to match. */ - pub tos: u8, - /**< Time to live to match. */ - pub ttl: u8, - /**< Protocol, next header in big endian. */ - pub proto: u8, -} -#[test] -fn bindgen_test_layout_rte_eth_ipv4_flow() { - assert_eq!(::std::mem::size_of::() , 12usize , concat ! - ( "Size of: " , stringify ! ( rte_eth_ipv4_flow ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( rte_eth_ipv4_flow ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . src_ip as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , - "::" , stringify ! ( src_ip ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . dst_ip as * const - _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , - "::" , stringify ! ( dst_ip ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . tos as * const _ - as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , - "::" , stringify ! ( tos ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . ttl as * const _ - as usize } , 9usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , - "::" , stringify ! ( ttl ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . proto as * const - _ as usize } , 10usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) , - "::" , stringify ! ( proto ) )); -} -impl Clone for rte_eth_ipv4_flow { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_eth_ipv4_flow { + /**< IPv4 source address in big endian. */ + pub src_ip: u32, + /**< IPv4 destination address in big endian. */ + pub dst_ip: u32, + /**< Type of service to match. */ + pub tos: u8, + /**< Time to live to match. */ + pub ttl: u8, + /**< Protocol, next header in big endian. */ + pub proto: u8, + } + #[test] + fn bindgen_test_layout_rte_eth_ipv4_flow() { + assert_eq!(::std::mem::size_of::() , 12usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_ipv4_flow ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_ipv4_flow ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . src_ip as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) + , "::" , stringify ! ( src_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . dst_ip as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) + , "::" , stringify ! ( dst_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . tos as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) + , "::" , stringify ! ( tos ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . ttl as * + const _ as usize } , 9usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) + , "::" , stringify ! ( ttl ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv4_flow ) ) . proto as * + const _ as usize } , 10usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv4_flow ) + , "::" , stringify ! ( proto ) )); + } + impl Clone for rte_eth_ipv4_flow { + fn clone(&self) -> Self { *self } + } + /** * A structure used to define the input for IPV6 flow */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_eth_ipv6_flow { - /**< IPv6 source address in big endian. */ - pub src_ip: [u32; 4usize], - /**< IPv6 destination address in big endian. */ - pub dst_ip: [u32; 4usize], - /**< Traffic class to match. */ - pub tc: u8, - /**< Protocol, next header to match. */ - pub proto: u8, - /**< Hop limits to match. */ - pub hop_limits: u8, -} -#[test] -fn bindgen_test_layout_rte_eth_ipv6_flow() { - assert_eq!(::std::mem::size_of::() , 36usize , concat ! - ( "Size of: " , stringify ! ( rte_eth_ipv6_flow ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( rte_eth_ipv6_flow ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . src_ip as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , - "::" , stringify ! ( src_ip ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . dst_ip as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , - "::" , stringify ! ( dst_ip ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . tc as * const _ - as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , - "::" , stringify ! ( tc ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . proto as * const - _ as usize } , 33usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , - "::" , stringify ! ( proto ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . hop_limits as * - const _ as usize } , 34usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) , - "::" , stringify ! ( hop_limits ) )); -} -impl Clone for rte_eth_ipv6_flow { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_eth_ipv6_flow { + /**< IPv6 source address in big endian. */ + pub src_ip: [u32; 4usize], + /**< IPv6 destination address in big endian. */ + pub dst_ip: [u32; 4usize], + /**< Traffic class to match. */ + pub tc: u8, + /**< Protocol, next header to match. */ + pub proto: u8, + /**< Hop limits to match. */ + pub hop_limits: u8, + } + #[test] + fn bindgen_test_layout_rte_eth_ipv6_flow() { + assert_eq!(::std::mem::size_of::() , 36usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_ipv6_flow ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_ipv6_flow ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . src_ip as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) + , "::" , stringify ! ( src_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . dst_ip as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) + , "::" , stringify ! ( dst_ip ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . tc as * const + _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) + , "::" , stringify ! ( tc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . proto as * + const _ as usize } , 33usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) + , "::" , stringify ! ( proto ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_ipv6_flow ) ) . hop_limits as + * const _ as usize } , 34usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_ipv6_flow ) + , "::" , stringify ! ( hop_limits ) )); + } + impl Clone for rte_eth_ipv6_flow { + fn clone(&self) -> Self { *self } + } + /** * A structure used to configure FDIR masks that are used by the device * to match the various fields of RX packet headers. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_eth_fdir_masks { - /**< Bit mask for vlan_tci in big endian */ - pub vlan_tci_mask: u16, - /** Bit mask for ipv4 flow in big endian. */ - pub ipv4_mask: rte_eth_ipv4_flow, - /** Bit maks for ipv6 flow in big endian. */ - pub ipv6_mask: rte_eth_ipv6_flow, - /** Bit mask for L4 source port in big endian. */ - pub src_port_mask: u16, - /** Bit mask for L4 destination port in big endian. */ - pub dst_port_mask: u16, - /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_eth_fdir_masks { + /**< Bit mask for vlan_tci in big endian */ + pub vlan_tci_mask: u16, + /** Bit mask for ipv4 flow in big endian. */ + pub ipv4_mask: rte_eth_ipv4_flow, + /** Bit maks for ipv6 flow in big endian. */ + pub ipv6_mask: rte_eth_ipv6_flow, + /** Bit mask for L4 source port in big endian. */ + pub src_port_mask: u16, + /** Bit mask for L4 destination port in big endian. */ + pub dst_port_mask: u16, + /** 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the first byte on the wire */ - pub mac_addr_byte_mask: u8, - /** Bit mask for tunnel ID in big endian. */ - pub tunnel_id_mask: u32, - /**< 1 - Match tunnel type, + pub mac_addr_byte_mask: u8, + /** Bit mask for tunnel ID in big endian. */ + pub tunnel_id_mask: u32, + /**< 1 - Match tunnel type, 0 - Ignore tunnel type. */ - pub tunnel_type_mask: u8, -} -#[test] -fn bindgen_test_layout_rte_eth_fdir_masks() { - assert_eq!(::std::mem::size_of::() , 68usize , concat - ! ( "Size of: " , stringify ! ( rte_eth_fdir_masks ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( rte_eth_fdir_masks ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . vlan_tci_mask as - * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( vlan_tci_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv4_mask as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( ipv4_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv6_mask as * - const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( ipv6_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . src_port_mask as - * const _ as usize } , 52usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( src_port_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . dst_port_mask as - * const _ as usize } , 54usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( dst_port_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . - mac_addr_byte_mask as * const _ as usize } , 56usize , concat - ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( mac_addr_byte_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . tunnel_id_mask - as * const _ as usize } , 60usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( tunnel_id_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_masks ) ) . tunnel_type_mask - as * const _ as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_masks ) , - "::" , stringify ! ( tunnel_type_mask ) )); -} -impl Clone for rte_eth_fdir_masks { - fn clone(&self) -> Self { *self } -} -#[repr(u32)] -/** + pub tunnel_type_mask: u8, + } + #[test] + fn bindgen_test_layout_rte_eth_fdir_masks() { + assert_eq!(::std::mem::size_of::() , 68usize , + concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_masks ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( rte_eth_fdir_masks ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + vlan_tci_mask as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( vlan_tci_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv4_mask as + * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( ipv4_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . ipv6_mask as + * const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( ipv6_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + src_port_mask as * const _ as usize } , 52usize , concat ! + ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( src_port_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + dst_port_mask as * const _ as usize } , 54usize , concat ! + ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( dst_port_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + mac_addr_byte_mask as * const _ as usize } , 56usize , + concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( mac_addr_byte_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + tunnel_id_mask as * const _ as usize } , 60usize , concat + ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( tunnel_id_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_masks ) ) . + tunnel_type_mask as * const _ as usize } , 64usize , + concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_fdir_masks + ) , "::" , stringify ! ( tunnel_type_mask ) )); + } + impl Clone for rte_eth_fdir_masks { + fn clone(&self) -> Self { *self } + } + #[repr(u32)] + /** * Payload type */ -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum rte_eth_payload_type { - RTE_ETH_PAYLOAD_UNKNOWN = 0, - RTE_ETH_RAW_PAYLOAD = 1, - RTE_ETH_L2_PAYLOAD = 2, - RTE_ETH_L3_PAYLOAD = 3, - RTE_ETH_L4_PAYLOAD = 4, - RTE_ETH_PAYLOAD_MAX = 8, -} -/** + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum rte_eth_payload_type { + RTE_ETH_PAYLOAD_UNKNOWN = 0, + RTE_ETH_RAW_PAYLOAD = 1, + RTE_ETH_L2_PAYLOAD = 2, + RTE_ETH_L3_PAYLOAD = 3, + RTE_ETH_L4_PAYLOAD = 4, + RTE_ETH_PAYLOAD_MAX = 8, + } + /** * A structure used to select bytes extracted from the protocol layers to * flexible payload for filter */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_flex_payload_cfg { - /**< Payload type */ - pub type_: rte_eth_payload_type, - pub src_offset: [u16; 16usize], -} -#[test] -fn bindgen_test_layout_rte_eth_flex_payload_cfg() { - assert_eq!(::std::mem::size_of::() , 36usize , - concat ! ( - "Size of: " , stringify ! ( rte_eth_flex_payload_cfg ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_flex_payload_cfg ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . type_ as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_flex_payload_cfg ) , "::" , stringify ! ( type_ ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . src_offset - as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_flex_payload_cfg ) , "::" , stringify ! ( src_offset ) - )); -} -impl Clone for rte_eth_flex_payload_cfg { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_flex_payload_cfg { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_flex_payload_cfg { + /**< Payload type */ + pub type_: rte_eth_payload_type, + pub src_offset: [u16; 16usize], + } + #[test] + fn bindgen_test_layout_rte_eth_flex_payload_cfg() { + assert_eq!(::std::mem::size_of::() , 36usize + , concat ! ( + "Size of: " , stringify ! ( rte_eth_flex_payload_cfg ) )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_flex_payload_cfg ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . type_ + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_flex_payload_cfg ) , "::" , stringify ! ( type_ ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_flex_payload_cfg ) ) . + src_offset as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_flex_payload_cfg ) , "::" , stringify ! ( + src_offset ) )); + } + impl Clone for rte_eth_flex_payload_cfg { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_flex_payload_cfg { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** * A structure used to define FDIR masks for flexible payload * for each flow type */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_eth_fdir_flex_mask { - pub flow_type: u16, - pub mask: [u8; 16usize], -} -#[test] -fn bindgen_test_layout_rte_eth_fdir_flex_mask() { - assert_eq!(::std::mem::size_of::() , 18usize , - concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_mask ) - )); - assert_eq! (::std::mem::align_of::() , 2usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_fdir_flex_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . flow_type as - * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_mask - ) , "::" , stringify ! ( flow_type ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . mask as * - const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_mask - ) , "::" , stringify ! ( mask ) )); -} -impl Clone for rte_eth_fdir_flex_mask { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_eth_fdir_flex_mask { + pub flow_type: u16, + pub mask: [u8; 16usize], + } + #[test] + fn bindgen_test_layout_rte_eth_fdir_flex_mask() { + assert_eq!(::std::mem::size_of::() , 18usize , + concat ! ( + "Size of: " , stringify ! ( rte_eth_fdir_flex_mask ) )); + assert_eq! (::std::mem::align_of::() , 2usize + , concat ! ( + "Alignment of " , stringify ! ( rte_eth_fdir_flex_mask ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . + flow_type as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_fdir_flex_mask ) , "::" , stringify ! ( flow_type + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_mask ) ) . mask as + * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_fdir_flex_mask ) , "::" , stringify ! ( mask ) )); + } + impl Clone for rte_eth_fdir_flex_mask { + fn clone(&self) -> Self { *self } + } + /** * A structure used to define all flexible payload related setting * include flex payload and flex mask */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_eth_fdir_flex_conf { - /**< The number of following payload cfg */ - pub nb_payloads: u16, - /**< The number of following mask */ - pub nb_flexmasks: u16, - pub flex_set: [rte_eth_flex_payload_cfg; 8usize], - pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], -} -#[test] -fn bindgen_test_layout_rte_eth_fdir_flex_conf() { - assert_eq!(::std::mem::size_of::() , 688usize , - concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_conf ) - )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_eth_fdir_flex_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . nb_payloads - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf - ) , "::" , stringify ! ( nb_payloads ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . nb_flexmasks - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf - ) , "::" , stringify ! ( nb_flexmasks ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_set as - * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf - ) , "::" , stringify ! ( flex_set ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_mask as - * const _ as usize } , 292usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_fdir_flex_conf - ) , "::" , stringify ! ( flex_mask ) )); -} -impl Clone for rte_eth_fdir_flex_conf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_eth_fdir_flex_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_eth_fdir_flex_conf { + /**< The number of following payload cfg */ + pub nb_payloads: u16, + /**< The number of following mask */ + pub nb_flexmasks: u16, + pub flex_set: [rte_eth_flex_payload_cfg; 8usize], + pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], + } + #[test] + fn bindgen_test_layout_rte_eth_fdir_flex_conf() { + assert_eq!(::std::mem::size_of::() , 688usize + , concat ! ( + "Size of: " , stringify ! ( rte_eth_fdir_flex_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( rte_eth_fdir_flex_conf ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . + nb_payloads as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_fdir_flex_conf ) , "::" , stringify ! ( + nb_payloads ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . + nb_flexmasks as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_fdir_flex_conf ) , "::" , stringify ! ( + nb_flexmasks ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . flex_set + as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_fdir_flex_conf ) , "::" , stringify ! ( flex_set ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_fdir_flex_conf ) ) . + flex_mask as * const _ as usize } , 292usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_fdir_flex_conf ) , "::" , stringify ! ( flex_mask + ) )); + } + impl Clone for rte_eth_fdir_flex_conf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_eth_fdir_flex_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** * A structure used to configure the Flow Director (FDIR) feature * of an Ethernet port. * * If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_fdir_conf { - /**< Flow Director mode. */ - pub mode: rte_fdir_mode, - /**< Space for FDIR filters. */ - pub pballoc: rte_fdir_pballoc_type, - /**< How to report FDIR hash. */ - pub status: rte_fdir_status_mode, - /** RX queue of packets matching a "drop" filter in perfect mode. */ - pub drop_queue: u8, - pub mask: rte_eth_fdir_masks, - pub flex_conf: rte_eth_fdir_flex_conf, -} -#[test] -fn bindgen_test_layout_rte_fdir_conf() { - assert_eq!(::std::mem::size_of::() , 772usize , concat ! ( - "Size of: " , stringify ! ( rte_fdir_conf ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( rte_fdir_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_fdir_conf ) ) . mode as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" - , stringify ! ( mode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_fdir_conf ) ) . pballoc as * const _ - as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" - , stringify ! ( pballoc ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_fdir_conf ) ) . status as * const _ - as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" - , stringify ! ( status ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_fdir_conf ) ) . drop_queue as * const - _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" - , stringify ! ( drop_queue ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_fdir_conf ) ) . mask as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" - , stringify ! ( mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_fdir_conf ) ) . flex_conf as * const - _ as usize } , 84usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_fdir_conf ) , "::" - , stringify ! ( flex_conf ) )); -} -impl Clone for rte_fdir_conf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_fdir_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_fdir_conf { + /**< Flow Director mode. */ + pub mode: rte_fdir_mode, + /**< Space for FDIR filters. */ + pub pballoc: rte_fdir_pballoc_type, + /**< How to report FDIR hash. */ + pub status: rte_fdir_status_mode, + /** RX queue of packets matching a "drop" filter in perfect mode. */ + pub drop_queue: u8, + pub mask: rte_eth_fdir_masks, + pub flex_conf: rte_eth_fdir_flex_conf, + } + #[test] + fn bindgen_test_layout_rte_fdir_conf() { + assert_eq!(::std::mem::size_of::() , 772usize , concat + ! ( "Size of: " , stringify ! ( rte_fdir_conf ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( rte_fdir_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . mode as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , + "::" , stringify ! ( mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . pballoc as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , + "::" , stringify ! ( pballoc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . status as * const + _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , + "::" , stringify ! ( status ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . drop_queue as * + const _ as usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , + "::" , stringify ! ( drop_queue ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . mask as * const _ + as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , + "::" , stringify ! ( mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_fdir_conf ) ) . flex_conf as * + const _ as usize } , 84usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_fdir_conf ) , + "::" , stringify ! ( flex_conf ) )); + } + impl Clone for rte_fdir_conf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_fdir_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** * A structure used to enable/disable specific device interrupts. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_intr_conf { - /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */ - pub lsc: u16, - /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */ - pub rxq: u16, -} -#[test] -fn bindgen_test_layout_rte_intr_conf() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( rte_intr_conf ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( - "Alignment of " , stringify ! ( rte_intr_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_intr_conf ) ) . lsc as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_intr_conf ) , "::" - , stringify ! ( lsc ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_intr_conf ) ) . rxq as * const _ as - usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_intr_conf ) , "::" - , stringify ! ( rxq ) )); -} -impl Clone for rte_intr_conf { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_intr_conf { + /** enable/disable lsc interrupt. 0 (default) - disable, 1 enable */ + pub lsc: u16, + /** enable/disable rxq interrupt. 0 (default) - disable, 1 enable */ + pub rxq: u16, + } + #[test] + fn bindgen_test_layout_rte_intr_conf() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! + ( "Size of: " , stringify ! ( rte_intr_conf ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat + ! ( "Alignment of " , stringify ! ( rte_intr_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_intr_conf ) ) . lsc as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_intr_conf ) , + "::" , stringify ! ( lsc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_intr_conf ) ) . rxq as * const _ + as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_intr_conf ) , + "::" , stringify ! ( rxq ) )); + } + 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 + #[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 + 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 + 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 */ - pub rss_conf: rte_eth_rss_conf, - pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, - pub dcb_rx_conf: rte_eth_dcb_rx_conf, - pub vmdq_rx_conf: rte_eth_vmdq_rx_conf, -} -#[test] -fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 2120usize - , concat ! ( - "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 8usize - , concat ! ( - "Alignment of " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . rss_conf - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( rss_conf ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . - vmdq_dcb_conf as * const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( - vmdq_dcb_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . - dcb_rx_conf as * const _ as usize } , 1064usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( - dcb_rx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . - vmdq_rx_conf as * const _ as usize } , 1080usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( - vmdq_rx_conf ) )); -} -impl Default for rte_eth_conf__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_eth_conf__bindgen_ty_2 { - pub vmdq_dcb_tx_conf: __BindgenUnionField, - pub dcb_tx_conf: __BindgenUnionField, - pub vmdq_tx_conf: __BindgenUnionField, - pub bindgen_union_field: [u32; 3usize], -} -#[test] -fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , 12usize , - concat ! ( - "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 4usize - , concat ! ( - "Alignment of " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . - vmdq_dcb_tx_conf as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( - vmdq_dcb_tx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . - dcb_tx_conf as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( - dcb_tx_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . - vmdq_tx_conf as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( - vmdq_tx_conf ) )); -} -impl Clone for rte_eth_conf__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_eth_conf() { - assert_eq!(::std::mem::size_of::() , 2944usize , concat ! ( - "Size of: " , stringify ! ( rte_eth_conf ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( rte_eth_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . link_speeds as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( link_speeds ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . rxmode as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( rxmode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . txmode as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( txmode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . lpbk_mode as * const _ - as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( lpbk_mode ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . rx_adv_conf as * const - _ as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( rx_adv_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . tx_adv_conf as * const - _ as usize } , 2152usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( tx_adv_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . dcb_capability_en as * - const _ as usize } , 2164usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( dcb_capability_en ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . fdir_conf as * const _ - as usize } , 2168usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( fdir_conf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_eth_conf ) ) . intr_conf as * const _ - as usize } , 2940usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_eth_conf ) , "::" , - stringify ! ( intr_conf ) )); -} -impl Default for rte_eth_conf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + 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 */ + pub rss_conf: rte_eth_rss_conf, + pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, + pub dcb_rx_conf: rte_eth_dcb_rx_conf, + pub vmdq_rx_conf: rte_eth_vmdq_rx_conf, + } + #[test] + fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 2120usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_conf__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + rss_conf as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + rss_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + vmdq_dcb_conf as * const _ as usize } , 24usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + vmdq_dcb_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + dcb_rx_conf as * const _ as usize } , 1064usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + dcb_rx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_1 ) ) . + vmdq_rx_conf as * const _ as usize } , 1080usize , concat + ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_1 ) , "::" , stringify ! ( + vmdq_rx_conf ) )); + } + impl Default for rte_eth_conf__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_eth_conf__bindgen_ty_2 { + pub vmdq_dcb_tx_conf: __BindgenUnionField, + pub dcb_tx_conf: __BindgenUnionField, + pub vmdq_tx_conf: __BindgenUnionField, + pub bindgen_union_field: [u32; 3usize], + } + #[test] + fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 12usize , concat ! ( + "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , + 4usize , concat ! ( + "Alignment of " , stringify ! ( rte_eth_conf__bindgen_ty_2 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + vmdq_dcb_tx_conf as * const _ as usize } , 0usize , concat + ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( + vmdq_dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + dcb_tx_conf as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( + dcb_tx_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf__bindgen_ty_2 ) ) . + vmdq_tx_conf as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_eth_conf__bindgen_ty_2 ) , "::" , stringify ! ( + vmdq_tx_conf ) )); + } + impl Clone for rte_eth_conf__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_eth_conf() { + assert_eq!(::std::mem::size_of::() , 2944usize , concat + ! ( "Size of: " , stringify ! ( rte_eth_conf ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( rte_eth_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . link_speeds as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( link_speeds ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . rxmode as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( rxmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . txmode as * const + _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( txmode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . lpbk_mode as * + const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( lpbk_mode ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . rx_adv_conf as * + const _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( rx_adv_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . tx_adv_conf as * + const _ as usize } , 2152usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( tx_adv_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . dcb_capability_en + as * const _ as usize } , 2164usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( dcb_capability_en ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . fdir_conf as * + const _ as usize } , 2168usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( fdir_conf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_eth_conf ) ) . intr_conf as * + const _ as usize } , 2940usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_eth_conf ) , + "::" , stringify ! ( intr_conf ) )); + } + impl Default for rte_eth_conf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index d704267dee..9f2c2c732a 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -1,114 +1,117 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; -pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_kni_mbuf { - pub buf_addr: *mut ::std::os::raw::c_void, - pub buf_physaddr: u64, - pub pad0: [::std::os::raw::c_char; 2usize], - /**< Start address of data in segment buffer. */ - pub data_off: u16, - pub pad1: [::std::os::raw::c_char; 2usize], - /**< Number of segments. */ - pub nb_segs: u8, - pub pad4: [::std::os::raw::c_char; 1usize], - /**< Offload features. */ - pub ol_flags: u64, - pub pad2: [::std::os::raw::c_char; 4usize], - /**< Total pkt len: sum of all segment data_len. */ - pub pkt_len: u32, - /**< Amount of data in segment buffer. */ - pub data_len: u16, - pub __bindgen_padding_0: [u8; 22usize], - pub pad3: [::std::os::raw::c_char; 8usize], - pub pool: *mut ::std::os::raw::c_void, - pub next: *mut ::std::os::raw::c_void, - pub __bindgen_padding_1: [u64; 5usize], -} -#[test] -fn bindgen_test_layout_rte_kni_mbuf() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( - "Size of: " , stringify ! ( rte_kni_mbuf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_addr as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( buf_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_physaddr as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( buf_physaddr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad0 as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad0 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . data_off as * const _ - as usize } , 18usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( data_off ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad1 as * const _ as - usize } , 20usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . nb_segs as * const _ - as usize } , 22usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( nb_segs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad4 as * const _ as - usize } , 23usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . ol_flags as * const _ - as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( ol_flags ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad2 as * const _ as - usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pkt_len as * const _ - as usize } , 36usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pkt_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . data_len as * const _ - as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( data_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pad3 as * const _ as - usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pad3 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . pool as * const _ as - usize } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_kni_mbuf ) ) . next as * const _ as - usize } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , "::" , - stringify ! ( next ) )); -} -impl Clone for rte_kni_mbuf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_kni_mbuf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; + pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_kni_mbuf { + pub buf_addr: *mut ::std::os::raw::c_void, + pub buf_physaddr: u64, + pub pad0: [::std::os::raw::c_char; 2usize], + /**< Start address of data in segment buffer. */ + pub data_off: u16, + pub pad1: [::std::os::raw::c_char; 2usize], + /**< Number of segments. */ + pub nb_segs: u8, + pub pad4: [::std::os::raw::c_char; 1usize], + /**< Offload features. */ + pub ol_flags: u64, + pub pad2: [::std::os::raw::c_char; 4usize], + /**< Total pkt len: sum of all segment data_len. */ + pub pkt_len: u32, + /**< Amount of data in segment buffer. */ + pub data_len: u16, + pub __bindgen_padding_0: [u8; 22usize], + pub pad3: [::std::os::raw::c_char; 8usize], + pub pool: *mut ::std::os::raw::c_void, + pub next: *mut ::std::os::raw::c_void, + pub __bindgen_padding_1: [u64; 5usize], + } + #[test] + fn bindgen_test_layout_rte_kni_mbuf() { + assert_eq!(::std::mem::size_of::() , 128usize , concat ! + ( "Size of: " , stringify ! ( rte_kni_mbuf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_addr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( buf_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . buf_physaddr as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( buf_physaddr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad0 as * const _ + as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pad0 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . data_off as * + const _ as usize } , 18usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( data_off ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad1 as * const _ + as usize } , 20usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pad1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . nb_segs as * const + _ as usize } , 22usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( nb_segs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad4 as * const _ + as usize } , 23usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pad4 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . ol_flags as * + const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( ol_flags ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad2 as * const _ + as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pad2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pkt_len as * const + _ as usize } , 36usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pkt_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . data_len as * + const _ as usize } , 40usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( data_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pad3 as * const _ + as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pad3 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . pool as * const _ + as usize } , 72usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_kni_mbuf ) ) . next as * const _ + as usize } , 80usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_kni_mbuf ) , + "::" , stringify ! ( next ) )); + } + impl Clone for rte_kni_mbuf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_kni_mbuf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index 820e421035..9c3c79ce01 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -1,419 +1,428 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData); -impl __IncompleteArrayField { - #[inline] - pub fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData) - } - #[inline] - pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut_ptr(&mut self) -> *mut T { - ::std::mem::transmute(self) - } - #[inline] - pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) - } - #[inline] - pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + #[derive(Default)] + pub struct __IncompleteArrayField(::std::marker::PhantomData); + impl __IncompleteArrayField { + #[inline] + pub fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } } -} -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__IncompleteArrayField") + impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } } -} -impl ::std::clone::Clone for __IncompleteArrayField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __IncompleteArrayField { } -pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; -pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: ::std::os::raw::c_uint = 4; -pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_LAST_FRAG_IDX; -pub const IP_FIRST_FRAG_IDX: _bindgen_ty_1 = _bindgen_ty_1::IP_FIRST_FRAG_IDX; -pub const IP_MIN_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MIN_FRAG_NUM; -pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_1 { - IP_LAST_FRAG_IDX = 0, - IP_FIRST_FRAG_IDX = 1, - IP_MIN_FRAG_NUM = 2, - IP_MAX_FRAG_NUM = 4, -} -/** @internal fragmented mbuf */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ip_frag { - /**< offset into the packet */ - pub ofs: u16, - /**< length of fragment */ - pub len: u16, - /**< fragment mbuf */ - pub mb: *mut rte_mbuf, -} -#[test] -fn bindgen_test_layout_ip_frag() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( ip_frag ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ip_frag ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag ) ) . ofs as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag ) , "::" , - stringify ! ( ofs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag ) ) . len as * const _ as usize } - , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag ) , "::" , - stringify ! ( len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag ) ) . mb as * const _ as usize } - , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag ) , "::" , - stringify ! ( mb ) )); -} -impl Clone for ip_frag { - fn clone(&self) -> Self { *self } -} -impl Default for ip_frag { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** @internal to uniquely indetify fragmented datagram. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct ip_frag_key { - /**< src address, first 8 bytes used for IPv4 */ - pub src_dst: [u64; 4usize], - /**< dst address */ - pub id: u32, - /**< src/dst key length */ - pub key_len: u32, -} -#[test] -fn bindgen_test_layout_ip_frag_key() { - assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( - "Size of: " , stringify ! ( ip_frag_key ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ip_frag_key ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_key ) ) . src_dst as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , - stringify ! ( src_dst ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_key ) ) . id as * const _ as - usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , - stringify ! ( id ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_key ) ) . key_len as * const _ as - usize } , 36usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_key ) , "::" , - stringify ! ( key_len ) )); -} -impl Clone for ip_frag_key { - fn clone(&self) -> Self { *self } -} -/** + impl ::std::clone::Clone for __IncompleteArrayField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __IncompleteArrayField { } + #[allow(unused_imports)] + use self::super::*; + pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; + pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: ::std::os::raw::c_uint = 4; + pub const IP_LAST_FRAG_IDX: _bindgen_ty_1 = + _bindgen_ty_1::IP_LAST_FRAG_IDX; + pub const IP_FIRST_FRAG_IDX: _bindgen_ty_1 = + _bindgen_ty_1::IP_FIRST_FRAG_IDX; + pub const IP_MIN_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MIN_FRAG_NUM; + pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { + IP_LAST_FRAG_IDX = 0, + IP_FIRST_FRAG_IDX = 1, + IP_MIN_FRAG_NUM = 2, + IP_MAX_FRAG_NUM = 4, + } + /** @internal fragmented mbuf */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct ip_frag { + /**< offset into the packet */ + pub ofs: u16, + /**< length of fragment */ + pub len: u16, + /**< fragment mbuf */ + pub mb: *mut rte_mbuf, + } + #[test] + fn bindgen_test_layout_ip_frag() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( ip_frag ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( ip_frag ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . ofs as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( ofs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . len as * const _ as + usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag ) ) . mb as * const _ as + usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag ) , "::" , + stringify ! ( mb ) )); + } + impl Clone for ip_frag { + fn clone(&self) -> Self { *self } + } + impl Default for ip_frag { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** @internal to uniquely indetify fragmented datagram. */ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct ip_frag_key { + /**< src address, first 8 bytes used for IPv4 */ + pub src_dst: [u64; 4usize], + /**< dst address */ + pub id: u32, + /**< src/dst key length */ + pub key_len: u32, + } + #[test] + fn bindgen_test_layout_ip_frag_key() { + assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( + "Size of: " , stringify ! ( ip_frag_key ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( ip_frag_key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . src_dst as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , + "::" , stringify ! ( src_dst ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . id as * const _ as + usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , + "::" , stringify ! ( id ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_key ) ) . key_len as * const + _ as usize } , 36usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_key ) , + "::" , stringify ! ( key_len ) )); + } + 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 { - pub tqe_next: *mut ip_frag_pkt, - pub tqe_prev: *mut *mut ip_frag_pkt, -} -#[test] -fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 16usize , - concat ! ( - "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_next - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_next ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . tqe_prev - as * const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( - ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( tqe_prev ) - )); -} -impl Clone for ip_frag_pkt__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl Default for ip_frag_pkt__bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn bindgen_test_layout_ip_frag_pkt() { - assert_eq!(::std::mem::size_of::() , 192usize , concat ! ( - "Size of: " , stringify ! ( ip_frag_pkt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . lru as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( lru ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . key as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( key ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . start as * const _ as - usize } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( start ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . total_size as * const _ - as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( total_size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . frag_size as * const _ - as usize } , 68usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( frag_size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . last_idx as * const _ - as usize } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( last_idx ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_pkt ) ) . frags as * const _ as - usize } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_pkt ) , "::" , - stringify ! ( frags ) )); -} -impl Clone for ip_frag_pkt { - fn clone(&self) -> Self { *self } -} -impl Default for ip_frag_pkt { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct ip_pkt_list { - pub tqh_first: *mut ip_frag_pkt, - pub tqh_last: *mut *mut ip_frag_pkt, -} -#[test] -fn bindgen_test_layout_ip_pkt_list() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( ip_pkt_list ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( ip_pkt_list ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_pkt_list ) ) . tqh_first as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_pkt_list ) , "::" , - stringify ! ( tqh_first ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_pkt_list ) ) . tqh_last as * const _ - as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_pkt_list ) , "::" , - stringify ! ( tqh_last ) )); -} -impl Clone for ip_pkt_list { - fn clone(&self) -> Self { *self } -} -impl Default for ip_pkt_list { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** fragmentation table statistics */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct ip_frag_tbl_stat { - /**< total # of find/insert attempts. */ - pub find_num: u64, - /**< # of add ops. */ - pub add_num: u64, - /**< # of del ops. */ - pub del_num: u64, - /**< # of reuse (del/add) ops. */ - pub reuse_num: u64, - /**< total # of add failures. */ - pub fail_total: u64, - /**< # of 'no space' add failures. */ - pub fail_nospace: u64, - pub __bindgen_padding_0: [u64; 2usize], -} -#[test] -fn bindgen_test_layout_ip_frag_tbl_stat() { - assert_eq!(::std::mem::size_of::() , 64usize , concat ! - ( "Size of: " , stringify ! ( ip_frag_tbl_stat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . find_num as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( find_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . add_num as * const - _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( add_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . del_num as * const - _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( del_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . reuse_num as * - const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( reuse_num ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . fail_total as * - const _ as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( fail_total ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ip_frag_tbl_stat ) ) . fail_nospace as * - const _ as usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) , - "::" , stringify ! ( fail_nospace ) )); -} -impl Clone for ip_frag_tbl_stat { - fn clone(&self) -> Self { *self } -} -/** fragmentation table */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct rte_ip_frag_tbl { - /**< ttl for table entries. */ - pub max_cycles: u64, - /**< hash value mask. */ - pub entry_mask: u32, - /**< max entries allowed. */ - pub max_entries: u32, - /**< entries in use. */ - pub use_entries: u32, - /**< hash assocaitivity. */ - pub bucket_entries: u32, - /**< total size of the table. */ - pub nb_entries: u32, - /**< num of associativity lines. */ - pub nb_buckets: u32, - /**< last used entry. */ - pub last: *mut ip_frag_pkt, - /**< LRU list for table entries. */ - pub lru: ip_pkt_list, - pub __bindgen_padding_0: u64, - /**< statistics counters. */ - pub stat: ip_frag_tbl_stat, - /**< hash table. */ - pub pkt: __IncompleteArrayField, -} -#[test] -fn bindgen_test_layout_rte_ip_frag_tbl() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! - ( "Size of: " , stringify ! ( rte_ip_frag_tbl ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . max_cycles as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( max_cycles ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . entry_mask as * - const _ as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( entry_mask ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . max_entries as * - const _ as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( max_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . use_entries as * - const _ as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( use_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . bucket_entries as * - const _ as usize } , 20usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( bucket_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . nb_entries as * - const _ as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( nb_entries ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . nb_buckets as * - const _ as usize } , 28usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( nb_buckets ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . last as * const _ - as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( last ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . lru as * const _ as - usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( lru ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . stat as * const _ - as usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( stat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_ip_frag_tbl ) ) . pkt as * const _ as - usize } , 128usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , - "::" , stringify ! ( pkt ) )); -} -impl Clone for rte_ip_frag_tbl { - fn clone(&self) -> Self { *self } -} -impl Default for rte_ip_frag_tbl { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/**< fragment mbuf */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf { - pub _address: u8, -} -impl Clone for rte_mbuf { - fn clone(&self) -> Self { *self } + #[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 { + pub tqe_next: *mut ip_frag_pkt, + pub tqe_prev: *mut *mut ip_frag_pkt, + } + #[test] + fn bindgen_test_layout_ip_frag_pkt__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 16usize , concat ! ( + "Size of: " , stringify ! ( ip_frag_pkt__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , + 8usize , concat ! ( + "Alignment of " , stringify ! ( ip_frag_pkt__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . + tqe_next as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( + tqe_next ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt__bindgen_ty_1 ) ) . + tqe_prev as * const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( + ip_frag_pkt__bindgen_ty_1 ) , "::" , stringify ! ( + tqe_prev ) )); + } + impl Clone for ip_frag_pkt__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Default for ip_frag_pkt__bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn bindgen_test_layout_ip_frag_pkt() { + assert_eq!(::std::mem::size_of::() , 192usize , concat ! + ( "Size of: " , stringify ! ( ip_frag_pkt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . lru as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( lru ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . key as * const _ as + usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( key ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . start as * const _ + as usize } , 56usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( start ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . total_size as * + const _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( total_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . frag_size as * + const _ as usize } , 68usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( frag_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . last_idx as * const + _ as usize } , 72usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( last_idx ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_pkt ) ) . frags as * const _ + as usize } , 80usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_pkt ) , + "::" , stringify ! ( frags ) )); + } + impl Clone for ip_frag_pkt { + fn clone(&self) -> Self { *self } + } + impl Default for ip_frag_pkt { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct ip_pkt_list { + pub tqh_first: *mut ip_frag_pkt, + pub tqh_last: *mut *mut ip_frag_pkt, + } + #[test] + fn bindgen_test_layout_ip_pkt_list() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( ip_pkt_list ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( ip_pkt_list ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_pkt_list ) ) . tqh_first as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_pkt_list ) , + "::" , stringify ! ( tqh_first ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_pkt_list ) ) . tqh_last as * const + _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_pkt_list ) , + "::" , stringify ! ( tqh_last ) )); + } + impl Clone for ip_pkt_list { + fn clone(&self) -> Self { *self } + } + impl Default for ip_pkt_list { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** fragmentation table statistics */ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct ip_frag_tbl_stat { + /**< total # of find/insert attempts. */ + pub find_num: u64, + /**< # of add ops. */ + pub add_num: u64, + /**< # of del ops. */ + pub del_num: u64, + /**< # of reuse (del/add) ops. */ + pub reuse_num: u64, + /**< total # of add failures. */ + pub fail_total: u64, + /**< # of 'no space' add failures. */ + pub fail_nospace: u64, + pub __bindgen_padding_0: [u64; 2usize], + } + #[test] + fn bindgen_test_layout_ip_frag_tbl_stat() { + assert_eq!(::std::mem::size_of::() , 64usize , + concat ! ( "Size of: " , stringify ! ( ip_frag_tbl_stat ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_tbl_stat ) ) . find_num as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) + , "::" , stringify ! ( find_num ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_tbl_stat ) ) . add_num as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) + , "::" , stringify ! ( add_num ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_tbl_stat ) ) . del_num as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) + , "::" , stringify ! ( del_num ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_tbl_stat ) ) . reuse_num as * + const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) + , "::" , stringify ! ( reuse_num ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_tbl_stat ) ) . fail_total as + * const _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) + , "::" , stringify ! ( fail_total ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ip_frag_tbl_stat ) ) . fail_nospace + as * const _ as usize } , 40usize , concat ! ( + "Alignment of field: " , stringify ! ( ip_frag_tbl_stat ) + , "::" , stringify ! ( fail_nospace ) )); + } + impl Clone for ip_frag_tbl_stat { + fn clone(&self) -> Self { *self } + } + /** fragmentation table */ + #[repr(C)] + #[derive(Debug, Copy)] + pub struct rte_ip_frag_tbl { + /**< ttl for table entries. */ + pub max_cycles: u64, + /**< hash value mask. */ + pub entry_mask: u32, + /**< max entries allowed. */ + pub max_entries: u32, + /**< entries in use. */ + pub use_entries: u32, + /**< hash assocaitivity. */ + pub bucket_entries: u32, + /**< total size of the table. */ + pub nb_entries: u32, + /**< num of associativity lines. */ + pub nb_buckets: u32, + /**< last used entry. */ + pub last: *mut ip_frag_pkt, + /**< LRU list for table entries. */ + pub lru: ip_pkt_list, + pub __bindgen_padding_0: u64, + /**< statistics counters. */ + pub stat: ip_frag_tbl_stat, + /**< hash table. */ + pub pkt: __IncompleteArrayField, + } + #[test] + fn bindgen_test_layout_rte_ip_frag_tbl() { + assert_eq!(::std::mem::size_of::() , 128usize , + concat ! ( "Size of: " , stringify ! ( rte_ip_frag_tbl ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . max_cycles as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( max_cycles ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . entry_mask as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( entry_mask ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . max_entries as + * const _ as usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( max_entries ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . use_entries as + * const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( use_entries ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . bucket_entries + as * const _ as usize } , 20usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( bucket_entries ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . nb_entries as * + const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( nb_entries ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . nb_buckets as * + const _ as usize } , 28usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( nb_buckets ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . last as * const + _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( last ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . lru as * const + _ as usize } , 40usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( lru ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . stat as * const + _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( stat ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_ip_frag_tbl ) ) . pkt as * const + _ as usize } , 128usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_ip_frag_tbl ) , + "::" , stringify ! ( pkt ) )); + } + impl Clone for rte_ip_frag_tbl { + fn clone(&self) -> Self { *self } + } + impl Default for rte_ip_frag_tbl { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /**< fragment mbuf */ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_mbuf { + pub _address: u8, + } + impl Clone for rte_mbuf { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 6c8b758618..cd97e93c99 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -1,114 +1,120 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } } -} -pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; -pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; -pub type phys_addr_t = u64; -pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; -pub type MARKER8 = [u8; 0usize]; -pub type MARKER64 = [u64; 0usize]; -/** + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64; + pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64; + pub type phys_addr_t = u64; + pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; + pub type MARKER8 = [u8; 0usize]; + pub type MARKER64 = [u64; 0usize]; + /** * The atomic counter structure. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_atomic16_t { - /**< An internal counter value. */ - pub cnt: i16, -} -#[test] -fn bindgen_test_layout_rte_atomic16_t() { - assert_eq!(::std::mem::size_of::() , 2usize , concat ! ( - "Size of: " , stringify ! ( rte_atomic16_t ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat ! ( - "Alignment of " , stringify ! ( rte_atomic16_t ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_atomic16_t ) ) . cnt as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_atomic16_t ) , "::" - , stringify ! ( cnt ) )); -} -impl Clone for rte_atomic16_t { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_atomic16_t { + /**< An internal counter value. */ + pub cnt: i16, + } + #[test] + fn bindgen_test_layout_rte_atomic16_t() { + assert_eq!(::std::mem::size_of::() , 2usize , concat ! + ( "Size of: " , stringify ! ( rte_atomic16_t ) )); + assert_eq! (::std::mem::align_of::() , 2usize , concat + ! ( "Alignment of " , stringify ! ( rte_atomic16_t ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_atomic16_t ) ) . cnt as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_atomic16_t ) , + "::" , stringify ! ( cnt ) )); + } + 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 + #[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], -} -/** + 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: * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and @@ -116,692 +122,709 @@ pub struct rte_mbuf { * or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC * config option. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_1 { - /**< Atomically accessed refcnt */ - pub refcnt_atomic: __BindgenUnionField, - /**< Non-atomically accessed refcnt */ - pub refcnt: __BindgenUnionField, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 2usize , - concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , 2usize , - concat ! ( - "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . - refcnt_atomic as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_1 - ) , "::" , stringify ! ( refcnt_atomic ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . refcnt as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_1 - ) , "::" , stringify ! ( refcnt ) )); -} -impl Clone for rte_mbuf__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[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], -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) )); -} -impl Clone for rte_mbuf__bindgen_ty_2__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 { - #[inline] - pub fn l2_type(&self) -> u32 { - let mask = 15usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_l2_type(&mut self, val: u32) { - let mask = 15usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn l3_type(&self) -> u32 { - let mask = 240usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 4usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_l3_type(&mut self, val: u32) { - let mask = 240usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 4usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn l4_type(&self) -> u32 { - let mask = 3840usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 8usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_l4_type(&mut self, val: u32) { - let mask = 3840usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 8usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn tun_type(&self) -> u32 { - let mask = 61440usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 12usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_tun_type(&mut self, val: u32) { - let mask = 61440usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 12usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn inner_l2_type(&self) -> u32 { - let mask = 983040usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 16usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_inner_l2_type(&mut self, val: u32) { - let mask = 983040usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 16usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn inner_l3_type(&self) -> u32 { - let mask = 15728640usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 20usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_inner_l3_type(&mut self, val: u32) { - let mask = 15728640usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 20usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn inner_l4_type(&self) -> u32 { - let mask = 251658240usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 24usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_inner_l4_type(&mut self, val: u32) { - let mask = 251658240usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 24usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_mbuf__bindgen_ty_1 { + /**< Atomically accessed refcnt */ + pub refcnt_atomic: __BindgenUnionField, + /**< Non-atomically accessed refcnt */ + pub refcnt: __BindgenUnionField, + pub bindgen_union_field: u16, } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , 4usize , - concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_2 ) ) . packet_type - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_2 - ) , "::" , stringify ! ( packet_type ) )); -} -impl Clone for rte_mbuf__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], -} -#[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, -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ) )); - assert_eq! (::std::mem::align_of::() - , 2usize , concat ! ( - "Alignment of " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ) )); - assert_eq! (unsafe { - & ( - * ( - 0 as * const - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ) ) . hash as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ) , "::" , stringify ! ( hash ) )); - assert_eq! (unsafe { - & ( - * ( - 0 as * const - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ) ) . id as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 - ) , "::" , stringify ! ( id ) )); -} -impl Clone for - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( - * ( - 0 as * const - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) ) . lo as - * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) , "::" , - stringify ! ( lo ) )); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 8usize , concat ! ( - "Size of: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) ) - . hi as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) , "::" , stringify ! ( - hi ) )); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 { - pub lo: u32, - pub hi: u32, -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , - 8usize , concat ! ( - "Size of: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) - . lo as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) , "::" , stringify ! ( - lo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) - . hi as * const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( - rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) , "::" , stringify ! ( - hi ) )); -} -impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { - assert_eq!(::std::mem::size_of::() , 8usize , - concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_3 ) - )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_3 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . rss as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 - ) , "::" , stringify ! ( rss ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . fdir as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 - ) , "::" , stringify ! ( fdir ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . sched as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 - ) , "::" , stringify ! ( sched ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . usr as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_3 - ) , "::" , stringify ! ( usr ) )); -} -impl Clone for rte_mbuf__bindgen_ty_3 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mbuf__bindgen_ty_4 { - /**< Can be used for external metadata */ - pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, - /**< Allow 8-byte userdata on 32-bit */ - pub udata64: __BindgenUnionField, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { - assert_eq!(::std::mem::size_of::() , 8usize , - concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_4 ) - )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_4 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . userdata as - * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_4 - ) , "::" , stringify ! ( userdata ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . udata64 as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_4 - ) , "::" , stringify ! ( udata64 ) )); -} -impl Clone for rte_mbuf__bindgen_ty_4 { - fn clone(&self) -> Self { *self } -} -#[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], -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 8usize , concat ! ( - "Size of: " , stringify ! ( - rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() - , 8usize , concat ! ( - "Alignment of " , stringify ! ( - rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) )); -} -impl Clone for rte_mbuf__bindgen_ty_5__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 { - #[inline] - pub fn l2_len(&self) -> u64 { - let mask = 127usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u64) } - } - #[inline] - pub fn set_l2_len(&mut self, val: u64) { - let mask = 127usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn l3_len(&self) -> u64 { - let mask = 65408usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 7usize; - unsafe { ::std::mem::transmute(val as u64) } - } - #[inline] - pub fn set_l3_len(&mut self, val: u64) { - let mask = 65408usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 7usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn l4_len(&self) -> u64 { - let mask = 16711680usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 16usize; - unsafe { ::std::mem::transmute(val as u64) } - } - #[inline] - pub fn set_l4_len(&mut self, val: u64) { - let mask = 16711680usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 16usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn tso_segsz(&self) -> u64 { - let mask = 1099494850560usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 24usize; - unsafe { ::std::mem::transmute(val as u64) } - } - #[inline] - pub fn set_tso_segsz(&mut self, val: u64) { - let mask = 1099494850560usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 24usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn outer_l3_len(&self) -> u64 { - let mask = 561850441793536usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 40usize; - unsafe { ::std::mem::transmute(val as u64) } - } - #[inline] - pub fn set_outer_l3_len(&mut self, val: u64) { - let mask = 561850441793536usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 40usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn outer_l2_len(&self) -> u64 { - let mask = 71494644084506624usize as u64; - let field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 49usize; - unsafe { ::std::mem::transmute(val as u64) } - } - #[inline] - pub fn set_outer_l2_len(&mut self, val: u64) { - let mask = 71494644084506624usize as u64; - let val = val as u64 as u64; - let mut field_val: u64 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 49usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 2usize , + concat ! ( + "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 2usize + , concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_1 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . + refcnt_atomic as * const _ as usize } , 0usize , concat ! + ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_1 ) , "::" , stringify ! ( + refcnt_atomic ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_1 ) ) . refcnt + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_1 ) , "::" , stringify ! ( refcnt ) + )); + } + impl Clone for rte_mbuf__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[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], + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) )); + } + impl Clone for rte_mbuf__bindgen_ty_2__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 { + #[inline] + pub fn l2_type(&self) -> u32 { + let mask = 15usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_l2_type(&mut self, val: u32) { + let mask = 15usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn l3_type(&self) -> u32 { + let mask = 240usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 4usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_l3_type(&mut self, val: u32) { + let mask = 240usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 4usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn l4_type(&self) -> u32 { + let mask = 3840usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 8usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_l4_type(&mut self, val: u32) { + let mask = 3840usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 8usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn tun_type(&self) -> u32 { + let mask = 61440usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 12usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_tun_type(&mut self, val: u32) { + let mask = 61440usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 12usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn inner_l2_type(&self) -> u32 { + let mask = 983040usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 16usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_inner_l2_type(&mut self, val: u32) { + let mask = 983040usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 16usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn inner_l3_type(&self) -> u32 { + let mask = 15728640usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 20usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_inner_l3_type(&mut self, val: u32) { + let mask = 15728640usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 20usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn inner_l4_type(&self) -> u32 { + let mask = 251658240usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 24usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_inner_l4_type(&mut self, val: u32) { + let mask = 251658240usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 24usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_2 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_2 ) ) . + packet_type as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_2 ) , "::" , stringify ! ( + packet_type ) )); + } + impl Clone for rte_mbuf__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], + } + #[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, + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) ) . hash as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) , "::" , stringify ! ( hash ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) ) . id as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) , "::" , stringify ! ( id ) )); + } + impl Clone for + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( + 0 as * const + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) ) . + lo as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) , + "::" , stringify ! ( lo ) )); + } + impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 8usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) ) + . hi as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) , "::" , stringify + ! ( hi ) )); + } + impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 { + pub lo: u32, + pub hi: u32, + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() + , 8usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) + . lo as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) , "::" , stringify + ! ( lo ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ) + . hi as * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) , "::" , stringify + ! ( hi ) )); + } + impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_3 ) )); + assert_eq! (::std::mem::align_of::() , 4usize + , concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_3 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . rss as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3 ) , "::" , stringify ! ( rss ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . fdir as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3 ) , "::" , stringify ! ( fdir ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . sched as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3 ) , "::" , stringify ! ( sched ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_3 ) ) . usr as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_3 ) , "::" , stringify ! ( usr ) )); + } + impl Clone for rte_mbuf__bindgen_ty_3 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_mbuf__bindgen_ty_4 { + /**< Can be used for external metadata */ + pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, + /**< Allow 8-byte userdata on 32-bit */ + pub udata64: __BindgenUnionField, + pub bindgen_union_field: u64, + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_4 ) )); + assert_eq! (::std::mem::align_of::() , 8usize + , concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_4 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . userdata + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_4 ) , "::" , stringify ! ( userdata ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_4 ) ) . udata64 + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_4 ) , "::" , stringify ! ( udata64 ) + )); + } + impl Clone for rte_mbuf__bindgen_ty_4 { + fn clone(&self) -> Self { *self } + } + #[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], + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() + , 8usize , concat ! ( + "Size of: " , stringify ! ( + rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() + , 8usize , concat ! ( + "Alignment of " , stringify ! ( + rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) )); + } + impl Clone for rte_mbuf__bindgen_ty_5__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 { + #[inline] + pub fn l2_len(&self) -> u64 { + let mask = 127usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_l2_len(&mut self, val: u64) { + let mask = 127usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn l3_len(&self) -> u64 { + let mask = 65408usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_l3_len(&mut self, val: u64) { + let mask = 65408usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 7usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn l4_len(&self) -> u64 { + let mask = 16711680usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 16usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_l4_len(&mut self, val: u64) { + let mask = 16711680usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 16usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn tso_segsz(&self) -> u64 { + let mask = 1099494850560usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 24usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_tso_segsz(&mut self, val: u64) { + let mask = 1099494850560usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 24usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn outer_l3_len(&self) -> u64 { + let mask = 561850441793536usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 40usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_outer_l3_len(&mut self, val: u64) { + let mask = 561850441793536usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 40usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn outer_l2_len(&self) -> u64 { + let mask = 71494644084506624usize as u64; + let field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 49usize; + unsafe { ::std::mem::transmute(val as u64) } + } + #[inline] + pub fn set_outer_l2_len(&mut self, val: u64) { + let mask = 71494644084506624usize as u64; + let val = val as u64 as u64; + let mut field_val: u64 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 49usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[test] + fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( + "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_5 ) )); + assert_eq! (::std::mem::align_of::() , 8usize + , concat ! ( + "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_5 ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf__bindgen_ty_5 ) ) . + tx_offload as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + rte_mbuf__bindgen_ty_5 ) , "::" , stringify ! ( tx_offload + ) )); + } + impl Clone for rte_mbuf__bindgen_ty_5 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_rte_mbuf() { + assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( + "Size of: " , stringify ! ( rte_mbuf ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . cacheline0 as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( cacheline0 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_addr as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( buf_addr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_physaddr as * + const _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( buf_physaddr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . buf_len as * const _ + as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( buf_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . rearm_data as * const + _ as usize } , 18usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( rearm_data ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . data_off as * const _ + as usize } , 18usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( data_off ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . nb_segs as * const _ + as usize } , 22usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( nb_segs ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . port as * const _ as + usize } , 23usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( port ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . ol_flags as * const _ + as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( ol_flags ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . rx_descriptor_fields1 + as * const _ as usize } , 32usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( rx_descriptor_fields1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . pkt_len as * const _ + as usize } , 36usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( pkt_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . data_len as * const _ + as usize } , 40usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( data_len ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci as * const _ + as usize } , 42usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( vlan_tci ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . hash as * const _ as + usize } , 44usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( hash ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . seqn as * const _ as + usize } , 52usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( seqn ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci_outer as * + const _ as usize } , 56usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( vlan_tci_outer ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . cacheline1 as * const + _ as usize } , 64usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( cacheline1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . pool as * const _ as + usize } , 72usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( pool ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . next as * const _ as + usize } , 80usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( next ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . priv_size as * const _ + as usize } , 96usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( priv_size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const rte_mbuf ) ) . timesync as * const _ + as usize } , 98usize , concat ! ( + "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , + stringify ! ( timesync ) )); + } + impl Clone for rte_mbuf { + fn clone(&self) -> Self { *self } + } + impl Default for rte_mbuf { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /**< Pool from which mbuf was allocated. */ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct rte_mempool { + pub _address: u8, + } + impl Clone for rte_mempool { + fn clone(&self) -> Self { *self } } -} -#[test] -fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() { - assert_eq!(::std::mem::size_of::() , 8usize , - concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_5 ) - )); - assert_eq! (::std::mem::align_of::() , 8usize , - concat ! ( - "Alignment of " , stringify ! ( rte_mbuf__bindgen_ty_5 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf__bindgen_ty_5 ) ) . tx_offload - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf__bindgen_ty_5 - ) , "::" , stringify ! ( tx_offload ) )); -} -impl Clone for rte_mbuf__bindgen_ty_5 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_rte_mbuf() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( - "Size of: " , stringify ! ( rte_mbuf ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . cacheline0 as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( cacheline0 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . buf_addr as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( buf_addr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . buf_physaddr as * const _ - as usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( buf_physaddr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . buf_len as * const _ as - usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( buf_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . rearm_data as * const _ as - usize } , 18usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( rearm_data ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . data_off as * const _ as - usize } , 18usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( data_off ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . nb_segs as * const _ as - usize } , 22usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( nb_segs ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . port as * const _ as usize - } , 23usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( port ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . ol_flags as * const _ as - usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( ol_flags ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . rx_descriptor_fields1 as * - const _ as usize } , 32usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( rx_descriptor_fields1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . pkt_len as * const _ as - usize } , 36usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( pkt_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . data_len as * const _ as - usize } , 40usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( data_len ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci as * const _ as - usize } , 42usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( vlan_tci ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . hash as * const _ as usize - } , 44usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( hash ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . seqn as * const _ as usize - } , 52usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( seqn ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . vlan_tci_outer as * const - _ as usize } , 56usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( vlan_tci_outer ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . cacheline1 as * const _ as - usize } , 64usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( cacheline1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . pool as * const _ as usize - } , 72usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( pool ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . next as * const _ as usize - } , 80usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( next ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . priv_size as * const _ as - usize } , 96usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( priv_size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const rte_mbuf ) ) . timesync as * const _ as - usize } , 98usize , concat ! ( - "Alignment of field: " , stringify ! ( rte_mbuf ) , "::" , - stringify ! ( timesync ) )); -} -impl Clone for rte_mbuf { - fn clone(&self) -> Self { *self } -} -impl Default for rte_mbuf { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/**< Pool from which mbuf was allocated. */ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct rte_mempool { - pub _address: u8, -} -impl Clone for rte_mempool { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/macro-expr-basic.rs b/tests/expectations/tests/macro-expr-basic.rs index 355294e715..3c6e769a9b 100644 --- a/tests/expectations/tests/macro-expr-basic.rs +++ b/tests/expectations/tests/macro-expr-basic.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const FOO: ::std::os::raw::c_uint = 1; -pub const BAR: ::std::os::raw::c_uint = 4; -pub const BAZ: ::std::os::raw::c_uint = 5; -pub const MIN: ::std::os::raw::c_longlong = -9223372036854775808; -pub const BARR: ::std::os::raw::c_uint = 1; -pub const BAZZ: ::std::os::raw::c_uint = 7; -pub const I_RAN_OUT_OF_DUMB_NAMES: ::std::os::raw::c_uint = 7; -pub const HAZ_A_COMMENT: ::std::os::raw::c_uint = 1; -pub const HAZ_A_COMMENT_INSIDE: ::std::os::raw::c_uint = 2; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const FOO: ::std::os::raw::c_uint = 1; + pub const BAR: ::std::os::raw::c_uint = 4; + pub const BAZ: ::std::os::raw::c_uint = 5; + pub const MIN: ::std::os::raw::c_longlong = -9223372036854775808; + pub const BARR: ::std::os::raw::c_uint = 1; + pub const BAZZ: ::std::os::raw::c_uint = 7; + pub const I_RAN_OUT_OF_DUMB_NAMES: ::std::os::raw::c_uint = 7; + pub const HAZ_A_COMMENT: ::std::os::raw::c_uint = 1; + pub const HAZ_A_COMMENT_INSIDE: ::std::os::raw::c_uint = 2; +} diff --git a/tests/expectations/tests/macro-redef.rs b/tests/expectations/tests/macro-redef.rs index 881a44ae87..192d45945c 100644 --- a/tests/expectations/tests/macro-redef.rs +++ b/tests/expectations/tests/macro-redef.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const FOO: ::std::os::raw::c_uint = 4; -pub const BAR: ::std::os::raw::c_uint = 5; -pub const BAZ: ::std::os::raw::c_uint = 6; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const FOO: ::std::os::raw::c_uint = 4; + pub const BAR: ::std::os::raw::c_uint = 5; + pub const BAZ: ::std::os::raw::c_uint = 6; +} diff --git a/tests/expectations/tests/macro_const.rs b/tests/expectations/tests/macro_const.rs index 383cedc788..64f873b2b9 100644 --- a/tests/expectations/tests/macro_const.rs +++ b/tests/expectations/tests/macro_const.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const foo: &'static [u8; 4usize] = b"bar\x00"; -pub const CHAR: u8 = b'b'; -pub const CHARR: u8 = b'\x00'; -pub const FLOAT: f64 = 5.09; -pub const FLOAT_EXPR: f64 = 0.005; -pub const INVALID_UTF8: [u8; 5usize] = [240, 40, 140, 40, 0]; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const foo: &'static [u8; 4usize] = b"bar\x00"; + pub const CHAR: u8 = b'b'; + pub const CHARR: u8 = b'\x00'; + pub const FLOAT: f64 = 5.09; + pub const FLOAT_EXPR: f64 = 0.005; + pub const INVALID_UTF8: [u8; 5usize] = [240, 40, 140, 40, 0]; +} diff --git a/tests/expectations/tests/maddness-is-avoidable.rs b/tests/expectations/tests/maddness-is-avoidable.rs index 09c1c921db..da45fe82a6 100644 --- a/tests/expectations/tests/maddness-is-avoidable.rs +++ b/tests/expectations/tests/maddness-is-avoidable.rs @@ -1,16 +1,19 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr_Proxy { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct RefPtr { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct RefPtr_Proxy { + pub _address: u8, + } } diff --git a/tests/expectations/tests/method-mangling.rs b/tests/expectations/tests/method-mangling.rs index 360f0ea7de..ee25bda758 100644 --- a/tests/expectations/tests/method-mangling.rs +++ b/tests/expectations/tests/method-mangling.rs @@ -1,29 +1,34 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( 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 } -} -impl Foo { - #[inline] - pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int { Foo_type(self) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( 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 } + } + impl Foo { + #[inline] + pub unsafe fn type_(&mut self) -> ::std::os::raw::c_int { + Foo_type(self) + } + } } diff --git a/tests/expectations/tests/module-whitelisted.rs b/tests/expectations/tests/module-whitelisted.rs index 0f4d54b321..a2cd733b90 100644 --- a/tests/expectations/tests/module-whitelisted.rs +++ b/tests/expectations/tests/module-whitelisted.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/msvc-no-usr.rs b/tests/expectations/tests/msvc-no-usr.rs index 7ea253b694..8c42cf1f11 100644 --- a/tests/expectations/tests/msvc-no-usr.rs +++ b/tests/expectations/tests/msvc-no-usr.rs @@ -1,26 +1,29 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A { - pub foo: usize, -} -#[test] -fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( foo ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct A { + pub foo: usize, + } + #[test] + fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( foo ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs index 253d58435b..d2c52ef9e3 100644 --- a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs +++ b/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs @@ -1,51 +1,54 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Bar { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); -} -impl Clone for 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 ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); -} -impl Clone for Baz { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + } + impl Clone for 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 ! ( + "Size of: " , stringify ! ( Baz ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Baz ) )); + } + impl Clone for Baz { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/mutable.rs b/tests/expectations/tests/mutable.rs index cde3dac1b3..947a124e83 100644 --- a/tests/expectations/tests/mutable.rs +++ b/tests/expectations/tests/mutable.rs @@ -1,71 +1,75 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct C { - pub m_member: ::std::os::raw::c_int, - pub m_other: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . m_member as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( m_member ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . m_other as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( m_other ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct NonCopiable { - pub m_member: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_NonCopiable() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( NonCopiable ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( NonCopiable ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const NonCopiable ) ) . m_member as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( NonCopiable ) , "::" , - stringify ! ( m_member ) )); -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct NonCopiableWithNonCopiableMutableMember { - pub m_member: NonCopiable, -} -#[test] -fn bindgen_test_layout_NonCopiableWithNonCopiableMutableMember() { - assert_eq!(::std::mem::size_of::() - , 4usize , concat ! ( - "Size of: " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) )); - assert_eq! (::std::mem::align_of::() - , 4usize , concat ! ( - "Alignment of " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const NonCopiableWithNonCopiableMutableMember ) - ) . m_member as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - NonCopiableWithNonCopiableMutableMember ) , "::" , stringify ! - ( m_member ) )); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct C { + pub m_member: ::std::os::raw::c_int, + pub m_other: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . m_member as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( m_member ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . m_other as * const _ as usize + } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( m_other ) )); + } + impl Clone for C { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default)] + pub struct NonCopiable { + pub m_member: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_NonCopiable() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( NonCopiable ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( NonCopiable ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const NonCopiable ) ) . m_member as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( NonCopiable ) , + "::" , stringify ! ( m_member ) )); + } + #[repr(C)] + #[derive(Debug, Default)] + pub struct NonCopiableWithNonCopiableMutableMember { + pub m_member: NonCopiable, + } + #[test] + fn bindgen_test_layout_NonCopiableWithNonCopiableMutableMember() { + assert_eq!(::std::mem::size_of::() + , 4usize , concat ! ( + "Size of: " , stringify ! ( + NonCopiableWithNonCopiableMutableMember ) )); + assert_eq! (::std::mem::align_of::() + , 4usize , concat ! ( + "Alignment of " , stringify ! ( + NonCopiableWithNonCopiableMutableMember ) )); + assert_eq! (unsafe { + & ( + * ( 0 as * const NonCopiableWithNonCopiableMutableMember ) + ) . m_member as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + NonCopiableWithNonCopiableMutableMember ) , "::" , + stringify ! ( m_member ) )); + } } diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs index 8e64fa2237..88dbbdb4cd 100644 --- a/tests/expectations/tests/namespace.rs +++ b/tests/expectations/tests/namespace.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] @@ -21,7 +17,7 @@ pub mod root { pub fn in_whatever(); } } - pub mod _bindgen_mod_id_13 { + pub mod _bindgen_mod_id_14 { #[allow(unused_imports)] use self::super::super::root; extern "C" { @@ -48,7 +44,7 @@ pub mod root { 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) + *mut root::_bindgen_mod_id_14::A) -> ::std::os::raw::c_int; } impl Clone for A { @@ -65,7 +61,7 @@ pub mod root { #[repr(C)] #[derive(Debug)] pub struct C { - pub _base: root::_bindgen_mod_id_13::A, + pub _base: root::_bindgen_mod_id_14::A, pub m_c: T, pub m_c_ptr: *mut T, pub m_c_arr: [T; 10usize], diff --git a/tests/expectations/tests/nested.rs b/tests/expectations/tests/nested.rs index d50f8e1703..ccaee4e673 100644 --- a/tests/expectations/tests/nested.rs +++ b/tests/expectations/tests/nested.rs @@ -1,83 +1,87 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Calc { - pub w: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Calc() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Calc ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Calc ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Calc ) ) . w as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Calc ) , "::" , - stringify ! ( w ) )); -} -impl Clone for Calc { - fn clone(&self) -> Self { *self } -} -#[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, -} -#[test] -fn bindgen_test_layout_Test_Size_Dimension() { - assert_eq!(::std::mem::size_of::() , 4usize , concat - ! ( "Size of: " , stringify ! ( Test_Size_Dimension ) )); - assert_eq! (::std::mem::align_of::() , 4usize , - concat ! ( - "Alignment of " , stringify ! ( Test_Size_Dimension ) )); -} -impl Clone for Test_Size_Dimension { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Test_Size() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Test_Size ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Test_Size ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test_Size ) ) . mWidth as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test_Size ) , "::" , - stringify ! ( mWidth ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test_Size ) ) . mHeight as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( Test_Size ) , "::" , - stringify ! ( mHeight ) )); -} -impl Clone for Test_Size { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); -} -impl Clone for Test { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Calc { + pub w: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_Calc() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Calc ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Calc ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Calc ) ) . w as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Calc ) , "::" , + stringify ! ( w ) )); + } + impl Clone for Calc { + fn clone(&self) -> Self { *self } + } + #[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, + } + #[test] + fn bindgen_test_layout_Test_Size_Dimension() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( Test_Size_Dimension ) )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( Test_Size_Dimension ) )); + } + impl Clone for Test_Size_Dimension { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_Test_Size() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Test_Size ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Test_Size ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test_Size ) ) . mWidth as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Test_Size ) , "::" + , stringify ! ( mWidth ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test_Size ) ) . mHeight as * const _ + as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( Test_Size ) , "::" + , stringify ! ( mHeight ) )); + } + impl Clone for Test_Size { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_Test() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Test ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Test ) )); + } + impl Clone for Test { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/nested_vtable.rs b/tests/expectations/tests/nested_vtable.rs index 4c9dc8f6c2..bf127b50d8 100644 --- a/tests/expectations/tests/nested_vtable.rs +++ b/tests/expectations/tests/nested_vtable.rs @@ -1,62 +1,65 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct nsISupports__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct nsISupports { - pub vtable_: *const nsISupports__bindgen_vtable, -} -#[test] -fn bindgen_test_layout_nsISupports() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsISupports ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsISupports ) )); -} -impl Clone for nsISupports { - fn clone(&self) -> Self { *self } -} -impl Default for nsISupports { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct nsIRunnable { - pub _base: nsISupports, -} -#[test] -fn bindgen_test_layout_nsIRunnable() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsIRunnable ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsIRunnable ) )); -} -impl Clone for nsIRunnable { - fn clone(&self) -> Self { *self } -} -impl Default for nsIRunnable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Runnable { - pub _base: nsIRunnable, -} -#[test] -fn bindgen_test_layout_Runnable() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Runnable ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Runnable ) )); -} -impl Clone for Runnable { - fn clone(&self) -> Self { *self } -} -impl Default for Runnable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + pub struct nsISupports__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct nsISupports { + pub vtable_: *const nsISupports__bindgen_vtable, + } + #[test] + fn bindgen_test_layout_nsISupports() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsISupports ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( nsISupports ) )); + } + impl Clone for nsISupports { + fn clone(&self) -> Self { *self } + } + impl Default for nsISupports { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct nsIRunnable { + pub _base: nsISupports, + } + #[test] + fn bindgen_test_layout_nsIRunnable() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsIRunnable ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( nsIRunnable ) )); + } + impl Clone for nsIRunnable { + fn clone(&self) -> Self { *self } + } + impl Default for nsIRunnable { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Runnable { + pub _base: nsIRunnable, + } + #[test] + fn bindgen_test_layout_Runnable() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Runnable ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Runnable ) )); + } + impl Clone for Runnable { + fn clone(&self) -> Self { *self } + } + impl Default for Runnable { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/nested_within_namespace.rs b/tests/expectations/tests/nested_within_namespace.rs index c51446573e..dae684b04d 100644 --- a/tests/expectations/tests/nested_within_namespace.rs +++ b/tests/expectations/tests/nested_within_namespace.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/no-comments.rs b/tests/expectations/tests/no-comments.rs index 058f2045dc..35605c536b 100644 --- a/tests/expectations/tests/no-comments.rs +++ b/tests/expectations/tests/no-comments.rs @@ -1,26 +1,29 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Foo { - pub s: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . s as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( s ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Foo { + pub s: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . s as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Foo ) , "::" , + stringify ! ( s ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs index 07e6ae8228..dc7c5e038c 100644 --- a/tests/expectations/tests/no-derive-debug.rs +++ b/tests/expectations/tests/no-derive-debug.rs @@ -1,38 +1,42 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #[repr(C)] #[derive(Copy, Clone, Default)] pub struct foo { bar: ::std::os::raw::c_int, } -/** +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** * bar should compile. It will normally derive debug, but our blacklist of foo * and replacement for another type that doesn't implement it would prevent it * from building if --no-derive-debug didn't work. */ -#[repr(C)] -#[derive(Default, Copy)] -pub struct bar { - pub foo: foo, - pub baz: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( baz ) )); -} -impl Clone for bar { - fn clone(&self) -> Self { *self } + #[repr(C)] + #[derive(Default, Copy)] + pub struct bar { + pub foo: foo, + pub baz: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( bar ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . foo as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( bar ) , "::" , + stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } + , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( bar ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for bar { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/no-derive-default.rs b/tests/expectations/tests/no-derive-default.rs index 2cec9d19b5..4599290d2a 100644 --- a/tests/expectations/tests/no-derive-default.rs +++ b/tests/expectations/tests/no-derive-default.rs @@ -1,38 +1,42 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #[repr(C)] #[derive(Copy, Clone, Debug)] pub struct foo { bar: ::std::os::raw::c_int, } -/** +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** * bar should compile. It will normally derive default, but our blacklist of foo * and replacement for another type that doesn't implement it would prevent it * from building if --no-derive-default didn't work. */ -#[repr(C)] -#[derive(Debug, Copy)] -pub struct bar { - pub foo: foo, - pub baz: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_bar() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( bar ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( bar ) , "::" , - stringify ! ( baz ) )); -} -impl Clone for bar { - fn clone(&self) -> Self { *self } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct bar { + pub foo: foo, + pub baz: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( bar ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . foo as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( bar ) , "::" , + stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bar ) ) . baz as * const _ as usize } + , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( bar ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for bar { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/no-recursive-whitelisting.rs b/tests/expectations/tests/no-recursive-whitelisting.rs index 7cc3d89e04..a231d1debb 100644 --- a/tests/expectations/tests/no-recursive-whitelisting.rs +++ b/tests/expectations/tests/no-recursive-whitelisting.rs @@ -1,30 +1,34 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - pub enum Bar {} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Foo { - pub baz: *mut Bar, -} -#[test] -fn bindgen_test_layout_Foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Foo ) ) . baz as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Foo ) , "::" , - stringify ! ( baz ) )); -} -impl Clone for Foo { - fn clone(&self) -> Self { *self } -} -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Foo { + pub baz: *mut Bar, + } + #[test] + fn bindgen_test_layout_Foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Foo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Foo ) ) . baz as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Foo ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for Foo { + fn clone(&self) -> Self { *self } + } + impl Default for Foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/no-std.rs b/tests/expectations/tests/no-std.rs index 998ac2a87c..fe506fc36e 100644 --- a/tests/expectations/tests/no-std.rs +++ b/tests/expectations/tests/no-std.rs @@ -1,43 +1,47 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![no_std] mod libc { pub type c_int = i32; pub enum c_void {} } -#[repr(C)] -#[derive(Debug, Copy)] -pub struct foo { - pub a: libc::c_int, - pub b: libc::c_int, - pub bar: *mut libc::c_void, -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::core::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } -} -impl Default for foo { - fn default() -> Self { unsafe { ::core::mem::zeroed() } } +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct foo { + pub a: libc::c_int, + pub b: libc::c_int, + pub bar: *mut libc::c_void, + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::core::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::core::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , + 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } + impl Default for foo { + fn default() -> Self { unsafe { ::core::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/no_copy.rs b/tests/expectations/tests/no_copy.rs index a75f891ce5..17f5008bc6 100644 --- a/tests/expectations/tests/no_copy.rs +++ b/tests/expectations/tests/no_copy.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -/**
*/ -#[repr(C)] -#[derive(Debug, Default)] -pub struct CopiableButWait { - pub whatever: ::std::os::raw::c_int, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /**
*/ + #[repr(C)] + #[derive(Debug, Default)] + pub struct CopiableButWait { + pub whatever: ::std::os::raw::c_int, + } } diff --git a/tests/expectations/tests/non-type-params.rs b/tests/expectations/tests/non-type-params.rs index 039aa711da..64f5c68b15 100644 --- a/tests/expectations/tests/non-type-params.rs +++ b/tests/expectations/tests/non-type-params.rs @@ -1,48 +1,53 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type Array16 = u8; -pub type ArrayInt4 = [u32; 4usize]; -#[repr(C)] -pub struct UsesArray { - pub array_char_16: [u8; 16usize], - pub array_bool_8: [u8; 8usize], - pub array_int_4: ArrayInt4, -} -#[test] -fn bindgen_test_layout_UsesArray() { - assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( - "Size of: " , stringify ! ( UsesArray ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( UsesArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UsesArray ) ) . array_char_16 as * const - _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UsesArray ) , "::" , - stringify ! ( array_char_16 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UsesArray ) ) . array_bool_8 as * const _ - as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( UsesArray ) , "::" , - stringify ! ( array_bool_8 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UsesArray ) ) . array_int_4 as * const _ - as usize } , 24usize , concat ! ( - "Alignment of field: " , stringify ! ( UsesArray ) , "::" , - stringify ! ( array_int_4 ) )); -} -impl Default for UsesArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[test] -fn __bindgen_test_layout_Array_instantiation_18() { - assert_eq!(::std::mem::size_of::<[u32; 4usize]>() , 16usize , concat ! ( - "Size of template specialization: " , stringify ! ( - [u32; 4usize] ) )); - assert_eq!(::std::mem::align_of::<[u32; 4usize]>() , 4usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - [u32; 4usize] ) )); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type Array16 = u8; + pub type ArrayInt4 = [u32; 4usize]; + #[repr(C)] + pub struct UsesArray { + pub array_char_16: [u8; 16usize], + pub array_bool_8: [u8; 8usize], + pub array_int_4: ArrayInt4, + } + #[test] + fn bindgen_test_layout_UsesArray() { + assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( + "Size of: " , stringify ! ( UsesArray ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( UsesArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UsesArray ) ) . array_char_16 as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( UsesArray ) , "::" + , stringify ! ( array_char_16 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UsesArray ) ) . array_bool_8 as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( UsesArray ) , "::" + , stringify ! ( array_bool_8 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UsesArray ) ) . array_int_4 as * + const _ as usize } , 24usize , concat ! ( + "Alignment of field: " , stringify ! ( UsesArray ) , "::" + , stringify ! ( array_int_4 ) )); + } + impl Default for UsesArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[test] + fn __bindgen_test_layout_Array_instantiation_19() { + assert_eq!(::std::mem::size_of::<[u32; 4usize]>() , 16usize , concat ! + ( + "Size of template specialization: " , stringify ! ( + [u32; 4usize] ) )); + assert_eq!(::std::mem::align_of::<[u32; 4usize]>() , 4usize , concat ! + ( + "Alignment of template specialization: " , stringify ! ( + [u32; 4usize] ) )); + } } diff --git a/tests/expectations/tests/nsStyleAutoArray.rs b/tests/expectations/tests/nsStyleAutoArray.rs index bc5f5184cb..3a3b12e7ed 100644 --- a/tests/expectations/tests/nsStyleAutoArray.rs +++ b/tests/expectations/tests/nsStyleAutoArray.rs @@ -1,28 +1,31 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct nsTArray { - pub mBuff: *mut T, -} -impl Default for nsTArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct nsStyleAutoArray { - pub mFirstElement: T, - pub mOtherElements: nsTArray, -} -#[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() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct nsTArray { + pub mBuff: *mut T, + } + impl Default for nsTArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct nsStyleAutoArray { + pub mFirstElement: T, + pub mOtherElements: nsTArray, + } + #[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/objc_category.rs b/tests/expectations/tests/objc_category.rs index d358e1329d..a13cca60c5 100644 --- a/tests/expectations/tests/objc_category.rs +++ b/tests/expectations/tests/objc_category.rs @@ -1,23 +1,27 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { - unsafe fn method(self); -} -impl Foo for id { - unsafe fn method(self) { msg_send!(self , method) } -} -pub trait Foo_BarCategory { - unsafe fn categoryMethod(self); -} -impl Foo_BarCategory for id { - unsafe fn categoryMethod(self) { msg_send!(self , categoryMethod) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait Foo { + unsafe fn method(self); + } + impl Foo for id { + unsafe fn method(self) { msg_send!(self , method) } + } + pub trait Foo_BarCategory { + unsafe fn categoryMethod(self); + } + impl Foo_BarCategory for id { + unsafe fn categoryMethod(self) { msg_send!(self , categoryMethod) } + } } diff --git a/tests/expectations/tests/objc_class.rs b/tests/expectations/tests/objc_class.rs index 9aa30c1a6f..c1ddeac1d4 100644 --- a/tests/expectations/tests/objc_class.rs +++ b/tests/expectations/tests/objc_class.rs @@ -1,21 +1,25 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { - unsafe fn method(self); -} -impl Foo for id { - unsafe fn method(self) { msg_send!(self , method) } -} -extern "C" { - #[link_name = "fooVar"] - pub static mut fooVar: *mut id; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait Foo { + unsafe fn method(self); + } + impl Foo for id { + unsafe fn method(self) { msg_send!(self , method) } + } + extern "C" { + #[link_name = "fooVar"] + pub static mut fooVar: *mut id; + } } diff --git a/tests/expectations/tests/objc_class_method.rs b/tests/expectations/tests/objc_class_method.rs index 699f5619a5..1529c2b6a0 100644 --- a/tests/expectations/tests/objc_class_method.rs +++ b/tests/expectations/tests/objc_class_method.rs @@ -1,54 +1,60 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { - unsafe fn method(); - unsafe fn methodWithInt_(foo: ::std::os::raw::c_int); - unsafe fn methodWithFoo_(foo: id); - unsafe fn methodReturningInt() - -> ::std::os::raw::c_int; - unsafe fn methodReturningFoo() - -> *mut id; - unsafe fn methodWithArg1_andArg2_andArg3_(intvalue: ::std::os::raw::c_int, - ptr: - *mut ::std::os::raw::c_char, - floatvalue: f32); -} -impl Foo for id { - unsafe fn method() { - msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( - "Couldn\'t find Foo" ) , method) - } - unsafe fn methodWithInt_(foo: ::std::os::raw::c_int) { - msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( - "Couldn\'t find Foo" ) , methodWithInt:foo ) - } - unsafe fn methodWithFoo_(foo: id) { - msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( - "Couldn\'t find Foo" ) , methodWithFoo:foo ) - } - unsafe fn methodReturningInt() -> ::std::os::raw::c_int { - msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( - "Couldn\'t find Foo" ) , methodReturningInt) - } - unsafe fn methodReturningFoo() -> *mut id { - msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( - "Couldn\'t find Foo" ) , methodReturningFoo) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait Foo { + unsafe fn method(); + unsafe fn methodWithInt_(foo: ::std::os::raw::c_int); + unsafe fn methodWithFoo_(foo: id); + unsafe fn methodReturningInt() + -> ::std::os::raw::c_int; + unsafe fn methodReturningFoo() + -> *mut id; + unsafe fn methodWithArg1_andArg2_andArg3_(intvalue: + ::std::os::raw::c_int, + ptr: + *mut ::std::os::raw::c_char, + floatvalue: f32); } - unsafe fn methodWithArg1_andArg2_andArg3_(intvalue: ::std::os::raw::c_int, - ptr: - *mut ::std::os::raw::c_char, - floatvalue: f32) { - msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( - "Couldn\'t find Foo" ) , - methodWithArg1:intvalue andArg2:ptr andArg3:floatvalue ) + impl Foo for id { + unsafe fn method() { + msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( + "Couldn\'t find Foo" ) , method) + } + unsafe fn methodWithInt_(foo: ::std::os::raw::c_int) { + msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( + "Couldn\'t find Foo" ) , methodWithInt:foo ) + } + unsafe fn methodWithFoo_(foo: id) { + msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( + "Couldn\'t find Foo" ) , methodWithFoo:foo ) + } + unsafe fn methodReturningInt() -> ::std::os::raw::c_int { + msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( + "Couldn\'t find Foo" ) , methodReturningInt) + } + unsafe fn methodReturningFoo() -> *mut id { + msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( + "Couldn\'t find Foo" ) , methodReturningFoo) + } + unsafe fn methodWithArg1_andArg2_andArg3_(intvalue: + ::std::os::raw::c_int, + ptr: + *mut ::std::os::raw::c_char, + floatvalue: f32) { + msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect ( + "Couldn\'t find Foo" ) , + methodWithArg1:intvalue andArg2:ptr andArg3:floatvalue ) + } } } diff --git a/tests/expectations/tests/objc_interface.rs b/tests/expectations/tests/objc_interface.rs index 3ca67b892f..46997ef69c 100644 --- a/tests/expectations/tests/objc_interface.rs +++ b/tests/expectations/tests/objc_interface.rs @@ -1,15 +1,19 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { } -impl Foo for id { } -pub trait protocol_bar { } -impl protocol_bar for id { } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait Foo { } + impl Foo for id { } + pub trait protocol_bar { } + impl protocol_bar for id { } +} diff --git a/tests/expectations/tests/objc_interface_type.rs b/tests/expectations/tests/objc_interface_type.rs index edf551d354..96482c9c68 100644 --- a/tests/expectations/tests/objc_interface_type.rs +++ b/tests/expectations/tests/objc_interface_type.rs @@ -1,43 +1,47 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { } -impl Foo for id { } -#[repr(C)] -#[derive(Debug, Copy)] -pub struct FooStruct { - pub foo: *mut id, -} -#[test] -fn bindgen_test_layout_FooStruct() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( FooStruct ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( FooStruct ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const FooStruct ) ) . foo as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( FooStruct ) , "::" , - stringify ! ( foo ) )); -} -impl Clone for FooStruct { - fn clone(&self) -> Self { *self } -} -impl Default for FooStruct { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -extern "C" { - pub fn fooFunc(foo: id); -} -extern "C" { - #[link_name = "kFoo"] - pub static mut kFoo: *const id; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait Foo { } + impl Foo for id { } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct FooStruct { + pub foo: *mut id, + } + #[test] + fn bindgen_test_layout_FooStruct() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( FooStruct ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( FooStruct ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const FooStruct ) ) . foo as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( FooStruct ) , "::" + , stringify ! ( foo ) )); + } + impl Clone for FooStruct { + fn clone(&self) -> Self { *self } + } + impl Default for FooStruct { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + extern "C" { + pub fn fooFunc(foo: id); + } + extern "C" { + #[link_name = "kFoo"] + pub static mut kFoo: *const id; + } } diff --git a/tests/expectations/tests/objc_method.rs b/tests/expectations/tests/objc_method.rs index d0342a2129..75edb5975c 100644 --- a/tests/expectations/tests/objc_method.rs +++ b/tests/expectations/tests/objc_method.rs @@ -1,48 +1,54 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait Foo { - unsafe fn method(self); - unsafe fn methodWithInt_(self, foo: ::std::os::raw::c_int); - unsafe fn methodWithFoo_(self, foo: id); - unsafe fn methodReturningInt(self) - -> ::std::os::raw::c_int; - unsafe fn methodReturningFoo(self) - -> *mut id; - unsafe fn methodWithArg1_andArg2_andArg3_(self, - intvalue: ::std::os::raw::c_int, - ptr: - *mut ::std::os::raw::c_char, - floatvalue: f32); -} -impl Foo for id { - unsafe fn method(self) { msg_send!(self , method) } - unsafe fn methodWithInt_(self, foo: ::std::os::raw::c_int) { - msg_send!(self , methodWithInt:foo ) - } - unsafe fn methodWithFoo_(self, foo: id) { - msg_send!(self , methodWithFoo:foo ) - } - unsafe fn methodReturningInt(self) -> ::std::os::raw::c_int { - msg_send!(self , methodReturningInt) - } - unsafe fn methodReturningFoo(self) -> *mut id { - msg_send!(self , methodReturningFoo) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait Foo { + unsafe fn method(self); + unsafe fn methodWithInt_(self, foo: ::std::os::raw::c_int); + unsafe fn methodWithFoo_(self, foo: id); + unsafe fn methodReturningInt(self) + -> ::std::os::raw::c_int; + unsafe fn methodReturningFoo(self) + -> *mut id; + unsafe fn methodWithArg1_andArg2_andArg3_(self, + intvalue: + ::std::os::raw::c_int, + ptr: + *mut ::std::os::raw::c_char, + floatvalue: f32); } - unsafe fn methodWithArg1_andArg2_andArg3_(self, - intvalue: ::std::os::raw::c_int, - ptr: - *mut ::std::os::raw::c_char, - floatvalue: f32) { - msg_send!(self , - methodWithArg1:intvalue andArg2:ptr andArg3:floatvalue ) + impl Foo for id { + unsafe fn method(self) { msg_send!(self , method) } + unsafe fn methodWithInt_(self, foo: ::std::os::raw::c_int) { + msg_send!(self , methodWithInt:foo ) + } + unsafe fn methodWithFoo_(self, foo: id) { + msg_send!(self , methodWithFoo:foo ) + } + unsafe fn methodReturningInt(self) -> ::std::os::raw::c_int { + msg_send!(self , methodReturningInt) + } + unsafe fn methodReturningFoo(self) -> *mut id { + msg_send!(self , methodReturningFoo) + } + unsafe fn methodWithArg1_andArg2_andArg3_(self, + intvalue: + ::std::os::raw::c_int, + ptr: + *mut ::std::os::raw::c_char, + floatvalue: f32) { + msg_send!(self , + methodWithArg1:intvalue andArg2:ptr andArg3:floatvalue ) + } } } diff --git a/tests/expectations/tests/objc_protocol.rs b/tests/expectations/tests/objc_protocol.rs index a21d4baa50..6f7ccf1691 100644 --- a/tests/expectations/tests/objc_protocol.rs +++ b/tests/expectations/tests/objc_protocol.rs @@ -1,15 +1,19 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait protocol_Foo { } -impl protocol_Foo for id { } -pub trait Foo { } -impl Foo for id { } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait protocol_Foo { } + impl protocol_Foo for id { } + pub trait Foo { } + impl Foo for id { } +} diff --git a/tests/expectations/tests/objc_sel_and_id.rs b/tests/expectations/tests/objc_sel_and_id.rs index d72b0bc756..16fefec76c 100644 --- a/tests/expectations/tests/objc_sel_and_id.rs +++ b/tests/expectations/tests/objc_sel_and_id.rs @@ -1,22 +1,26 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -extern "C" { - #[link_name = "object"] - pub static mut object: id; -} -extern "C" { - #[link_name = "selector"] - pub static mut selector: objc::runtime::Sel; -} -extern "C" { - pub fn f(object: id, selector: objc::runtime::Sel); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "object"] + pub static mut object: id; + } + extern "C" { + #[link_name = "selector"] + pub static mut selector: objc::runtime::Sel; + } + extern "C" { + pub fn f(object: id, selector: objc::runtime::Sel); + } } diff --git a/tests/expectations/tests/objc_whitelist.rs b/tests/expectations/tests/objc_whitelist.rs index b0418f38d1..f72d641fc7 100644 --- a/tests/expectations/tests/objc_whitelist.rs +++ b/tests/expectations/tests/objc_whitelist.rs @@ -1,35 +1,40 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - #![cfg(target_os="macos")] +pub use self::root::*; + #[macro_use] extern crate objc; #[allow(non_camel_case_types)] pub type id = *mut objc::runtime::Object; -pub trait protocol_SomeProtocol { - unsafe fn protocolMethod(self); - unsafe fn protocolClassMethod(); -} -impl protocol_SomeProtocol for id { - unsafe fn protocolMethod(self) { msg_send!(self , protocolMethod) } - unsafe fn protocolClassMethod() { - msg_send!(objc :: runtime :: Class :: get ( "SomeProtocol" ) . expect - ( "Couldn\'t find SomeProtocol" ) , protocolClassMethod) +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub trait protocol_SomeProtocol { + unsafe fn protocolMethod(self); + unsafe fn protocolClassMethod(); } -} -pub trait WhitelistMe { - unsafe fn method(self); - unsafe fn classMethod(); -} -impl WhitelistMe for id { - unsafe fn method(self) { msg_send!(self , method) } - unsafe fn classMethod() { - msg_send!(objc :: runtime :: Class :: get ( "WhitelistMe" ) . expect ( - "Couldn\'t find WhitelistMe" ) , classMethod) + impl protocol_SomeProtocol for id { + unsafe fn protocolMethod(self) { msg_send!(self , protocolMethod) } + unsafe fn protocolClassMethod() { + msg_send!(objc :: runtime :: Class :: get ( "SomeProtocol" ) . + expect ( "Couldn\'t find SomeProtocol" ) , + protocolClassMethod) + } + } + pub trait WhitelistMe { + unsafe fn method(self); + unsafe fn classMethod(); + } + impl WhitelistMe for id { + unsafe fn method(self) { msg_send!(self , method) } + unsafe fn classMethod() { + msg_send!(objc :: runtime :: Class :: get ( "WhitelistMe" ) . + expect ( "Couldn\'t find WhitelistMe" ) , classMethod) + } } + pub trait WhitelistMe_InterestingCategory { } + impl WhitelistMe_InterestingCategory for id { } } -pub trait WhitelistMe_InterestingCategory { } -impl WhitelistMe_InterestingCategory for id { } diff --git a/tests/expectations/tests/only_bitfields.rs b/tests/expectations/tests/only_bitfields.rs index 0decd2bf0b..cba7fac3c3 100644 --- a/tests/expectations/tests/only_bitfields.rs +++ b/tests/expectations/tests/only_bitfields.rs @@ -1,60 +1,63 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct C { - pub _bitfield_1: u8, - pub __bindgen_align: [u8; 0usize], -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } -} -impl C { - #[inline] - pub fn a(&self) -> bool { - let mask = 1usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u8) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct C { + pub _bitfield_1: u8, + pub __bindgen_align: [u8; 0usize], } - #[inline] - pub fn set_a(&mut self, val: bool) { - let mask = 1usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); } - #[inline] - pub fn b(&self) -> bool { - let mask = 254usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u8) } + impl Clone for C { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn set_b(&mut self, val: bool) { - let mask = 254usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + impl C { + #[inline] + pub fn a(&self) -> bool { + let mask = 1usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_a(&mut self, val: bool) { + let mask = 1usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b(&self) -> bool { + let mask = 254usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_b(&mut self, val: bool) { + let mask = 254usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } } } diff --git a/tests/expectations/tests/opaque-tracing.rs b/tests/expectations/tests/opaque-tracing.rs index c7534d97ce..c8ad4ef95f 100644 --- a/tests/expectations/tests/opaque-tracing.rs +++ b/tests/expectations/tests/opaque-tracing.rs @@ -1,25 +1,28 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Container { - pub _bindgen_opaque_blob: [u32; 2usize], -} -#[test] -fn bindgen_test_layout_Container() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Container ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Container ) )); -} -impl Clone for Container { - fn clone(&self) -> Self { *self } -} -extern "C" { - #[link_name = "_Z3fooP9Container"] - pub fn foo(c: *mut Container); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Container { + pub _bindgen_opaque_blob: [u32; 2usize], + } + #[test] + fn bindgen_test_layout_Container() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Container ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Container ) )); + } + impl Clone for Container { + fn clone(&self) -> Self { *self } + } + extern "C" { + #[link_name = "_Z3fooP9Container"] + pub fn foo(c: *mut Container); + } } diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index f689b02bc0..7c67538723 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -1,42 +1,45 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct opaque { - pub _bindgen_opaque_blob: u32, -} -#[test] -fn bindgen_test_layout_opaque() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( opaque ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( opaque ) )); -} -impl Clone for opaque { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct container { - pub contained: opaque, -} -#[test] -fn bindgen_test_layout_container() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( container ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( container ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const container ) ) . contained as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( container ) , "::" , - stringify ! ( contained ) )); -} -impl Clone for container { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /**
*/ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct opaque { + pub _bindgen_opaque_blob: u32, + } + #[test] + fn bindgen_test_layout_opaque() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( opaque ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( opaque ) )); + } + impl Clone for opaque { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct container { + pub contained: opaque, + } + #[test] + fn bindgen_test_layout_container() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( container ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( container ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const container ) ) . contained as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( container ) , "::" + , stringify ! ( contained ) )); + } + impl Clone for container { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 1a2da431dc..2abb0d1dca 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -1,69 +1,72 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** *
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct OtherOpaque { - pub _bindgen_opaque_blob: u32, -} -#[test] -fn bindgen_test_layout_OtherOpaque() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( OtherOpaque ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( OtherOpaque ) )); -} -impl Clone for OtherOpaque { - fn clone(&self) -> Self { *self } -} -/** + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct OtherOpaque { + pub _bindgen_opaque_blob: u32, + } + #[test] + fn bindgen_test_layout_OtherOpaque() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( OtherOpaque ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( OtherOpaque ) )); + } + impl Clone for OtherOpaque { + fn clone(&self) -> Self { *self } + } + /** *
*/ -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Opaque { -} -impl Default for Opaque { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct WithOpaquePtr { - pub whatever: *mut u8, - pub other: u32, - pub t: OtherOpaque, -} -#[test] -fn bindgen_test_layout_WithOpaquePtr() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( WithOpaquePtr ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( WithOpaquePtr ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithOpaquePtr ) ) . whatever as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithOpaquePtr ) , "::" - , stringify ! ( whatever ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithOpaquePtr ) ) . other as * const _ as - usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( WithOpaquePtr ) , "::" - , stringify ! ( other ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithOpaquePtr ) ) . t as * const _ as - usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( WithOpaquePtr ) , "::" - , stringify ! ( t ) )); -} -impl Clone for WithOpaquePtr { - fn clone(&self) -> Self { *self } -} -impl Default for WithOpaquePtr { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Opaque { + } + impl Default for Opaque { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct WithOpaquePtr { + pub whatever: *mut u8, + pub other: u32, + pub t: OtherOpaque, + } + #[test] + fn bindgen_test_layout_WithOpaquePtr() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! + ( "Size of: " , stringify ! ( WithOpaquePtr ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat + ! ( "Alignment of " , stringify ! ( WithOpaquePtr ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithOpaquePtr ) ) . whatever as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithOpaquePtr ) , + "::" , stringify ! ( whatever ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithOpaquePtr ) ) . other as * const + _ as usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( WithOpaquePtr ) , + "::" , stringify ! ( other ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithOpaquePtr ) ) . t as * const _ as + usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( WithOpaquePtr ) , + "::" , stringify ! ( t ) )); + } + impl Clone for WithOpaquePtr { + fn clone(&self) -> Self { *self } + } + impl Default for WithOpaquePtr { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs index 34b40ff6a7..1b8cc4389c 100644 --- a/tests/expectations/tests/opaque_typedef.rs +++ b/tests/expectations/tests/opaque_typedef.rs @@ -1,14 +1,17 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct RandomTemplate { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct RandomTemplate { + pub _address: u8, + } + /**
*/ + pub type ShouldBeOpaque = u8; + pub type ShouldNotBeOpaque = RandomTemplate; } -/**
*/ -pub type ShouldBeOpaque = u8; -pub type ShouldNotBeOpaque = RandomTemplate; diff --git a/tests/expectations/tests/overflowed_enum.rs b/tests/expectations/tests/overflowed_enum.rs index 9e1f8a7f62..fc96d8b9a6 100644 --- a/tests/expectations/tests/overflowed_enum.rs +++ b/tests/expectations/tests/overflowed_enum.rs @@ -1,16 +1,19 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Foo { - BAP_ARM = 9698489, - BAP_X86 = 11960045, - BAP_X86_64 = 3128633167, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Foo { + BAP_ARM = 9698489, + BAP_X86 = 11960045, + BAP_X86_64 = 3128633167, + } + #[repr(u16)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum Bar { One = 1, Big = 2, } } -#[repr(u16)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum Bar { One = 1, Big = 2, } diff --git a/tests/expectations/tests/overloading.rs b/tests/expectations/tests/overloading.rs index 71002e23bc..f98b0fd0ba 100644 --- a/tests/expectations/tests/overloading.rs +++ b/tests/expectations/tests/overloading.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "_Z8Evaluatec"] - pub fn Evaluate(r: ::std::os::raw::c_char) -> bool; -} -extern "C" { - #[link_name = "_Z8Evaluateii"] - pub fn Evaluate1(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) - -> bool; -} -extern "C" { - #[link_name = "_ZN3foo10MyFunctionEv"] - pub fn foo_MyFunction(); -} -extern "C" { - #[link_name = "_ZN3bar10MyFunctionEv"] - pub fn bar_MyFunction(); +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "_Z8Evaluatec"] + pub fn Evaluate(r: ::std::os::raw::c_char) -> bool; + } + extern "C" { + #[link_name = "_Z8Evaluateii"] + pub fn Evaluate1(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) + -> bool; + } + extern "C" { + #[link_name = "_ZN3foo10MyFunctionEv"] + pub fn foo_MyFunction(); + } + extern "C" { + #[link_name = "_ZN3bar10MyFunctionEv"] + pub fn bar_MyFunction(); + } } diff --git a/tests/expectations/tests/partial-specialization-and-inheritance.rs b/tests/expectations/tests/partial-specialization-and-inheritance.rs index 2422593465..75f996ae30 100644 --- a/tests/expectations/tests/partial-specialization-and-inheritance.rs +++ b/tests/expectations/tests/partial-specialization-and-inheritance.rs @@ -1,44 +1,49 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Base { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Derived { - pub b: bool, -} -#[test] -fn __bindgen_test_layout__bindgen_ty_id_20_instantiation_14() { - assert_eq!(::std::mem::size_of::<[u32; 2usize]>() , 8usize , concat ! ( - "Size of template specialization: " , stringify ! ( - [u32; 2usize] ) )); - assert_eq!(::std::mem::align_of::<[u32; 2usize]>() , 4usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - [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 ! ( - "Size of: " , stringify ! ( Usage ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Usage ) )); -} -impl Clone for Usage { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Base { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Derived { + pub b: bool, + } + #[test] + fn __bindgen_test_layout__bindgen_ty_id_21_instantiation_15() { + assert_eq!(::std::mem::size_of::<[u32; 2usize]>() , 8usize , concat ! + ( + "Size of template specialization: " , stringify ! ( + [u32; 2usize] ) )); + assert_eq!(::std::mem::align_of::<[u32; 2usize]>() , 4usize , concat ! + ( + "Alignment of template specialization: " , stringify ! ( + [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 ! ( + "Size of: " , stringify ! ( Usage ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Usage ) )); + } + impl Clone for Usage { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/prepend_enum_name.rs b/tests/expectations/tests/prepend_enum_name.rs index d95bd1b4bc..c0ce1a9659 100644 --- a/tests/expectations/tests/prepend_enum_name.rs +++ b/tests/expectations/tests/prepend_enum_name.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const FOO_BAR: foo = 0; -pub const FOO_BAZ: foo = 1; -pub type foo = ::std::os::raw::c_uint; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const FOO_BAR: foo = 0; + pub const FOO_BAZ: foo = 1; + pub type foo = ::std::os::raw::c_uint; +} diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index a9fbef9f50..5fced9c733 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -1,88 +1,93 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct HasPrivate { - pub mNotPrivate: ::std::os::raw::c_int, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct HasPrivate { + pub mNotPrivate: ::std::os::raw::c_int, + /**
*/ + mIsPrivate: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_HasPrivate() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( HasPrivate ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( HasPrivate ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const HasPrivate ) ) . mNotPrivate as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( HasPrivate ) , "::" + , stringify ! ( mNotPrivate ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const HasPrivate ) ) . mIsPrivate as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( HasPrivate ) , "::" + , stringify ! ( mIsPrivate ) )); + } + impl Clone for HasPrivate { + fn clone(&self) -> Self { *self } + } /**
*/ - mIsPrivate: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_HasPrivate() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( HasPrivate ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( HasPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const HasPrivate ) ) . mNotPrivate as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( HasPrivate ) , "::" , - stringify ! ( mNotPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const HasPrivate ) ) . mIsPrivate as * const _ - as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( HasPrivate ) , "::" , - stringify ! ( mIsPrivate ) )); -} -impl Clone for HasPrivate { - fn clone(&self) -> Self { *self } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct VeryPrivate { - mIsPrivate: ::std::os::raw::c_int, - mIsAlsoPrivate: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_VeryPrivate() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( VeryPrivate ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( VeryPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const VeryPrivate ) ) . mIsPrivate as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( VeryPrivate ) , "::" , - stringify ! ( mIsPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const VeryPrivate ) ) . mIsAlsoPrivate as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( VeryPrivate ) , "::" , - stringify ! ( mIsAlsoPrivate ) )); -} -impl Clone for VeryPrivate { - fn clone(&self) -> Self { *self } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct ContradictPrivate { - /**
*/ - pub mNotPrivate: ::std::os::raw::c_int, - mIsPrivate: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_ContradictPrivate() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( ContradictPrivate ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( ContradictPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictPrivate ) ) . mNotPrivate as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictPrivate ) , - "::" , stringify ! ( mNotPrivate ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const ContradictPrivate ) ) . mIsPrivate as * - const _ as usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( ContradictPrivate ) , - "::" , stringify ! ( mIsPrivate ) )); -} -impl Clone for ContradictPrivate { - fn clone(&self) -> Self { *self } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct VeryPrivate { + mIsPrivate: ::std::os::raw::c_int, + mIsAlsoPrivate: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_VeryPrivate() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( VeryPrivate ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( VeryPrivate ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const VeryPrivate ) ) . mIsPrivate as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( VeryPrivate ) , + "::" , stringify ! ( mIsPrivate ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const VeryPrivate ) ) . mIsAlsoPrivate as * + const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( VeryPrivate ) , + "::" , stringify ! ( mIsAlsoPrivate ) )); + } + impl Clone for VeryPrivate { + fn clone(&self) -> Self { *self } + } + /**
*/ + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct ContradictPrivate { + /**
*/ + pub mNotPrivate: ::std::os::raw::c_int, + mIsPrivate: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_ContradictPrivate() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( ContradictPrivate ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( ContradictPrivate ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictPrivate ) ) . mNotPrivate + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( ContradictPrivate ) + , "::" , stringify ! ( mNotPrivate ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const ContradictPrivate ) ) . mIsPrivate as + * const _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( ContradictPrivate ) + , "::" , stringify ! ( mIsPrivate ) )); + } + impl Clone for ContradictPrivate { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/public-dtor.rs b/tests/expectations/tests/public-dtor.rs index d24e863e4a..e660c8a5ff 100644 --- a/tests/expectations/tests/public-dtor.rs +++ b/tests/expectations/tests/public-dtor.rs @@ -1,26 +1,31 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default)] -pub struct cv_String { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_cv_String() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( 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) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default)] + pub struct cv_String { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_cv_String() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( 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/redeclaration.rs b/tests/expectations/tests/redeclaration.rs index 0d7e585cad..3483cfd06a 100644 --- a/tests/expectations/tests/redeclaration.rs +++ b/tests/expectations/tests/redeclaration.rs @@ -1,9 +1,12 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -extern "C" { - pub fn foo(); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn foo(); + } } diff --git a/tests/expectations/tests/ref_argument_array.rs b/tests/expectations/tests/ref_argument_array.rs index 51531824cb..d67c1ec2f4 100644 --- a/tests/expectations/tests/ref_argument_array.rs +++ b/tests/expectations/tests/ref_argument_array.rs @@ -1,27 +1,30 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub const NSID_LENGTH: ::std::os::raw::c_uint = 10; -#[repr(C)] -pub struct nsID__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct nsID { - pub vtable_: *const nsID__bindgen_vtable, -} -#[test] -fn bindgen_test_layout_nsID() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsID ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsID ) )); -} -impl Clone for nsID { - fn clone(&self) -> Self { *self } -} -impl Default for nsID { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const NSID_LENGTH: ::std::os::raw::c_uint = 10; + #[repr(C)] + pub struct nsID__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct nsID { + pub vtable_: *const nsID__bindgen_vtable, + } + #[test] + fn bindgen_test_layout_nsID() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsID ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( nsID ) )); + } + impl Clone for nsID { + fn clone(&self) -> Self { *self } + } + impl Default for nsID { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index 93cd3012c5..e5c4b8b00c 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/replace_template_alias.rs b/tests/expectations/tests/replace_template_alias.rs index dbd0d283de..87b3f8be7c 100644 --- a/tests/expectations/tests/replace_template_alias.rs +++ b/tests/expectations/tests/replace_template_alias.rs @@ -1,18 +1,21 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/// But the replacement type does use T! +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /// But the replacement type does use T! /// ///
-pub type JS_detail_MaybeWrapped = T; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct JS_Rooted { - pub ptr: JS_detail_MaybeWrapped, -} -impl Default for JS_Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + pub type JS_detail_MaybeWrapped = T; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct JS_Rooted { + pub ptr: JS_detail_MaybeWrapped, + } + impl Default for JS_Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index 6cdc326383..5beb489766 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -1,37 +1,40 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + /** *
*/ -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct nsTArray { - pub y: ::std::os::raw::c_uint, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Test { - pub a: nsTArray, -} -#[test] -fn bindgen_test_layout_Test() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Test ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Test ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Test ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Test ) , "::" , - stringify ! ( a ) )); -} -impl Clone for Test { - fn clone(&self) -> Self { *self } -} -impl Default for Test { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct nsTArray { + pub y: ::std::os::raw::c_uint, + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Test { + pub a: nsTArray, + } + #[test] + fn bindgen_test_layout_Test() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Test ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Test ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Test ) ) . a as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Test ) , "::" , + stringify ! ( a ) )); + } + impl Clone for Test { + fn clone(&self) -> Self { *self } + } + impl Default for Test { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/replaces_double.rs b/tests/expectations/tests/replaces_double.rs index 99b812db39..490e7c36e8 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -1,18 +1,21 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub ptr: Rooted_MaybeWrapped, -} -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub ptr: Rooted_MaybeWrapped, + } + /** *
*/ -pub type Rooted_MaybeWrapped = T; -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } + pub type Rooted_MaybeWrapped = T; + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/resolved_type_def_function.rs b/tests/expectations/tests/resolved_type_def_function.rs index 83f07dd0c8..62b38b595d 100644 --- a/tests/expectations/tests/resolved_type_def_function.rs +++ b/tests/expectations/tests/resolved_type_def_function.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type FuncType = ::std::option::Option; -extern "C" { - pub fn Func(); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type FuncType = ::std::option::Option; + extern "C" { + pub fn Func(); + } } diff --git a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs index 820b5e71e0..b47f8ff82f 100644 --- a/tests/expectations/tests/same_struct_name_in_different_namespaces.rs +++ b/tests/expectations/tests/same_struct_name_in_different_namespaces.rs @@ -1,35 +1,38 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct JS_Zone([u8; 0]); -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct JS_shadow_Zone { - pub x: ::std::os::raw::c_int, - pub y: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_JS_shadow_Zone() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( JS_shadow_Zone ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( JS_shadow_Zone ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JS_shadow_Zone ) ) . x as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( JS_shadow_Zone ) , "::" - , stringify ! ( x ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const JS_shadow_Zone ) ) . y as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( JS_shadow_Zone ) , "::" - , stringify ! ( y ) )); -} -impl Clone for JS_shadow_Zone { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct JS_Zone([u8; 0]); + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct JS_shadow_Zone { + pub x: ::std::os::raw::c_int, + pub y: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_JS_shadow_Zone() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! + ( "Size of: " , stringify ! ( JS_shadow_Zone ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( JS_shadow_Zone ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const JS_shadow_Zone ) ) . x as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( JS_shadow_Zone ) , + "::" , stringify ! ( x ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const JS_shadow_Zone ) ) . y as * const _ + as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( JS_shadow_Zone ) , + "::" , stringify ! ( y ) )); + } + impl Clone for JS_shadow_Zone { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/size_t_template.rs b/tests/expectations/tests/size_t_template.rs index b2680869a9..2248615923 100644 --- a/tests/expectations/tests/size_t_template.rs +++ b/tests/expectations/tests/size_t_template.rs @@ -1,25 +1,28 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct C { - pub arr: [u32; 3usize], -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( arr ) )); -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + pub struct C { + pub arr: [u32; 3usize], + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 12usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . arr as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( arr ) )); + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/struct_containing_forward_declared_struct.rs b/tests/expectations/tests/struct_containing_forward_declared_struct.rs index 58ab04c946..165faf44a0 100644 --- a/tests/expectations/tests/struct_containing_forward_declared_struct.rs +++ b/tests/expectations/tests/struct_containing_forward_declared_struct.rs @@ -1,49 +1,52 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy)] -pub struct a { - pub val_a: *mut b, -} -#[test] -fn bindgen_test_layout_a() { - assert_eq!(::std::mem::size_of::
() , 8usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const a ) ) . val_a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( val_a ) )); -} -impl Clone for a { - fn clone(&self) -> Self { *self } -} -impl Default for a { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct b { - pub val_b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_b() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( b ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const b ) ) . val_b as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( b ) , "::" , stringify - ! ( val_b ) )); -} -impl Clone for b { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct a { + pub val_a: *mut b, + } + #[test] + fn bindgen_test_layout_a() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( a ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const a ) ) . val_a as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( a ) , "::" , + stringify ! ( val_a ) )); + } + impl Clone for a { + fn clone(&self) -> Self { *self } + } + impl Default for a { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct b { + pub val_b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_b() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( b ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const b ) ) . val_b as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( b ) , "::" , + stringify ! ( val_b ) )); + } + impl Clone for b { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/struct_typedef.rs b/tests/expectations/tests/struct_typedef.rs index 63811bda7a..401eee79a2 100644 --- a/tests/expectations/tests/struct_typedef.rs +++ b/tests/expectations/tests/struct_typedef.rs @@ -1,61 +1,66 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct typedef_named_struct { - pub has_name: bool, -} -#[test] -fn bindgen_test_layout_typedef_named_struct() { - assert_eq!(::std::mem::size_of::() , 1usize , concat - ! ( "Size of: " , stringify ! ( typedef_named_struct ) )); - assert_eq! (::std::mem::align_of::() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( typedef_named_struct ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const typedef_named_struct ) ) . has_name as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( typedef_named_struct ) - , "::" , stringify ! ( has_name ) )); -} -impl Clone for typedef_named_struct { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct _bindgen_ty_1 { - pub no_name: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . no_name as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( no_name ) )); -} -impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl Default for _bindgen_ty_1 { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct typedef_named_struct { + pub has_name: bool, + } + #[test] + fn bindgen_test_layout_typedef_named_struct() { + assert_eq!(::std::mem::size_of::() , 1usize , + concat ! ( + "Size of: " , stringify ! ( typedef_named_struct ) )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( typedef_named_struct ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const typedef_named_struct ) ) . has_name + as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + typedef_named_struct ) , "::" , stringify ! ( has_name ) + )); + } + impl Clone for typedef_named_struct { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct _bindgen_ty_1 { + pub no_name: *mut ::std::os::raw::c_void, + } + #[test] + fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! + ( "Size of: " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 8usize , concat + ! ( "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . no_name as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , + "::" , stringify ! ( no_name ) )); + } + impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl Default for _bindgen_ty_1 { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type struct_ptr_t = *mut _bindgen_ty_1; + pub type struct_ptr_ptr_t = *mut *mut _bindgen_ty_1; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum typedef_named_enum { ENUM_HAS_NAME = 1, } + pub const ENUM_IS_ANON: _bindgen_ty_2 = _bindgen_ty_2::ENUM_IS_ANON; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_2 { ENUM_IS_ANON = 0, } + pub type enum_ptr_t = *mut _bindgen_ty_2; + pub type enum_ptr_ptr_t = *mut *mut _bindgen_ty_2; } -pub type struct_ptr_t = *mut _bindgen_ty_1; -pub type struct_ptr_ptr_t = *mut *mut _bindgen_ty_1; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum typedef_named_enum { ENUM_HAS_NAME = 1, } -pub const ENUM_IS_ANON: _bindgen_ty_2 = _bindgen_ty_2::ENUM_IS_ANON; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _bindgen_ty_2 { ENUM_IS_ANON = 0, } -pub type enum_ptr_t = *mut _bindgen_ty_2; -pub type enum_ptr_ptr_t = *mut *mut _bindgen_ty_2; diff --git a/tests/expectations/tests/struct_typedef_ns.rs b/tests/expectations/tests/struct_typedef_ns.rs index 9f2c3b3446..f0df87de4a 100644 --- a/tests/expectations/tests/struct_typedef_ns.rs +++ b/tests/expectations/tests/struct_typedef_ns.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] @@ -37,7 +33,7 @@ pub mod root { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum typedef_enum { BAR = 1, } } - pub mod _bindgen_mod_id_12 { + pub mod _bindgen_mod_id_13 { #[allow(unused_imports)] use self::super::super::root; #[repr(C)] @@ -62,14 +58,14 @@ pub mod root { impl Clone for _bindgen_ty_1 { fn clone(&self) -> Self { *self } } - pub type typedef_struct = root::_bindgen_mod_id_12::_bindgen_ty_1; - pub const _bindgen_mod_id_12_BAR: - root::_bindgen_mod_id_12::_bindgen_ty_2 = + pub type typedef_struct = root::_bindgen_mod_id_13::_bindgen_ty_1; + pub const _bindgen_mod_id_13_BAR: + root::_bindgen_mod_id_13::_bindgen_ty_2 = _bindgen_ty_2::BAR; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_2 { BAR = 1, } - pub use self::super::super::root::_bindgen_mod_id_12::_bindgen_ty_2 as + pub use self::super::super::root::_bindgen_mod_id_13::_bindgen_ty_2 as typedef_enum; } } diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/tests/expectations/tests/struct_with_anon_struct.rs index b02fdd0ed7..b676323ad0 100644 --- a/tests/expectations/tests/struct_with_anon_struct.rs +++ b/tests/expectations/tests/struct_with_anon_struct.rs @@ -1,52 +1,57 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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: ::std::os::raw::c_int, - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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: ::std::os::raw::c_int, + pub b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/struct_with_anon_struct_array.rs b/tests/expectations/tests/struct_with_anon_struct_array.rs index a19c957b35..d45f4a9e0c 100644 --- a/tests/expectations/tests/struct_with_anon_struct_array.rs +++ b/tests/expectations/tests/struct_with_anon_struct_array.rs @@ -1,84 +1,91 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 { - pub a: ::std::os::raw::c_int, - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo__bindgen_ty_2 { - pub a: ::std::os::raw::c_int, - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_2 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_2 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_2 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 208usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } , - 16usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( baz ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 { + pub a: ::std::os::raw::c_int, + pub b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct foo__bindgen_ty_2 { + pub a: ::std::os::raw::c_int, + pub b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_2 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_2 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_2 ) ) . b as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_2 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 208usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . baz as * const _ as usize } + , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/tests/expectations/tests/struct_with_anon_struct_pointer.rs index e0b06f7682..e3e35ea462 100644 --- a/tests/expectations/tests/struct_with_anon_struct_pointer.rs +++ b/tests/expectations/tests/struct_with_anon_struct_pointer.rs @@ -1,55 +1,60 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 { - pub a: ::std::os::raw::c_int, - pub b: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } -} -impl Default for foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 { + pub a: ::std::os::raw::c_int, + pub b: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } + impl Default for foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/tests/expectations/tests/struct_with_anon_union.rs index aff61c4542..ffecb526f4 100644 --- a/tests/expectations/tests/struct_with_anon_union.rs +++ b/tests/expectations/tests/struct_with_anon_union.rs @@ -1,77 +1,86 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } } -} -#[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>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs index 80039415bb..f7f1805175 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_struct.rs @@ -1,47 +1,52 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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: ::std::os::raw::c_uint, - pub b: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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: ::std::os::raw::c_uint, + pub b: ::std::os::raw::c_uint, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/tests/expectations/tests/struct_with_anon_unnamed_union.rs index f55d8e3867..143b3225ab 100644 --- a/tests/expectations/tests/struct_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/struct_with_anon_unnamed_union.rs @@ -1,72 +1,81 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } } -} -#[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>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs index 92f1ec474a..c52d20d090 100644 --- a/tests/expectations/tests/struct_with_bitfields.rs +++ b/tests/expectations/tests/struct_with_bitfields.rs @@ -1,139 +1,142 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct bitfield { - pub _bitfield_1: u8, - pub e: ::std::os::raw::c_int, - pub _bitfield_2: u8, - pub _bitfield_3: u32, -} -#[test] -fn bindgen_test_layout_bitfield() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( bitfield ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( bitfield ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const bitfield ) ) . e as * const _ as usize } - , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( bitfield ) , "::" , - stringify ! ( e ) )); -} -impl Clone for bitfield { - fn clone(&self) -> Self { *self } -} -impl bitfield { - #[inline] - pub fn a(&self) -> ::std::os::raw::c_ushort { - let mask = 1usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_a(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 1usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn b(&self) -> ::std::os::raw::c_ushort { - let mask = 2usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 1usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_b(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 2usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 1usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn c(&self) -> ::std::os::raw::c_ushort { - let mask = 4usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 2usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_c(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 4usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 2usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn d(&self) -> ::std::os::raw::c_ushort { - let mask = 192usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 6usize; - unsafe { ::std::mem::transmute(val as u16) } - } - #[inline] - pub fn set_d(&mut self, val: ::std::os::raw::c_ushort) { - let mask = 192usize as u8; - let val = val as u16 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 6usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn f(&self) -> ::std::os::raw::c_uint { - let mask = 3usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct bitfield { + pub _bitfield_1: u8, + pub e: ::std::os::raw::c_int, + pub _bitfield_2: u8, + pub _bitfield_3: u32, } - #[inline] - pub fn set_f(&mut self, val: ::std::os::raw::c_uint) { - let mask = 3usize as u8; - let val = val as u32 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + #[test] + fn bindgen_test_layout_bitfield() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( bitfield ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( bitfield ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const bitfield ) ) . e as * const _ as + usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( bitfield ) , "::" , + stringify ! ( e ) )); } - #[inline] - pub fn g(&self) -> ::std::os::raw::c_uint { - let mask = 4294967295usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_3) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } + impl Clone for bitfield { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn set_g(&mut self, val: ::std::os::raw::c_uint) { - let mask = 4294967295usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_3) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_3 = unsafe { ::std::mem::transmute(field_val) }; + impl bitfield { + #[inline] + pub fn a(&self) -> ::std::os::raw::c_ushort { + let mask = 1usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_a(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 1usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn b(&self) -> ::std::os::raw::c_ushort { + let mask = 2usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 1usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_b(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 2usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 1usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn c(&self) -> ::std::os::raw::c_ushort { + let mask = 4usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 2usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_c(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 4usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 2usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn d(&self) -> ::std::os::raw::c_ushort { + let mask = 192usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 6usize; + unsafe { ::std::mem::transmute(val as u16) } + } + #[inline] + pub fn set_d(&mut self, val: ::std::os::raw::c_ushort) { + let mask = 192usize as u8; + let val = val as u16 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 6usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn f(&self) -> ::std::os::raw::c_uint { + let mask = 3usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_f(&mut self, val: ::std::os::raw::c_uint) { + let mask = 3usize as u8; + let val = val as u32 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn g(&self) -> ::std::os::raw::c_uint { + let mask = 4294967295usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_3) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_g(&mut self, val: ::std::os::raw::c_uint) { + let mask = 4294967295usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_3) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_3 = unsafe { ::std::mem::transmute(field_val) }; + } } } diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/tests/expectations/tests/struct_with_derive_debug.rs index 58a94853be..71ba6758bd 100644 --- a/tests/expectations/tests/struct_with_derive_debug.rs +++ b/tests/expectations/tests/struct_with_derive_debug.rs @@ -1,84 +1,89 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct LittleArray { - pub a: [::std::os::raw::c_int; 32usize], -} -#[test] -fn bindgen_test_layout_LittleArray() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! ( - "Size of: " , stringify ! ( LittleArray ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( LittleArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const LittleArray ) ) . a as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( LittleArray ) , "::" , - stringify ! ( a ) )); -} -impl Clone for LittleArray { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -pub struct BigArray { - pub a: [::std::os::raw::c_int; 33usize], -} -#[test] -fn bindgen_test_layout_BigArray() { - assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( - "Size of: " , stringify ! ( BigArray ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( BigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const BigArray ) ) . a as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( BigArray ) , "::" , - stringify ! ( a ) )); -} -impl Default for BigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct WithLittleArray { - pub a: LittleArray, -} -#[test] -fn bindgen_test_layout_WithLittleArray() { - assert_eq!(::std::mem::size_of::() , 128usize , concat ! - ( "Size of: " , stringify ! ( WithLittleArray ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! - ( "Alignment of " , stringify ! ( WithLittleArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithLittleArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithLittleArray ) , - "::" , stringify ! ( a ) )); -} -impl Clone for WithLittleArray { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -pub struct WithBigArray { - pub a: BigArray, -} -#[test] -fn bindgen_test_layout_WithBigArray() { - assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( a ) )); -} -impl Default for WithBigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct LittleArray { + pub a: [::std::os::raw::c_int; 32usize], + } + #[test] + fn bindgen_test_layout_LittleArray() { + assert_eq!(::std::mem::size_of::() , 128usize , concat ! + ( "Size of: " , stringify ! ( LittleArray ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( LittleArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const LittleArray ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( LittleArray ) , + "::" , stringify ! ( a ) )); + } + impl Clone for LittleArray { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + pub struct BigArray { + pub a: [::std::os::raw::c_int; 33usize], + } + #[test] + fn bindgen_test_layout_BigArray() { + assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( + "Size of: " , stringify ! ( BigArray ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( BigArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const BigArray ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( BigArray ) , "::" , + stringify ! ( a ) )); + } + impl Default for BigArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct WithLittleArray { + pub a: LittleArray, + } + #[test] + fn bindgen_test_layout_WithLittleArray() { + assert_eq!(::std::mem::size_of::() , 128usize , + concat ! ( "Size of: " , stringify ! ( WithLittleArray ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( WithLittleArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithLittleArray ) ) . a as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithLittleArray ) , + "::" , stringify ! ( a ) )); + } + impl Clone for WithLittleArray { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + pub struct WithBigArray { + pub a: BigArray, + } + #[test] + fn bindgen_test_layout_WithBigArray() { + assert_eq!(::std::mem::size_of::() , 132usize , concat ! + ( "Size of: " , stringify ! ( WithBigArray ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( WithBigArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray ) , + "::" , stringify ! ( a ) )); + } + impl Default for WithBigArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/struct_with_nesting.rs b/tests/expectations/tests/struct_with_nesting.rs index 30ba124b94..10afe8a1a1 100644 --- a/tests/expectations/tests/struct_with_nesting.rs +++ b/tests/expectations/tests/struct_with_nesting.rs @@ -1,152 +1,161 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . + c1 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( + c1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . + c2 as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( + c2 ) )); + } + impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct foo__bindgen_ty_1__bindgen_ty_2 { + pub d1: ::std::os::raw::c_uchar, + pub d2: ::std::os::raw::c_uchar, + pub d3: ::std::os::raw::c_uchar, + pub d4: ::std::os::raw::c_uchar, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 4usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 + ) )); + assert_eq! (::std::mem::align_of::() + , 1usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . + d1 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + d1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . + d2 as * const _ as usize } , 1usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + d2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . + d3 as * const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + d3 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . + d4 as * const _ as usize } , 3usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + d4 ) )); + } + impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + } + impl Clone for foo { + 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, -} -#[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, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . c2 - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( c2 ) - )); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo__bindgen_ty_1__bindgen_ty_2 { - pub d1: ::std::os::raw::c_uchar, - pub d2: ::std::os::raw::c_uchar, - pub d3: ::std::os::raw::c_uchar, - pub d4: ::std::os::raw::c_uchar, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , - 4usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , - 1usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d2 - as * const _ as usize } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d2 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d3 - as * const _ as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d3 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . d4 - as * const _ as usize } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( d4 ) - )); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/struct_with_packing.rs b/tests/expectations/tests/struct_with_packing.rs index cba3d4759e..139b6caa56 100644 --- a/tests/expectations/tests/struct_with_packing.rs +++ b/tests/expectations/tests/struct_with_packing.rs @@ -1,30 +1,35 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C, packed)] -#[derive(Debug, Default, Copy)] -pub struct a { - pub b: ::std::os::raw::c_char, - pub c: ::std::os::raw::c_short, -} -#[test] -fn bindgen_test_layout_a() { - assert_eq!(::std::mem::size_of::() , 3usize , concat ! ( - "Size of: " , stringify ! ( a ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( a ) )); - assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . b as * const _ as usize - } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( b ) )); - assert_eq! (unsafe { & ( * ( 0 as * const a ) ) . c as * const _ as usize - } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( a ) , "::" , stringify - ! ( c ) )); -} -impl Clone for a { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C, packed)] + #[derive(Debug, Default, Copy)] + pub struct a { + pub b: ::std::os::raw::c_char, + pub c: ::std::os::raw::c_short, + } + #[test] + fn bindgen_test_layout_a() { + assert_eq!(::std::mem::size_of::() , 3usize , concat ! ( + "Size of: " , stringify ! ( a ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const a ) ) . b as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( a ) , "::" , + stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const a ) ) . c as * const _ as usize } , + 1usize , concat ! ( + "Alignment of field: " , stringify ! ( a ) , "::" , + stringify ! ( c ) )); + } + impl Clone for a { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/struct_with_struct.rs b/tests/expectations/tests/struct_with_struct.rs index bcdaada225..169002f0f2 100644 --- a/tests/expectations/tests/struct_with_struct.rs +++ b/tests/expectations/tests/struct_with_struct.rs @@ -1,52 +1,57 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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 x: ::std::os::raw::c_uint, - pub y: ::std::os::raw::c_uint, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . x as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( x ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . y as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( y ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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 x: ::std::os::raw::c_uint, + pub y: ::std::os::raw::c_uint, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . x as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( x ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . y as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( y ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/struct_with_typedef_template_arg.rs b/tests/expectations/tests/struct_with_typedef_template_arg.rs index 93620e5948..ba29debf11 100644 --- a/tests/expectations/tests/struct_with_typedef_template_arg.rs +++ b/tests/expectations/tests/struct_with_typedef_template_arg.rs @@ -1,13 +1,16 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Proxy { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Proxy { + pub _address: u8, + } + pub type Proxy_foo = + ::std::option::Option; } -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 05351d7d7b..b18c0294e3 100644 --- a/tests/expectations/tests/template-fun-ty.rs +++ b/tests/expectations/tests/template-fun-ty.rs @@ -1,26 +1,29 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, -} -pub type Foo_FunctionPtr = - ::std::option::Option T>; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct RefPtr_Proxy { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Foo { + pub _address: u8, + } + pub type Foo_FunctionPtr = + ::std::option::Option T>; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct RefPtr { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct RefPtr_Proxy { + pub _address: u8, + } + pub type RefPtr_Proxy_member_function = + ::std::option::Option R>; + pub type Returner = ::std::option::Option T>; } -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-0.rs b/tests/expectations/tests/template-param-usage-0.rs index 494001f771..600d64b067 100644 --- a/tests/expectations/tests/template-param-usage-0.rs +++ b/tests/expectations/tests/template-param-usage-0.rs @@ -1,14 +1,17 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter { - pub t: T, -} -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct UsesTemplateParameter { + pub t: T, + } + impl Default for UsesTemplateParameter { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template-param-usage-1.rs b/tests/expectations/tests/template-param-usage-1.rs index 0fd8719bf2..845654aabd 100644 --- a/tests/expectations/tests/template-param-usage-1.rs +++ b/tests/expectations/tests/template-param-usage-1.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct DoesNotUseTemplateParameter { - pub x: ::std::os::raw::c_int, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct DoesNotUseTemplateParameter { + pub x: ::std::os::raw::c_int, + } } diff --git a/tests/expectations/tests/template-param-usage-10.rs b/tests/expectations/tests/template-param-usage-10.rs index 95d200b576..a19a4215e2 100644 --- a/tests/expectations/tests/template-param-usage-10.rs +++ b/tests/expectations/tests/template-param-usage-10.rs @@ -1,25 +1,28 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DoublyIndirectUsage { - pub doubly_indirect: DoublyIndirectUsage_IndirectUsage, -} -pub type DoublyIndirectUsage_Aliased = T; -pub type DoublyIndirectUsage_Typedefed = U; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DoublyIndirectUsage_IndirectUsage { - pub member: DoublyIndirectUsage_Aliased, - pub another: DoublyIndirectUsage_Typedefed, -} -impl Default for DoublyIndirectUsage_IndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for DoublyIndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct DoublyIndirectUsage { + pub doubly_indirect: DoublyIndirectUsage_IndirectUsage, + } + pub type DoublyIndirectUsage_Aliased = T; + pub type DoublyIndirectUsage_Typedefed = U; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct DoublyIndirectUsage_IndirectUsage { + pub member: DoublyIndirectUsage_Aliased, + pub another: DoublyIndirectUsage_Typedefed, + } + impl Default for DoublyIndirectUsage_IndirectUsage { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl Default for DoublyIndirectUsage { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template-param-usage-11.rs b/tests/expectations/tests/template-param-usage-11.rs index a8959b9951..760ffdc061 100644 --- a/tests/expectations/tests/template-param-usage-11.rs +++ b/tests/expectations/tests/template-param-usage-11.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct DoesNotUseT { - pub _address: u8, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct DoesNotUseT { + pub _address: u8, + } } diff --git a/tests/expectations/tests/template-param-usage-12.rs b/tests/expectations/tests/template-param-usage-12.rs index 0c31111e78..23871e4b5f 100644 --- a/tests/expectations/tests/template-param-usage-12.rs +++ b/tests/expectations/tests/template-param-usage-12.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct BaseUsesT { - pub t: *mut T, -} -impl Default for BaseUsesT { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct CrtpUsesU { - pub _base: BaseUsesT>, - pub usage: U, -} -impl Default for CrtpUsesU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct BaseUsesT { + pub t: *mut T, + } + impl Default for BaseUsesT { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct CrtpUsesU { + pub _base: BaseUsesT>, + pub usage: U, + } + impl Default for CrtpUsesU { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template-param-usage-13.rs b/tests/expectations/tests/template-param-usage-13.rs index c77da0973e..e554b6da17 100644 --- a/tests/expectations/tests/template-param-usage-13.rs +++ b/tests/expectations/tests/template-param-usage-13.rs @@ -1,20 +1,23 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct BaseIgnoresT { - pub x: ::std::os::raw::c_int, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct CrtpUsesU { - pub _base: BaseIgnoresT, - pub usage: U, -} -impl Default for CrtpUsesU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct BaseIgnoresT { + pub x: ::std::os::raw::c_int, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct CrtpUsesU { + pub _base: BaseIgnoresT, + pub usage: U, + } + impl Default for CrtpUsesU { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template-param-usage-14.rs b/tests/expectations/tests/template-param-usage-14.rs index fae4afdca8..d41f3dc464 100644 --- a/tests/expectations/tests/template-param-usage-14.rs +++ b/tests/expectations/tests/template-param-usage-14.rs @@ -1,20 +1,23 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct BaseIgnoresT { - pub x: ::std::os::raw::c_int, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct CrtpIgnoresU { - pub _base: BaseIgnoresT, - pub y: ::std::os::raw::c_int, -} -impl Default for CrtpIgnoresU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct BaseIgnoresT { + pub x: ::std::os::raw::c_int, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct CrtpIgnoresU { + pub _base: BaseIgnoresT, + pub y: ::std::os::raw::c_int, + } + impl Default for CrtpIgnoresU { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template-param-usage-15.rs b/tests/expectations/tests/template-param-usage-15.rs index a653e08904..81cd5e19b9 100644 --- a/tests/expectations/tests/template-param-usage-15.rs +++ b/tests/expectations/tests/template-param-usage-15.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct BaseUsesT { - pub usage: *mut T, -} -impl Default for BaseUsesT { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct CrtpIgnoresU { - pub _base: BaseUsesT, - pub y: ::std::os::raw::c_int, -} -impl Default for CrtpIgnoresU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct BaseUsesT { + pub usage: *mut T, + } + impl Default for BaseUsesT { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct CrtpIgnoresU { + pub _base: BaseUsesT, + pub y: ::std::os::raw::c_int, + } + impl Default for CrtpIgnoresU { + 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 6dc21b6865..99a51538f3 100644 --- a/tests/expectations/tests/template-param-usage-2.rs +++ b/tests/expectations/tests/template-param-usage-2.rs @@ -1,22 +1,25 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter { - pub t: T, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter_AlsoUsesTemplateParameter { - pub also: T, -} -impl Default for UsesTemplateParameter_AlsoUsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct UsesTemplateParameter { + pub t: T, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct UsesTemplateParameter_AlsoUsesTemplateParameter { + pub also: T, + } + impl Default for UsesTemplateParameter_AlsoUsesTemplateParameter { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + 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 a7ff22f900..7d52a6c1cf 100644 --- a/tests/expectations/tests/template-param-usage-3.rs +++ b/tests/expectations/tests/template-param-usage-3.rs @@ -1,24 +1,27 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter { - pub t: T, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { - pub also: T, - pub more: U, -} -impl Default for - UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for UsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct UsesTemplateParameter { + pub t: T, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { + pub also: T, + pub more: U, + } + impl Default for + UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + 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 31f8872dbb..11a1231e54 100644 --- a/tests/expectations/tests/template-param-usage-4.rs +++ b/tests/expectations/tests/template-param-usage-4.rs @@ -1,19 +1,22 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct UsesTemplateParameter { - pub t: T, -} -#[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() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct UsesTemplateParameter { + pub t: T, + } + #[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 5a9caf32d0..905ef09252 100644 --- a/tests/expectations/tests/template-param-usage-5.rs +++ b/tests/expectations/tests/template-param-usage-5.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct IndirectlyUsesTemplateParameter { - pub aliased: IndirectlyUsesTemplateParameter_Aliased, -} -pub type IndirectlyUsesTemplateParameter_Aliased = T; -impl Default for IndirectlyUsesTemplateParameter { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct IndirectlyUsesTemplateParameter { + pub aliased: IndirectlyUsesTemplateParameter_Aliased, + } + 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 37b7fe6413..717b452e04 100644 --- a/tests/expectations/tests/template-param-usage-6.rs +++ b/tests/expectations/tests/template-param-usage-6.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct DoesNotUseTemplateParameter { - pub x: ::std::os::raw::c_int, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct DoesNotUseTemplateParameter { + pub x: ::std::os::raw::c_int, + } + pub type DoesNotUseTemplateParameter_ButAliasDoesUseIt = T; } -pub type DoesNotUseTemplateParameter_ButAliasDoesUseIt = T; diff --git a/tests/expectations/tests/template-param-usage-7.rs b/tests/expectations/tests/template-param-usage-7.rs index 2544ffd047..87d12bb629 100644 --- a/tests/expectations/tests/template-param-usage-7.rs +++ b/tests/expectations/tests/template-param-usage-7.rs @@ -1,16 +1,20 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct DoesNotUseU { - pub t: T, - pub v: V, -} -impl Default for DoesNotUseU { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct DoesNotUseU { + pub t: T, + pub v: V, + } + impl Default for DoesNotUseU { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type Alias = + DoesNotUseU<::std::os::raw::c_int, ::std::os::raw::c_char>; } -pub type Alias = DoesNotUseU<::std::os::raw::c_int, ::std::os::raw::c_char>; diff --git a/tests/expectations/tests/template-param-usage-8.rs b/tests/expectations/tests/template-param-usage-8.rs index b181cc0911..7e26c038e1 100644 --- a/tests/expectations/tests/template-param-usage-8.rs +++ b/tests/expectations/tests/template-param-usage-8.rs @@ -1,17 +1,20 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct IndirectUsage { - pub member1: IndirectUsage_Typedefed, - pub member2: IndirectUsage_Aliased, -} -pub type IndirectUsage_Typedefed = T; -pub type IndirectUsage_Aliased = U; -impl Default for IndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct IndirectUsage { + pub member1: IndirectUsage_Typedefed, + pub member2: IndirectUsage_Aliased, + } + 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 d0a3f29f6a..d3aeab6f8d 100644 --- a/tests/expectations/tests/template-param-usage-9.rs +++ b/tests/expectations/tests/template-param-usage-9.rs @@ -1,22 +1,25 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[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)] -#[derive(Debug, Copy, Clone)] -pub struct DoesNotUse_IndirectUsage { - pub member: DoesNotUse_Aliased, - pub another: DoesNotUse_Typedefed, -} -impl Default for DoesNotUse_IndirectUsage { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[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)] + #[derive(Debug, Copy, Clone)] + pub struct DoesNotUse_IndirectUsage { + pub member: DoesNotUse_Aliased, + pub another: DoesNotUse_Typedefed, + } + impl Default for DoesNotUse_IndirectUsage { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 911b0e6ae1..f4950d253b 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -1,267 +1,273 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug)] -pub struct Foo { - pub m_member: T, - pub m_member_ptr: *mut T, - pub m_member_arr: [T; 1usize], -} -impl Default for Foo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -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)] -pub struct D_U { - pub m_nested_foo: D_MyFoo, - pub m_baz: Z, -} -impl Default for D_U { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for D { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub prev: *mut T, - pub next: *mut Rooted<*mut ::std::os::raw::c_void>, - pub ptr: T, -} -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct RootedContainer { - pub root: Rooted<*mut ::std::os::raw::c_void>, -} -#[test] -fn bindgen_test_layout_RootedContainer() { - assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( - "Size of: " , stringify ! ( RootedContainer ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! - ( "Alignment of " , stringify ! ( RootedContainer ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const RootedContainer ) ) . root as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( RootedContainer ) , - "::" , stringify ! ( root ) )); -} -impl Clone for RootedContainer { - fn clone(&self) -> Self { *self } -} -impl Default for RootedContainer { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug)] -pub struct WithDtor { - pub member: T, -} -impl Default for WithDtor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>; -#[repr(C)] -#[derive(Debug)] -pub struct PODButContainsDtor { - pub member: WithDtorIntFwd, -} -#[test] -fn bindgen_test_layout_PODButContainsDtor() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( PODButContainsDtor ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( PODButContainsDtor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const PODButContainsDtor ) ) . member as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( PODButContainsDtor ) , - "::" , stringify ! ( member ) )); -} -impl Default for PODButContainsDtor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/**
*/ -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Opaque { -} -impl Default for Opaque { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct POD { - pub opaque_member: u32, -} -#[test] -fn bindgen_test_layout_POD() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( POD ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( POD ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const POD ) ) . opaque_member as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( POD ) , "::" , - stringify ! ( opaque_member ) )); -} -impl Clone for POD { - fn clone(&self) -> Self { *self } -} -/** +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug)] + pub struct Foo { + pub m_member: T, + pub m_member_ptr: *mut T, + pub m_member_arr: [T; 1usize], + } + impl Default for Foo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + 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)] + pub struct D_U { + pub m_nested_foo: D_MyFoo, + pub m_baz: Z, + } + impl Default for D_U { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl Default for D { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub prev: *mut T, + pub next: *mut Rooted<*mut ::std::os::raw::c_void>, + pub ptr: T, + } + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct RootedContainer { + pub root: Rooted<*mut ::std::os::raw::c_void>, + } + #[test] + fn bindgen_test_layout_RootedContainer() { + assert_eq!(::std::mem::size_of::() , 24usize , concat + ! ( "Size of: " , stringify ! ( RootedContainer ) )); + assert_eq! (::std::mem::align_of::() , 8usize , + concat ! ( + "Alignment of " , stringify ! ( RootedContainer ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const RootedContainer ) ) . root as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( RootedContainer ) , + "::" , stringify ! ( root ) )); + } + impl Clone for RootedContainer { + fn clone(&self) -> Self { *self } + } + impl Default for RootedContainer { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug)] + pub struct WithDtor { + pub member: T, + } + impl Default for WithDtor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>; + #[repr(C)] + #[derive(Debug)] + pub struct PODButContainsDtor { + pub member: WithDtorIntFwd, + } + #[test] + fn bindgen_test_layout_PODButContainsDtor() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( PODButContainsDtor ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( PODButContainsDtor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const PODButContainsDtor ) ) . member as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( PODButContainsDtor + ) , "::" , stringify ! ( member ) )); + } + impl Default for PODButContainsDtor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /**
*/ + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Opaque { + } + impl Default for Opaque { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct POD { + pub opaque_member: u32, + } + #[test] + fn bindgen_test_layout_POD() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( POD ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( POD ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const POD ) ) . opaque_member as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( POD ) , "::" , + stringify ! ( opaque_member ) )); + } + impl Clone for POD { + fn clone(&self) -> Self { *self } + } + /** *
*/ -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NestedReplaced { - pub buff: *mut T, -} -impl Default for NestedReplaced { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NestedBase { - pub buff: *mut T, -} -impl Default for NestedBase { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Incomplete { - pub d: T, -} -impl Default for Incomplete { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NestedContainer { - pub c: T, - pub nested: NestedReplaced, - pub inc: Incomplete, -} -impl Default for NestedContainer { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Untemplated { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Untemplated() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( Untemplated ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Untemplated ) )); -} -impl Clone for Untemplated { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Templated { - pub m_untemplated: Untemplated, -} -/** + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct NestedReplaced { + pub buff: *mut T, + } + impl Default for NestedReplaced { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct NestedBase { + pub buff: *mut T, + } + impl Default for NestedBase { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Incomplete { + pub d: T, + } + impl Default for Incomplete { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct NestedContainer { + pub c: T, + pub nested: NestedReplaced, + pub inc: Incomplete, + } + impl Default for NestedContainer { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Untemplated { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Untemplated() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( Untemplated ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! + ( "Alignment of " , stringify ! ( Untemplated ) )); + } + impl Clone for Untemplated { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Templated { + pub m_untemplated: Untemplated, + } + /** * If the replacement doesn't happen at the parse level the container would be * copy and the replacement wouldn't, so this wouldn't compile. * *
*/ -#[repr(C)] -#[derive(Debug)] -pub struct ReplacedWithoutDestructor { - pub buff: *mut T, -} -impl Default for ReplacedWithoutDestructor { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug)] -pub struct ShouldNotBeCopiable { - pub m_member: ReplacedWithoutDestructor, -} -impl Default for ShouldNotBeCopiable { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug)] -pub struct ShouldNotBeCopiableAsWell { - pub m_member: ReplacedWithoutDestructorFwd, -} -impl Default for ShouldNotBeCopiableAsWell { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -/** + #[repr(C)] + #[derive(Debug)] + pub struct ReplacedWithoutDestructor { + pub buff: *mut T, + } + impl Default for ReplacedWithoutDestructor { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug)] + pub struct ShouldNotBeCopiable { + pub m_member: ReplacedWithoutDestructor, + } + impl Default for ShouldNotBeCopiable { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug)] + pub struct ShouldNotBeCopiableAsWell { + pub m_member: ReplacedWithoutDestructorFwd, + } + impl Default for ShouldNotBeCopiableAsWell { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + /** * If the replacement doesn't happen at the parse level the container would be * copy and the replacement wouldn't, so this wouldn't compile. * *
*/ -#[repr(C)] -#[derive(Debug)] -pub struct ReplacedWithoutDestructorFwd { - pub buff: *mut T, -} -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_95() { - assert_eq!(::std::mem::size_of::>() , 24usize , - concat ! ( - "Size of template specialization: " , stringify ! ( - Foo<::std::os::raw::c_int> ) )); - assert_eq!(::std::mem::align_of::>() , 8usize , - concat ! ( - "Alignment of template specialization: " , stringify ! ( - Foo<::std::os::raw::c_int> ) )); -} -#[test] -fn __bindgen_test_layout_Rooted_instantiation_106() { - 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_WithDtor_instantiation_114() { - assert_eq!(::std::mem::size_of::>() , - 4usize , concat ! ( - "Size of template specialization: " , stringify ! ( - WithDtor<::std::os::raw::c_int> ) )); - assert_eq!(::std::mem::align_of::>() , - 4usize , concat ! ( - "Alignment of template specialization: " , stringify ! ( - WithDtor<::std::os::raw::c_int> ) )); + #[repr(C)] + #[derive(Debug)] + pub struct ReplacedWithoutDestructorFwd { + pub buff: *mut T, + } + 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_96() { + assert_eq!(::std::mem::size_of::>() , + 24usize , concat ! ( + "Size of template specialization: " , stringify ! ( + Foo<::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::>() , + 8usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + Foo<::std::os::raw::c_int> ) )); + } + #[test] + fn __bindgen_test_layout_Rooted_instantiation_107() { + 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_WithDtor_instantiation_115() { + assert_eq!(::std::mem::size_of::>() , + 4usize , concat ! ( + "Size of template specialization: " , stringify ! ( + WithDtor<::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::>() , + 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + WithDtor<::std::os::raw::c_int> ) )); + } } diff --git a/tests/expectations/tests/template_alias.rs b/tests/expectations/tests/template_alias.rs index 44f7830f66..30665099dc 100644 --- a/tests/expectations/tests/template_alias.rs +++ b/tests/expectations/tests/template_alias.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type JS_detail_Wrapped = T; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct JS_Rooted { - pub ptr: JS_detail_Wrapped, -} -impl Default for JS_Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type JS_detail_Wrapped = T; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct JS_Rooted { + pub ptr: JS_detail_Wrapped, + } + impl Default for JS_Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/template_alias_basic.rs b/tests/expectations/tests/template_alias_basic.rs index 656fff336d..b1142e7a79 100644 --- a/tests/expectations/tests/template_alias_basic.rs +++ b/tests/expectations/tests/template_alias_basic.rs @@ -1,7 +1,10 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type Wrapped = T; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type Wrapped = T; +} diff --git a/tests/expectations/tests/template_alias_namespace.rs b/tests/expectations/tests/template_alias_namespace.rs index 90740a2d6f..1d25b0f510 100644 --- a/tests/expectations/tests/template_alias_namespace.rs +++ b/tests/expectations/tests/template_alias_namespace.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/template_partial_specification.rs b/tests/expectations/tests/template_partial_specification.rs index b4b7b2bcee..6e573b6a56 100644 --- a/tests/expectations/tests/template_partial_specification.rs +++ b/tests/expectations/tests/template_partial_specification.rs @@ -1,7 +1,9 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - - +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; +} diff --git a/tests/expectations/tests/template_typedef_transitive_param.rs b/tests/expectations/tests/template_typedef_transitive_param.rs index 265ab5ce1f..008fba9a48 100644 --- a/tests/expectations/tests/template_typedef_transitive_param.rs +++ b/tests/expectations/tests/template_typedef_transitive_param.rs @@ -1,20 +1,23 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Wrapper { - pub _address: u8, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Wrapper_Wrapped { - pub t: T, -} -impl Default for Wrapper_Wrapped { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct Wrapper { + pub _address: u8, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Wrapper_Wrapped { + pub t: T, + } + impl Default for Wrapper_Wrapped { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type Wrapper_Type = Wrapper_Wrapped; } -pub type Wrapper_Type = Wrapper_Wrapped; diff --git a/tests/expectations/tests/template_typedefs.rs b/tests/expectations/tests/template_typedefs.rs index c987bf8e05..8bd3ce3ec5 100644 --- a/tests/expectations/tests/template_typedefs.rs +++ b/tests/expectations/tests/template_typedefs.rs @@ -1,20 +1,24 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type foo = - ::std::option::Option; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct Foo { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + 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 = + ::std::option::Option bool>; } -pub type Foo_Char = T; -pub type Foo_FooPtrTypedef = *mut Foo_Char; -pub type Foo_nsCOMArrayEnumFunc = - ::std::option::Option bool>; diff --git a/tests/expectations/tests/templateref_opaque.rs b/tests/expectations/tests/templateref_opaque.rs index 89808f3010..1a7f414722 100644 --- a/tests/expectations/tests/templateref_opaque.rs +++ b/tests/expectations/tests/templateref_opaque.rs @@ -1,18 +1,21 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct detail_PointerType { - pub _address: u8, -} -pub type detail_PointerType_Type = *mut T; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct UniquePtr { - pub _address: u8, +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct detail_PointerType { + pub _address: u8, + } + pub type detail_PointerType_Type = *mut T; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct UniquePtr { + pub _address: u8, + } + pub type UniquePtr_Pointer = detail_PointerType; } -pub type UniquePtr_Pointer = detail_PointerType; diff --git a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs index 67381d41eb..52b0bdd6e4 100644 --- a/tests/expectations/tests/type-referenced-by-whitelisted-function.rs +++ b/tests/expectations/tests/type-referenced-by-whitelisted-function.rs @@ -1,29 +1,33 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct dl_phdr_info { - pub x: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_dl_phdr_info() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( dl_phdr_info ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( dl_phdr_info ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const dl_phdr_info ) ) . x as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( dl_phdr_info ) , "::" , - stringify ! ( x ) )); -} -impl Clone for dl_phdr_info { - fn clone(&self) -> Self { *self } -} -extern "C" { - pub fn dl_iterate_phdr(arg1: *mut dl_phdr_info) -> ::std::os::raw::c_int; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct dl_phdr_info { + pub x: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_dl_phdr_info() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( dl_phdr_info ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( dl_phdr_info ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const dl_phdr_info ) ) . x as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( dl_phdr_info ) , + "::" , stringify ! ( x ) )); + } + impl Clone for dl_phdr_info { + fn clone(&self) -> Self { *self } + } + extern "C" { + pub fn dl_iterate_phdr(arg1: *mut dl_phdr_info) + -> ::std::os::raw::c_int; + } } diff --git a/tests/expectations/tests/type_alias_empty.rs b/tests/expectations/tests/type_alias_empty.rs index c455b8aeaa..e3f666dbd0 100644 --- a/tests/expectations/tests/type_alias_empty.rs +++ b/tests/expectations/tests/type_alias_empty.rs @@ -1,7 +1,10 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type bool_constant = u8; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type bool_constant = u8; +} diff --git a/tests/expectations/tests/type_alias_partial_template_especialization.rs b/tests/expectations/tests/type_alias_partial_template_especialization.rs index 2e0f2f4d6c..aa6e079d03 100644 --- a/tests/expectations/tests/type_alias_partial_template_especialization.rs +++ b/tests/expectations/tests/type_alias_partial_template_especialization.rs @@ -1,15 +1,18 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -pub type MaybeWrapped
= A; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Rooted { - pub ptr: MaybeWrapped, -} -impl Default for Rooted { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type MaybeWrapped = A; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Rooted { + pub ptr: MaybeWrapped, + } + impl Default for Rooted { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/type_alias_template_specialized.rs b/tests/expectations/tests/type_alias_template_specialized.rs index 20665af67d..09bb2c3685 100644 --- a/tests/expectations/tests/type_alias_template_specialized.rs +++ b/tests/expectations/tests/type_alias_template_specialized.rs @@ -1,28 +1,31 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Rooted { - pub ptr: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Rooted() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Rooted ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Rooted ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Rooted ) ) . ptr as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Rooted ) , "::" , - stringify ! ( ptr ) )); -} -impl Clone for Rooted { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Rooted { + pub ptr: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_Rooted() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Rooted ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Rooted ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Rooted ) ) . ptr as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Rooted ) , "::" , + stringify ! ( ptr ) )); + } + impl Clone for Rooted { + fn clone(&self) -> Self { *self } + } + ///
+ pub type MaybeWrapped
= a; } -///
-pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/typedefd-array-as-function-arg.rs b/tests/expectations/tests/typedefd-array-as-function-arg.rs index 56074f75e5..11ce02f07f 100644 --- a/tests/expectations/tests/typedefd-array-as-function-arg.rs +++ b/tests/expectations/tests/typedefd-array-as-function-arg.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub type myVector3 = [f32; 3usize]; -extern "C" { - pub fn modifyVectorFunc(v: *mut f32); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub type myVector3 = [f32; 3usize]; + extern "C" { + pub fn modifyVectorFunc(v: *mut f32); + } } diff --git a/tests/expectations/tests/typeref.rs b/tests/expectations/tests/typeref.rs index c9982b6706..5a41a57e02 100644 --- a/tests/expectations/tests/typeref.rs +++ b/tests/expectations/tests/typeref.rs @@ -1,125 +1,135 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct nsFoo { + pub mBar: mozilla_StyleShapeSource, + } + #[test] + fn bindgen_test_layout_nsFoo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsFoo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( nsFoo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsFoo ) , "::" , + stringify ! ( mBar ) )); + } + impl Clone for nsFoo { + fn clone(&self) -> Self { *self } + } + impl Default for nsFoo { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct mozilla_FragmentOrURL { + pub mIsLocalRef: bool, + } + #[test] + fn bindgen_test_layout_mozilla_FragmentOrURL() { + assert_eq!(::std::mem::size_of::() , 1usize , + concat ! ( + "Size of: " , stringify ! ( mozilla_FragmentOrURL ) )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( mozilla_FragmentOrURL ) + )); + assert_eq! (unsafe { + & ( * ( 0 as * const mozilla_FragmentOrURL ) ) . + mIsLocalRef as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + mozilla_FragmentOrURL ) , "::" , stringify ! ( mIsLocalRef + ) )); + } + impl Clone for mozilla_FragmentOrURL { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct mozilla_Position { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_mozilla_Position() { + assert_eq!(::std::mem::size_of::() , 1usize , concat + ! ( "Size of: " , stringify ! ( mozilla_Position ) )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( mozilla_Position ) )); + } + impl Clone for mozilla_Position { + fn clone(&self) -> Self { *self } + } + #[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, Copy)] + pub struct Bar { + pub mFoo: *mut nsFoo, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . mFoo as * const _ as usize + } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Bar ) , "::" , + stringify ! ( mFoo ) )); + } + impl Clone for Bar { + fn clone(&self) -> Self { *self } + } + impl Default for Bar { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct nsFoo { - pub mBar: mozilla_StyleShapeSource, -} -#[test] -fn bindgen_test_layout_nsFoo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsFoo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsFoo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsFoo ) ) . mBar as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsFoo ) , "::" , - stringify ! ( mBar ) )); -} -impl Clone for nsFoo { - fn clone(&self) -> Self { *self } -} -impl Default for nsFoo { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct mozilla_FragmentOrURL { - pub mIsLocalRef: bool, -} -#[test] -fn bindgen_test_layout_mozilla_FragmentOrURL() { - assert_eq!(::std::mem::size_of::() , 1usize , - concat ! ( "Size of: " , stringify ! ( mozilla_FragmentOrURL ) - )); - assert_eq! (::std::mem::align_of::() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( mozilla_FragmentOrURL ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const mozilla_FragmentOrURL ) ) . mIsLocalRef - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( mozilla_FragmentOrURL ) - , "::" , stringify ! ( mIsLocalRef ) )); -} -impl Clone for mozilla_FragmentOrURL { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct mozilla_Position { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_mozilla_Position() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( mozilla_Position ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! - ( "Alignment of " , stringify ! ( mozilla_Position ) )); -} -impl Clone for mozilla_Position { - fn clone(&self) -> Self { *self } -} -#[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, Copy)] -pub struct Bar { - pub mFoo: *mut nsFoo, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . mFoo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Bar ) , "::" , - stringify ! ( mFoo ) )); -} -impl Clone for Bar { - fn clone(&self) -> Self { *self } -} -impl Default for Bar { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/union-in-ns.rs b/tests/expectations/tests/union-in-ns.rs index e5aeb3688b..6060bc9d81 100644 --- a/tests/expectations/tests/union-in-ns.rs +++ b/tests/expectations/tests/union-in-ns.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[repr(C)] diff --git a/tests/expectations/tests/union_dtor.rs b/tests/expectations/tests/union_dtor.rs index 61fb0380f7..440bd5512a 100644 --- a/tests/expectations/tests/union_dtor.rs +++ b/tests/expectations/tests/union_dtor.rs @@ -1,64 +1,72 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct UnionWithDtor { - pub mFoo: __BindgenUnionField<::std::os::raw::c_int>, - pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout_UnionWithDtor() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( UnionWithDtor ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( UnionWithDtor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UnionWithDtor ) ) . mFoo as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( UnionWithDtor ) , "::" - , stringify ! ( mFoo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const UnionWithDtor ) ) . mBar as * const _ as - usize } , 0usize , concat ! ( - "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) { - UnionWithDtor_UnionWithDtor_destructor(self) + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default)] + pub struct UnionWithDtor { + pub mFoo: __BindgenUnionField<::std::os::raw::c_int>, + pub mBar: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub bindgen_union_field: u64, + } + #[test] + fn bindgen_test_layout_UnionWithDtor() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! + ( "Size of: " , stringify ! ( UnionWithDtor ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat + ! ( "Alignment of " , stringify ! ( UnionWithDtor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UnionWithDtor ) ) . mFoo as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( UnionWithDtor ) , + "::" , stringify ! ( mFoo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const UnionWithDtor ) ) . mBar as * const _ + as usize } , 0usize , concat ! ( + "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) { + UnionWithDtor_UnionWithDtor_destructor(self) + } } } diff --git a/tests/expectations/tests/union_fields.rs b/tests/expectations/tests/union_fields.rs index 8c8ef7d58e..b4f6202232 100644 --- a/tests/expectations/tests/union_fields.rs +++ b/tests/expectations/tests/union_fields.rs @@ -1,63 +1,70 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct nsStyleUnion { + pub mInt: __BindgenUnionField<::std::os::raw::c_int>, + pub mFloat: __BindgenUnionField, + pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, + pub bindgen_union_field: u64, + } + #[test] + fn bindgen_test_layout_nsStyleUnion() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsStyleUnion ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! + ( "Alignment of " , stringify ! ( nsStyleUnion ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsStyleUnion ) ) . mInt as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsStyleUnion ) , + "::" , stringify ! ( mInt ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsStyleUnion ) ) . mFloat as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsStyleUnion ) , + "::" , stringify ! ( mFloat ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const nsStyleUnion ) ) . mPointer as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( nsStyleUnion ) , + "::" , stringify ! ( mPointer ) )); + } + impl Clone for nsStyleUnion { + fn clone(&self) -> Self { *self } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct nsStyleUnion { - pub mInt: __BindgenUnionField<::std::os::raw::c_int>, - pub mFloat: __BindgenUnionField, - pub mPointer: __BindgenUnionField<*mut ::std::os::raw::c_void>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout_nsStyleUnion() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsStyleUnion ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsStyleUnion ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mInt as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mInt ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mFloat as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mFloat ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const nsStyleUnion ) ) . mPointer as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( nsStyleUnion ) , "::" , - stringify ! ( mPointer ) )); -} -impl Clone for nsStyleUnion { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/union_template.rs b/tests/expectations/tests/union_template.rs index e02f196440..63d05e4eec 100644 --- a/tests/expectations/tests/union_template.rs +++ b/tests/expectations/tests/union_template.rs @@ -1,58 +1,65 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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>, + pub bindgen_union_field: u64, + } + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct NastyStruct__bindgen_ty_2 { + pub wat: __BindgenUnionField<::std::os::raw::c_short>, + pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, + pub bindgen_union_field: u64, + } + #[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>, + pub bindgen_union_field: u64, } -} -#[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>, - pub bindgen_union_field: u64, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct NastyStruct__bindgen_ty_2 { - pub wat: __BindgenUnionField<::std::os::raw::c_short>, - pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>, - pub bindgen_union_field: u64, -} -#[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>, - pub bindgen_union_field: u64, } diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/tests/expectations/tests/union_with_anon_struct.rs index 59f8fcab79..c0bfd533bf 100644 --- a/tests/expectations/tests/union_with_anon_struct.rs +++ b/tests/expectations/tests/union_with_anon_struct.rs @@ -1,77 +1,86 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 8usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } } -} -#[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, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index de19dc9102..fbc1d46ca4 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -1,106 +1,115 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } } -} -#[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], -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -impl foo__bindgen_ty_1 { - #[inline] - pub fn b(&self) -> ::std::os::raw::c_int { - let mask = 127usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } } - #[inline] - pub fn set_b(&mut self, val: ::std::os::raw::c_int) { - let mask = 127usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } } - #[inline] - pub fn c(&self) -> ::std::os::raw::c_int { - let mask = 4294967168usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 7usize; - unsafe { ::std::mem::transmute(val as u32) } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } } - #[inline] - pub fn set_c(&mut self, val: ::std::os::raw::c_int) { - let mask = 4294967168usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 7usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + #[allow(unused_imports)] + use self::super::*; + #[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], + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + impl foo__bindgen_ty_1 { + #[inline] + pub fn b(&self) -> ::std::os::raw::c_int { + let mask = 127usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_b(&mut self, val: ::std::os::raw::c_int) { + let mask = 127usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn c(&self) -> ::std::os::raw::c_int { + let mask = 4294967168usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_c(&mut self, val: ::std::os::raw::c_int) { + let mask = 4294967168usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 7usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/union_with_anon_union.rs b/tests/expectations/tests/union_with_anon_union.rs index 9e182d218d..5b2bc88cc7 100644 --- a/tests/expectations/tests/union_with_anon_union.rs +++ b/tests/expectations/tests/union_with_anon_union.rs @@ -1,78 +1,87 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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>, + pub bindgen_union_field: u32, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } } -} -#[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>, - pub bindgen_union_field: u32, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/tests/expectations/tests/union_with_anon_unnamed_struct.rs index 4d0b639f2d..4e50453756 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_struct.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_struct.rs @@ -1,91 +1,99 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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, + pub b: ::std::os::raw::c_uchar, + pub a: ::std::os::raw::c_uchar, + } + #[test] + fn bindgen_test_layout_pixel__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( + "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); + assert_eq! (::std::mem::align_of::() , 1usize , + concat ! ( + "Alignment of " , stringify ! ( pixel__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . r as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 + ) , "::" , stringify ! ( r ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . g as * + const _ as usize } , 1usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 + ) , "::" , stringify ! ( g ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . b as * + const _ as usize } , 2usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 + ) , "::" , stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . a as * + const _ as usize } , 3usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 + ) , "::" , stringify ! ( a ) )); + } + impl Clone for pixel__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_pixel() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( pixel ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( pixel ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const pixel ) ) . rgba as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( pixel ) , "::" , + stringify ! ( rgba ) )); + } + impl Clone for pixel { + 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, -} -#[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, - pub b: ::std::os::raw::c_uchar, - pub a: ::std::os::raw::c_uchar, -} -#[test] -fn bindgen_test_layout_pixel__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat - ! ( "Size of: " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 1usize , - concat ! ( - "Alignment of " , stringify ! ( pixel__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . r as * const _ - as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( r ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . g as * const _ - as usize } , 1usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( g ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . b as * const _ - as usize } , 2usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel__bindgen_ty_1 ) ) . a as * const _ - as usize } , 3usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel__bindgen_ty_1 ) , - "::" , stringify ! ( a ) )); -} -impl Clone for pixel__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_pixel() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( pixel ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( pixel ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const pixel ) ) . rgba as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( pixel ) , "::" , - stringify ! ( rgba ) )); -} -impl Clone for pixel { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/tests/expectations/tests/union_with_anon_unnamed_union.rs index fd6f82fc5a..dfc61e3fb6 100644 --- a/tests/expectations/tests/union_with_anon_unnamed_union.rs +++ b/tests/expectations/tests/union_with_anon_unnamed_union.rs @@ -1,79 +1,88 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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>, + pub bindgen_union_field: u16, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 2usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 2usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . c as * const + _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) + , "::" , stringify ! ( c ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + } + impl Clone for foo { + 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, -} -#[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>, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 2usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1 ) ) . c as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo__bindgen_ty_1 ) , - "::" , stringify ! ( c ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/union_with_big_member.rs b/tests/expectations/tests/union_with_big_member.rs index 2b7a8eefd3..a10fb12944 100644 --- a/tests/expectations/tests/union_with_big_member.rs +++ b/tests/expectations/tests/union_with_big_member.rs @@ -1,117 +1,124 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Copy)] + pub struct WithBigArray { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, + pub bindgen_union_field: [u32; 33usize], + } + #[test] + fn bindgen_test_layout_WithBigArray() { + assert_eq!(::std::mem::size_of::() , 132usize , concat ! + ( "Size of: " , stringify ! ( WithBigArray ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! + ( "Alignment of " , stringify ! ( WithBigArray ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray ) , + "::" , stringify ! ( b ) )); + } + impl Clone for WithBigArray { + fn clone(&self) -> Self { *self } + } + impl Default for WithBigArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct WithBigArray2 { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>, + pub bindgen_union_field: [u32; 9usize], + } + #[test] + fn bindgen_test_layout_WithBigArray2() { + assert_eq!(::std::mem::size_of::() , 36usize , concat ! + ( "Size of: " , stringify ! ( WithBigArray2 ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( WithBigArray2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray2 ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray2 ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigArray2 ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigArray2 ) , + "::" , stringify ! ( b ) )); + } + impl Clone for WithBigArray2 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Copy)] + pub struct WithBigMember { + pub a: __BindgenUnionField<::std::os::raw::c_int>, + pub b: __BindgenUnionField, + pub bindgen_union_field: [u32; 33usize], + } + #[test] + fn bindgen_test_layout_WithBigMember() { + assert_eq!(::std::mem::size_of::() , 132usize , concat + ! ( "Size of: " , stringify ! ( WithBigMember ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat + ! ( "Alignment of " , stringify ! ( WithBigMember ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigMember ) ) . a as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigMember ) , + "::" , stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const WithBigMember ) ) . b as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( WithBigMember ) , + "::" , stringify ! ( b ) )); + } + impl Clone for WithBigMember { + fn clone(&self) -> Self { *self } + } + impl Default for WithBigMember { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } -} -#[repr(C)] -#[derive(Copy)] -pub struct WithBigArray { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>, - pub bindgen_union_field: [u32; 33usize], -} -#[test] -fn bindgen_test_layout_WithBigArray() { - assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray ) , "::" , - stringify ! ( b ) )); -} -impl Clone for WithBigArray { - fn clone(&self) -> Self { *self } -} -impl Default for WithBigArray { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct WithBigArray2 { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField<[::std::os::raw::c_char; 33usize]>, - pub bindgen_union_field: [u32; 9usize], -} -#[test] -fn bindgen_test_layout_WithBigArray2() { - assert_eq!(::std::mem::size_of::() , 36usize , concat ! ( - "Size of: " , stringify ! ( WithBigArray2 ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigArray2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray2 ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" - , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigArray2 ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigArray2 ) , "::" - , stringify ! ( b ) )); -} -impl Clone for WithBigArray2 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Copy)] -pub struct WithBigMember { - pub a: __BindgenUnionField<::std::os::raw::c_int>, - pub b: __BindgenUnionField, - pub bindgen_union_field: [u32; 33usize], -} -#[test] -fn bindgen_test_layout_WithBigMember() { - assert_eq!(::std::mem::size_of::() , 132usize , concat ! ( - "Size of: " , stringify ! ( WithBigMember ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( WithBigMember ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigMember ) ) . a as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigMember ) , "::" - , stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const WithBigMember ) ) . b as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( WithBigMember ) , "::" - , stringify ! ( b ) )); -} -impl Clone for WithBigMember { - fn clone(&self) -> Self { *self } -} -impl Default for WithBigMember { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } } diff --git a/tests/expectations/tests/union_with_nesting.rs b/tests/expectations/tests/union_with_nesting.rs index d92e8efae2..0bfe43bb92 100644 --- a/tests/expectations/tests/union_with_nesting.rs +++ b/tests/expectations/tests/union_with_nesting.rs @@ -1,134 +1,143 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct __BindgenUnionField(::std::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) } -} -impl ::std::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::std::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::std::marker::Copy for __BindgenUnionField { } -impl ::std::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - fmt.write_str("__BindgenUnionField") +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::std::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } + } + impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::std::marker::Copy for __BindgenUnionField { } + impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[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>, + pub bindgen_union_field: u16, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , + 2usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 + ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . + b1 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( + b1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . + b2 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( + b2 ) )); + } + impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct foo__bindgen_ty_1__bindgen_ty_2 { + pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, + pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, + pub bindgen_union_field: u16, + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { + assert_eq!(::std::mem::size_of::() , + 2usize , concat ! ( + "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 + ) )); + assert_eq! (::std::mem::align_of::() + , 2usize , concat ! ( + "Alignment of " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . + c1 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + c1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . + c2 as * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( + foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( + c2 ) )); + } + impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::() , 4usize , + concat ! ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::() , 2usize , + concat ! ( + "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); + } + impl Clone for foo__bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + } + impl Clone for foo { + 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, -} -#[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>, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_1 ) - )); - assert_eq! (::std::mem::align_of::() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_1 ) ) . b2 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_1 ) , "::" , stringify ! ( b2 ) - )); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo__bindgen_ty_1__bindgen_ty_2 { - pub c1: __BindgenUnionField<::std::os::raw::c_ushort>, - pub c2: __BindgenUnionField<::std::os::raw::c_ushort>, - pub bindgen_union_field: u16, -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1__bindgen_ty_2() { - assert_eq!(::std::mem::size_of::() , - 2usize , concat ! ( - "Size of: " , stringify ! ( foo__bindgen_ty_1__bindgen_ty_2 ) - )); - assert_eq! (::std::mem::align_of::() , - 2usize , concat ! ( - "Alignment of " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c1 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c1 ) - )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo__bindgen_ty_1__bindgen_ty_2 ) ) . c2 - as * const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( - foo__bindgen_ty_1__bindgen_ty_2 ) , "::" , stringify ! ( c2 ) - )); -} -impl Clone for foo__bindgen_ty_1__bindgen_ty_2 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo__bindgen_ty_1() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! - ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) )); - assert_eq! (::std::mem::align_of::() , 2usize , concat - ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) )); -} -impl Clone for foo__bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/unknown_attr.rs b/tests/expectations/tests/unknown_attr.rs index 23d9ff7519..6d70044abf 100644 --- a/tests/expectations/tests/unknown_attr.rs +++ b/tests/expectations/tests/unknown_attr.rs @@ -1,34 +1,37 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: ::std::os::raw::c_longlong, - pub __bindgen_padding_1: u64, -} -#[test] -fn bindgen_test_layout_max_align_t() { - assert_eq!(::std::mem::size_of::() , 32usize , concat ! ( - "Size of: " , stringify ! ( max_align_t ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const max_align_t ) ) . - __clang_max_align_nonce1 as * const _ as usize } , 0usize , - concat ! ( - "Alignment of field: " , stringify ! ( max_align_t ) , "::" , - stringify ! ( __clang_max_align_nonce1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const max_align_t ) ) . - __clang_max_align_nonce2 as * const _ as usize } , 16usize , - concat ! ( - "Alignment of field: " , stringify ! ( max_align_t ) , "::" , - stringify ! ( __clang_max_align_nonce2 ) )); -} -impl Clone for max_align_t { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct max_align_t { + pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, + pub __bindgen_padding_0: u64, + pub __clang_max_align_nonce2: ::std::os::raw::c_longlong, + pub __bindgen_padding_1: u64, + } + #[test] + fn bindgen_test_layout_max_align_t() { + assert_eq!(::std::mem::size_of::() , 32usize , concat ! ( + "Size of: " , stringify ! ( max_align_t ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const max_align_t ) ) . + __clang_max_align_nonce1 as * const _ as usize } , 0usize + , concat ! ( + "Alignment of field: " , stringify ! ( max_align_t ) , + "::" , stringify ! ( __clang_max_align_nonce1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const max_align_t ) ) . + __clang_max_align_nonce2 as * const _ as usize } , 16usize + , concat ! ( + "Alignment of field: " , stringify ! ( max_align_t ) , + "::" , stringify ! ( __clang_max_align_nonce2 ) )); + } + impl Clone for max_align_t { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/use-core.rs b/tests/expectations/tests/use-core.rs index c2996f74d5..b53d15dcff 100644 --- a/tests/expectations/tests/use-core.rs +++ b/tests/expectations/tests/use-core.rs @@ -1,99 +1,109 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - extern crate core; -#[repr(C)] -pub struct __BindgenUnionField(::core::marker::PhantomData); -impl __BindgenUnionField { - #[inline] - pub fn new() -> Self { __BindgenUnionField(::core::marker::PhantomData) } - #[inline] - pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } - #[inline] - pub unsafe fn as_mut(&mut self) -> &mut T { ::core::mem::transmute(self) } -} -impl ::core::default::Default for __BindgenUnionField { - #[inline] - fn default() -> Self { Self::new() } -} -impl ::core::clone::Clone for __BindgenUnionField { - #[inline] - fn clone(&self) -> Self { Self::new() } -} -impl ::core::marker::Copy for __BindgenUnionField { } -impl ::core::fmt::Debug for __BindgenUnionField { - fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - fmt.write_str("__BindgenUnionField") +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[repr(C)] + pub struct __BindgenUnionField(::core::marker::PhantomData); + impl __BindgenUnionField { + #[inline] + pub fn new() -> Self { + __BindgenUnionField(::core::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::core::mem::transmute(self) + } } + impl ::core::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { Self::new() } + } + impl ::core::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { Self::new() } + } + impl ::core::marker::Copy for __BindgenUnionField { } + impl ::core::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter) + -> ::core::fmt::Result { + fmt.write_str("__BindgenUnionField") + } + } + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct foo { + pub a: ::std::os::raw::c_int, + pub b: ::std::os::raw::c_int, + pub bar: *mut ::std::os::raw::c_void, + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::core::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::core::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( a ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , + 4usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( b ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } + , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } + impl Default for foo { + fn default() -> Self { unsafe { ::core::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct _bindgen_ty_1 { + pub bar: __BindgenUnionField<::std::os::raw::c_int>, + pub baz: __BindgenUnionField<::std::os::raw::c_long>, + pub bindgen_union_field: u64, + } + #[test] + fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::core::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! + ( "Size of: " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (::core::mem::align_of::<_bindgen_ty_1>() , 8usize , concat + ! ( "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , + "::" , stringify ! ( bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ + as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , + "::" , stringify ! ( baz ) )); + } + impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + extern "C" { + #[link_name = "bazz"] + pub static mut bazz: _bindgen_ty_1; + } + pub type fooFunction = + ::core::option::Option; } -#[repr(C)] -#[derive(Debug, Copy)] -pub struct foo { - pub a: ::std::os::raw::c_int, - pub b: ::std::os::raw::c_int, - pub bar: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::core::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::core::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . a as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( a ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . b as * const _ as usize } , - 4usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( b ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( bar ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } -} -impl Default for foo { - fn default() -> Self { unsafe { ::core::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct _bindgen_ty_1 { - pub bar: __BindgenUnionField<::std::os::raw::c_int>, - pub baz: __BindgenUnionField<::std::os::raw::c_long>, - pub bindgen_union_field: u64, -} -#[test] -fn bindgen_test_layout__bindgen_ty_1() { - assert_eq!(::core::mem::size_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Size of: " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (::core::mem::align_of::<_bindgen_ty_1>() , 8usize , concat ! ( - "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . bar as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const _bindgen_ty_1 ) ) . baz as * const _ as - usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) , "::" - , stringify ! ( baz ) )); -} -impl Clone for _bindgen_ty_1 { - fn clone(&self) -> Self { *self } -} -extern "C" { - #[link_name = "bazz"] - pub static mut bazz: _bindgen_ty_1; -} -pub type fooFunction = - ::core::option::Option; diff --git a/tests/expectations/tests/using.rs b/tests/expectations/tests/using.rs index 1638287ab6..f9b265f75a 100644 --- a/tests/expectations/tests/using.rs +++ b/tests/expectations/tests/using.rs @@ -1,17 +1,20 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Point { - pub x: T, - pub y: T, -} -impl Default for Point { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct Point { + pub x: T, + pub y: T, + } + impl Default for Point { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type IntPoint2D = Point<::std::os::raw::c_int>; + pub type IntVec2D = Point<::std::os::raw::c_int>; } -pub type IntPoint2D = Point<::std::os::raw::c_int>; -pub type IntVec2D = Point<::std::os::raw::c_int>; diff --git a/tests/expectations/tests/var-tracing.rs b/tests/expectations/tests/var-tracing.rs index ba10cf2285..8950ef98bb 100644 --- a/tests/expectations/tests/var-tracing.rs +++ b/tests/expectations/tests/var-tracing.rs @@ -1,57 +1,60 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Bar { - pub m_baz: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( Bar ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Bar ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Bar ) ) . m_baz as * const _ as usize } , - 0usize , concat ! ( - "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 } -} -impl Bar { - #[inline] - pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self { - let mut __bindgen_tmp = ::std::mem::uninitialized(); - Bar_Bar(&mut __bindgen_tmp, baz); - __bindgen_tmp +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub m_baz: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( Bar ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Bar ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Bar ) ) . m_baz as * const _ as usize + } , 0usize , concat ! ( + "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 } + } + impl Bar { + #[inline] + pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self { + let mut __bindgen_tmp = ::std::mem::uninitialized(); + Bar_Bar(&mut __bindgen_tmp, baz); + __bindgen_tmp + } + } + #[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 ! ( + "Size of: " , stringify ! ( Baz ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( + "Alignment of " , stringify ! ( Baz ) )); + } + impl Clone for Baz { + fn clone(&self) -> Self { *self } } -} -#[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 ! ( - "Size of: " , stringify ! ( Baz ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( Baz ) )); -} -impl Clone for Baz { - fn clone(&self) -> Self { *self } } diff --git a/tests/expectations/tests/variadic-method.rs b/tests/expectations/tests/variadic-method.rs index 542e1e75b4..942ee8779d 100644 --- a/tests/expectations/tests/variadic-method.rs +++ b/tests/expectations/tests/variadic-method.rs @@ -1,29 +1,33 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -extern "C" { - #[link_name = "_Z3fooPKcz"] - pub fn foo(fmt: *const ::std::os::raw::c_char, ...); -} -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct Bar { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_Bar() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( 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 } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + #[link_name = "_Z3fooPKcz"] + pub fn foo(fmt: *const ::std::os::raw::c_char, ...); + } + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct Bar { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Bar() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( 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/variadic_template_function.rs b/tests/expectations/tests/variadic_template_function.rs index 66fd73ed52..81f52518a4 100644 --- a/tests/expectations/tests/variadic_template_function.rs +++ b/tests/expectations/tests/variadic_template_function.rs @@ -1,11 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct VariadicFunctionObject { - pub _address: u8, +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct VariadicFunctionObject { + pub _address: u8, + } } diff --git a/tests/expectations/tests/vector.rs b/tests/expectations/tests/vector.rs index 31bc8fd7a0..bc1da0e339 100644 --- a/tests/expectations/tests/vector.rs +++ b/tests/expectations/tests/vector.rs @@ -1,26 +1,29 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct foo { - pub mMember: [::std::os::raw::c_longlong; 1usize], -} -#[test] -fn bindgen_test_layout_foo() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( foo ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( foo ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const foo ) ) . mMember as * const _ as usize } - , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( foo ) , "::" , - stringify ! ( mMember ) )); -} -impl Clone for foo { - fn clone(&self) -> Self { *self } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct foo { + pub mMember: [::std::os::raw::c_longlong; 1usize], + } + #[test] + fn bindgen_test_layout_foo() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( foo ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( foo ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const foo ) ) . mMember as * const _ as + usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( foo ) , "::" , + stringify ! ( mMember ) )); + } + impl Clone for foo { + fn clone(&self) -> Self { *self } + } } diff --git a/tests/expectations/tests/virtual_dtor.rs b/tests/expectations/tests/virtual_dtor.rs index e5d3ace2fc..a4779c4fd0 100644 --- a/tests/expectations/tests/virtual_dtor.rs +++ b/tests/expectations/tests/virtual_dtor.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct nsSlots__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug)] -pub struct nsSlots { - pub vtable_: *const nsSlots__bindgen_vtable, -} -#[test] -fn bindgen_test_layout_nsSlots() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( nsSlots ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( nsSlots ) )); -} -impl Default for nsSlots { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + pub struct nsSlots__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug)] + pub struct nsSlots { + pub vtable_: *const nsSlots__bindgen_vtable, + } + #[test] + fn bindgen_test_layout_nsSlots() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( nsSlots ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( nsSlots ) )); + } + impl Default for nsSlots { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/virtual_inheritance.rs b/tests/expectations/tests/virtual_inheritance.rs index b3119ca7ad..d5854289b7 100644 --- a/tests/expectations/tests/virtual_inheritance.rs +++ b/tests/expectations/tests/virtual_inheritance.rs @@ -1,98 +1,101 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct A { - pub foo: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_A() { - assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( - "Size of: " , stringify ! ( A ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( A ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , - 0usize , concat ! ( - "Alignment of field: " , stringify ! ( A ) , "::" , stringify - ! ( foo ) )); -} -impl Clone for A { - fn clone(&self) -> Self { *self } -} -#[repr(C)] -pub struct B__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct B { - pub vtable_: *const B__bindgen_vtable, - pub bar: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_B() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( B ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( B ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const B ) ) . bar as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( B ) , "::" , stringify - ! ( bar ) )); -} -impl Clone for B { - fn clone(&self) -> Self { *self } -} -impl Default for B { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -pub struct C__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct C { - pub vtable_: *const C__bindgen_vtable, - pub baz: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const C ) ) . baz as * const _ as usize } , - 8usize , concat ! ( - "Alignment of field: " , stringify ! ( C ) , "::" , stringify - ! ( baz ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct D { - pub _base: C, - pub _base_1: B, - pub bazz: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_D() { - assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( - "Size of: " , stringify ! ( D ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( D ) )); -} -impl Clone for D { - fn clone(&self) -> Self { *self } -} -impl Default for D { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct A { + pub foo: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_A() { + assert_eq!(::std::mem::size_of::() , 4usize , concat ! ( + "Size of: " , stringify ! ( A ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( A ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const A ) ) . foo as * const _ as usize } , + 0usize , concat ! ( + "Alignment of field: " , stringify ! ( A ) , "::" , + stringify ! ( foo ) )); + } + impl Clone for A { + fn clone(&self) -> Self { *self } + } + #[repr(C)] + pub struct B__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct B { + pub vtable_: *const B__bindgen_vtable, + pub bar: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_B() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( B ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( B ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const B ) ) . bar as * const _ as usize } , + 8usize , concat ! ( + "Alignment of field: " , stringify ! ( B ) , "::" , + stringify ! ( bar ) )); + } + impl Clone for B { + fn clone(&self) -> Self { *self } + } + impl Default for B { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + pub struct C__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct C { + pub vtable_: *const C__bindgen_vtable, + pub baz: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 16usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const C ) ) . baz as * const _ as usize } , + 8usize , concat ! ( + "Alignment of field: " , stringify ! ( C ) , "::" , + stringify ! ( baz ) )); + } + impl Clone for C { + fn clone(&self) -> Self { *self } + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Debug, Copy)] + pub struct D { + pub _base: C, + pub _base_1: B, + pub bazz: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_D() { + assert_eq!(::std::mem::size_of::() , 40usize , concat ! ( + "Size of: " , stringify ! ( D ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( D ) )); + } + impl Clone for D { + fn clone(&self) -> Self { *self } + } + impl Default for D { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/virtual_overloaded.rs b/tests/expectations/tests/virtual_overloaded.rs index 625abe3bde..4de1dc413c 100644 --- a/tests/expectations/tests/virtual_overloaded.rs +++ b/tests/expectations/tests/virtual_overloaded.rs @@ -1,26 +1,29 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -pub struct C__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct C { - pub vtable_: *const C__bindgen_vtable, -} -#[test] -fn bindgen_test_layout_C() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( C ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( C ) )); -} -impl Clone for C { - fn clone(&self) -> Self { *self } -} -impl Default for C { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + pub struct C__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct C { + pub vtable_: *const C__bindgen_vtable, + } + #[test] + fn bindgen_test_layout_C() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( C ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( C ) )); + } + impl Clone for C { + fn clone(&self) -> Self { *self } + } + impl Default for C { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/vtable_recursive_sig.rs b/tests/expectations/tests/vtable_recursive_sig.rs index 0faf37ac33..1dd8fc65a2 100644 --- a/tests/expectations/tests/vtable_recursive_sig.rs +++ b/tests/expectations/tests/vtable_recursive_sig.rs @@ -1,44 +1,47 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Derived { - pub _base: Base, -} -#[test] -fn bindgen_test_layout_Derived() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Derived ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Derived ) )); -} -impl Clone for Derived { - fn clone(&self) -> Self { *self } -} -impl Default for Derived { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -#[repr(C)] -pub struct Base__bindgen_vtable(::std::os::raw::c_void); -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Base { - pub vtable_: *const Base__bindgen_vtable, -} -#[test] -fn bindgen_test_layout_Base() { - assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( - "Size of: " , stringify ! ( Base ) )); - assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( - "Alignment of " , stringify ! ( Base ) )); -} -impl Clone for Base { - fn clone(&self) -> Self { *self } -} -impl Default for Base { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Derived { + pub _base: Base, + } + #[test] + fn bindgen_test_layout_Derived() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Derived ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Derived ) )); + } + impl Clone for Derived { + fn clone(&self) -> Self { *self } + } + impl Default for Derived { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + pub struct Base__bindgen_vtable(::std::os::raw::c_void); + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Base { + pub vtable_: *const Base__bindgen_vtable, + } + #[test] + fn bindgen_test_layout_Base() { + assert_eq!(::std::mem::size_of::() , 8usize , concat ! ( + "Size of: " , stringify ! ( Base ) )); + assert_eq! (::std::mem::align_of::() , 8usize , concat ! ( + "Alignment of " , stringify ! ( Base ) )); + } + impl Clone for Base { + fn clone(&self) -> Self { *self } + } + impl Default for Base { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/weird_bitfields.rs b/tests/expectations/tests/weird_bitfields.rs index 52638b01c6..f7deb424f2 100644 --- a/tests/expectations/tests/weird_bitfields.rs +++ b/tests/expectations/tests/weird_bitfields.rs @@ -1,233 +1,239 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum nsStyleSVGOpacitySource { - eStyleSVGOpacitySource_Normal = 0, - eStyleSVGOpacitySource_ContextFillOpacity = 1, - eStyleSVGOpacitySource_ContextStrokeOpacity = 2, -} -#[repr(C)] -#[derive(Debug, Copy)] -pub struct Weird { - pub mStrokeDasharrayLength: ::std::os::raw::c_uint, - pub _bitfield_1: [u16; 2usize], - pub mClipRule: ::std::os::raw::c_uchar, - pub mColorInterpolation: ::std::os::raw::c_uchar, - pub mColorInterpolationFilters: ::std::os::raw::c_uchar, - pub mFillRule: ::std::os::raw::c_uchar, - pub mImageRendering: ::std::os::raw::c_uchar, - pub mPaintOrder: ::std::os::raw::c_uchar, - pub mShapeRendering: ::std::os::raw::c_uchar, - pub mStrokeLinecap: ::std::os::raw::c_uchar, - pub mStrokeLinejoin: ::std::os::raw::c_uchar, - pub mTextAnchor: ::std::os::raw::c_uchar, - pub mTextRendering: ::std::os::raw::c_uchar, - pub _bitfield_2: u8, - pub _bitfield_3: u8, -} -#[test] -fn bindgen_test_layout_Weird() { - assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( - "Size of: " , stringify ! ( Weird ) )); - assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( - "Alignment of " , stringify ! ( Weird ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mStrokeDasharrayLength as * - const _ as usize } , 0usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mStrokeDasharrayLength ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mClipRule as * const _ as - usize } , 8usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mClipRule ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mColorInterpolation as * - const _ as usize } , 9usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mColorInterpolation ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mColorInterpolationFilters as - * const _ as usize } , 10usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mColorInterpolationFilters ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mFillRule as * const _ as - usize } , 11usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mFillRule ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mImageRendering as * const _ - as usize } , 12usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mImageRendering ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mPaintOrder as * const _ as - usize } , 13usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mPaintOrder ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mShapeRendering as * const _ - as usize } , 14usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mShapeRendering ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mStrokeLinecap as * const _ - as usize } , 15usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mStrokeLinecap ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mStrokeLinejoin as * const _ - as usize } , 16usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mStrokeLinejoin ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mTextAnchor as * const _ as - usize } , 17usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mTextAnchor ) )); - assert_eq! (unsafe { - & ( * ( 0 as * const Weird ) ) . mTextRendering as * const _ - as usize } , 18usize , concat ! ( - "Alignment of field: " , stringify ! ( Weird ) , "::" , - stringify ! ( mTextRendering ) )); -} -impl Clone for Weird { - fn clone(&self) -> Self { *self } -} -impl Default for Weird { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Weird { - #[inline] - pub fn bitTest(&self) -> ::std::os::raw::c_uint { - let mask = 65535usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_bitTest(&mut self, val: ::std::os::raw::c_uint) { - let mask = 65535usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn bitTest2(&self) -> ::std::os::raw::c_uint { - let mask = 2147418112usize as u32; - let field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - let val = (field_val & mask) >> 16usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_bitTest2(&mut self, val: ::std::os::raw::c_uint) { - let mask = 2147418112usize as u32; - let val = val as u32 as u32; - let mut field_val: u32 = - unsafe { ::std::mem::transmute(self._bitfield_1) }; - field_val &= !mask; - field_val |= (val << 16usize) & mask; - self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn mFillOpacitySource(&self) -> nsStyleSVGOpacitySource { - let mask = 7usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_mFillOpacitySource(&mut self, val: nsStyleSVGOpacitySource) { - let mask = 7usize as u8; - let val = val as u32 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn mStrokeOpacitySource(&self) -> nsStyleSVGOpacitySource { - let mask = 56usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 3usize; - unsafe { ::std::mem::transmute(val as u32) } - } - #[inline] - pub fn set_mStrokeOpacitySource(&mut self, val: nsStyleSVGOpacitySource) { - let mask = 56usize as u8; - let val = val as u32 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 3usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; - } - #[inline] - pub fn mStrokeDasharrayFromObject(&self) -> bool { - let mask = 64usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 6usize; - unsafe { ::std::mem::transmute(val as u8) } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum nsStyleSVGOpacitySource { + eStyleSVGOpacitySource_Normal = 0, + eStyleSVGOpacitySource_ContextFillOpacity = 1, + eStyleSVGOpacitySource_ContextStrokeOpacity = 2, } - #[inline] - pub fn set_mStrokeDasharrayFromObject(&mut self, val: bool) { - let mask = 64usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 6usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Weird { + pub mStrokeDasharrayLength: ::std::os::raw::c_uint, + pub _bitfield_1: [u16; 2usize], + pub mClipRule: ::std::os::raw::c_uchar, + pub mColorInterpolation: ::std::os::raw::c_uchar, + pub mColorInterpolationFilters: ::std::os::raw::c_uchar, + pub mFillRule: ::std::os::raw::c_uchar, + pub mImageRendering: ::std::os::raw::c_uchar, + pub mPaintOrder: ::std::os::raw::c_uchar, + pub mShapeRendering: ::std::os::raw::c_uchar, + pub mStrokeLinecap: ::std::os::raw::c_uchar, + pub mStrokeLinejoin: ::std::os::raw::c_uchar, + pub mTextAnchor: ::std::os::raw::c_uchar, + pub mTextRendering: ::std::os::raw::c_uchar, + pub _bitfield_2: u8, + pub _bitfield_3: u8, } - #[inline] - pub fn mStrokeDashoffsetFromObject(&self) -> bool { - let mask = 128usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - let val = (field_val & mask) >> 7usize; - unsafe { ::std::mem::transmute(val as u8) } + #[test] + fn bindgen_test_layout_Weird() { + assert_eq!(::std::mem::size_of::() , 24usize , concat ! ( + "Size of: " , stringify ! ( Weird ) )); + assert_eq! (::std::mem::align_of::() , 4usize , concat ! ( + "Alignment of " , stringify ! ( Weird ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mStrokeDasharrayLength as + * const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mStrokeDasharrayLength ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mClipRule as * const _ as + usize } , 8usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mClipRule ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mColorInterpolation as * + const _ as usize } , 9usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mColorInterpolation ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . + mColorInterpolationFilters as * const _ as usize } , + 10usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mColorInterpolationFilters ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mFillRule as * const _ as + usize } , 11usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mFillRule ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mImageRendering as * + const _ as usize } , 12usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mImageRendering ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mPaintOrder as * const _ + as usize } , 13usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mPaintOrder ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mShapeRendering as * + const _ as usize } , 14usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mShapeRendering ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mStrokeLinecap as * const + _ as usize } , 15usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mStrokeLinecap ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mStrokeLinejoin as * + const _ as usize } , 16usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mStrokeLinejoin ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mTextAnchor as * const _ + as usize } , 17usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mTextAnchor ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const Weird ) ) . mTextRendering as * const + _ as usize } , 18usize , concat ! ( + "Alignment of field: " , stringify ! ( Weird ) , "::" , + stringify ! ( mTextRendering ) )); } - #[inline] - pub fn set_mStrokeDashoffsetFromObject(&mut self, val: bool) { - let mask = 128usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_2) }; - field_val &= !mask; - field_val |= (val << 7usize) & mask; - self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + impl Clone for Weird { + fn clone(&self) -> Self { *self } } - #[inline] - pub fn mStrokeWidthFromObject(&self) -> bool { - let mask = 1usize as u8; - let field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_3) }; - let val = (field_val & mask) >> 0usize; - unsafe { ::std::mem::transmute(val as u8) } + impl Default for Weird { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } } - #[inline] - pub fn set_mStrokeWidthFromObject(&mut self, val: bool) { - let mask = 1usize as u8; - let val = val as u8 as u8; - let mut field_val: u8 = - unsafe { ::std::mem::transmute(self._bitfield_3) }; - field_val &= !mask; - field_val |= (val << 0usize) & mask; - self._bitfield_3 = unsafe { ::std::mem::transmute(field_val) }; + impl Weird { + #[inline] + pub fn bitTest(&self) -> ::std::os::raw::c_uint { + let mask = 65535usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_bitTest(&mut self, val: ::std::os::raw::c_uint) { + let mask = 65535usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn bitTest2(&self) -> ::std::os::raw::c_uint { + let mask = 2147418112usize as u32; + let field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + let val = (field_val & mask) >> 16usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_bitTest2(&mut self, val: ::std::os::raw::c_uint) { + let mask = 2147418112usize as u32; + let val = val as u32 as u32; + let mut field_val: u32 = + unsafe { ::std::mem::transmute(self._bitfield_1) }; + field_val &= !mask; + field_val |= (val << 16usize) & mask; + self._bitfield_1 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn mFillOpacitySource(&self) -> nsStyleSVGOpacitySource { + let mask = 7usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_mFillOpacitySource(&mut self, + val: nsStyleSVGOpacitySource) { + let mask = 7usize as u8; + let val = val as u32 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn mStrokeOpacitySource(&self) -> nsStyleSVGOpacitySource { + let mask = 56usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 3usize; + unsafe { ::std::mem::transmute(val as u32) } + } + #[inline] + pub fn set_mStrokeOpacitySource(&mut self, + val: nsStyleSVGOpacitySource) { + let mask = 56usize as u8; + let val = val as u32 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 3usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn mStrokeDasharrayFromObject(&self) -> bool { + let mask = 64usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 6usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_mStrokeDasharrayFromObject(&mut self, val: bool) { + let mask = 64usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 6usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn mStrokeDashoffsetFromObject(&self) -> bool { + let mask = 128usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + let val = (field_val & mask) >> 7usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_mStrokeDashoffsetFromObject(&mut self, val: bool) { + let mask = 128usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_2) }; + field_val &= !mask; + field_val |= (val << 7usize) & mask; + self._bitfield_2 = unsafe { ::std::mem::transmute(field_val) }; + } + #[inline] + pub fn mStrokeWidthFromObject(&self) -> bool { + let mask = 1usize as u8; + let field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_3) }; + let val = (field_val & mask) >> 0usize; + unsafe { ::std::mem::transmute(val as u8) } + } + #[inline] + pub fn set_mStrokeWidthFromObject(&mut self, val: bool) { + let mask = 1usize as u8; + let val = val as u8 as u8; + let mut field_val: u8 = + unsafe { ::std::mem::transmute(self._bitfield_3) }; + field_val &= !mask; + field_val |= (val << 0usize) & mask; + self._bitfield_3 = unsafe { ::std::mem::transmute(field_val) }; + } } } diff --git a/tests/expectations/tests/what_is_going_on.rs b/tests/expectations/tests/what_is_going_on.rs index e5194c02c6..133cd4e234 100644 --- a/tests/expectations/tests/what_is_going_on.rs +++ b/tests/expectations/tests/what_is_going_on.rs @@ -1,32 +1,35 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Default, Copy)] -pub struct UnknownUnits { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_UnknownUnits() { - assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( - "Size of: " , stringify ! ( UnknownUnits ) )); - assert_eq! (::std::mem::align_of::() , 1usize , concat ! ( - "Alignment of " , stringify ! ( UnknownUnits ) )); -} -impl Clone for UnknownUnits { - fn clone(&self) -> Self { *self } -} -pub type Float = f32; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct PointTyped { - pub x: F, - pub y: F, -} -impl Default for PointTyped { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct UnknownUnits { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_UnknownUnits() { + assert_eq!(::std::mem::size_of::() , 1usize , concat ! ( + "Size of: " , stringify ! ( UnknownUnits ) )); + assert_eq! (::std::mem::align_of::() , 1usize , concat ! + ( "Alignment of " , stringify ! ( UnknownUnits ) )); + } + impl Clone for UnknownUnits { + fn clone(&self) -> Self { *self } + } + pub type Float = f32; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct PointTyped { + pub x: F, + pub y: F, + } + impl Default for PointTyped { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + pub type IntPoint = PointTyped; } -pub type IntPoint = PointTyped; diff --git a/tests/expectations/tests/whitelist-namespaces-basic.rs b/tests/expectations/tests/whitelist-namespaces-basic.rs index 6a1e90291f..b13ee0eabb 100644 --- a/tests/expectations/tests/whitelist-namespaces-basic.rs +++ b/tests/expectations/tests/whitelist-namespaces-basic.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/whitelist-namespaces.rs b/tests/expectations/tests/whitelist-namespaces.rs index 0c6cc4b694..467d43566c 100644 --- a/tests/expectations/tests/whitelist-namespaces.rs +++ b/tests/expectations/tests/whitelist-namespaces.rs @@ -1,9 +1,5 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] diff --git a/tests/expectations/tests/whitelist_basic.rs b/tests/expectations/tests/whitelist_basic.rs index 8af4aba352..1a4ca736be 100644 --- a/tests/expectations/tests/whitelist_basic.rs +++ b/tests/expectations/tests/whitelist_basic.rs @@ -1,23 +1,26 @@ /* automatically generated by rust-bindgen */ +pub use self::root::*; -#![allow(non_snake_case)] - - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct WhitelistMe { - pub foo: ::std::os::raw::c_int, - pub bar: WhitelistMe_Inner, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct WhitelistMe_Inner { - pub bar: T, -} -impl Default for WhitelistMe_Inner { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } -} -impl Default for WhitelistMe { - fn default() -> Self { unsafe { ::std::mem::zeroed() } } +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct WhitelistMe { + pub foo: ::std::os::raw::c_int, + pub bar: WhitelistMe_Inner, + } + #[repr(C)] + #[derive(Debug, Copy, Clone)] + pub struct WhitelistMe_Inner { + pub bar: T, + } + impl Default for WhitelistMe_Inner { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + impl Default for WhitelistMe { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } } diff --git a/tests/expectations/tests/whitelist_fix.rs b/tests/expectations/tests/whitelist_fix.rs index 9e26e1bed0..4190be74a7 100644 --- a/tests/expectations/tests/whitelist_fix.rs +++ b/tests/expectations/tests/whitelist_fix.rs @@ -1,10 +1,14 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - pub enum Test {} -extern "C" { - pub fn Servo_Test(a: *mut Test); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern "C" { + pub fn Servo_Test(a: *mut Test); + } } diff --git a/tests/expectations/tests/whitelist_vars.rs b/tests/expectations/tests/whitelist_vars.rs index f7af24b256..a0a3286f42 100644 --- a/tests/expectations/tests/whitelist_vars.rs +++ b/tests/expectations/tests/whitelist_vars.rs @@ -1,10 +1,13 @@ /* automatically generated by rust-bindgen */ - -#![allow(non_snake_case)] - - -pub const NONE: ::std::os::raw::c_uint = 0; -pub const FOO: ::std::os::raw::c_uint = 5; -pub const FOOB: ::std::os::raw::c_int = -2; -pub const FOOBAR: ::std::os::raw::c_int = -10; +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + pub const NONE: ::std::os::raw::c_uint = 0; + pub const FOO: ::std::os::raw::c_uint = 5; + pub const FOOB: ::std::os::raw::c_int = -2; + pub const FOOBAR: ::std::os::raw::c_int = -10; +} diff --git a/tests/tests.rs b/tests/tests.rs index bb965bd7ba..18da4f82c2 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -105,13 +105,7 @@ fn create_bindgen_builder(header: &PathBuf) -> Result, Error> { let prepend = ["bindgen", "--with-derive-default", - header_str, - "--raw-line", - "", - "--raw-line", - "#![allow(non_snake_case)]", - "--raw-line", - ""]; + header_str]; let args = prepend.into_iter() .map(ToString::to_string) @@ -155,8 +149,14 @@ fn test_header_contents() { .to_string(); assert_eq!(bindings, "/* automatically generated by rust-bindgen */ -extern \"C\" { - pub fn foo(a: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; -} -"); +pub use self::root::*; + +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::*; + extern \"C\" { + pub fn foo(a: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; + } +}\n"); } From a2257257b41d65da9716963a8e06ea534f8dcdbc Mon Sep 17 00:00:00 2001 From: framlog Date: Sat, 8 Apr 2017 08:43:40 +0000 Subject: [PATCH 7/7] fixup! Merge branch 'master' into master --- tests/expectations/tests/bitfield-large.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs index af058848e8..aa16c81ed0 100644 --- a/tests/expectations/tests/bitfield-large.rs +++ b/tests/expectations/tests/bitfield-large.rs @@ -1,6 +1,5 @@ /* automatically generated by rust-bindgen */ - pub use self::root::*; #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]