summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-09-07 14:02:09 -0500
committerGitHub <noreply@github.com>2017-09-07 14:02:09 -0500
commitb13f0766e28cf75dd04f358bf64d87ea96b111c3 (patch)
treed8686bf93e5fa8c52ff6d085008a6b25c2cba42e
parentdcd8385a41f6fd6d8f5208931c418cbc745672b4 (diff)
parent46f74c189c95fc6a41daf8ded741e0cf5f5bed92 (diff)
Auto merge of #940 - fitzgen:no-syntex, r=emilio
No more syntex There are a few commits in this PR, but the big one is the commit that goes `syntex` -> `quote` for code generation. I've included a copy of its commit message below. I tried to verify that it works with the stylo build still, but there were some issues, and then I checked with master, and that wasn't working either. So now I'm C-Reducing the failures on master and figured that this is at least ready for feedback in the meantime. r? @emilio ---------------------------- The `syntex` crate is unmaintained. It is slow to build, and additionally it requires that we pre-process `src/codegen/mod.rs` before we build the `bindgen` crate. The `quote` crate provides similar quasi-quoting functionality, is maintained, and builds faster. It doesn't have a typed API or builders, however; it only deals with tokens. Before this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 98.75 secs ``` After this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs ``` Build time is cut in half! But what about run time? Before this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 521105668 } ``` After this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 548797242 } ``` So it appears to be about 20ms slower at generating Stylo bindings, but I suspect this is well within the noise. Finally, this also lets us remove that nasty `mem::transmute` inside `bindgen::ir::BindgenContext::gen` that was used for the old `syntex` context. Now `BindgenContext` doesn't have a lifetime parameter either. This should make it easier to revisit doing our analyses in parallel with `rayon`, since that context was one of the things that made it hard for `BindgenContext` to implement `Sync`. Fixes #925
-rw-r--r--CONTRIBUTING.md8
-rw-r--r--Cargo.lock104
-rw-r--r--Cargo.toml17
-rw-r--r--build.rs13
-rwxr-xr-xci/script.sh4
-rw-r--r--src/codegen/derive_debug.rs82
-rw-r--r--src/codegen/helpers.rs208
-rw-r--r--src/codegen/mod.rs2133
-rw-r--r--src/codegen/struct_layout.rs37
-rw-r--r--src/ir/analysis/derive_copy.rs19
-rw-r--r--src/ir/analysis/derive_debug.rs19
-rw-r--r--src/ir/analysis/derive_default.rs19
-rw-r--r--src/ir/analysis/derive_hash.rs19
-rw-r--r--src/ir/analysis/derive_partial_eq.rs21
-rw-r--r--src/ir/analysis/has_destructor.rs19
-rw-r--r--src/ir/analysis/has_float.rs18
-rw-r--r--src/ir/analysis/has_type_param_in_array.rs21
-rw-r--r--src/ir/analysis/has_vtable.rs19
-rw-r--r--src/ir/analysis/template_params.rs21
-rw-r--r--src/ir/context.rs174
-rw-r--r--src/ir/function.rs57
-rw-r--r--src/ir/item.rs58
-rw-r--r--src/ir/objc.rs27
-rw-r--r--src/ir/traversal.rs60
-rw-r--r--src/ir/ty.rs31
-rw-r--r--src/lib.rs90
-rw-r--r--src/main.rs1
-rw-r--r--src/time.rs6
-rw-r--r--tests/expectations/tests/annotation_hide.rs52
-rw-r--r--tests/expectations/tests/bitfield-32bit-overflow.rs1462
-rw-r--r--tests/expectations/tests/bitfield-method-same-name.rs57
-rw-r--r--tests/expectations/tests/bitfield_align.rs1131
-rw-r--r--tests/expectations/tests/bitfield_align_2.rs94
-rw-r--r--tests/expectations/tests/bitfield_method_mangling.rs88
-rw-r--r--tests/expectations/tests/blacklist-and-impl-debug.rs38
-rw-r--r--tests/expectations/tests/class_nested.rs150
-rw-r--r--tests/expectations/tests/class_use_as.rs67
-rw-r--r--tests/expectations/tests/class_with_dtor.rs56
-rw-r--r--tests/expectations/tests/constify-all-enums.rs37
-rw-r--r--tests/expectations/tests/constify-module-enums-basic.rs51
-rw-r--r--tests/expectations/tests/constify-module-enums-simple-alias.rs142
-rw-r--r--tests/expectations/tests/default-template-parameter.rs30
-rw-r--r--tests/expectations/tests/derive-debug-bitfield.rs118
-rw-r--r--tests/expectations/tests/derive-debug-generic.rs10
-rw-r--r--tests/expectations/tests/derive-default-and-blacklist.rs36
-rw-r--r--tests/expectations/tests/derive-hash-and-blacklist.rs35
-rw-r--r--tests/expectations/tests/derive-hash-blacklisting.rs74
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs82
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-float-array.rs34
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-pointer.rs149
-rw-r--r--tests/expectations/tests/derive-hash-template-def-float.rs7
-rw-r--r--tests/expectations/tests/derive-hash-template-inst-float.rs106
-rw-r--r--tests/expectations/tests/derive-partialeq-and-blacklist.rs36
-rw-r--r--tests/expectations/tests/forward-declaration-autoptr.rs58
-rw-r--r--tests/expectations/tests/gen-constructors.rs18
-rw-r--r--tests/expectations/tests/issue-410.rs23
-rw-r--r--tests/expectations/tests/issue-447.rs56
-rw-r--r--tests/expectations/tests/issue-648-derive-debug-with-padding.rs77
-rw-r--r--tests/expectations/tests/issue-848-replacement-system-include.rs7
-rw-r--r--tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs34
-rw-r--r--tests/expectations/tests/issue_315.rs1
-rw-r--r--tests/expectations/tests/jsval_layout_opaque.rs388
-rw-r--r--tests/expectations/tests/jsval_layout_opaque_1_0.rs412
-rw-r--r--tests/expectations/tests/layout_align.rs169
-rw-r--r--tests/expectations/tests/layout_cmdline_token.rs281
-rw-r--r--tests/expectations/tests/layout_eth_conf.rs2188
-rw-r--r--tests/expectations/tests/layout_eth_conf_1_0.rs2224
-rw-r--r--tests/expectations/tests/layout_mbuf.rs1404
-rw-r--r--tests/expectations/tests/layout_mbuf_1_0.rs1419
-rw-r--r--tests/expectations/tests/libclang-3.8/auto.rs20
-rw-r--r--tests/expectations/tests/libclang-3.8/call-conv-field.rs60
-rw-r--r--tests/expectations/tests/libclang-3.8/const_bool.rs24
-rw-r--r--tests/expectations/tests/libclang-3.8/constant-evaluate.rs10
-rw-r--r--tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs33
-rw-r--r--tests/expectations/tests/libclang-3.8/objc_template.rs10
-rw-r--r--tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs18
-rw-r--r--tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs33
-rw-r--r--tests/expectations/tests/libclang-3.9/auto.rs18
-rw-r--r--tests/expectations/tests/libclang-3.9/call-conv-field.rs60
-rw-r--r--tests/expectations/tests/libclang-3.9/const_bool.rs18
-rw-r--r--tests/expectations/tests/libclang-3.9/constant-evaluate.rs9
-rw-r--r--tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs33
-rw-r--r--tests/expectations/tests/libclang-3.9/objc_template.rs10
-rw-r--r--tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs18
-rw-r--r--tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs33
-rw-r--r--tests/expectations/tests/libclang-4/constant-evaluate.rs9
-rw-r--r--tests/expectations/tests/libclang-4/issue-769-bad-instantiation-test.rs33
-rw-r--r--tests/expectations/tests/libclang-4/type_alias_template_specialized.rs54
-rw-r--r--tests/expectations/tests/macro_const.rs8
-rw-r--r--tests/expectations/tests/mangling-win32.rs18
-rw-r--r--tests/expectations/tests/namespace.rs63
-rw-r--r--tests/expectations/tests/no-derive-debug.rs55
-rw-r--r--tests/expectations/tests/no-derive-default.rs51
-rw-r--r--tests/expectations/tests/no_copy.rs1
-rw-r--r--tests/expectations/tests/nsBaseHashtable.rs50
-rw-r--r--tests/expectations/tests/objc_class_method.rs66
-rw-r--r--tests/expectations/tests/objc_method.rs51
-rw-r--r--tests/expectations/tests/objc_method_clash.rs13
-rw-r--r--tests/expectations/tests/objc_property_fnptr.rs36
-rw-r--r--tests/expectations/tests/objc_whitelist.rs32
-rw-r--r--tests/expectations/tests/only_bitfields.rs82
-rw-r--r--tests/expectations/tests/opaque-template-inst-member-2.rs93
-rw-r--r--tests/expectations/tests/opaque-template-instantiation-namespaced.rs161
-rw-r--r--tests/expectations/tests/opaque-template-instantiation.rs99
-rw-r--r--tests/expectations/tests/opaque_in_struct.rs52
-rw-r--r--tests/expectations/tests/opaque_pointer.rs89
-rw-r--r--tests/expectations/tests/replace_template_alias.rs7
-rw-r--r--tests/expectations/tests/replace_use.rs53
-rw-r--r--tests/expectations/tests/struct_typedef_ns.rs84
-rw-r--r--tests/expectations/tests/struct_with_bitfields.rs241
-rw-r--r--tests/expectations/tests/template.rs646
-rw-r--r--tests/expectations/tests/template_typedefs.rs11
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield.rs117
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs153
-rw-r--r--tests/expectations/tests/weird_bitfields.rs458
-rw-r--r--tests/headers/nsBaseHashtable.hpp48
-rw-r--r--tests/rustfmt.toml0
-rwxr-xr-xtests/stylo_sanity.rs1035
-rwxr-xr-xtests/test-one.sh6
-rw-r--r--tests/tests.rs172
120 files changed, 11718 insertions, 9042 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9f0fcc6b..fa345335 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -88,6 +88,14 @@ There is also the `./bindgen-integration` crate, which uses `bindgen` to
generate bindings to some C++ code, and then uses the bindings, asserting that
values are what we expect them to be both on the Rust and C++ side.
+The generated and expected bindings are run through `rustfmt` before they are
+compared. Make sure you have `rustfmt` up to date:
+
+```
+$ rustup update nightly
+$ rustup run nightly cargo install -f rustfmt-nightly
+```
+
### Testing Bindings Generation
To regenerate bindings from the corpus of test headers in `tests/headers` and
diff --git a/Cargo.lock b/Cargo.lock
index 3135089f..c1218383 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,7 +2,6 @@
name = "bindgen"
version = "0.30.0"
dependencies = [
- "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -12,11 +11,9 @@ dependencies = [
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
"which 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -34,14 +31,6 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "aster"
-version = "0.41.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "atty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -172,24 +161,9 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "quasi"
-version = "0.32.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "quasi_codegen"
-version = "0.32.0"
+name = "quote"
+version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
[[package]]
name = "regex"
@@ -209,11 +183,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "rustc-serialize"
-version = "0.3.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -224,57 +193,6 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "syntex"
-version = "0.58.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "syntex_errors"
-version = "0.58.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "syntex_pos"
-version = "0.58.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "syntex_syntax"
-version = "0.58.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "term"
-version = "0.4.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "term_size"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -313,11 +231,6 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "unicode-xid"
-version = "0.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "unreachable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -361,7 +274,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
-"checksum aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfdf7355d9db158df68f976ed030ab0f6578af811f5a7bb6dcf221ec24e0e0"
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4"
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
@@ -380,24 +292,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
-"checksum quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c45c4854d6d1cf5d531db97c75880feb91c958b0720f4ec1057135fec358b3"
-"checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4"
+"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
-"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
-"checksum syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f5e3aaa79319573d19938ea38d068056b826db9883a5d47f86c1cecc688f0e"
-"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c"
-"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047"
-"checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791"
-"checksum term 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d168af3930b369cfe245132550579d47dfd873d69470755a19c2c6568dbbd989"
"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209"
"checksum thread-id 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8df7875b676fddfadffd96deea3b1124e5ede707d4884248931077518cf1f773"
"checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7"
"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
-"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
diff --git a/Cargo.toml b/Cargo.toml
index 0e57a06b..076528f3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -39,25 +39,18 @@ diff = "0.1"
clap = "2"
shlex = "0.1"
-[build-dependencies]
-quasi_codegen = "0.32"
-
[dependencies]
cexpr = "0.2"
cfg-if = "0.1.0"
+# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
+clap = "2"
clang-sys = { version = "0.19.0", features = ["runtime", "clang_3_9"] }
lazy_static = "0.2.1"
peeking_take_while = "0.1.2"
-syntex_syntax = "0.58"
+quote = "0.3.15"
regex = "0.2"
-# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
-clap = "2"
which = "1.0.2"
-[dependencies.aster]
-features = ["with-syntex"]
-version = "0.41"
-
[dependencies.env_logger]
optional = true
version = "0.4"
@@ -66,10 +59,6 @@ version = "0.4"
optional = true
version = "0.3"
-[dependencies.quasi]
-features = ["with-syntex"]
-version = "0.32"
-
[features]
default = ["logging"]
logging = ["env_logger", "log"]
diff --git a/build.rs b/build.rs
index a699f5ab..a20c3781 100644
--- a/build.rs
+++ b/build.rs
@@ -1,5 +1,4 @@
-mod codegen {
- extern crate quasi_codegen;
+mod target {
use std::env;
use std::fs::File;
use std::io::Write;
@@ -7,14 +6,6 @@ mod codegen {
pub fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
- let src = Path::new("src/codegen/mod.rs");
- let dst = Path::new(&out_dir).join("codegen.rs");
-
- quasi_codegen::expand(&src, &dst).unwrap();
- println!("cargo:rerun-if-changed=src/codegen/mod.rs");
- println!("cargo:rerun-if-changed=src/codegen/error.rs");
- println!("cargo:rerun-if-changed=src/codegen/helpers.rs");
- println!("cargo:rerun-if-changed=src/codegen/struct_layout.rs");
let mut dst = File::create(Path::new(&out_dir).join("host-target.txt"))
.unwrap();
@@ -77,6 +68,6 @@ mod testgen {
}
fn main() {
- codegen::main();
+ target::main();
testgen::main();
}
diff --git a/ci/script.sh b/ci/script.sh
index b23d8b5d..7338dc0b 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -11,6 +11,10 @@ export RUST_BACKTRACE=1
case "$BINDGEN_JOB" in
"test")
+ # Need rustfmt to compare the test expectations.
+ rustup update nightly
+ rustup run nightly cargo install -f rustfmt-nightly
+
cargo test $BINDGEN_PROFILE --features "$BINDGEN_FEATURES"
./ci/assert-no-diff.sh
;;
diff --git a/src/codegen/derive_debug.rs b/src/codegen/derive_debug.rs
index 82456797..7ef108da 100644
--- a/src/codegen/derive_debug.rs
+++ b/src/codegen/derive_debug.rs
@@ -3,21 +3,17 @@ use ir::context::BindgenContext;
use ir::derive::CanTriviallyDeriveDebug;
use ir::item::{HasTypeParamInArray, IsOpaque, Item, ItemCanonicalName};
use ir::ty::{RUST_DERIVE_IN_ARRAY_LIMIT, TypeKind};
-use syntax::ast;
-use syntax::codemap::DUMMY_SP;
-use syntax::parse::token::Token;
-
-use syntax::tokenstream::TokenTree;
+use quote;
pub fn gen_debug_impl(
ctx: &BindgenContext,
fields: &[Field],
item: &Item,
kind: CompKind,
-) -> Vec<ast::ImplItem> {
+) -> quote::Tokens {
let struct_name = item.canonical_name(ctx);
let mut format_string = format!("{} {{{{ ", struct_name);
- let mut tokens: Vec<TokenTree> = Vec::new();
+ let mut tokens = vec![];
if item.is_opaque(ctx, &()) {
format_string.push_str("opaque");
@@ -33,14 +29,11 @@ pub fn gen_debug_impl(
});
- for (i, (fstring, token)) in processed_fields.enumerate() {
+ for (i, (fstring, toks)) in processed_fields.enumerate() {
if i > 0 {
format_string.push_str(", ");
}
- if !token.is_empty() {
- tokens.push(TokenTree::Token(DUMMY_SP, Token::Comma));
- tokens.extend(token);
- }
+ tokens.extend(toks);
format_string.push_str(&fstring);
}
}
@@ -48,17 +41,12 @@ pub fn gen_debug_impl(
}
format_string.push_str(" }}");
+ tokens.insert(0, quote! { #format_string });
- let impl_ = quote_item!(ctx.ext_cx(),
- impl X {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- write!(f, $format_string $tokens)
- }
- });
-
- match impl_.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, ref items) => items.clone(),
- _ => unreachable!(),
+ quote! {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ write!(f, #( #tokens ),*)
+ }
}
}
@@ -74,7 +62,7 @@ pub trait ImplDebug<'a> {
&self,
ctx: &BindgenContext,
extra: Self::Extra,
- ) -> Option<(String, Vec<TokenTree>)>;
+ ) -> Option<(String, Vec<quote::Tokens>)>;
}
impl<'a> ImplDebug<'a> for FieldData {
@@ -84,7 +72,7 @@ impl<'a> ImplDebug<'a> for FieldData {
&self,
ctx: &BindgenContext,
_: Self::Extra,
- ) -> Option<(String, Vec<TokenTree>)> {
+ ) -> Option<(String, Vec<quote::Tokens>)> {
if let Some(name) = self.name() {
ctx.resolve_item(self.ty()).impl_debug(ctx, name)
} else {
@@ -100,17 +88,18 @@ impl<'a> ImplDebug<'a> for BitfieldUnit {
&self,
ctx: &BindgenContext,
_: Self::Extra,
- ) -> Option<(String, Vec<TokenTree>)> {
+ ) -> Option<(String, Vec<quote::Tokens>)> {
let mut format_string = String::new();
- let mut tokens = Vec::new();
+ let mut tokens = vec![];
for (i, bu) in self.bitfields().iter().enumerate() {
if i > 0 {
format_string.push_str(", ");
- tokens.push(TokenTree::Token(DUMMY_SP, Token::Comma));
}
format_string.push_str(&format!("{} : {{:?}}", bu.name()));
let name_ident = ctx.rust_ident_raw(bu.name());
- tokens.extend(quote_tokens!(ctx.ext_cx(), self.$name_ident()));
+ tokens.push(quote! {
+ self.#name_ident ()
+ });
}
Some((format_string, tokens))
@@ -123,8 +112,8 @@ impl<'a> ImplDebug<'a> for Item {
fn impl_debug(
&self,
ctx: &BindgenContext,
- name: Self::Extra,
- ) -> Option<(String, Vec<TokenTree>)> {
+ name: &str,
+ ) -> Option<(String, Vec<quote::Tokens>)> {
let name_ident = ctx.rust_ident_raw(name);
// We don't know if blacklisted items `impl Debug` or not, so we can't
@@ -141,13 +130,14 @@ impl<'a> ImplDebug<'a> for Item {
};
fn debug_print(
- ctx: &BindgenContext,
name: &str,
- name_ident: ast::Ident,
- ) -> Option<(String, Vec<TokenTree>)> {
+ name_ident: quote::Tokens,
+ ) -> Option<(String, Vec<quote::Tokens>)> {
Some((
format!("{}: {{:?}}", name),
- quote_tokens!(ctx.ext_cx(), self.$name_ident),
+ vec![quote! {
+ self.#name_ident
+ }],
))
}
@@ -166,13 +156,13 @@ impl<'a> ImplDebug<'a> for Item {
TypeKind::ObjCInterface(..) |
TypeKind::ObjCId |
TypeKind::Comp(..) |
- TypeKind::ObjCSel => debug_print(ctx, name, name_ident),
+ TypeKind::ObjCSel => debug_print(name, quote! { #name_ident }),
TypeKind::TemplateInstantiation(ref inst) => {
if inst.is_opaque(ctx, self) {
Some((format!("{}: opaque", name), vec![]))
} else {
- debug_print(ctx, name, name_ident)
+ debug_print(name, quote! { #name_ident })
}
}
@@ -189,18 +179,18 @@ impl<'a> ImplDebug<'a> for Item {
)
} else if len < RUST_DERIVE_IN_ARRAY_LIMIT {
// The simple case
- debug_print(ctx, name, name_ident)
+ debug_print(name, quote! { #name_ident })
} else {
// Let's implement our own print function
Some((
format!("{}: [{{}}]", name),
- quote_tokens!(
- ctx.ext_cx(),
- self.$name_ident
- .iter()
- .enumerate()
- .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
- .collect::<String>()),
+ vec![quote! {
+ self.#name_ident
+ .iter()
+ .enumerate()
+ .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
+ .collect::<String>()
+ }],
))
}
}
@@ -217,9 +207,9 @@ impl<'a> ImplDebug<'a> for Item {
match *inner_type.kind() {
TypeKind::Function(ref sig)
if !sig.can_trivially_derive_debug() => {
- Some((format!("{}: FunctionPointer", name), vec![]))
+ Some((format!("{}: FunctionPointer", name), vec![]))
}
- _ => debug_print(ctx, name, name_ident),
+ _ => debug_print(name, quote! { #name_ident }),
}
}
diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs
index ed165aa9..5136d787 100644
--- a/src/codegen/helpers.rs
+++ b/src/codegen/helpers.rs
@@ -1,66 +1,59 @@
//! Helpers for code generation that don't need macro expansion.
-use aster;
use ir::layout::Layout;
-use syntax::ast;
-use syntax::ptr::P;
-
+use quote;
pub mod attributes {
- use aster;
- use syntax::ast;
-
- pub fn allow(which_ones: &[&str]) -> ast::Attribute {
- aster::AstBuilder::new()
- .attr()
- .list("allow")
- .words(which_ones)
- .build()
- }
+ use quote;
- pub fn repr(which: &str) -> ast::Attribute {
- aster::AstBuilder::new()
- .attr()
- .list("repr")
- .words(&[which])
- .build()
+ pub fn repr(which: &str) -> quote::Tokens {
+ let which = quote::Ident::new(which);
+ quote! {
+ #[repr( #which )]
+ }
}
- pub fn repr_list(which_ones: &[&str]) -> ast::Attribute {
- aster::AstBuilder::new()
- .attr()
- .list("repr")
- .words(which_ones)
- .build()
+ pub fn repr_list(which_ones: &[&str]) -> quote::Tokens {
+ let which_ones = which_ones.iter().cloned().map(quote::Ident::new);
+ quote! {
+ #[repr( #( #which_ones ),* )]
+ }
}
- pub fn derives(which_ones: &[&str]) -> ast::Attribute {
- aster::AstBuilder::new()
- .attr()
- .list("derive")
- .words(which_ones)
- .build()
+ pub fn derives(which_ones: &[&str]) -> quote::Tokens {
+ let which_ones = which_ones.iter().cloned().map(quote::Ident::new);
+ quote! {
+ #[derive( #( #which_ones ),* )]
+ }
}
- pub fn inline() -> ast::Attribute {
- aster::AstBuilder::new().attr().word("inline")
+ pub fn inline() -> quote::Tokens {
+ quote! {
+ #[inline]
+ }
}
- pub fn doc(comment: String) -> ast::Attribute {
- aster::AstBuilder::new().attr().doc(&*comment)
+ pub fn doc(comment: String) -> quote::Tokens {
+ // Doc comments are already preprocessed into nice `///` formats by the
+ // time they get here. Just make sure that we have newlines around it so
+ // that nothing else gets wrapped into the comment.
+ let mut tokens = quote! {};
+ tokens.append("\n");
+ tokens.append(comment);
+ tokens.append("\n");
+ tokens
}
- pub fn link_name(name: &str) -> ast::Attribute {
- aster::AstBuilder::new()
- .attr()
- .name_value("link_name")
- .str(name)
+ pub fn link_name(name: &str) -> quote::Tokens {
+ quote! {
+ #[link_name = #name]
+ }
}
}
/// Generates a proper type for a field or type with a given `Layout`, that is,
/// a type with the correct size and alignment restrictions.
-pub fn blob(layout: Layout) -> P<ast::Ty> {
+pub fn blob(layout: Layout) -> quote::Tokens {
let opaque = layout.opaque();
// FIXME(emilio, #412): We fall back to byte alignment, but there are
@@ -75,39 +68,46 @@ pub fn blob(layout: Layout) -> P<ast::Ty> {
}
};
+ let ty_name = quote::Ident::new(ty_name);
+
let data_len = opaque.array_size().unwrap_or(layout.size);
- let inner_ty = aster::AstBuilder::new().ty().path().id(ty_name).build();
if data_len == 1 {
- inner_ty
+ quote! {
+ #ty_name
+ }
} else {
- aster::ty::TyBuilder::new().array(data_len).build(inner_ty)
+ quote! {
+ [ #ty_name ; #data_len ]
+ }
}
}
pub mod ast_ty {
- use aster;
use ir::context::BindgenContext;
use ir::function::FunctionSig;
use ir::ty::FloatKind;
- use syntax::ast;
- use syntax::ptr::P;
+ use quote;
- pub fn raw_type(ctx: &BindgenContext, name: &str) -> P<ast::Ty> {
- let ident = ctx.rust_ident_raw(&name);
+ pub fn raw_type(ctx: &BindgenContext, name: &str) -> quote::Tokens {
+ let ident = ctx.rust_ident_raw(name);
match ctx.options().ctypes_prefix {
Some(ref prefix) => {
- let prefix = ctx.rust_ident_raw(prefix);
- quote_ty!(ctx.ext_cx(), $prefix::$ident)
+ let prefix = ctx.rust_ident_raw(prefix.as_str());
+ quote! {
+ #prefix::#ident
+ }
}
- None => quote_ty!(ctx.ext_cx(), ::std::os::raw::$ident),
+ None => quote! {
+ ::std::os::raw::#ident
+ },
}
}
pub fn float_kind_rust_type(
ctx: &BindgenContext,
fk: FloatKind,
- ) -> P<ast::Ty> {
+ ) -> quote::Tokens {
// TODO: we probably should just take the type layout into
// account?
//
@@ -116,64 +116,50 @@ pub mod ast_ty {
// FIXME: `c_longdouble` doesn't seem to be defined in some
// systems, so we use `c_double` directly.
match (fk, ctx.options().convert_floats) {
- (FloatKind::Float, true) => aster::ty::TyBuilder::new().f32(),
+ (FloatKind::Float, true) => quote! { f32 },
(FloatKind::Double, true) |
- (FloatKind::LongDouble, true) => aster::ty::TyBuilder::new().f64(),
+ (FloatKind::LongDouble, true) => quote! { f64 },
(FloatKind::Float, false) => raw_type(ctx, "c_float"),
(FloatKind::Double, false) |
(FloatKind::LongDouble, false) => raw_type(ctx, "c_double"),
- (FloatKind::Float128, _) => {
- aster::ty::TyBuilder::new().array(16).u8()
- }
+ (FloatKind::Float128, _) => quote! { [u8; 16] },
}
}
- pub fn int_expr(val: i64) -> P<ast::Expr> {
- use std::i64;
- let expr = aster::AstBuilder::new().expr();
-
- // This is not representable as an i64 if it's negative, so we
- // special-case it.
- //
- // Fix in aster incoming.
- if val == i64::MIN {
- expr.neg().uint(1u64 << 63)
- } else {
- expr.int(val)
- }
+ pub fn int_expr(val: i64) -> quote::Tokens {
+ // Don't use quote! { #val } because that adds the type suffix.
+ let mut tokens = quote! {};
+ tokens.append(val.to_string());
+ tokens
}
- pub fn bool_expr(val: bool) -> P<ast::Expr> {
- aster::AstBuilder::new().expr().bool(val)
+ pub fn uint_expr(val: u64) -> quote::Tokens {
+ // Don't use quote! { #val } because that adds the type suffix.
+ let mut tokens = quote! {};
+ tokens.append(val.to_string());
+ tokens
}
- pub fn byte_array_expr(bytes: &[u8]) -> P<ast::Expr> {
- let mut vec = Vec::with_capacity(bytes.len() + 1);
- for byte in bytes {
- vec.push(int_expr(*byte as i64));
+ pub fn byte_array_expr(bytes: &[u8]) -> quote::Tokens {
+ let mut bytes: Vec<_> = bytes.iter().cloned().collect();
+ bytes.push(0);
+ quote! {
+ #bytes
}
- vec.push(int_expr(0));
-
- let kind = ast::ExprKind::Array(vec);
-
- aster::AstBuilder::new().expr().build_expr_kind(kind)
}
- pub fn cstr_expr(mut string: String) -> P<ast::Expr> {
+ pub fn cstr_expr(mut string: String) -> quote::Tokens {
string.push('\0');
- aster::AstBuilder::new().expr().build_lit(
- aster::AstBuilder::new()
- .lit()
- .byte_str(string),
- )
+ let b = quote::ByteStr(&string);
+ quote! {
+ #b
+ }
}
pub fn float_expr(
ctx: &BindgenContext,
f: f64,
- ) -> Result<P<ast::Expr>, ()> {
- use aster::symbol::ToSymbol;
-
+ ) -> Result<quote::Tokens, ()> {
if f.is_finite() {
let mut string = f.to_string();
@@ -182,21 +168,28 @@ pub mod ast_ty {
string.push('.');
}
- let kind =
- ast::LitKind::FloatUnsuffixed(string.as_str().to_symbol());
- return Ok(aster::AstBuilder::new().expr().lit().build_lit(kind));
+ let mut tokens = quote! {};
+ tokens.append(string);
+ return Ok(tokens);
}
let prefix = ctx.trait_prefix();
+
if f.is_nan() {
- return Ok(quote_expr!(ctx.ext_cx(), ::$prefix::f64::NAN));
+ return Ok(quote! {
+ ::#prefix::f64::NAN
+ });
}
if f.is_infinite() {
return Ok(if f.is_sign_positive() {
- quote_expr!(ctx.ext_cx(), ::$prefix::f64::INFINITY)
+ quote! {
+ ::#prefix::f64::INFINITY
+ }
} else {
- quote_expr!(ctx.ext_cx(), ::$prefix::f64::NEG_INFINITY)
+ quote! {
+ ::#prefix::f64::NEG_INFINITY
+ }
});
}
@@ -207,23 +200,24 @@ pub mod ast_ty {
pub fn arguments_from_signature(
signature: &FunctionSig,
ctx: &BindgenContext,
- ) -> Vec<P<ast::Expr>> {
- // TODO: We need to keep in sync the argument names, so we should unify
- // this with the other loop that decides them.
+ ) -> Vec<quote::Tokens> {
let mut unnamed_arguments = 0;
signature
.argument_types()
.iter()
.map(|&(ref name, _ty)| {
- let arg_name = match *name {
- Some(ref name) => ctx.rust_mangle(name).into_owned(),
+ match *name {
+ Some(ref name) => {
+ let name = ctx.rust_ident(name);
+ quote! { #name }
+ }
None => {
unnamed_arguments += 1;
- format!("arg{}", unnamed_arguments)
+ let name = ctx.rust_ident(format!("arg{}", unnamed_arguments));
+ quote! { #name }
}
- };
- aster::expr::ExprBuilder::new().id(arg_name)
+ }
})
- .collect::<Vec<_>>()
+ .collect()
}
}
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 4697ba21..f13bd65a 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -6,9 +6,6 @@ pub mod struct_layout;
use self::helpers::attributes;
use self::struct_layout::StructLayoutTracker;
-use aster;
-use aster::struct_field::StructFieldBuilder;
-
use ir::annotations::FieldAccessorKind;
use ir::comment;
use ir::comp::{Base, Bitfield, BitfieldUnit, CompInfo, CompKind, Field,
@@ -29,36 +26,33 @@ use ir::template::{AsTemplateParam, TemplateInstantiation, TemplateParameters};
use ir::ty::{Type, TypeKind};
use ir::var::Var;
+use quote;
+
use std::borrow::Cow;
use std::cell::Cell;
use std::collections::{HashSet, VecDeque};
use std::collections::hash_map::{Entry, HashMap};
use std::fmt::Write;
+use std::iter;
use std::mem;
use std::ops;
-use syntax::abi;
-use syntax::ast;
-use syntax::codemap::{DUMMY_SP, Span, respan};
-use syntax::ptr::P;
// Name of type defined in constified enum module
pub static CONSTIFIED_ENUM_MODULE_REPR_NAME: &'static str = "Type";
-fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec<ast::Ident> {
- let mut path = vec![ctx.rust_ident_raw("self")];
+fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec<quote::Tokens> {
+ let mut path = vec![quote! { self }];
if ctx.options().enable_cxx_namespaces {
- let super_ = ctx.rust_ident_raw("super");
-
for _ in 0..item.codegen_depth(ctx) {
- path.push(super_.clone());
+ path.push(quote! { super });
}
}
path
}
-fn root_import(ctx: &BindgenContext, module: &Item) -> P<ast::Item> {
+fn root_import(ctx: &BindgenContext, module: &Item) -> quote::Tokens {
assert!(ctx.options().enable_cxx_namespaces, "Somebody messed it up");
assert!(module.is_module());
@@ -66,20 +60,20 @@ fn root_import(ctx: &BindgenContext, module: &Item) -> P<ast::Item> {
let root = ctx.root_module().canonical_name(ctx);
let root_ident = ctx.rust_ident(&root);
- path.push(root_ident);
+ path.push(quote! { #root_ident });
+
- let use_root = aster::AstBuilder::new()
- .item()
- .use_()
- .ids(path)
- .build()
- .build();
+ let mut tokens = quote! {};
+ tokens.append_separated(path, "::");
- quote_item!(ctx.ext_cx(), #[allow(unused_imports)] $use_root).unwrap()
+ quote! {
+ #[allow(unused_imports)]
+ use #tokens ;
+ }
}
struct CodegenResult<'a> {
- items: Vec<P<ast::Item>>,
+ items: Vec<quote::Tokens>,
/// A monotonic counter used to add stable unique id's to stuff that doesn't
/// need to be referenced by anything.
@@ -190,7 +184,7 @@ impl<'a> CodegenResult<'a> {
self.vars_seen.insert(name.into());
}
- fn inner<F>(&mut self, cb: F) -> Vec<P<ast::Item>>
+ fn inner<F>(&mut self, cb: F) -> Vec<quote::Tokens>
where
F: FnOnce(&mut Self),
{
@@ -207,7 +201,7 @@ impl<'a> CodegenResult<'a> {
}
impl<'a> ops::Deref for CodegenResult<'a> {
- type Target = Vec<P<ast::Item>>;
+ type Target = Vec<quote::Tokens>;
fn deref(&self) -> &Self::Target {
&self.items
@@ -220,70 +214,85 @@ impl<'a> ops::DerefMut for CodegenResult<'a> {
}
}
-struct ForeignModBuilder {
- inner: ast::ForeignMod,
+/// A trait to convert a rust type into a pointer, optionally const, to the same
+/// type.
+trait ToPtr {
+ fn to_ptr(self, is_const: bool) -> quote::Tokens;
}
-impl ForeignModBuilder {
- fn new(abi: abi::Abi) -> Self {
- ForeignModBuilder {
- inner: ast::ForeignMod {
- abi: abi,
- items: vec![],
- },
+impl ToPtr for quote::Tokens {
+ fn to_ptr(self, is_const: bool) -> quote::Tokens {
+ if is_const {
+ quote! { *const #self }
+ } else {
+ quote! { *mut #self }
}
}
-
- fn with_foreign_item(mut self, item: ast::ForeignItem) -> Self {
- self.inner.items.push(item);
- self
- }
-
- #[allow(dead_code)]
- fn with_foreign_items<I>(mut self, items: I) -> Self
- where
- I: IntoIterator<Item = ast::ForeignItem>,
- {
- self.inner.items.extend(items.into_iter());
- self
- }
-
- fn build(self, ctx: &BindgenContext) -> P<ast::Item> {
- P(ast::Item {
- ident: ctx.rust_ident(""),
- id: ast::DUMMY_NODE_ID,
- node: ast::ItemKind::ForeignMod(self.inner),
- vis: ast::Visibility::Public,
- attrs: vec![],
- span: DUMMY_SP,
- })
- }
}
-/// A trait to convert a rust type into a pointer, optionally const, to the same
-/// type.
-///
-/// This is done due to aster's lack of pointer builder, I guess I should PR
-/// there.
-trait ToPtr {
- fn to_ptr(self, is_const: bool, span: Span) -> P<ast::Ty>;
+/// An extension trait for `quote::Tokens` that lets us append any implicit
+/// template parameters that exist for some type, if necessary.
+trait AppendImplicitTemplateParams {
+ fn append_implicit_template_params(
+ &mut self,
+ ctx: &BindgenContext,
+ item: &Item,
+ );
}
-impl ToPtr for P<ast::Ty> {
- fn to_ptr(self, is_const: bool, span: Span) -> Self {
- let ty = ast::TyKind::Ptr(ast::MutTy {
- ty: self,
- mutbl: if is_const {
- ast::Mutability::Immutable
- } else {
- ast::Mutability::Mutable
- },
- });
- P(ast::Ty {
- id: ast::DUMMY_NODE_ID,
- node: ty,
- span: span,
- })
+impl AppendImplicitTemplateParams for quote::Tokens {
+ fn append_implicit_template_params(
+ &mut self,
+ ctx: &BindgenContext,
+ item: &Item,
+ ) {
+ let item = item.id()
+ .into_resolver()
+ .through_type_refs()
+ .resolve(ctx);
+
+ match *item.expect_type().kind() {
+ TypeKind::UnresolvedTypeRef(..) => {
+ unreachable!("already resolved unresolved type refs")
+ }
+ TypeKind::ResolvedTypeRef(..) => {
+ unreachable!("we resolved item through type refs")
+ }
+
+ // None of these types ever have implicit template parameters.
+ TypeKind::Void |
+ TypeKind::NullPtr |
+ TypeKind::Pointer(..) |
+ TypeKind::Int(..) |
+ TypeKind::Float(..) |
+ TypeKind::Complex(..) |
+ TypeKind::Array(..) |
+ TypeKind::TypeParam |
+ TypeKind::Opaque |
+ TypeKind::Function(..) |
+ TypeKind::Enum(..) |
+ TypeKind::BlockPointer |
+ TypeKind::ObjCId |
+ TypeKind::ObjCSel |
+ TypeKind::TemplateInstantiation(..) => return,
+
+ _ => {},
+ }
+
+ if let Some(params) = item.used_template_params(ctx) {
+ if params.is_empty() {
+ return;
+ }
+
+ let params = params.into_iter().map(|p| {
+ p.try_to_rust_ty(ctx, &())
+ .expect("template params cannot fail to be a rust type")
+ });
+
+ self.append(quote! {
+ < #( #params ),* >
+ });
+ }
}
}
@@ -376,7 +385,7 @@ impl CodeGenerator for Module {
utils::prepend_incomplete_array_types(ctx, &mut *result);
}
if ctx.need_bindegen_complex_type() {
- utils::prepend_complex_type(ctx, &mut *result);
+ utils::prepend_complex_type(&mut *result);
}
if result.saw_objc {
utils::prepend_objc_header(ctx, &mut *result);
@@ -403,27 +412,23 @@ impl CodeGenerator for Module {
return;
}
- let module = ast::ItemKind::Mod(ast::Mod {
- inner: ctx.span(),
- items: inner_items,
- });
-
let name = item.canonical_name(ctx);
- let item_builder = aster::AstBuilder::new().item().pub_();
- let item = if name == "root" {
- let attrs = &[
- "non_snake_case",
- "non_camel_case_types",
- "non_upper_case_globals",
- ];
- item_builder
- .with_attr(attributes::allow(attrs))
- .build_item_kind(name, module)
- } else {
- item_builder.build_item_kind(name, module)
- };
- result.push(item);
+ result.push(if name == "root" {
+ quote! {
+ #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
+ pub mod root {
+ #( #inner_items )*
+ }
+ }
+ } else {
+ let ident = ctx.rust_ident(name);
+ quote! {
+ pub mod #ident {
+ #( #inner_items )*
+ }
+ }
+ });
}
}
@@ -446,6 +451,8 @@ impl CodeGenerator for Var {
}
result.saw_var(&canonical_name);
+ let canonical_ident = ctx.rust_ident(&canonical_name);
+
// We can't generate bindings to static variables of templates. The
// number of actual variables for a single declaration are open ended
// and we don't know what instantiations do or don't exist.
@@ -459,17 +466,17 @@ impl CodeGenerator for Var {
let ty = self.ty().to_rust_ty_or_opaque(ctx, &());
if let Some(val) = self.val() {
- let const_item = aster::AstBuilder::new()
- .item()
- .pub_()
- .const_(canonical_name)
- .expr();
- let item = match *val {
+ match *val {
VarType::Bool(val) => {
- const_item.build(helpers::ast_ty::bool_expr(val)).build(ty)
+ result.push(quote! {
+ pub const #canonical_ident : #ty = #val ;
+ });
}
VarType::Int(val) => {
- const_item.build(helpers::ast_ty::int_expr(val)).build(ty)
+ let val = helpers::ast_ty::int_expr(val);
+ result.push(quote! {
+ pub const #canonical_ident : #ty = #val ;
+ });
}
VarType::String(ref bytes) => {
// Account the trailing zero.
@@ -477,35 +484,39 @@ impl CodeGenerator for Var {
// TODO: Here we ignore the type we just made up, probably
// we should refactor how the variable type and ty id work.
let len = bytes.len() + 1;
- let ty = quote_ty!(ctx.ext_cx(), [u8; $len]);
+ let ty = quote! {
+ [u8; #len]
+ };
match String::from_utf8(bytes.clone()) {
Ok(string) => {
- const_item
- .build(helpers::ast_ty::cstr_expr(string))
- .build(quote_ty!(ctx.ext_cx(), &'static $ty))
+ let cstr = helpers::ast_ty::cstr_expr(string);
+ result.push(quote! {
+ pub const #canonical_ident : &'static #ty = #cstr ;
+ });
}
Err(..) => {
- const_item
- .build(helpers::ast_ty::byte_array_expr(bytes))
- .build(ty)
+ let bytes = helpers::ast_ty::byte_array_expr(bytes);
+ result.push(quote! {
+ pub const #canonical_ident : #ty = #bytes ;
+ });
}
}
}
VarType::Float(f) => {
match helpers::ast_ty::float_expr(ctx, f) {
- Ok(expr) => const_item.build(expr).build(ty),
+ Ok(expr) => result.push(quote! {
+ pub const #canonical_ident : #ty = #expr ;
+ }),
Err(..) => return,
}
}
VarType::Char(c) => {
- const_item
- .build(aster::AstBuilder::new().expr().lit().byte(c))
- .build(ty)
+ result.push(quote! {
+ pub const #canonical_ident : #ty = #c ;
+ });
}
- };
-
- result.push(item);
+ }
} else {
let mut attrs = vec![];
if let Some(mangled) = self.mangled_name() {
@@ -514,19 +525,21 @@ impl CodeGenerator for Var {
attrs.push(attributes::link_name(self.name()));
}
- let item = ast::ForeignItem {
- ident: ctx.rust_ident_raw(&canonical_name),
- attrs: attrs,
- node: ast::ForeignItemKind::Static(ty, !self.is_const()),
- id: ast::DUMMY_NODE_ID,
- span: ctx.span(),
- vis: ast::Visibility::Public,
+ let mut tokens = quote! {
+ extern "C"
};
+ tokens.append("{\n");
+ if !attrs.is_empty() {
+ tokens.append_separated(attrs, "\n");
+ tokens.append("\n");
+ }
+ tokens.append("pub static mut ");
+ tokens.append(quote! { #canonical_ident });
+ tokens.append(" : ");
+ tokens.append(quote! { #ty });
+ tokens.append(";\n}");
- let item = ForeignModBuilder::new(abi::Abi::C)
- .with_foreign_item(item)
- .build(ctx);
- result.push(item);
+ result.push(tokens);
}
}
}
@@ -567,7 +580,9 @@ impl CodeGenerator for Type {
TypeKind::Comp(ref ci) => ci.codegen(ctx, result, item),
TypeKind::TemplateAlias(inner, _) |
TypeKind::Alias(inner) => {
- let inner_item = ctx.resolve_item(inner);
+ let inner_item = inner.into_resolver()
+ .through_type_refs()
+ .resolve(ctx);
let name = item.canonical_name(ctx);
// Try to catch the common pattern:
@@ -587,17 +602,25 @@ impl CodeGenerator for Type {
return;
}
- let mut used_template_params = item.used_template_params(ctx);
+ let mut outer_params = item.used_template_params(ctx)
+ .and_then(|ps| if ps.is_empty() {
+ None
+ } else {
+ Some(ps)
+ });
+
let inner_rust_type = if item.is_opaque(ctx, &()) {
- used_template_params = None;
+ outer_params = None;
self.to_opaque(ctx, item)
} else {
// Its possible that we have better layout information than
// the inner type does, so fall back to an opaque blob based
// on our layout if converting the inner item fails.
- inner_item
+ let mut inner_ty = inner_item
.try_to_rust_ty_or_opaque(ctx, &())
- .unwrap_or_else(|_| self.to_opaque(ctx, item))
+ .unwrap_or_else(|_| self.to_opaque(ctx, item));
+ inner_ty.append_implicit_template_params(ctx, inner_item);
+ inner_ty
};
{
@@ -625,68 +648,71 @@ impl CodeGenerator for Type {
}
let rust_name = ctx.rust_ident(&name);
- let mut typedef = aster::AstBuilder::new().item().pub_();
- if let Some(comment) = item.comment(ctx) {
- typedef = typedef.with_attr(attributes::doc(comment));
- }
+ let mut tokens = if let Some(comment) = item.comment(ctx) {
+ attributes::doc(comment)
+ } else {
+ quote! {}
+ };
// We prefer using `pub use` over `pub type` because of:
// https://github.com/rust-lang/rust/issues/26264
- let simple_enum_path = match inner_rust_type.node {
- ast::TyKind::Path(None, ref p) => {
- if used_template_params.is_none() &&
- inner_item
- .expect_type()
- .canonical_type(ctx)
- .is_enum() &&
- p.segments.iter().all(|p| p.parameters.is_none())
- {
- Some(p.clone())
- } else {
- None
- }
- }
- _ => None,
- };
+ if inner_rust_type.as_str()
+ .chars()
+ .all(|c| match c {
+ // These are the only characters allowed in simple
+ // paths, eg `good::dogs::Bront`.
+ 'A'...'Z' | 'a'...'z' | '0'...'9' | ':' | '_' | ' ' => true,
+ _ => false,
+ }) &&
+ outer_params.is_none() &&
+ inner_item.expect_type().canonical_type(ctx).is_enum()
+ {
+ tokens.append(quote! {
+ pub use
+ });
+ let path = top_level_path(ctx, item);
+ tokens.append_separated(path, "::");
+ tokens.append(quote! {
+ :: #inner_rust_type as #rust_name ;
+ });
+ result.push(tokens);
+ return;
+ }
- let typedef = if let Some(mut p) = simple_enum_path {
- for ident in top_level_path(ctx, item).into_iter().rev() {
- p.segments.insert(
- 0,
- ast::PathSegment {
- identifier: ident,
- parameters: None,
- },
+ tokens.append(quote! {
+ pub type #rust_name
+ });
+
+ if let Some(params) = outer_params {
+ let params: Vec<_> = params.into_iter()
+ .filter_map(|p| p.as_template_param(ctx, &()))
+ .collect();
+ if params.iter().any(|p| ctx.resolve_type(*p).is_invalid_type_param()) {
+ warn!(
+ "Item contained invalid template \
+ parameter: {:?}",
+ item
);
+ return;
}
- typedef.use_().build(p).as_(rust_name)
- } else {
- let mut generics = typedef.type_(rust_name).generics();
- if let Some(ref params) = used_template_params {
- for template_param in params {
- if let Some(id) = template_param
- .as_template_param(ctx, &())
- {
- let template_param = ctx.resolve_type(id);
- if template_param.is_invalid_type_param() {
- warn!(
- "Item contained invalid template \
- parameter: {:?}",
- item
- );
- return;
- }
- generics =
- generics.ty_param_id(
- template_param.name().unwrap(),
- );
- }
- }
- }
- generics.build().build_ty(inner_rust_type)
- };
- result.push(typedef)
+
+ let params = params.iter()
+ .map(|p| {
+ p.try_to_rust_ty(ctx, &())
+ .expect("type parameters can always convert to rust ty OK")
+ });
+
+ tokens.append(quote! {
+ < #( #params ),* >
+ });
+ }
+
+ tokens.append(quote! {
+ = #inner_rust_type ;
+ });
+
+ result.push(tokens);
}
TypeKind::Enum(ref ei) => ei.codegen(ctx, result, item),
TypeKind::ObjCId | TypeKind::ObjCSel => {
@@ -738,17 +764,12 @@ impl<'a> CodeGenerator for Vtable<'a> {
// For now, generate an empty struct, later we should generate function
// pointers and whatnot.
- let attributes = vec![attributes::repr("C")];
-
- let vtable = aster::AstBuilder::new()
- .item()
- .pub_()
- .with_attrs(attributes)
- .tuple_struct(self.canonical_name(ctx))
- .field()
- .build_ty(helpers::ast_ty::raw_type(ctx, "c_void"))
- .build();
- result.push(vtable);
+ let name = ctx.rust_ident(&self.canonical_name(ctx));
+ let void = helpers::ast_ty::raw_type(ctx, "c_void");
+ result.push(quote! {
+ #[repr(C)]
+ pub struct #name ( #void );
+ });
}
}
@@ -765,8 +786,11 @@ impl<'a> TryToRustTy for Vtable<'a> {
&self,
ctx: &BindgenContext,
_: &(),
- ) -> error::Result<P<ast::Ty>> {
- Ok(aster::ty::TyBuilder::new().id(self.canonical_name(ctx)))
+ ) -> error::Result<quote::Tokens> {
+ let name = ctx.rust_ident(self.canonical_name(ctx));
+ Ok(quote! {
+ #name
+ })
}
}
@@ -812,26 +836,28 @@ impl CodeGenerator for TemplateInstantiation {
write!(&mut fn_name, "_{}", times_seen).unwrap();
}
- let fn_name = ctx.rust_ident_raw(&fn_name);
+ let fn_name = ctx.rust_ident_raw(fn_name);
let prefix = ctx.trait_prefix();
let ident = item.to_rust_ty_or_opaque(ctx, &());
- let size_of_expr = quote_expr!(ctx.ext_cx(),
- ::$prefix::mem::size_of::<$ident>());
- let align_of_expr = quote_expr!(ctx.ext_cx(),
- ::$prefix::mem::align_of::<$ident>());
+ let size_of_expr = quote! {
+ ::#prefix::mem::size_of::<#ident>()
+ };
+ let align_of_expr = quote! {
+ ::#prefix::mem::align_of::<#ident>()
+ };
- let item = quote_item!(
- ctx.ext_cx(),
+ let item = quote! {
#[test]
- fn $fn_name() {
- assert_eq!($size_of_expr, $size,
+ fn #fn_name() {
+ assert_eq!(#size_of_expr, #size,
concat!("Size of template specialization: ",
- stringify!($ident)));
- assert_eq!($align_of_expr, $align,
+ stringify!(#ident)));
+ assert_eq!(#align_of_expr, #align,
concat!("Alignment of template specialization: ",
- stringify!($ident)));
- }).unwrap();
+ stringify!(#ident)));
+ }
+ };
result.push(item);
}
@@ -874,8 +900,8 @@ trait FieldCodegen<'a> {
methods: &mut M,
extra: Self::Extra,
) where
- F: Extend<ast::StructField>,
- M: Extend<ast::ImplItem>;
+ F: Extend<quote::Tokens>,
+ M: Extend<quote::Tokens>;
}
impl<'a> FieldCodegen<'a> for Field {
@@ -895,8 +921,8 @@ impl<'a> FieldCodegen<'a> for Field {
methods: &mut M,
_: (),
) where
- F: Extend<ast::StructField>,
- M: Extend<ast::ImplItem>,
+ F: Extend<quote::Tokens>,
+ M: Extend<quote::Tokens>,
{
match *self {
Field::DataMember(ref data) => {
@@ -950,22 +976,27 @@ impl<'a> FieldCodegen<'a> for FieldData {
methods: &mut M,
_: (),
) where
- F: Extend<ast::StructField>,
- M: Extend<ast::ImplItem>,
+ F: Extend<quote::Tokens>,
+ M: Extend<quote::Tokens>,
{
// Bitfields are handled by `FieldCodegen` implementations for
// `BitfieldUnit` and `Bitfield`.
assert!(self.bitfield().is_none());
- let field_ty = ctx.resolve_type(self.ty());
- let ty = self.ty().to_rust_ty_or_opaque(ctx, &());
+ let field_item = self.ty().into_resolver().through_type_refs().resolve(ctx);
+ let field_ty = field_item.expect_type();
+ let mut ty = self.ty().to_rust_ty_or_opaque(ctx, &());
// NB: If supported, we use proper `union` types.
let ty = if parent.is_union() && !parent.can_be_rust_union(ctx) {
if ctx.options().enable_cxx_namespaces {
- quote_ty!(ctx.ext_cx(), root::__BindgenUnionField<$ty>)
+ quote! {
+ root::__BindgenUnionField<#ty>
+ }
} else {
- quote_ty!(ctx.ext_cx(), __BindgenUnionField<$ty>)
+ quote! {
+ __BindgenUnionField<#ty>
+ }
}
} else if let Some(item) = field_ty.is_incomplete_array(ctx) {
result.saw_incomplete_array();
@@ -973,20 +1004,25 @@ impl<'a> FieldCodegen<'a> for FieldData {
let inner = item.to_rust_ty_or_opaque(ctx, &());
if ctx.options().enable_cxx_namespaces {
- quote_ty!(ctx.ext_cx(), root::__IncompleteArrayField<$inner>)
+ quote! {
+ root::__IncompleteArrayField<#inner>
+ }
} else {
- quote_ty!(ctx.ext_cx(), __IncompleteArrayField<$inner>)
+ quote! {
+ __IncompleteArrayField<#inner>
+ }
}
} else {
+ ty.append_implicit_template_params(ctx, field_item);
ty
};
- let mut attrs = vec![];
+ let mut field = quote! {};
if ctx.options().generate_comments {
if let Some(raw_comment) = self.comment() {
let comment =
comment::preprocess(raw_comment, codegen_depth + 1);
- attrs.push(attributes::doc(comment))
+ field = attributes::doc(comment);
}
}
@@ -994,6 +1030,7 @@ impl<'a> FieldCodegen<'a> for FieldData {
self.name()
.map(|name| ctx.rust_mangle(name).into_owned())
.unwrap_or_else(|| anon_field_names.next().unwrap());
+ let field_ident = ctx.rust_ident_raw(field_name.as_str());
if !parent.is_union() {
if let Some(padding_field) =
@@ -1010,14 +1047,16 @@ impl<'a> FieldCodegen<'a> for FieldData {
let accessor_kind =
self.annotations().accessor_kind().unwrap_or(accessor_kind);
- let mut field = StructFieldBuilder::named(&field_name);
-
- if !is_private {
- field = field.pub_();
+ if is_private {
+ field.append(quote! {
+ #field_ident : #ty ,
+ });
+ } else {
+ field.append(quote! {
+ pub #field_ident : #ty ,
+ });
}
- let field = field.with_attrs(attrs).build_ty(ty.clone());
-
fields.extend(Some(field));
// TODO: Factor the following code out, please!
@@ -1025,98 +1064,58 @@ impl<'a> FieldCodegen<'a> for FieldData {
return;
}
- let getter_name = ctx.rust_ident_raw(&format!("get_{}", field_name));
+ let getter_name = ctx.rust_ident_raw(format!("get_{}", field_name));
let mutable_getter_name =
- ctx.rust_ident_raw(&format!("get_{}_mut", field_name));
- let field_name = ctx.rust_ident_raw(&field_name);
+ ctx.rust_ident_raw(format!("get_{}_mut", field_name));
+ let field_name = ctx.rust_ident_raw(field_name);
- let accessor_methods_impl = match accessor_kind {
+ methods.extend(Some(match accessor_kind {
FieldAccessorKind::None => unreachable!(),
FieldAccessorKind::Regular => {
- quote_item!(ctx.ext_cx(),
- impl X {
- #[inline]
- pub fn $getter_name(&self) -> &$ty {
- &self.$field_name
- }
+ quote! {
+ #[inline]
+ pub fn #getter_name(&self) -> & #ty {
+ &self.#field_name
+ }
- #[inline]
- pub fn $mutable_getter_name(&mut self) -> &mut $ty {
- &mut self.$field_name
- }
+ #[inline]
+ pub fn #mutable_getter_name(&mut self) -> &mut #ty {
+ &mut self.#field_name
}
- )
+ }
}
FieldAccessorKind::Unsafe => {
- quote_item!(ctx.ext_cx(),
- impl X {
- #[inline]
- pub unsafe fn $getter_name(&self) -> &$ty {
- &self.$field_name
- }
+ quote! {
+ #[inline]
+ pub unsafe fn #getter_name(&self) -> & #ty {
+ &self.#field_name
+ }
- #[inline]
- pub unsafe fn $mutable_getter_name(&mut self)
- -> &mut $ty {
- &mut self.$field_name
- }
+ #[inline]
+ pub unsafe fn #mutable_getter_name(&mut self) -> &mut #ty {
+ &mut self.#field_name
}
- )
+ }
}
FieldAccessorKind::Immutable => {
- quote_item!(ctx.ext_cx(),
- impl X {
- #[inline]
- pub fn $getter_name(&self) -> &$ty {
- &self.$field_name
- }
+ quote! {
+ #[inline]
+ pub fn #getter_name(&self) -> & #ty {
+ &self.#field_name
}
- )
- }
- };
-
- match accessor_methods_impl.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, ref items) => {
- methods.extend(items.clone())
+ }
}
- _ => unreachable!(),
- }
+ }));
}
}
impl BitfieldUnit {
/// Get the constructor name for this bitfield unit.
- fn ctor_name(&self, ctx: &BindgenContext) -> ast::Ident {
- let ctor_name = format!("new_bitfield_{}", self.nth());
- ctx.ext_cx().ident_of(&ctor_name)
- }
-
- /// Get the initial bitfield unit constructor that just returns 0. This will
- /// then be extended by each bitfield in the unit. See `extend_ctor_impl`
- /// below.
- fn initial_ctor_impl(
- &self,
- ctx: &BindgenContext,
- unit_field_int_ty: &P<ast::Ty>,
- ) -> P<ast::Item> {
- let ctor_name = self.ctor_name(ctx);
-
- // If supported, add the const.
- let fn_prefix = if ctx.options().rust_features().const_fn() {
- quote_tokens!(ctx.ext_cx(), pub const fn)
- } else {
- quote_tokens!(ctx.ext_cx(), pub fn)
- };
-
- quote_item!(
- ctx.ext_cx(),
- impl XxxUnused {
- #[inline]
- $fn_prefix $ctor_name() -> $unit_field_int_ty {
- 0
- }
- }
- ).unwrap()
+ fn ctor_name(&self) -> quote::Tokens {
+ let ctor_name = quote::Ident::new(format!("new_bitfield_{}", self.nth()));
+ quote! {
+ #ctor_name
+ }
}
}
@@ -1131,57 +1130,26 @@ impl Bitfield {
fn extend_ctor_impl(
&self,
ctx: &BindgenContext,
- parent: &CompInfo,
- ctor_impl: P<ast::Item>,
- ctor_name: &ast::Ident,
- unit_field_int_ty: &P<ast::Ty>,
- ) -> P<ast::Item> {
- let items = match ctor_impl.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, items) => items,
- _ => unreachable!(),
- };
-
- assert_eq!(items.len(), 1);
- let (sig, body) = match items[0].node {
- ast::ImplItemKind::Method(ref sig, ref body) => (sig, body),
- _ => unreachable!(),
- };
-
- let params = sig.decl.clone().unwrap().inputs;
- let param_name = bitfield_getter_name(ctx, parent, self.name());
-
- let bitfield_ty_item = ctx.resolve_item(self.ty());
- let bitfield_ty = bitfield_ty_item.expect_type();
+ param_name: quote::Tokens,
+ ctor_impl: quote::Tokens,
+ unit_field_int_ty: &quote::Tokens,
+ ) -> quote::Tokens {
+ let bitfield_ty = ctx.resolve_type(self.ty());
let bitfield_ty_layout = bitfield_ty.layout(ctx).expect(
"Bitfield without layout? Gah!",
);
let bitfield_int_ty = helpers::blob(bitfield_ty_layout);
- let bitfield_ty =
- bitfield_ty.to_rust_ty_or_opaque(ctx, bitfield_ty_item);
let offset = self.offset_into_unit();
let mask = self.mask();
- // If supported, add the const.
- let fn_prefix = if ctx.options().rust_features().const_fn() {
- quote_tokens!(ctx.ext_cx(), pub const fn)
- } else {
- quote_tokens!(ctx.ext_cx(), pub fn)
- };
-
- // Don't use variables or blocks because const function does not allow them.
- quote_item!(
- ctx.ext_cx(),
- impl XxxUnused {
- #[inline]
- $fn_prefix $ctor_name($params $param_name : $bitfield_ty)
- -> $unit_field_int_ty {
- ($body |
- (($param_name as $bitfield_int_ty as $unit_field_int_ty) << $offset) &
- ($mask as $unit_field_int_ty))
- }
- }
- ).unwrap()
+ // Don't use variables or blocks because const functions do not allow
+ // them.
+ quote! {
+ (#ctor_impl |
+ ((#param_name as #bitfield_int_ty as #unit_field_int_ty) << #offset) &
+ (#mask as #unit_field_int_ty))
+ }
}
}
@@ -1202,15 +1170,16 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
methods: &mut M,
_: (),
) where
- F: Extend<ast::StructField>,
- M: Extend<ast::ImplItem>,
+ F: Extend<quote::Tokens>,
+ M: Extend<quote::Tokens>,
{
let field_ty = helpers::blob(self.layout());
let unit_field_name = format!("_bitfield_{}", self.nth());
+ let unit_field_ident = ctx.rust_ident(&unit_field_name);
- let field = StructFieldBuilder::named(&unit_field_name)
- .pub_()
- .build_ty(field_ty.clone());
+ let field = quote! {
+ pub #unit_field_ident : #field_ty ,
+ };
fields.extend(Some(field));
let mut field_int_size = self.layout().size;
@@ -1219,10 +1188,10 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
}
let unit_field_int_ty = match field_int_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),
+ 8 => quote! { u64 },
+ 4 => quote! { u32 },
+ 2 => quote! { u16 },
+ 1 => quote! { u8 },
size => {
debug_assert!(size > 8);
// Can't generate bitfield accessors for unit sizes larget than
@@ -1232,8 +1201,9 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
}
};
- let ctor_name = self.ctor_name(ctx);
- let mut ctor_impl = self.initial_ctor_impl(ctx, &unit_field_int_ty);
+ let ctor_name = self.ctor_name();
+ let mut ctor_params = vec![];
+ let mut ctor_impl = quote! { 0 };
for bf in self.bitfields() {
bf.codegen(
@@ -1250,23 +1220,36 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
(&unit_field_name, unit_field_int_ty.clone()),
);
+ let param_name = bitfield_getter_name(ctx, parent, bf.name());
+ let bitfield_ty_item = ctx.resolve_item(bf.ty());
+ let bitfield_ty = bitfield_ty_item.expect_type();
+ let bitfield_ty =
+ bitfield_ty.to_rust_ty_or_opaque(ctx, bitfield_ty_item);
+
+ ctor_params.push(quote! {
+ #param_name : #bitfield_ty
+ });
ctor_impl = bf.extend_ctor_impl(
ctx,
- parent,
+ param_name,
ctor_impl,
- &ctor_name,
&unit_field_int_ty,
);
}
- match ctor_impl.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, items) => {
- assert_eq!(items.len(), 1);
- methods.extend(items.into_iter());
- }
- _ => unreachable!(),
+ let const_ = if ctx.options().rust_features().const_fn() {
+ quote! { const }
+ } else {
+ quote! { }
};
+ methods.extend(Some(quote! {
+ #[inline]
+ pub #const_ fn #ctor_name ( #( #ctor_params ),* ) -> #unit_field_int_ty {
+ #ctor_impl
+ }
+ }));
+
struct_layout.saw_bitfield_unit(self.layout());
}
}
@@ -1297,23 +1280,25 @@ fn bitfield_getter_name(
ctx: &BindgenContext,
parent: &CompInfo,
bitfield_name: &str,
-) -> ast::Ident {
+) -> quote::Tokens {
let name = ctx.rust_mangle(bitfield_name);
if parent_has_method(ctx, parent, &name) {
let mut name = name.to_string();
name.push_str("_bindgen_bitfield");
- return ctx.ext_cx().ident_of(&name);
+ let name = ctx.rust_ident(name);
+ return quote! { #name };
}
- ctx.ext_cx().ident_of(&name)
+ let name = ctx.rust_ident(name);
+ quote! { #name }
}
fn bitfield_setter_name(
ctx: &BindgenContext,
parent: &CompInfo,
bitfield_name: &str,
-) -> ast::Ident {
+) -> quote::Tokens {
let setter = format!("set_{}", bitfield_name);
let mut setter = ctx.rust_mangle(&setter).to_string();
@@ -1321,11 +1306,12 @@ fn bitfield_setter_name(
setter.push_str("_bindgen_bitfield");
}
- ctx.ext_cx().ident_of(&setter)
+ let setter = ctx.rust_ident(setter);
+ quote! { #setter }
}
impl<'a> FieldCodegen<'a> for Bitfield {
- type Extra = (&'a str, P<ast::Ty>);
+ type Extra = (&'a str, quote::Tokens);
fn codegen<F, M>(
&self,
@@ -1339,15 +1325,15 @@ impl<'a> FieldCodegen<'a> for Bitfield {
_struct_layout: &mut StructLayoutTracker,
_fields: &mut F,
methods: &mut M,
- (unit_field_name, unit_field_int_ty): (&'a str, P<ast::Ty>),
+ (unit_field_name, unit_field_int_ty): (&'a str, quote::Tokens),
) where
- F: Extend<ast::StructField>,
- M: Extend<ast::ImplItem>,
+ F: Extend<quote::Tokens>,
+ M: Extend<quote::Tokens>,
{
let prefix = ctx.trait_prefix();
let getter_name = bitfield_getter_name(ctx, parent, self.name());
let setter_name = bitfield_setter_name(ctx, parent, self.name());
- let unit_field_ident = ctx.ext_cx().ident_of(unit_field_name);
+ let unit_field_ident = quote::Ident::new(unit_field_name);
let bitfield_ty_item = ctx.resolve_item(self.ty());
let bitfield_ty = bitfield_ty_item.expect_type();
@@ -1363,67 +1349,57 @@ impl<'a> FieldCodegen<'a> for Bitfield {
let offset = self.offset_into_unit();
let mask = self.mask();
- let impl_item = quote_item!(
- ctx.ext_cx(),
- impl XxxIgnored {
- #[inline]
- pub fn $getter_name(&self) -> $bitfield_ty {
- let mut unit_field_val: $unit_field_int_ty = unsafe {
- ::$prefix::mem::uninitialized()
- };
+ methods.extend(Some(quote! {
+ #[inline]
+ pub fn #getter_name(&self) -> #bitfield_ty {
+ let mut unit_field_val: #unit_field_int_ty = unsafe {
+ ::#prefix::mem::uninitialized()
+ };
- unsafe {
- ::$prefix::ptr::copy_nonoverlapping(
- &self.$unit_field_ident as *const _ as *const u8,
- &mut unit_field_val as *mut $unit_field_int_ty as *mut u8,
- ::$prefix::mem::size_of::<$unit_field_int_ty>(),
- )
- };
+ unsafe {
+ ::#prefix::ptr::copy_nonoverlapping(
+ &self.#unit_field_ident as *const _ as *const u8,
+ &mut unit_field_val as *mut #unit_field_int_ty as *mut u8,
+ ::#prefix::mem::size_of::<#unit_field_int_ty>(),
+ )
+ };
- let mask = $mask as $unit_field_int_ty;
- let val = (unit_field_val & mask) >> $offset;
- unsafe {
- ::$prefix::mem::transmute(val as $bitfield_int_ty)
- }
+ let mask = #mask as #unit_field_int_ty;
+ let val = (unit_field_val & mask) >> #offset;
+ unsafe {
+ ::#prefix::mem::transmute(val as #bitfield_int_ty)
}
+ }
- #[inline]
- pub fn $setter_name(&mut self, val: $bitfield_ty) {
- let mask = $mask as $unit_field_int_ty;
- let val = val as $bitfield_int_ty as $unit_field_int_ty;
+ #[inline]
+ pub fn #setter_name(&mut self, val: #bitfield_ty) {
+ let mask = #mask as #unit_field_int_ty;
+ let val = val as #bitfield_int_ty as #unit_field_int_ty;
- let mut unit_field_val: $unit_field_int_ty = unsafe {
- ::$prefix::mem::uninitialized()
- };
+ let mut unit_field_val: #unit_field_int_ty = unsafe {
+ ::#prefix::mem::uninitialized()
+ };
- unsafe {
- ::$prefix::ptr::copy_nonoverlapping(
- &self.$unit_field_ident as *const _ as *const u8,
- &mut unit_field_val as *mut $unit_field_int_ty as *mut u8,
- ::$prefix::mem::size_of::<$unit_field_int_ty>(),
- )
- };
+ unsafe {
+ ::#prefix::ptr::copy_nonoverlapping(
+ &self.#unit_field_ident as *const _ as *const u8,
+ &mut unit_field_val as *mut #unit_field_int_ty as *mut u8,
+ ::#prefix::mem::size_of::< #unit_field_int_ty >(),
+ )
+ };
- unit_field_val &= !mask;
- unit_field_val |= (val << $offset) & mask;
+ unit_field_val &= !mask;
+ unit_field_val |= (val << #offset) & mask;
- unsafe {
- ::$prefix::ptr::copy_nonoverlapping(
- &unit_field_val as *const _ as *const u8,
- &mut self.$unit_field_ident as *mut _ as *mut u8,
- ::$prefix::mem::size_of::<$unit_field_int_ty>(),
- );
- }
+ unsafe {
+ ::#prefix::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self.#unit_field_ident as *mut _ as *mut u8,
+ ::#prefix::mem::size_of::< #unit_field_int_ty >(),
+ );
}
}
- ).unwrap();
-
- match impl_item.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, items) => {
- methods.extend(items.into_iter());
- }
- _ => unreachable!(),
- };
+ }));
}
}
@@ -1454,13 +1430,12 @@ impl CodeGenerator for CompInfo {
// collisions.
if self.is_forward_declaration() && used_template_params.is_none() {
let struct_name = item.canonical_name(ctx);
- let struct_name = ctx.rust_ident_raw(&struct_name);
- let tuple_struct = quote_item!(ctx.ext_cx(),
- #[repr(C)]
- #[derive(Debug, Copy, Clone)]
- pub struct $struct_name { _unused: [u8; 0] };
- )
- .unwrap();
+ let struct_name = ctx.rust_ident_raw(struct_name);
+ let tuple_struct = quote! {
+ #[repr(C)]
+ #[derive(Debug, Copy, Clone)]
+ pub struct #struct_name { _unused: [u8; 0] }
+ };
result.push(tuple_struct);
return;
}
@@ -1527,18 +1502,17 @@ impl CodeGenerator for CompInfo {
}
let canonical_name = item.canonical_name(ctx);
- let builder = if is_union && self.can_be_rust_union(ctx) {
- aster::AstBuilder::new()
- .item()
- .pub_()
- .with_attrs(attributes)
- .union_(&canonical_name)
+ let canonical_ident = ctx.rust_ident(&canonical_name);
+ let mut tokens = if is_union && self.can_be_rust_union(ctx) {
+ quote! {
+ #( #attributes )*
+ pub union #canonical_ident
+ }
} else {
- aster::AstBuilder::new()
- .item()
- .pub_()
- .with_attrs(attributes)
- .struct_(&canonical_name)
+ quote! {
+ #( #attributes )*
+ pub struct #canonical_ident
+ }
};
// Generate the vtable from the method list if appropriate.
@@ -1567,15 +1541,13 @@ impl CodeGenerator for CompInfo {
let vtable_type = vtable
.try_to_rust_ty(ctx, &())
.expect("vtable to Rust type conversion is infallible")
- .to_ptr(true, ctx.span());
+ .to_ptr(true);
- let vtable_field = StructFieldBuilder::named("vtable_")
- .pub_()
- .build_ty(vtable_type);
+ fields.push(quote! {
+ pub vtable_: #vtable_type ,
+ });
struct_layout.saw_vtable();
-
- fields.push(vtable_field);
}
for (i, base) in self.base_members().iter().enumerate() {
@@ -1596,17 +1568,17 @@ impl CodeGenerator for CompInfo {
}
let inner = base.ty.to_rust_ty_or_opaque(ctx, &());
- let field_name = if i == 0 {
+ let field_name = ctx.rust_ident(if i == 0 {
"_base".into()
} else {
format!("_base_{}", i)
- };
+ });
struct_layout.saw_base(base_ty);
- let field =
- StructFieldBuilder::named(field_name).pub_().build_ty(inner);
- fields.extend(Some(field));
+ fields.push(quote! {
+ pub #field_name : #inner ,
+ });
}
}
if is_union {
@@ -1647,17 +1619,17 @@ impl CodeGenerator for CompInfo {
let layout = layout.expect("Unable to get layout information?");
let ty = helpers::blob(layout);
- let field = if self.can_be_rust_union(ctx) {
- StructFieldBuilder::named("_bindgen_union_align").build_ty(ty)
+ fields.push(if self.can_be_rust_union(ctx) {
+ quote! {
+ _bindgen_union_align: #ty ,
+ }
} else {
struct_layout.saw_union(layout);
- StructFieldBuilder::named("bindgen_union_field")
- .pub_()
- .build_ty(ty)
- };
-
- fields.push(field);
+ quote! {
+ pub bindgen_union_field: #ty ,
+ }
+ });
}
if is_opaque {
@@ -1668,11 +1640,9 @@ impl CodeGenerator for CompInfo {
match layout {
Some(l) => {
let ty = helpers::blob(l);
- let field = StructFieldBuilder::named(
- "_bindgen_opaque_blob",
- ).pub_()
- .build_ty(ty);
- fields.push(field);
+ fields.push(quote! {
+ pub _bindgen_opaque_blob: #ty ,
+ });
}
None => {
warn!("Opaque type without layout! Expect dragons!");
@@ -1713,41 +1683,45 @@ impl CodeGenerator for CompInfo {
if has_address {
let ty = helpers::blob(Layout::new(1, 1));
- let field =
- StructFieldBuilder::named("_address").pub_().build_ty(ty);
- fields.push(field);
+ fields.push(quote! {
+ pub _address: #ty,
+ });
}
}
- let mut generics = aster::AstBuilder::new().generics();
+ let mut generics = quote! {};
if let Some(ref params) = used_template_params {
- for (idx, ty) in params.iter().enumerate() {
- let param = ctx.resolve_type(*ty);
- let name = param.name().unwrap();
- let ident = ctx.rust_ident(name);
+ if !params.is_empty() {
+ let mut param_names = vec![];
- generics = generics.ty_param_id(ident);
+ for (idx, ty) in params.iter().enumerate() {
+ let param = ctx.resolve_type(*ty);
+ let name = param.name().unwrap();
+ let ident = ctx.rust_ident(name);
+ param_names.push(ident.clone());
- let prefix = ctx.trait_prefix();
- let phantom_ty = quote_ty!(
- ctx.ext_cx(),
- ::$prefix::marker::PhantomData<::$prefix::cell::UnsafeCell<$ident>>);
- let phantom_field = StructFieldBuilder::named(
- format!("_phantom_{}", idx),
- ).pub_()
- .build_ty(phantom_ty);
- fields.push(phantom_field);
+ let prefix = ctx.trait_prefix();
+ let field_name = ctx.rust_ident(format!("_phantom_{}", idx));
+ fields.push(quote! {
+ pub #field_name : ::#prefix::marker::PhantomData<
+ ::#prefix::cell::UnsafeCell<#ident>
+ > ,
+ });
+ }
+
+ generics = quote! {
+ < #( #param_names ),* >
+ };
}
}
- let generics = generics.build();
-
- let rust_struct = builder
- .with_generics(generics.clone())
- .with_fields(fields)
- .build();
- result.push(rust_struct);
+ tokens.append(quote! {
+ #generics {
+ #( #fields )*
+ }
+ });
+ result.push(tokens);
// Generate the inner types and all that stuff.
//
@@ -1765,7 +1739,7 @@ impl CodeGenerator for CompInfo {
if self.found_unknown_attr() {
warn!(
"Type {} has an unkown attribute that may affect layout",
- canonical_name
+ canonical_ident
);
}
@@ -1779,14 +1753,15 @@ impl CodeGenerator for CompInfo {
if ctx.options().layout_tests {
if let Some(layout) = layout {
let fn_name =
- format!("bindgen_test_layout_{}", canonical_name);
- let fn_name = ctx.rust_ident_raw(&fn_name);
- let type_name = ctx.rust_ident_raw(&canonical_name);
+ format!("bindgen_test_layout_{}", canonical_ident);
+ let fn_name = ctx.rust_ident_raw(fn_name);
let prefix = ctx.trait_prefix();
- let size_of_expr = quote_expr!(ctx.ext_cx(),
- ::$prefix::mem::size_of::<$type_name>());
- let align_of_expr = quote_expr!(ctx.ext_cx(),
- ::$prefix::mem::align_of::<$type_name>());
+ let size_of_expr = quote! {
+ ::#prefix::mem::size_of::<#canonical_ident>()
+ };
+ let align_of_expr = quote! {
+ ::#prefix::mem::align_of::<#canonical_ident>()
+ };
let size = layout.size;
let align = layout.align;
@@ -1795,11 +1770,12 @@ impl CodeGenerator for CompInfo {
// FIXME when [RFC 1358](https://github.com/rust-lang/rust/issues/33626) ready
None
} else {
- quote_item!(ctx.ext_cx(),
- assert_eq!($align_of_expr,
- $align,
- concat!("Alignment of ", stringify!($type_name)));
- )
+ Some(quote! {
+ assert_eq!(#align_of_expr,
+ #align,
+ concat!("Alignment of ", stringify!(#canonical_ident)));
+
+ })
};
// FIXME when [issue #465](https://github.com/rust-lang-nursery/rust-bindgen/issues/465) ready
@@ -1814,43 +1790,43 @@ impl CodeGenerator for CompInfo {
let check_field_offset =
if should_skip_field_offset_checks {
- None
+ vec![]
} else {
let asserts = self.fields()
- .iter()
- .filter_map(|field| match *field {
- Field::DataMember(ref f) if f.name().is_some() => Some(f),
- _ => None,
- })
- .flat_map(|field| {
- let name = field.name().unwrap();
- field.offset().and_then(|offset| {
- let field_offset = offset / 8;
- let field_name = ctx.rust_ident(name);
-
- quote_item!(ctx.ext_cx(),
- assert_eq!(unsafe { &(*(0 as *const $type_name)).$field_name as *const _ as usize },
- $field_offset,
- concat!("Alignment of field: ", stringify!($type_name), "::", stringify!($field_name)));
- )
- })
- })
- .collect::<Vec<P<ast::Item>>>();
-
- Some(asserts)
+ .iter()
+ .filter_map(|field| match *field {
+ Field::DataMember(ref f) if f.name().is_some() => Some(f),
+ _ => None,
+ })
+ .flat_map(|field| {
+ let name = field.name().unwrap();
+ field.offset().and_then(|offset| {
+ let field_offset = offset / 8;
+ let field_name = ctx.rust_ident(name);
+
+ Some(quote! {
+ assert_eq!(unsafe { &(*(0 as *const #canonical_ident)).#field_name as *const _ as usize },
+ #field_offset,
+ concat!("Alignment of field: ", stringify!(#canonical_ident), "::", stringify!(#field_name)));
+ })
+ })
+ })
+ .collect::<Vec<quote::Tokens>>();
+
+ asserts
};
- let item = quote_item!(ctx.ext_cx(),
+ let item = quote! {
#[test]
- fn $fn_name() {
- assert_eq!($size_of_expr,
- $size,
- concat!("Size of: ", stringify!($type_name)));
+ fn #fn_name() {
+ assert_eq!(#size_of_expr,
+ #size,
+ concat!("Size of: ", stringify!(#canonical_ident)));
- $check_struct_align
- $check_field_offset
- })
- .unwrap();
+ #check_struct_align
+ #( #check_field_offset )*
+ }
+ };
result.push(item);
}
}
@@ -1907,63 +1883,25 @@ impl CodeGenerator for CompInfo {
// NB: We can't use to_rust_ty here since for opaque types this tries to
// use the specialization knowledge to generate a blob field.
- let ty_for_impl = aster::AstBuilder::new()
- .ty()
- .path()
- .segment(&canonical_name)
- .with_generics(generics.clone())
- .build()
- .build();
+ let ty_for_impl = quote! {
+ #canonical_ident #generics
+ };
if needs_clone_impl {
- let impl_ = quote_item!(ctx.ext_cx(),
- impl X {
+ result.push(quote! {
+ impl #generics Clone for #ty_for_impl {
fn clone(&self) -> Self { *self }
}
- );
-
- let impl_ = match impl_.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, ref items) => items.clone(),
- _ => unreachable!(),
- };
-
- let clone_impl = aster::AstBuilder::new()
- .item()
- .impl_()
- .trait_()
- .id("Clone")
- .build()
- .with_generics(generics.clone())
- .with_items(impl_)
- .build_ty(ty_for_impl.clone());
-
- result.push(clone_impl);
+ });
}
if needs_default_impl {
let prefix = ctx.trait_prefix();
- let impl_ = quote_item!(ctx.ext_cx(),
- impl X {
- fn default() -> Self { unsafe { ::$prefix::mem::zeroed() } }
+ result.push(quote! {
+ impl #generics Default for #ty_for_impl {
+ fn default() -> Self { unsafe { ::#prefix::mem::zeroed() } }
}
- );
-
- let impl_ = match impl_.unwrap().node {
- ast::ItemKind::Impl(_, _, _, _, _, ref items) => items.clone(),
- _ => unreachable!(),
- };
-
- let default_impl = aster::AstBuilder::new()
- .item()
- .impl_()
- .trait_()
- .id("Default")
- .build()
- .with_generics(generics.clone())
- .with_items(impl_)
- .build_ty(ty_for_impl.clone());
-
- result.push(default_impl);
+ });
}
if needs_debug_impl {
@@ -1974,27 +1912,19 @@ impl CodeGenerator for CompInfo {
self.kind(),
);
- let debug_impl = aster::AstBuilder::new()
- .item()
- .impl_()
- .trait_()
- .id("::std::fmt::Debug")
- .build()
- .with_generics(generics.clone())
- .with_items(impl_)
- .build_ty(ty_for_impl.clone());
-
- result.push(debug_impl);
+ result.push(quote! {
+ impl #generics ::std::fmt::Debug for #ty_for_impl {
+ #impl_
+ }
+ });
}
if !methods.is_empty() {
- let methods = aster::AstBuilder::new()
- .item()
- .impl_()
- .with_generics(generics)
- .with_items(methods)
- .build_ty(ty_for_impl);
- result.push(methods);
+ result.push(quote! {
+ impl #generics #ty_for_impl {
+ #( #methods )*
+ }
+ });
}
}
}
@@ -2003,7 +1933,7 @@ trait MethodCodegen {
fn codegen_method<'a>(
&self,
ctx: &BindgenContext,
- methods: &mut Vec<ast::ImplItem>,
+ methods: &mut Vec<quote::Tokens>,
method_names: &mut HashMap<String, usize>,
result: &mut CodegenResult<'a>,
parent: &CompInfo,
@@ -2014,7 +1944,7 @@ impl MethodCodegen for Method {
fn codegen_method<'a>(
&self,
ctx: &BindgenContext,
- methods: &mut Vec<ast::ImplItem>,
+ methods: &mut Vec<quote::Tokens>,
method_names: &mut HashMap<String, usize>,
result: &mut CodegenResult<'a>,
_parent: &CompInfo,
@@ -2067,45 +1997,15 @@ impl MethodCodegen for Method {
name.push_str(&count.to_string());
}
- let function_name = function_item.canonical_name(ctx);
- let mut fndecl = utils::rust_fndecl_from_signature(ctx, signature_item)
- .unwrap();
+ let function_name = ctx.rust_ident(function_item.canonical_name(ctx));
+ let mut args = utils::fnsig_arguments(ctx, signature);
+ let mut ret = utils::fnsig_return_ty(ctx, signature);
+
if !self.is_static() && !self.is_constructor() {
- let mutability = if self.is_const() {
- ast::Mutability::Immutable
+ args[0] = if self.is_const() {
+ quote! { &self }
} else {
- ast::Mutability::Mutable
- };
-
- assert!(!fndecl.inputs.is_empty());
-
- // FIXME: use aster here.
- fndecl.inputs[0] = ast::Arg {
- ty: P(ast::Ty {
- id: ast::DUMMY_NODE_ID,
- node: ast::TyKind::Rptr(
- None,
- ast::MutTy {
- ty: P(ast::Ty {
- id: ast::DUMMY_NODE_ID,
- node: ast::TyKind::ImplicitSelf,
- span: ctx.span(),
- }),
- mutbl: mutability,
- },
- ),
- span: ctx.span(),
- }),
- pat: P(ast::Pat {
- id: ast::DUMMY_NODE_ID,
- node: ast::PatKind::Ident(
- ast::BindingMode::ByValue(ast::Mutability::Immutable),
- respan(ctx.span(), ctx.ext_cx().ident_of("self")),
- None,
- ),
- span: ctx.span(),
- }),
- id: ast::DUMMY_NODE_ID,
+ quote! { &mut self }
};
}
@@ -2115,19 +2015,10 @@ impl MethodCodegen for Method {
// Note that constructors in Clang are represented as functions with
// return-type = void.
if self.is_constructor() {
- fndecl.inputs.remove(0);
- fndecl.output =
- ast::FunctionRetTy::Ty(quote_ty!(ctx.ext_cx(), Self));
+ args.remove(0);
+ ret = quote! { -> Self };
}
- let sig = ast::MethodSig {
- unsafety: ast::Unsafety::Unsafe,
- abi: abi::Abi::Rust,
- decl: P(fndecl),
- generics: ast::Generics::default(),
- constness: respan(ctx.span(), ast::Constness::NotConst),
- };
-
let mut exprs =
helpers::ast_ty::arguments_from_signature(&signature, ctx);
@@ -2138,67 +2029,60 @@ impl MethodCodegen for Method {
if self.is_constructor() {
let prefix = ctx.trait_prefix();
let tmp_variable_decl =
- quote_stmt!(ctx.ext_cx(),
- let mut __bindgen_tmp = ::$prefix::mem::uninitialized())
- .unwrap();
+ quote! {
+ let mut __bindgen_tmp = ::#prefix::mem::uninitialized()
+ };
stmts.push(tmp_variable_decl);
- exprs[0] = quote_expr!(ctx.ext_cx(), &mut __bindgen_tmp);
+ exprs[0] = quote! {
+ &mut __bindgen_tmp
+ };
} else if !self.is_static() {
assert!(!exprs.is_empty());
- exprs[0] = quote_expr!(ctx.ext_cx(), self);
+ exprs[0] = quote! {
+ self
+ };
};
- let call = aster::expr::ExprBuilder::new()
- .call()
- .id(function_name)
- .with_args(exprs)
- .build();
+ let call = quote! {
+ #function_name (#( #exprs ),* )
+ };
- stmts.push(ast::Stmt {
- id: ast::DUMMY_NODE_ID,
- node: ast::StmtKind::Expr(call),
- span: ctx.span(),
- });
+ stmts.push(call);
if self.is_constructor() {
- stmts.push(quote_stmt!(ctx.ext_cx(), __bindgen_tmp).unwrap());
+ stmts.push(quote! {
+ __bindgen_tmp
+ });
}
- let block = ast::Block {
- stmts: stmts,
- id: ast::DUMMY_NODE_ID,
- rules: ast::BlockCheckMode::Default,
- span: ctx.span(),
+ let block = quote! {
+ #( #stmts );*
};
let mut attrs = vec![];
attrs.push(attributes::inline());
- let item = ast::ImplItem {
- id: ast::DUMMY_NODE_ID,
- ident: ctx.rust_ident(&name),
- vis: ast::Visibility::Public,
- attrs: attrs,
- node: ast::ImplItemKind::Method(sig, P(block)),
- defaultness: ast::Defaultness::Final,
- span: ctx.span(),
- };
-
- methods.push(item);
+ let name = ctx.rust_ident(&name);
+ methods.push(quote! {
+ #[inline]
+ pub unsafe fn #name ( #( #args ),* ) #ret {
+ #block
+ }
+ });
}
}
/// A helper type to construct enums, either bitfield ones or rust-style ones.
enum EnumBuilder<'a> {
- Rust(aster::item::ItemEnumBuilder<aster::invoke::Identity>),
+ Rust(quote::Tokens),
Bitfield {
canonical_name: &'a str,
- aster: P<ast::Item>,
+ tokens: quote::Tokens,
},
- Consts { aster: P<ast::Item> },
+ Consts(Vec<quote::Tokens>),
ModuleConsts {
module_name: &'a str,
- module_items: Vec<P<ast::Item>>,
+ module_items: Vec<quote::Tokens>,
},
}
@@ -2206,41 +2090,47 @@ impl<'a> EnumBuilder<'a> {
/// Create a new enum given an item builder, a canonical name, a name for
/// the representation, and whether it should be represented as a rust enum.
fn new(
- aster: aster::item::ItemBuilder<aster::invoke::Identity>,
name: &'a str,
- repr: P<ast::Ty>,
+ attrs: Vec<quote::Tokens>,
+ repr: quote::Tokens,
bitfield_like: bool,
constify: bool,
constify_module: bool,
) -> Self {
+ let ident = quote::Ident::new(name);
if bitfield_like {
EnumBuilder::Bitfield {
canonical_name: name,
- aster: aster
- .tuple_struct(name)
- .field()
- .pub_()
- .build_ty(repr)
- .build(),
+ tokens: quote! {
+ #( #attrs )*
+ pub struct #ident (pub #repr);
+ },
}
} else if constify {
if constify_module {
- let type_definition = aster::item::ItemBuilder::new()
- .pub_()
- .type_(CONSTIFIED_ENUM_MODULE_REPR_NAME)
- .build_ty(repr);
+ let ident = quote::Ident::new(CONSTIFIED_ENUM_MODULE_REPR_NAME);
+ let type_definition = quote! {
+ pub type #ident = #repr;
+ };
EnumBuilder::ModuleConsts {
module_name: name,
module_items: vec![type_definition],
}
} else {
- EnumBuilder::Consts {
- aster: aster.type_(name).build_ty(repr),
- }
+ EnumBuilder::Consts(vec![
+ quote! {
+ pub type #ident = #repr;
+ }
+ ])
}
} else {
- EnumBuilder::Rust(aster.enum_(name))
+ let mut tokens = quote! {
+ #( #attrs )*
+ pub enum #ident
+ };
+ tokens.append("{");
+ EnumBuilder::Rust(tokens)
}
}
@@ -2250,28 +2140,25 @@ impl<'a> EnumBuilder<'a> {
ctx: &BindgenContext,
variant: &EnumVariant,
mangling_prefix: Option<&String>,
- rust_ty: P<ast::Ty>,
+ rust_ty: quote::Tokens,
result: &mut CodegenResult<'b>,
) -> Self {
let variant_name = ctx.rust_mangle(variant.name());
- let expr = aster::AstBuilder::new().expr();
let expr = match variant.val() {
EnumVariantValue::Signed(v) => helpers::ast_ty::int_expr(v),
- EnumVariantValue::Unsigned(v) => expr.uint(v),
+ EnumVariantValue::Unsigned(v) => helpers::ast_ty::uint_expr(v),
};
match self {
- EnumBuilder::Rust(b) => {
- EnumBuilder::Rust(b.with_variant_(ast::Variant_ {
- name: ctx.rust_ident(&*variant_name),
- attrs: vec![],
- data: ast::VariantData::Unit(ast::DUMMY_NODE_ID),
- disr_expr: Some(expr),
- }))
+ EnumBuilder::Rust(tokens) => {
+ let name = ctx.rust_ident(variant_name);
+ EnumBuilder::Rust(quote! {
+ #tokens
+ #name = #expr,
+ })
}
- EnumBuilder::Bitfield {
- canonical_name, ..
- } => {
+
+ EnumBuilder::Bitfield { .. } => {
let constant_name = match mangling_prefix {
Some(prefix) => {
Cow::Owned(format!("{}_{}", prefix, variant_name))
@@ -2279,20 +2166,14 @@ impl<'a> EnumBuilder<'a> {
None => variant_name,
};
- let constant = aster::AstBuilder::new()
- .item()
- .pub_()
- .const_(&*constant_name)
- .expr()
- .call()
- .id(canonical_name)
- .arg()
- .build(expr)
- .build()
- .build(rust_ty);
- result.push(constant);
+ let ident = ctx.rust_ident(constant_name);
+ result.push(quote! {
+ pub const #ident : #rust_ty = #rust_ty ( #expr );
+ });
+
self
}
+
EnumBuilder::Consts {
..
} => {
@@ -2303,37 +2184,22 @@ impl<'a> EnumBuilder<'a> {
None => variant_name,
};
- let constant = aster::AstBuilder::new()
- .item()
- .pub_()
- .const_(&*constant_name)
- .expr()
- .build(expr)
- .build(rust_ty);
+ let ident = ctx.rust_ident(constant_name);
+ result.push(quote! {
+ pub const #ident : #rust_ty = #expr ;
+ });
- result.push(constant);
self
}
EnumBuilder::ModuleConsts {
module_name,
- module_items,
- ..
+ mut module_items,
} => {
- // Variant type
- let inside_module_type = aster::AstBuilder::new().ty().id(
- CONSTIFIED_ENUM_MODULE_REPR_NAME,
- );
-
- let constant = aster::AstBuilder::new()
- .item()
- .pub_()
- .const_(&*variant_name)
- .expr()
- .build(expr)
- .build(inside_module_type.clone());
-
- let mut module_items = module_items.clone();
- module_items.push(constant);
+ let name = ctx.rust_ident(variant_name);
+ let ty = ctx.rust_ident(CONSTIFIED_ENUM_MODULE_REPR_NAME);
+ module_items.push(quote! {
+ pub const #name : #ty = #expr ;
+ });
EnumBuilder::ModuleConsts {
module_name,
@@ -2346,86 +2212,74 @@ impl<'a> EnumBuilder<'a> {
fn build<'b>(
self,
ctx: &BindgenContext,
- rust_ty: P<ast::Ty>,
+ rust_ty: quote::Tokens,
result: &mut CodegenResult<'b>,
- ) -> P<ast::Item> {
+ ) -> quote::Tokens {
match self {
- EnumBuilder::Rust(b) => b.build(),
+ EnumBuilder::Rust(mut t) => {
+ t.append("}");
+ t
+ }
EnumBuilder::Bitfield {
canonical_name,
- aster,
+ tokens,
} => {
let rust_ty_name = ctx.rust_ident_raw(canonical_name);
let prefix = ctx.trait_prefix();
- let impl_ = quote_item!(ctx.ext_cx(),
- impl ::$prefix::ops::BitOr<$rust_ty> for $rust_ty {
+ result.push(quote! {
+ impl ::#prefix::ops::BitOr<#rust_ty> for #rust_ty {
type Output = Self;
#[inline]
fn bitor(self, other: Self) -> Self {
- $rust_ty_name(self.0 | other.0)
+ #rust_ty_name(self.0 | other.0)
}
}
- ).unwrap();
- result.push(impl_);
+ });
- let impl_ = quote_item!(ctx.ext_cx(),
- impl ::$prefix::ops::BitOrAssign for $rust_ty {
+ result.push(quote! {
+ impl ::#prefix::ops::BitOrAssign for #rust_ty {
#[inline]
- fn bitor_assign(&mut self, rhs: $rust_ty) {
+ fn bitor_assign(&mut self, rhs: #rust_ty) {
self.0 |= rhs.0;
}
}
- ).unwrap();
- result.push(impl_);
+ });
- let impl_ = quote_item!(ctx.ext_cx(),
- impl ::$prefix::ops::BitAnd<$rust_ty> for $rust_ty {
+ result.push(quote! {
+ impl ::#prefix::ops::BitAnd<#rust_ty> for #rust_ty {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self {
- $rust_ty_name(self.0 & other.0)
+ #rust_ty_name(self.0 & other.0)
}
}
- ).unwrap();
- result.push(impl_);
+ });
- let impl_ = quote_item!(ctx.ext_cx(),
- impl ::$prefix::ops::BitAndAssign for $rust_ty {
+ result.push(quote! {
+ impl ::#prefix::ops::BitAndAssign for #rust_ty {
#[inline]
- fn bitand_assign(&mut self, rhs: $rust_ty) {
+ fn bitand_assign(&mut self, rhs: #rust_ty) {
self.0 &= rhs.0;
}
}
- ).unwrap();
- result.push(impl_);
+ });
- aster
+ tokens
}
- EnumBuilder::Consts {
- aster, ..
- } => aster,
+ EnumBuilder::Consts(tokens) => quote! { #( #tokens )* },
EnumBuilder::ModuleConsts {
module_items,
module_name,
- ..
} => {
- // Create module item with type and variant definitions
- let module_item = P(ast::Item {
- ident: ast::Ident::from_str(module_name),
- attrs: vec![],
- id: ast::DUMMY_NODE_ID,
- node: ast::ItemKind::Mod(ast::Mod {
- inner: DUMMY_SP,
- items: module_items,
- }),
- vis: ast::Visibility::Public,
- span: DUMMY_SP,
- });
-
- module_item
+ let ident = ctx.rust_ident(module_name);
+ quote! {
+ pub mod #ident {
+ #( #module_items )*
+ }
+ }
}
}
}
@@ -2444,6 +2298,7 @@ impl CodeGenerator for Enum {
debug_assert!(item.is_enabled_for_codegen(ctx));
let name = item.canonical_name(ctx);
+ let ident = ctx.rust_ident(&name);
let enum_ty = item.expect_type();
let layout = enum_ty.layout(ctx);
@@ -2485,8 +2340,6 @@ impl CodeGenerator for Enum {
}
};
- let mut builder = aster::AstBuilder::new().item().pub_();
-
// FIXME(emilio): These should probably use the path so it can
// disambiguate between namespaces, just like is_opaque etc.
let is_bitfield = {
@@ -2511,42 +2364,41 @@ impl CodeGenerator for Enum {
let is_rust_enum = !is_bitfield && !is_constified_enum;
+ let mut attrs = vec![];
+
// FIXME: Rust forbids repr with empty enums. Remove this condition when
// this is allowed.
//
// TODO(emilio): Delegate this to the builders?
if is_rust_enum {
if !self.variants().is_empty() {
- builder = builder.with_attr(attributes::repr(repr_name));
+ attrs.push(attributes::repr(repr_name));
}
} else if is_bitfield {
- builder = builder.with_attr(attributes::repr("C"));
+ attrs.push(attributes::repr("C"));
}
if let Some(comment) = item.comment(ctx) {
- builder = builder.with_attr(attributes::doc(comment));
+ attrs.push(attributes::doc(comment));
}
if !is_constified_enum {
- let derives =
- attributes::derives(
- &["Debug", "Copy", "Clone", "PartialEq", "Eq", "Hash"],
- );
-
- builder = builder.with_attr(derives);
+ attrs.push(attributes::derives(
+ &["Debug", "Copy", "Clone", "PartialEq", "Eq", "Hash"],
+ ));
}
fn add_constant<'a>(
ctx: &BindgenContext,
enum_: &Type,
// Only to avoid recomputing every time.
- enum_canonical_name: &str,
+ enum_canonical_name: &quote::Ident,
// May be the same as "variant" if it's because the
// enum is unnamed and we still haven't seen the
// value.
variant_name: &str,
- referenced_name: &str,
- enum_rust_ty: P<ast::Ty>,
+ referenced_name: &quote::Ident,
+ enum_rust_ty: quote::Tokens,
result: &mut CodegenResult<'a>,
) {
let constant_name = if enum_.name().is_some() {
@@ -2558,17 +2410,12 @@ impl CodeGenerator for Enum {
} else {
variant_name.into()
};
+ let constant_name = ctx.rust_ident(constant_name);
- let constant = aster::AstBuilder::new()
- .item()
- .pub_()
- .const_(constant_name)
- .expr()
- .path()
- .ids(&[&*enum_canonical_name, referenced_name])
- .build()
- .build(enum_rust_ty);
- result.push(constant);
+ result.push(quote! {
+ pub const #constant_name : #enum_rust_ty =
+ #enum_canonical_name :: #referenced_name ;
+ });
}
let repr =
@@ -2577,8 +2424,8 @@ impl CodeGenerator for Enum {
.unwrap_or_else(|| helpers::ast_ty::raw_type(ctx, repr_name));
let mut builder = EnumBuilder::new(
- builder,
&name,
+ attrs,
repr,
is_bitfield,
is_constified_enum,
@@ -2586,7 +2433,7 @@ impl CodeGenerator for Enum {
);
// A map where we keep a value -> variant relation.
- let mut seen_values = HashMap::<_, String>::new();
+ let mut seen_values = HashMap::<_, quote::Ident>::new();
let enum_rust_ty = item.to_rust_ty_or_opaque(ctx, &());
let is_toplevel = item.is_toplevel(ctx);
@@ -2646,7 +2493,7 @@ impl CodeGenerator for Enum {
add_constant(
ctx,
enum_ty,
- &name,
+ &ident,
&*mangled_name,
existing_variant_name,
enum_rust_ty.clone(),
@@ -2671,7 +2518,7 @@ impl CodeGenerator for Enum {
result,
);
- let variant_name = ctx.rust_mangle(variant.name());
+ let variant_name = ctx.rust_ident(variant.name());
// If it's an unnamed enum, or constification is enforced,
// we also generate a constant so it can be properly
@@ -2685,29 +2532,33 @@ impl CodeGenerator for Enum {
let parent_name =
parent_canonical_name.as_ref().unwrap();
- Cow::Owned(
- format!("{}_{}", parent_name, variant_name),
+ quote::Ident::new(
+ format!(
+ "{}_{}",
+ parent_name,
+ variant_name
+ )
)
};
add_constant(
ctx,
enum_ty,
- &name,
- &mangled_name,
+ &ident,
+ mangled_name.as_ref(),
&variant_name,
enum_rust_ty.clone(),
result,
);
}
- entry.insert(variant_name.into_owned());
+ entry.insert(quote::Ident::new(variant_name));
}
}
}
- let enum_ = builder.build(ctx, enum_rust_ty, result);
- result.push(enum_);
+ let item = builder.build(ctx, enum_rust_ty, result);
+ result.push(item);
}
}
@@ -2731,7 +2582,7 @@ trait TryToOpaque {
&self,
ctx: &BindgenContext,
extra: &Self::Extra,
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
self.try_get_layout(ctx, extra).map(|layout| {
helpers::blob(layout)
})
@@ -2759,7 +2610,7 @@ trait ToOpaque: TryToOpaque {
&self,
ctx: &BindgenContext,
extra: &Self::Extra,
- ) -> P<ast::Ty> {
+ ) -> quote::Tokens {
let layout = self.get_layout(ctx, extra);
helpers::blob(layout)
}
@@ -2785,7 +2636,7 @@ trait TryToRustTy {
&self,
ctx: &BindgenContext,
extra: &Self::Extra,
- ) -> error::Result<P<ast::Ty>>;
+ ) -> error::Result<quote::Tokens>;
}
/// Fallible conversion to a Rust type or an opaque blob with the correct size
@@ -2800,7 +2651,7 @@ trait TryToRustTyOrOpaque: TryToRustTy + TryToOpaque {
&self,
ctx: &BindgenContext,
extra: &<Self as TryToRustTyOrOpaque>::Extra,
- ) -> error::Result<P<ast::Ty>>;
+ ) -> error::Result<quote::Tokens>;
}
impl<E, T> TryToRustTyOrOpaque for T
@@ -2814,7 +2665,7 @@ where
&self,
ctx: &BindgenContext,
extra: &E,
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
self.try_to_rust_ty(ctx, extra).or_else(
|_| if let Ok(layout) =
self.try_get_layout(ctx, extra)
@@ -2851,7 +2702,7 @@ trait ToRustTyOrOpaque: TryToRustTy + ToOpaque {
&self,
ctx: &BindgenContext,
extra: &<Self as ToRustTyOrOpaque>::Extra,
- ) -> P<ast::Ty>;
+ ) -> quote::Tokens;
}
impl<E, T> ToRustTyOrOpaque for T
@@ -2864,7 +2715,7 @@ where
&self,
ctx: &BindgenContext,
extra: &E,
- ) -> P<ast::Ty> {
+ ) -> quote::Tokens {
self.try_to_rust_ty(ctx, extra).unwrap_or_else(|_| {
self.to_opaque(ctx, extra)
})
@@ -2890,7 +2741,7 @@ impl TryToRustTy for ItemId {
&self,
ctx: &BindgenContext,
_: &(),
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
ctx.resolve_item(*self).try_to_rust_ty(ctx, &())
}
}
@@ -2914,7 +2765,7 @@ impl TryToRustTy for Item {
&self,
ctx: &BindgenContext,
_: &(),
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
self.kind().expect_type().try_to_rust_ty(ctx, self)
}
}
@@ -2938,7 +2789,7 @@ impl TryToRustTy for Type {
&self,
ctx: &BindgenContext,
item: &Item,
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
use self::helpers::ast_ty::*;
match *self.kind() {
@@ -2946,11 +2797,11 @@ impl TryToRustTy for Type {
// TODO: we should do something smart with nullptr, or maybe *const
// c_void is enough?
TypeKind::NullPtr => {
- Ok(raw_type(ctx, "c_void").to_ptr(true, ctx.span()))
+ Ok(raw_type(ctx, "c_void").to_ptr(true))
}
TypeKind::Int(ik) => {
match ik {
- IntKind::Bool => Ok(aster::ty::TyBuilder::new().bool()),
+ IntKind::Bool => Ok(quote! { bool }),
IntKind::Char {
..
} => Ok(raw_type(ctx, "c_char")),
@@ -2965,25 +2816,27 @@ impl TryToRustTy for Type {
IntKind::LongLong => Ok(raw_type(ctx, "c_longlong")),
IntKind::ULongLong => Ok(raw_type(ctx, "c_ulonglong")),
- IntKind::I8 => Ok(aster::ty::TyBuilder::new().i8()),
- IntKind::U8 => Ok(aster::ty::TyBuilder::new().u8()),
- IntKind::I16 => Ok(aster::ty::TyBuilder::new().i16()),
- IntKind::U16 => Ok(aster::ty::TyBuilder::new().u16()),
- IntKind::I32 => Ok(aster::ty::TyBuilder::new().i32()),
- IntKind::U32 => Ok(aster::ty::TyBuilder::new().u32()),
- IntKind::I64 => Ok(aster::ty::TyBuilder::new().i64()),
- IntKind::U64 => Ok(aster::ty::TyBuilder::new().u64()),
+ IntKind::I8 => Ok(quote! { i8 }),
+ IntKind::U8 => Ok(quote! { u8 }),
+ IntKind::I16 => Ok(quote! { i16 }),
+ IntKind::U16 => Ok(quote! { u16 }),
+ IntKind::I32 => Ok(quote! { i32 }),
+ IntKind::U32 => Ok(quote! { u32 }),
+ IntKind::I64 => Ok(quote! { i64 }),
+ IntKind::U64 => Ok(quote! { u64 }),
IntKind::Custom {
name, ..
} => {
let ident = ctx.rust_ident_raw(name);
- Ok(quote_ty!(ctx.ext_cx(), $ident))
+ Ok(quote! {
+ #ident
+ })
}
// FIXME: This doesn't generate the proper alignment, but we
// can't do better right now. We should be able to use
// i128/u128 when they're available.
IntKind::U128 | IntKind::I128 => {
- Ok(aster::ty::TyBuilder::new().array(2).u64())
+ Ok(quote! { [u64; 2] })
}
}
}
@@ -2993,9 +2846,13 @@ impl TryToRustTy for Type {
ctx.generated_bindegen_complex();
Ok(if ctx.options().enable_cxx_namespaces {
- quote_ty!(ctx.ext_cx(), root::__BindgenComplex<$float_path>)
+ quote! {
+ root::__BindgenComplex<#float_path>
+ }
} else {
- quote_ty!(ctx.ext_cx(), __BindgenComplex<$float_path>)
+ quote! {
+ __BindgenComplex<#float_path>
+ }
})
}
TypeKind::Function(ref fs) => {
@@ -3003,18 +2860,24 @@ impl TryToRustTy for Type {
// sizeof(NonZero<_>) optimization with opaque blobs (because
// they aren't NonZero), so don't *ever* use an or_opaque
// variant here.
- let ty = fs.try_to_rust_ty(ctx, item)?;
+ let ty = fs.try_to_rust_ty(ctx, &())?;
let prefix = ctx.trait_prefix();
- Ok(quote_ty!(ctx.ext_cx(), ::$prefix::option::Option<$ty>))
+ Ok(quote! {
+ ::#prefix::option::Option<#ty>
+ })
}
TypeKind::Array(item, len) => {
let ty = item.try_to_rust_ty(ctx, &())?;
- Ok(aster::ty::TyBuilder::new().array(len).build(ty))
+ Ok(quote! {
+ [ #ty ; #len ]
+ })
}
TypeKind::Enum(..) => {
+ let mut tokens = quote! {};
let path = item.namespace_aware_canonical_path(ctx);
- Ok(aster::AstBuilder::new().ty().path().ids(path).build())
+ tokens.append_separated(path.into_iter().map(quote::Ident::new), "::");
+ Ok(tokens)
}
TypeKind::TemplateInstantiation(ref inst) => {
inst.try_to_rust_ty(ctx, item)
@@ -3039,7 +2902,7 @@ impl TryToRustTy for Type {
{
Ok(ty)
} else {
- utils::build_templated_path(item, ctx, template_params)
+ utils::build_templated_path(item, ctx, vec![]) //template_params)
}
}
TypeKind::Comp(ref info) => {
@@ -3050,48 +2913,54 @@ impl TryToRustTy for Type {
return self.try_to_opaque(ctx, item);
}
- let template_params = template_params.unwrap_or(vec![]);
- utils::build_templated_path(item, ctx, template_params)
+ // let template_params = template_params.unwrap_or(vec![]);
+ utils::build_templated_path(item, ctx, vec![])
}
TypeKind::Opaque => self.try_to_opaque(ctx, item),
TypeKind::BlockPointer => {
let void = raw_type(ctx, "c_void");
Ok(void.to_ptr(
/* is_const = */
- false,
- ctx.span(),
+ false
))
}
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) => {
- let inner = ctx.resolve_item(inner);
+ let is_const = self.is_const() || ctx.resolve_type(inner).is_const();
+
+ let inner = inner.into_resolver().through_type_refs().resolve(ctx);
let inner_ty = inner.expect_type();
// Regardless if we can properly represent the inner type, we
// should always generate a proper pointer here, so use
// infallible conversion of the inner type.
- let ty = inner.to_rust_ty_or_opaque(ctx, &());
+ let mut ty = inner.to_rust_ty_or_opaque(ctx, &());
+ ty.append_implicit_template_params(ctx, inner);
// Avoid the first function pointer level, since it's already
// represented in Rust.
if inner_ty.canonical_type(ctx).is_function() {
Ok(ty)
} else {
- let is_const = self.is_const() ||
- inner.expect_type().is_const();
- Ok(ty.to_ptr(is_const, ctx.span()))
+ Ok(ty.to_ptr(is_const))
}
}
TypeKind::TypeParam => {
let name = item.canonical_name(ctx);
let ident = ctx.rust_ident(&name);
- Ok(quote_ty!(ctx.ext_cx(), $ident))
+ Ok(quote! {
+ #ident
+ })
}
TypeKind::ObjCSel => {
- Ok(quote_ty!(ctx.ext_cx(), objc::runtime::Sel))
+ Ok(quote! {
+ objc::runtime::Sel
+ })
}
TypeKind::ObjCId |
- TypeKind::ObjCInterface(..) => Ok(quote_ty!(ctx.ext_cx(), id)),
+ TypeKind::ObjCInterface(..) => Ok(quote! {
+ id
+ }),
ref u @ TypeKind::UnresolvedTypeRef(..) => {
unreachable!("Should have been resolved after parsing {:?}!", u)
}
@@ -3120,108 +2989,81 @@ impl TryToRustTy for TemplateInstantiation {
&self,
ctx: &BindgenContext,
item: &Item,
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
if self.is_opaque(ctx, item) {
return Err(error::Error::InstantiationOfOpaqueType);
}
- let decl = self.template_definition();
- let mut ty = decl.try_to_rust_ty(ctx, &())?.unwrap();
+ let def = self.template_definition()
+ .into_resolver()
+ .through_type_refs()
+ .resolve(ctx);
- let decl_params = match decl.self_template_params(ctx) {
+ let mut ty = quote! {};
+ let def_path = def.namespace_aware_canonical_path(ctx);
+ ty.append_separated(def_path.into_iter().map(|p| ctx.rust_ident(p)), "::");
+
+ let def_params = match def.self_template_params(ctx) {
Some(params) => params,
None => {
// This can happen if we generated an opaque type for a partial
// template specialization, and we've hit an instantiation of
// that partial specialization.
extra_assert!(
- decl.into_resolver()
- .through_type_refs()
- .resolve(ctx)
- .is_opaque(ctx, &())
+ def.is_opaque(ctx, &())
);
return Err(error::Error::InstantiationOfOpaqueType);
}
};
- // TODO: If the decl type is a template class/struct
- // declaration's member template declaration, it could rely on
+ // TODO: If the definition type is a template class/struct
+ // definition's member template definition, it could rely on
// generic template parameters from its outer template
// class/struct. When we emit bindings for it, it could require
// *more* type arguments than we have here, and we will need to
// reconstruct them somehow. We don't have any means of doing
// that reconstruction at this time.
- if let ast::TyKind::Path(_, ref mut path) = ty.node {
- let template_args = self.template_arguments()
- .iter()
- .zip(decl_params.iter())
- // Only pass type arguments for the type parameters that
- // the decl uses.
- .filter(|&(_, param)| ctx.uses_template_parameter(decl, *param))
- .map(|(arg, _)| arg.try_to_rust_ty(ctx, &()))
- .collect::<error::Result<Vec<_>>>()?;
-
- path.segments.last_mut().unwrap().parameters =
- if template_args.is_empty() {
- None
- } else {
- Some(P(ast::PathParameters::AngleBracketed(
- ast::AngleBracketedParameterData {
- lifetimes: vec![],
- types: template_args,
- bindings: vec![],
- },
- )))
- }
+ let template_args = self.template_arguments()
+ .iter()
+ .zip(def_params.iter())
+ // Only pass type arguments for the type parameters that
+ // the def uses.
+ .filter(|&(_, param)| ctx.uses_template_parameter(def.id(), *param))
+ .map(|(arg, _)| {
+ let arg = arg.into_resolver().through_type_refs().resolve(ctx);
+ let mut ty = arg.try_to_rust_ty(ctx, &())?;
+ ty.append_implicit_template_params(ctx, arg);
+ Ok(ty)
+ })
+ .collect::<error::Result<Vec<_>>>()?;
+
+ if template_args.is_empty() {
+ return Ok(ty);
}
- Ok(P(ty))
+ Ok(quote! {
+ #ty < #( #template_args ),* >
+ })
}
}
impl TryToRustTy for FunctionSig {
- type Extra = Item;
+ type Extra = ();
fn try_to_rust_ty(
&self,
ctx: &BindgenContext,
- item: &Item,
- ) -> error::Result<P<ast::Ty>> {
+ _: &(),
+ ) -> error::Result<quote::Tokens> {
// TODO: we might want to consider ignoring the reference return value.
let ret = utils::fnsig_return_ty(ctx, &self);
let arguments = utils::fnsig_arguments(ctx, &self);
+ let abi = self.abi();
- let decl = P(ast::FnDecl {
- inputs: arguments,
- output: ret,
- variadic: self.is_variadic(),
- });
-
- let abi = match self.abi() {
- Abi::Known(abi) => abi,
- Abi::Unknown(unknown_abi) => {
- panic!(
- "Invalid or unknown abi {:?} for function {:?} {:?}",
- unknown_abi,
- item.canonical_name(ctx),
- self
- );
- }
- };
-
- let fnty = ast::TyKind::BareFn(P(ast::BareFnTy {
- unsafety: ast::Unsafety::Unsafe,
- abi: abi,
- lifetimes: vec![],
- decl: decl,
- }));
-
- Ok(P(ast::Ty {
- id: ast::DUMMY_NODE_ID,
- node: fnty,
- span: ctx.span(),
- }))
+ Ok(quote! {
+ unsafe extern #abi fn ( #( #arguments ),* ) #ret
+ })
}
}
@@ -3270,7 +3112,8 @@ impl CodeGenerator for Function {
_ => panic!("Signature kind is not a Function: {:?}", signature),
};
- let fndecl = utils::rust_fndecl_from_signature(ctx, signature_item);
+ let args = utils::fnsig_arguments(ctx, signature);
+ let ret = utils::fnsig_return_ty(ctx, signature);
let mut attributes = vec![];
@@ -3284,9 +3127,6 @@ impl CodeGenerator for Function {
attributes.push(attributes::link_name(name));
}
- let foreign_item_kind =
- ast::ForeignItemKind::Fn(fndecl, ast::Generics::default());
-
// Handle overloaded functions by giving each overload its own unique
// suffix.
let times_seen = result.overload_number(&canonical_name);
@@ -3294,17 +3134,7 @@ impl CodeGenerator for Function {
write!(&mut canonical_name, "{}", times_seen).unwrap();
}
- let foreign_item = ast::ForeignItem {
- ident: ctx.rust_ident_raw(&canonical_name),
- attrs: attributes,
- node: foreign_item_kind,
- id: ast::DUMMY_NODE_ID,
- span: ctx.span(),
- vis: ast::Visibility::Public,
- };
-
let abi = match signature.abi() {
- Abi::Known(abi) => abi,
Abi::Unknown(unknown_abi) => {
panic!(
"Invalid or unknown abi {:?} for function {:?} ({:?})",
@@ -3313,13 +3143,29 @@ impl CodeGenerator for Function {
self
);
}
+ abi => abi,
};
- let item = ForeignModBuilder::new(abi)
- .with_foreign_item(foreign_item)
- .build(ctx);
+ let variadic = if signature.is_variadic() {
+ quote! { ... }
+ } else {
+ quote! {}
+ };
- result.push(item);
+ let ident = ctx.rust_ident(canonical_name);
+ let mut tokens = quote! { extern #abi };
+ tokens.append("{\n");
+ if !attributes.is_empty() {
+ tokens.append_separated(attributes, "\n");
+ tokens.append("\n");
+ }
+ let mut args = args;
+ args.push(variadic);
+ tokens.append(quote! {
+ pub fn #ident ( #( #args ),* ) #ret;
+ });
+ tokens.append("\n}");
+ result.push(tokens);
}
}
@@ -3329,86 +3175,53 @@ fn objc_method_codegen(
method: &ObjCMethod,
class_name: Option<&str>,
prefix: &str,
-) -> (ast::ImplItem, ast::TraitItem) {
+) -> (quote::Tokens, quote::Tokens) {
let signature = method.signature();
let fn_args = utils::fnsig_arguments(ctx, signature);
let fn_ret = utils::fnsig_return_ty(ctx, signature);
let sig = if method.is_class_method() {
- aster::AstBuilder::new()
- .method_sig()
- .unsafe_()
- .fn_decl()
- .with_args(fn_args.clone())
- .build(fn_ret)
+ let fn_args = fn_args.clone();
+ quote! {
+ ( #( #fn_args ),* ) #fn_ret
+ }
} else {
- aster::AstBuilder::new()
- .method_sig()
- .unsafe_()
- .fn_decl()
- .self_()
- .build(ast::SelfKind::Value(ast::Mutability::Immutable))
- .with_args(fn_args.clone())
- .build(fn_ret)
+ let fn_args = fn_args.clone();
+ let args = iter::once(quote! { self })
+ .chain(fn_args.into_iter());
+ quote! {
+ ( #( #args ),* ) #fn_ret
+ }
};
- // Collect the actual used argument names
- let arg_names: Vec<_> = fn_args
- .iter()
- .map(|ref arg| match arg.pat.node {
- ast::PatKind::Ident(_, ref spanning, _) => {
- spanning.node.name.as_str().to_string()
- }
- _ => {
- panic!("odd argument!");
- }
- })
- .collect();
-
- let methods_and_args =
- ctx.rust_ident(&method.format_method_call(&arg_names));
+ let methods_and_args = method.format_method_call(&fn_args);
let body = if method.is_class_method() {
let class_name = class_name
.expect("Generating a class method without class name?")
.to_owned();
let expect_msg = format!("Couldn't find {}", class_name);
- quote_stmt!(ctx.ext_cx(),
- msg_send![objc::runtime::Class::get($class_name).expect($expect_msg), $methods_and_args])
- .unwrap()
+ quote! {
+ msg_send!(objc::runtime::Class::get(#class_name).expect(#expect_msg), #methods_and_args)
+ }
} else {
- quote_stmt!(ctx.ext_cx(), msg_send![self, $methods_and_args]).unwrap()
- };
- let block = ast::Block {
- stmts: vec![body],
- id: ast::DUMMY_NODE_ID,
- rules: ast::BlockCheckMode::Default,
- span: ctx.span(),
- };
-
- let attrs = vec![];
-
- let method_name = format!("{}{}", prefix, method.rust_name());
-
- let impl_item = ast::ImplItem {
- id: ast::DUMMY_NODE_ID,
- ident: ctx.rust_ident(&method_name),
- vis: ast::Visibility::Inherited, // Public,
- attrs: attrs.clone(),
- node: ast::ImplItemKind::Method(sig.clone(), P(block)),
- defaultness: ast::Defaultness::Final,
- span: ctx.span(),
+ quote! {
+ msg_send!(self, #methods_and_args)
+ }
};
- let trait_item = ast::TraitItem {
- id: ast::DUMMY_NODE_ID,
- ident: ctx.rust_ident(&method_name),
- attrs: attrs,
- node: ast::TraitItemKind::Method(sig, None),
- span: ctx.span(),
- };
+ let method_name = ctx.rust_ident(format!("{}{}", prefix, method.rust_name()));
- (impl_item, trait_item)
+ (
+ quote! {
+ unsafe fn #method_name #sig {
+ #body
+ }
+ },
+ quote! {
+ unsafe fn #method_name #sig ;
+ }
+ )
}
impl CodeGenerator for ObjCInterface {
@@ -3440,7 +3253,6 @@ impl CodeGenerator for ObjCInterface {
.collect();
for class_method in self.class_methods() {
-
let ambiquity =
instance_method_names.contains(&class_method.rust_name());
let prefix = if ambiquity { "class_" } else { "" };
@@ -3454,24 +3266,22 @@ impl CodeGenerator for ObjCInterface {
trait_items.push(trait_item)
}
- let trait_name = self.rust_name();
+ let trait_name = ctx.rust_ident(self.rust_name());
- let trait_block = aster::AstBuilder::new()
- .item()
- .pub_()
- .trait_(&trait_name)
- .with_items(trait_items)
- .build();
+ let trait_block = quote! {
+ pub trait #trait_name {
+ #( #trait_items )*
+ }
+ };
- let ty_for_impl = quote_ty!(ctx.ext_cx(), id);
- let impl_block = aster::AstBuilder::new()
- .item()
- .impl_()
- .trait_()
- .id(&trait_name)
- .build()
- .with_items(impl_items)
- .build_ty(ty_for_impl);
+ let ty_for_impl = quote! {
+ id
+ };
+ let impl_block = quote! {
+ impl #trait_name for #ty_for_impl {
+ #( #impl_items )*
+ }
+ };
result.push(trait_block);
result.push(impl_block);
@@ -3479,7 +3289,7 @@ impl CodeGenerator for ObjCInterface {
}
}
-pub fn codegen(context: &mut BindgenContext) -> Vec<P<ast::Item>> {
+pub fn codegen(context: &mut BindgenContext) -> Vec<quote::Tokens> {
context.gen(|context| {
let _t = context.timer("codegen");
let counter = Cell::new(0);
@@ -3511,35 +3321,32 @@ pub fn codegen(context: &mut BindgenContext) -> Vec<P<ast::Item>> {
mod utils {
use super::{ToRustTyOrOpaque, TryToRustTy, error};
- use aster;
use ir::context::{BindgenContext, ItemId};
use ir::function::FunctionSig;
use ir::item::{Item, ItemCanonicalPath};
use ir::ty::TypeKind;
+ use quote;
use std::mem;
- use syntax::ast;
- use syntax::ptr::P;
pub fn prepend_objc_header(
ctx: &BindgenContext,
- result: &mut Vec<P<ast::Item>>,
+ result: &mut Vec<quote::Tokens>,
) {
let use_objc = if ctx.options().objc_extern_crate {
- quote_item!(ctx.ext_cx(),
+ quote! {
#[macro_use]
extern crate objc;
- ).unwrap()
+ }
} else {
- quote_item!(ctx.ext_cx(),
+ quote! {
use objc;
- ).unwrap()
+ }
};
-
- let id_type = quote_item!(ctx.ext_cx(),
+ let id_type = quote! {
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
- ).unwrap();
+ };
let items = vec![use_objc, id_type];
let old_items = mem::replace(result, items);
@@ -3548,90 +3355,88 @@ mod utils {
pub fn prepend_union_types(
ctx: &BindgenContext,
- result: &mut Vec<P<ast::Item>>,
+ result: &mut Vec<quote::Tokens>,
) {
let prefix = ctx.trait_prefix();
// TODO(emilio): The fmt::Debug impl could be way nicer with
// std::intrinsics::type_name, but...
- let union_field_decl = quote_item!(ctx.ext_cx(),
+ let union_field_decl = quote! {
#[repr(C)]
- pub struct __BindgenUnionField<T>(
- ::$prefix::marker::PhantomData<T>);
- ).unwrap();
+ pub struct __BindgenUnionField<T>(::#prefix::marker::PhantomData<T>);
+ };
- let union_field_impl = quote_item!(&ctx.ext_cx(),
+ let union_field_impl = quote! {
impl<T> __BindgenUnionField<T> {
#[inline]
pub fn new() -> Self {
- __BindgenUnionField(::$prefix::marker::PhantomData)
+ __BindgenUnionField(::#prefix::marker::PhantomData)
}
#[inline]
pub unsafe fn as_ref(&self) -> &T {
- ::$prefix::mem::transmute(self)
+ ::#prefix::mem::transmute(self)
}
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
- ::$prefix::mem::transmute(self)
+ ::#prefix::mem::transmute(self)
}
}
- ).unwrap();
+ };
- let union_field_default_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::default::Default for __BindgenUnionField<T> {
+ let union_field_default_impl = quote! {
+ impl<T> ::#prefix::default::Default for __BindgenUnionField<T> {
#[inline]
fn default() -> Self {
Self::new()
}
}
- ).unwrap();
+ };
- let union_field_clone_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::clone::Clone for __BindgenUnionField<T> {
+ let union_field_clone_impl = quote! {
+ impl<T> ::#prefix::clone::Clone for __BindgenUnionField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
- ).unwrap();
+ };
- let union_field_copy_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::marker::Copy for __BindgenUnionField<T> {}
- ).unwrap();
+ let union_field_copy_impl = quote! {
+ impl<T> ::#prefix::marker::Copy for __BindgenUnionField<T> {}
+ };
- let union_field_debug_impl = quote_item!(ctx.ext_cx(),
- impl<T> ::$prefix::fmt::Debug for __BindgenUnionField<T> {
- fn fmt(&self, fmt: &mut ::$prefix::fmt::Formatter)
- -> ::$prefix::fmt::Result {
+ let union_field_debug_impl = quote! {
+ impl<T> ::#prefix::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::#prefix::fmt::Formatter)
+ -> ::#prefix::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
- ).unwrap();
+ };
// The actual memory of the filed will be hashed, so that's why these
// field doesn't do anything with the hash.
- let union_field_hash_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::hash::Hash for __BindgenUnionField<T> {
- fn hash<H: ::$prefix::hash::Hasher>(&self, _state: &mut H) {
+ let union_field_hash_impl = quote! {
+ impl<T> ::#prefix::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::#prefix::hash::Hasher>(&self, _state: &mut H) {
}
}
- ).unwrap();
+ };
- let union_field_partialeq_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::cmp::PartialEq for __BindgenUnionField<T> {
+ let union_field_partialeq_impl = quote! {
+ impl<T> ::#prefix::cmp::PartialEq for __BindgenUnionField<T> {
fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
true
}
}
- ).unwrap();
+ };
- let union_field_eq_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::cmp::Eq for __BindgenUnionField<T> {
+ let union_field_eq_impl = quote! {
+ impl<T> ::#prefix::cmp::Eq for __BindgenUnionField<T> {
}
- )
- .unwrap();
+ };
let items = vec![union_field_decl,
union_field_impl,
@@ -3649,67 +3454,67 @@ mod utils {
pub fn prepend_incomplete_array_types(
ctx: &BindgenContext,
- result: &mut Vec<P<ast::Item>>,
+ result: &mut Vec<quote::Tokens>,
) {
let prefix = ctx.trait_prefix();
- let incomplete_array_decl = quote_item!(ctx.ext_cx(),
+ let incomplete_array_decl = quote! {
#[repr(C)]
#[derive(Default)]
pub struct __IncompleteArrayField<T>(
- ::$prefix::marker::PhantomData<T>);
- ).unwrap();
+ ::#prefix::marker::PhantomData<T>);
+ };
- let incomplete_array_impl = quote_item!(&ctx.ext_cx(),
+ let incomplete_array_impl = quote! {
impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
- __IncompleteArrayField(::$prefix::marker::PhantomData)
+ __IncompleteArrayField(::#prefix::marker::PhantomData)
}
#[inline]
pub unsafe fn as_ptr(&self) -> *const T {
- ::$prefix::mem::transmute(self)
+ ::#prefix::mem::transmute(self)
}
#[inline]
pub unsafe fn as_mut_ptr(&mut self) -> *mut T {
- ::$prefix::mem::transmute(self)
+ ::#prefix::mem::transmute(self)
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
- ::$prefix::slice::from_raw_parts(self.as_ptr(), len)
+ ::#prefix::slice::from_raw_parts(self.as_ptr(), len)
}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
- ::$prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
+ ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
}
}
- ).unwrap();
+ };
- let incomplete_array_debug_impl = quote_item!(ctx.ext_cx(),
- impl<T> ::$prefix::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::$prefix::fmt::Formatter)
- -> ::$prefix::fmt::Result {
+ let incomplete_array_debug_impl = quote! {
+ impl<T> ::#prefix::fmt::Debug for __IncompleteArrayField<T> {
+ fn fmt(&self, fmt: &mut ::#prefix::fmt::Formatter)
+ -> ::#prefix::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
- ).unwrap();
+ };
- let incomplete_array_clone_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::clone::Clone for __IncompleteArrayField<T> {
+ let incomplete_array_clone_impl = quote! {
+ impl<T> ::#prefix::clone::Clone for __IncompleteArrayField<T> {
#[inline]
fn clone(&self) -> Self {
Self::new()
}
}
- ).unwrap();
+ };
- let incomplete_array_copy_impl = quote_item!(&ctx.ext_cx(),
- impl<T> ::$prefix::marker::Copy for __IncompleteArrayField<T> {}
- ).unwrap();
+ let incomplete_array_copy_impl = quote! {
+ impl<T> ::#prefix::marker::Copy for __IncompleteArrayField<T> {}
+ };
let items = vec![incomplete_array_decl,
incomplete_array_impl,
@@ -3722,17 +3527,16 @@ mod utils {
}
pub fn prepend_complex_type(
- ctx: &BindgenContext,
- result: &mut Vec<P<ast::Item>>,
+ result: &mut Vec<quote::Tokens>,
) {
- let complex_type = quote_item!(ctx.ext_cx(),
+ let complex_type = quote! {
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct __BindgenComplex<T> {
pub re: T,
pub im: T
}
- ).unwrap();
+ };
let items = vec![complex_type];
let old_items = mem::replace(result, items);
@@ -3743,53 +3547,38 @@ mod utils {
item: &Item,
ctx: &BindgenContext,
template_params: Vec<ItemId>,
- ) -> error::Result<P<ast::Ty>> {
+ ) -> error::Result<quote::Tokens> {
let path = item.namespace_aware_canonical_path(ctx);
- let builder = aster::AstBuilder::new().ty().path();
let template_params = template_params
.iter()
.map(|param| param.try_to_rust_ty(ctx, &()))
.collect::<error::Result<Vec<_>>>()?;
- // XXX: I suck at aster.
- if path.len() == 1 {
- return Ok(
- builder
- .segment(&path[0])
- .with_tys(template_params)
- .build()
- .build(),
- );
- }
+ let mut tokens = quote! {};
+ tokens.append_separated(path.into_iter().map(quote::Ident::new), "::");
- let mut builder = builder.id(&path[0]);
- for (i, segment) in path.iter().skip(1).enumerate() {
- // Take into account the skip(1)
- builder = if i == path.len() - 2 {
- // XXX Extra clone courtesy of the borrow checker.
- builder
- .segment(&segment)
- .with_tys(template_params.clone())
- .build()
- } else {
- builder.segment(&segment).build()
- }
+ if template_params.is_empty() {
+ Ok(tokens)
+ } else {
+ Ok(quote! {
+ #tokens < #( #template_params ),* >
+ })
}
-
- Ok(builder.build())
}
- fn primitive_ty(ctx: &BindgenContext, name: &str) -> P<ast::Ty> {
- let ident = ctx.rust_ident_raw(&name);
- quote_ty!(ctx.ext_cx(), $ident)
+ fn primitive_ty(ctx: &BindgenContext, name: &str) -> quote::Tokens {
+ let ident = ctx.rust_ident_raw(name);
+ quote! {
+ #ident
+ }
}
pub fn type_from_named(
ctx: &BindgenContext,
name: &str,
_inner: ItemId,
- ) -> Option<P<ast::Ty>> {
+ ) -> Option<quote::Tokens> {
// FIXME: We could use the inner item to check this is really a
// primitive type but, who the heck overrides these anyway?
Some(match name {
@@ -3809,42 +3598,27 @@ mod utils {
})
}
- pub fn rust_fndecl_from_signature(
- ctx: &BindgenContext,
- sig: &Item,
- ) -> P<ast::FnDecl> {
- let signature = sig.kind().expect_type().canonical_type(ctx);
- let signature = match *signature.kind() {
- TypeKind::Function(ref sig) => sig,
- _ => panic!("How?"),
- };
-
- let decl_ty = signature.try_to_rust_ty(ctx, sig).expect(
- "function signature to Rust type conversion is infallible",
- );
- match decl_ty.unwrap().node {
- ast::TyKind::BareFn(bare_fn) => bare_fn.unwrap().decl,
- _ => panic!("How did this happen exactly?"),
- }
- }
-
pub fn fnsig_return_ty(
ctx: &BindgenContext,
sig: &FunctionSig,
- ) -> ast::FunctionRetTy {
+ ) -> quote::Tokens {
let return_item = ctx.resolve_item(sig.return_type());
if let TypeKind::Void = *return_item.kind().expect_type().kind() {
- ast::FunctionRetTy::Default(ctx.span())
+ quote! { }
} else {
- ast::FunctionRetTy::Ty(return_item.to_rust_ty_or_opaque(ctx, &()))
+ let ret_ty = return_item.to_rust_ty_or_opaque(ctx, &());
+ quote! {
+ -> #ret_ty
+ }
}
}
pub fn fnsig_arguments(
ctx: &BindgenContext,
sig: &FunctionSig,
- ) -> Vec<ast::Arg> {
+ ) -> Vec<quote::Tokens> {
use super::ToPtr;
+
let mut unnamed_arguments = 0;
sig.argument_types().iter().map(|&(ref name, ty)| {
let arg_item = ctx.resolve_item(ty);
@@ -3861,13 +3635,15 @@ mod utils {
let arg_ty = match *arg_ty.canonical_type(ctx).kind() {
TypeKind::Array(t, _) => {
t.to_rust_ty_or_opaque(ctx, &())
- .to_ptr(ctx.resolve_type(t).is_const(), ctx.span())
+ .to_ptr(ctx.resolve_type(t).is_const())
},
TypeKind::Pointer(inner) => {
let inner = ctx.resolve_item(inner);
let inner_ty = inner.expect_type();
if let TypeKind::ObjCInterface(_) = *inner_ty.canonical_type(ctx).kind() {
- quote_ty!(ctx.ext_cx(), id)
+ quote! {
+ id
+ }
} else {
arg_item.to_rust_ty_or_opaque(ctx, &())
}
@@ -3886,12 +3662,11 @@ mod utils {
};
assert!(!arg_name.is_empty());
+ let arg_name = ctx.rust_ident(arg_name);
- ast::Arg {
- ty: arg_ty,
- pat: aster::AstBuilder::new().pat().id(arg_name),
- id: ast::DUMMY_NODE_ID,
+ quote! {
+ #arg_name : #arg_ty
}
- }).collect::<Vec<_>>()
+ }).collect()
}
}
diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs
index 956a1f44..06059853 100644
--- a/src/codegen/struct_layout.rs
+++ b/src/codegen/struct_layout.rs
@@ -2,22 +2,19 @@
use super::helpers;
-use aster::struct_field::StructFieldBuilder;
-
use ir::comp::CompInfo;
use ir::context::BindgenContext;
use ir::layout::Layout;
use ir::ty::{Type, TypeKind};
+use quote;
use std::cmp;
use std::mem;
-use syntax::ast;
-
/// Trace the layout of struct.
#[derive(Debug)]
-pub struct StructLayoutTracker<'a, 'ctx: 'a> {
+pub struct StructLayoutTracker<'a> {
name: &'a str,
- ctx: &'a BindgenContext<'ctx>,
+ ctx: &'a BindgenContext,
comp: &'a CompInfo,
latest_offset: usize,
padding_count: usize,
@@ -80,9 +77,9 @@ fn test_bytes_from_bits_pow2() {
}
}
-impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
+impl<'a> StructLayoutTracker<'a> {
pub fn new(
- ctx: &'a BindgenContext<'ctx>,
+ ctx: &'a BindgenContext,
comp: &'a CompInfo,
name: &'a str,
) -> Self {
@@ -154,7 +151,7 @@ impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
field_name: &str,
field_ty: &Type,
field_offset: Option<usize>,
- ) -> Option<ast::StructField> {
+ ) -> Option<quote::Tokens> {
let mut field_layout = match field_ty.layout(self.ctx) {
Some(l) => l,
None => return None,
@@ -241,7 +238,7 @@ impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
padding_layout.map(|layout| self.padding_field(layout))
}
- pub fn pad_struct(&mut self, layout: Layout) -> Option<ast::StructField> {
+ pub fn pad_struct(&mut self, layout: Layout) -> Option<quote::Tokens> {
debug!(
"pad_struct:\n\tself = {:#?}\n\tlayout = {:#?}",
self,
@@ -291,17 +288,15 @@ impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
}
}
- pub fn align_struct(&self, layout: Layout) -> Option<ast::StructField> {
+ pub fn align_struct(&self, layout: Layout) -> Option<quote::Tokens> {
if self.max_field_align < layout.align &&
layout.align <= mem::size_of::<*mut ()>()
{
let ty = helpers::blob(Layout::new(0, layout.align));
- Some(
- StructFieldBuilder::named("__bindgen_align")
- .pub_()
- .build_ty(ty),
- )
+ Some(quote! {
+ pub __bindgen_align: #ty ,
+ })
} else {
None
}
@@ -311,19 +306,19 @@ impl<'a, 'ctx> StructLayoutTracker<'a, 'ctx> {
align_to(self.latest_offset, layout.align) - self.latest_offset
}
- fn padding_field(&mut self, layout: Layout) -> ast::StructField {
+ fn padding_field(&mut self, layout: Layout) -> quote::Tokens {
let ty = helpers::blob(layout);
let padding_count = self.padding_count;
self.padding_count += 1;
- let padding_field_name = format!("__bindgen_padding_{}", padding_count);
+ let padding_field_name = quote::Ident::new(format!("__bindgen_padding_{}", padding_count));
self.max_field_align = cmp::max(self.max_field_align, layout.align);
- StructFieldBuilder::named(padding_field_name)
- .pub_()
- .build_ty(ty)
+ quote! {
+ pub #padding_field_name : #ty ,
+ }
}
/// Returns whether the new field is known to merge with a bitfield.
diff --git a/src/ir/analysis/derive_copy.rs b/src/ir/analysis/derive_copy.rs
index 1890dcec..ef01c65a 100644
--- a/src/ir/analysis/derive_copy.rs
+++ b/src/ir/analysis/derive_copy.rs
@@ -31,11 +31,8 @@ use std::collections::HashSet;
/// derived copy if any of the template arguments or template definition
/// cannot derive copy.
#[derive(Debug, Clone)]
-pub struct CannotDeriveCopy<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct CannotDeriveCopy<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set cannot derive copy.
@@ -51,7 +48,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> CannotDeriveCopy<'ctx, 'gen> {
+impl<'ctx> CannotDeriveCopy<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
@@ -97,12 +94,12 @@ impl<'ctx, 'gen> CannotDeriveCopy<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveCopy<'ctx, 'gen> {
+ fn new(ctx: &'ctx BindgenContext) -> CannotDeriveCopy<'ctx> {
let cannot_derive_copy = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -336,8 +333,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveCopy<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<CannotDeriveCopy<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: CannotDeriveCopy<'ctx, 'gen>) -> Self {
+impl<'ctx> From<CannotDeriveCopy<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: CannotDeriveCopy<'ctx>) -> Self {
analysis.cannot_derive_copy
}
}
diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs
index b7a35132..2bfaff71 100644
--- a/src/ir/analysis/derive_debug.rs
+++ b/src/ir/analysis/derive_debug.rs
@@ -33,11 +33,8 @@ use std::collections::HashSet;
/// derived debug if any of the template arguments or template definition
/// cannot derive debug.
#[derive(Debug, Clone)]
-pub struct CannotDeriveDebug<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct CannotDeriveDebug<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set cannot derive debug.
@@ -53,7 +50,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> CannotDeriveDebug<'ctx, 'gen> {
+impl<'ctx> CannotDeriveDebug<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
@@ -99,12 +96,12 @@ impl<'ctx, 'gen> CannotDeriveDebug<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveDebug<'ctx, 'gen> {
+ fn new(ctx: &'ctx BindgenContext) -> CannotDeriveDebug<'ctx> {
let cannot_derive_debug = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -355,8 +352,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<CannotDeriveDebug<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: CannotDeriveDebug<'ctx, 'gen>) -> Self {
+impl<'ctx> From<CannotDeriveDebug<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: CannotDeriveDebug<'ctx>) -> Self {
analysis.cannot_derive_debug
}
}
diff --git a/src/ir/analysis/derive_default.rs b/src/ir/analysis/derive_default.rs
index 19f4a842..96805863 100644
--- a/src/ir/analysis/derive_default.rs
+++ b/src/ir/analysis/derive_default.rs
@@ -30,11 +30,8 @@ use std::collections::HashSet;
/// * If T is a compound type, default cannot be derived if any of its base member
/// or field cannot be derived default.
#[derive(Debug, Clone)]
-pub struct CannotDeriveDefault<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct CannotDeriveDefault<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set cannot derive default.
@@ -50,7 +47,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> CannotDeriveDefault<'ctx, 'gen> {
+impl<'ctx> CannotDeriveDefault<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
@@ -94,12 +91,12 @@ impl<'ctx, 'gen> CannotDeriveDefault<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDefault<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveDefault<'ctx, 'gen> {
+ fn new(ctx: &'ctx BindgenContext) -> CannotDeriveDefault<'ctx> {
let mut dependencies = HashMap::new();
let cannot_derive_default = HashSet::new();
@@ -388,8 +385,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDefault<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<CannotDeriveDefault<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: CannotDeriveDefault<'ctx, 'gen>) -> Self {
+impl<'ctx> From<CannotDeriveDefault<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: CannotDeriveDefault<'ctx>) -> Self {
analysis.cannot_derive_default
}
}
diff --git a/src/ir/analysis/derive_hash.rs b/src/ir/analysis/derive_hash.rs
index ee9cb23a..80ea0abf 100644
--- a/src/ir/analysis/derive_hash.rs
+++ b/src/ir/analysis/derive_hash.rs
@@ -33,11 +33,8 @@ use std::collections::HashSet;
/// derived hash if any of the template arguments or template definition
/// cannot derive hash.
#[derive(Debug, Clone)]
-pub struct CannotDeriveHash<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct CannotDeriveHash<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set cannot derive hash.
@@ -53,7 +50,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> CannotDeriveHash<'ctx, 'gen> {
+impl<'ctx> CannotDeriveHash<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
@@ -92,12 +89,12 @@ impl<'ctx, 'gen> CannotDeriveHash<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for CannotDeriveHash<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> CannotDeriveHash<'ctx, 'gen> {
+ fn new(ctx: &'ctx BindgenContext) -> CannotDeriveHash<'ctx> {
let cannot_derive_hash = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -356,8 +353,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveHash<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<CannotDeriveHash<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: CannotDeriveHash<'ctx, 'gen>) -> Self {
+impl<'ctx> From<CannotDeriveHash<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: CannotDeriveHash<'ctx>) -> Self {
analysis.cannot_derive_hash
}
}
diff --git a/src/ir/analysis/derive_partial_eq.rs b/src/ir/analysis/derive_partial_eq.rs
index 45ba67a5..96689601 100644
--- a/src/ir/analysis/derive_partial_eq.rs
+++ b/src/ir/analysis/derive_partial_eq.rs
@@ -33,11 +33,8 @@ use std::collections::HashSet;
/// derived partialeq if any of the template arguments or template definition
/// cannot derive partialeq.
#[derive(Debug, Clone)]
-pub struct CannotDerivePartialEq<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct CannotDerivePartialEq<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set cannot derive partialeq.
@@ -53,7 +50,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> CannotDerivePartialEq<'ctx, 'gen> {
+impl<'ctx> CannotDerivePartialEq<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type can derive
@@ -92,14 +89,14 @@ impl<'ctx, 'gen> CannotDerivePartialEq<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for CannotDerivePartialEq<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for CannotDerivePartialEq<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
fn new(
- ctx: &'ctx BindgenContext<'gen>,
- ) -> CannotDerivePartialEq<'ctx, 'gen> {
+ ctx: &'ctx BindgenContext,
+ ) -> CannotDerivePartialEq<'ctx> {
let cannot_derive_partialeq = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -365,8 +362,8 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDerivePartialEq<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<CannotDerivePartialEq<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: CannotDerivePartialEq<'ctx, 'gen>) -> Self {
+impl<'ctx> From<CannotDerivePartialEq<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: CannotDerivePartialEq<'ctx>) -> Self {
analysis.cannot_derive_partialeq
}
}
diff --git a/src/ir/analysis/has_destructor.rs b/src/ir/analysis/has_destructor.rs
index b37dbaaa..f6400d7d 100644
--- a/src/ir/analysis/has_destructor.rs
+++ b/src/ir/analysis/has_destructor.rs
@@ -23,11 +23,8 @@ use std::collections::HashSet;
/// * If T is the type of a field, that field has a destructor if it's not a bitfield,
/// and if T has a destructor.
#[derive(Debug, Clone)]
-pub struct HasDestructorAnalysis<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct HasDestructorAnalysis<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set definitely has a destructor.
@@ -43,7 +40,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> HasDestructorAnalysis<'ctx, 'gen> {
+impl<'ctx> HasDestructorAnalysis<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type has a
@@ -69,12 +66,12 @@ impl<'ctx, 'gen> HasDestructorAnalysis<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for HasDestructorAnalysis<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for HasDestructorAnalysis<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> Self {
+ fn new(ctx: &'ctx BindgenContext) -> Self {
let have_destructor = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -172,8 +169,8 @@ impl<'ctx, 'gen> MonotoneFramework for HasDestructorAnalysis<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<HasDestructorAnalysis<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: HasDestructorAnalysis<'ctx, 'gen>) -> Self {
+impl<'ctx> From<HasDestructorAnalysis<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: HasDestructorAnalysis<'ctx>) -> Self {
analysis.have_destructor
}
}
diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs
index 85fe241e..959a411b 100644
--- a/src/ir/analysis/has_float.rs
+++ b/src/ir/analysis/has_float.rs
@@ -23,10 +23,8 @@ use ir::comp::FieldMethods;
/// float if any of the template arguments or template definition
/// has.
#[derive(Debug, Clone)]
-pub struct HasFloat<'ctx, 'gen>
- where 'gen: 'ctx
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct HasFloat<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set has float.
@@ -42,7 +40,7 @@ pub struct HasFloat<'ctx, 'gen>
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> HasFloat<'ctx, 'gen> {
+impl<'ctx> HasFloat<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
EdgeKind::BaseMember |
@@ -79,12 +77,12 @@ impl<'ctx, 'gen> HasFloat<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for HasFloat<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> HasFloat<'ctx, 'gen> {
+ fn new(ctx: &'ctx BindgenContext) -> HasFloat<'ctx> {
let has_float = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -232,8 +230,8 @@ impl<'ctx, 'gen> MonotoneFramework for HasFloat<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<HasFloat<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: HasFloat<'ctx, 'gen>) -> Self {
+impl<'ctx> From<HasFloat<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: HasFloat<'ctx>) -> Self {
analysis.has_float
}
}
diff --git a/src/ir/analysis/has_type_param_in_array.rs b/src/ir/analysis/has_type_param_in_array.rs
index c361e9d9..f21bae14 100644
--- a/src/ir/analysis/has_type_param_in_array.rs
+++ b/src/ir/analysis/has_type_param_in_array.rs
@@ -23,11 +23,8 @@ use std::collections::HashSet;
/// type parameter in array if any of the template arguments or template definition
/// has.
#[derive(Debug, Clone)]
-pub struct HasTypeParameterInArray<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct HasTypeParameterInArray<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set has array.
@@ -43,7 +40,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> HasTypeParameterInArray<'ctx, 'gen> {
+impl<'ctx> HasTypeParameterInArray<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type has type parameter
@@ -86,14 +83,14 @@ impl<'ctx, 'gen> HasTypeParameterInArray<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for HasTypeParameterInArray<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
fn new(
- ctx: &'ctx BindgenContext<'gen>,
- ) -> HasTypeParameterInArray<'ctx, 'gen> {
+ ctx: &'ctx BindgenContext,
+ ) -> HasTypeParameterInArray<'ctx> {
let has_type_parameter_in_array = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -249,8 +246,8 @@ impl<'ctx, 'gen> MonotoneFramework for HasTypeParameterInArray<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<HasTypeParameterInArray<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: HasTypeParameterInArray<'ctx, 'gen>) -> Self {
+impl<'ctx> From<HasTypeParameterInArray<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: HasTypeParameterInArray<'ctx>) -> Self {
analysis.has_type_parameter_in_array
}
}
diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs
index bb85d0c9..b0d48738 100644
--- a/src/ir/analysis/has_vtable.rs
+++ b/src/ir/analysis/has_vtable.rs
@@ -18,11 +18,8 @@ use std::collections::HashSet;
/// * If T is an instantiation of an abstract template definition, T has
/// vtable if template definition has vtable
#[derive(Debug, Clone)]
-pub struct HasVtableAnalysis<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct HasVtableAnalysis<'ctx> {
+ ctx: &'ctx BindgenContext,
// The incremental result of this analysis's computation. Everything in this
// set definitely has a vtable.
@@ -38,7 +35,7 @@ where
dependencies: HashMap<ItemId, Vec<ItemId>>,
}
-impl<'ctx, 'gen> HasVtableAnalysis<'ctx, 'gen> {
+impl<'ctx> HasVtableAnalysis<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type has a
@@ -62,12 +59,12 @@ impl<'ctx, 'gen> HasVtableAnalysis<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for HasVtableAnalysis<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for HasVtableAnalysis<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashSet<ItemId>;
- fn new(ctx: &'ctx BindgenContext<'gen>) -> HasVtableAnalysis<'ctx, 'gen> {
+ fn new(ctx: &'ctx BindgenContext) -> HasVtableAnalysis<'ctx> {
let have_vtable = HashSet::new();
let dependencies = generate_dependencies(ctx, Self::consider_edge);
@@ -147,8 +144,8 @@ impl<'ctx, 'gen> MonotoneFramework for HasVtableAnalysis<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<HasVtableAnalysis<'ctx, 'gen>> for HashSet<ItemId> {
- fn from(analysis: HasVtableAnalysis<'ctx, 'gen>) -> Self {
+impl<'ctx> From<HasVtableAnalysis<'ctx>> for HashSet<ItemId> {
+ fn from(analysis: HasVtableAnalysis<'ctx>) -> Self {
analysis.have_vtable
}
}
diff --git a/src/ir/analysis/template_params.rs b/src/ir/analysis/template_params.rs
index caaa8f30..7699a0c2 100644
--- a/src/ir/analysis/template_params.rs
+++ b/src/ir/analysis/template_params.rs
@@ -146,11 +146,8 @@ use std::collections::{HashMap, HashSet};
/// specially; see `constrain_instantiation_of_blacklisted_template` and its
/// documentation for details.
#[derive(Debug, Clone)]
-pub struct UsedTemplateParameters<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+pub struct UsedTemplateParameters<'ctx> {
+ ctx: &'ctx BindgenContext,
// The Option is only there for temporary moves out of the hash map. See the
// comments in `UsedTemplateParameters::constrain` below.
@@ -164,7 +161,7 @@ where
whitelisted_items: HashSet<ItemId>,
}
-impl<'ctx, 'gen> UsedTemplateParameters<'ctx, 'gen> {
+impl<'ctx> UsedTemplateParameters<'ctx> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// For each of these kinds of edges, if the referent uses a template
@@ -367,14 +364,14 @@ impl<'ctx, 'gen> UsedTemplateParameters<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> MonotoneFramework for UsedTemplateParameters<'ctx, 'gen> {
+impl<'ctx> MonotoneFramework for UsedTemplateParameters<'ctx> {
type Node = ItemId;
- type Extra = &'ctx BindgenContext<'gen>;
+ type Extra = &'ctx BindgenContext;
type Output = HashMap<ItemId, ItemSet>;
fn new(
- ctx: &'ctx BindgenContext<'gen>,
- ) -> UsedTemplateParameters<'ctx, 'gen> {
+ ctx: &'ctx BindgenContext,
+ ) -> UsedTemplateParameters<'ctx> {
let mut used = HashMap::new();
let mut dependencies = HashMap::new();
let whitelisted_items: HashSet<_> =
@@ -578,9 +575,9 @@ impl<'ctx, 'gen> MonotoneFramework for UsedTemplateParameters<'ctx, 'gen> {
}
}
-impl<'ctx, 'gen> From<UsedTemplateParameters<'ctx, 'gen>>
+impl<'ctx> From<UsedTemplateParameters<'ctx>>
for HashMap<ItemId, ItemSet> {
- fn from(used_templ_params: UsedTemplateParameters<'ctx, 'gen>) -> Self {
+ fn from(used_templ_params: UsedTemplateParameters<'ctx>) -> Self {
used_templ_params
.used
.into_iter()
diff --git a/src/ir/context.rs b/src/ir/context.rs
index cfbb3766..af1e95e9 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -22,16 +22,13 @@ use cexpr;
use clang::{self, Cursor};
use clang_sys;
use parse::ClangItemParser;
+use quote;
use std::borrow::Cow;
use std::cell::Cell;
use std::collections::{HashMap, HashSet, hash_map};
use std::collections::btree_map::{self, BTreeMap};
-use std::fmt;
use std::iter::IntoIterator;
use std::mem;
-use syntax::ast::Ident;
-use syntax::codemap::{DUMMY_SP, Span};
-use syntax::ext::base::ExtCtxt;
/// A single identifier for an item.
///
@@ -98,19 +95,9 @@ enum TypeKey {
Declaration(Cursor),
}
-// This is just convenience to avoid creating a manual debug impl for the
-// context.
-struct GenContext<'ctx>(ExtCtxt<'ctx>);
-
-impl<'ctx> fmt::Debug for GenContext<'ctx> {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(fmt, "GenContext {{ ... }}")
- }
-}
-
/// A context used during parsing and generation of structs.
#[derive(Debug)]
-pub struct BindgenContext<'ctx> {
+pub struct BindgenContext {
/// The map of all the items parsed so far.
///
/// It's a BTreeMap because we want the keys to be sorted to have consistent
@@ -168,9 +155,7 @@ pub struct BindgenContext<'ctx> {
collected_typerefs: bool,
- /// Dummy structures for code generation.
- gen_ctx: Option<&'ctx GenContext<'ctx>>,
- span: Span,
+ in_codegen: bool,
/// The clang index for parsing.
index: clang::Index,
@@ -268,24 +253,17 @@ pub struct BindgenContext<'ctx> {
}
/// A traversal of whitelisted items.
-struct WhitelistedItemsTraversal<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- ctx: &'ctx BindgenContext<'gen>,
+struct WhitelistedItemsTraversal<'ctx> {
+ ctx: &'ctx BindgenContext,
traversal: ItemTraversal<
'ctx,
- 'gen,
ItemSet,
Vec<ItemId>,
for<'a> fn(&'a BindgenContext, Edge) -> bool,
>,
}
-impl<'ctx, 'gen> Iterator for WhitelistedItemsTraversal<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
+impl<'ctx> Iterator for WhitelistedItemsTraversal<'ctx> {
type Item = ItemId;
fn next(&mut self) -> Option<ItemId> {
@@ -301,13 +279,10 @@ where
}
}
-impl<'ctx, 'gen> WhitelistedItemsTraversal<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
+impl<'ctx> WhitelistedItemsTraversal<'ctx> {
/// Construct a new whitelisted items traversal.
pub fn new<R>(
- ctx: &'ctx BindgenContext<'gen>,
+ ctx: &'ctx BindgenContext,
roots: R,
predicate: for<'a> fn(&'a BindgenContext, Edge) -> bool,
) -> Self
@@ -344,7 +319,7 @@ fn find_effective_target(clang_args: &[String]) -> (String, bool) {
(HOST_TARGET.to_owned(), false)
}
-impl<'ctx> BindgenContext<'ctx> {
+impl BindgenContext {
/// Construct the context for the given `options`.
pub fn new(options: BindgenOptions) -> Self {
use clang_sys;
@@ -402,8 +377,7 @@ impl<'ctx> BindgenContext<'ctx> {
parsed_macros: Default::default(),
replacements: Default::default(),
collected_typerefs: false,
- gen_ctx: None,
- span: DUMMY_SP,
+ in_codegen: false,
index: index,
translation_unit: translation_unit,
options: options,
@@ -632,24 +606,67 @@ impl<'ctx> BindgenContext<'ctx> {
// TODO: Move all this syntax crap to other part of the code.
- /// Given that we are in the codegen phase, get the syntex context.
- pub fn ext_cx(&self) -> &ExtCtxt<'ctx> {
- &self.gen_ctx.expect("Not in gen phase").0
- }
-
- /// Given that we are in the codegen phase, get the current syntex span.
- pub fn span(&self) -> Span {
- self.span
- }
-
/// Mangles a name so it doesn't conflict with any keyword.
pub fn rust_mangle<'a>(&self, name: &'a str) -> Cow<'a, str> {
- use syntax::parse::token;
- let ident = self.rust_ident_raw(name);
- let token = token::Ident(ident);
- if token.is_any_keyword() || name.contains("@") ||
- name.contains("?") || name.contains("$") ||
- "bool" == name
+ if name.contains("@") ||
+ name.contains("?") ||
+ name.contains("$") ||
+ match name {
+ "abstract" |
+ "alignof" |
+ "as" |
+ "become" |
+ "box" |
+ "break" |
+ "const" |
+ "continue" |
+ "crate" |
+ "do" |
+ "else" |
+ "enum" |
+ "extern" |
+ "false" |
+ "final" |
+ "fn" |
+ "for" |
+ "if" |
+ "impl" |
+ "in" |
+ "let" |
+ "loop" |
+ "macro" |
+ "match" |
+ "mod" |
+ "move" |
+ "mut" |
+ "offsetof" |
+ "override" |
+ "priv" |
+ "proc" |
+ "pub" |
+ "pure" |
+ "ref" |
+ "return" |
+ "Self" |
+ "self" |
+ "sizeof" |
+ "static" |
+ "struct" |
+ "super" |
+ "trait" |
+ "true" |
+ "type" |
+ "typeof" |
+ "unsafe" |
+ "unsized" |
+ "use" |
+ "virtual" |
+ "where" |
+ "while" |
+ "yield" |
+ "bool" => true,
+ _ => false,
+ }
{
let mut s = name.to_owned();
s = s.replace("@", "_");
@@ -662,13 +679,19 @@ impl<'ctx> BindgenContext<'ctx> {
}
/// Returns a mangled name as a rust identifier.
- pub fn rust_ident(&self, name: &str) -> Ident {
- self.rust_ident_raw(&self.rust_mangle(name))
+ pub fn rust_ident<S>(&self, name: S) -> quote::Ident
+ where
+ S: AsRef<str>
+ {
+ self.rust_ident_raw(self.rust_mangle(name.as_ref()))
}
/// Returns a mangled name as a rust identifier.
- pub fn rust_ident_raw(&self, name: &str) -> Ident {
- self.ext_cx().ident_of(name)
+ pub fn rust_ident_raw<T>(&self, name: T) -> quote::Ident
+ where
+ T: Into<quote::Ident>
+ {
+ name.into()
}
/// Iterate over all items that have been defined.
@@ -891,30 +914,7 @@ impl<'ctx> BindgenContext<'ctx> {
where
F: FnOnce(&Self) -> Out,
{
- use aster::symbol::ToSymbol;
- use syntax::ext::expand::ExpansionConfig;
- use syntax::codemap::{ExpnInfo, MacroBang, NameAndSpan};
- use syntax::ext::base;
- use syntax::parse;
-
- let cfg = ExpansionConfig::default("xxx".to_owned());
- let sess = parse::ParseSess::new();
- let mut loader = base::DummyResolver;
- let mut ctx = GenContext(base::ExtCtxt::new(&sess, cfg, &mut loader));
-
- ctx.0.bt_push(ExpnInfo {
- call_site: self.span,
- callee: NameAndSpan {
- format: MacroBang("".to_symbol()),
- allow_internal_unstable: false,
- span: None,
- },
- });
-
- // FIXME: This is evil, we should move code generation to use a wrapper
- // of BindgenContext instead, I guess. Even though we know it's fine
- // because we remove it before the end of this function.
- self.gen_ctx = Some(unsafe { mem::transmute(&ctx) });
+ self.in_codegen = true;
self.assert_no_dangling_references();
@@ -950,7 +950,7 @@ impl<'ctx> BindgenContext<'ctx> {
self.compute_cannot_derive_partialeq_or_eq();
let ret = cb(self);
- self.gen_ctx = None;
+ self.in_codegen = false;
ret
}
@@ -965,9 +965,9 @@ impl<'ctx> BindgenContext<'ctx> {
}
}
- fn assert_no_dangling_item_traversal<'me>(
- &'me self,
- ) -> traversal::AssertNoDanglingItemsTraversal<'me, 'ctx> {
+ fn assert_no_dangling_item_traversal(
+ &self,
+ ) -> traversal::AssertNoDanglingItemsTraversal {
assert!(self.in_codegen_phase());
assert!(self.current_module == self.root_module);
@@ -1735,7 +1735,7 @@ impl<'ctx> BindgenContext<'ctx> {
/// Are we in the codegen phase?
pub fn in_codegen_phase(&self) -> bool {
- self.gen_ctx.is_some()
+ self.in_codegen
}
/// Mark the type with the given `name` as replaced by the type with id
@@ -2031,7 +2031,7 @@ impl<'ctx> BindgenContext<'ctx> {
/// Convenient method for getting the prefix to use for most traits in
/// codegen depending on the `use_core` option.
- pub fn trait_prefix(&self) -> Ident {
+ pub fn trait_prefix(&self) -> quote::Ident {
if self.options().use_core {
self.rust_ident_raw("core")
} else {
@@ -2244,7 +2244,7 @@ impl ItemResolver {
}
/// Finish configuring and perform the actual item resolution.
- pub fn resolve<'a, 'b>(self, ctx: &'a BindgenContext<'b>) -> &'a Item {
+ pub fn resolve(self, ctx: &BindgenContext) -> &Item {
assert!(ctx.collected_typerefs());
let mut id = self.id;
diff --git a/src/ir/function.rs b/src/ir/function.rs
index 3cf48db7..b08824af 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -11,8 +11,8 @@ use clang_sys::{self, CXCallingConv};
use ir::derive::{CanTriviallyDeriveDebug, CanTriviallyDeriveHash,
CanTriviallyDerivePartialEq};
use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult};
+use quote;
use std::io;
-use syntax::abi;
const RUST_DERIVE_FUNPTR_LIMIT: usize = 12;
@@ -136,8 +136,16 @@ impl DotAttributes for Function {
/// An ABI extracted from a clang cursor.
#[derive(Debug, Copy, Clone)]
pub enum Abi {
- /// A known ABI, that rust also understand.
- Known(abi::Abi),
+ /// The default C ABI.
+ C,
+ /// The "stdcall" ABI.
+ Stdcall,
+ /// The "fastcall" ABI.
+ Fastcall,
+ /// The "aapcs" ABI.
+ Aapcs,
+ /// The "win64" ABI.
+ Win64,
/// An unknown or invalid ABI.
Unknown(CXCallingConv),
}
@@ -152,6 +160,22 @@ impl Abi {
}
}
+impl quote::ToTokens for Abi {
+ fn to_tokens(&self, tokens: &mut quote::Tokens) {
+ tokens.append(match *self {
+ Abi::C => quote! { "C" },
+ Abi::Stdcall => quote! { "stdcall" },
+ Abi::Fastcall => quote! { "fastcall" },
+ Abi::Aapcs => quote! { "aapcs" },
+ Abi::Win64 => quote! { "win64" },
+ Abi::Unknown(cc) => panic!(
+ "Cannot turn unknown calling convention to tokens: {:?}",
+ cc
+ ),
+ });
+ }
+}
+
/// A function signature.
#[derive(Debug)]
pub struct FunctionSig {
@@ -171,15 +195,15 @@ pub struct FunctionSig {
fn get_abi(cc: CXCallingConv) -> Abi {
use clang_sys::*;
- Abi::Known(match cc {
- CXCallingConv_Default => abi::Abi::C,
- CXCallingConv_C => abi::Abi::C,
- CXCallingConv_X86StdCall => abi::Abi::Stdcall,
- CXCallingConv_X86FastCall => abi::Abi::Fastcall,
- CXCallingConv_AAPCS => abi::Abi::Aapcs,
- CXCallingConv_X86_64Win64 => abi::Abi::Win64,
- other => return Abi::Unknown(other),
- })
+ match cc {
+ CXCallingConv_Default => Abi::C,
+ CXCallingConv_C => Abi::C,
+ CXCallingConv_X86StdCall => Abi::Stdcall,
+ CXCallingConv_X86FastCall => Abi::Fastcall,
+ CXCallingConv_AAPCS => Abi::Aapcs,
+ CXCallingConv_X86_64Win64 => Abi::Win64,
+ other => Abi::Unknown(other),
+ }
}
fn mangling_hack_if_needed(ctx: &BindgenContext, symbol: &mut String) {
@@ -513,8 +537,7 @@ impl CanTriviallyDeriveDebug for FunctionSig {
}
match self.abi {
- Abi::Known(abi::Abi::C) |
- Abi::Unknown(..) => true,
+ Abi::C | Abi::Unknown(..) => true,
_ => false,
}
}
@@ -527,8 +550,7 @@ impl CanTriviallyDeriveHash for FunctionSig {
}
match self.abi {
- Abi::Known(abi::Abi::C) |
- Abi::Unknown(..) => true,
+ Abi::C | Abi::Unknown(..) => true,
_ => false,
}
}
@@ -541,8 +563,7 @@ impl CanTriviallyDerivePartialEq for FunctionSig {
}
match self.abi {
- Abi::Known(abi::Abi::C) |
- Abi::Unknown(..) => true,
+ Abi::C | Abi::Unknown(..) => true,
_ => false,
}
}
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 0dac1287..241bd9ef 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -93,10 +93,10 @@ pub trait HasFloat {
/// up to (but not including) the implicit root module.
pub trait ItemAncestors {
/// Get an iterable over this item's ancestors.
- fn ancestors<'a, 'b>(
+ fn ancestors<'a>(
&self,
- ctx: &'a BindgenContext<'b>,
- ) -> ItemAncestorsIter<'a, 'b>;
+ ctx: &'a BindgenContext,
+ ) -> ItemAncestorsIter<'a>;
}
cfg_if! {
@@ -120,20 +120,14 @@ cfg_if! {
}
/// An iterator over an item and its ancestors.
-pub struct ItemAncestorsIter<'a, 'b>
-where
- 'b: 'a,
-{
+pub struct ItemAncestorsIter<'a> {
item: ItemId,
- ctx: &'a BindgenContext<'b>,
+ ctx: &'a BindgenContext,
seen: DebugOnlyItemSet,
}
-impl<'a, 'b> ItemAncestorsIter<'a, 'b>
-where
- 'b: 'a,
-{
- fn new(ctx: &'a BindgenContext<'b>, item: ItemId) -> Self {
+impl<'a> ItemAncestorsIter<'a> {
+ fn new(ctx: &'a BindgenContext, item: ItemId) -> Self {
ItemAncestorsIter {
item: item,
ctx: ctx,
@@ -142,10 +136,7 @@ where
}
}
-impl<'a, 'b> Iterator for ItemAncestorsIter<'a, 'b>
-where
- 'b: 'a,
-{
+impl<'a> Iterator for ItemAncestorsIter<'a> {
type Item = ItemId;
fn next(&mut self) -> Option<Self::Item> {
@@ -238,19 +229,19 @@ impl ItemCanonicalPath for ItemId {
}
impl ItemAncestors for ItemId {
- fn ancestors<'a, 'b>(
+ fn ancestors<'a>(
&self,
- ctx: &'a BindgenContext<'b>,
- ) -> ItemAncestorsIter<'a, 'b> {
+ ctx: &'a BindgenContext,
+ ) -> ItemAncestorsIter<'a> {
ItemAncestorsIter::new(ctx, *self)
}
}
impl ItemAncestors for Item {
- fn ancestors<'a, 'b>(
+ fn ancestors<'a>(
&self,
- ctx: &'a BindgenContext<'b>,
- ) -> ItemAncestorsIter<'a, 'b> {
+ ctx: &'a BindgenContext,
+ ) -> ItemAncestorsIter<'a> {
self.id().ancestors(ctx)
}
}
@@ -638,10 +629,10 @@ impl Item {
}
/// Take out item NameOptions
- pub fn name<'item, 'ctx>(
- &'item self,
- ctx: &'item BindgenContext<'ctx>,
- ) -> NameOptions<'item, 'ctx> {
+ pub fn name<'a>(
+ &'a self,
+ ctx: &'a BindgenContext,
+ ) -> NameOptions<'a> {
NameOptions::new(self, ctx)
}
@@ -1773,18 +1764,15 @@ impl ItemCanonicalPath for Item {
/// Builder struct for naming variations, which hold inside different
/// flags for naming options.
#[derive(Debug)]
-pub struct NameOptions<'item, 'ctx>
-where
- 'ctx: 'item,
-{
- item: &'item Item,
- ctx: &'item BindgenContext<'ctx>,
+pub struct NameOptions<'a> {
+ item: &'a Item,
+ ctx: &'a BindgenContext,
within_namespaces: bool,
}
-impl<'item, 'ctx> NameOptions<'item, 'ctx> {
+impl<'a> NameOptions<'a> {
/// Construct a new `NameOptions`
- pub fn new(item: &'item Item, ctx: &'item BindgenContext<'ctx>) -> Self {
+ pub fn new(item: &'a Item, ctx: &'a BindgenContext) -> Self {
NameOptions {
item: item,
ctx: ctx,
diff --git a/src/ir/objc.rs b/src/ir/objc.rs
index 843dd722..cabbd389 100644
--- a/src/ir/objc.rs
+++ b/src/ir/objc.rs
@@ -12,6 +12,7 @@ use clang_sys::CXCursor_ObjCClassRef;
use clang_sys::CXCursor_ObjCInstanceMethodDecl;
use clang_sys::CXCursor_ObjCProtocolDecl;
use clang_sys::CXCursor_ObjCProtocolRef;
+use quote;
/// Objective C interface as used in TypeKind
///
@@ -211,13 +212,19 @@ impl ObjCMethod {
}
/// Formats the method call
- pub fn format_method_call(&self, args: &[String]) -> String {
- let split_name: Vec<&str> =
- self.name.split(':').filter(|p| !p.is_empty()).collect();
+ pub fn format_method_call(&self, args: &[quote::Tokens]) -> quote::Tokens {
+ let split_name: Vec<_> = self.name
+ .split(':')
+ .filter(|p| !p.is_empty())
+ .map(quote::Ident::new)
+ .collect();
// No arguments
if args.len() == 0 && split_name.len() == 1 {
- return split_name[0].to_string();
+ let name = &split_name[0];
+ return quote! {
+ #name
+ };
}
// Check right amount of arguments
@@ -229,12 +236,14 @@ impl ObjCMethod {
);
}
- split_name
- .iter()
+ let args = split_name
+ .into_iter()
.zip(args.iter())
- .map(|parts| format!("{}:{} ", parts.0, parts.1))
- .collect::<Vec<_>>()
- .join("")
+ .map(|(arg, ty)| quote! { #arg : #ty });
+
+ quote! {
+ #( #args ),*
+ }
}
}
diff --git a/src/ir/traversal.rs b/src/ir/traversal.rs
index e4ce946d..f55acc10 100644
--- a/src/ir/traversal.rs
+++ b/src/ir/traversal.rs
@@ -241,9 +241,9 @@ pub fn codegen_edges(ctx: &BindgenContext, edge: Edge) -> bool {
/// The storage for the set of items that have been seen (although their
/// outgoing edges might not have been fully traversed yet) in an active
/// traversal.
-pub trait TraversalStorage<'ctx, 'gen> {
+pub trait TraversalStorage<'ctx> {
/// Construct a new instance of this TraversalStorage, for a new traversal.
- fn new(ctx: &'ctx BindgenContext<'gen>) -> Self;
+ fn new(ctx: &'ctx BindgenContext) -> Self;
/// Add the given item to the storage. If the item has never been seen
/// before, return `true`. Otherwise, return `false`.
@@ -253,8 +253,8 @@ pub trait TraversalStorage<'ctx, 'gen> {
fn add(&mut self, from: Option<ItemId>, item: ItemId) -> bool;
}
-impl<'ctx, 'gen> TraversalStorage<'ctx, 'gen> for ItemSet {
- fn new(_: &'ctx BindgenContext<'gen>) -> Self {
+impl<'ctx> TraversalStorage<'ctx> for ItemSet {
+ fn new(_: &'ctx BindgenContext) -> Self {
ItemSet::new()
}
@@ -267,18 +267,13 @@ impl<'ctx, 'gen> TraversalStorage<'ctx, 'gen> for ItemSet {
/// each item. This is useful for providing debug assertions with meaningful
/// diagnostic messages about dangling items.
#[derive(Debug)]
-pub struct Paths<'ctx, 'gen>(
+pub struct Paths<'ctx>(
BTreeMap<ItemId, ItemId>,
- &'ctx BindgenContext<'gen>
-)
-where
- 'gen: 'ctx;
+ &'ctx BindgenContext
+);
-impl<'ctx, 'gen> TraversalStorage<'ctx, 'gen> for Paths<'ctx, 'gen>
-where
- 'gen: 'ctx,
-{
- fn new(ctx: &'ctx BindgenContext<'gen>) -> Self {
+impl<'ctx> TraversalStorage<'ctx> for Paths<'ctx> {
+ fn new(ctx: &'ctx BindgenContext) -> Self {
Paths(BTreeMap::new(), ctx)
}
@@ -388,14 +383,13 @@ pub trait Trace {
/// An graph traversal of the transitive closure of references between items.
///
/// See `BindgenContext::whitelisted_items` for more information.
-pub struct ItemTraversal<'ctx, 'gen, Storage, Queue, Predicate>
+pub struct ItemTraversal<'ctx, Storage, Queue, Predicate>
where
- 'gen: 'ctx,
- Storage: TraversalStorage<'ctx, 'gen>,
+ Storage: TraversalStorage<'ctx>,
Queue: TraversalQueue,
Predicate: TraversalPredicate,
{
- ctx: &'ctx BindgenContext<'gen>,
+ ctx: &'ctx BindgenContext,
/// The set of items we have seen thus far in this traversal.
seen: Storage,
@@ -410,20 +404,19 @@ where
currently_traversing: Option<ItemId>,
}
-impl<'ctx, 'gen, Storage, Queue, Predicate>
- ItemTraversal<'ctx, 'gen, Storage, Queue, Predicate>
+impl<'ctx, Storage, Queue, Predicate>
+ ItemTraversal<'ctx, Storage, Queue, Predicate>
where
- 'gen: 'ctx,
- Storage: TraversalStorage<'ctx, 'gen>,
+ Storage: TraversalStorage<'ctx>,
Queue: TraversalQueue,
Predicate: TraversalPredicate,
{
/// Begin a new traversal, starting from the given roots.
pub fn new<R>(
- ctx: &'ctx BindgenContext<'gen>,
+ ctx: &'ctx BindgenContext,
roots: R,
predicate: Predicate,
- ) -> ItemTraversal<'ctx, 'gen, Storage, Queue, Predicate>
+ ) -> ItemTraversal<'ctx, Storage, Queue, Predicate>
where
R: IntoIterator<Item = ItemId>,
{
@@ -445,11 +438,10 @@ where
}
}
-impl<'ctx, 'gen, Storage, Queue, Predicate> Tracer
- for ItemTraversal<'ctx, 'gen, Storage, Queue, Predicate>
+impl<'ctx, Storage, Queue, Predicate> Tracer
+ for ItemTraversal<'ctx, Storage, Queue, Predicate>
where
- 'gen: 'ctx,
- Storage: TraversalStorage<'ctx, 'gen>,
+ Storage: TraversalStorage<'ctx>,
Queue: TraversalQueue,
Predicate: TraversalPredicate,
{
@@ -467,11 +459,10 @@ where
}
}
-impl<'ctx, 'gen, Storage, Queue, Predicate> Iterator
- for ItemTraversal<'ctx, 'gen, Storage, Queue, Predicate>
+impl<'ctx, Storage, Queue, Predicate> Iterator
+ for ItemTraversal<'ctx, Storage, Queue, Predicate>
where
- 'gen: 'ctx,
- Storage: TraversalStorage<'ctx, 'gen>,
+ Storage: TraversalStorage<'ctx>,
Queue: TraversalQueue,
Predicate: TraversalPredicate,
{
@@ -505,11 +496,10 @@ where
///
/// See `BindgenContext::assert_no_dangling_item_traversal` for more
/// information.
-pub type AssertNoDanglingItemsTraversal<'ctx, 'gen> =
+pub type AssertNoDanglingItemsTraversal<'ctx> =
ItemTraversal<
'ctx,
- 'gen,
- Paths<'ctx, 'gen>,
+ Paths<'ctx>,
VecDeque<ItemId>,
for<'a> fn(&'a BindgenContext, Edge) -> bool,
>;
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b588dbb4..8cfbde10 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -443,6 +443,8 @@ impl DotAttributes for TypeKind {
where
W: io::Write,
{
+ writeln!(out, "<tr><td>type kind</td><td>{}</td></tr>", self.kind_name())?;
+
if let TypeKind::Comp(ref comp) = *self {
comp.dot_attributes(ctx, out)?;
}
@@ -451,6 +453,35 @@ impl DotAttributes for TypeKind {
}
}
+impl TypeKind {
+ fn kind_name(&self) -> &'static str {
+ match *self {
+ TypeKind::Void => "Void",
+ TypeKind::NullPtr => "NullPtr",
+ TypeKind::Comp(..) => "Comp",
+ TypeKind::Opaque => "Opaque",
+ TypeKind::Int(..) => "Int",
+ TypeKind::Float(..) => "Float",
+ TypeKind::Complex(..) => "Complex",
+ TypeKind::Alias(..) => "Alias",
+ TypeKind::TemplateAlias(..) => "TemplateAlias",
+ TypeKind::Array(..) => "Array",
+ TypeKind::Function(..) => "Function",
+ TypeKind::Enum(..) => "Enum",
+ TypeKind::Pointer(..) => "Pointer",
+ TypeKind::BlockPointer => "BlockPointer",
+ TypeKind::Reference(..) => "Reference",
+ TypeKind::TemplateInstantiation(..) => "TemplateInstantiation",
+ TypeKind::UnresolvedTypeRef(..) => "UnresolvedTypeRef",
+ TypeKind::ResolvedTypeRef(..) => "ResolvedTypeRef",
+ TypeKind::TypeParam => "TypeParam",
+ TypeKind::ObjCInterface(..) => "ObjCInterface",
+ TypeKind::ObjCId => "ObjCId",
+ TypeKind::ObjCSel => "ObjCSel",
+ }
+ }
+}
+
#[test]
fn is_invalid_type_param_valid() {
let ty = Type::new(Some("foo".into()), None, TypeKind::TypeParam, false);
diff --git a/src/lib.rs b/src/lib.rs
index 91b7d8d4..ed63724a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,19 +13,20 @@
// To avoid rather annoying warnings when matching with CXCursor_xxx as a
// constant.
#![allow(non_upper_case_globals)]
+// `quote!` nests quite deeply.
+#![recursion_limit="128"]
+extern crate cexpr;
#[macro_use]
#[allow(unused_extern_crates)]
extern crate cfg_if;
-extern crate cexpr;
-extern crate syntex_syntax as syntax;
-extern crate aster;
-extern crate quasi;
extern crate clang_sys;
-extern crate peeking_take_while;
-extern crate regex;
#[macro_use]
extern crate lazy_static;
+extern crate peeking_take_while;
+#[macro_use]
+extern crate quote;
+extern crate regex;
extern crate which;
#[cfg(feature = "logging")]
@@ -60,6 +61,7 @@ macro_rules! doc_mod {
}
mod clang;
+mod codegen;
mod features;
mod ir;
mod parse;
@@ -68,19 +70,12 @@ mod time;
pub mod callbacks;
-#[cfg(rustfmt)]
-mod codegen;
-
doc_mod!(clang, clang_docs);
doc_mod!(features, features_docs);
doc_mod!(ir, ir_docs);
doc_mod!(parse, parse_docs);
doc_mod!(regex_set, regex_set_docs);
-mod codegen {
- include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
-}
-
pub use features::{LATEST_STABLE_RUST, RUST_TARGET_STRINGS, RustTarget};
use features::RustFeatures;
use ir::context::{BindgenContext, ItemId};
@@ -95,12 +90,6 @@ use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::Arc;
-use syntax::ast;
-use syntax::codemap::{DUMMY_SP, Span};
-use syntax::print::pp::eof;
-use syntax::print::pprust;
-use syntax::ptr::P;
-
/// A type used to indicate which kind of items do we have to generate.
///
/// TODO(emilio): Use `bitflags!`
@@ -948,7 +937,7 @@ impl Builder {
}
/// Generate the Rust bindings using the options built up thus far.
- pub fn generate<'ctx>(mut self) -> Result<Bindings<'ctx>, ()> {
+ pub fn generate(mut self) -> Result<Bindings, ()> {
self.options.input_header = self.input_headers.pop();
self.options.clang_args.extend(
self.input_headers
@@ -964,7 +953,7 @@ impl Builder {
}),
);
- Bindings::generate(self.options, None)
+ Bindings::generate(self.options)
}
/// Preprocess and dump the input header files to disk.
@@ -1353,21 +1342,19 @@ fn ensure_libclang_is_loaded() {
/// Generated Rust bindings.
#[derive(Debug)]
-pub struct Bindings<'ctx> {
- context: BindgenContext<'ctx>,
- module: ast::Mod,
+pub struct Bindings {
+ context: BindgenContext,
+ module: quote::Tokens,
}
-impl<'ctx> Bindings<'ctx> {
+impl Bindings {
/// Generate bindings for the given options.
///
/// Deprecated - use a `Builder` instead
#[deprecated]
pub fn generate(
mut options: BindgenOptions,
- span: Option<Span>,
- ) -> Result<Bindings<'ctx>, ()> {
- let span = span.unwrap_or(DUMMY_SP);
+ ) -> Result<Bindings, ()> {
ensure_libclang_is_loaded();
options.build();
@@ -1436,38 +1423,30 @@ impl<'ctx> Bindings<'ctx> {
let time_phases = options.time_phases;
let mut context = BindgenContext::new(options);
+
{
let _t = time::Timer::new("parse")
.with_output(time_phases);
try!(parse(&mut context));
}
- let module = ast::Mod {
- inner: span,
- items: codegen::codegen(&mut context),
- };
+ let items = codegen::codegen(&mut context);
Ok(Bindings {
context: context,
- module: module,
+ module: quote! {
+ #( #items )*
+ }
})
}
- /// Convert these bindings into a Rust AST.
- pub fn into_ast(self) -> Vec<P<ast::Item>> {
- self.module.items
- }
-
/// Convert these bindings into source text (with raw lines prepended).
pub fn to_string(&self) -> String {
- let mut mod_str = vec![];
- {
- let ref_writer = Box::new(mod_str.by_ref()) as Box<Write>;
- self.write(ref_writer).expect(
- "Could not write bindings to string",
- );
- }
- String::from_utf8(mod_str).unwrap()
+ let mut bytes = vec![];
+ self.write(Box::new(&mut bytes) as Box<Write>)
+ .expect("writing to a vec cannot fail");
+ String::from_utf8(bytes)
+ .expect("we should only write bindings that are valid utf-8")
}
/// Write these bindings as source text to a file.
@@ -1488,27 +1467,26 @@ impl<'ctx> Bindings<'ctx> {
/// Write these bindings as source text to the given `Write`able.
pub fn write<'a>(&self, mut writer: Box<Write + 'a>) -> io::Result<()> {
- try!(writer.write(
+ writer.write(
"/* automatically generated by rust-bindgen */\n\n".as_bytes(),
- ));
+ )?;
for line in self.context.options().raw_lines.iter() {
- try!(writer.write(line.as_bytes()));
- try!(writer.write("\n".as_bytes()));
+ writer.write(line.as_bytes())?;
+ writer.write("\n".as_bytes())?;
}
if !self.context.options().raw_lines.is_empty() {
- try!(writer.write("\n".as_bytes()));
+ writer.write("\n".as_bytes())?;
}
- let mut ps = pprust::rust_printer(writer);
- try!(ps.print_mod(&self.module, &[]));
- try!(ps.print_remaining_comments());
- try!(eof(&mut ps.s));
- ps.s.out.flush()
+ writer.write(self.module.as_str().as_bytes())?;
+ Ok(())
}
/// Checks if rustfmt_bindings is set and runs rustfmt on the file
fn rustfmt_generated_file(&self, file: &Path) -> io::Result<()> {
+ let _t = self.context.timer("rustfmt_generated_file");
+
if !self.context.options().rustfmt_bindings {
return Ok(());
}
diff --git a/src/main.rs b/src/main.rs
index dc3572b3..eb3d6caf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,6 @@ extern crate env_logger;
#[macro_use]
#[cfg(feature = "logging")]
extern crate log;
-extern crate clang_sys;
extern crate clap;
use bindgen::clang_version;
diff --git a/src/time.rs b/src/time.rs
index ebbac702..c841bccf 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -37,12 +37,12 @@ impl<'a> Timer<'a> {
fn print_elapsed(&mut self) {
if self.output {
let elapsed = self.elapsed();
- let time = (elapsed.as_secs() as f32)
- + (elapsed.subsec_nanos() as f32) / 1e9;
+ let time = (elapsed.as_secs() as f64) * 1e3
+ + (elapsed.subsec_nanos() as f64) / 1e6;
let stderr = io::stderr();
// Arbitrary output format, subject to change.
writeln!(stderr.lock(),
- " time: {:.3} ms.\t{}",
+ " time: {:>9.3} ms.\t{}",
time, self.name)
.expect("timer write should not fail");
}
diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs
index 7305091a..0cd443a7 100644
--- a/tests/expectations/tests/annotation_hide.rs
+++ b/tests/expectations/tests/annotation_hide.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen opaque></div>
#[repr(C)]
#[derive(Debug, Default, Copy)]
@@ -12,13 +13,21 @@ pub struct D {
}
#[test]
fn bindgen_test_layout_D() {
- assert_eq!(::std::mem::size_of::<D>() , 4usize , concat ! (
- "Size of: " , stringify ! ( D ) ));
- assert_eq! (::std::mem::align_of::<D>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( D ) ));
+ assert_eq!(
+ ::std::mem::size_of::<D>(),
+ 4usize,
+ concat!("Size of: ", stringify!(D))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<D>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(D))
+ );
}
impl Clone for D {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
@@ -27,16 +36,29 @@ pub struct NotAnnotated {
}
#[test]
fn bindgen_test_layout_NotAnnotated() {
- assert_eq!(::std::mem::size_of::<NotAnnotated>() , 4usize , concat ! (
- "Size of: " , stringify ! ( NotAnnotated ) ));
- assert_eq! (::std::mem::align_of::<NotAnnotated>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<NotAnnotated>(),
+ 4usize,
+ concat!("Size of: ", stringify!(NotAnnotated))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<NotAnnotated>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/bitfield-32bit-overflow.rs b/tests/expectations/tests/bitfield-32bit-overflow.rs
index d179ddf9..9f7ea2e9 100644
--- a/tests/expectations/tests/bitfield-32bit-overflow.rs
+++ b/tests/expectations/tests/bitfield-32bit-overflow.rs
@@ -12,24 +12,32 @@ pub struct MuchBitfield {
}
#[test]
fn bindgen_test_layout_MuchBitfield() {
- assert_eq!(::std::mem::size_of::<MuchBitfield>() , 5usize , concat ! (
- "Size of: " , stringify ! ( MuchBitfield ) ));
- assert_eq! (::std::mem::align_of::<MuchBitfield>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( MuchBitfield ) ));
+ assert_eq!(
+ ::std::mem::size_of::<MuchBitfield>(),
+ 5usize,
+ concat!("Size of: ", stringify!(MuchBitfield))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<MuchBitfield>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(MuchBitfield))
+ );
}
impl Clone for MuchBitfield {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl MuchBitfield {
#[inline]
pub fn m0(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 1u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -41,31 +49,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m1(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 2u64 as u64;
let val = (unit_field_val & mask) >> 1usize;
@@ -77,31 +85,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m2(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 4u64 as u64;
let val = (unit_field_val & mask) >> 2usize;
@@ -113,31 +121,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m3(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 8u64 as u64;
let val = (unit_field_val & mask) >> 3usize;
@@ -149,31 +157,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m4(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 16u64 as u64;
let val = (unit_field_val & mask) >> 4usize;
@@ -185,31 +193,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 4usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m5(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 32u64 as u64;
let val = (unit_field_val & mask) >> 5usize;
@@ -221,31 +229,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 5usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m6(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 64u64 as u64;
let val = (unit_field_val & mask) >> 6usize;
@@ -257,31 +265,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 6usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m7(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 128u64 as u64;
let val = (unit_field_val & mask) >> 7usize;
@@ -293,31 +301,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m8(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 256u64 as u64;
let val = (unit_field_val & mask) >> 8usize;
@@ -329,31 +337,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m9(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 512u64 as u64;
let val = (unit_field_val & mask) >> 9usize;
@@ -365,31 +373,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 9usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m10(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 1024u64 as u64;
let val = (unit_field_val & mask) >> 10usize;
@@ -401,31 +409,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 10usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m11(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 2048u64 as u64;
let val = (unit_field_val & mask) >> 11usize;
@@ -437,31 +445,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 11usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m12(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 4096u64 as u64;
let val = (unit_field_val & mask) >> 12usize;
@@ -473,31 +481,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 12usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m13(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 8192u64 as u64;
let val = (unit_field_val & mask) >> 13usize;
@@ -509,31 +517,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 13usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m14(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 16384u64 as u64;
let val = (unit_field_val & mask) >> 14usize;
@@ -545,31 +553,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 14usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m15(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 32768u64 as u64;
let val = (unit_field_val & mask) >> 15usize;
@@ -581,31 +589,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 15usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m16(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 65536u64 as u64;
let val = (unit_field_val & mask) >> 16usize;
@@ -617,31 +625,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m17(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 131072u64 as u64;
let val = (unit_field_val & mask) >> 17usize;
@@ -653,31 +661,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 17usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m18(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 262144u64 as u64;
let val = (unit_field_val & mask) >> 18usize;
@@ -689,31 +697,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 18usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m19(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 524288u64 as u64;
let val = (unit_field_val & mask) >> 19usize;
@@ -725,31 +733,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 19usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m20(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 1048576u64 as u64;
let val = (unit_field_val & mask) >> 20usize;
@@ -761,31 +769,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 20usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m21(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 2097152u64 as u64;
let val = (unit_field_val & mask) >> 21usize;
@@ -797,31 +805,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 21usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m22(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 4194304u64 as u64;
let val = (unit_field_val & mask) >> 22usize;
@@ -833,31 +841,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 22usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m23(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 8388608u64 as u64;
let val = (unit_field_val & mask) >> 23usize;
@@ -869,31 +877,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 23usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m24(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 16777216u64 as u64;
let val = (unit_field_val & mask) >> 24usize;
@@ -905,31 +913,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m25(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 33554432u64 as u64;
let val = (unit_field_val & mask) >> 25usize;
@@ -941,31 +949,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 25usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m26(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 67108864u64 as u64;
let val = (unit_field_val & mask) >> 26usize;
@@ -977,31 +985,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 26usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m27(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 134217728u64 as u64;
let val = (unit_field_val & mask) >> 27usize;
@@ -1013,31 +1021,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 27usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m28(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 268435456u64 as u64;
let val = (unit_field_val & mask) >> 28usize;
@@ -1049,31 +1057,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 28usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m29(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 536870912u64 as u64;
let val = (unit_field_val & mask) >> 29usize;
@@ -1085,31 +1093,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 29usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m30(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 1073741824u64 as u64;
let val = (unit_field_val & mask) >> 30usize;
@@ -1121,31 +1129,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 30usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m31(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 2147483648u64 as u64;
let val = (unit_field_val & mask) >> 31usize;
@@ -1157,31 +1165,31 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 31usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn m32(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 4294967296u64 as u64;
let val = (unit_field_val & mask) >> 32usize;
@@ -1193,408 +1201,90 @@ impl MuchBitfield {
let val = val as u8 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 32usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(m0: ::std::os::raw::c_char,
- m1: ::std::os::raw::c_char,
- m2: ::std::os::raw::c_char,
- m3: ::std::os::raw::c_char,
- m4: ::std::os::raw::c_char,
- m5: ::std::os::raw::c_char,
- m6: ::std::os::raw::c_char,
- m7: ::std::os::raw::c_char,
- m8: ::std::os::raw::c_char,
- m9: ::std::os::raw::c_char,
- m10: ::std::os::raw::c_char,
- m11: ::std::os::raw::c_char,
- m12: ::std::os::raw::c_char,
- m13: ::std::os::raw::c_char,
- m14: ::std::os::raw::c_char,
- m15: ::std::os::raw::c_char,
- m16: ::std::os::raw::c_char,
- m17: ::std::os::raw::c_char,
- m18: ::std::os::raw::c_char,
- m19: ::std::os::raw::c_char,
- m20: ::std::os::raw::c_char,
- m21: ::std::os::raw::c_char,
- m22: ::std::os::raw::c_char,
- m23: ::std::os::raw::c_char,
- m24: ::std::os::raw::c_char,
- m25: ::std::os::raw::c_char,
- m26: ::std::os::raw::c_char,
- m27: ::std::os::raw::c_char,
- m28: ::std::os::raw::c_char,
- m29: ::std::os::raw::c_char,
- m30: ::std::os::raw::c_char,
- m31: ::std::os::raw::c_char,
- m32: ::std::os::raw::c_char) -> u64 {
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- 0
- }
- |
- ((m0
- as
- u8
- as
- u64)
- <<
- 0usize)
- &
- (1u64
- as
- u64))
- }
- |
- ((m1
- as
- u8
- as
- u64)
- <<
- 1usize)
- &
- (2u64
- as
- u64))
- }
- |
- ((m2
- as
- u8
- as
- u64)
- <<
- 2usize)
- &
- (4u64
- as
- u64))
- }
- |
- ((m3
- as
- u8
- as
- u64)
- <<
- 3usize)
- &
- (8u64
- as
- u64))
- }
- |
- ((m4
- as
- u8
- as
- u64)
- <<
- 4usize)
- &
- (16u64
- as
- u64))
- }
- |
- ((m5
- as
- u8
- as
- u64)
- <<
- 5usize)
- &
- (32u64
- as
- u64))
- }
- |
- ((m6
- as
- u8
- as
- u64)
- <<
- 6usize)
- &
- (64u64
- as
- u64))
- }
- |
- ((m7
- as
- u8
- as
- u64)
- <<
- 7usize)
- &
- (128u64
- as
- u64))
- }
- |
- ((m8
- as
- u8
- as
- u64)
- <<
- 8usize)
- &
- (256u64
- as
- u64))
- }
- |
- ((m9
- as
- u8
- as
- u64)
- <<
- 9usize)
- &
- (512u64
- as
- u64))
- }
- |
- ((m10
- as
- u8
- as
- u64)
- <<
- 10usize)
- &
- (1024u64
- as
- u64))
- }
- |
- ((m11
- as
- u8
- as
- u64)
- <<
- 11usize)
- &
- (2048u64
- as
- u64))
- }
- |
- ((m12
- as
- u8
- as
- u64)
- <<
- 12usize)
- &
- (4096u64
- as
- u64))
- }
- |
- ((m13
- as
- u8
- as
- u64)
- <<
- 13usize)
- &
- (8192u64
- as
- u64))
- }
- |
- ((m14
- as
- u8
- as
- u64)
- <<
- 14usize)
- &
- (16384u64
- as
- u64))
- }
- |
- ((m15
- as
- u8
- as
- u64)
- <<
- 15usize)
- &
- (32768u64
- as
- u64))
- }
- |
- ((m16
- as
- u8
- as
- u64)
- <<
- 16usize)
- &
- (65536u64
- as
- u64))
- }
- |
- ((m17
- as
- u8
- as
- u64)
- <<
- 17usize)
- &
- (131072u64
- as
- u64))
- }
- |
- ((m18
- as
- u8
- as
- u64)
- <<
- 18usize)
- &
- (262144u64
- as
- u64))
- } |
- ((m19
- as
- u8
- as
- u64)
- <<
- 19usize)
- &
- (524288u64
- as
- u64))
- } |
- ((m20
- as
- u8
- as
- u64)
- <<
- 20usize)
- &
- (1048576u64
- as
- u64))
- } |
- ((m21 as
- u8
- as
- u64)
- <<
- 21usize)
- &
- (2097152u64
- as
- u64))
- } |
- ((m22 as u8 as
- u64) <<
- 22usize) &
- (4194304u64
- as
- u64))
- } |
- ((m23 as u8 as u64)
- << 23usize) &
- (8388608u64 as
- u64))
- } |
- ((m24 as u8 as u64) <<
- 24usize) &
- (16777216u64 as u64))
- } |
- ((m25 as u8 as u64) <<
- 25usize) &
- (33554432u64 as u64))
- } |
- ((m26 as u8 as u64) << 26usize) &
- (67108864u64 as u64))
- } |
- ((m27 as u8 as u64) << 27usize) &
- (134217728u64 as u64))
- } |
- ((m28 as u8 as u64) << 28usize) &
- (268435456u64 as u64))
- } |
- ((m29 as u8 as u64) << 29usize) &
- (536870912u64 as u64))
- } |
- ((m30 as u8 as u64) << 30usize) &
- (1073741824u64 as u64))
- } | ((m31 as u8 as u64) << 31usize) & (2147483648u64 as u64))
- } | ((m32 as u8 as u64) << 32usize) & (4294967296u64 as u64))
+ pub fn new_bitfield_1(
+ m0: ::std::os::raw::c_char,
+ m1: ::std::os::raw::c_char,
+ m2: ::std::os::raw::c_char,
+ m3: ::std::os::raw::c_char,
+ m4: ::std::os::raw::c_char,
+ m5: ::std::os::raw::c_char,
+ m6: ::std::os::raw::c_char,
+ m7: ::std::os::raw::c_char,
+ m8: ::std::os::raw::c_char,
+ m9: ::std::os::raw::c_char,
+ m10: ::std::os::raw::c_char,
+ m11: ::std::os::raw::c_char,
+ m12: ::std::os::raw::c_char,
+ m13: ::std::os::raw::c_char,
+ m14: ::std::os::raw::c_char,
+ m15: ::std::os::raw::c_char,
+ m16: ::std::os::raw::c_char,
+ m17: ::std::os::raw::c_char,
+ m18: ::std::os::raw::c_char,
+ m19: ::std::os::raw::c_char,
+ m20: ::std::os::raw::c_char,
+ m21: ::std::os::raw::c_char,
+ m22: ::std::os::raw::c_char,
+ m23: ::std::os::raw::c_char,
+ m24: ::std::os::raw::c_char,
+ m25: ::std::os::raw::c_char,
+ m26: ::std::os::raw::c_char,
+ m27: ::std::os::raw::c_char,
+ m28: ::std::os::raw::c_char,
+ m29: ::std::os::raw::c_char,
+ m30: ::std::os::raw::c_char,
+ m31: ::std::os::raw::c_char,
+ m32: ::std::os::raw::c_char,
+ ) -> u64 {
+ (((((((((((((((((((((((((((((((((0 | ((m0 as u8 as u64) << 0usize) & (1u64 as u64)) |
+ ((m1 as u8 as u64) << 1usize) & (2u64 as u64)) |
+ ((m2 as u8 as u64) << 2usize) & (4u64 as u64)) |
+ ((m3 as u8 as u64) << 3usize) & (8u64 as u64)) |
+ ((m4 as u8 as u64) << 4usize) & (16u64 as u64)) |
+ ((m5 as u8 as u64) << 5usize) & (32u64 as u64)) |
+ ((m6 as u8 as u64) << 6usize) & (64u64 as u64)) |
+ ((m7 as u8 as u64) << 7usize) & (128u64 as u64)) |
+ ((m8 as u8 as u64) << 8usize) & (256u64 as u64)) |
+ ((m9 as u8 as u64) << 9usize) & (512u64 as u64)) |
+ ((m10 as u8 as u64) << 10usize) & (1024u64 as u64)) |
+ ((m11 as u8 as u64) << 11usize) & (2048u64 as u64)) |
+ ((m12 as u8 as u64) << 12usize) & (4096u64 as u64)) |
+ ((m13 as u8 as u64) << 13usize) & (8192u64 as u64)) |
+ ((m14 as u8 as u64) << 14usize) & (16384u64 as u64)) |
+ ((m15 as u8 as u64) << 15usize) & (32768u64 as u64)) |
+ ((m16 as u8 as u64) << 16usize) & (65536u64 as u64)) |
+ ((m17 as u8 as u64) << 17usize) & (131072u64 as u64)) |
+ ((m18 as u8 as u64) << 18usize) & (262144u64 as u64)) |
+ ((m19 as u8 as u64) << 19usize) & (524288u64 as u64)) |
+ ((m20 as u8 as u64) << 20usize) & (1048576u64 as u64)) |
+ ((m21 as u8 as u64) << 21usize) & (2097152u64 as u64)) |
+ ((m22 as u8 as u64) << 22usize) & (4194304u64 as u64)) |
+ ((m23 as u8 as u64) << 23usize) & (8388608u64 as u64)) |
+ ((m24 as u8 as u64) << 24usize) & (16777216u64 as u64)) |
+ ((m25 as u8 as u64) << 25usize) & (33554432u64 as u64)) |
+ ((m26 as u8 as u64) << 26usize) & (67108864u64 as u64)) |
+ ((m27 as u8 as u64) << 27usize) & (134217728u64 as u64)) |
+ ((m28 as u8 as u64) << 28usize) & (268435456u64 as u64)) |
+ ((m29 as u8 as u64) << 29usize) & (536870912u64 as u64)) |
+ ((m30 as u8 as u64) << 30usize) & (1073741824u64 as u64)) |
+ ((m31 as u8 as u64) << 31usize) & (2147483648u64 as u64)) |
+ ((m32 as u8 as u64) << 32usize) & (4294967296u64 as u64))
}
}
diff --git a/tests/expectations/tests/bitfield-method-same-name.rs b/tests/expectations/tests/bitfield-method-same-name.rs
index dd6b286f..be55ce38 100644
--- a/tests/expectations/tests/bitfield-method-same-name.rs
+++ b/tests/expectations/tests/bitfield-method-same-name.rs
@@ -12,10 +12,16 @@ pub struct Foo {
}
#[test]
fn bindgen_test_layout_Foo() {
- assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Foo ) ));
- assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Foo))
+ );
}
extern "C" {
#[link_name = "_ZN3Foo4typeEv"]
@@ -30,51 +36,50 @@ extern "C" {
pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char);
}
impl Clone for Foo {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Foo {
#[inline]
pub fn type__bindgen_bitfield(&self) -> ::std::os::raw::c_char {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 7u64 as u8;
let val = (unit_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) {
+ pub fn set_type__bindgen_bitfield(&mut self, val: ::std::os::raw::c_char) {
let mask = 7u64 as u8;
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(type__bindgen_bitfield: ::std::os::raw::c_char)
- -> u8 {
- ({ 0 } |
- ((type__bindgen_bitfield as u8 as u8) << 0usize) & (7u64 as u8))
+ pub fn new_bitfield_1(type__bindgen_bitfield: ::std::os::raw::c_char) -> u8 {
+ (0 | ((type__bindgen_bitfield as u8 as u8) << 0usize) & (7u64 as u8))
}
#[inline]
pub unsafe fn type_(&mut self) -> ::std::os::raw::c_char {
diff --git a/tests/expectations/tests/bitfield_align.rs b/tests/expectations/tests/bitfield_align.rs
index e2db1329..6479bb50 100644
--- a/tests/expectations/tests/bitfield_align.rs
+++ b/tests/expectations/tests/bitfield_align.rs
@@ -14,32 +14,42 @@ pub struct A {
}
#[test]
fn bindgen_test_layout_A() {
- assert_eq!(::std::mem::size_of::<A>() , 4usize , concat ! (
- "Size of: " , stringify ! ( A ) ));
- assert_eq! (::std::mem::align_of::<A>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A>(),
+ 4usize,
+ concat!("Size of: ", stringify!(A))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl A {
#[inline]
pub fn b1(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 1u64 as u16;
let val = (unit_field_val & mask) >> 0usize;
@@ -51,31 +61,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b2(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 2u64 as u16;
let val = (unit_field_val & mask) >> 1usize;
@@ -87,31 +97,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b3(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 4u64 as u16;
let val = (unit_field_val & mask) >> 2usize;
@@ -123,31 +133,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b4(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 8u64 as u16;
let val = (unit_field_val & mask) >> 3usize;
@@ -159,31 +169,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b5(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 16u64 as u16;
let val = (unit_field_val & mask) >> 4usize;
@@ -195,31 +205,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 4usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b6(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 32u64 as u16;
let val = (unit_field_val & mask) >> 5usize;
@@ -231,31 +241,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 5usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b7(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 64u64 as u16;
let val = (unit_field_val & mask) >> 6usize;
@@ -267,31 +277,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 6usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b8(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 128u64 as u16;
let val = (unit_field_val & mask) >> 7usize;
@@ -303,31 +313,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b9(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 256u64 as u16;
let val = (unit_field_val & mask) >> 8usize;
@@ -339,31 +349,31 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn b10(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 512u64 as u16;
let val = (unit_field_val & mask) >> 9usize;
@@ -375,66 +385,45 @@ impl A {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 9usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(b1: ::std::os::raw::c_uint,
- b2: ::std::os::raw::c_uint,
- b3: ::std::os::raw::c_uint,
- b4: ::std::os::raw::c_uint,
- b5: ::std::os::raw::c_uint,
- b6: ::std::os::raw::c_uint,
- b7: ::std::os::raw::c_uint,
- b8: ::std::os::raw::c_uint,
- b9: ::std::os::raw::c_uint,
- b10: ::std::os::raw::c_uint) -> u16 {
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((b1 as u32 as u16)
- << 0usize) &
- (1u64 as u16))
- } |
- ((b2 as u32 as u16) <<
- 1usize) &
- (2u64 as u16))
- } |
- ((b3 as u32 as u16) << 2usize)
- & (4u64 as u16))
- } |
- ((b4 as u32 as u16) << 3usize) &
- (8u64 as u16))
- } |
- ((b5 as u32 as u16) << 4usize) &
- (16u64 as u16))
- } |
- ((b6 as u32 as u16) << 5usize) &
- (32u64 as u16))
- } | ((b7 as u32 as u16) << 6usize) & (64u64 as u16))
- } | ((b8 as u32 as u16) << 7usize) & (128u64 as u16))
- } | ((b9 as u32 as u16) << 8usize) & (256u64 as u16))
- } | ((b10 as u32 as u16) << 9usize) & (512u64 as u16))
+ pub fn new_bitfield_1(
+ b1: ::std::os::raw::c_uint,
+ b2: ::std::os::raw::c_uint,
+ b3: ::std::os::raw::c_uint,
+ b4: ::std::os::raw::c_uint,
+ b5: ::std::os::raw::c_uint,
+ b6: ::std::os::raw::c_uint,
+ b7: ::std::os::raw::c_uint,
+ b8: ::std::os::raw::c_uint,
+ b9: ::std::os::raw::c_uint,
+ b10: ::std::os::raw::c_uint,
+ ) -> u16 {
+ ((((((((((0 | ((b1 as u32 as u16) << 0usize) & (1u64 as u16)) |
+ ((b2 as u32 as u16) << 1usize) & (2u64 as u16)) |
+ ((b3 as u32 as u16) << 2usize) & (4u64 as u16)) |
+ ((b4 as u32 as u16) << 3usize) & (8u64 as u16)) |
+ ((b5 as u32 as u16) << 4usize) & (16u64 as u16)) |
+ ((b6 as u32 as u16) << 5usize) & (32u64 as u16)) |
+ ((b7 as u32 as u16) << 6usize) & (64u64 as u16)) |
+ ((b8 as u32 as u16) << 7usize) & (128u64 as u16)) |
+ ((b9 as u32 as u16) << 8usize) & (256u64 as u16)) |
+ ((b10 as u32 as u16) << 9usize) & (512u64 as u16))
}
}
#[repr(C)]
@@ -445,24 +434,32 @@ pub struct B {
}
#[test]
fn bindgen_test_layout_B() {
- assert_eq!(::std::mem::size_of::<B>() , 4usize , concat ! (
- "Size of: " , stringify ! ( B ) ));
- assert_eq! (::std::mem::align_of::<B>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( B ) ));
+ assert_eq!(
+ ::std::mem::size_of::<B>(),
+ 4usize,
+ concat!("Size of: ", stringify!(B))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<B>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(B))
+ );
}
impl Clone for B {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl B {
#[inline]
pub fn foo(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 2147483647u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -474,31 +471,31 @@ impl B {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn bar(&self) -> ::std::os::raw::c_uchar {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 2147483648u64 as u32;
let val = (unit_field_val & mask) >> 31usize;
@@ -510,29 +507,26 @@ impl B {
let val = val as u8 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 31usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(foo: ::std::os::raw::c_uint,
- bar: ::std::os::raw::c_uchar) -> u32 {
- ({
- ({ 0 } |
- ((foo as u32 as u32) << 0usize) & (2147483647u64 as u32))
- } | ((bar as u8 as u32) << 31usize) & (2147483648u64 as u32))
+ pub fn new_bitfield_1(foo: ::std::os::raw::c_uint, bar: ::std::os::raw::c_uchar) -> u32 {
+ ((0 | ((foo as u32 as u32) << 0usize) & (2147483647u64 as u32)) |
+ ((bar as u8 as u32) << 31usize) & (2147483648u64 as u32))
}
}
#[repr(C)]
@@ -544,33 +538,42 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
- assert_eq!(::std::mem::size_of::<C>() , 8usize , concat ! (
- "Size of: " , stringify ! ( C ) ));
- assert_eq! (::std::mem::align_of::<C>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C>(),
+ 8usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl C {
#[inline]
pub fn b1(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -582,31 +585,31 @@ impl C {
let val = val as u32 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn b2(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 2u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -618,27 +621,26 @@ impl C {
let val = val as u32 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(b1: ::std::os::raw::c_uint,
- b2: ::std::os::raw::c_uint) -> u8 {
- ({ ({ 0 } | ((b1 as u32 as u8) << 0usize) & (1u64 as u8)) } |
- ((b2 as u32 as u8) << 1usize) & (2u64 as u8))
+ pub fn new_bitfield_1(b1: ::std::os::raw::c_uint, b2: ::std::os::raw::c_uint) -> u8 {
+ ((0 | ((b1 as u32 as u8) << 0usize) & (1u64 as u8)) |
+ ((b2 as u32 as u8) << 1usize) & (2u64 as u8))
}
}
#[repr(C)]
@@ -650,24 +652,32 @@ pub struct Date1 {
}
#[test]
fn bindgen_test_layout_Date1() {
- assert_eq!(::std::mem::size_of::<Date1>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Date1 ) ));
- assert_eq! (::std::mem::align_of::<Date1>() , 2usize , concat ! (
- "Alignment of " , stringify ! ( Date1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Date1>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Date1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Date1>(),
+ 2usize,
+ concat!("Alignment of ", stringify!(Date1))
+ );
}
impl Clone for Date1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Date1 {
#[inline]
pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 7u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -679,31 +689,31 @@ impl Date1 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 504u64 as u32;
let val = (unit_field_val & mask) >> 3usize;
@@ -715,31 +725,31 @@ impl Date1 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nMonth(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15872u64 as u32;
let val = (unit_field_val & mask) >> 9usize;
@@ -751,31 +761,31 @@ impl Date1 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 9usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nYear(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 16711680u64 as u32;
let val = (unit_field_val & mask) >> 16usize;
@@ -787,38 +797,33 @@ impl Date1 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(nWeekDay: ::std::os::raw::c_ushort,
- nMonthDay: ::std::os::raw::c_ushort,
- nMonth: ::std::os::raw::c_ushort,
- nYear: ::std::os::raw::c_ushort) -> u32 {
- ({
- ({
- ({
- ({ 0 } |
- ((nWeekDay as u16 as u32) << 0usize) &
- (7u64 as u32))
- } |
- ((nMonthDay as u16 as u32) << 3usize) &
- (504u64 as u32))
- } | ((nMonth as u16 as u32) << 9usize) & (15872u64 as u32))
- } | ((nYear as u16 as u32) << 16usize) & (16711680u64 as u32))
+ pub fn new_bitfield_1(
+ nWeekDay: ::std::os::raw::c_ushort,
+ nMonthDay: ::std::os::raw::c_ushort,
+ nMonth: ::std::os::raw::c_ushort,
+ nYear: ::std::os::raw::c_ushort,
+ ) -> u32 {
+ ((((0 | ((nWeekDay as u16 as u32) << 0usize) & (7u64 as u32)) |
+ ((nMonthDay as u16 as u32) << 3usize) & (504u64 as u32)) |
+ ((nMonth as u16 as u32) << 9usize) & (15872u64 as u32)) |
+ ((nYear as u16 as u32) << 16usize) & (16711680u64 as u32))
}
}
#[repr(C)]
@@ -829,24 +834,32 @@ pub struct Date2 {
}
#[test]
fn bindgen_test_layout_Date2() {
- assert_eq!(::std::mem::size_of::<Date2>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Date2 ) ));
- assert_eq! (::std::mem::align_of::<Date2>() , 2usize , concat ! (
- "Alignment of " , stringify ! ( Date2 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Date2>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Date2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Date2>(),
+ 2usize,
+ concat!("Alignment of ", stringify!(Date2))
+ );
}
impl Clone for Date2 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Date2 {
#[inline]
pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 7u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -858,31 +871,31 @@ impl Date2 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 504u64 as u32;
let val = (unit_field_val & mask) >> 3usize;
@@ -894,31 +907,31 @@ impl Date2 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nMonth(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15872u64 as u32;
let val = (unit_field_val & mask) >> 9usize;
@@ -930,31 +943,31 @@ impl Date2 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 9usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nYear(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 16711680u64 as u32;
let val = (unit_field_val & mask) >> 16usize;
@@ -966,31 +979,31 @@ impl Date2 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn byte(&self) -> ::std::os::raw::c_uchar {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 4278190080u64 as u32;
let val = (unit_field_val & mask) >> 24usize;
@@ -1002,41 +1015,35 @@ impl Date2 {
let val = val as u8 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(nWeekDay: ::std::os::raw::c_ushort,
- nMonthDay: ::std::os::raw::c_ushort,
- nMonth: ::std::os::raw::c_ushort,
- nYear: ::std::os::raw::c_ushort,
- byte: ::std::os::raw::c_uchar) -> u32 {
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((nWeekDay as u16 as u32) << 0usize) &
- (7u64 as u32))
- } |
- ((nMonthDay as u16 as u32) << 3usize) &
- (504u64 as u32))
- } | ((nMonth as u16 as u32) << 9usize) & (15872u64 as u32))
- } | ((nYear as u16 as u32) << 16usize) & (16711680u64 as u32))
- } | ((byte as u8 as u32) << 24usize) & (4278190080u64 as u32))
+ pub fn new_bitfield_1(
+ nWeekDay: ::std::os::raw::c_ushort,
+ nMonthDay: ::std::os::raw::c_ushort,
+ nMonth: ::std::os::raw::c_ushort,
+ nYear: ::std::os::raw::c_ushort,
+ byte: ::std::os::raw::c_uchar,
+ ) -> u32 {
+ (((((0 | ((nWeekDay as u16 as u32) << 0usize) & (7u64 as u32)) |
+ ((nMonthDay as u16 as u32) << 3usize) & (504u64 as u32)) |
+ ((nMonth as u16 as u32) << 9usize) & (15872u64 as u32)) |
+ ((nYear as u16 as u32) << 16usize) & (16711680u64 as u32)) |
+ ((byte as u8 as u32) << 24usize) & (4278190080u64 as u32))
}
}
#[repr(C)]
@@ -1048,29 +1055,42 @@ pub struct Date3 {
}
#[test]
fn bindgen_test_layout_Date3() {
- assert_eq!(::std::mem::size_of::<Date3>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Date3 ) ));
- assert_eq! (::std::mem::align_of::<Date3>() , 2usize , concat ! (
- "Alignment of " , stringify ! ( Date3 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Date3 ) ) . byte as * const _ as usize }
- , 3usize , concat ! (
- "Alignment of field: " , stringify ! ( Date3 ) , "::" ,
- stringify ! ( byte ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Date3>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Date3))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Date3>(),
+ 2usize,
+ concat!("Alignment of ", stringify!(Date3))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Date3)).byte as *const _ as usize },
+ 3usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Date3),
+ "::",
+ stringify!(byte)
+ )
+ );
}
impl Clone for Date3 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Date3 {
#[inline]
pub fn nWeekDay(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 7u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -1082,31 +1102,31 @@ impl Date3 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nMonthDay(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 504u64 as u32;
let val = (unit_field_val & mask) >> 3usize;
@@ -1118,31 +1138,31 @@ impl Date3 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nMonth(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15872u64 as u32;
let val = (unit_field_val & mask) >> 9usize;
@@ -1154,31 +1174,31 @@ impl Date3 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 9usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn nYear(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 16711680u64 as u32;
let val = (unit_field_val & mask) >> 16usize;
@@ -1190,37 +1210,32 @@ impl Date3 {
let val = val as u16 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(nWeekDay: ::std::os::raw::c_ushort,
- nMonthDay: ::std::os::raw::c_ushort,
- nMonth: ::std::os::raw::c_ushort,
- nYear: ::std::os::raw::c_ushort) -> u32 {
- ({
- ({
- ({
- ({ 0 } |
- ((nWeekDay as u16 as u32) << 0usize) &
- (7u64 as u32))
- } |
- ((nMonthDay as u16 as u32) << 3usize) &
- (504u64 as u32))
- } | ((nMonth as u16 as u32) << 9usize) & (15872u64 as u32))
- } | ((nYear as u16 as u32) << 16usize) & (16711680u64 as u32))
+ pub fn new_bitfield_1(
+ nWeekDay: ::std::os::raw::c_ushort,
+ nMonthDay: ::std::os::raw::c_ushort,
+ nMonth: ::std::os::raw::c_ushort,
+ nYear: ::std::os::raw::c_ushort,
+ ) -> u32 {
+ ((((0 | ((nWeekDay as u16 as u32) << 0usize) & (7u64 as u32)) |
+ ((nMonthDay as u16 as u32) << 3usize) & (504u64 as u32)) |
+ ((nMonth as u16 as u32) << 9usize) & (15872u64 as u32)) |
+ ((nYear as u16 as u32) << 16usize) & (16711680u64 as u32))
}
}
diff --git a/tests/expectations/tests/bitfield_align_2.rs b/tests/expectations/tests/bitfield_align_2.rs
index f92f09db..d3ce64f8 100644
--- a/tests/expectations/tests/bitfield_align_2.rs
+++ b/tests/expectations/tests/bitfield_align_2.rs
@@ -6,7 +6,12 @@
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
-pub enum MyEnum { ONE = 0, TWO = 1, THREE = 2, FOUR = 3, }
+pub enum MyEnum {
+ ONE = 0,
+ TWO = 1,
+ THREE = 2,
+ FOUR = 3,
+}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct TaggedPtr {
@@ -15,27 +20,37 @@ pub struct TaggedPtr {
}
#[test]
fn bindgen_test_layout_TaggedPtr() {
- assert_eq!(::std::mem::size_of::<TaggedPtr>() , 8usize , concat ! (
- "Size of: " , stringify ! ( TaggedPtr ) ));
- assert_eq! (::std::mem::align_of::<TaggedPtr>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( TaggedPtr ) ));
+ assert_eq!(
+ ::std::mem::size_of::<TaggedPtr>(),
+ 8usize,
+ concat!("Size of: ", stringify!(TaggedPtr))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<TaggedPtr>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(TaggedPtr))
+ );
}
impl Clone for TaggedPtr {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for TaggedPtr {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl TaggedPtr {
#[inline]
pub fn tag(&self) -> MyEnum {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 3u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -47,31 +62,31 @@ impl TaggedPtr {
let val = val as u32 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn ptr(&self) -> ::std::os::raw::c_long {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 18446744073709551612u64 as u64;
let val = (unit_field_val & mask) >> 2usize;
@@ -83,26 +98,25 @@ impl TaggedPtr {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn new_bitfield_1(tag: MyEnum, ptr: ::std::os::raw::c_long) -> u64 {
- ({ ({ 0 } | ((tag as u32 as u64) << 0usize) & (3u64 as u64)) } |
- ((ptr as u64 as u64) << 2usize) &
- (18446744073709551612u64 as u64))
+ ((0 | ((tag as u32 as u64) << 0usize) & (3u64 as u64)) |
+ ((ptr as u64 as u64) << 2usize) & (18446744073709551612u64 as u64))
}
}
diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs
index 855ae72b..736d6360 100644
--- a/tests/expectations/tests/bitfield_method_mangling.rs
+++ b/tests/expectations/tests/bitfield_method_mangling.rs
@@ -12,27 +12,32 @@ pub struct mach_msg_type_descriptor_t {
}
#[test]
fn bindgen_test_layout_mach_msg_type_descriptor_t() {
- assert_eq!(::std::mem::size_of::<mach_msg_type_descriptor_t>() , 4usize ,
- concat ! (
- "Size of: " , stringify ! ( mach_msg_type_descriptor_t ) ));
- assert_eq! (::std::mem::align_of::<mach_msg_type_descriptor_t>() , 4usize
- , concat ! (
- "Alignment of " , stringify ! ( mach_msg_type_descriptor_t )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<mach_msg_type_descriptor_t>(),
+ 4usize,
+ concat!("Size of: ", stringify!(mach_msg_type_descriptor_t))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<mach_msg_type_descriptor_t>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(mach_msg_type_descriptor_t))
+ );
}
impl Clone for mach_msg_type_descriptor_t {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl mach_msg_type_descriptor_t {
#[inline]
pub fn pad3(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 16777215u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -44,31 +49,31 @@ impl mach_msg_type_descriptor_t {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn type_(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 4278190080u64 as u32;
let val = (unit_field_val & mask) >> 24usize;
@@ -80,26 +85,25 @@ impl mach_msg_type_descriptor_t {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(pad3: ::std::os::raw::c_uint,
- type_: ::std::os::raw::c_uint) -> u32 {
- ({ ({ 0 } | ((pad3 as u32 as u32) << 0usize) & (16777215u64 as u32)) }
- | ((type_ as u32 as u32) << 24usize) & (4278190080u64 as u32))
+ pub fn new_bitfield_1(pad3: ::std::os::raw::c_uint, type_: ::std::os::raw::c_uint) -> u32 {
+ ((0 | ((pad3 as u32 as u32) << 0usize) & (16777215u64 as u32)) |
+ ((type_ as u32 as u32) << 24usize) & (4278190080u64 as u32))
}
}
diff --git a/tests/expectations/tests/blacklist-and-impl-debug.rs b/tests/expectations/tests/blacklist-and-impl-debug.rs
index d84b0256..3cba2b29 100644
--- a/tests/expectations/tests/blacklist-and-impl-debug.rs
+++ b/tests/expectations/tests/blacklist-and-impl-debug.rs
@@ -5,6 +5,7 @@
pub struct BlacklistMe(u8);
+
/// Because this type contains a blacklisted type, it should not derive Debug.
#[repr(C)]
pub struct ShouldManuallyImplDebug {
@@ -12,23 +13,34 @@ pub struct ShouldManuallyImplDebug {
}
#[test]
fn bindgen_test_layout_ShouldManuallyImplDebug() {
- assert_eq!(::std::mem::size_of::<ShouldManuallyImplDebug>() , 1usize ,
- concat ! (
- "Size of: " , stringify ! ( ShouldManuallyImplDebug ) ));
- assert_eq! (::std::mem::align_of::<ShouldManuallyImplDebug>() , 1usize ,
- concat ! (
- "Alignment of " , stringify ! ( ShouldManuallyImplDebug ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldManuallyImplDebug ) ) . a as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ShouldManuallyImplDebug
- ) , "::" , stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ShouldManuallyImplDebug>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ShouldManuallyImplDebug))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldManuallyImplDebug>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ShouldManuallyImplDebug))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldManuallyImplDebug)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldManuallyImplDebug),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Default for ShouldManuallyImplDebug {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl ::std::fmt::Debug for ShouldManuallyImplDebug {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- write!(f , "ShouldManuallyImplDebug {{ }}")
+ write!(f, "ShouldManuallyImplDebug {{ }}")
}
}
diff --git a/tests/expectations/tests/class_nested.rs b/tests/expectations/tests/class_nested.rs
index a874d6b8..b0062c9b 100644
--- a/tests/expectations/tests/class_nested.rs
+++ b/tests/expectations/tests/class_nested.rs
@@ -16,18 +16,31 @@ pub struct A_B {
}
#[test]
fn bindgen_test_layout_A_B() {
- assert_eq!(::std::mem::size_of::<A_B>() , 4usize , concat ! (
- "Size of: " , stringify ! ( A_B ) ));
- assert_eq! (::std::mem::align_of::<A_B>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A_B>(),
+ 4usize,
+ concat!("Size of: ", stringify!(A_B))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A_B>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -35,23 +48,38 @@ pub struct A_D<T> {
pub foo: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for A_D<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for A_D<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_A() {
- assert_eq!(::std::mem::size_of::<A>() , 4usize , concat ! (
- "Size of: " , stringify ! ( A ) ));
- assert_eq! (::std::mem::align_of::<A>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A>(),
+ 4usize,
+ concat!("Size of: ", stringify!(A))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -60,18 +88,31 @@ pub struct A_C {
}
#[test]
fn bindgen_test_layout_A_C() {
- assert_eq!(::std::mem::size_of::<A_C>() , 4usize , concat ! (
- "Size of: " , stringify ! ( A_C ) ));
- assert_eq! (::std::mem::align_of::<A_C>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A_C>(),
+ 4usize,
+ concat!("Size of: ", stringify!(A_C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A_C>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
extern "C" {
#[link_name = "var"]
@@ -79,14 +120,15 @@ extern "C" {
}
#[test]
fn __bindgen_test_layout_A_D_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<A_D<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- A_D<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<A_D<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- A_D<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A_D<::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( A_D < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < A_D < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( A_D < :: std :: os :: raw :: c_int > ) ) );
}
extern "C" {
#[link_name = "baz"]
@@ -99,18 +141,14 @@ pub struct D {
}
#[test]
fn bindgen_test_layout_D() {
- assert_eq!(::std::mem::size_of::<D>() , 4usize , concat ! (
- "Size of: " , stringify ! ( D ) ));
- assert_eq! (::std::mem::align_of::<D>() , 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 ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < D > ( ) , 4usize , concat ! ( "Size of: " , stringify ! ( D ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < D > ( ) , 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -124,9 +162,13 @@ pub struct Templated_Templated_inner<T> {
pub member_ptr: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for Templated_Templated_inner<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for Templated_Templated_inner<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
-impl <T> Default for Templated<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for Templated<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs
index 4d2ae275..af73ae3b 100644
--- a/tests/expectations/tests/class_use_as.rs
+++ b/tests/expectations/tests/class_use_as.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen="true" replaces="whatever"></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -12,18 +13,31 @@ pub struct whatever {
}
#[test]
fn bindgen_test_layout_whatever() {
- assert_eq!(::std::mem::size_of::<whatever>() , 4usize , concat ! (
- "Size of: " , stringify ! ( whatever ) ));
- assert_eq! (::std::mem::align_of::<whatever>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<whatever>(),
+ 4usize,
+ concat!("Size of: ", stringify!(whatever))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<whatever>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -32,16 +46,29 @@ pub struct container {
}
#[test]
fn bindgen_test_layout_container() {
- assert_eq!(::std::mem::size_of::<container>() , 4usize , concat ! (
- "Size of: " , stringify ! ( container ) ));
- assert_eq! (::std::mem::align_of::<container>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<container>(),
+ 4usize,
+ concat!("Size of: ", stringify!(container))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<container>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/class_with_dtor.rs b/tests/expectations/tests/class_with_dtor.rs
index 8171288a..08e3aa88 100644
--- a/tests/expectations/tests/class_with_dtor.rs
+++ b/tests/expectations/tests/class_with_dtor.rs
@@ -10,8 +10,10 @@ pub struct HandleWithDtor<T> {
pub ptr: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for HandleWithDtor<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for HandleWithDtor<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
pub type HandleValue = HandleWithDtor<::std::os::raw::c_int>;
#[repr(C)]
@@ -21,27 +23,41 @@ pub struct WithoutDtor {
}
#[test]
fn bindgen_test_layout_WithoutDtor() {
- assert_eq!(::std::mem::size_of::<WithoutDtor>() , 8usize , concat ! (
- "Size of: " , stringify ! ( WithoutDtor ) ));
- assert_eq! (::std::mem::align_of::<WithoutDtor>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<WithoutDtor>(),
+ 8usize,
+ concat!("Size of: ", stringify!(WithoutDtor))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<WithoutDtor>(),
+ 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() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>()
- , 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- HandleWithDtor<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>()
- , 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- HandleWithDtor<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>(),
+ 8usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < HandleWithDtor < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > ) ) );
}
diff --git a/tests/expectations/tests/constify-all-enums.rs b/tests/expectations/tests/constify-all-enums.rs
index 700ddeb4..af13e079 100644
--- a/tests/expectations/tests/constify-all-enums.rs
+++ b/tests/expectations/tests/constify-all-enums.rs
@@ -15,19 +15,34 @@ pub struct bar {
}
#[test]
fn bindgen_test_layout_bar() {
- assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! (
- "Size of: " , stringify ! ( bar ) ));
- assert_eq! (::std::mem::align_of::<bar>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<bar>(),
+ 4usize,
+ concat!("Size of: ", stringify!(bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<bar>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for bar {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/constify-module-enums-basic.rs b/tests/expectations/tests/constify-module-enums-basic.rs
index 803c804b..bfe33c6b 100644
--- a/tests/expectations/tests/constify-module-enums-basic.rs
+++ b/tests/expectations/tests/constify-module-enums-basic.rs
@@ -19,27 +19,48 @@ pub struct bar {
}
#[test]
fn bindgen_test_layout_bar() {
- assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! (
- "Size of: " , stringify ! ( bar ) ));
- assert_eq! (::std::mem::align_of::<bar>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<bar>(),
+ 4usize,
+ concat!("Size of: ", stringify!(bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<bar>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for bar {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
extern "C" {
- pub fn func1(arg1: foo::Type, arg2: *mut foo::Type,
- arg3: *mut *mut foo::Type) -> *mut foo::Type;
+ pub fn func1(
+ arg1: foo::Type,
+ arg2: *mut foo::Type,
+ arg3: *mut *mut foo::Type,
+ ) -> *mut foo::Type;
}
extern "C" {
- pub fn func2(arg1: foo_alias1, arg2: *mut foo_alias1,
- arg3: *mut *mut foo_alias1) -> *mut foo_alias1;
+ pub fn func2(
+ arg1: foo_alias1,
+ arg2: *mut foo_alias1,
+ arg3: *mut *mut foo_alias1,
+ ) -> *mut foo_alias1;
}
diff --git a/tests/expectations/tests/constify-module-enums-simple-alias.rs b/tests/expectations/tests/constify-module-enums-simple-alias.rs
index 709a6947..75c952d7 100644
--- a/tests/expectations/tests/constify-module-enums-simple-alias.rs
+++ b/tests/expectations/tests/constify-module-enums-simple-alias.rs
@@ -27,54 +27,104 @@ pub struct Bar {
}
#[test]
fn bindgen_test_layout_Bar() {
- assert_eq!(::std::mem::size_of::<Bar>() , 48usize , concat ! (
- "Size of: " , stringify ! ( Bar ) ));
- assert_eq! (::std::mem::align_of::<Bar>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( Bar ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz1 as * const _ as usize } ,
- 0usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz1 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz2 as * const _ as usize } ,
- 4usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz2 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz3 as * const _ as usize } ,
- 8usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz3 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz4 as * const _ as usize } ,
- 12usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz4 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz_ptr1 as * const _ as usize
- } , 16usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz_ptr1 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz_ptr2 as * const _ as usize
- } , 24usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz_ptr2 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz_ptr3 as * const _ as usize
- } , 32usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz_ptr3 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . baz_ptr4 as * const _ as usize
- } , 40usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( baz_ptr4 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Bar>(),
+ 48usize,
+ concat!("Size of: ", stringify!(Bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Bar>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(Bar))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz1 as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz1)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz2 as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz2)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz3 as *const _ as usize },
+ 8usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz3)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz4 as *const _ as usize },
+ 12usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz4)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz_ptr1 as *const _ as usize },
+ 16usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz_ptr1)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz_ptr2 as *const _ as usize },
+ 24usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz_ptr2)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz_ptr3 as *const _ as usize },
+ 32usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz_ptr3)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).baz_ptr4 as *const _ as usize },
+ 40usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(Bar),
+ "::",
+ stringify!(baz_ptr4)
+ )
+ );
}
impl Clone for Bar {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for Bar {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/default-template-parameter.rs b/tests/expectations/tests/default-template-parameter.rs
index 0336f0d8..8dae0c90 100644
--- a/tests/expectations/tests/default-template-parameter.rs
+++ b/tests/expectations/tests/default-template-parameter.rs
@@ -12,19 +12,29 @@ pub struct Foo<T, U> {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
}
-impl <T, U> Default for Foo<T, U> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T, U> Default for Foo<T, U> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_Foo_open0_bool__int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<Foo<bool, ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- Foo<bool, ::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<Foo<bool, ::std::os::raw::c_int>>() ,
- 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- Foo<bool, ::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo<bool, ::std::os::raw::c_int>>(),
+ 8usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( Foo < bool , :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo<bool, ::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Alignment of template specialization: ",
+ stringify ! ( Foo < bool , :: std :: os :: raw :: c_int > )
+ )
+ );
}
extern "C" {
#[link_name = "_ZL3bar"]
diff --git a/tests/expectations/tests/derive-debug-bitfield.rs b/tests/expectations/tests/derive-debug-bitfield.rs
index 62e941e4..47ec570b 100644
--- a/tests/expectations/tests/derive-debug-bitfield.rs
+++ b/tests/expectations/tests/derive-debug-bitfield.rs
@@ -12,30 +12,50 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
- assert_eq!(::std::mem::size_of::<C>() , 204usize , concat ! (
- "Size of: " , stringify ! ( C ) ));
- assert_eq! (::std::mem::align_of::<C>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( C ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . large_array as * const _ as usize
- } , 4usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( large_array ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C>(),
+ 204usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).large_array as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(large_array)
+ )
+ );
}
impl Clone for C {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for C {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl ::std::fmt::Debug for C {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- write!(f , "C {{ a : {:?}, b : {:?}, large_array: [{}] }}" , self . a
- ( ) , self . b ( ) , self . large_array . iter ( ) .
- enumerate ( ) . map (
- | ( i , v ) | format ! (
- "{}{:?}" , if i > 0 { ", " } else { "" } , v ) ) . collect :: <
- String > ( ))
+ write!(
+ f,
+ "C {{ a : {:?}, b : {:?}, large_array: [{}] }}",
+ self.a(),
+ self.b(),
+ self.large_array
+ .iter()
+ .enumerate()
+ .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
+ .collect::<String>()
+ )
}
}
impl C {
@@ -43,11 +63,11 @@ impl C {
pub fn a(&self) -> bool {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -59,31 +79,31 @@ impl C {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn b(&self) -> bool {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 254u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -95,25 +115,25 @@ impl C {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn new_bitfield_1(a: bool, b: bool) -> u8 {
- ({ ({ 0 } | ((a as u8 as u8) << 0usize) & (1u64 as u8)) } |
- ((b as u8 as u8) << 1usize) & (254u64 as u8))
+ ((0 | ((a as u8 as u8) << 0usize) & (1u64 as u8)) |
+ ((b as u8 as u8) << 1usize) & (254u64 as u8))
}
}
diff --git a/tests/expectations/tests/derive-debug-generic.rs b/tests/expectations/tests/derive-debug-generic.rs
index f238234a..6c0b41a6 100644
--- a/tests/expectations/tests/derive-debug-generic.rs
+++ b/tests/expectations/tests/derive-debug-generic.rs
@@ -9,11 +9,13 @@ pub struct Generic<T> {
pub t: [T; 40usize],
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for Generic<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for Generic<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
-impl <T> ::std::fmt::Debug for Generic<T> {
+impl<T> ::std::fmt::Debug for Generic<T> {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
- write!(f , "Generic {{ t: Array with length 40 }}")
+ write!(f, "Generic {{ t: Array with length 40 }}")
}
}
diff --git a/tests/expectations/tests/derive-default-and-blacklist.rs b/tests/expectations/tests/derive-default-and-blacklist.rs
index e811bd05..d6a8bc75 100644
--- a/tests/expectations/tests/derive-default-and-blacklist.rs
+++ b/tests/expectations/tests/derive-default-and-blacklist.rs
@@ -5,6 +5,7 @@
pub struct BlacklistMe(u8);
+
/// Because this type contains a blacklisted type, it should not derive
/// Default. Instead, we should emit a `mem::zeroed` implementation.
#[repr(C)]
@@ -13,18 +14,29 @@ pub struct ShouldNotDeriveDefault {
}
#[test]
fn bindgen_test_layout_ShouldNotDeriveDefault() {
- assert_eq!(::std::mem::size_of::<ShouldNotDeriveDefault>() , 1usize ,
- concat ! ( "Size of: " , stringify ! ( ShouldNotDeriveDefault )
- ));
- assert_eq! (::std::mem::align_of::<ShouldNotDeriveDefault>() , 1usize ,
- concat ! (
- "Alignment of " , stringify ! ( ShouldNotDeriveDefault ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldNotDeriveDefault ) ) . a as * const
- _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ShouldNotDeriveDefault
- ) , "::" , stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ShouldNotDeriveDefault>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ShouldNotDeriveDefault))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldNotDeriveDefault>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ShouldNotDeriveDefault))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldNotDeriveDefault)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldNotDeriveDefault),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Default for ShouldNotDeriveDefault {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/derive-hash-and-blacklist.rs b/tests/expectations/tests/derive-hash-and-blacklist.rs
index e5a66376..bdbdc9ae 100644
--- a/tests/expectations/tests/derive-hash-and-blacklist.rs
+++ b/tests/expectations/tests/derive-hash-and-blacklist.rs
@@ -5,6 +5,7 @@
pub struct BlacklistMe(u8);
+
/// Because this type contains a blacklisted type, it should not derive Hash.
#[repr(C)]
pub struct ShouldNotDeriveHash {
@@ -12,17 +13,29 @@ pub struct ShouldNotDeriveHash {
}
#[test]
fn bindgen_test_layout_ShouldNotDeriveHash() {
- assert_eq!(::std::mem::size_of::<ShouldNotDeriveHash>() , 1usize , concat
- ! ( "Size of: " , stringify ! ( ShouldNotDeriveHash ) ));
- assert_eq! (::std::mem::align_of::<ShouldNotDeriveHash>() , 1usize ,
- concat ! (
- "Alignment of " , stringify ! ( ShouldNotDeriveHash ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldNotDeriveHash ) ) . a as * const _
- as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ShouldNotDeriveHash ) ,
- "::" , stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ShouldNotDeriveHash>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ShouldNotDeriveHash))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldNotDeriveHash>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ShouldNotDeriveHash))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldNotDeriveHash)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldNotDeriveHash),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Default for ShouldNotDeriveHash {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/derive-hash-blacklisting.rs b/tests/expectations/tests/derive-hash-blacklisting.rs
index 5d1a8d37..c9cbf6ef 100644
--- a/tests/expectations/tests/derive-hash-blacklisting.rs
+++ b/tests/expectations/tests/derive-hash-blacklisting.rs
@@ -3,7 +3,13 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] pub struct Blacklisted<T> {t: T, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>> }
+#[repr(C)]
+#[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)]
+pub struct Blacklisted<T> {
+ t: T,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+
/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type,
/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it.
@@ -13,18 +19,31 @@ pub struct WhitelistedOne {
}
#[test]
fn bindgen_test_layout_WhitelistedOne() {
- assert_eq!(::std::mem::size_of::<WhitelistedOne>() , 4usize , concat ! (
- "Size of: " , stringify ! ( WhitelistedOne ) ));
- assert_eq! (::std::mem::align_of::<WhitelistedOne>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( WhitelistedOne ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const WhitelistedOne ) ) . a as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( WhitelistedOne ) , "::"
- , stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<WhitelistedOne>(),
+ 4usize,
+ concat!("Size of: ", stringify!(WhitelistedOne))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<WhitelistedOne>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(WhitelistedOne))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const WhitelistedOne)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(WhitelistedOne),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Default for WhitelistedOne {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type.
#[repr(C)]
@@ -33,16 +52,29 @@ pub struct WhitelistedTwo {
}
#[test]
fn bindgen_test_layout_WhitelistedTwo() {
- assert_eq!(::std::mem::size_of::<WhitelistedTwo>() , 4usize , concat ! (
- "Size of: " , stringify ! ( WhitelistedTwo ) ));
- assert_eq! (::std::mem::align_of::<WhitelistedTwo>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( WhitelistedTwo ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const WhitelistedTwo ) ) . b as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( WhitelistedTwo ) , "::"
- , stringify ! ( b ) ));
+ assert_eq!(
+ ::std::mem::size_of::<WhitelistedTwo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(WhitelistedTwo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<WhitelistedTwo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(WhitelistedTwo))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const WhitelistedTwo)).b as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(WhitelistedTwo),
+ "::",
+ stringify!(b)
+ )
+ );
}
impl Default for WhitelistedTwo {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs
index 3457afef..332c1129 100644
--- a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs
+++ b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// A struct containing a struct containing a float that cannot derive hash/eq but can derive partial eq.
#[repr(C)]
#[derive(Debug, Default, Copy, PartialEq)]
@@ -18,36 +19,67 @@ pub struct foo__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_foo__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 8usize , concat !
- ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<foo__bindgen_ty_1>(),
+ 8usize,
+ concat!("Size of: ", stringify!(foo__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_foo() {
- assert_eq!(::std::mem::size_of::<foo>() , 8usize , concat ! (
- "Size of: " , stringify ! ( foo ) ));
- assert_eq! (::std::mem::align_of::<foo>() , 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!(
+ ::std::mem::size_of::<foo>(),
+ 8usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/derive-hash-struct-with-float-array.rs b/tests/expectations/tests/derive-hash-struct-with-float-array.rs
index 9ee6785c..43075796 100644
--- a/tests/expectations/tests/derive-hash-struct-with-float-array.rs
+++ b/tests/expectations/tests/derive-hash-struct-with-float-array.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// A struct containing an array of floats that cannot derive hash/eq but can derive partialeq.
#[repr(C)]
#[derive(Debug, Default, Copy, PartialEq)]
@@ -12,16 +13,29 @@ pub struct foo {
}
#[test]
fn bindgen_test_layout_foo() {
- assert_eq!(::std::mem::size_of::<foo>() , 12usize , concat ! (
- "Size of: " , stringify ! ( foo ) ));
- assert_eq! (::std::mem::align_of::<foo>() , 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!(
+ ::std::mem::size_of::<foo>(),
+ 12usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/derive-hash-struct-with-pointer.rs b/tests/expectations/tests/derive-hash-struct-with-pointer.rs
index c29f9b1e..28aa1e25 100644
--- a/tests/expectations/tests/derive-hash-struct-with-pointer.rs
+++ b/tests/expectations/tests/derive-hash-struct-with-pointer.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// Pointers can derive hash/PartialEq/Eq
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -12,21 +13,36 @@ pub struct ConstPtrMutObj {
}
#[test]
fn bindgen_test_layout_ConstPtrMutObj() {
- assert_eq!(::std::mem::size_of::<ConstPtrMutObj>() , 8usize , concat ! (
- "Size of: " , stringify ! ( ConstPtrMutObj ) ));
- assert_eq! (::std::mem::align_of::<ConstPtrMutObj>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( ConstPtrMutObj ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ConstPtrMutObj ) ) . bar as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ConstPtrMutObj ) , "::"
- , stringify ! ( bar ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ConstPtrMutObj>(),
+ 8usize,
+ concat!("Size of: ", stringify!(ConstPtrMutObj))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ConstPtrMutObj>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(ConstPtrMutObj))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ConstPtrMutObj)).bar as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ConstPtrMutObj),
+ "::",
+ stringify!(bar)
+ )
+ );
}
impl Clone for ConstPtrMutObj {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ConstPtrMutObj {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -35,21 +51,36 @@ pub struct MutPtrMutObj {
}
#[test]
fn bindgen_test_layout_MutPtrMutObj() {
- assert_eq!(::std::mem::size_of::<MutPtrMutObj>() , 8usize , concat ! (
- "Size of: " , stringify ! ( MutPtrMutObj ) ));
- assert_eq! (::std::mem::align_of::<MutPtrMutObj>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( MutPtrMutObj ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const MutPtrMutObj ) ) . bar as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( MutPtrMutObj ) , "::" ,
- stringify ! ( bar ) ));
+ assert_eq!(
+ ::std::mem::size_of::<MutPtrMutObj>(),
+ 8usize,
+ concat!("Size of: ", stringify!(MutPtrMutObj))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<MutPtrMutObj>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(MutPtrMutObj))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const MutPtrMutObj)).bar as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(MutPtrMutObj),
+ "::",
+ stringify!(bar)
+ )
+ );
}
impl Clone for MutPtrMutObj {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for MutPtrMutObj {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -58,21 +89,36 @@ pub struct MutPtrConstObj {
}
#[test]
fn bindgen_test_layout_MutPtrConstObj() {
- assert_eq!(::std::mem::size_of::<MutPtrConstObj>() , 8usize , concat ! (
- "Size of: " , stringify ! ( MutPtrConstObj ) ));
- assert_eq! (::std::mem::align_of::<MutPtrConstObj>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( MutPtrConstObj ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const MutPtrConstObj ) ) . bar as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( MutPtrConstObj ) , "::"
- , stringify ! ( bar ) ));
+ assert_eq!(
+ ::std::mem::size_of::<MutPtrConstObj>(),
+ 8usize,
+ concat!("Size of: ", stringify!(MutPtrConstObj))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<MutPtrConstObj>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(MutPtrConstObj))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const MutPtrConstObj)).bar as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(MutPtrConstObj),
+ "::",
+ stringify!(bar)
+ )
+ );
}
impl Clone for MutPtrConstObj {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for MutPtrConstObj {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -81,19 +127,34 @@ pub struct ConstPtrConstObj {
}
#[test]
fn bindgen_test_layout_ConstPtrConstObj() {
- assert_eq!(::std::mem::size_of::<ConstPtrConstObj>() , 8usize , concat ! (
- "Size of: " , stringify ! ( ConstPtrConstObj ) ));
- assert_eq! (::std::mem::align_of::<ConstPtrConstObj>() , 8usize , concat !
- ( "Alignment of " , stringify ! ( ConstPtrConstObj ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ConstPtrConstObj ) ) . bar as * const _
- as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ConstPtrConstObj ) ,
- "::" , stringify ! ( bar ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ConstPtrConstObj>(),
+ 8usize,
+ concat!("Size of: ", stringify!(ConstPtrConstObj))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ConstPtrConstObj>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(ConstPtrConstObj))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ConstPtrConstObj)).bar as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ConstPtrConstObj),
+ "::",
+ stringify!(bar)
+ )
+ );
}
impl Clone for ConstPtrConstObj {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ConstPtrConstObj {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/derive-hash-template-def-float.rs b/tests/expectations/tests/derive-hash-template-def-float.rs
index 23bf702d..7b643901 100644
--- a/tests/expectations/tests/derive-hash-template-def-float.rs
+++ b/tests/expectations/tests/derive-hash-template-def-float.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// Template definition containing a float, which cannot derive hash/eq but can derive partialeq.
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -12,6 +13,8 @@ pub struct foo<T> {
pub b: f32,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for foo<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for foo<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/derive-hash-template-inst-float.rs b/tests/expectations/tests/derive-hash-template-inst-float.rs
index 58848f87..7bca45b3 100644
--- a/tests/expectations/tests/derive-hash-template-inst-float.rs
+++ b/tests/expectations/tests/derive-hash-template-inst-float.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// Template definition that doesn't contain float can derive hash/partialeq/eq
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -11,8 +12,10 @@ pub struct foo<T> {
pub data: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for foo<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for foo<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// Can derive hash/partialeq/eq when instantiated with int
#[repr(C)]
@@ -22,21 +25,36 @@ pub struct IntStr {
}
#[test]
fn bindgen_test_layout_IntStr() {
- assert_eq!(::std::mem::size_of::<IntStr>() , 4usize , concat ! (
- "Size of: " , stringify ! ( IntStr ) ));
- assert_eq! (::std::mem::align_of::<IntStr>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( IntStr ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const IntStr ) ) . a as * const _ as usize } ,
- 0usize , concat ! (
- "Alignment of field: " , stringify ! ( IntStr ) , "::" ,
- stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<IntStr>(),
+ 4usize,
+ concat!("Size of: ", stringify!(IntStr))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<IntStr>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(IntStr))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const IntStr)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(IntStr),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Clone for IntStr {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for IntStr {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// Cannot derive hash/eq when instantiated with float but can derive partialeq
#[repr(C)]
@@ -46,39 +64,51 @@ pub struct FloatStr {
}
#[test]
fn bindgen_test_layout_FloatStr() {
- assert_eq!(::std::mem::size_of::<FloatStr>() , 4usize , concat ! (
- "Size of: " , stringify ! ( FloatStr ) ));
- assert_eq! (::std::mem::align_of::<FloatStr>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( FloatStr ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const FloatStr ) ) . a as * const _ as usize }
- , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( FloatStr ) , "::" ,
- stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<FloatStr>(),
+ 4usize,
+ concat!("Size of: ", stringify!(FloatStr))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<FloatStr>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(FloatStr))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const FloatStr)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(FloatStr),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Clone for FloatStr {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for FloatStr {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_foo_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<foo<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- foo<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<foo<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- foo<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<foo<::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( foo < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < foo < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( foo < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_foo_open0_float_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<foo<f32>>() , 4usize , concat ! (
- "Size of template specialization: " , stringify ! ( foo<f32> )
- ));
- assert_eq!(::std::mem::align_of::<foo<f32>>() , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- foo<f32> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < foo < f32 > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( foo < f32 > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < foo < f32 > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( foo < f32 > ) ) );
}
diff --git a/tests/expectations/tests/derive-partialeq-and-blacklist.rs b/tests/expectations/tests/derive-partialeq-and-blacklist.rs
index 4aac3c8c..28f8ff53 100644
--- a/tests/expectations/tests/derive-partialeq-and-blacklist.rs
+++ b/tests/expectations/tests/derive-partialeq-and-blacklist.rs
@@ -5,6 +5,7 @@
pub struct BlacklistMe(u8);
+
/// Because this type contains a blacklisted type, it should not derive
/// PartialEq.
#[repr(C)]
@@ -13,18 +14,29 @@ pub struct ShouldNotDerivePartialEq {
}
#[test]
fn bindgen_test_layout_ShouldNotDerivePartialEq() {
- assert_eq!(::std::mem::size_of::<ShouldNotDerivePartialEq>() , 1usize ,
- concat ! (
- "Size of: " , stringify ! ( ShouldNotDerivePartialEq ) ));
- assert_eq! (::std::mem::align_of::<ShouldNotDerivePartialEq>() , 1usize ,
- concat ! (
- "Alignment of " , stringify ! ( ShouldNotDerivePartialEq ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldNotDerivePartialEq ) ) . a as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- ShouldNotDerivePartialEq ) , "::" , stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ShouldNotDerivePartialEq>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ShouldNotDerivePartialEq))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldNotDerivePartialEq>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ShouldNotDerivePartialEq))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldNotDerivePartialEq)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldNotDerivePartialEq),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Default for ShouldNotDerivePartialEq {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/forward-declaration-autoptr.rs b/tests/expectations/tests/forward-declaration-autoptr.rs
index 069728cb..6b078418 100644
--- a/tests/expectations/tests/forward-declaration-autoptr.rs
+++ b/tests/expectations/tests/forward-declaration-autoptr.rs
@@ -15,8 +15,10 @@ pub struct RefPtr<T> {
pub m_inner: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for RefPtr<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for RefPtr<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy)]
@@ -25,28 +27,46 @@ pub struct Bar {
}
#[test]
fn bindgen_test_layout_Bar() {
- assert_eq!(::std::mem::size_of::<Bar>() , 8usize , concat ! (
- "Size of: " , stringify ! ( Bar ) ));
- assert_eq! (::std::mem::align_of::<Bar>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Bar>(),
+ 8usize,
+ concat!("Size of: ", stringify!(Bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Bar>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for Bar {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_RefPtr_open0_Foo_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<RefPtr<Foo>>() , 8usize , concat ! (
- "Size of template specialization: " , stringify ! ( RefPtr<Foo>
- ) ));
- assert_eq!(::std::mem::align_of::<RefPtr<Foo>>() , 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- RefPtr<Foo> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<RefPtr<Foo>>(),
+ 8usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( RefPtr < Foo > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < RefPtr < Foo > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( RefPtr < Foo > ) ) );
}
diff --git a/tests/expectations/tests/gen-constructors.rs b/tests/expectations/tests/gen-constructors.rs
index d0439864..c811efb8 100644
--- a/tests/expectations/tests/gen-constructors.rs
+++ b/tests/expectations/tests/gen-constructors.rs
@@ -11,17 +11,25 @@ pub struct Foo {
}
#[test]
fn bindgen_test_layout_Foo() {
- assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Foo ) ));
- assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Foo {
#[inline]
diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs
index 9f0b9a14..b0366f1c 100644
--- a/tests/expectations/tests/issue-410.rs
+++ b/tests/expectations/tests/issue-410.rs
@@ -18,18 +18,25 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_Value() {
- assert_eq!(::std::mem::size_of::<Value>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Value ) ));
- assert_eq! (::std::mem::align_of::<Value>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Value ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Value>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Value))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Value>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Value))
+ );
}
extern "C" {
- #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"]
- pub fn Value_a(this: *mut root::JS::Value,
- arg1: root::JSWhyMagic);
+ #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"]
+ pub fn Value_a(this: *mut root::JS::Value, arg1: root::JSWhyMagic);
}
impl Clone for Value {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Value {
#[inline]
diff --git a/tests/expectations/tests/issue-447.rs b/tests/expectations/tests/issue-447.rs
index 4a7f07ed..7102235f 100644
--- a/tests/expectations/tests/issue-447.rs
+++ b/tests/expectations/tests/issue-447.rs
@@ -21,17 +21,21 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_GuardObjectNotifier() {
- assert_eq!(::std::mem::size_of::<GuardObjectNotifier>() ,
- 1usize , concat ! (
- "Size of: " , stringify ! ( GuardObjectNotifier )
- ));
- assert_eq! (::std::mem::align_of::<GuardObjectNotifier>() ,
- 1usize , concat ! (
- "Alignment of " , stringify ! (
- GuardObjectNotifier ) ));
+ assert_eq!(
+ ::std::mem::size_of::<GuardObjectNotifier>(),
+ 1usize,
+ concat!("Size of: ", stringify!(GuardObjectNotifier))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<GuardObjectNotifier>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(GuardObjectNotifier))
+ );
}
impl Clone for GuardObjectNotifier {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
}
}
@@ -42,28 +46,32 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_JSAutoCompartment() {
- assert_eq!(::std::mem::size_of::<JSAutoCompartment>() , 1usize ,
- concat ! ( "Size of: " , stringify ! ( JSAutoCompartment )
- ));
- assert_eq! (::std::mem::align_of::<JSAutoCompartment>() , 1usize ,
- concat ! (
- "Alignment of " , stringify ! ( JSAutoCompartment ) ));
+ assert_eq!(
+ ::std::mem::size_of::<JSAutoCompartment>(),
+ 1usize,
+ concat!("Size of: ", stringify!(JSAutoCompartment))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<JSAutoCompartment>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(JSAutoCompartment))
+ );
}
extern "C" {
- #[link_name =
- "_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"]
- pub fn JSAutoCompartment_JSAutoCompartment(this:
- *mut root::JSAutoCompartment,
- arg1:
- root::mozilla::detail::GuardObjectNotifier);
+ #[link_name = "_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"]
+ pub fn JSAutoCompartment_JSAutoCompartment(
+ this: *mut root::JSAutoCompartment,
+ arg1: root::mozilla::detail::GuardObjectNotifier,
+ );
}
impl Clone for JSAutoCompartment {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl JSAutoCompartment {
#[inline]
- pub unsafe fn new(arg1: root::mozilla::detail::GuardObjectNotifier)
- -> Self {
+ pub unsafe fn new(arg1: root::mozilla::detail::GuardObjectNotifier) -> Self {
let mut __bindgen_tmp = ::std::mem::uninitialized();
JSAutoCompartment_JSAutoCompartment(&mut __bindgen_tmp, arg1);
__bindgen_tmp
diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
index 85937c3f..27b5cfcd 100644
--- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
+++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// We emit a `[u8; 63usize]` padding field for this struct, which cannot derive
/// Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end
/// up with the reight alignment, we're waiting on `#[repr(align="N")]` to land
@@ -16,19 +17,31 @@ pub struct NoDebug {
}
#[test]
fn bindgen_test_layout_NoDebug() {
- assert_eq!(::std::mem::size_of::<NoDebug>() , 64usize , concat ! (
- "Size of: " , stringify ! ( NoDebug ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const NoDebug ) ) . c as * const _ as usize } ,
- 0usize , concat ! (
- "Alignment of field: " , stringify ! ( NoDebug ) , "::" ,
- stringify ! ( c ) ));
+ assert_eq!(
+ ::std::mem::size_of::<NoDebug>(),
+ 64usize,
+ concat!("Size of: ", stringify!(NoDebug))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const NoDebug)).c as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(NoDebug),
+ "::",
+ stringify!(c)
+ )
+ );
}
impl Clone for NoDebug {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for NoDebug {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive
/// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because
@@ -43,23 +56,39 @@ pub struct ShouldDeriveDebugButDoesNot {
}
#[test]
fn bindgen_test_layout_ShouldDeriveDebugButDoesNot() {
- assert_eq!(::std::mem::size_of::<ShouldDeriveDebugButDoesNot>() , 64usize
- , concat ! (
- "Size of: " , stringify ! ( ShouldDeriveDebugButDoesNot ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldDeriveDebugButDoesNot ) ) . c as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- ShouldDeriveDebugButDoesNot ) , "::" , stringify ! ( c ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldDeriveDebugButDoesNot ) ) . d as *
- const _ as usize } , 32usize , concat ! (
- "Alignment of field: " , stringify ! (
- ShouldDeriveDebugButDoesNot ) , "::" , stringify ! ( d ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ShouldDeriveDebugButDoesNot>(),
+ 64usize,
+ concat!("Size of: ", stringify!(ShouldDeriveDebugButDoesNot))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldDeriveDebugButDoesNot)).c as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldDeriveDebugButDoesNot),
+ "::",
+ stringify!(c)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldDeriveDebugButDoesNot)).d as *const _ as usize },
+ 32usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldDeriveDebugButDoesNot),
+ "::",
+ stringify!(d)
+ )
+ );
}
impl Clone for ShouldDeriveDebugButDoesNot {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ShouldDeriveDebugButDoesNot {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/issue-848-replacement-system-include.rs b/tests/expectations/tests/issue-848-replacement-system-include.rs
index 14083705..16fab93a 100644
--- a/tests/expectations/tests/issue-848-replacement-system-include.rs
+++ b/tests/expectations/tests/issue-848-replacement-system-include.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// This is intended to replace another type, but won't if we treat this include
/// as a system include, because clang doesn't parse comments there.
///
@@ -16,8 +17,10 @@ pub struct nsTArray<T> {
pub m: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for nsTArray<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for nsTArray<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
extern "C" {
pub fn func() -> *mut nsTArray<::std::os::raw::c_int>;
diff --git a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs b/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs
index 10e54056..cd3d38c1 100644
--- a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs
+++ b/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs
@@ -5,6 +5,7 @@
pub struct BlacklistMe(u8);
+
/// Because this type contains a blacklisted type, it should not derive Copy.
#[repr(C)]
pub struct ShouldNotBeCopy {
@@ -12,16 +13,29 @@ pub struct ShouldNotBeCopy {
}
#[test]
fn bindgen_test_layout_ShouldNotBeCopy() {
- assert_eq!(::std::mem::size_of::<ShouldNotBeCopy>() , 1usize , concat ! (
- "Size of: " , stringify ! ( ShouldNotBeCopy ) ));
- assert_eq! (::std::mem::align_of::<ShouldNotBeCopy>() , 1usize , concat !
- ( "Alignment of " , stringify ! ( ShouldNotBeCopy ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ShouldNotBeCopy ) ) . a as * const _ as
- usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ShouldNotBeCopy ) ,
- "::" , stringify ! ( a ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ShouldNotBeCopy>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ShouldNotBeCopy))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ShouldNotBeCopy>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ShouldNotBeCopy))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ShouldNotBeCopy)).a as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ShouldNotBeCopy),
+ "::",
+ stringify!(a)
+ )
+ );
}
impl Default for ShouldNotBeCopy {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/issue_315.rs b/tests/expectations/tests/issue_315.rs
index d5302451..d6660523 100644
--- a/tests/expectations/tests/issue_315.rs
+++ b/tests/expectations/tests/issue_315.rs
@@ -4,5 +4,6 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen replaces="c"></div>
pub type c<a> = a;
diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs
index 0a77b24e..2e93bb46 100644
--- a/tests/expectations/tests/jsval_layout_opaque.rs
+++ b/tests/expectations/tests/jsval_layout_opaque.rs
@@ -91,30 +91,37 @@ pub struct jsval_layout__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_1>() , 8usize ,
- concat ! (
- "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_1>() , 8usize
- , concat ! (
- "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout__bindgen_ty_1>(),
+ 8usize,
+ concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout__bindgen_ty_1>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_1))
+ );
}
impl Clone for jsval_layout__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for jsval_layout__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl jsval_layout__bindgen_ty_1 {
#[inline]
pub fn payload47(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 140737488355327u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -126,31 +133,31 @@ impl jsval_layout__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn tag(&self) -> JSValueTag {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 18446603336221196288u64 as u64;
let val = (unit_field_val & mask) >> 47usize;
@@ -162,31 +169,26 @@ impl jsval_layout__bindgen_ty_1 {
let val = val as u32 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 47usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn new_bitfield_1(payload47: u64, tag: JSValueTag) -> u64 {
- ({
- ({ 0 } |
- ((payload47 as u64 as u64) << 0usize) &
- (140737488355327u64 as u64))
- } |
- ((tag as u32 as u64) << 47usize) &
- (18446603336221196288u64 as u64))
+ ((0 | ((payload47 as u64 as u64) << 0usize) & (140737488355327u64 as u64)) |
+ ((tag as u32 as u64) << 47usize) & (18446603336221196288u64 as u64))
}
}
#[repr(C)]
@@ -204,111 +206,194 @@ pub union jsval_layout__bindgen_ty_2__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>()
- , 4usize , concat ! (
- "Size of: " , stringify ! (
- jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>(),
+ 4usize,
+ concat!(
+ "Size of: ",
+ stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for jsval_layout__bindgen_ty_2__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_2>() , 4usize ,
- concat ! (
- "Size of: " , stringify ! ( jsval_layout__bindgen_ty_2 ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_2>() , 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 )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout__bindgen_ty_2>(),
+ 4usize,
+ concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for jsval_layout__bindgen_ty_2 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_jsval_layout() {
- assert_eq!(::std::mem::size_of::<jsval_layout>() , 8usize , concat ! (
- "Size of: " , stringify ! ( jsval_layout ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout>(),
+ 8usize,
+ concat!("Size of: ", stringify!(jsval_layout))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for jsval_layout {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -317,19 +402,34 @@ pub struct Value {
}
#[test]
fn bindgen_test_layout_Value() {
- assert_eq!(::std::mem::size_of::<Value>() , 8usize , concat ! (
- "Size of: " , stringify ! ( Value ) ));
- assert_eq! (::std::mem::align_of::<Value>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Value>(),
+ 8usize,
+ concat!("Size of: ", stringify!(Value))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Value>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for Value {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs
index 563124d5..b818bf90 100644
--- a/tests/expectations/tests/jsval_layout_opaque_1_0.rs
+++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs
@@ -6,33 +6,45 @@
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
-impl <T> __BindgenUnionField<T> {
+impl<T> __BindgenUnionField<T> {
#[inline]
- pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
#[inline]
- pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ 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 unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
}
-impl <T> ::std::default::Default for __BindgenUnionField<T> {
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
#[inline]
- fn default() -> Self { Self::new() }
+ fn default() -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
-impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
-impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
- fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
}
-impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
- fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
+impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
}
impl <T> ::std::cmp::Eq for __BindgenUnionField<T> { }
pub const JSVAL_TAG_SHIFT: ::std::os::raw::c_uint = 47;
@@ -122,30 +134,37 @@ pub struct jsval_layout__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_1>() , 8usize ,
- concat ! (
- "Size of: " , stringify ! ( jsval_layout__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_1>() , 8usize
- , concat ! (
- "Alignment of " , stringify ! ( jsval_layout__bindgen_ty_1 )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout__bindgen_ty_1>(),
+ 8usize,
+ concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout__bindgen_ty_1>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(jsval_layout__bindgen_ty_1))
+ );
}
impl Clone for jsval_layout__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for jsval_layout__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl jsval_layout__bindgen_ty_1 {
#[inline]
pub fn payload47(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 140737488355327u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -157,31 +176,31 @@ impl jsval_layout__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn tag(&self) -> JSValueTag {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 18446603336221196288u64 as u64;
let val = (unit_field_val & mask) >> 47usize;
@@ -193,31 +212,26 @@ impl jsval_layout__bindgen_ty_1 {
let val = val as u32 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 47usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn new_bitfield_1(payload47: u64, tag: JSValueTag) -> u64 {
- ({
- ({ 0 } |
- ((payload47 as u64 as u64) << 0usize) &
- (140737488355327u64 as u64))
- } |
- ((tag as u32 as u64) << 47usize) &
- (18446603336221196288u64 as u64))
+ ((0 | ((payload47 as u64 as u64) << 0usize) & (140737488355327u64 as u64)) |
+ ((tag as u32 as u64) << 47usize) & (18446603336221196288u64 as u64))
}
}
#[repr(C)]
@@ -235,102 +249,179 @@ pub struct jsval_layout__bindgen_ty_2__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_2__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>()
- , 4usize , concat ! (
- "Size of: " , stringify ! (
- jsval_layout__bindgen_ty_2__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>(),
+ 4usize,
+ concat!(
+ "Size of: ",
+ stringify!(jsval_layout__bindgen_ty_2__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout__bindgen_ty_2__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_jsval_layout__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<jsval_layout__bindgen_ty_2>() , 4usize ,
- concat ! (
- "Size of: " , stringify ! ( jsval_layout__bindgen_ty_2 ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout__bindgen_ty_2>() , 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 )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout__bindgen_ty_2>(),
+ 4usize,
+ concat!("Size of: ", stringify!(jsval_layout__bindgen_ty_2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_jsval_layout() {
- assert_eq!(::std::mem::size_of::<jsval_layout>() , 8usize , concat ! (
- "Size of: " , stringify ! ( jsval_layout ) ));
- assert_eq! (::std::mem::align_of::<jsval_layout>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<jsval_layout>(),
+ 8usize,
+ concat!("Size of: ", stringify!(jsval_layout))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<jsval_layout>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq)]
@@ -339,16 +430,29 @@ pub struct Value {
}
#[test]
fn bindgen_test_layout_Value() {
- assert_eq!(::std::mem::size_of::<Value>() , 8usize , concat ! (
- "Size of: " , stringify ! ( Value ) ));
- assert_eq! (::std::mem::align_of::<Value>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Value>(),
+ 8usize,
+ concat!("Size of: ", stringify!(Value))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Value>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs
index 102f1785..9e9ac872 100644
--- a/tests/expectations/tests/layout_align.rs
+++ b/tests/expectations/tests/layout_align.rs
@@ -7,13 +7,15 @@
#[repr(C)]
#[derive(Default)]
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>);
-impl <T> __IncompleteArrayField<T> {
+impl<T> __IncompleteArrayField<T> {
#[inline]
pub fn new() -> Self {
__IncompleteArrayField(::std::marker::PhantomData)
}
#[inline]
- pub unsafe fn as_ptr(&self) -> *const T { ::std::mem::transmute(self) }
+ 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)
@@ -27,16 +29,18 @@ impl <T> __IncompleteArrayField<T> {
::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
}
}
-impl <T> ::std::fmt::Debug for __IncompleteArrayField<T> {
+impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
-impl <T> ::std::clone::Clone for __IncompleteArrayField<T> {
+impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
+impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Debug)]
pub struct rte_kni_fifo {
@@ -54,13 +58,21 @@ pub struct rte_kni_fifo {
}
#[test]
fn bindgen_test_layout_rte_kni_fifo() {
- assert_eq!(::std::mem::size_of::<rte_kni_fifo>() , 16usize , concat ! (
- "Size of: " , stringify ! ( rte_kni_fifo ) ));
- assert_eq! (::std::mem::align_of::<rte_kni_fifo>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( rte_kni_fifo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_kni_fifo>(),
+ 16usize,
+ concat!("Size of: ", stringify!(rte_kni_fifo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_kni_fifo>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(rte_kni_fifo))
+ );
}
impl Default for rte_kni_fifo {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
@@ -73,29 +85,42 @@ pub struct rte_eth_link {
}
#[test]
fn bindgen_test_layout_rte_eth_link() {
- assert_eq!(::std::mem::size_of::<rte_eth_link>() , 8usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_link ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_link>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_link>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_eth_link))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_link>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl rte_eth_link {
#[inline]
pub fn link_duplex(&self) -> u16 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -107,31 +132,31 @@ impl rte_eth_link {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn link_autoneg(&self) -> u16 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 2u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -143,31 +168,31 @@ impl rte_eth_link {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn link_status(&self) -> u16 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 4u64 as u8;
let val = (unit_field_val & mask) >> 2usize;
@@ -179,30 +204,26 @@ impl rte_eth_link {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(link_duplex: u16, link_autoneg: u16,
- link_status: u16) -> u8 {
- ({
- ({
- ({ 0 } |
- ((link_duplex as u16 as u8) << 0usize) & (1u64 as u8))
- } | ((link_autoneg as u16 as u8) << 1usize) & (2u64 as u8))
- } | ((link_status as u16 as u8) << 2usize) & (4u64 as u8))
+ pub fn new_bitfield_1(link_duplex: u16, link_autoneg: u16, link_status: u16) -> u8 {
+ (((0 | ((link_duplex as u16 as u8) << 0usize) & (1u64 as u8)) |
+ ((link_autoneg as u16 as u8) << 1usize) & (2u64 as u8)) |
+ ((link_status as u16 as u8) << 2usize) & (4u64 as u8))
}
}
diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs
index 94968579..be841432 100644
--- a/tests/expectations/tests/layout_cmdline_token.rs
+++ b/tests/expectations/tests/layout_cmdline_token.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// Stores a pointer to the ops struct, and the offset: the place to
/// write the parsed result in the destination structure.
#[repr(C)]
@@ -14,26 +15,46 @@ pub struct cmdline_token_hdr {
}
#[test]
fn bindgen_test_layout_cmdline_token_hdr() {
- assert_eq!(::std::mem::size_of::<cmdline_token_hdr>() , 16usize , concat !
- ( "Size of: " , stringify ! ( cmdline_token_hdr ) ));
- assert_eq! (::std::mem::align_of::<cmdline_token_hdr>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<cmdline_token_hdr>(),
+ 16usize,
+ concat!("Size of: ", stringify!(cmdline_token_hdr))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<cmdline_token_hdr>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for cmdline_token_hdr {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
pub type cmdline_parse_token_hdr_t = cmdline_token_hdr;
/// A token is defined by this structure.
@@ -57,70 +78,99 @@ pub type cmdline_parse_token_hdr_t = cmdline_token_hdr;
#[derive(Debug, Copy)]
pub struct cmdline_token_ops {
/// parse(token ptr, buf, res pts, buf len)
- pub parse: ::std::option::Option<unsafe extern "C" fn(arg1:
- *mut cmdline_parse_token_hdr_t,
- arg2:
- *const ::std::os::raw::c_char,
- arg3:
- *mut ::std::os::raw::c_void,
- arg4:
- ::std::os::raw::c_uint)
- -> ::std::os::raw::c_int>,
+ pub parse: ::std::option::Option<
+ unsafe extern "C" fn(
+ arg1: *mut cmdline_parse_token_hdr_t,
+ arg2: *const ::std::os::raw::c_char,
+ arg3: *mut ::std::os::raw::c_void,
+ arg4: ::std::os::raw::c_uint,
+ ) -> ::std::os::raw::c_int,
+ >,
/// return the num of possible choices for this token
- pub complete_get_nb: ::std::option::Option<unsafe extern "C" fn(arg1:
- *mut cmdline_parse_token_hdr_t)
- -> ::std::os::raw::c_int>,
+ pub complete_get_nb: ::std::option::Option<
+ unsafe extern "C" fn(arg1: *mut cmdline_parse_token_hdr_t)
+ -> ::std::os::raw::c_int,
+ >,
/// return the elt x for this token (token, idx, dstbuf, size)
- pub complete_get_elt: ::std::option::Option<unsafe extern "C" fn(arg1:
- *mut cmdline_parse_token_hdr_t,
- arg2:
- ::std::os::raw::c_int,
- arg3:
- *mut ::std::os::raw::c_char,
- arg4:
- ::std::os::raw::c_uint)
- -> ::std::os::raw::c_int>,
+ pub complete_get_elt: ::std::option::Option<
+ unsafe extern "C" fn(
+ arg1: *mut cmdline_parse_token_hdr_t,
+ arg2: ::std::os::raw::c_int,
+ arg3: *mut ::std::os::raw::c_char,
+ arg4: ::std::os::raw::c_uint,
+ ) -> ::std::os::raw::c_int,
+ >,
/// get help for this token (token, dstbuf, size)
- pub get_help: ::std::option::Option<unsafe extern "C" fn(arg1:
- *mut cmdline_parse_token_hdr_t,
- arg2:
- *mut ::std::os::raw::c_char,
- arg3:
- ::std::os::raw::c_uint)
- -> ::std::os::raw::c_int>,
+ pub get_help: ::std::option::Option<
+ unsafe extern "C" fn(
+ arg1: *mut cmdline_parse_token_hdr_t,
+ arg2: *mut ::std::os::raw::c_char,
+ arg3: ::std::os::raw::c_uint,
+ ) -> ::std::os::raw::c_int,
+ >,
}
#[test]
fn bindgen_test_layout_cmdline_token_ops() {
- assert_eq!(::std::mem::size_of::<cmdline_token_ops>() , 32usize , concat !
- ( "Size of: " , stringify ! ( cmdline_token_ops ) ));
- assert_eq! (::std::mem::align_of::<cmdline_token_ops>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<cmdline_token_ops>(),
+ 32usize,
+ concat!("Size of: ", stringify!(cmdline_token_ops))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<cmdline_token_ops>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for cmdline_token_ops {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@@ -141,23 +191,36 @@ pub struct cmdline_token_num_data {
}
#[test]
fn bindgen_test_layout_cmdline_token_num_data() {
- assert_eq!(::std::mem::size_of::<cmdline_token_num_data>() , 4usize ,
- concat ! ( "Size of: " , stringify ! ( cmdline_token_num_data )
- ));
- assert_eq! (::std::mem::align_of::<cmdline_token_num_data>() , 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_ ) ));
+ assert_eq!(
+ ::std::mem::size_of::<cmdline_token_num_data>(),
+ 4usize,
+ concat!("Size of: ", stringify!(cmdline_token_num_data))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<cmdline_token_num_data>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for cmdline_token_num_data {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy)]
@@ -167,25 +230,45 @@ pub struct cmdline_token_num {
}
#[test]
fn bindgen_test_layout_cmdline_token_num() {
- assert_eq!(::std::mem::size_of::<cmdline_token_num>() , 24usize , concat !
- ( "Size of: " , stringify ! ( cmdline_token_num ) ));
- assert_eq! (::std::mem::align_of::<cmdline_token_num>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<cmdline_token_num>(),
+ 24usize,
+ concat!("Size of: ", stringify!(cmdline_token_num))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<cmdline_token_num>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for cmdline_token_num {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
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 38c105d3..8c2889ba 100644
--- a/tests/expectations/tests/layout_eth_conf.rs
+++ b/tests/expectations/tests/layout_eth_conf.rs
@@ -64,42 +64,67 @@ pub struct rte_eth_rxmode {
}
#[test]
fn bindgen_test_layout_rte_eth_rxmode() {
- assert_eq!(::std::mem::size_of::<rte_eth_rxmode>() , 12usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_rxmode ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_rxmode>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_rxmode>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_rxmode))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_rxmode>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_rxmode {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl rte_eth_rxmode {
#[inline]
pub fn header_split(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 1u64 as u16;
let val = (unit_field_val & mask) >> 0usize;
@@ -111,31 +136,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_ip_checksum(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 2u64 as u16;
let val = (unit_field_val & mask) >> 1usize;
@@ -147,31 +172,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_vlan_filter(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 4u64 as u16;
let val = (unit_field_val & mask) >> 2usize;
@@ -183,31 +208,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_vlan_strip(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 8u64 as u16;
let val = (unit_field_val & mask) >> 3usize;
@@ -219,31 +244,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_vlan_extend(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 16u64 as u16;
let val = (unit_field_val & mask) >> 4usize;
@@ -255,31 +280,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 4usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn jumbo_frame(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 32u64 as u16;
let val = (unit_field_val & mask) >> 5usize;
@@ -291,31 +316,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 5usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_strip_crc(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 64u64 as u16;
let val = (unit_field_val & mask) >> 6usize;
@@ -327,31 +352,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 6usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn enable_scatter(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 128u64 as u16;
let val = (unit_field_val & mask) >> 7usize;
@@ -363,31 +388,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn enable_lro(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 256u64 as u16;
let val = (unit_field_val & mask) >> 8usize;
@@ -399,63 +424,43 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(header_split: u16, hw_ip_checksum: u16,
- hw_vlan_filter: u16, hw_vlan_strip: u16,
- hw_vlan_extend: u16, jumbo_frame: u16,
- hw_strip_crc: u16, enable_scatter: u16,
- enable_lro: u16) -> u16 {
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((header_split as u16 as
- u16) << 0usize) &
- (1u64 as u16))
- } |
- ((hw_ip_checksum as u16 as
- u16) << 1usize) &
- (2u64 as u16))
- } |
- ((hw_vlan_filter as u16 as u16) <<
- 2usize) & (4u64 as u16))
- } |
- ((hw_vlan_strip as u16 as u16) <<
- 3usize) & (8u64 as u16))
- } |
- ((hw_vlan_extend as u16 as u16) << 4usize) &
- (16u64 as u16))
- } |
- ((jumbo_frame as u16 as u16) << 5usize) &
- (32u64 as u16))
- } |
- ((hw_strip_crc as u16 as u16) << 6usize) &
- (64u64 as u16))
- } |
- ((enable_scatter as u16 as u16) << 7usize) &
- (128u64 as u16))
- } | ((enable_lro as u16 as u16) << 8usize) & (256u64 as u16))
+ pub fn new_bitfield_1(
+ header_split: u16,
+ hw_ip_checksum: u16,
+ hw_vlan_filter: u16,
+ hw_vlan_strip: u16,
+ hw_vlan_extend: u16,
+ jumbo_frame: u16,
+ hw_strip_crc: u16,
+ enable_scatter: u16,
+ enable_lro: u16,
+ ) -> u16 {
+ (((((((((0 | ((header_split as u16 as u16) << 0usize) & (1u64 as u16)) |
+ ((hw_ip_checksum as u16 as u16) << 1usize) & (2u64 as u16)) |
+ ((hw_vlan_filter as u16 as u16) << 2usize) & (4u64 as u16)) |
+ ((hw_vlan_strip as u16 as u16) << 3usize) & (8u64 as u16)) |
+ ((hw_vlan_extend as u16 as u16) << 4usize) & (16u64 as u16)) |
+ ((jumbo_frame as u16 as u16) << 5usize) & (32u64 as u16)) |
+ ((hw_strip_crc as u16 as u16) << 6usize) & (64u64 as u16)) |
+ ((enable_scatter as u16 as u16) << 7usize) & (128u64 as u16)) |
+ ((enable_lro as u16 as u16) << 8usize) & (256u64 as u16))
}
}
#[repr(u32)]
@@ -480,37 +485,57 @@ pub struct rte_eth_txmode {
}
#[test]
fn bindgen_test_layout_rte_eth_txmode() {
- assert_eq!(::std::mem::size_of::<rte_eth_txmode>() , 8usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_txmode ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_txmode>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_txmode>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_eth_txmode))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_txmode>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_txmode {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl rte_eth_txmode {
#[inline]
pub fn hw_vlan_reject_tagged(&self) -> u8 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -522,31 +547,31 @@ impl rte_eth_txmode {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn hw_vlan_reject_untagged(&self) -> u8 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 2u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -558,31 +583,31 @@ impl rte_eth_txmode {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn hw_vlan_insert_pvid(&self) -> u8 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 4u64 as u8;
let val = (unit_field_val & mask) >> 2usize;
@@ -594,35 +619,31 @@ impl rte_eth_txmode {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(hw_vlan_reject_tagged: u8,
- hw_vlan_reject_untagged: u8,
- hw_vlan_insert_pvid: u8) -> u8 {
- ({
- ({
- ({ 0 } |
- ((hw_vlan_reject_tagged as u8 as u8) << 0usize) &
- (1u64 as u8))
- } |
- ((hw_vlan_reject_untagged as u8 as u8) << 1usize) &
- (2u64 as u8))
- } | ((hw_vlan_insert_pvid as u8 as u8) << 2usize) & (4u64 as u8))
+ pub fn new_bitfield_1(
+ hw_vlan_reject_tagged: u8,
+ hw_vlan_reject_untagged: u8,
+ hw_vlan_insert_pvid: u8,
+ ) -> u8 {
+ (((0 | ((hw_vlan_reject_tagged as u8 as u8) << 0usize) & (1u64 as u8)) |
+ ((hw_vlan_reject_untagged as u8 as u8) << 1usize) & (2u64 as u8)) |
+ ((hw_vlan_insert_pvid as u8 as u8) << 2usize) & (4u64 as u8))
}
}
/// A structure used to configure the Receive Side Scaling (RSS) feature
@@ -652,37 +673,65 @@ pub struct rte_eth_rss_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_rss_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_rss_conf>() , 24usize , concat !
- ( "Size of: " , stringify ! ( rte_eth_rss_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_rss_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_rss_conf>(),
+ 24usize,
+ concat!("Size of: ", stringify!(rte_eth_rss_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_rss_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_rss_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ 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, }
+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.
@@ -727,75 +776,129 @@ pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>() ,
- 16usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf__bindgen_ty_1
- ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>(),
+ 16usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_dcb_conf>() , 1040usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_dcb_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_dcb_conf>(),
+ 1040usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_dcb_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_dcb_conf>(),
+ 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 Clone for rte_eth_vmdq_dcb_conf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_dcb_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -807,27 +910,46 @@ pub struct rte_eth_dcb_rx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_dcb_rx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_dcb_rx_conf>() , 12usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_dcb_rx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_dcb_rx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_dcb_rx_conf>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_dcb_rx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_dcb_rx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_dcb_rx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -839,29 +961,46 @@ pub struct rte_eth_vmdq_dcb_tx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_dcb_tx_conf>() , 12usize ,
- concat ! (
- "Size of: " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_dcb_tx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_dcb_tx_conf>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_dcb_tx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_dcb_tx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_dcb_tx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -873,27 +1012,46 @@ pub struct rte_eth_dcb_tx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_dcb_tx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_dcb_tx_conf>() , 12usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_dcb_tx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_dcb_tx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_dcb_tx_conf>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_dcb_tx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_dcb_tx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_dcb_tx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -903,22 +1061,36 @@ pub struct rte_eth_vmdq_tx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_tx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_tx_conf>() , 4usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_vmdq_tx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_tx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_tx_conf>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_tx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_tx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_tx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -948,80 +1120,139 @@ pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>() ,
- 16usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf__bindgen_ty_1
- ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>() ,
- 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>(),
+ 16usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_rx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_rx_conf>() , 1040usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_rx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_rx_conf>(),
+ 1040usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_rx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_rx_conf>(),
+ 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 Clone for rte_eth_vmdq_rx_conf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_rx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(u32)]
/// Flow Director setting modes: none, signature or perfect.
@@ -1067,38 +1298,71 @@ pub struct rte_eth_ipv4_flow {
}
#[test]
fn bindgen_test_layout_rte_eth_ipv4_flow() {
- assert_eq!(::std::mem::size_of::<rte_eth_ipv4_flow>() , 12usize , concat !
- ( "Size of: " , stringify ! ( rte_eth_ipv4_flow ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_ipv4_flow>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_ipv4_flow>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_ipv4_flow))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_ipv4_flow>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// A structure used to define the input for IPV6 flow
#[repr(C)]
@@ -1117,38 +1381,71 @@ pub struct rte_eth_ipv6_flow {
}
#[test]
fn bindgen_test_layout_rte_eth_ipv6_flow() {
- assert_eq!(::std::mem::size_of::<rte_eth_ipv6_flow>() , 36usize , concat !
- ( "Size of: " , stringify ! ( rte_eth_ipv6_flow ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_ipv6_flow>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_ipv6_flow>(),
+ 36usize,
+ concat!("Size of: ", stringify!(rte_eth_ipv6_flow))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_ipv6_flow>(),
+ 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 }
+ 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.
@@ -1176,54 +1473,101 @@ pub struct rte_eth_fdir_masks {
}
#[test]
fn bindgen_test_layout_rte_eth_fdir_masks() {
- assert_eq!(::std::mem::size_of::<rte_eth_fdir_masks>() , 68usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_fdir_masks ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_fdir_masks>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_fdir_masks>(),
+ 68usize,
+ concat!("Size of: ", stringify!(rte_eth_fdir_masks))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_fdir_masks>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(u32)]
/// Payload type
@@ -1247,29 +1591,46 @@ pub struct rte_eth_flex_payload_cfg {
}
#[test]
fn bindgen_test_layout_rte_eth_flex_payload_cfg() {
- assert_eq!(::std::mem::size_of::<rte_eth_flex_payload_cfg>() , 36usize ,
- concat ! (
- "Size of: " , stringify ! ( rte_eth_flex_payload_cfg ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_flex_payload_cfg>() , 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 )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_flex_payload_cfg>(),
+ 36usize,
+ concat!("Size of: ", stringify!(rte_eth_flex_payload_cfg))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_flex_payload_cfg>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_flex_payload_cfg {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// A structure used to define FDIR masks for flexible payload
/// for each flow type
@@ -1281,25 +1642,41 @@ pub struct rte_eth_fdir_flex_mask {
}
#[test]
fn bindgen_test_layout_rte_eth_fdir_flex_mask() {
- assert_eq!(::std::mem::size_of::<rte_eth_fdir_flex_mask>() , 18usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_mask )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_fdir_flex_mask>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_fdir_flex_mask>(),
+ 18usize,
+ concat!("Size of: ", stringify!(rte_eth_fdir_flex_mask))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_fdir_flex_mask>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// A structure used to define all flexible payload related setting
/// include flex payload and flex mask
@@ -1315,38 +1692,66 @@ pub struct rte_eth_fdir_flex_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_fdir_flex_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_fdir_flex_conf>() , 688usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_conf )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_fdir_flex_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_fdir_flex_conf>(),
+ 688usize,
+ concat!("Size of: ", stringify!(rte_eth_fdir_flex_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_fdir_flex_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_fdir_flex_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// A structure used to configure the Flow Director (FDIR) feature
/// of an Ethernet port.
@@ -1368,46 +1773,86 @@ pub struct rte_fdir_conf {
}
#[test]
fn bindgen_test_layout_rte_fdir_conf() {
- assert_eq!(::std::mem::size_of::<rte_fdir_conf>() , 772usize , concat ! (
- "Size of: " , stringify ! ( rte_fdir_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_fdir_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_fdir_conf>(),
+ 772usize,
+ concat!("Size of: ", stringify!(rte_fdir_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_fdir_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_fdir_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// A structure used to enable/disable specific device interrupts.
#[repr(C)]
@@ -1420,23 +1865,41 @@ pub struct rte_intr_conf {
}
#[test]
fn bindgen_test_layout_rte_intr_conf() {
- assert_eq!(::std::mem::size_of::<rte_intr_conf>() , 4usize , concat ! (
- "Size of: " , stringify ! ( rte_intr_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_intr_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_intr_conf>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_intr_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_intr_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// A structure used to configure an Ethernet port.
/// Depending upon the RX multi-queue mode, extra advanced
@@ -1485,43 +1948,66 @@ pub struct rte_eth_conf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_eth_conf__bindgen_ty_1>() , 2120usize
- , concat ! (
- "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_conf__bindgen_ty_1>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_conf__bindgen_ty_1>(),
+ 2120usize,
+ concat!("Size of: ", stringify!(rte_eth_conf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_conf__bindgen_ty_1>(),
+ 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 Clone for rte_eth_conf__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_conf__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -1533,93 +2019,169 @@ pub union rte_eth_conf__bindgen_ty_2 {
}
#[test]
fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<rte_eth_conf__bindgen_ty_2>() , 12usize ,
- concat ! (
- "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_conf__bindgen_ty_2>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_conf__bindgen_ty_2>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_conf__bindgen_ty_2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_conf__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_conf__bindgen_ty_2 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_rte_eth_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_conf>() , 2944usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_conf>(),
+ 2944usize,
+ concat!("Size of: ", stringify!(rte_eth_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_conf>(),
+ 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 Clone for rte_eth_conf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs
index c03a3dd4..88e931b6 100644
--- a/tests/expectations/tests/layout_eth_conf_1_0.rs
+++ b/tests/expectations/tests/layout_eth_conf_1_0.rs
@@ -6,33 +6,45 @@
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
-impl <T> __BindgenUnionField<T> {
+impl<T> __BindgenUnionField<T> {
#[inline]
- pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
#[inline]
- pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ 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 unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
}
-impl <T> ::std::default::Default for __BindgenUnionField<T> {
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
#[inline]
- fn default() -> Self { Self::new() }
+ fn default() -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
-impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
-impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
- fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
}
-impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
- fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
+impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
}
impl <T> ::std::cmp::Eq for __BindgenUnionField<T> { }
pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1;
@@ -95,42 +107,67 @@ pub struct rte_eth_rxmode {
}
#[test]
fn bindgen_test_layout_rte_eth_rxmode() {
- assert_eq!(::std::mem::size_of::<rte_eth_rxmode>() , 12usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_rxmode ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_rxmode>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_rxmode>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_rxmode))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_rxmode>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_rxmode {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl rte_eth_rxmode {
#[inline]
pub fn header_split(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 1u64 as u16;
let val = (unit_field_val & mask) >> 0usize;
@@ -142,31 +179,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_ip_checksum(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 2u64 as u16;
let val = (unit_field_val & mask) >> 1usize;
@@ -178,31 +215,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_vlan_filter(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 4u64 as u16;
let val = (unit_field_val & mask) >> 2usize;
@@ -214,31 +251,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_vlan_strip(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 8u64 as u16;
let val = (unit_field_val & mask) >> 3usize;
@@ -250,31 +287,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_vlan_extend(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 16u64 as u16;
let val = (unit_field_val & mask) >> 4usize;
@@ -286,31 +323,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 4usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn jumbo_frame(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 32u64 as u16;
let val = (unit_field_val & mask) >> 5usize;
@@ -322,31 +359,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 5usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn hw_strip_crc(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 64u64 as u16;
let val = (unit_field_val & mask) >> 6usize;
@@ -358,31 +395,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 6usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn enable_scatter(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 128u64 as u16;
let val = (unit_field_val & mask) >> 7usize;
@@ -394,31 +431,31 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn enable_lro(&self) -> u16 {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 256u64 as u16;
let val = (unit_field_val & mask) >> 8usize;
@@ -430,63 +467,43 @@ impl rte_eth_rxmode {
let val = val as u16 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(header_split: u16, hw_ip_checksum: u16,
- hw_vlan_filter: u16, hw_vlan_strip: u16,
- hw_vlan_extend: u16, jumbo_frame: u16,
- hw_strip_crc: u16, enable_scatter: u16,
- enable_lro: u16) -> u16 {
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((header_split as u16 as
- u16) << 0usize) &
- (1u64 as u16))
- } |
- ((hw_ip_checksum as u16 as
- u16) << 1usize) &
- (2u64 as u16))
- } |
- ((hw_vlan_filter as u16 as u16) <<
- 2usize) & (4u64 as u16))
- } |
- ((hw_vlan_strip as u16 as u16) <<
- 3usize) & (8u64 as u16))
- } |
- ((hw_vlan_extend as u16 as u16) << 4usize) &
- (16u64 as u16))
- } |
- ((jumbo_frame as u16 as u16) << 5usize) &
- (32u64 as u16))
- } |
- ((hw_strip_crc as u16 as u16) << 6usize) &
- (64u64 as u16))
- } |
- ((enable_scatter as u16 as u16) << 7usize) &
- (128u64 as u16))
- } | ((enable_lro as u16 as u16) << 8usize) & (256u64 as u16))
+ pub fn new_bitfield_1(
+ header_split: u16,
+ hw_ip_checksum: u16,
+ hw_vlan_filter: u16,
+ hw_vlan_strip: u16,
+ hw_vlan_extend: u16,
+ jumbo_frame: u16,
+ hw_strip_crc: u16,
+ enable_scatter: u16,
+ enable_lro: u16,
+ ) -> u16 {
+ (((((((((0 | ((header_split as u16 as u16) << 0usize) & (1u64 as u16)) |
+ ((hw_ip_checksum as u16 as u16) << 1usize) & (2u64 as u16)) |
+ ((hw_vlan_filter as u16 as u16) << 2usize) & (4u64 as u16)) |
+ ((hw_vlan_strip as u16 as u16) << 3usize) & (8u64 as u16)) |
+ ((hw_vlan_extend as u16 as u16) << 4usize) & (16u64 as u16)) |
+ ((jumbo_frame as u16 as u16) << 5usize) & (32u64 as u16)) |
+ ((hw_strip_crc as u16 as u16) << 6usize) & (64u64 as u16)) |
+ ((enable_scatter as u16 as u16) << 7usize) & (128u64 as u16)) |
+ ((enable_lro as u16 as u16) << 8usize) & (256u64 as u16))
}
}
#[repr(u32)]
@@ -511,37 +528,57 @@ pub struct rte_eth_txmode {
}
#[test]
fn bindgen_test_layout_rte_eth_txmode() {
- assert_eq!(::std::mem::size_of::<rte_eth_txmode>() , 8usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_txmode ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_txmode>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_txmode>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_eth_txmode))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_txmode>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_txmode {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl rte_eth_txmode {
#[inline]
pub fn hw_vlan_reject_tagged(&self) -> u8 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -553,31 +590,31 @@ impl rte_eth_txmode {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn hw_vlan_reject_untagged(&self) -> u8 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 2u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -589,31 +626,31 @@ impl rte_eth_txmode {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn hw_vlan_insert_pvid(&self) -> u8 {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 4u64 as u8;
let val = (unit_field_val & mask) >> 2usize;
@@ -625,35 +662,31 @@ impl rte_eth_txmode {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(hw_vlan_reject_tagged: u8,
- hw_vlan_reject_untagged: u8,
- hw_vlan_insert_pvid: u8) -> u8 {
- ({
- ({
- ({ 0 } |
- ((hw_vlan_reject_tagged as u8 as u8) << 0usize) &
- (1u64 as u8))
- } |
- ((hw_vlan_reject_untagged as u8 as u8) << 1usize) &
- (2u64 as u8))
- } | ((hw_vlan_insert_pvid as u8 as u8) << 2usize) & (4u64 as u8))
+ pub fn new_bitfield_1(
+ hw_vlan_reject_tagged: u8,
+ hw_vlan_reject_untagged: u8,
+ hw_vlan_insert_pvid: u8,
+ ) -> u8 {
+ (((0 | ((hw_vlan_reject_tagged as u8 as u8) << 0usize) & (1u64 as u8)) |
+ ((hw_vlan_reject_untagged as u8 as u8) << 1usize) & (2u64 as u8)) |
+ ((hw_vlan_insert_pvid as u8 as u8) << 2usize) & (4u64 as u8))
}
}
/// A structure used to configure the Receive Side Scaling (RSS) feature
@@ -683,37 +716,65 @@ pub struct rte_eth_rss_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_rss_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_rss_conf>() , 24usize , concat !
- ( "Size of: " , stringify ! ( rte_eth_rss_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_rss_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_rss_conf>(),
+ 24usize,
+ concat!("Size of: ", stringify!(rte_eth_rss_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_rss_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_rss_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ 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, }
+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.
@@ -758,75 +819,129 @@ pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_dcb_conf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>() ,
- 16usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf__bindgen_ty_1
- ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>(),
+ 16usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_dcb_conf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_dcb_conf__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_dcb_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_dcb_conf>() , 1040usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_dcb_conf )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_dcb_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_dcb_conf>(),
+ 1040usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_dcb_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_dcb_conf>(),
+ 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 Clone for rte_eth_vmdq_dcb_conf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_dcb_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -838,27 +953,46 @@ pub struct rte_eth_dcb_rx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_dcb_rx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_dcb_rx_conf>() , 12usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_dcb_rx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_dcb_rx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_dcb_rx_conf>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_dcb_rx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_dcb_rx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_dcb_rx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -870,29 +1004,46 @@ pub struct rte_eth_vmdq_dcb_tx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_dcb_tx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_dcb_tx_conf>() , 12usize ,
- concat ! (
- "Size of: " , stringify ! ( rte_eth_vmdq_dcb_tx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_dcb_tx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_dcb_tx_conf>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_dcb_tx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_dcb_tx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_dcb_tx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -904,27 +1055,46 @@ pub struct rte_eth_dcb_tx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_dcb_tx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_dcb_tx_conf>() , 12usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_dcb_tx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_dcb_tx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_dcb_tx_conf>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_dcb_tx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_dcb_tx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_dcb_tx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -934,22 +1104,36 @@ pub struct rte_eth_vmdq_tx_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_tx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_tx_conf>() , 4usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_vmdq_tx_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_tx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_tx_conf>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_tx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_tx_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_tx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -979,80 +1163,139 @@ pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_rx_conf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>() ,
- 16usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf__bindgen_ty_1
- ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>() ,
- 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>(),
+ 16usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_rx_conf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_rx_conf__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_eth_vmdq_rx_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_vmdq_rx_conf>() , 1040usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_vmdq_rx_conf )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_vmdq_rx_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_vmdq_rx_conf>(),
+ 1040usize,
+ concat!("Size of: ", stringify!(rte_eth_vmdq_rx_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_vmdq_rx_conf>(),
+ 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 Clone for rte_eth_vmdq_rx_conf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_vmdq_rx_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(u32)]
/// Flow Director setting modes: none, signature or perfect.
@@ -1098,38 +1341,71 @@ pub struct rte_eth_ipv4_flow {
}
#[test]
fn bindgen_test_layout_rte_eth_ipv4_flow() {
- assert_eq!(::std::mem::size_of::<rte_eth_ipv4_flow>() , 12usize , concat !
- ( "Size of: " , stringify ! ( rte_eth_ipv4_flow ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_ipv4_flow>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_ipv4_flow>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_ipv4_flow))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_ipv4_flow>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// A structure used to define the input for IPV6 flow
#[repr(C)]
@@ -1148,38 +1424,71 @@ pub struct rte_eth_ipv6_flow {
}
#[test]
fn bindgen_test_layout_rte_eth_ipv6_flow() {
- assert_eq!(::std::mem::size_of::<rte_eth_ipv6_flow>() , 36usize , concat !
- ( "Size of: " , stringify ! ( rte_eth_ipv6_flow ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_ipv6_flow>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_ipv6_flow>(),
+ 36usize,
+ concat!("Size of: ", stringify!(rte_eth_ipv6_flow))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_ipv6_flow>(),
+ 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 }
+ 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.
@@ -1207,54 +1516,101 @@ pub struct rte_eth_fdir_masks {
}
#[test]
fn bindgen_test_layout_rte_eth_fdir_masks() {
- assert_eq!(::std::mem::size_of::<rte_eth_fdir_masks>() , 68usize , concat
- ! ( "Size of: " , stringify ! ( rte_eth_fdir_masks ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_fdir_masks>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_fdir_masks>(),
+ 68usize,
+ concat!("Size of: ", stringify!(rte_eth_fdir_masks))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_fdir_masks>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(u32)]
/// Payload type
@@ -1278,29 +1634,46 @@ pub struct rte_eth_flex_payload_cfg {
}
#[test]
fn bindgen_test_layout_rte_eth_flex_payload_cfg() {
- assert_eq!(::std::mem::size_of::<rte_eth_flex_payload_cfg>() , 36usize ,
- concat ! (
- "Size of: " , stringify ! ( rte_eth_flex_payload_cfg ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_flex_payload_cfg>() , 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 )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_flex_payload_cfg>(),
+ 36usize,
+ concat!("Size of: ", stringify!(rte_eth_flex_payload_cfg))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_flex_payload_cfg>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_flex_payload_cfg {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// A structure used to define FDIR masks for flexible payload
/// for each flow type
@@ -1312,25 +1685,41 @@ pub struct rte_eth_fdir_flex_mask {
}
#[test]
fn bindgen_test_layout_rte_eth_fdir_flex_mask() {
- assert_eq!(::std::mem::size_of::<rte_eth_fdir_flex_mask>() , 18usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_mask )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_fdir_flex_mask>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_fdir_flex_mask>(),
+ 18usize,
+ concat!("Size of: ", stringify!(rte_eth_fdir_flex_mask))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_fdir_flex_mask>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// A structure used to define all flexible payload related setting
/// include flex payload and flex mask
@@ -1346,38 +1735,66 @@ pub struct rte_eth_fdir_flex_conf {
}
#[test]
fn bindgen_test_layout_rte_eth_fdir_flex_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_fdir_flex_conf>() , 688usize ,
- concat ! ( "Size of: " , stringify ! ( rte_eth_fdir_flex_conf )
- ));
- assert_eq! (::std::mem::align_of::<rte_eth_fdir_flex_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_fdir_flex_conf>(),
+ 688usize,
+ concat!("Size of: ", stringify!(rte_eth_fdir_flex_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_fdir_flex_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_fdir_flex_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// A structure used to configure the Flow Director (FDIR) feature
/// of an Ethernet port.
@@ -1399,46 +1816,86 @@ pub struct rte_fdir_conf {
}
#[test]
fn bindgen_test_layout_rte_fdir_conf() {
- assert_eq!(::std::mem::size_of::<rte_fdir_conf>() , 772usize , concat ! (
- "Size of: " , stringify ! ( rte_fdir_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_fdir_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_fdir_conf>(),
+ 772usize,
+ concat!("Size of: ", stringify!(rte_fdir_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_fdir_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_fdir_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// A structure used to enable/disable specific device interrupts.
#[repr(C)]
@@ -1451,23 +1908,41 @@ pub struct rte_intr_conf {
}
#[test]
fn bindgen_test_layout_rte_intr_conf() {
- assert_eq!(::std::mem::size_of::<rte_intr_conf>() , 4usize , concat ! (
- "Size of: " , stringify ! ( rte_intr_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_intr_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_intr_conf>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_intr_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_intr_conf>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// A structure used to configure an Ethernet port.
/// Depending upon the RX multi-queue mode, extra advanced
@@ -1516,43 +1991,66 @@ pub struct rte_eth_conf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_eth_conf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_eth_conf__bindgen_ty_1>() , 2120usize
- , concat ! (
- "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_conf__bindgen_ty_1>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_conf__bindgen_ty_1>(),
+ 2120usize,
+ concat!("Size of: ", stringify!(rte_eth_conf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_conf__bindgen_ty_1>(),
+ 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 Clone for rte_eth_conf__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_conf__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -1564,90 +2062,164 @@ pub struct rte_eth_conf__bindgen_ty_2 {
}
#[test]
fn bindgen_test_layout_rte_eth_conf__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<rte_eth_conf__bindgen_ty_2>() , 12usize ,
- concat ! (
- "Size of: " , stringify ! ( rte_eth_conf__bindgen_ty_2 ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_conf__bindgen_ty_2>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_conf__bindgen_ty_2>(),
+ 12usize,
+ concat!("Size of: ", stringify!(rte_eth_conf__bindgen_ty_2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_conf__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_eth_conf() {
- assert_eq!(::std::mem::size_of::<rte_eth_conf>() , 2944usize , concat ! (
- "Size of: " , stringify ! ( rte_eth_conf ) ));
- assert_eq! (::std::mem::align_of::<rte_eth_conf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_eth_conf>(),
+ 2944usize,
+ concat!("Size of: ", stringify!(rte_eth_conf))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_eth_conf>(),
+ 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 Clone for rte_eth_conf {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_eth_conf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs
index 63cd92bb..a671db6c 100644
--- a/tests/expectations/tests/layout_mbuf.rs
+++ b/tests/expectations/tests/layout_mbuf.rs
@@ -19,18 +19,31 @@ pub struct rte_atomic16_t {
}
#[test]
fn bindgen_test_layout_rte_atomic16_t() {
- assert_eq!(::std::mem::size_of::<rte_atomic16_t>() , 2usize , concat ! (
- "Size of: " , stringify ! ( rte_atomic16_t ) ));
- assert_eq! (::std::mem::align_of::<rte_atomic16_t>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_atomic16_t>(),
+ 2usize,
+ concat!("Size of: ", stringify!(rte_atomic16_t))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_atomic16_t>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// The generic rte_mbuf, containing a packet mbuf.
#[repr(C)]
@@ -96,28 +109,46 @@ pub union rte_mbuf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_1>() , 2usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_1 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_1>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_1>(),
+ 2usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -135,28 +166,38 @@ pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>() ,
- 4usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>()
- , 4usize , concat ! (
- "Alignment of " , stringify ! (
- rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>(),
+ 4usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_2__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
#[inline]
pub fn l2_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -168,31 +209,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn l3_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 240u64 as u32;
let val = (unit_field_val & mask) >> 4usize;
@@ -204,31 +245,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 4usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn l4_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 3840u64 as u32;
let val = (unit_field_val & mask) >> 8usize;
@@ -240,31 +281,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn tun_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 61440u64 as u32;
let val = (unit_field_val & mask) >> 12usize;
@@ -276,31 +317,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 12usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn inner_l2_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 983040u64 as u32;
let val = (unit_field_val & mask) >> 16usize;
@@ -312,31 +353,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn inner_l3_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15728640u64 as u32;
let val = (unit_field_val & mask) >> 20usize;
@@ -348,31 +389,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 20usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn inner_l4_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 251658240u64 as u32;
let val = (unit_field_val & mask) >> 24usize;
@@ -384,74 +425,73 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(l2_type: u32, l3_type: u32, l4_type: u32,
- tun_type: u32, inner_l2_type: u32,
- inner_l3_type: u32, inner_l4_type: u32) -> u32 {
- ({
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((l2_type as u32 as u32) << 0usize)
- & (15u64 as u32))
- } |
- ((l3_type as u32 as u32) << 4usize) &
- (240u64 as u32))
- } |
- ((l4_type as u32 as u32) << 8usize) &
- (3840u64 as u32))
- } |
- ((tun_type as u32 as u32) << 12usize) &
- (61440u64 as u32))
- } |
- ((inner_l2_type as u32 as u32) << 16usize) &
- (983040u64 as u32))
- } |
- ((inner_l3_type as u32 as u32) << 20usize) &
- (15728640u64 as u32))
- } |
- ((inner_l4_type as u32 as u32) << 24usize) &
- (251658240u64 as u32))
+ pub fn new_bitfield_1(
+ l2_type: u32,
+ l3_type: u32,
+ l4_type: u32,
+ tun_type: u32,
+ inner_l2_type: u32,
+ inner_l3_type: u32,
+ inner_l4_type: u32,
+ ) -> u32 {
+ (((((((0 | ((l2_type as u32 as u32) << 0usize) & (15u64 as u32)) |
+ ((l3_type as u32 as u32) << 4usize) & (240u64 as u32)) |
+ ((l4_type as u32 as u32) << 8usize) & (3840u64 as u32)) |
+ ((tun_type as u32 as u32) << 12usize) & (61440u64 as u32)) |
+ ((inner_l2_type as u32 as u32) << 16usize) & (983040u64 as u32)) |
+ ((inner_l3_type as u32 as u32) << 20usize) & (15728640u64 as u32)) |
+ ((inner_l4_type as u32 as u32) << 24usize) & (251658240u64 as u32))
}
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_2>() , 4usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_2 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_2>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_2>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_2 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -487,87 +527,134 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 {
}
#[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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>()
- , 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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(),
+ 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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(),
+ 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 }
+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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>()
- , 4usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>(),
+ 4usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>() ,
- 8usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>(),
+ 8usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_3__bindgen_ty_1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -577,64 +664,110 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>() ,
- 8usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>(),
+ 8usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_2)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_3>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_3 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_3))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_3 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -647,28 +780,46 @@ pub union rte_mbuf__bindgen_ty_4 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_4>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_4 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_4>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_4>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_4))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_4>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_4 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Copy)]
@@ -686,28 +837,38 @@ pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>() ,
- 8usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>()
- , 8usize , concat ! (
- "Alignment of " , stringify ! (
- rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>(),
+ 8usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_5__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
#[inline]
pub fn l2_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 127u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -719,31 +880,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn l3_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 65408u64 as u64;
let val = (unit_field_val & mask) >> 7usize;
@@ -755,31 +916,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn l4_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 16711680u64 as u64;
let val = (unit_field_val & mask) >> 16usize;
@@ -791,31 +952,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn tso_segsz(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 1099494850560u64 as u64;
let val = (unit_field_val & mask) >> 24usize;
@@ -827,31 +988,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn outer_l3_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 561850441793536u64 as u64;
let val = (unit_field_val & mask) >> 40usize;
@@ -863,31 +1024,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 40usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn outer_l2_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 71494644084506624u64 as u64;
let val = (unit_field_val & mask) >> 49usize;
@@ -899,183 +1060,294 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 49usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(l2_len: u64, l3_len: u64, l4_len: u64,
- tso_segsz: u64, outer_l3_len: u64,
- outer_l2_len: u64) -> u64 {
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((l2_len as u64 as u64) << 0usize) &
- (127u64 as u64))
- } |
- ((l3_len as u64 as u64) << 7usize) &
- (65408u64 as u64))
- } |
- ((l4_len as u64 as u64) << 16usize) &
- (16711680u64 as u64))
- } |
- ((tso_segsz as u64 as u64) << 24usize) &
- (1099494850560u64 as u64))
- } |
- ((outer_l3_len as u64 as u64) << 40usize) &
- (561850441793536u64 as u64))
- } |
- ((outer_l2_len as u64 as u64) << 49usize) &
- (71494644084506624u64 as u64))
+ pub fn new_bitfield_1(
+ l2_len: u64,
+ l3_len: u64,
+ l4_len: u64,
+ tso_segsz: u64,
+ outer_l3_len: u64,
+ outer_l2_len: u64,
+ ) -> u64 {
+ ((((((0 | ((l2_len as u64 as u64) << 0usize) & (127u64 as u64)) |
+ ((l3_len as u64 as u64) << 7usize) & (65408u64 as u64)) |
+ ((l4_len as u64 as u64) << 16usize) & (16711680u64 as u64)) |
+ ((tso_segsz as u64 as u64) << 24usize) & (1099494850560u64 as u64)) |
+ ((outer_l3_len as u64 as u64) << 40usize) & (561850441793536u64 as u64)) |
+ ((outer_l2_len as u64 as u64) << 49usize) & (71494644084506624u64 as u64))
}
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_5>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_5 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_5>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_5>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_5))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_5>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for rte_mbuf__bindgen_ty_5 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn bindgen_test_layout_rte_mbuf() {
- assert_eq!(::std::mem::size_of::<rte_mbuf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf>(),
+ 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 Default for rte_mbuf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// < Pool from which mbuf was allocated.
#[repr(C)]
@@ -1084,5 +1356,7 @@ pub struct rte_mempool {
pub _address: u8,
}
impl Clone for rte_mempool {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs
index b9c6e69b..fe947a3a 100644
--- a/tests/expectations/tests/layout_mbuf_1_0.rs
+++ b/tests/expectations/tests/layout_mbuf_1_0.rs
@@ -6,33 +6,45 @@
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
-impl <T> __BindgenUnionField<T> {
+impl<T> __BindgenUnionField<T> {
#[inline]
- pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
#[inline]
- pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ 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 unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
}
-impl <T> ::std::default::Default for __BindgenUnionField<T> {
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
#[inline]
- fn default() -> Self { Self::new() }
+ fn default() -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
-impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
-impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
- fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
}
-impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
- fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
+impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
}
impl <T> ::std::cmp::Eq for __BindgenUnionField<T> { }
pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64;
@@ -50,18 +62,31 @@ pub struct rte_atomic16_t {
}
#[test]
fn bindgen_test_layout_rte_atomic16_t() {
- assert_eq!(::std::mem::size_of::<rte_atomic16_t>() , 2usize , concat ! (
- "Size of: " , stringify ! ( rte_atomic16_t ) ));
- assert_eq! (::std::mem::align_of::<rte_atomic16_t>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_atomic16_t>(),
+ 2usize,
+ concat!("Size of: ", stringify!(rte_atomic16_t))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_atomic16_t>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// The generic rte_mbuf, containing a packet mbuf.
#[repr(C)]
@@ -127,25 +152,41 @@ pub struct rte_mbuf__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_1>() , 2usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_1 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_1>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_1>(),
+ 2usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -163,28 +204,38 @@ pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_2__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>() ,
- 4usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>()
- , 4usize , concat ! (
- "Alignment of " , stringify ! (
- rte_mbuf__bindgen_ty_2__bindgen_ty_1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>(),
+ 4usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_2__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_2__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
#[inline]
pub fn l2_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -196,31 +247,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn l3_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 240u64 as u32;
let val = (unit_field_val & mask) >> 4usize;
@@ -232,31 +283,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 4usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn l4_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 3840u64 as u32;
let val = (unit_field_val & mask) >> 8usize;
@@ -268,31 +319,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn tun_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 61440u64 as u32;
let val = (unit_field_val & mask) >> 12usize;
@@ -304,31 +355,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 12usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn inner_l2_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 983040u64 as u32;
let val = (unit_field_val & mask) >> 16usize;
@@ -340,31 +391,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn inner_l3_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 15728640u64 as u32;
let val = (unit_field_val & mask) >> 20usize;
@@ -376,31 +427,31 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 20usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn inner_l4_type(&self) -> u32 {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 251658240u64 as u32;
let val = (unit_field_val & mask) >> 24usize;
@@ -412,71 +463,68 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(l2_type: u32, l3_type: u32, l4_type: u32,
- tun_type: u32, inner_l2_type: u32,
- inner_l3_type: u32, inner_l4_type: u32) -> u32 {
- ({
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((l2_type as u32 as u32) << 0usize)
- & (15u64 as u32))
- } |
- ((l3_type as u32 as u32) << 4usize) &
- (240u64 as u32))
- } |
- ((l4_type as u32 as u32) << 8usize) &
- (3840u64 as u32))
- } |
- ((tun_type as u32 as u32) << 12usize) &
- (61440u64 as u32))
- } |
- ((inner_l2_type as u32 as u32) << 16usize) &
- (983040u64 as u32))
- } |
- ((inner_l3_type as u32 as u32) << 20usize) &
- (15728640u64 as u32))
- } |
- ((inner_l4_type as u32 as u32) << 24usize) &
- (251658240u64 as u32))
+ pub fn new_bitfield_1(
+ l2_type: u32,
+ l3_type: u32,
+ l4_type: u32,
+ tun_type: u32,
+ inner_l2_type: u32,
+ inner_l3_type: u32,
+ inner_l4_type: u32,
+ ) -> u32 {
+ (((((((0 | ((l2_type as u32 as u32) << 0usize) & (15u64 as u32)) |
+ ((l3_type as u32 as u32) << 4usize) & (240u64 as u32)) |
+ ((l4_type as u32 as u32) << 8usize) & (3840u64 as u32)) |
+ ((tun_type as u32 as u32) << 12usize) & (61440u64 as u32)) |
+ ((inner_l2_type as u32 as u32) << 16usize) & (983040u64 as u32)) |
+ ((inner_l3_type as u32 as u32) << 20usize) & (15728640u64 as u32)) |
+ ((inner_l4_type as u32 as u32) << 24usize) & (251658240u64 as u32))
}
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_2>() , 4usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_2 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_2>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_2>(),
+ 4usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_2))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -500,7 +548,8 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 {
- pub __bindgen_anon_1: __BindgenUnionField<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>,
+ pub __bindgen_anon_1:
+ __BindgenUnionField<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>,
pub lo: __BindgenUnionField<u32>,
pub bindgen_union_field: u32,
}
@@ -512,81 +561,124 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 {
}
#[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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>()
- , 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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(),
+ 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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(),
+ 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 }
+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::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>()
- , 4usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>(),
+ 4usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>() ,
- 8usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_3__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>(),
+ 8usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -596,61 +688,105 @@ pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_2() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>() ,
- 8usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_3__bindgen_ty_2 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>()
- , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>(),
+ 8usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_3__bindgen_ty_2)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3__bindgen_ty_2>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_3() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_3>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_3 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_3>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_3>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_3))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_3>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -663,25 +799,41 @@ pub struct rte_mbuf__bindgen_ty_4 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_4() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_4>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_4 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_4>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_4>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_4))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_4>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -699,28 +851,38 @@ pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_5__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>() ,
- 8usize , concat ! (
- "Size of: " , stringify ! (
- rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>()
- , 8usize , concat ! (
- "Alignment of " , stringify ! (
- rte_mbuf__bindgen_ty_5__bindgen_ty_1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>(),
+ 8usize,
+ concat!(
+ "Size of: ",
+ stringify!(rte_mbuf__bindgen_ty_5__bindgen_ty_1)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_5__bindgen_ty_1>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
#[inline]
pub fn l2_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 127u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -732,31 +894,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn l3_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 65408u64 as u64;
let val = (unit_field_val & mask) >> 7usize;
@@ -768,31 +930,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn l4_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 16711680u64 as u64;
let val = (unit_field_val & mask) >> 16usize;
@@ -804,31 +966,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn tso_segsz(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 1099494850560u64 as u64;
let val = (unit_field_val & mask) >> 24usize;
@@ -840,31 +1002,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 24usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn outer_l3_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 561850441793536u64 as u64;
let val = (unit_field_val & mask) >> 40usize;
@@ -876,31 +1038,31 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 40usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn outer_l2_len(&self) -> u64 {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 71494644084506624u64 as u64;
let val = (unit_field_val & mask) >> 49usize;
@@ -912,180 +1074,289 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
let val = val as u64 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 49usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(l2_len: u64, l3_len: u64, l4_len: u64,
- tso_segsz: u64, outer_l3_len: u64,
- outer_l2_len: u64) -> u64 {
- ({
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((l2_len as u64 as u64) << 0usize) &
- (127u64 as u64))
- } |
- ((l3_len as u64 as u64) << 7usize) &
- (65408u64 as u64))
- } |
- ((l4_len as u64 as u64) << 16usize) &
- (16711680u64 as u64))
- } |
- ((tso_segsz as u64 as u64) << 24usize) &
- (1099494850560u64 as u64))
- } |
- ((outer_l3_len as u64 as u64) << 40usize) &
- (561850441793536u64 as u64))
- } |
- ((outer_l2_len as u64 as u64) << 49usize) &
- (71494644084506624u64 as u64))
+ pub fn new_bitfield_1(
+ l2_len: u64,
+ l3_len: u64,
+ l4_len: u64,
+ tso_segsz: u64,
+ outer_l3_len: u64,
+ outer_l2_len: u64,
+ ) -> u64 {
+ ((((((0 | ((l2_len as u64 as u64) << 0usize) & (127u64 as u64)) |
+ ((l3_len as u64 as u64) << 7usize) & (65408u64 as u64)) |
+ ((l4_len as u64 as u64) << 16usize) & (16711680u64 as u64)) |
+ ((tso_segsz as u64 as u64) << 24usize) & (1099494850560u64 as u64)) |
+ ((outer_l3_len as u64 as u64) << 40usize) & (561850441793536u64 as u64)) |
+ ((outer_l2_len as u64 as u64) << 49usize) & (71494644084506624u64 as u64))
}
}
#[test]
fn bindgen_test_layout_rte_mbuf__bindgen_ty_5() {
- assert_eq!(::std::mem::size_of::<rte_mbuf__bindgen_ty_5>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( rte_mbuf__bindgen_ty_5 )
- ));
- assert_eq! (::std::mem::align_of::<rte_mbuf__bindgen_ty_5>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf__bindgen_ty_5>(),
+ 8usize,
+ concat!("Size of: ", stringify!(rte_mbuf__bindgen_ty_5))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<rte_mbuf__bindgen_ty_5>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn bindgen_test_layout_rte_mbuf() {
- assert_eq!(::std::mem::size_of::<rte_mbuf>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<rte_mbuf>(),
+ 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 Default for rte_mbuf {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// < Pool from which mbuf was allocated.
#[repr(C)]
@@ -1094,5 +1365,7 @@ pub struct rte_mempool {
pub _address: u8,
}
impl Clone for rte_mempool {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/libclang-3.8/auto.rs b/tests/expectations/tests/libclang-3.8/auto.rs
index cf7320f5..6e2d9af3 100644
--- a/tests/expectations/tests/libclang-3.8/auto.rs
+++ b/tests/expectations/tests/libclang-3.8/auto.rs
@@ -11,17 +11,25 @@ pub struct Foo {
}
extern "C" {
#[link_name = "_ZN3Foo4kFooE"]
- pub static Foo_kFoo: bool;
+ pub static mut Foo_kFoo: bool;
}
#[test]
fn bindgen_test_layout_Foo() {
- assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Foo ) ));
- assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Foo))
+ );
}
impl Clone for Foo {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
diff --git a/tests/expectations/tests/libclang-3.8/call-conv-field.rs b/tests/expectations/tests/libclang-3.8/call-conv-field.rs
index 31fb309c..c5769c4c 100644
--- a/tests/expectations/tests/libclang-3.8/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-3.8/call-conv-field.rs
@@ -7,34 +7,54 @@
#[repr(C)]
#[derive(Copy)]
pub struct JNINativeInterface_ {
- pub GetVersion: ::std::option::Option<unsafe extern "stdcall" fn(env:
- *mut ::std::os::raw::c_void)
- -> ::std::os::raw::c_int>,
+ pub GetVersion: ::std::option::Option<
+ unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void)
+ -> ::std::os::raw::c_int,
+ >,
pub __hack: ::std::os::raw::c_ulonglong,
}
#[test]
fn bindgen_test_layout_JNINativeInterface_() {
- assert_eq!(::std::mem::size_of::<JNINativeInterface_>() , 16usize , concat
- ! ( "Size of: " , stringify ! ( JNINativeInterface_ ) ));
- assert_eq! (::std::mem::align_of::<JNINativeInterface_>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<JNINativeInterface_>(),
+ 16usize,
+ concat!("Size of: ", stringify!(JNINativeInterface_))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<JNINativeInterface_>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for JNINativeInterface_ {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
extern "C" {
#[link_name = "_bar@0"]
diff --git a/tests/expectations/tests/libclang-3.8/const_bool.rs b/tests/expectations/tests/libclang-3.8/const_bool.rs
index cc150436..ad6a60d8 100644
--- a/tests/expectations/tests/libclang-3.8/const_bool.rs
+++ b/tests/expectations/tests/libclang-3.8/const_bool.rs
@@ -6,7 +6,7 @@
extern "C" {
#[link_name = "_ZL1k"]
- pub static k: bool;
+ pub static mut k: bool;
}
#[repr(C)]
#[derive(Debug, Default, Copy)]
@@ -15,20 +15,28 @@ pub struct A {
}
extern "C" {
#[link_name = "_ZN1A1kE"]
- pub static A_k: bool;
+ pub static mut A_k: bool;
}
#[test]
fn bindgen_test_layout_A() {
- assert_eq!(::std::mem::size_of::<A>() , 1usize , concat ! (
- "Size of: " , stringify ! ( A ) ));
- assert_eq! (::std::mem::align_of::<A>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( A ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A>(),
+ 1usize,
+ concat!("Size of: ", stringify!(A))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(A))
+ );
}
impl Clone for A {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
pub type foo = bool;
extern "C" {
#[link_name = "_ZL2k2"]
- pub static k2: foo;
+ pub static mut k2: foo;
}
diff --git a/tests/expectations/tests/libclang-3.8/constant-evaluate.rs b/tests/expectations/tests/libclang-3.8/constant-evaluate.rs
index 9089b442..4f9e62da 100644
--- a/tests/expectations/tests/libclang-3.8/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-3.8/constant-evaluate.rs
@@ -13,23 +13,23 @@ pub type EasyToOverflow = ::std::os::raw::c_ulonglong;
pub const k: EasyToOverflow = 2147483648;
extern "C" {
#[link_name = "k_expr"]
- pub static k_expr: EasyToOverflow;
+ pub static mut k_expr: EasyToOverflow;
}
extern "C" {
#[link_name = "BAZ"]
- pub static BAZ: ::std::os::raw::c_longlong;
+ pub static mut BAZ: ::std::os::raw::c_longlong;
}
extern "C" {
#[link_name = "fuzz"]
- pub static fuzz: f64;
+ pub static mut fuzz: f64;
}
extern "C" {
#[link_name = "BAZZ"]
- pub static BAZZ: ::std::os::raw::c_char;
+ pub static mut BAZZ: ::std::os::raw::c_char;
}
extern "C" {
#[link_name = "WAT"]
- pub static WAT: ::std::os::raw::c_char;
+ pub static mut WAT: ::std::os::raw::c_char;
}
extern "C" {
#[link_name = "bytestring"]
diff --git a/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs b/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs
index 376b43cb..0603873d 100644
--- a/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs
+++ b/tests/expectations/tests/libclang-3.8/issue-769-bad-instantiation-test.rs
@@ -14,29 +14,26 @@ pub mod root {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
- impl <T> Default for Rooted<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ impl<T> Default for Rooted<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation_1() {
- assert_eq!(::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
}
}
diff --git a/tests/expectations/tests/libclang-3.8/objc_template.rs b/tests/expectations/tests/libclang-3.8/objc_template.rs
index 16efa59e..c5d16ae1 100644
--- a/tests/expectations/tests/libclang-3.8/objc_template.rs
+++ b/tests/expectations/tests/libclang-3.8/objc_template.rs
@@ -2,17 +2,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
pub trait Foo {
- unsafe fn get(self)
- -> id;
+ unsafe fn get(self) -> id;
}
impl Foo for id {
- unsafe fn get(self) -> id { msg_send!(self , get) }
+ unsafe fn get(self) -> id {
+ msg_send!(self, get)
+ }
}
diff --git a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs
index 159cad11..d867e73a 100644
--- a/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs
+++ b/tests/expectations/tests/libclang-3.8/partial-specialization-and-inheritance.rs
@@ -25,17 +25,25 @@ extern "C" {
}
#[test]
fn bindgen_test_layout_Usage() {
- assert_eq!(::std::mem::size_of::<Usage>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Usage ) ));
- assert_eq! (::std::mem::align_of::<Usage>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Usage ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Usage>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Usage))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Usage>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Usage))
+ );
}
extern "C" {
#[link_name = "_ZN5UsageC1Ev"]
pub fn Usage_Usage(this: *mut Usage);
}
impl Clone for Usage {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Usage {
#[inline]
diff --git a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs
index 7728ddeb..590f491a 100644
--- a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs
+++ b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs
@@ -11,18 +11,31 @@ pub struct Rooted {
}
#[test]
fn bindgen_test_layout_Rooted() {
- assert_eq!(::std::mem::size_of::<Rooted>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Rooted ) ));
- assert_eq! (::std::mem::align_of::<Rooted>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Rooted>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Rooted))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Rooted>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// <div rustbindgen replaces="MaybeWrapped"></div>
pub type MaybeWrapped<a> = a;
diff --git a/tests/expectations/tests/libclang-3.9/auto.rs b/tests/expectations/tests/libclang-3.9/auto.rs
index 70743067..4f5ee5b6 100644
--- a/tests/expectations/tests/libclang-3.9/auto.rs
+++ b/tests/expectations/tests/libclang-3.9/auto.rs
@@ -12,13 +12,21 @@ pub struct Foo {
pub const Foo_kFoo: bool = true;
#[test]
fn bindgen_test_layout_Foo() {
- assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Foo ) ));
- assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Foo))
+ );
}
impl Clone for Foo {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
diff --git a/tests/expectations/tests/libclang-3.9/call-conv-field.rs b/tests/expectations/tests/libclang-3.9/call-conv-field.rs
index 39943119..ea794b68 100644
--- a/tests/expectations/tests/libclang-3.9/call-conv-field.rs
+++ b/tests/expectations/tests/libclang-3.9/call-conv-field.rs
@@ -7,34 +7,54 @@
#[repr(C)]
#[derive(Copy)]
pub struct JNINativeInterface_ {
- pub GetVersion: ::std::option::Option<unsafe extern "stdcall" fn(env:
- *mut ::std::os::raw::c_void)
- -> ::std::os::raw::c_int>,
+ pub GetVersion: ::std::option::Option<
+ unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void)
+ -> ::std::os::raw::c_int,
+ >,
pub __hack: ::std::os::raw::c_ulonglong,
}
#[test]
fn bindgen_test_layout_JNINativeInterface_() {
- assert_eq!(::std::mem::size_of::<JNINativeInterface_>() , 16usize , concat
- ! ( "Size of: " , stringify ! ( JNINativeInterface_ ) ));
- assert_eq! (::std::mem::align_of::<JNINativeInterface_>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<JNINativeInterface_>(),
+ 16usize,
+ concat!("Size of: ", stringify!(JNINativeInterface_))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<JNINativeInterface_>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for JNINativeInterface_ {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
extern "stdcall" {
#[link_name = "_bar@0"]
diff --git a/tests/expectations/tests/libclang-3.9/const_bool.rs b/tests/expectations/tests/libclang-3.9/const_bool.rs
index fd0273aa..7106e0ab 100644
--- a/tests/expectations/tests/libclang-3.9/const_bool.rs
+++ b/tests/expectations/tests/libclang-3.9/const_bool.rs
@@ -13,13 +13,21 @@ pub struct A {
pub const A_k: bool = false;
#[test]
fn bindgen_test_layout_A() {
- assert_eq!(::std::mem::size_of::<A>() , 1usize , concat ! (
- "Size of: " , stringify ! ( A ) ));
- assert_eq! (::std::mem::align_of::<A>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( A ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A>(),
+ 1usize,
+ concat!("Size of: ", stringify!(A))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(A))
+ );
}
impl Clone for A {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
pub type foo = bool;
pub const k2: foo = true;
diff --git a/tests/expectations/tests/libclang-3.9/constant-evaluate.rs b/tests/expectations/tests/libclang-3.9/constant-evaluate.rs
index ffa3fff8..096bc182 100644
--- a/tests/expectations/tests/libclang-3.9/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-3.9/constant-evaluate.rs
@@ -8,7 +8,10 @@ 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 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;
@@ -16,5 +19,5 @@ 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];
+pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
+pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];
diff --git a/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs b/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs
index 376b43cb..0603873d 100644
--- a/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs
+++ b/tests/expectations/tests/libclang-3.9/issue-769-bad-instantiation-test.rs
@@ -14,29 +14,26 @@ pub mod root {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
- impl <T> Default for Rooted<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ impl<T> Default for Rooted<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation_1() {
- assert_eq!(::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
}
}
diff --git a/tests/expectations/tests/libclang-3.9/objc_template.rs b/tests/expectations/tests/libclang-3.9/objc_template.rs
index 16efa59e..c5d16ae1 100644
--- a/tests/expectations/tests/libclang-3.9/objc_template.rs
+++ b/tests/expectations/tests/libclang-3.9/objc_template.rs
@@ -2,17 +2,17 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
pub trait Foo {
- unsafe fn get(self)
- -> id;
+ unsafe fn get(self) -> id;
}
impl Foo for id {
- unsafe fn get(self) -> id { msg_send!(self , get) }
+ unsafe fn get(self) -> id {
+ msg_send!(self, get)
+ }
}
diff --git a/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs b/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs
index 4f6794e9..84319c75 100644
--- a/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs
+++ b/tests/expectations/tests/libclang-3.9/partial-specialization-and-inheritance.rs
@@ -25,11 +25,19 @@ extern "C" {
}
#[test]
fn bindgen_test_layout_Usage() {
- assert_eq!(::std::mem::size_of::<Usage>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Usage ) ));
- assert_eq! (::std::mem::align_of::<Usage>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Usage ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Usage>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Usage))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Usage>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Usage))
+ );
}
impl Clone for Usage {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs
index 7728ddeb..590f491a 100644
--- a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs
+++ b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs
@@ -11,18 +11,31 @@ pub struct Rooted {
}
#[test]
fn bindgen_test_layout_Rooted() {
- assert_eq!(::std::mem::size_of::<Rooted>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Rooted ) ));
- assert_eq! (::std::mem::align_of::<Rooted>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Rooted>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Rooted))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Rooted>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// <div rustbindgen replaces="MaybeWrapped"></div>
pub type MaybeWrapped<a> = a;
diff --git a/tests/expectations/tests/libclang-4/constant-evaluate.rs b/tests/expectations/tests/libclang-4/constant-evaluate.rs
index ffa3fff8..096bc182 100644
--- a/tests/expectations/tests/libclang-4/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-4/constant-evaluate.rs
@@ -8,7 +8,10 @@ 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 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;
@@ -16,5 +19,5 @@ 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];
+pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
+pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];
diff --git a/tests/expectations/tests/libclang-4/issue-769-bad-instantiation-test.rs b/tests/expectations/tests/libclang-4/issue-769-bad-instantiation-test.rs
index 392f7a0a..86fad78d 100644
--- a/tests/expectations/tests/libclang-4/issue-769-bad-instantiation-test.rs
+++ b/tests/expectations/tests/libclang-4/issue-769-bad-instantiation-test.rs
@@ -14,30 +14,27 @@ pub mod root {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
- impl <T> Default for Rooted<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ impl<T> Default for Rooted<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
pub type AutoValueVector_Alias = ::std::os::raw::c_int;
#[test]
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<root::Rooted<::std::os::raw::c_int>>()
- , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::Rooted<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_Rooted_open0_AutoValueVector_Alias_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<root::Rooted<root::AutoValueVector_Alias>>()
- , 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::Rooted<root::AutoValueVector_Alias> ) ));
- assert_eq!(::std::mem::align_of::<root::Rooted<root::AutoValueVector_Alias>>()
- , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::Rooted<root::AutoValueVector_Alias> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < root :: Rooted < root :: AutoValueVector_Alias > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: Rooted < root :: AutoValueVector_Alias > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < root :: AutoValueVector_Alias > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < root :: AutoValueVector_Alias > ) ) );
}
}
diff --git a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs
index 66331e28..b8d4fbec 100644
--- a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs
+++ b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs
@@ -11,32 +11,48 @@ pub struct Rooted {
}
#[test]
fn bindgen_test_layout_Rooted() {
- assert_eq!(::std::mem::size_of::<Rooted>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Rooted ) ));
- assert_eq! (::std::mem::align_of::<Rooted>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Rooted>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Rooted))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Rooted>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for Rooted {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// <div rustbindgen replaces="MaybeWrapped"></div>
pub type MaybeWrapped<a> = a;
#[test]
fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<MaybeWrapped<::std::os::raw::c_int>>() ,
- 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- MaybeWrapped<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<MaybeWrapped<::std::os::raw::c_int>>() ,
- 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- MaybeWrapped<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<MaybeWrapped<::std::os::raw::c_int>>(),
+ 4usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( MaybeWrapped < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < MaybeWrapped < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( MaybeWrapped < :: std :: os :: raw :: c_int > ) ) );
}
diff --git a/tests/expectations/tests/macro_const.rs b/tests/expectations/tests/macro_const.rs
index b7b7cc2c..382af9a5 100644
--- a/tests/expectations/tests/macro_const.rs
+++ b/tests/expectations/tests/macro_const.rs
@@ -4,9 +4,9 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-pub const foo: &'static [u8; 4usize] = b"bar\x00";
-pub const CHAR: u8 = b'b';
-pub const CHARR: u8 = b'\x00';
+pub const foo: &'static [u8; 4usize] = b"bar\0";
+pub const CHAR: u8 = 98u8;
+pub const CHARR: u8 = 0u8;
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 const INVALID_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];
diff --git a/tests/expectations/tests/mangling-win32.rs b/tests/expectations/tests/mangling-win32.rs
index ffaf52cf..747ccbf5 100644
--- a/tests/expectations/tests/mangling-win32.rs
+++ b/tests/expectations/tests/mangling-win32.rs
@@ -18,11 +18,19 @@ extern "C" {
}
#[test]
fn bindgen_test_layout_Foo() {
- assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Foo ) ));
- assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Foo))
+ );
}
impl Clone for Foo {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/namespace.rs b/tests/expectations/tests/namespace.rs
index 1e954298..dec8fabb 100644
--- a/tests/expectations/tests/namespace.rs
+++ b/tests/expectations/tests/namespace.rs
@@ -9,7 +9,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::root;
extern "C" {
- #[link_name = "_Z9top_levelv"]
+ #[link_name = "_Z9top_levelv"]
pub fn top_level();
}
pub mod whatever {
@@ -17,7 +17,7 @@ pub mod root {
use self::super::super::root;
pub type whatever_int_t = ::std::os::raw::c_int;
extern "C" {
- #[link_name = "_ZN8whatever11in_whateverEv"]
+ #[link_name = "_ZN8whatever11in_whateverEv"]
pub fn in_whatever();
}
}
@@ -25,7 +25,7 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::root;
extern "C" {
- #[link_name = "_ZN12_GLOBAL__N_13fooEv"]
+ #[link_name = "_ZN12_GLOBAL__N_13fooEv"]
pub fn foo();
}
#[repr(C)]
@@ -35,29 +35,36 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_A() {
- assert_eq!(::std::mem::size_of::<A>() , 4usize , concat ! (
- "Size of: " , stringify ! ( A ) ));
- assert_eq! (::std::mem::align_of::<A>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<A>(),
+ 4usize,
+ concat!("Size of: ", stringify!(A))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<A>(),
+ 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))
+ );
}
extern "C" {
- #[link_name = "_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"]
- pub fn A_lets_hope_this_works(this:
- *mut root::_bindgen_mod_id_13::A)
- -> ::std::os::raw::c_int;
+ #[link_name = "_ZN12_GLOBAL__N_11A20lets_hope_this_worksEv"]
+ pub fn A_lets_hope_this_works(
+ this: *mut root::_bindgen_mod_id_13::A,
+ ) -> ::std::os::raw::c_int;
}
impl Clone for A {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl A {
#[inline]
- pub unsafe fn lets_hope_this_works(&mut self)
- -> ::std::os::raw::c_int {
+ pub unsafe fn lets_hope_this_works(&mut self) -> ::std::os::raw::c_int {
A_lets_hope_this_works(self)
}
}
@@ -71,8 +78,10 @@ pub mod root {
pub m_c_arr: [T; 10usize],
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
- impl <T> Default for C<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ impl<T> Default for C<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
pub mod w {
#[allow(unused_imports)]
@@ -84,19 +93,21 @@ pub mod root {
pub m_c: root::C<T>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
- impl <T> Default for D<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ impl<T> Default for D<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
extern "C" {
- #[link_name = "_ZN1w3hehEv"]
+ #[link_name = "_ZN1w3hehEv"]
pub fn heh() -> root::w::whatever_int_t;
}
extern "C" {
- #[link_name = "_ZN1w3fooEv"]
+ #[link_name = "_ZN1w3fooEv"]
pub fn foo() -> root::C<::std::os::raw::c_int>;
}
extern "C" {
- #[link_name = "_ZN1w4barrEv"]
+ #[link_name = "_ZN1w4barrEv"]
pub fn barr() -> root::C<f32>;
}
}
diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs
index f1616e64..a36b6247 100644
--- a/tests/expectations/tests/no-derive-debug.rs
+++ b/tests/expectations/tests/no-derive-debug.rs
@@ -3,7 +3,12 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[repr(C)] #[derive(Copy, Clone, Default)] pub struct foo { bar: ::std::os::raw::c_int, }
+#[repr(C)]
+#[derive(Copy, Clone, Default)]
+pub struct foo {
+ bar: ::std::os::raw::c_int,
+}
+
/// 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
@@ -15,21 +20,39 @@ pub struct bar {
}
#[test]
fn bindgen_test_layout_bar() {
- assert_eq!(::std::mem::size_of::<bar>() , 8usize , concat ! (
- "Size of: " , stringify ! ( bar ) ));
- assert_eq! (::std::mem::align_of::<bar>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<bar>(),
+ 8usize,
+ concat!("Size of: ", stringify!(bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<bar>(),
+ 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 Default for bar {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/no-derive-default.rs b/tests/expectations/tests/no-derive-default.rs
index cdb89eb1..8c290e38 100644
--- a/tests/expectations/tests/no-derive-default.rs
+++ b/tests/expectations/tests/no-derive-default.rs
@@ -3,7 +3,12 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-#[repr(C)] #[derive(Copy, Clone, Debug)] pub struct foo { bar: ::std::os::raw::c_int, }
+#[repr(C)]
+#[derive(Copy, Clone, Debug)]
+pub struct foo {
+ bar: ::std::os::raw::c_int,
+}
+
/// 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
@@ -15,18 +20,34 @@ pub struct bar {
}
#[test]
fn bindgen_test_layout_bar() {
- assert_eq!(::std::mem::size_of::<bar>() , 8usize , concat ! (
- "Size of: " , stringify ! ( bar ) ));
- assert_eq! (::std::mem::align_of::<bar>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<bar>(),
+ 8usize,
+ concat!("Size of: ", stringify!(bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<bar>(),
+ 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)
+ )
+ );
}
diff --git a/tests/expectations/tests/no_copy.rs b/tests/expectations/tests/no_copy.rs
index ca28bdeb..45249668 100644
--- a/tests/expectations/tests/no_copy.rs
+++ b/tests/expectations/tests/no_copy.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen nocopy></div>
#[repr(C)]
#[derive(Debug, Default)]
diff --git a/tests/expectations/tests/nsBaseHashtable.rs b/tests/expectations/tests/nsBaseHashtable.rs
new file mode 100644
index 00000000..338978e1
--- /dev/null
+++ b/tests/expectations/tests/nsBaseHashtable.rs
@@ -0,0 +1,50 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct nsBaseHashtableET {
+ pub _address: u8,
+}
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct nsTHashtable {
+ pub _address: u8,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsBaseHashtable {
+ pub _address: u8,
+}
+pub type nsBaseHashtable_KeyType = [u8; 0usize];
+pub type nsBaseHashtable_EntryType = nsBaseHashtableET;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct nsBaseHashtable_LookupResult {
+ pub mEntry: *mut nsBaseHashtable_EntryType,
+ pub mTable: *mut nsBaseHashtable,
+}
+impl Default for nsBaseHashtable_LookupResult {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct nsBaseHashtable_EntryPtr {
+ pub mEntry: *mut nsBaseHashtable_EntryType,
+ pub mExistingEntry: bool,
+}
+impl Default for nsBaseHashtable_EntryPtr {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl Default for nsBaseHashtable {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
diff --git a/tests/expectations/tests/objc_class_method.rs b/tests/expectations/tests/objc_class_method.rs
index 640ae07f..3803f1f8 100644
--- a/tests/expectations/tests/objc_class_method.rs
+++ b/tests/expectations/tests/objc_class_method.rs
@@ -2,8 +2,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
@@ -13,42 +12,55 @@ 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 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)
+ 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 )
+ msg_send!(
+ objc::runtime::Class::get("Foo").expect("Couldn't find Foo"),
+ methodWithInt: foo: ::std::os::raw::c_int
+ )
}
unsafe fn methodWithFoo_(foo: id) {
- msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect (
- "Couldn\'t find Foo" ) , methodWithFoo:foo )
+ msg_send!(
+ objc::runtime::Class::get("Foo").expect("Couldn't find Foo"),
+ methodWithFoo: foo: id
+ )
}
unsafe fn methodReturningInt() -> ::std::os::raw::c_int {
- msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect (
- "Couldn\'t find Foo" ) , methodReturningInt)
+ 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)
+ 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 )
+ 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: ::std::os::raw::c_int,
+ andArg2: ptr: *mut ::std::os::raw::c_char,
+ andArg3: floatvalue: f32
+ )
}
}
diff --git a/tests/expectations/tests/objc_method.rs b/tests/expectations/tests/objc_method.rs
index 2b57a938..abf55849 100644
--- a/tests/expectations/tests/objc_method.rs
+++ b/tests/expectations/tests/objc_method.rs
@@ -2,8 +2,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
@@ -13,36 +12,42 @@ 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 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 method(self) {
+ msg_send!(self, method)
+ }
unsafe fn methodWithInt_(self, foo: ::std::os::raw::c_int) {
- msg_send!(self , methodWithInt:foo )
+ msg_send!(self, methodWithInt: foo: ::std::os::raw::c_int)
}
unsafe fn methodWithFoo_(self, foo: id) {
- msg_send!(self , methodWithFoo:foo )
+ msg_send!(self, methodWithFoo: foo: id)
}
unsafe fn methodReturningInt(self) -> ::std::os::raw::c_int {
- msg_send!(self , methodReturningInt)
+ msg_send!(self, methodReturningInt)
}
unsafe fn methodReturningFoo(self) -> *mut id {
- msg_send!(self , methodReturningFoo)
+ 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 )
+ 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: ::std::os::raw::c_int,
+ andArg2: ptr: *mut ::std::os::raw::c_char,
+ andArg3: floatvalue: f32
+ )
}
}
diff --git a/tests/expectations/tests/objc_method_clash.rs b/tests/expectations/tests/objc_method_clash.rs
index 88c2bd28..f57951b4 100644
--- a/tests/expectations/tests/objc_method_clash.rs
+++ b/tests/expectations/tests/objc_method_clash.rs
@@ -2,8 +2,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
@@ -14,9 +13,13 @@ pub trait Foo {
unsafe fn class_foo();
}
impl Foo for id {
- unsafe fn foo(self) { msg_send!(self , foo) }
+ unsafe fn foo(self) {
+ msg_send!(self, foo)
+ }
unsafe fn class_foo() {
- msg_send!(objc :: runtime :: Class :: get ( "Foo" ) . expect (
- "Couldn\'t find Foo" ) , foo)
+ msg_send!(
+ objc::runtime::Class::get("Foo").expect("Couldn't find Foo"),
+ foo
+ )
}
}
diff --git a/tests/expectations/tests/objc_property_fnptr.rs b/tests/expectations/tests/objc_property_fnptr.rs
index 2d7e08ed..16e0b4ba 100644
--- a/tests/expectations/tests/objc_property_fnptr.rs
+++ b/tests/expectations/tests/objc_property_fnptr.rs
@@ -2,34 +2,30 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
pub trait Foo {
- unsafe fn func(self)
- -> ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int>;
- unsafe fn setFunc_(self,
- func:
- ::std::option::Option<unsafe extern "C" fn()
- ->
- ::std::os::raw::c_int>);
+ unsafe fn func(self) -> ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int>;
+ unsafe fn setFunc_(
+ self,
+ func: ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int>,
+ );
}
impl Foo for id {
- unsafe fn func(self)
- ->
- ::std::option::Option<unsafe extern "C" fn()
- -> ::std::os::raw::c_int> {
- msg_send!(self , func)
+ unsafe fn func(self) -> ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int> {
+ msg_send!(self, func)
}
- unsafe fn setFunc_(self,
- func:
- ::std::option::Option<unsafe extern "C" fn()
- ->
- ::std::os::raw::c_int>) {
- msg_send!(self , setFunc:func )
+ unsafe fn setFunc_(
+ self,
+ func: ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int>,
+ ) {
+ msg_send!(
+ self,
+ setFunc: func: ::std::option::Option<unsafe extern "C" fn() -> ::std::os::raw::c_int>
+ )
}
}
diff --git a/tests/expectations/tests/objc_whitelist.rs b/tests/expectations/tests/objc_whitelist.rs
index 1f722b70..4eba7c7f 100644
--- a/tests/expectations/tests/objc_whitelist.rs
+++ b/tests/expectations/tests/objc_whitelist.rs
@@ -1,9 +1,9 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-#![cfg(target_os="macos")]
+#![allow(dead_code, non_snake_case, non_camel_case_types,
+ non_upper_case_globals)]
+#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
@@ -14,10 +14,15 @@ pub trait protocol_SomeProtocol {
unsafe fn protocolClassMethod();
}
impl protocol_SomeProtocol for id {
- unsafe fn protocolMethod(self) { msg_send!(self , protocolMethod) }
+ unsafe fn protocolMethod(self) {
+ msg_send!(self, protocolMethod)
+ }
unsafe fn protocolClassMethod() {
- msg_send!(objc :: runtime :: Class :: get ( "SomeProtocol" ) . expect
- ( "Couldn\'t find SomeProtocol" ) , protocolClassMethod)
+ msg_send!(
+ objc::runtime::Class::get("SomeProtocol")
+ .expect("Couldn't find SomeProtocol"),
+ protocolClassMethod
+ )
}
}
pub trait WhitelistMe {
@@ -25,11 +30,16 @@ pub trait WhitelistMe {
unsafe fn classMethod();
}
impl WhitelistMe for id {
- unsafe fn method(self) { msg_send!(self , method) }
+ unsafe fn method(self) {
+ msg_send!(self, method)
+ }
unsafe fn classMethod() {
- msg_send!(objc :: runtime :: Class :: get ( "WhitelistMe" ) . expect (
- "Couldn\'t find WhitelistMe" ) , 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 64a1fd79..13fb00ba 100644
--- a/tests/expectations/tests/only_bitfields.rs
+++ b/tests/expectations/tests/only_bitfields.rs
@@ -12,24 +12,32 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
- assert_eq!(::std::mem::size_of::<C>() , 1usize , concat ! (
- "Size of: " , stringify ! ( C ) ));
- assert_eq! (::std::mem::align_of::<C>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( C ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C>(),
+ 1usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(C))
+ );
}
impl Clone for C {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl C {
#[inline]
pub fn a(&self) -> bool {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -41,31 +49,31 @@ impl C {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn b(&self) -> bool {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 254u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -77,25 +85,25 @@ impl C {
let val = val as u8 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn new_bitfield_1(a: bool, b: bool) -> u8 {
- ({ ({ 0 } | ((a as u8 as u8) << 0usize) & (1u64 as u8)) } |
- ((b as u8 as u8) << 1usize) & (254u64 as u8))
+ ((0 | ((a as u8 as u8) << 0usize) & (1u64 as u8)) |
+ ((b as u8 as u8) << 1usize) & (254u64 as u8))
}
}
diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs
index 53122ba6..20b44d7e 100644
--- a/tests/expectations/tests/opaque-template-inst-member-2.rs
+++ b/tests/expectations/tests/opaque-template-inst-member-2.rs
@@ -4,12 +4,12 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// This is like `opaque-template-inst-member.hpp` except exercising the cases
/// where we are OK to derive Debug/Hash/PartialEq.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
-pub struct OpaqueTemplate {
-}
+pub struct OpaqueTemplate {}
/// Should derive Debug/Hash/PartialEq.
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -19,25 +19,41 @@ pub struct ContainsOpaqueTemplate {
}
#[test]
fn bindgen_test_layout_ContainsOpaqueTemplate() {
- assert_eq!(::std::mem::size_of::<ContainsOpaqueTemplate>() , 8usize ,
- concat ! ( "Size of: " , stringify ! ( ContainsOpaqueTemplate )
- ));
- assert_eq! (::std::mem::align_of::<ContainsOpaqueTemplate>() , 4usize ,
- concat ! (
- "Alignment of " , stringify ! ( ContainsOpaqueTemplate ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsOpaqueTemplate ) ) . mBlah as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ContainsOpaqueTemplate
- ) , "::" , stringify ! ( mBlah ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsOpaqueTemplate ) ) . mBaz as *
- const _ as usize } , 4usize , concat ! (
- "Alignment of field: " , stringify ! ( ContainsOpaqueTemplate
- ) , "::" , stringify ! ( mBaz ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ContainsOpaqueTemplate>(),
+ 8usize,
+ concat!("Size of: ", stringify!(ContainsOpaqueTemplate))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ContainsOpaqueTemplate>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ContainsOpaqueTemplate))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsOpaqueTemplate)).mBlah as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsOpaqueTemplate),
+ "::",
+ stringify!(mBlah)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsOpaqueTemplate)).mBaz as *const _ as usize },
+ 4usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsOpaqueTemplate),
+ "::",
+ stringify!(mBaz)
+ )
+ );
}
impl Clone for ContainsOpaqueTemplate {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// Should also derive Debug/Hash/PartialEq.
#[repr(C)]
@@ -48,21 +64,34 @@ pub struct InheritsOpaqueTemplate {
}
#[test]
fn bindgen_test_layout_InheritsOpaqueTemplate() {
- assert_eq!(::std::mem::size_of::<InheritsOpaqueTemplate>() , 16usize ,
- concat ! ( "Size of: " , stringify ! ( InheritsOpaqueTemplate )
- ));
- assert_eq! (::std::mem::align_of::<InheritsOpaqueTemplate>() , 8usize ,
- concat ! (
- "Alignment of " , stringify ! ( InheritsOpaqueTemplate ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const InheritsOpaqueTemplate ) ) . wow as *
- const _ as usize } , 8usize , concat ! (
- "Alignment of field: " , stringify ! ( InheritsOpaqueTemplate
- ) , "::" , stringify ! ( wow ) ));
+ assert_eq!(
+ ::std::mem::size_of::<InheritsOpaqueTemplate>(),
+ 16usize,
+ concat!("Size of: ", stringify!(InheritsOpaqueTemplate))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<InheritsOpaqueTemplate>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(InheritsOpaqueTemplate))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const InheritsOpaqueTemplate)).wow as *const _ as usize },
+ 8usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(InheritsOpaqueTemplate),
+ "::",
+ stringify!(wow)
+ )
+ );
}
impl Clone for InheritsOpaqueTemplate {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for InheritsOpaqueTemplate {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs
index 7bf657ed..09818446 100644
--- a/tests/expectations/tests/opaque-template-instantiation-namespaced.rs
+++ b/tests/expectations/tests/opaque-template-instantiation-namespaced.rs
@@ -17,8 +17,10 @@ pub mod root {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
- impl <T> Default for Template<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ impl<T> Default for Template<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -27,18 +29,26 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_Foo() {
- assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Foo ) ));
- assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Foo ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Foo ) ) . c as * const _ as usize
- } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( Foo ) , "::" ,
- stringify ! ( c ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Foo))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Foo)).c as *const _ as usize },
+ 0usize,
+ concat!("Alignment of field: ", stringify!(Foo), "::", stringify!(c))
+ );
}
impl Clone for Foo {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -47,18 +57,26 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_Bar() {
- assert_eq!(::std::mem::size_of::<Bar>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Bar ) ));
- assert_eq! (::std::mem::align_of::<Bar>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( Bar ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const Bar ) ) . i as * const _ as usize
- } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( Bar ) , "::" ,
- stringify ! ( i ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Bar>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Bar>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(Bar))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const Bar)).i as *const _ as usize },
+ 0usize,
+ concat!("Alignment of field: ", stringify!(Bar), "::", stringify!(i))
+ );
}
impl Clone for Bar {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -67,26 +85,36 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_ContainsInstantiation() {
- assert_eq!(::std::mem::size_of::<ContainsInstantiation>() , 1usize
- , concat ! (
- "Size of: " , stringify ! ( ContainsInstantiation ) ));
- assert_eq! (::std::mem::align_of::<ContainsInstantiation>() ,
- 1usize , concat ! (
- "Alignment of " , stringify ! ( ContainsInstantiation
- ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsInstantiation ) ) .
- not_opaque as * const _ as usize } , 0usize , concat !
- (
- "Alignment of field: " , stringify ! (
- ContainsInstantiation ) , "::" , stringify ! (
- not_opaque ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ContainsInstantiation>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ContainsInstantiation))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ContainsInstantiation>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ContainsInstantiation))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsInstantiation)).not_opaque as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsInstantiation),
+ "::",
+ stringify!(not_opaque)
+ )
+ );
}
impl Clone for ContainsInstantiation {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ContainsInstantiation {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -95,34 +123,45 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_ContainsOpaqueInstantiation() {
- assert_eq!(::std::mem::size_of::<ContainsOpaqueInstantiation>() ,
- 4usize , concat ! (
- "Size of: " , stringify ! ( ContainsOpaqueInstantiation
- ) ));
- assert_eq! (::std::mem::align_of::<ContainsOpaqueInstantiation>()
- , 4usize , concat ! (
- "Alignment of " , stringify ! (
- ContainsOpaqueInstantiation ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsOpaqueInstantiation ) ) .
- opaque as * const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- ContainsOpaqueInstantiation ) , "::" , stringify ! (
- opaque ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ContainsOpaqueInstantiation>(),
+ 4usize,
+ concat!("Size of: ", stringify!(ContainsOpaqueInstantiation))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ContainsOpaqueInstantiation>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ContainsOpaqueInstantiation))
+ );
+ assert_eq!(
+ unsafe {
+ &(*(0 as *const ContainsOpaqueInstantiation)).opaque as *const _ as usize
+ },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsOpaqueInstantiation),
+ "::",
+ stringify!(opaque)
+ )
+ );
}
impl Clone for ContainsOpaqueInstantiation {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
}
#[test]
fn __bindgen_test_layout_Template_open0_Foo_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<root::zoidberg::Template<root::zoidberg::Foo>>()
- , 1usize , concat ! (
- "Size of template specialization: " , stringify ! (
- root::zoidberg::Template<root::zoidberg::Foo> ) ));
- assert_eq!(::std::mem::align_of::<root::zoidberg::Template<root::zoidberg::Foo>>()
- , 1usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- root::zoidberg::Template<root::zoidberg::Foo> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<root::zoidberg::Template<root::zoidberg::Foo>>(),
+ 1usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( root :: zoidberg :: Template < root :: zoidberg :: Foo > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < root :: zoidberg :: Template < root :: zoidberg :: Foo > > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: zoidberg :: Template < root :: zoidberg :: Foo > ) ) );
}
}
diff --git a/tests/expectations/tests/opaque-template-instantiation.rs b/tests/expectations/tests/opaque-template-instantiation.rs
index 010186a5..480dba48 100644
--- a/tests/expectations/tests/opaque-template-instantiation.rs
+++ b/tests/expectations/tests/opaque-template-instantiation.rs
@@ -10,8 +10,10 @@ pub struct Template<T> {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for Template<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for Template<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -20,23 +22,36 @@ pub struct ContainsInstantiation {
}
#[test]
fn bindgen_test_layout_ContainsInstantiation() {
- assert_eq!(::std::mem::size_of::<ContainsInstantiation>() , 1usize ,
- concat ! ( "Size of: " , stringify ! ( ContainsInstantiation )
- ));
- assert_eq! (::std::mem::align_of::<ContainsInstantiation>() , 1usize ,
- concat ! (
- "Alignment of " , stringify ! ( ContainsInstantiation ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsInstantiation ) ) . not_opaque as
- * const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( ContainsInstantiation )
- , "::" , stringify ! ( not_opaque ) ));
+ assert_eq!(
+ ::std::mem::size_of::<ContainsInstantiation>(),
+ 1usize,
+ concat!("Size of: ", stringify!(ContainsInstantiation))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ContainsInstantiation>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(ContainsInstantiation))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsInstantiation)).not_opaque as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsInstantiation),
+ "::",
+ stringify!(not_opaque)
+ )
+ );
}
impl Clone for ContainsInstantiation {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for ContainsInstantiation {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -45,31 +60,41 @@ pub struct ContainsOpaqueInstantiation {
}
#[test]
fn bindgen_test_layout_ContainsOpaqueInstantiation() {
- assert_eq!(::std::mem::size_of::<ContainsOpaqueInstantiation>() , 4usize ,
- concat ! (
- "Size of: " , stringify ! ( ContainsOpaqueInstantiation ) ));
- assert_eq! (::std::mem::align_of::<ContainsOpaqueInstantiation>() , 4usize
- , concat ! (
- "Alignment of " , stringify ! ( ContainsOpaqueInstantiation )
- ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const ContainsOpaqueInstantiation ) ) . opaque
- as * const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! (
- ContainsOpaqueInstantiation ) , "::" , stringify ! ( opaque )
- ));
+ assert_eq!(
+ ::std::mem::size_of::<ContainsOpaqueInstantiation>(),
+ 4usize,
+ concat!("Size of: ", stringify!(ContainsOpaqueInstantiation))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<ContainsOpaqueInstantiation>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(ContainsOpaqueInstantiation))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const ContainsOpaqueInstantiation)).opaque as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(ContainsOpaqueInstantiation),
+ "::",
+ stringify!(opaque)
+ )
+ );
}
impl Clone for ContainsOpaqueInstantiation {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn __bindgen_test_layout_Template_open0_char_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<Template<::std::os::raw::c_char>>() ,
- 1usize , concat ! (
- "Size of template specialization: " , stringify ! (
- Template<::std::os::raw::c_char> ) ));
- assert_eq!(::std::mem::align_of::<Template<::std::os::raw::c_char>>() ,
- 1usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- Template<::std::os::raw::c_char> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Template<::std::os::raw::c_char>>(),
+ 1usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( Template < :: std :: os :: raw :: c_char > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < Template < :: std :: os :: raw :: c_char > > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Template < :: std :: os :: raw :: c_char > ) ) );
}
diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs
index a4ba4649..49cfc5fc 100644
--- a/tests/expectations/tests/opaque_in_struct.rs
+++ b/tests/expectations/tests/opaque_in_struct.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen opaque>
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -12,13 +13,21 @@ pub struct opaque {
}
#[test]
fn bindgen_test_layout_opaque() {
- assert_eq!(::std::mem::size_of::<opaque>() , 4usize , concat ! (
- "Size of: " , stringify ! ( opaque ) ));
- assert_eq! (::std::mem::align_of::<opaque>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( opaque ) ));
+ assert_eq!(
+ ::std::mem::size_of::<opaque>(),
+ 4usize,
+ concat!("Size of: ", stringify!(opaque))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<opaque>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(opaque))
+ );
}
impl Clone for opaque {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -27,16 +36,29 @@ pub struct container {
}
#[test]
fn bindgen_test_layout_container() {
- assert_eq!(::std::mem::size_of::<container>() , 4usize , concat ! (
- "Size of: " , stringify ! ( container ) ));
- assert_eq! (::std::mem::align_of::<container>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<container>(),
+ 4usize,
+ concat!("Size of: ", stringify!(container))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<container>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs
index bd2a624e..6eb7b672 100644
--- a/tests/expectations/tests/opaque_pointer.rs
+++ b/tests/expectations/tests/opaque_pointer.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen opaque></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -12,19 +13,26 @@ pub struct OtherOpaque {
}
#[test]
fn bindgen_test_layout_OtherOpaque() {
- assert_eq!(::std::mem::size_of::<OtherOpaque>() , 4usize , concat ! (
- "Size of: " , stringify ! ( OtherOpaque ) ));
- assert_eq! (::std::mem::align_of::<OtherOpaque>() , 4usize , concat ! (
- "Alignment of " , stringify ! ( OtherOpaque ) ));
+ assert_eq!(
+ ::std::mem::size_of::<OtherOpaque>(),
+ 4usize,
+ concat!("Size of: ", stringify!(OtherOpaque))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<OtherOpaque>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(OtherOpaque))
+ );
}
impl Clone for OtherOpaque {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// <div rustbindgen opaque></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
-pub struct Opaque {
-}
+pub struct Opaque {}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq)]
pub struct WithOpaquePtr {
@@ -34,29 +42,54 @@ pub struct WithOpaquePtr {
}
#[test]
fn bindgen_test_layout_WithOpaquePtr() {
- assert_eq!(::std::mem::size_of::<WithOpaquePtr>() , 16usize , concat ! (
- "Size of: " , stringify ! ( WithOpaquePtr ) ));
- assert_eq! (::std::mem::align_of::<WithOpaquePtr>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<WithOpaquePtr>(),
+ 16usize,
+ concat!("Size of: ", stringify!(WithOpaquePtr))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<WithOpaquePtr>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for WithOpaquePtr {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/replace_template_alias.rs b/tests/expectations/tests/replace_template_alias.rs
index 8d837341..3ddde177 100644
--- a/tests/expectations/tests/replace_template_alias.rs
+++ b/tests/expectations/tests/replace_template_alias.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// But the replacement type does use T!
///
/// <div rustbindgen replaces="JS::detail::MaybeWrapped" />
@@ -14,6 +15,8 @@ pub struct JS_Rooted<T> {
pub ptr: JS_detail_MaybeWrapped<T>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for JS_Rooted<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for JS_Rooted<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs
index 2569f7ac..49185e32 100644
--- a/tests/expectations/tests/replace_use.rs
+++ b/tests/expectations/tests/replace_use.rs
@@ -4,6 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
/// <div rustbindgen replaces="nsTArray"></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@@ -17,25 +18,45 @@ pub struct Test {
}
#[test]
fn bindgen_test_layout_Test() {
- assert_eq!(::std::mem::size_of::<Test>() , 4usize , concat ! (
- "Size of: " , stringify ! ( Test ) ));
- assert_eq! (::std::mem::align_of::<Test>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Test>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Test))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Test>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[test]
fn __bindgen_test_layout_nsTArray_open0_long_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<nsTArray>() , 4usize , concat ! (
- "Size of template specialization: " , stringify ! ( nsTArray )
- ));
- assert_eq!(::std::mem::align_of::<nsTArray>() , 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- nsTArray ) ));
+ assert_eq!(
+ ::std::mem::size_of::<nsTArray>(),
+ 4usize,
+ concat!("Size of template specialization: ", stringify!(nsTArray))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<nsTArray>(),
+ 4usize,
+ concat!(
+ "Alignment of template specialization: ",
+ stringify!(nsTArray)
+ )
+ );
}
diff --git a/tests/expectations/tests/struct_typedef_ns.rs b/tests/expectations/tests/struct_typedef_ns.rs
index 74c60923..e0dfe41d 100644
--- a/tests/expectations/tests/struct_typedef_ns.rs
+++ b/tests/expectations/tests/struct_typedef_ns.rs
@@ -18,24 +18,37 @@ pub mod root {
}
#[test]
fn bindgen_test_layout_typedef_struct() {
- assert_eq!(::std::mem::size_of::<typedef_struct>() , 4usize ,
- concat ! ( "Size of: " , stringify ! ( typedef_struct )
- ));
- assert_eq! (::std::mem::align_of::<typedef_struct>() , 4usize ,
- concat ! (
- "Alignment of " , stringify ! ( typedef_struct ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const typedef_struct ) ) . foo as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( typedef_struct
- ) , "::" , stringify ! ( foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<typedef_struct>(),
+ 4usize,
+ concat!("Size of: ", stringify!(typedef_struct))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<typedef_struct>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(typedef_struct))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const typedef_struct)).foo as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(typedef_struct),
+ "::",
+ stringify!(foo)
+ )
+ );
}
impl Clone for typedef_struct {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
- pub enum typedef_enum { BAR = 1, }
+ pub enum typedef_enum {
+ BAR = 1,
+ }
}
pub mod _bindgen_mod_id_12 {
#[allow(unused_imports)]
@@ -47,29 +60,40 @@ pub mod root {
}
#[test]
fn bindgen_test_layout__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize ,
- concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 )
- ));
- assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize ,
- concat ! (
- "Alignment of " , stringify ! ( _bindgen_ty_1 ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as *
- const _ as usize } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( _bindgen_ty_1 )
- , "::" , stringify ! ( foo ) ));
+ assert_eq!(
+ ::std::mem::size_of::<_bindgen_ty_1>(),
+ 4usize,
+ concat!("Size of: ", stringify!(_bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<_bindgen_ty_1>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(_bindgen_ty_1))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const _bindgen_ty_1)).foo as *const _ as usize },
+ 0usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(_bindgen_ty_1),
+ "::",
+ stringify!(foo)
+ )
+ );
}
impl Clone for _bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ 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 const _bindgen_mod_id_12_BAR: root::_bindgen_mod_id_12::_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
- typedef_enum;
+ pub enum _bindgen_ty_2 {
+ BAR = 1,
+ }
+ pub use self::super::super::root::_bindgen_mod_id_12::_bindgen_ty_2 as typedef_enum;
}
}
diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs
index d874351b..0581d4f2 100644
--- a/tests/expectations/tests/struct_with_bitfields.rs
+++ b/tests/expectations/tests/struct_with_bitfields.rs
@@ -13,29 +13,42 @@ pub struct bitfield {
}
#[test]
fn bindgen_test_layout_bitfield() {
- assert_eq!(::std::mem::size_of::<bitfield>() , 16usize , concat ! (
- "Size of: " , stringify ! ( bitfield ) ));
- assert_eq! (::std::mem::align_of::<bitfield>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<bitfield>(),
+ 16usize,
+ concat!("Size of: ", stringify!(bitfield))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<bitfield>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl bitfield {
#[inline]
pub fn a(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 1u64 as u8;
let val = (unit_field_val & mask) >> 0usize;
@@ -47,31 +60,31 @@ impl bitfield {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn b(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 2u64 as u8;
let val = (unit_field_val & mask) >> 1usize;
@@ -83,31 +96,31 @@ impl bitfield {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 1usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn c(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 4u64 as u8;
let val = (unit_field_val & mask) >> 2usize;
@@ -119,31 +132,31 @@ impl bitfield {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 2usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
pub fn d(&self) -> ::std::os::raw::c_ushort {
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
let mask = 192u64 as u8;
let val = (unit_field_val & mask) >> 6usize;
@@ -155,43 +168,43 @@ impl bitfield {
let val = val as u16 as u8;
let mut unit_field_val: u8 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u8 as
- *mut u8,
- ::std::mem::size_of::<u8>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u8 as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 6usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u8>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u8>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(a: ::std::os::raw::c_ushort,
- b: ::std::os::raw::c_ushort,
- c: ::std::os::raw::c_ushort,
- d: ::std::os::raw::c_ushort) -> u8 {
- ({
- ({
- ({ ({ 0 } | ((a as u16 as u8) << 0usize) & (1u64 as u8)) } |
- ((b as u16 as u8) << 1usize) & (2u64 as u8))
- } | ((c as u16 as u8) << 2usize) & (4u64 as u8))
- } | ((d as u16 as u8) << 6usize) & (192u64 as u8))
+ pub fn new_bitfield_1(
+ a: ::std::os::raw::c_ushort,
+ b: ::std::os::raw::c_ushort,
+ c: ::std::os::raw::c_ushort,
+ d: ::std::os::raw::c_ushort,
+ ) -> u8 {
+ ((((0 | ((a as u16 as u8) << 0usize) & (1u64 as u8)) |
+ ((b as u16 as u8) << 1usize) & (2u64 as u8)) |
+ ((c as u16 as u8) << 2usize) & (4u64 as u8)) |
+ ((d as u16 as u8) << 6usize) & (192u64 as u8))
}
#[inline]
pub fn f(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 3u64 as u64;
let val = (unit_field_val & mask) >> 0usize;
@@ -203,31 +216,31 @@ impl bitfield {
let val = val as u32 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
pub fn g(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
let mask = 18446744069414584320u64 as u64;
let val = (unit_field_val & mask) >> 32usize;
@@ -239,27 +252,25 @@ impl bitfield {
let val = val as u32 as u64;
let mut unit_field_val: u64 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u64 as
- *mut u8,
- ::std::mem::size_of::<u64>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u64 as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 32usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u64>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u64>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_2(f: ::std::os::raw::c_uint,
- g: ::std::os::raw::c_uint) -> u64 {
- ({ ({ 0 } | ((f as u32 as u64) << 0usize) & (3u64 as u64)) } |
- ((g as u32 as u64) << 32usize) &
- (18446744069414584320u64 as u64))
+ pub fn new_bitfield_2(f: ::std::os::raw::c_uint, g: ::std::os::raw::c_uint) -> u64 {
+ ((0 | ((f as u32 as u64) << 0usize) & (3u64 as u64)) |
+ ((g as u32 as u64) << 32usize) & (18446744069414584320u64 as u64))
}
}
diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs
index 4033f07b..067ed380 100644
--- a/tests/expectations/tests/template.rs
+++ b/tests/expectations/tests/template.rs
@@ -12,8 +12,10 @@ pub struct Foo<T> {
pub m_member_arr: [T; 1usize],
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for Foo<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for Foo<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -21,8 +23,10 @@ pub struct B<T> {
pub m_member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for B<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for B<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
extern "C" {
#[link_name = "_Z3bar3FooIiiE"]
@@ -54,90 +58,171 @@ pub struct C {
}
#[test]
fn bindgen_test_layout_C() {
- assert_eq!(::std::mem::size_of::<C>() , 96usize , concat ! (
- "Size of: " , stringify ! ( C ) ));
- assert_eq! (::std::mem::align_of::<C>() , 8usize , concat ! (
- "Alignment of " , stringify ! ( C ) ));
- assert_eq! (unsafe { & ( * ( 0 as * const C ) ) . mB as * const _ as usize
- } , 0usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mB ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConstPtr as * const _ as usize
- } , 8usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConstPtr ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConstStructPtr as * const _ as
- usize } , 16usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConstStructPtr ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConstStructPtrArray as * const
- _ as usize } , 24usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConstStructPtrArray ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConst as * const _ as usize } ,
- 32usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConst ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBVolatile as * const _ as usize
- } , 36usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBVolatile ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConstBool as * const _ as usize
- } , 40usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConstBool ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConstChar as * const _ as usize
- } , 42usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConstChar ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBArray as * const _ as usize } ,
- 44usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBArray ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBPtrArray as * const _ as usize
- } , 48usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBPtrArray ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBArrayPtr as * const _ as usize
- } , 56usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBArrayPtr ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBRef as * const _ as usize } ,
- 64usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBRef ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mBConstRef as * const _ as usize
- } , 72usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mBConstRef ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mPtrRef as * const _ as usize } ,
- 80usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mPtrRef ) ));
- assert_eq! (unsafe {
- & ( * ( 0 as * const C ) ) . mArrayRef as * const _ as usize }
- , 88usize , concat ! (
- "Alignment of field: " , stringify ! ( C ) , "::" , stringify
- ! ( mArrayRef ) ));
+ assert_eq!(
+ ::std::mem::size_of::<C>(),
+ 96usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<C>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(C))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mB as *const _ as usize },
+ 0usize,
+ concat!("Alignment of field: ", stringify!(C), "::", stringify!(mB))
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConstPtr as *const _ as usize },
+ 8usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConstPtr)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConstStructPtr as *const _ as usize },
+ 16usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConstStructPtr)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConstStructPtrArray as *const _ as usize },
+ 24usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConstStructPtrArray)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConst as *const _ as usize },
+ 32usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConst)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBVolatile as *const _ as usize },
+ 36usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBVolatile)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConstBool as *const _ as usize },
+ 40usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConstBool)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConstChar as *const _ as usize },
+ 42usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConstChar)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBArray as *const _ as usize },
+ 44usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBArray)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBPtrArray as *const _ as usize },
+ 48usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBPtrArray)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBArrayPtr as *const _ as usize },
+ 56usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBArrayPtr)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBRef as *const _ as usize },
+ 64usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBRef)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mBConstRef as *const _ as usize },
+ 72usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mBConstRef)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mPtrRef as *const _ as usize },
+ 80usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mPtrRef)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(0 as *const C)).mArrayRef as *const _ as usize },
+ 88usize,
+ concat!(
+ "Alignment of field: ",
+ stringify!(C),
+ "::",
+ stringify!(mArrayRef)
+ )
+ );
}
impl Clone for C {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for C {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
@@ -152,11 +237,15 @@ pub struct D_U<Z> {
pub m_baz: Z,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<Z>>,
}
-impl <Z> Default for D_U<Z> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<Z> Default for D_U<Z> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl Default for D {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -166,8 +255,10 @@ pub struct Rooted<T> {
pub ptr: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for Rooted<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for Rooted<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
@@ -176,21 +267,36 @@ pub struct RootedContainer {
}
#[test]
fn bindgen_test_layout_RootedContainer() {
- assert_eq!(::std::mem::size_of::<RootedContainer>() , 24usize , concat ! (
- "Size of: " , stringify ! ( RootedContainer ) ));
- assert_eq! (::std::mem::align_of::<RootedContainer>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<RootedContainer>(),
+ 24usize,
+ concat!("Size of: ", stringify!(RootedContainer))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<RootedContainer>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for RootedContainer {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>;
#[repr(C)]
@@ -199,8 +305,10 @@ pub struct WithDtor<T> {
pub member: T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for WithDtor<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for WithDtor<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
@@ -209,24 +317,36 @@ pub struct PODButContainsDtor {
}
#[test]
fn bindgen_test_layout_PODButContainsDtor() {
- assert_eq!(::std::mem::size_of::<PODButContainsDtor>() , 4usize , concat !
- ( "Size of: " , stringify ! ( PODButContainsDtor ) ));
- assert_eq! (::std::mem::align_of::<PODButContainsDtor>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<PODButContainsDtor>(),
+ 4usize,
+ concat!("Size of: ", stringify!(PODButContainsDtor))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<PODButContainsDtor>(),
+ 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() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
/// <div rustbindgen opaque>
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
-pub struct Opaque {
-}
+pub struct Opaque {}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct POD {
@@ -234,18 +354,31 @@ pub struct POD {
}
#[test]
fn bindgen_test_layout_POD() {
- assert_eq!(::std::mem::size_of::<POD>() , 4usize , concat ! (
- "Size of: " , stringify ! ( POD ) ));
- assert_eq! (::std::mem::align_of::<POD>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<POD>(),
+ 4usize,
+ concat!("Size of: ", stringify!(POD))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<POD>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
/// <div rustbindgen replaces="NestedReplaced"></div>
#[repr(C)]
@@ -254,8 +387,10 @@ pub struct NestedReplaced<T> {
pub buff: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for NestedReplaced<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for NestedReplaced<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -263,8 +398,10 @@ pub struct NestedBase<T> {
pub buff: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for NestedBase<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for NestedBase<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -275,7 +412,9 @@ pub struct NestedContainer<T> {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl <T> Default for NestedContainer<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
@@ -284,7 +423,9 @@ pub struct Incomplete<T> {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
impl <T> Default for Incomplete<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
@@ -293,13 +434,21 @@ pub struct Untemplated {
}
#[test]
fn bindgen_test_layout_Untemplated() {
- assert_eq!(::std::mem::size_of::<Untemplated>() , 1usize , concat ! (
- "Size of: " , stringify ! ( Untemplated ) ));
- assert_eq! (::std::mem::align_of::<Untemplated>() , 1usize , concat ! (
- "Alignment of " , stringify ! ( Untemplated ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Untemplated>(),
+ 1usize,
+ concat!("Size of: ", stringify!(Untemplated))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Untemplated>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(Untemplated))
+ );
}
impl Clone for Untemplated {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
@@ -316,8 +465,10 @@ pub struct ReplacedWithoutDestructor<T> {
pub buff: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for ReplacedWithoutDestructor<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for ReplacedWithoutDestructor<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
@@ -325,8 +476,10 @@ pub struct ShouldNotBeCopiable<T> {
pub m_member: ReplacedWithoutDestructor<T>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for ShouldNotBeCopiable<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for ShouldNotBeCopiable<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
@@ -334,8 +487,10 @@ pub struct ShouldNotBeCopiableAsWell<U> {
pub m_member: ReplacedWithoutDestructorFwd<U>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
}
-impl <U> Default for ShouldNotBeCopiableAsWell<U> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<U> Default for ShouldNotBeCopiableAsWell<U> {
+ 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.
@@ -347,222 +502,115 @@ pub struct ReplacedWithoutDestructorFwd<T> {
pub buff: *mut T,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-impl <T> Default for ReplacedWithoutDestructorFwd<T> {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+impl<T> Default for ReplacedWithoutDestructorFwd<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
#[test]
fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<Foo<::std::os::raw::c_int>>() , 24usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- Foo<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<Foo<::std::os::raw::c_int>>() , 8usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- Foo<::std::os::raw::c_int> ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Foo<::std::os::raw::c_int>>(),
+ 24usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify ! ( Foo < :: std :: os :: raw :: c_int > )
+ )
+ );
+ assert_eq ! ( :: std :: mem :: align_of :: < Foo < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Foo < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_unsigned_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<::std::os::raw::c_uint>>() , 4usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- B<::std::os::raw::c_uint> ) ));
- assert_eq!(::std::mem::align_of::<B<::std::os::raw::c_uint>>() , 4usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<::std::os::raw::c_uint> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < :: std :: os :: raw :: c_uint > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_uint > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < :: std :: os :: raw :: c_uint > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_uint > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ptr_const_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*const ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<*const ::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<B<*const ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*const ::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ptr_const_mozilla__Foo_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*const mozilla_Foo>>() , 8usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- B<*const mozilla_Foo> ) ));
- assert_eq!(::std::mem::align_of::<B<*const mozilla_Foo>>() , 8usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*const mozilla_Foo> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * const mozilla_Foo > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * const mozilla_Foo > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * const mozilla_Foo > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * const mozilla_Foo > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_array1_ptr_const_mozilla__Foo_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<[*const mozilla_Foo; 1usize]>>() ,
- 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<[*const mozilla_Foo; 1usize]> ) ));
- assert_eq!(::std::mem::align_of::<B<[*const mozilla_Foo; 1usize]>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<[*const mozilla_Foo; 1usize]> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < [ * const mozilla_Foo ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < [ * const mozilla_Foo ; 1usize ] > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < [ * const mozilla_Foo ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < [ * const mozilla_Foo ; 1usize ] > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_const_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- B<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<B<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_volatile_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- B<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<B<::std::os::raw::c_int>>() , 4usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_const_bool_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<bool>>() , 1usize , concat ! (
- "Size of template specialization: " , stringify ! ( B<bool> )
- ));
- assert_eq!(::std::mem::align_of::<B<bool>>() , 1usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<bool> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < bool > > ( ) , 1usize , concat ! ( "Size of template specialization: " , stringify ! ( B < bool > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < bool > > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < bool > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_const_char16_t_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<u16>>() , 2usize , concat ! (
- "Size of template specialization: " , stringify ! ( B<u16> )
- ));
- assert_eq!(::std::mem::align_of::<B<u16>>() , 2usize , concat ! (
- "Alignment of template specialization: " , stringify ! ( B<u16>
- ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < u16 > > ( ) , 2usize , concat ! ( "Size of template specialization: " , stringify ! ( B < u16 > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < u16 > > ( ) , 2usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < u16 > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_array1_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<[::std::os::raw::c_int; 1usize]>>() ,
- 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<[::std::os::raw::c_int; 1usize]> ) ));
- assert_eq!(::std::mem::align_of::<B<[::std::os::raw::c_int; 1usize]>>() ,
- 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<[::std::os::raw::c_int; 1usize]> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( B < [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_array1_ptr_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<[*mut ::std::os::raw::c_int; 1usize]>>()
- , 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<[*mut ::std::os::raw::c_int; 1usize]> ) ));
- assert_eq!(::std::mem::align_of::<B<[*mut ::std::os::raw::c_int; 1usize]>>()
- , 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<[*mut ::std::os::raw::c_int; 1usize]> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < [ * mut :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ptr_array1_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*mut [::std::os::raw::c_int; 1usize]>>()
- , 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<*mut [::std::os::raw::c_int; 1usize]> ) ));
- assert_eq!(::std::mem::align_of::<B<*mut [::std::os::raw::c_int; 1usize]>>()
- , 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*mut [::std::os::raw::c_int; 1usize]> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ref_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*mut ::std::os::raw::c_int>>() , 8usize
- , concat ! (
- "Size of template specialization: " , stringify ! (
- B<*mut ::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<B<*mut ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*mut ::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ref_const_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*const ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<*const ::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<B<*const ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*const ::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * const :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * const :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ref_ptr_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*mut *mut ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<*mut *mut ::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<B<*mut *mut ::std::os::raw::c_int>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*mut *mut ::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * mut * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut * mut :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * mut * mut :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut * mut :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_B_open0_ref_array1_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<B<*mut [::std::os::raw::c_int; 1usize]>>()
- , 8usize , concat ! (
- "Size of template specialization: " , stringify ! (
- B<*mut [::std::os::raw::c_int; 1usize]> ) ));
- assert_eq!(::std::mem::align_of::<B<*mut [::std::os::raw::c_int; 1usize]>>()
- , 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- B<*mut [::std::os::raw::c_int; 1usize]> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( B < * mut [ :: std :: os :: raw :: c_int ; 1usize ] > ) ) );
}
#[test]
fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() {
- assert_eq!(::std::mem::size_of::<Foo<::std::os::raw::c_int>>() , 24usize ,
- concat ! (
- "Size of template specialization: " , stringify ! (
- Foo<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<Foo<::std::os::raw::c_int>>() , 8usize ,
- concat ! (
- "Alignment of template specialization: " , stringify ! (
- Foo<::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < Foo < :: std :: os :: raw :: c_int > > ( ) , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( Foo < :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < Foo < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Foo < :: std :: os :: raw :: c_int > ) ) );
}
#[test]
fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
- 24usize , concat ! (
- "Size of template specialization: " , stringify ! (
- Rooted<*mut ::std::os::raw::c_void> ) ));
- assert_eq!(::std::mem::align_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- Rooted<*mut ::std::os::raw::c_void> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) );
}
#[test]
fn __bindgen_test_layout_Rooted_open0_ptr_void_close0_instantiation_1() {
- assert_eq!(::std::mem::size_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
- 24usize , concat ! (
- "Size of template specialization: " , stringify ! (
- Rooted<*mut ::std::os::raw::c_void> ) ));
- assert_eq!(::std::mem::align_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
- 8usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- Rooted<*mut ::std::os::raw::c_void> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 24usize , concat ! ( "Size of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < Rooted < * mut :: std :: os :: raw :: c_void > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( Rooted < * mut :: std :: os :: raw :: c_void > ) ) );
}
#[test]
fn __bindgen_test_layout_WithDtor_open0_int_close0_instantiation() {
- assert_eq!(::std::mem::size_of::<WithDtor<::std::os::raw::c_int>>() ,
- 4usize , concat ! (
- "Size of template specialization: " , stringify ! (
- WithDtor<::std::os::raw::c_int> ) ));
- assert_eq!(::std::mem::align_of::<WithDtor<::std::os::raw::c_int>>() ,
- 4usize , concat ! (
- "Alignment of template specialization: " , stringify ! (
- WithDtor<::std::os::raw::c_int> ) ));
+ assert_eq ! ( :: std :: mem :: size_of :: < WithDtor < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( WithDtor < :: std :: os :: raw :: c_int > ) ) );
+ assert_eq ! ( :: std :: mem :: align_of :: < WithDtor < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( WithDtor < :: std :: os :: raw :: c_int > ) ) );
}
diff --git a/tests/expectations/tests/template_typedefs.rs b/tests/expectations/tests/template_typedefs.rs
index d18783ad..df16f9f6 100644
--- a/tests/expectations/tests/template_typedefs.rs
+++ b/tests/expectations/tests/template_typedefs.rs
@@ -4,8 +4,7 @@
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-pub type foo =
- ::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int)>;
+pub type foo = ::std::option::Option<unsafe extern "C" fn(arg1: ::std::os::raw::c_int)>;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Foo {
@@ -13,8 +12,6 @@ pub struct Foo {
}
pub type Foo_Char<T> = T;
pub type Foo_FooPtrTypedef<T> = *mut Foo_Char<T>;
-pub type Foo_nsCOMArrayEnumFunc<T> =
- ::std::option::Option<unsafe extern "C" fn(aElement: *mut T,
- aData:
- *mut ::std::os::raw::c_void)
- -> bool>;
+pub type Foo_nsCOMArrayEnumFunc<T> = ::std::option::Option<
+ unsafe extern "C" fn(aElement: *mut T, aData: *mut ::std::os::raw::c_void) -> bool,
+>;
diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
index c258f901..3c903028 100644
--- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs
+++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
@@ -19,24 +19,32 @@ pub struct foo__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_foo__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat !
- ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat
- ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<foo__bindgen_ty_1>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo__bindgen_ty_1>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo__bindgen_ty_1))
+ );
}
impl Clone for foo__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl foo__bindgen_ty_1 {
#[inline]
pub fn b(&self) -> ::std::os::raw::c_int {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 127u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -48,31 +56,31 @@ impl foo__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn c(&self) -> ::std::os::raw::c_int {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 4294967168u64 as u32;
let val = (unit_field_val & mask) >> 7usize;
@@ -84,44 +92,53 @@ impl foo__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(b: ::std::os::raw::c_int, c: ::std::os::raw::c_int)
- -> u32 {
- ({ ({ 0 } | ((b as u32 as u32) << 0usize) & (127u64 as u32)) } |
- ((c as u32 as u32) << 7usize) & (4294967168u64 as u32))
+ pub fn new_bitfield_1(b: ::std::os::raw::c_int, c: ::std::os::raw::c_int) -> u32 {
+ ((0 | ((b as u32 as u32) << 0usize) & (127u64 as u32)) |
+ ((c as u32 as u32) << 7usize) & (4294967168u64 as u32))
}
}
#[test]
fn bindgen_test_layout_foo() {
- assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! (
- "Size of: " , stringify ! ( foo ) ));
- assert_eq! (::std::mem::align_of::<foo>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for foo {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
index 53faf3a4..2b5ffbac 100644
--- a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
+++ b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
@@ -6,33 +6,45 @@
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
-impl <T> __BindgenUnionField<T> {
+impl<T> __BindgenUnionField<T> {
#[inline]
- pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
#[inline]
- pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ 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 unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
}
-impl <T> ::std::default::Default for __BindgenUnionField<T> {
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
#[inline]
- fn default() -> Self { Self::new() }
+ fn default() -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
#[inline]
- fn clone(&self) -> Self { Self::new() }
+ fn clone(&self) -> Self {
+ Self::new()
+ }
}
-impl <T> ::std::marker::Copy for __BindgenUnionField<T> { }
-impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
-impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
- fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+impl<T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) {}
}
-impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
- fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
+impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
+ fn eq(&self, _other: &__BindgenUnionField<T>) -> bool {
+ true
+ }
}
impl <T> ::std::cmp::Eq for __BindgenUnionField<T> { }
#[repr(C)]
@@ -50,24 +62,32 @@ pub struct foo__bindgen_ty_1 {
}
#[test]
fn bindgen_test_layout_foo__bindgen_ty_1() {
- assert_eq!(::std::mem::size_of::<foo__bindgen_ty_1>() , 4usize , concat !
- ( "Size of: " , stringify ! ( foo__bindgen_ty_1 ) ));
- assert_eq! (::std::mem::align_of::<foo__bindgen_ty_1>() , 4usize , concat
- ! ( "Alignment of " , stringify ! ( foo__bindgen_ty_1 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<foo__bindgen_ty_1>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo__bindgen_ty_1))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo__bindgen_ty_1>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(foo__bindgen_ty_1))
+ );
}
impl Clone for foo__bindgen_ty_1 {
- fn clone(&self) -> Self { *self }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl foo__bindgen_ty_1 {
#[inline]
pub fn b(&self) -> ::std::os::raw::c_int {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 127u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -79,31 +99,31 @@ impl foo__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn c(&self) -> ::std::os::raw::c_int {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 4294967168u64 as u32;
let val = (unit_field_val & mask) >> 7usize;
@@ -115,41 +135,48 @@ impl foo__bindgen_ty_1 {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(b: ::std::os::raw::c_int, c: ::std::os::raw::c_int)
- -> u32 {
- ({ ({ 0 } | ((b as u32 as u32) << 0usize) & (127u64 as u32)) } |
- ((c as u32 as u32) << 7usize) & (4294967168u64 as u32))
+ pub fn new_bitfield_1(b: ::std::os::raw::c_int, c: ::std::os::raw::c_int) -> u32 {
+ ((0 | ((b as u32 as u32) << 0usize) & (127u64 as u32)) |
+ ((c as u32 as u32) << 7usize) & (4294967168u64 as u32))
}
}
#[test]
fn bindgen_test_layout_foo() {
- assert_eq!(::std::mem::size_of::<foo>() , 4usize , concat ! (
- "Size of: " , stringify ! ( foo ) ));
- assert_eq! (::std::mem::align_of::<foo>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 4usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
diff --git a/tests/expectations/tests/weird_bitfields.rs b/tests/expectations/tests/weird_bitfields.rs
index 0b97c368..06f3af34 100644
--- a/tests/expectations/tests/weird_bitfields.rs
+++ b/tests/expectations/tests/weird_bitfields.rs
@@ -32,87 +32,157 @@ pub struct Weird {
}
#[test]
fn bindgen_test_layout_Weird() {
- assert_eq!(::std::mem::size_of::<Weird>() , 24usize , concat ! (
- "Size of: " , stringify ! ( Weird ) ));
- assert_eq! (::std::mem::align_of::<Weird>() , 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 ) ));
+ assert_eq!(
+ ::std::mem::size_of::<Weird>(),
+ 24usize,
+ concat!("Size of: ", stringify!(Weird))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Weird>(),
+ 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 }
+ fn clone(&self) -> Self {
+ *self
+ }
}
impl Default for Weird {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
}
impl Weird {
#[inline]
pub fn bitTest(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 65535u64 as u32;
let val = (unit_field_val & mask) >> 0usize;
@@ -124,31 +194,31 @@ impl Weird {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
pub fn bitTest2(&self) -> ::std::os::raw::c_uint {
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
let mask = 2147418112u64 as u32;
let val = (unit_field_val & mask) >> 16usize;
@@ -160,37 +230,39 @@ impl Weird {
let val = val as u32 as u32;
let mut unit_field_val: u32 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_1 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u32 as
- *mut u8,
- ::std::mem::size_of::<u32>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_1 as *const _ as *const u8,
+ &mut unit_field_val as *mut u32 as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 16usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_1 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u32>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_1 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u32>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_1(bitTest: ::std::os::raw::c_uint,
- bitTest2: ::std::os::raw::c_uint) -> u32 {
- ({ ({ 0 } | ((bitTest as u32 as u32) << 0usize) & (65535u64 as u32)) }
- | ((bitTest2 as u32 as u32) << 16usize) & (2147418112u64 as u32))
+ pub fn new_bitfield_1(
+ bitTest: ::std::os::raw::c_uint,
+ bitTest2: ::std::os::raw::c_uint,
+ ) -> u32 {
+ ((0 | ((bitTest as u32 as u32) << 0usize) & (65535u64 as u32)) |
+ ((bitTest2 as u32 as u32) << 16usize) & (2147418112u64 as u32))
}
#[inline]
pub fn mFillOpacitySource(&self) -> nsStyleSVGOpacitySource {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 7u64 as u16;
let val = (unit_field_val & mask) >> 0usize;
@@ -202,31 +274,31 @@ impl Weird {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 0usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn mStrokeOpacitySource(&self) -> nsStyleSVGOpacitySource {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 56u64 as u16;
let val = (unit_field_val & mask) >> 3usize;
@@ -238,31 +310,31 @@ impl Weird {
let val = val as u32 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 3usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn mStrokeDasharrayFromObject(&self) -> bool {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 64u64 as u16;
let val = (unit_field_val & mask) >> 6usize;
@@ -274,31 +346,31 @@ impl Weird {
let val = val as u8 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 6usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn mStrokeDashoffsetFromObject(&self) -> bool {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 128u64 as u16;
let val = (unit_field_val & mask) >> 7usize;
@@ -310,31 +382,31 @@ impl Weird {
let val = val as u8 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 7usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
pub fn mStrokeWidthFromObject(&self) -> bool {
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
let mask = 256u64 as u16;
let val = (unit_field_val & mask) >> 8usize;
@@ -346,46 +418,34 @@ impl Weird {
let val = val as u8 as u16;
let mut unit_field_val: u16 = unsafe { ::std::mem::uninitialized() };
unsafe {
- ::std::ptr::copy_nonoverlapping(&self._bitfield_2 as *const _ as
- *const u8,
- &mut unit_field_val as *mut u16 as
- *mut u8,
- ::std::mem::size_of::<u16>())
+ ::std::ptr::copy_nonoverlapping(
+ &self._bitfield_2 as *const _ as *const u8,
+ &mut unit_field_val as *mut u16 as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ )
};
unit_field_val &= !mask;
unit_field_val |= (val << 8usize) & mask;
unsafe {
- ::std::ptr::copy_nonoverlapping(&unit_field_val as *const _ as
- *const u8,
- &mut self._bitfield_2 as *mut _ as
- *mut u8,
- ::std::mem::size_of::<u16>());
+ ::std::ptr::copy_nonoverlapping(
+ &unit_field_val as *const _ as *const u8,
+ &mut self._bitfield_2 as *mut _ as *mut u8,
+ ::std::mem::size_of::<u16>(),
+ );
}
}
#[inline]
- pub fn new_bitfield_2(mFillOpacitySource: nsStyleSVGOpacitySource,
- mStrokeOpacitySource: nsStyleSVGOpacitySource,
- mStrokeDasharrayFromObject: bool,
- mStrokeDashoffsetFromObject: bool,
- mStrokeWidthFromObject: bool) -> u16 {
- ({
- ({
- ({
- ({
- ({ 0 } |
- ((mFillOpacitySource as u32 as u16) <<
- 0usize) & (7u64 as u16))
- } |
- ((mStrokeOpacitySource as u32 as u16) << 3usize) &
- (56u64 as u16))
- } |
- ((mStrokeDasharrayFromObject as u8 as u16) << 6usize) &
- (64u64 as u16))
- } |
- ((mStrokeDashoffsetFromObject as u8 as u16) << 7usize) &
- (128u64 as u16))
- } |
- ((mStrokeWidthFromObject as u8 as u16) << 8usize) &
- (256u64 as u16))
+ pub fn new_bitfield_2(
+ mFillOpacitySource: nsStyleSVGOpacitySource,
+ mStrokeOpacitySource: nsStyleSVGOpacitySource,
+ mStrokeDasharrayFromObject: bool,
+ mStrokeDashoffsetFromObject: bool,
+ mStrokeWidthFromObject: bool,
+ ) -> u16 {
+ (((((0 | ((mFillOpacitySource as u32 as u16) << 0usize) & (7u64 as u16)) |
+ ((mStrokeOpacitySource as u32 as u16) << 3usize) & (56u64 as u16)) |
+ ((mStrokeDasharrayFromObject as u8 as u16) << 6usize) & (64u64 as u16)) |
+ ((mStrokeDashoffsetFromObject as u8 as u16) << 7usize) & (128u64 as u16)) |
+ ((mStrokeWidthFromObject as u8 as u16) << 8usize) & (256u64 as u16))
}
}
diff --git a/tests/headers/nsBaseHashtable.hpp b/tests/headers/nsBaseHashtable.hpp
new file mode 100644
index 00000000..36a480f2
--- /dev/null
+++ b/tests/headers/nsBaseHashtable.hpp
@@ -0,0 +1,48 @@
+// bindgen-flags: -- -std=c++14
+
+using uint32_t = unsigned long;
+using size_t = unsigned long long;
+
+template<class KeyClass, class DataType>
+class nsBaseHashtableET {
+};
+
+template<class Entry>
+class nsTHashtable {
+};
+
+template<class KeyClass, class DataType, class UserDataType>
+class nsBaseHashtable
+ : protected nsTHashtable<nsBaseHashtableET<KeyClass, DataType>>
+{
+
+public:
+ typedef typename KeyClass::KeyType KeyType;
+ typedef nsBaseHashtableET<KeyClass, DataType> EntryType;
+
+ using nsTHashtable<EntryType>::Contains;
+ using nsTHashtable<EntryType>::GetGeneration;
+
+ nsBaseHashtable() {}
+ explicit nsBaseHashtable(uint32_t);
+
+ struct LookupResult {
+ private:
+ EntryType* mEntry;
+ nsBaseHashtable& mTable;
+
+ public:
+ LookupResult(EntryType*, nsBaseHashtable&);
+ };
+
+ struct EntryPtr {
+ private:
+ EntryType& mEntry;
+ bool mExistingEntry;
+
+ public:
+ EntryPtr(nsBaseHashtable&, EntryType*, bool);
+ ~EntryPtr();
+ };
+
+};
diff --git a/tests/rustfmt.toml b/tests/rustfmt.toml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/rustfmt.toml
diff --git a/tests/stylo_sanity.rs b/tests/stylo_sanity.rs
index dfbfa9e3..56bfcaa8 100755
--- a/tests/stylo_sanity.rs
+++ b/tests/stylo_sanity.rs
@@ -1,3 +1,5 @@
+// Don't want to copy that nasty `cfg` below...
+#[allow(unused_extern_crates)]
extern crate bindgen;
/// A sanity test that we can generate bindings for Stylo.
@@ -13,528 +15,529 @@ extern crate bindgen;
/// takes too long to be a proper `#[bench]`.
#[test]
#[cfg(not(any(debug_assertions,
- feature = "testing_only_extra_assertions",
- feature = "testing_only_libclang_3_8")))]
+ feature = "testing_only_extra_assertions",
+ feature = "testing_only_libclang_3_8")))]
#[cfg(any(feature = "testing_only_libclang_3_9",
- feature = "testing_only_libclang_4"))]
+ feature = "testing_only_libclang_4"))]
fn sanity_check_can_generate_stylo_bindings() {
use std::time::Instant;
let then = Instant::now();
- bindgen::builder()
- .header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/stylo.hpp"))
- .whitelisted_function("Servo_.*")
- .whitelisted_function("Gecko_.*")
- .hide_type("nsACString_internal")
- .hide_type("nsAString_internal")
- .hide_type("mozilla::css::URLValue")
- .hide_type("RawGeckoAnimationPropertySegment")
- .hide_type("RawGeckoComputedTiming")
- .hide_type("RawGeckoDocument")
- .hide_type("RawGeckoElement")
- .hide_type("RawGeckoKeyframeList")
- .hide_type("RawGeckoComputedKeyframeValuesList")
- .hide_type("RawGeckoFontFaceRuleList")
- .hide_type("RawGeckoNode")
- .hide_type("RawGeckoAnimationValueList")
- .hide_type("RawServoAnimationValue")
- .hide_type("RawServoAnimationValueMap")
- .hide_type("RawServoDeclarationBlock")
- .hide_type("RawGeckoPresContext")
- .hide_type("RawGeckoPresContextOwned")
- .hide_type("RawGeckoStyleAnimationList")
- .hide_type("RawGeckoURLExtraData")
- .hide_type("RefPtr")
- .hide_type("CSSPseudoClassType")
- .hide_type("TraversalRootBehavior")
- .hide_type("ComputedTimingFunction_BeforeFlag")
- .hide_type("FontFamilyList")
- .hide_type("FontFamilyType")
- .hide_type("Keyframe")
- .hide_type("ServoBundledURI")
- .hide_type("ServoElementSnapshot")
- .hide_type("SheetParsingMode")
- .hide_type("StyleBasicShape")
- .hide_type("StyleBasicShapeType")
- .hide_type("StyleShapeSource")
- .hide_type("nsCSSFontFaceRule")
- .hide_type("nsCSSKeyword")
- .hide_type("nsCSSPropertyID")
- .hide_type("nsCSSShadowArray")
- .hide_type("nsCSSUnit")
- .hide_type("nsCSSValue")
- .hide_type("nsCSSValueSharedList")
- .hide_type("nsChangeHint")
- .hide_type("nsCursorImage")
- .hide_type("nsFont")
- .hide_type("nsIAtom")
- .hide_type("nsMediaFeature")
- .hide_type("nsRestyleHint")
- .hide_type("nsStyleBackground")
- .hide_type("nsStyleBorder")
- .hide_type("nsStyleColor")
- .hide_type("nsStyleColumn")
- .hide_type("nsStyleContent")
- .hide_type("nsStyleContentData")
- .hide_type("nsStyleContentType")
- .hide_type("nsStyleContext")
- .hide_type("nsStyleCoord")
- .hide_type("nsStyleCoord_Calc")
- .hide_type("nsStyleCoord_CalcValue")
- .hide_type("nsStyleDisplay")
- .hide_type("nsStyleEffects")
- .hide_type("nsStyleFilter")
- .hide_type("nsStyleFont")
- .hide_type("nsStyleGradient")
- .hide_type("nsStyleGradientStop")
- .hide_type("nsStyleImage")
- .hide_type("nsStyleImageLayers")
- .hide_type("nsStyleImageLayers_Layer")
- .hide_type("nsStyleImageLayers_LayerType")
- .hide_type("nsStyleImageRequest")
- .hide_type("nsStyleList")
- .hide_type("nsStyleMargin")
- .hide_type("nsStyleOutline")
- .hide_type("nsStylePadding")
- .hide_type("nsStylePosition")
- .hide_type("nsStyleQuoteValues")
- .hide_type("nsStyleSVG")
- .hide_type("nsStyleSVGPaint")
- .hide_type("nsStyleSVGReset")
- .hide_type("nsStyleTable")
- .hide_type("nsStyleTableBorder")
- .hide_type("nsStyleText")
- .hide_type("nsStyleTextReset")
- .hide_type("nsStyleUIReset")
- .hide_type("nsStyleUnion")
- .hide_type("nsStyleUnit")
- .hide_type("nsStyleUserInterface")
- .hide_type("nsStyleVariables")
- .hide_type("nsStyleVisibility")
- .hide_type("nsStyleXUL")
- .hide_type("nsTimingFunction")
- .hide_type("nscolor")
- .hide_type("nscoord")
- .hide_type("nsresult")
- .hide_type("Loader")
- .hide_type("ServoStyleSheet")
- .hide_type("EffectCompositor_CascadeLevel")
- .hide_type("UpdateAnimationsTasks")
- .hide_type("nsTArrayBorrowed_uintptr_t")
- .hide_type("ServoCssRulesStrong")
- .hide_type("ServoCssRulesBorrowed")
- .hide_type("ServoCssRulesBorrowedOrNull")
- .hide_type("ServoCssRules")
- .hide_type("RawServoStyleSheetStrong")
- .hide_type("RawServoStyleSheetBorrowed")
- .hide_type("RawServoStyleSheetBorrowedOrNull")
- .hide_type("RawServoStyleSheet")
- .hide_type("ServoComputedValuesStrong")
- .hide_type("ServoComputedValuesBorrowed")
- .hide_type("ServoComputedValuesBorrowedOrNull")
- .hide_type("ServoComputedValues")
- .hide_type("RawServoDeclarationBlockStrong")
- .hide_type("RawServoDeclarationBlockBorrowed")
- .hide_type("RawServoDeclarationBlockBorrowedOrNull")
- .hide_type("RawServoStyleRuleStrong")
- .hide_type("RawServoStyleRuleBorrowed")
- .hide_type("RawServoStyleRuleBorrowedOrNull")
- .hide_type("RawServoStyleRule")
- .hide_type("RawServoImportRuleStrong")
- .hide_type("RawServoImportRuleBorrowed")
- .hide_type("RawServoImportRuleBorrowedOrNull")
- .hide_type("RawServoImportRule")
- .hide_type("RawServoAnimationValueStrong")
- .hide_type("RawServoAnimationValueBorrowed")
- .hide_type("RawServoAnimationValueBorrowedOrNull")
- .hide_type("RawServoAnimationValueMapStrong")
- .hide_type("RawServoAnimationValueMapBorrowed")
- .hide_type("RawServoAnimationValueMapBorrowedOrNull")
- .hide_type("RawServoMediaListStrong")
- .hide_type("RawServoMediaListBorrowed")
- .hide_type("RawServoMediaListBorrowedOrNull")
- .hide_type("RawServoMediaList")
- .hide_type("RawServoMediaRuleStrong")
- .hide_type("RawServoMediaRuleBorrowed")
- .hide_type("RawServoMediaRuleBorrowedOrNull")
- .hide_type("RawServoMediaRule")
- .hide_type("RawServoNamespaceRuleStrong")
- .hide_type("RawServoNamespaceRuleBorrowed")
- .hide_type("RawServoNamespaceRuleBorrowedOrNull")
- .hide_type("RawServoNamespaceRule")
- .hide_type("RawServoStyleSetOwned")
- .hide_type("RawServoStyleSetOwnedOrNull")
- .hide_type("RawServoStyleSetBorrowed")
- .hide_type("RawServoStyleSetBorrowedOrNull")
- .hide_type("RawServoStyleSetBorrowedMut")
- .hide_type("RawServoStyleSetBorrowedMutOrNull")
- .hide_type("RawServoStyleSet")
- .hide_type("StyleChildrenIteratorOwned")
- .hide_type("StyleChildrenIteratorOwnedOrNull")
- .hide_type("StyleChildrenIteratorBorrowed")
- .hide_type("StyleChildrenIteratorBorrowedOrNull")
- .hide_type("StyleChildrenIteratorBorrowedMut")
- .hide_type("StyleChildrenIteratorBorrowedMutOrNull")
- .hide_type("StyleChildrenIterator")
- .hide_type("ServoElementSnapshotOwned")
- .hide_type("ServoElementSnapshotOwnedOrNull")
- .hide_type("ServoElementSnapshotBorrowed")
- .hide_type("ServoElementSnapshotBorrowedOrNull")
- .hide_type("ServoElementSnapshotBorrowedMut")
- .hide_type("ServoElementSnapshotBorrowedMutOrNull")
- .hide_type("RawGeckoNodeBorrowed")
- .hide_type("RawGeckoNodeBorrowedOrNull")
- .hide_type("RawGeckoElementBorrowed")
- .hide_type("RawGeckoElementBorrowedOrNull")
- .hide_type("RawGeckoDocumentBorrowed")
- .hide_type("RawGeckoDocumentBorrowedOrNull")
- .hide_type("RawServoDeclarationBlockStrongBorrowed")
- .hide_type("RawServoDeclarationBlockStrongBorrowedOrNull")
- .hide_type("RawGeckoPresContextBorrowed")
- .hide_type("RawGeckoPresContextBorrowedOrNull")
- .hide_type("RawGeckoStyleAnimationListBorrowed")
- .hide_type("RawGeckoStyleAnimationListBorrowedOrNull")
- .hide_type("nsCSSValueBorrowed")
- .hide_type("nsCSSValueBorrowedOrNull")
- .hide_type("nsCSSValueBorrowedMut")
- .hide_type("nsCSSValueBorrowedMutOrNull")
- .hide_type("nsTimingFunctionBorrowed")
- .hide_type("nsTimingFunctionBorrowedOrNull")
- .hide_type("nsTimingFunctionBorrowedMut")
- .hide_type("nsTimingFunctionBorrowedMutOrNull")
- .hide_type("RawGeckoAnimationPropertySegmentBorrowed")
- .hide_type("RawGeckoAnimationPropertySegmentBorrowedOrNull")
- .hide_type("RawGeckoAnimationPropertySegmentBorrowedMut")
- .hide_type("RawGeckoAnimationPropertySegmentBorrowedMutOrNull")
- .hide_type("RawGeckoAnimationValueListBorrowed")
- .hide_type("RawGeckoAnimationValueListBorrowedOrNull")
- .hide_type("RawGeckoAnimationValueListBorrowedMut")
- .hide_type("RawGeckoAnimationValueListBorrowedMutOrNull")
- .hide_type("RawGeckoComputedTimingBorrowed")
- .hide_type("RawGeckoComputedTimingBorrowedOrNull")
- .hide_type("RawGeckoComputedTimingBorrowedMut")
- .hide_type("RawGeckoComputedTimingBorrowedMutOrNull")
- .hide_type("RawGeckoKeyframeListBorrowed")
- .hide_type("RawGeckoKeyframeListBorrowedOrNull")
- .hide_type("RawGeckoKeyframeListBorrowedMut")
- .hide_type("RawGeckoKeyframeListBorrowedMutOrNull")
- .hide_type("RawGeckoComputedKeyframeValuesListBorrowed")
- .hide_type("RawGeckoComputedKeyframeValuesListBorrowedOrNull")
- .hide_type("RawGeckoComputedKeyframeValuesListBorrowedMut")
- .hide_type("RawGeckoComputedKeyframeValuesListBorrowedMutOrNull")
- .hide_type("RawGeckoFontFaceRuleListBorrowed")
- .hide_type("RawGeckoFontFaceRuleListBorrowedOrNull")
- .hide_type("RawGeckoFontFaceRuleListBorrowedMut")
- .hide_type("RawGeckoFontFaceRuleListBorrowedMutOrNull")
- .raw_line(r#"pub use nsstring::{nsACString, nsAString, nsString};"#)
- .raw_line(r#"type nsACString_internal = nsACString;"#)
- .raw_line(r#"type nsAString_internal = nsAString;"#)
- .raw_line(r#"use gecko_bindings::structs::mozilla::css::URLValue;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoAnimationPropertySegment;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoComputedTiming;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoDocument;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoElement;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoKeyframeList;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoComputedKeyframeValuesList;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoFontFaceRuleList;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoNode;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoAnimationValueList;"#)
- .raw_line(r#"use gecko_bindings::structs::RawServoAnimationValue;"#)
- .raw_line(r#"use gecko_bindings::structs::RawServoAnimationValueMap;"#)
- .raw_line(r#"use gecko_bindings::structs::RawServoDeclarationBlock;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoPresContext;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoPresContextOwned;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoStyleAnimationList;"#)
- .raw_line(r#"use gecko_bindings::structs::RawGeckoURLExtraData;"#)
- .raw_line(r#"use gecko_bindings::structs::RefPtr;"#)
- .raw_line(r#"use gecko_bindings::structs::CSSPseudoClassType;"#)
- .raw_line(r#"use gecko_bindings::structs::TraversalRootBehavior;"#)
- .raw_line(r#"use gecko_bindings::structs::ComputedTimingFunction_BeforeFlag;"#)
- .raw_line(r#"use gecko_bindings::structs::FontFamilyList;"#)
- .raw_line(r#"use gecko_bindings::structs::FontFamilyType;"#)
- .raw_line(r#"use gecko_bindings::structs::Keyframe;"#)
- .raw_line(r#"use gecko_bindings::structs::ServoBundledURI;"#)
- .raw_line(r#"use gecko_bindings::structs::ServoElementSnapshot;"#)
- .raw_line(r#"use gecko_bindings::structs::SheetParsingMode;"#)
- .raw_line(r#"use gecko_bindings::structs::StyleBasicShape;"#)
- .raw_line(r#"use gecko_bindings::structs::StyleBasicShapeType;"#)
- .raw_line(r#"use gecko_bindings::structs::StyleShapeSource;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSFontFaceRule;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSKeyword;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSPropertyID;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSShadowArray;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSUnit;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSValue;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCSSValueSharedList;"#)
- .raw_line(r#"use gecko_bindings::structs::nsChangeHint;"#)
- .raw_line(r#"use gecko_bindings::structs::nsCursorImage;"#)
- .raw_line(r#"use gecko_bindings::structs::nsFont;"#)
- .raw_line(r#"use gecko_bindings::structs::nsIAtom;"#)
- .raw_line(r#"use gecko_bindings::structs::nsMediaFeature;"#)
- .raw_line(r#"use gecko_bindings::structs::nsRestyleHint;"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleBackground;"#)
- .raw_line(r#"unsafe impl Send for nsStyleBackground {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleBackground {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleBorder;"#)
- .raw_line(r#"unsafe impl Send for nsStyleBorder {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleBorder {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleColor;"#)
- .raw_line(r#"unsafe impl Send for nsStyleColor {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleColor {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleColumn;"#)
- .raw_line(r#"unsafe impl Send for nsStyleColumn {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleColumn {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleContent;"#)
- .raw_line(r#"unsafe impl Send for nsStyleContent {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleContent {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleContentData;"#)
- .raw_line(r#"unsafe impl Send for nsStyleContentData {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleContentData {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleContentType;"#)
- .raw_line(r#"unsafe impl Send for nsStyleContentType {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleContentType {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleContext;"#)
- .raw_line(r#"unsafe impl Send for nsStyleContext {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleContext {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleCoord;"#)
- .raw_line(r#"unsafe impl Send for nsStyleCoord {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleCoord {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleCoord_Calc;"#)
- .raw_line(r#"unsafe impl Send for nsStyleCoord_Calc {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleCoord_Calc {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleCoord_CalcValue;"#)
- .raw_line(r#"unsafe impl Send for nsStyleCoord_CalcValue {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleCoord_CalcValue {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleDisplay;"#)
- .raw_line(r#"unsafe impl Send for nsStyleDisplay {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleDisplay {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleEffects;"#)
- .raw_line(r#"unsafe impl Send for nsStyleEffects {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleEffects {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleFilter;"#)
- .raw_line(r#"unsafe impl Send for nsStyleFilter {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleFilter {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleFont;"#)
- .raw_line(r#"unsafe impl Send for nsStyleFont {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleFont {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleGradient;"#)
- .raw_line(r#"unsafe impl Send for nsStyleGradient {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleGradient {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleGradientStop;"#)
- .raw_line(r#"unsafe impl Send for nsStyleGradientStop {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleGradientStop {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleImage;"#)
- .raw_line(r#"unsafe impl Send for nsStyleImage {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleImage {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleImageLayers;"#)
- .raw_line(r#"unsafe impl Send for nsStyleImageLayers {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleImageLayers {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleImageLayers_Layer;"#)
- .raw_line(r#"unsafe impl Send for nsStyleImageLayers_Layer {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleImageLayers_Layer {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleImageLayers_LayerType;"#)
- .raw_line(r#"unsafe impl Send for nsStyleImageLayers_LayerType {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleImageLayers_LayerType {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleImageRequest;"#)
- .raw_line(r#"unsafe impl Send for nsStyleImageRequest {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleImageRequest {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleList;"#)
- .raw_line(r#"unsafe impl Send for nsStyleList {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleList {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleMargin;"#)
- .raw_line(r#"unsafe impl Send for nsStyleMargin {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleMargin {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleOutline;"#)
- .raw_line(r#"unsafe impl Send for nsStyleOutline {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleOutline {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStylePadding;"#)
- .raw_line(r#"unsafe impl Send for nsStylePadding {}"#)
- .raw_line(r#"unsafe impl Sync for nsStylePadding {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStylePosition;"#)
- .raw_line(r#"unsafe impl Send for nsStylePosition {}"#)
- .raw_line(r#"unsafe impl Sync for nsStylePosition {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleQuoteValues;"#)
- .raw_line(r#"unsafe impl Send for nsStyleQuoteValues {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleQuoteValues {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleSVG;"#)
- .raw_line(r#"unsafe impl Send for nsStyleSVG {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleSVG {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleSVGPaint;"#)
- .raw_line(r#"unsafe impl Send for nsStyleSVGPaint {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleSVGPaint {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleSVGReset;"#)
- .raw_line(r#"unsafe impl Send for nsStyleSVGReset {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleSVGReset {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleTable;"#)
- .raw_line(r#"unsafe impl Send for nsStyleTable {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleTable {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleTableBorder;"#)
- .raw_line(r#"unsafe impl Send for nsStyleTableBorder {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleTableBorder {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleText;"#)
- .raw_line(r#"unsafe impl Send for nsStyleText {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleText {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleTextReset;"#)
- .raw_line(r#"unsafe impl Send for nsStyleTextReset {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleTextReset {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleUIReset;"#)
- .raw_line(r#"unsafe impl Send for nsStyleUIReset {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleUIReset {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleUnion;"#)
- .raw_line(r#"unsafe impl Send for nsStyleUnion {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleUnion {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleUnit;"#)
- .raw_line(r#"unsafe impl Send for nsStyleUnit {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleUnit {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleUserInterface;"#)
- .raw_line(r#"unsafe impl Send for nsStyleUserInterface {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleUserInterface {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleVariables;"#)
- .raw_line(r#"unsafe impl Send for nsStyleVariables {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleVariables {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleVisibility;"#)
- .raw_line(r#"unsafe impl Send for nsStyleVisibility {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleVisibility {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsStyleXUL;"#)
- .raw_line(r#"unsafe impl Send for nsStyleXUL {}"#)
- .raw_line(r#"unsafe impl Sync for nsStyleXUL {}"#)
- .raw_line(r#"use gecko_bindings::structs::nsTimingFunction;"#)
- .raw_line(r#"use gecko_bindings::structs::nscolor;"#)
- .raw_line(r#"use gecko_bindings::structs::nscoord;"#)
- .raw_line(r#"use gecko_bindings::structs::nsresult;"#)
- .raw_line(r#"use gecko_bindings::structs::Loader;"#)
- .raw_line(r#"use gecko_bindings::structs::ServoStyleSheet;"#)
- .raw_line(r#"use gecko_bindings::structs::EffectCompositor_CascadeLevel;"#)
- .raw_line(r#"use gecko_bindings::structs::UpdateAnimationsTasks;"#)
- .raw_line(r#"pub type nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>;"#)
- .raw_line(r#"pub type ServoCssRulesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoCssRules>;"#)
- .raw_line(r#"pub type ServoCssRulesBorrowed<'a> = &'a ServoCssRules;"#)
- .raw_line(r#"pub type ServoCssRulesBorrowedOrNull<'a> = Option<&'a ServoCssRules>;"#)
- .raw_line(r#"enum ServoCssRulesVoid { }"#)
- .raw_line(r#"pub struct ServoCssRules(ServoCssRulesVoid);"#)
- .raw_line(r#"pub type RawServoStyleSheetStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleSheet>;"#)
- .raw_line(r#"pub type RawServoStyleSheetBorrowed<'a> = &'a RawServoStyleSheet;"#)
- .raw_line(r#"pub type RawServoStyleSheetBorrowedOrNull<'a> = Option<&'a RawServoStyleSheet>;"#)
- .raw_line(r#"enum RawServoStyleSheetVoid { }"#)
- .raw_line(r#"pub struct RawServoStyleSheet(RawServoStyleSheetVoid);"#)
- .raw_line(r#"pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;"#)
- .raw_line(r#"pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;"#)
- .raw_line(r#"pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;"#)
- .raw_line(r#"enum ServoComputedValuesVoid { }"#)
- .raw_line(r#"pub struct ServoComputedValues(ServoComputedValuesVoid);"#)
- .raw_line(r#"pub type RawServoDeclarationBlockStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoDeclarationBlock>;"#)
- .raw_line(r#"pub type RawServoDeclarationBlockBorrowed<'a> = &'a RawServoDeclarationBlock;"#)
- .raw_line(r#"pub type RawServoDeclarationBlockBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlock>;"#)
- .raw_line(r#"pub type RawServoStyleRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleRule>;"#)
- .raw_line(r#"pub type RawServoStyleRuleBorrowed<'a> = &'a RawServoStyleRule;"#)
- .raw_line(r#"pub type RawServoStyleRuleBorrowedOrNull<'a> = Option<&'a RawServoStyleRule>;"#)
- .raw_line(r#"enum RawServoStyleRuleVoid { }"#)
- .raw_line(r#"pub struct RawServoStyleRule(RawServoStyleRuleVoid);"#)
- .raw_line(r#"pub type RawServoImportRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoImportRule>;"#)
- .raw_line(r#"pub type RawServoImportRuleBorrowed<'a> = &'a RawServoImportRule;"#)
- .raw_line(r#"pub type RawServoImportRuleBorrowedOrNull<'a> = Option<&'a RawServoImportRule>;"#)
- .raw_line(r#"enum RawServoImportRuleVoid { }"#)
- .raw_line(r#"pub struct RawServoImportRule(RawServoImportRuleVoid);"#)
- .raw_line(r#"pub type RawServoAnimationValueStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoAnimationValue>;"#)
- .raw_line(r#"pub type RawServoAnimationValueBorrowed<'a> = &'a RawServoAnimationValue;"#)
- .raw_line(r#"pub type RawServoAnimationValueBorrowedOrNull<'a> = Option<&'a RawServoAnimationValue>;"#)
- .raw_line(r#"pub type RawServoAnimationValueMapStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoAnimationValueMap>;"#)
- .raw_line(r#"pub type RawServoAnimationValueMapBorrowed<'a> = &'a RawServoAnimationValueMap;"#)
- .raw_line(r#"pub type RawServoAnimationValueMapBorrowedOrNull<'a> = Option<&'a RawServoAnimationValueMap>;"#)
- .raw_line(r#"pub type RawServoMediaListStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoMediaList>;"#)
- .raw_line(r#"pub type RawServoMediaListBorrowed<'a> = &'a RawServoMediaList;"#)
- .raw_line(r#"pub type RawServoMediaListBorrowedOrNull<'a> = Option<&'a RawServoMediaList>;"#)
- .raw_line(r#"enum RawServoMediaListVoid { }"#)
- .raw_line(r#"pub struct RawServoMediaList(RawServoMediaListVoid);"#)
- .raw_line(r#"pub type RawServoMediaRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoMediaRule>;"#)
- .raw_line(r#"pub type RawServoMediaRuleBorrowed<'a> = &'a RawServoMediaRule;"#)
- .raw_line(r#"pub type RawServoMediaRuleBorrowedOrNull<'a> = Option<&'a RawServoMediaRule>;"#)
- .raw_line(r#"enum RawServoMediaRuleVoid { }"#)
- .raw_line(r#"pub struct RawServoMediaRule(RawServoMediaRuleVoid);"#)
- .raw_line(r#"pub type RawServoNamespaceRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoNamespaceRule>;"#)
- .raw_line(r#"pub type RawServoNamespaceRuleBorrowed<'a> = &'a RawServoNamespaceRule;"#)
- .raw_line(r#"pub type RawServoNamespaceRuleBorrowedOrNull<'a> = Option<&'a RawServoNamespaceRule>;"#)
- .raw_line(r#"enum RawServoNamespaceRuleVoid { }"#)
- .raw_line(r#"pub struct RawServoNamespaceRule(RawServoNamespaceRuleVoid);"#)
- .raw_line(r#"pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;"#)
- .raw_line(r#"pub type RawServoStyleSetOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<RawServoStyleSet>;"#)
- .raw_line(r#"pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet;"#)
- .raw_line(r#"pub type RawServoStyleSetBorrowedOrNull<'a> = Option<&'a RawServoStyleSet>;"#)
- .raw_line(r#"pub type RawServoStyleSetBorrowedMut<'a> = &'a mut RawServoStyleSet;"#)
- .raw_line(r#"pub type RawServoStyleSetBorrowedMutOrNull<'a> = Option<&'a mut RawServoStyleSet>;"#)
- .raw_line(r#"enum RawServoStyleSetVoid { }"#)
- .raw_line(r#"pub struct RawServoStyleSet(RawServoStyleSetVoid);"#)
- .raw_line(r#"pub type StyleChildrenIteratorOwned = ::gecko_bindings::sugar::ownership::Owned<StyleChildrenIterator>;"#)
- .raw_line(r#"pub type StyleChildrenIteratorOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<StyleChildrenIterator>;"#)
- .raw_line(r#"pub type StyleChildrenIteratorBorrowed<'a> = &'a StyleChildrenIterator;"#)
- .raw_line(r#"pub type StyleChildrenIteratorBorrowedOrNull<'a> = Option<&'a StyleChildrenIterator>;"#)
- .raw_line(r#"pub type StyleChildrenIteratorBorrowedMut<'a> = &'a mut StyleChildrenIterator;"#)
- .raw_line(r#"pub type StyleChildrenIteratorBorrowedMutOrNull<'a> = Option<&'a mut StyleChildrenIterator>;"#)
- .raw_line(r#"enum StyleChildrenIteratorVoid { }"#)
- .raw_line(r#"pub struct StyleChildrenIterator(StyleChildrenIteratorVoid);"#)
- .raw_line(r#"pub type ServoElementSnapshotOwned = ::gecko_bindings::sugar::ownership::Owned<ServoElementSnapshot>;"#)
- .raw_line(r#"pub type ServoElementSnapshotOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<ServoElementSnapshot>;"#)
- .raw_line(r#"pub type ServoElementSnapshotBorrowed<'a> = &'a ServoElementSnapshot;"#)
- .raw_line(r#"pub type ServoElementSnapshotBorrowedOrNull<'a> = Option<&'a ServoElementSnapshot>;"#)
- .raw_line(r#"pub type ServoElementSnapshotBorrowedMut<'a> = &'a mut ServoElementSnapshot;"#)
- .raw_line(r#"pub type ServoElementSnapshotBorrowedMutOrNull<'a> = Option<&'a mut ServoElementSnapshot>;"#)
- .raw_line(r#"pub type RawGeckoNodeBorrowed<'a> = &'a RawGeckoNode;"#)
- .raw_line(r#"pub type RawGeckoNodeBorrowedOrNull<'a> = Option<&'a RawGeckoNode>;"#)
- .raw_line(r#"pub type RawGeckoElementBorrowed<'a> = &'a RawGeckoElement;"#)
- .raw_line(r#"pub type RawGeckoElementBorrowedOrNull<'a> = Option<&'a RawGeckoElement>;"#)
- .raw_line(r#"pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument;"#)
- .raw_line(r#"pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>;"#)
- .raw_line(r#"pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong;"#)
- .raw_line(r#"pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>;"#)
- .raw_line(r#"pub type RawGeckoPresContextBorrowed<'a> = &'a RawGeckoPresContext;"#)
- .raw_line(r#"pub type RawGeckoPresContextBorrowedOrNull<'a> = Option<&'a RawGeckoPresContext>;"#)
- .raw_line(r#"pub type RawGeckoStyleAnimationListBorrowed<'a> = &'a RawGeckoStyleAnimationList;"#)
- .raw_line(r#"pub type RawGeckoStyleAnimationListBorrowedOrNull<'a> = Option<&'a RawGeckoStyleAnimationList>;"#)
- .raw_line(r#"pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue;"#)
- .raw_line(r#"pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>;"#)
- .raw_line(r#"pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue;"#)
- .raw_line(r#"pub type nsCSSValueBorrowedMutOrNull<'a> = Option<&'a mut nsCSSValue>;"#)
- .raw_line(r#"pub type nsTimingFunctionBorrowed<'a> = &'a nsTimingFunction;"#)
- .raw_line(r#"pub type nsTimingFunctionBorrowedOrNull<'a> = Option<&'a nsTimingFunction>;"#)
- .raw_line(r#"pub type nsTimingFunctionBorrowedMut<'a> = &'a mut nsTimingFunction;"#)
- .raw_line(r#"pub type nsTimingFunctionBorrowedMutOrNull<'a> = Option<&'a mut nsTimingFunction>;"#)
- .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowed<'a> = &'a RawGeckoAnimationPropertySegment;"#)
- .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationPropertySegment>;"#)
- .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowedMut<'a> = &'a mut RawGeckoAnimationPropertySegment;"#)
- .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationPropertySegment>;"#)
- .raw_line(r#"pub type RawGeckoAnimationValueListBorrowed<'a> = &'a RawGeckoAnimationValueList;"#)
- .raw_line(r#"pub type RawGeckoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationValueList>;"#)
- .raw_line(r#"pub type RawGeckoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoAnimationValueList;"#)
- .raw_line(r#"pub type RawGeckoAnimationValueListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationValueList>;"#)
- .raw_line(r#"pub type RawGeckoComputedTimingBorrowed<'a> = &'a RawGeckoComputedTiming;"#)
- .raw_line(r#"pub type RawGeckoComputedTimingBorrowedOrNull<'a> = Option<&'a RawGeckoComputedTiming>;"#)
- .raw_line(r#"pub type RawGeckoComputedTimingBorrowedMut<'a> = &'a mut RawGeckoComputedTiming;"#)
- .raw_line(r#"pub type RawGeckoComputedTimingBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoComputedTiming>;"#)
- .raw_line(r#"pub type RawGeckoKeyframeListBorrowed<'a> = &'a RawGeckoKeyframeList;"#)
- .raw_line(r#"pub type RawGeckoKeyframeListBorrowedOrNull<'a> = Option<&'a RawGeckoKeyframeList>;"#)
- .raw_line(r#"pub type RawGeckoKeyframeListBorrowedMut<'a> = &'a mut RawGeckoKeyframeList;"#)
- .raw_line(r#"pub type RawGeckoKeyframeListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoKeyframeList>;"#)
- .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowed<'a> = &'a RawGeckoComputedKeyframeValuesList;"#)
- .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowedOrNull<'a> = Option<&'a RawGeckoComputedKeyframeValuesList>;"#)
- .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowedMut<'a> = &'a mut RawGeckoComputedKeyframeValuesList;"#)
- .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoComputedKeyframeValuesList>;"#)
- .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowed<'a> = &'a RawGeckoFontFaceRuleList;"#)
- .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowedOrNull<'a> = Option<&'a RawGeckoFontFaceRuleList>;"#)
- .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowedMut<'a> = &'a mut RawGeckoFontFaceRuleList;"#)
- .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoFontFaceRuleList>;"#)
- .clang_arg("-x")
- .clang_arg("c++")
- .clang_arg("-std=c++14")
- .clang_arg("-DTRACING=1")
- .clang_arg("-DIMPL_LIBXUL")
- .clang_arg("-DMOZ_STYLO_BINDINGS=1")
- .clang_arg("-DMOZILLA_INTERNAL_API")
- .clang_arg("-DRUST_BINDGEN")
- .clang_arg("-DMOZ_STYLO")
- .clang_arg("-DOS_POSIX=1")
- .clang_arg("-DOS_LINUX=1")
- .generate()
+ bindgen::builder()
+ .time_phases(true)
+ .header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/stylo.hpp"))
+ .whitelisted_function("Servo_.*")
+ .whitelisted_function("Gecko_.*")
+ .hide_type("nsACString_internal")
+ .hide_type("nsAString_internal")
+ .hide_type("mozilla::css::URLValue")
+ .hide_type("RawGeckoAnimationPropertySegment")
+ .hide_type("RawGeckoComputedTiming")
+ .hide_type("RawGeckoDocument")
+ .hide_type("RawGeckoElement")
+ .hide_type("RawGeckoKeyframeList")
+ .hide_type("RawGeckoComputedKeyframeValuesList")
+ .hide_type("RawGeckoFontFaceRuleList")
+ .hide_type("RawGeckoNode")
+ .hide_type("RawGeckoAnimationValueList")
+ .hide_type("RawServoAnimationValue")
+ .hide_type("RawServoAnimationValueMap")
+ .hide_type("RawServoDeclarationBlock")
+ .hide_type("RawGeckoPresContext")
+ .hide_type("RawGeckoPresContextOwned")
+ .hide_type("RawGeckoStyleAnimationList")
+ .hide_type("RawGeckoURLExtraData")
+ .hide_type("RefPtr")
+ .hide_type("CSSPseudoClassType")
+ .hide_type("TraversalRootBehavior")
+ .hide_type("ComputedTimingFunction_BeforeFlag")
+ .hide_type("FontFamilyList")
+ .hide_type("FontFamilyType")
+ .hide_type("Keyframe")
+ .hide_type("ServoBundledURI")
+ .hide_type("ServoElementSnapshot")
+ .hide_type("SheetParsingMode")
+ .hide_type("StyleBasicShape")
+ .hide_type("StyleBasicShapeType")
+ .hide_type("StyleShapeSource")
+ .hide_type("nsCSSFontFaceRule")
+ .hide_type("nsCSSKeyword")
+ .hide_type("nsCSSPropertyID")
+ .hide_type("nsCSSShadowArray")
+ .hide_type("nsCSSUnit")
+ .hide_type("nsCSSValue")
+ .hide_type("nsCSSValueSharedList")
+ .hide_type("nsChangeHint")
+ .hide_type("nsCursorImage")
+ .hide_type("nsFont")
+ .hide_type("nsIAtom")
+ .hide_type("nsMediaFeature")
+ .hide_type("nsRestyleHint")
+ .hide_type("nsStyleBackground")
+ .hide_type("nsStyleBorder")
+ .hide_type("nsStyleColor")
+ .hide_type("nsStyleColumn")
+ .hide_type("nsStyleContent")
+ .hide_type("nsStyleContentData")
+ .hide_type("nsStyleContentType")
+ .hide_type("nsStyleContext")
+ .hide_type("nsStyleCoord")
+ .hide_type("nsStyleCoord_Calc")
+ .hide_type("nsStyleCoord_CalcValue")
+ .hide_type("nsStyleDisplay")
+ .hide_type("nsStyleEffects")
+ .hide_type("nsStyleFilter")
+ .hide_type("nsStyleFont")
+ .hide_type("nsStyleGradient")
+ .hide_type("nsStyleGradientStop")
+ .hide_type("nsStyleImage")
+ .hide_type("nsStyleImageLayers")
+ .hide_type("nsStyleImageLayers_Layer")
+ .hide_type("nsStyleImageLayers_LayerType")
+ .hide_type("nsStyleImageRequest")
+ .hide_type("nsStyleList")
+ .hide_type("nsStyleMargin")
+ .hide_type("nsStyleOutline")
+ .hide_type("nsStylePadding")
+ .hide_type("nsStylePosition")
+ .hide_type("nsStyleQuoteValues")
+ .hide_type("nsStyleSVG")
+ .hide_type("nsStyleSVGPaint")
+ .hide_type("nsStyleSVGReset")
+ .hide_type("nsStyleTable")
+ .hide_type("nsStyleTableBorder")
+ .hide_type("nsStyleText")
+ .hide_type("nsStyleTextReset")
+ .hide_type("nsStyleUIReset")
+ .hide_type("nsStyleUnion")
+ .hide_type("nsStyleUnit")
+ .hide_type("nsStyleUserInterface")
+ .hide_type("nsStyleVariables")
+ .hide_type("nsStyleVisibility")
+ .hide_type("nsStyleXUL")
+ .hide_type("nsTimingFunction")
+ .hide_type("nscolor")
+ .hide_type("nscoord")
+ .hide_type("nsresult")
+ .hide_type("Loader")
+ .hide_type("ServoStyleSheet")
+ .hide_type("EffectCompositor_CascadeLevel")
+ .hide_type("UpdateAnimationsTasks")
+ .hide_type("nsTArrayBorrowed_uintptr_t")
+ .hide_type("ServoCssRulesStrong")
+ .hide_type("ServoCssRulesBorrowed")
+ .hide_type("ServoCssRulesBorrowedOrNull")
+ .hide_type("ServoCssRules")
+ .hide_type("RawServoStyleSheetStrong")
+ .hide_type("RawServoStyleSheetBorrowed")
+ .hide_type("RawServoStyleSheetBorrowedOrNull")
+ .hide_type("RawServoStyleSheet")
+ .hide_type("ServoComputedValuesStrong")
+ .hide_type("ServoComputedValuesBorrowed")
+ .hide_type("ServoComputedValuesBorrowedOrNull")
+ .hide_type("ServoComputedValues")
+ .hide_type("RawServoDeclarationBlockStrong")
+ .hide_type("RawServoDeclarationBlockBorrowed")
+ .hide_type("RawServoDeclarationBlockBorrowedOrNull")
+ .hide_type("RawServoStyleRuleStrong")
+ .hide_type("RawServoStyleRuleBorrowed")
+ .hide_type("RawServoStyleRuleBorrowedOrNull")
+ .hide_type("RawServoStyleRule")
+ .hide_type("RawServoImportRuleStrong")
+ .hide_type("RawServoImportRuleBorrowed")
+ .hide_type("RawServoImportRuleBorrowedOrNull")
+ .hide_type("RawServoImportRule")
+ .hide_type("RawServoAnimationValueStrong")
+ .hide_type("RawServoAnimationValueBorrowed")
+ .hide_type("RawServoAnimationValueBorrowedOrNull")
+ .hide_type("RawServoAnimationValueMapStrong")
+ .hide_type("RawServoAnimationValueMapBorrowed")
+ .hide_type("RawServoAnimationValueMapBorrowedOrNull")
+ .hide_type("RawServoMediaListStrong")
+ .hide_type("RawServoMediaListBorrowed")
+ .hide_type("RawServoMediaListBorrowedOrNull")
+ .hide_type("RawServoMediaList")
+ .hide_type("RawServoMediaRuleStrong")
+ .hide_type("RawServoMediaRuleBorrowed")
+ .hide_type("RawServoMediaRuleBorrowedOrNull")
+ .hide_type("RawServoMediaRule")
+ .hide_type("RawServoNamespaceRuleStrong")
+ .hide_type("RawServoNamespaceRuleBorrowed")
+ .hide_type("RawServoNamespaceRuleBorrowedOrNull")
+ .hide_type("RawServoNamespaceRule")
+ .hide_type("RawServoStyleSetOwned")
+ .hide_type("RawServoStyleSetOwnedOrNull")
+ .hide_type("RawServoStyleSetBorrowed")
+ .hide_type("RawServoStyleSetBorrowedOrNull")
+ .hide_type("RawServoStyleSetBorrowedMut")
+ .hide_type("RawServoStyleSetBorrowedMutOrNull")
+ .hide_type("RawServoStyleSet")
+ .hide_type("StyleChildrenIteratorOwned")
+ .hide_type("StyleChildrenIteratorOwnedOrNull")
+ .hide_type("StyleChildrenIteratorBorrowed")
+ .hide_type("StyleChildrenIteratorBorrowedOrNull")
+ .hide_type("StyleChildrenIteratorBorrowedMut")
+ .hide_type("StyleChildrenIteratorBorrowedMutOrNull")
+ .hide_type("StyleChildrenIterator")
+ .hide_type("ServoElementSnapshotOwned")
+ .hide_type("ServoElementSnapshotOwnedOrNull")
+ .hide_type("ServoElementSnapshotBorrowed")
+ .hide_type("ServoElementSnapshotBorrowedOrNull")
+ .hide_type("ServoElementSnapshotBorrowedMut")
+ .hide_type("ServoElementSnapshotBorrowedMutOrNull")
+ .hide_type("RawGeckoNodeBorrowed")
+ .hide_type("RawGeckoNodeBorrowedOrNull")
+ .hide_type("RawGeckoElementBorrowed")
+ .hide_type("RawGeckoElementBorrowedOrNull")
+ .hide_type("RawGeckoDocumentBorrowed")
+ .hide_type("RawGeckoDocumentBorrowedOrNull")
+ .hide_type("RawServoDeclarationBlockStrongBorrowed")
+ .hide_type("RawServoDeclarationBlockStrongBorrowedOrNull")
+ .hide_type("RawGeckoPresContextBorrowed")
+ .hide_type("RawGeckoPresContextBorrowedOrNull")
+ .hide_type("RawGeckoStyleAnimationListBorrowed")
+ .hide_type("RawGeckoStyleAnimationListBorrowedOrNull")
+ .hide_type("nsCSSValueBorrowed")
+ .hide_type("nsCSSValueBorrowedOrNull")
+ .hide_type("nsCSSValueBorrowedMut")
+ .hide_type("nsCSSValueBorrowedMutOrNull")
+ .hide_type("nsTimingFunctionBorrowed")
+ .hide_type("nsTimingFunctionBorrowedOrNull")
+ .hide_type("nsTimingFunctionBorrowedMut")
+ .hide_type("nsTimingFunctionBorrowedMutOrNull")
+ .hide_type("RawGeckoAnimationPropertySegmentBorrowed")
+ .hide_type("RawGeckoAnimationPropertySegmentBorrowedOrNull")
+ .hide_type("RawGeckoAnimationPropertySegmentBorrowedMut")
+ .hide_type("RawGeckoAnimationPropertySegmentBorrowedMutOrNull")
+ .hide_type("RawGeckoAnimationValueListBorrowed")
+ .hide_type("RawGeckoAnimationValueListBorrowedOrNull")
+ .hide_type("RawGeckoAnimationValueListBorrowedMut")
+ .hide_type("RawGeckoAnimationValueListBorrowedMutOrNull")
+ .hide_type("RawGeckoComputedTimingBorrowed")
+ .hide_type("RawGeckoComputedTimingBorrowedOrNull")
+ .hide_type("RawGeckoComputedTimingBorrowedMut")
+ .hide_type("RawGeckoComputedTimingBorrowedMutOrNull")
+ .hide_type("RawGeckoKeyframeListBorrowed")
+ .hide_type("RawGeckoKeyframeListBorrowedOrNull")
+ .hide_type("RawGeckoKeyframeListBorrowedMut")
+ .hide_type("RawGeckoKeyframeListBorrowedMutOrNull")
+ .hide_type("RawGeckoComputedKeyframeValuesListBorrowed")
+ .hide_type("RawGeckoComputedKeyframeValuesListBorrowedOrNull")
+ .hide_type("RawGeckoComputedKeyframeValuesListBorrowedMut")
+ .hide_type("RawGeckoComputedKeyframeValuesListBorrowedMutOrNull")
+ .hide_type("RawGeckoFontFaceRuleListBorrowed")
+ .hide_type("RawGeckoFontFaceRuleListBorrowedOrNull")
+ .hide_type("RawGeckoFontFaceRuleListBorrowedMut")
+ .hide_type("RawGeckoFontFaceRuleListBorrowedMutOrNull")
+ .raw_line(r#"pub use nsstring::{nsACString, nsAString, nsString};"#)
+ .raw_line(r#"type nsACString_internal = nsACString;"#)
+ .raw_line(r#"type nsAString_internal = nsAString;"#)
+ .raw_line(r#"use gecko_bindings::structs::mozilla::css::URLValue;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoAnimationPropertySegment;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoComputedTiming;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoDocument;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoElement;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoKeyframeList;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoComputedKeyframeValuesList;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoFontFaceRuleList;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoNode;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoAnimationValueList;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawServoAnimationValue;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawServoAnimationValueMap;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawServoDeclarationBlock;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoPresContext;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoPresContextOwned;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoStyleAnimationList;"#)
+ .raw_line(r#"use gecko_bindings::structs::RawGeckoURLExtraData;"#)
+ .raw_line(r#"use gecko_bindings::structs::RefPtr;"#)
+ .raw_line(r#"use gecko_bindings::structs::CSSPseudoClassType;"#)
+ .raw_line(r#"use gecko_bindings::structs::TraversalRootBehavior;"#)
+ .raw_line(r#"use gecko_bindings::structs::ComputedTimingFunction_BeforeFlag;"#)
+ .raw_line(r#"use gecko_bindings::structs::FontFamilyList;"#)
+ .raw_line(r#"use gecko_bindings::structs::FontFamilyType;"#)
+ .raw_line(r#"use gecko_bindings::structs::Keyframe;"#)
+ .raw_line(r#"use gecko_bindings::structs::ServoBundledURI;"#)
+ .raw_line(r#"use gecko_bindings::structs::ServoElementSnapshot;"#)
+ .raw_line(r#"use gecko_bindings::structs::SheetParsingMode;"#)
+ .raw_line(r#"use gecko_bindings::structs::StyleBasicShape;"#)
+ .raw_line(r#"use gecko_bindings::structs::StyleBasicShapeType;"#)
+ .raw_line(r#"use gecko_bindings::structs::StyleShapeSource;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSFontFaceRule;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSKeyword;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSPropertyID;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSShadowArray;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSUnit;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSValue;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCSSValueSharedList;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsChangeHint;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsCursorImage;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsFont;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsIAtom;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsMediaFeature;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsRestyleHint;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleBackground;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleBackground {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleBackground {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleBorder;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleBorder {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleBorder {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleColor;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleColor {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleColor {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleColumn;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleColumn {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleColumn {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleContent;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleContent {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleContent {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleContentData;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleContentData {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleContentData {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleContentType;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleContentType {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleContentType {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleContext;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleContext {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleContext {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleCoord;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleCoord {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleCoord {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleCoord_Calc;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleCoord_Calc {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleCoord_Calc {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleCoord_CalcValue;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleCoord_CalcValue {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleCoord_CalcValue {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleDisplay;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleDisplay {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleDisplay {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleEffects;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleEffects {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleEffects {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleFilter;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleFilter {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleFilter {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleFont;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleFont {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleFont {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleGradient;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleGradient {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleGradient {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleGradientStop;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleGradientStop {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleGradientStop {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleImage;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleImage {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleImage {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleImageLayers;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleImageLayers {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleImageLayers {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleImageLayers_Layer;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleImageLayers_Layer {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleImageLayers_Layer {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleImageLayers_LayerType;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleImageLayers_LayerType {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleImageLayers_LayerType {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleImageRequest;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleImageRequest {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleImageRequest {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleList;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleList {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleList {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleMargin;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleMargin {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleMargin {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleOutline;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleOutline {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleOutline {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStylePadding;"#)
+ .raw_line(r#"unsafe impl Send for nsStylePadding {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStylePadding {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStylePosition;"#)
+ .raw_line(r#"unsafe impl Send for nsStylePosition {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStylePosition {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleQuoteValues;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleQuoteValues {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleQuoteValues {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleSVG;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleSVG {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleSVG {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleSVGPaint;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleSVGPaint {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleSVGPaint {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleSVGReset;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleSVGReset {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleSVGReset {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleTable;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleTable {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleTable {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleTableBorder;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleTableBorder {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleTableBorder {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleText;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleText {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleText {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleTextReset;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleTextReset {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleTextReset {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleUIReset;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleUIReset {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleUIReset {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleUnion;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleUnion {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleUnion {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleUnit;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleUnit {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleUnit {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleUserInterface;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleUserInterface {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleUserInterface {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleVariables;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleVariables {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleVariables {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleVisibility;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleVisibility {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleVisibility {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsStyleXUL;"#)
+ .raw_line(r#"unsafe impl Send for nsStyleXUL {}"#)
+ .raw_line(r#"unsafe impl Sync for nsStyleXUL {}"#)
+ .raw_line(r#"use gecko_bindings::structs::nsTimingFunction;"#)
+ .raw_line(r#"use gecko_bindings::structs::nscolor;"#)
+ .raw_line(r#"use gecko_bindings::structs::nscoord;"#)
+ .raw_line(r#"use gecko_bindings::structs::nsresult;"#)
+ .raw_line(r#"use gecko_bindings::structs::Loader;"#)
+ .raw_line(r#"use gecko_bindings::structs::ServoStyleSheet;"#)
+ .raw_line(r#"use gecko_bindings::structs::EffectCompositor_CascadeLevel;"#)
+ .raw_line(r#"use gecko_bindings::structs::UpdateAnimationsTasks;"#)
+ .raw_line(r#"pub type nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>;"#)
+ .raw_line(r#"pub type ServoCssRulesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoCssRules>;"#)
+ .raw_line(r#"pub type ServoCssRulesBorrowed<'a> = &'a ServoCssRules;"#)
+ .raw_line(r#"pub type ServoCssRulesBorrowedOrNull<'a> = Option<&'a ServoCssRules>;"#)
+ .raw_line(r#"enum ServoCssRulesVoid { }"#)
+ .raw_line(r#"pub struct ServoCssRules(ServoCssRulesVoid);"#)
+ .raw_line(r#"pub type RawServoStyleSheetStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleSheet>;"#)
+ .raw_line(r#"pub type RawServoStyleSheetBorrowed<'a> = &'a RawServoStyleSheet;"#)
+ .raw_line(r#"pub type RawServoStyleSheetBorrowedOrNull<'a> = Option<&'a RawServoStyleSheet>;"#)
+ .raw_line(r#"enum RawServoStyleSheetVoid { }"#)
+ .raw_line(r#"pub struct RawServoStyleSheet(RawServoStyleSheetVoid);"#)
+ .raw_line(r#"pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;"#)
+ .raw_line(r#"pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;"#)
+ .raw_line(r#"pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;"#)
+ .raw_line(r#"enum ServoComputedValuesVoid { }"#)
+ .raw_line(r#"pub struct ServoComputedValues(ServoComputedValuesVoid);"#)
+ .raw_line(r#"pub type RawServoDeclarationBlockStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoDeclarationBlock>;"#)
+ .raw_line(r#"pub type RawServoDeclarationBlockBorrowed<'a> = &'a RawServoDeclarationBlock;"#)
+ .raw_line(r#"pub type RawServoDeclarationBlockBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlock>;"#)
+ .raw_line(r#"pub type RawServoStyleRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoStyleRule>;"#)
+ .raw_line(r#"pub type RawServoStyleRuleBorrowed<'a> = &'a RawServoStyleRule;"#)
+ .raw_line(r#"pub type RawServoStyleRuleBorrowedOrNull<'a> = Option<&'a RawServoStyleRule>;"#)
+ .raw_line(r#"enum RawServoStyleRuleVoid { }"#)
+ .raw_line(r#"pub struct RawServoStyleRule(RawServoStyleRuleVoid);"#)
+ .raw_line(r#"pub type RawServoImportRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoImportRule>;"#)
+ .raw_line(r#"pub type RawServoImportRuleBorrowed<'a> = &'a RawServoImportRule;"#)
+ .raw_line(r#"pub type RawServoImportRuleBorrowedOrNull<'a> = Option<&'a RawServoImportRule>;"#)
+ .raw_line(r#"enum RawServoImportRuleVoid { }"#)
+ .raw_line(r#"pub struct RawServoImportRule(RawServoImportRuleVoid);"#)
+ .raw_line(r#"pub type RawServoAnimationValueStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoAnimationValue>;"#)
+ .raw_line(r#"pub type RawServoAnimationValueBorrowed<'a> = &'a RawServoAnimationValue;"#)
+ .raw_line(r#"pub type RawServoAnimationValueBorrowedOrNull<'a> = Option<&'a RawServoAnimationValue>;"#)
+ .raw_line(r#"pub type RawServoAnimationValueMapStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoAnimationValueMap>;"#)
+ .raw_line(r#"pub type RawServoAnimationValueMapBorrowed<'a> = &'a RawServoAnimationValueMap;"#)
+ .raw_line(r#"pub type RawServoAnimationValueMapBorrowedOrNull<'a> = Option<&'a RawServoAnimationValueMap>;"#)
+ .raw_line(r#"pub type RawServoMediaListStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoMediaList>;"#)
+ .raw_line(r#"pub type RawServoMediaListBorrowed<'a> = &'a RawServoMediaList;"#)
+ .raw_line(r#"pub type RawServoMediaListBorrowedOrNull<'a> = Option<&'a RawServoMediaList>;"#)
+ .raw_line(r#"enum RawServoMediaListVoid { }"#)
+ .raw_line(r#"pub struct RawServoMediaList(RawServoMediaListVoid);"#)
+ .raw_line(r#"pub type RawServoMediaRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoMediaRule>;"#)
+ .raw_line(r#"pub type RawServoMediaRuleBorrowed<'a> = &'a RawServoMediaRule;"#)
+ .raw_line(r#"pub type RawServoMediaRuleBorrowedOrNull<'a> = Option<&'a RawServoMediaRule>;"#)
+ .raw_line(r#"enum RawServoMediaRuleVoid { }"#)
+ .raw_line(r#"pub struct RawServoMediaRule(RawServoMediaRuleVoid);"#)
+ .raw_line(r#"pub type RawServoNamespaceRuleStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoNamespaceRule>;"#)
+ .raw_line(r#"pub type RawServoNamespaceRuleBorrowed<'a> = &'a RawServoNamespaceRule;"#)
+ .raw_line(r#"pub type RawServoNamespaceRuleBorrowedOrNull<'a> = Option<&'a RawServoNamespaceRule>;"#)
+ .raw_line(r#"enum RawServoNamespaceRuleVoid { }"#)
+ .raw_line(r#"pub struct RawServoNamespaceRule(RawServoNamespaceRuleVoid);"#)
+ .raw_line(r#"pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;"#)
+ .raw_line(r#"pub type RawServoStyleSetOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<RawServoStyleSet>;"#)
+ .raw_line(r#"pub type RawServoStyleSetBorrowed<'a> = &'a RawServoStyleSet;"#)
+ .raw_line(r#"pub type RawServoStyleSetBorrowedOrNull<'a> = Option<&'a RawServoStyleSet>;"#)
+ .raw_line(r#"pub type RawServoStyleSetBorrowedMut<'a> = &'a mut RawServoStyleSet;"#)
+ .raw_line(r#"pub type RawServoStyleSetBorrowedMutOrNull<'a> = Option<&'a mut RawServoStyleSet>;"#)
+ .raw_line(r#"enum RawServoStyleSetVoid { }"#)
+ .raw_line(r#"pub struct RawServoStyleSet(RawServoStyleSetVoid);"#)
+ .raw_line(r#"pub type StyleChildrenIteratorOwned = ::gecko_bindings::sugar::ownership::Owned<StyleChildrenIterator>;"#)
+ .raw_line(r#"pub type StyleChildrenIteratorOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<StyleChildrenIterator>;"#)
+ .raw_line(r#"pub type StyleChildrenIteratorBorrowed<'a> = &'a StyleChildrenIterator;"#)
+ .raw_line(r#"pub type StyleChildrenIteratorBorrowedOrNull<'a> = Option<&'a StyleChildrenIterator>;"#)
+ .raw_line(r#"pub type StyleChildrenIteratorBorrowedMut<'a> = &'a mut StyleChildrenIterator;"#)
+ .raw_line(r#"pub type StyleChildrenIteratorBorrowedMutOrNull<'a> = Option<&'a mut StyleChildrenIterator>;"#)
+ .raw_line(r#"enum StyleChildrenIteratorVoid { }"#)
+ .raw_line(r#"pub struct StyleChildrenIterator(StyleChildrenIteratorVoid);"#)
+ .raw_line(r#"pub type ServoElementSnapshotOwned = ::gecko_bindings::sugar::ownership::Owned<ServoElementSnapshot>;"#)
+ .raw_line(r#"pub type ServoElementSnapshotOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<ServoElementSnapshot>;"#)
+ .raw_line(r#"pub type ServoElementSnapshotBorrowed<'a> = &'a ServoElementSnapshot;"#)
+ .raw_line(r#"pub type ServoElementSnapshotBorrowedOrNull<'a> = Option<&'a ServoElementSnapshot>;"#)
+ .raw_line(r#"pub type ServoElementSnapshotBorrowedMut<'a> = &'a mut ServoElementSnapshot;"#)
+ .raw_line(r#"pub type ServoElementSnapshotBorrowedMutOrNull<'a> = Option<&'a mut ServoElementSnapshot>;"#)
+ .raw_line(r#"pub type RawGeckoNodeBorrowed<'a> = &'a RawGeckoNode;"#)
+ .raw_line(r#"pub type RawGeckoNodeBorrowedOrNull<'a> = Option<&'a RawGeckoNode>;"#)
+ .raw_line(r#"pub type RawGeckoElementBorrowed<'a> = &'a RawGeckoElement;"#)
+ .raw_line(r#"pub type RawGeckoElementBorrowedOrNull<'a> = Option<&'a RawGeckoElement>;"#)
+ .raw_line(r#"pub type RawGeckoDocumentBorrowed<'a> = &'a RawGeckoDocument;"#)
+ .raw_line(r#"pub type RawGeckoDocumentBorrowedOrNull<'a> = Option<&'a RawGeckoDocument>;"#)
+ .raw_line(r#"pub type RawServoDeclarationBlockStrongBorrowed<'a> = &'a RawServoDeclarationBlockStrong;"#)
+ .raw_line(r#"pub type RawServoDeclarationBlockStrongBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlockStrong>;"#)
+ .raw_line(r#"pub type RawGeckoPresContextBorrowed<'a> = &'a RawGeckoPresContext;"#)
+ .raw_line(r#"pub type RawGeckoPresContextBorrowedOrNull<'a> = Option<&'a RawGeckoPresContext>;"#)
+ .raw_line(r#"pub type RawGeckoStyleAnimationListBorrowed<'a> = &'a RawGeckoStyleAnimationList;"#)
+ .raw_line(r#"pub type RawGeckoStyleAnimationListBorrowedOrNull<'a> = Option<&'a RawGeckoStyleAnimationList>;"#)
+ .raw_line(r#"pub type nsCSSValueBorrowed<'a> = &'a nsCSSValue;"#)
+ .raw_line(r#"pub type nsCSSValueBorrowedOrNull<'a> = Option<&'a nsCSSValue>;"#)
+ .raw_line(r#"pub type nsCSSValueBorrowedMut<'a> = &'a mut nsCSSValue;"#)
+ .raw_line(r#"pub type nsCSSValueBorrowedMutOrNull<'a> = Option<&'a mut nsCSSValue>;"#)
+ .raw_line(r#"pub type nsTimingFunctionBorrowed<'a> = &'a nsTimingFunction;"#)
+ .raw_line(r#"pub type nsTimingFunctionBorrowedOrNull<'a> = Option<&'a nsTimingFunction>;"#)
+ .raw_line(r#"pub type nsTimingFunctionBorrowedMut<'a> = &'a mut nsTimingFunction;"#)
+ .raw_line(r#"pub type nsTimingFunctionBorrowedMutOrNull<'a> = Option<&'a mut nsTimingFunction>;"#)
+ .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowed<'a> = &'a RawGeckoAnimationPropertySegment;"#)
+ .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationPropertySegment>;"#)
+ .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowedMut<'a> = &'a mut RawGeckoAnimationPropertySegment;"#)
+ .raw_line(r#"pub type RawGeckoAnimationPropertySegmentBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationPropertySegment>;"#)
+ .raw_line(r#"pub type RawGeckoAnimationValueListBorrowed<'a> = &'a RawGeckoAnimationValueList;"#)
+ .raw_line(r#"pub type RawGeckoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationValueList>;"#)
+ .raw_line(r#"pub type RawGeckoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoAnimationValueList;"#)
+ .raw_line(r#"pub type RawGeckoAnimationValueListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationValueList>;"#)
+ .raw_line(r#"pub type RawGeckoComputedTimingBorrowed<'a> = &'a RawGeckoComputedTiming;"#)
+ .raw_line(r#"pub type RawGeckoComputedTimingBorrowedOrNull<'a> = Option<&'a RawGeckoComputedTiming>;"#)
+ .raw_line(r#"pub type RawGeckoComputedTimingBorrowedMut<'a> = &'a mut RawGeckoComputedTiming;"#)
+ .raw_line(r#"pub type RawGeckoComputedTimingBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoComputedTiming>;"#)
+ .raw_line(r#"pub type RawGeckoKeyframeListBorrowed<'a> = &'a RawGeckoKeyframeList;"#)
+ .raw_line(r#"pub type RawGeckoKeyframeListBorrowedOrNull<'a> = Option<&'a RawGeckoKeyframeList>;"#)
+ .raw_line(r#"pub type RawGeckoKeyframeListBorrowedMut<'a> = &'a mut RawGeckoKeyframeList;"#)
+ .raw_line(r#"pub type RawGeckoKeyframeListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoKeyframeList>;"#)
+ .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowed<'a> = &'a RawGeckoComputedKeyframeValuesList;"#)
+ .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowedOrNull<'a> = Option<&'a RawGeckoComputedKeyframeValuesList>;"#)
+ .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowedMut<'a> = &'a mut RawGeckoComputedKeyframeValuesList;"#)
+ .raw_line(r#"pub type RawGeckoComputedKeyframeValuesListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoComputedKeyframeValuesList>;"#)
+ .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowed<'a> = &'a RawGeckoFontFaceRuleList;"#)
+ .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowedOrNull<'a> = Option<&'a RawGeckoFontFaceRuleList>;"#)
+ .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowedMut<'a> = &'a mut RawGeckoFontFaceRuleList;"#)
+ .raw_line(r#"pub type RawGeckoFontFaceRuleListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoFontFaceRuleList>;"#)
+ .clang_arg("-x")
+ .clang_arg("c++")
+ .clang_arg("-std=c++14")
+ .clang_arg("-DTRACING=1")
+ .clang_arg("-DIMPL_LIBXUL")
+ .clang_arg("-DMOZ_STYLO_BINDINGS=1")
+ .clang_arg("-DMOZILLA_INTERNAL_API")
+ .clang_arg("-DRUST_BINDGEN")
+ .clang_arg("-DMOZ_STYLO")
+ .clang_arg("-DOS_POSIX=1")
+ .clang_arg("-DOS_LINUX=1")
+ .generate()
.expect("Should generate stylo bindings");
let now = Instant::now();
diff --git a/tests/test-one.sh b/tests/test-one.sh
index 50950a59..91da55b1 100755
--- a/tests/test-one.sh
+++ b/tests/test-one.sh
@@ -45,7 +45,7 @@ TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXXX)
FLAGS="$(grep "// bindgen-flags: " "$TEST" || echo)"
FLAGS="${FLAGS/\/\/ bindgen\-flags:/}"
# Prepend the default flags added in test.rs's `create_bindgen_builder`.
-FLAGS="--with-derive-default --raw-line '' --raw-line '#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]' --raw-line '' $FLAGS"
+FLAGS="--rustfmt-bindings --with-derive-default --raw-line '' --raw-line '#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]' --raw-line '' $FLAGS"
eval ./target/debug/bindgen \
@@ -56,6 +56,8 @@ eval ./target/debug/bindgen \
-o "\"$BINDINGS\"" \
$FLAGS
+rustup run nightly rustfmt "$BINDINGS" || true
+
dot -Tpng ir.dot -o ir.png
echo
@@ -78,6 +80,8 @@ EXPECTED=${TEST/headers/expectations\/tests}
EXPECTED=${EXPECTED/.hpp/.rs}
EXPECTED=${EXPECTED/.h/.rs}
+rustup run nightly rustfmt "$EXPECTED" || true
+
# Don't exit early if there is a diff.
diff -U8 "$EXPECTED" "$BINDINGS" || true
diff --git a/tests/tests.rs b/tests/tests.rs
index 01f46ac6..1e02da2d 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -5,42 +5,123 @@ extern crate shlex;
use bindgen::{Builder, builder, clang_version};
use std::fs;
-use std::io::{BufRead, BufReader, Error, ErrorKind, Read, Write};
+use std::io::{self, BufRead, BufReader, Error, ErrorKind, Read, Write};
use std::path::PathBuf;
+use std::process;
+use std::sync::{Once, ONCE_INIT};
#[path = "../src/options.rs"]
mod options;
use options::builder_from_flags;
+// Run `rustfmt` on the given source string and return a tuple of the formatted
+// bindings, and rustfmt's stderr.
+fn rustfmt(source: String) -> (String, String) {
+ static CHECK_RUSTFMT: Once = ONCE_INIT;
+
+ CHECK_RUSTFMT.call_once(|| {
+ let have_working_rustfmt = process::Command::new("rustup")
+ .args(&["run", "nightly", "rustfmt", "--version"])
+ .stdout(process::Stdio::null())
+ .stderr(process::Stdio::null())
+ .status()
+ .ok()
+ .map_or(false, |status| status.success());
+
+ if !have_working_rustfmt {
+ panic!("
+The latest `rustfmt` is required to run the `bindgen` test suite. Install
+`rustfmt` with:
+
+ $ rustup update nightly
+ $ rustup run nightly cargo install -f rustfmt-nightly
+");
+ }
+ });
+
+ let mut child = process::Command::new("rustup")
+ .args(&[
+ "run",
+ "nightly",
+ "rustfmt",
+ "--config-path",
+ concat!(env!("CARGO_MANIFEST_DIR"), "/tests/rustfmt.toml")
+ ])
+ .stdin(process::Stdio::piped())
+ .stdout(process::Stdio::piped())
+ .stderr(process::Stdio::piped())
+ .spawn()
+ .expect("should spawn `rustup run nightly rustfmt`");
+
+ let mut stdin = child.stdin.take().unwrap();
+ let mut stdout = child.stdout.take().unwrap();
+ let mut stderr = child.stderr.take().unwrap();
+
+ // Write to stdin in a new thread, so that we can read from stdout on this
+ // thread. This keeps the child from blocking on writing to its stdout which
+ // might block us from writing to its stdin.
+ let stdin_handle = ::std::thread::spawn(move || {
+ stdin.write_all(source.as_bytes())
+ });
+
+ // Read stderr on a new thread for similar reasons.
+ let stderr_handle = ::std::thread::spawn(move || {
+ let mut output = vec![];
+ io::copy(&mut stderr, &mut output)
+ .map(|_| String::from_utf8_lossy(&output).to_string())
+ });
+
+ let mut output = vec![];
+ io::copy(&mut stdout, &mut output)
+ .expect("Should copy stdout into vec OK");
+
+ // Ignore actual rustfmt status because it is often non-zero for trivial
+ // things.
+ let _ = child.wait().expect("should wait on rustfmt child OK");
+
+ stdin_handle.join()
+ .expect("writer thread should not have panicked")
+ .expect("should have written to child rustfmt's stdin OK");
+
+ let bindings = String::from_utf8(output)
+ .expect("rustfmt should only emit valid utf-8");
+
+ let stderr = stderr_handle.join()
+ .expect("stderr reader thread should not have panicked")
+ .expect("should have read child rustfmt's stderr OK");
+
+ (bindings, stderr)
+}
+
fn compare_generated_header(
header: &PathBuf,
builder: Builder,
) -> Result<(), Error> {
let file_name = try!(header.file_name().ok_or(Error::new(
ErrorKind::Other,
- "spawn_bindgen expects a file",
+ "compare_generated_header expects a file",
)));
- let mut expected = PathBuf::from(header);
- expected.pop();
- expected.pop();
- expected.push("expectations");
- expected.push("tests");
- expected.push(file_name);
- expected.set_extension("rs");
+ let mut expectation = PathBuf::from(header);
+ expectation.pop();
+ expectation.pop();
+ expectation.push("expectations");
+ expectation.push("tests");
+ expectation.push(file_name);
+ expectation.set_extension("rs");
// If the expectation file doesn't exist, see if we have different test
// expectations for different libclang versions.
- if !expected.is_file() {
- let file_name = expected.file_name().unwrap().to_owned();
- expected.pop();
+ if !expectation.is_file() {
+ let file_name = expectation.file_name().unwrap().to_owned();
+ expectation.pop();
if cfg!(feature = "testing_only_libclang_4") {
- expected.push("libclang-4");
+ expectation.push("libclang-4");
} else if cfg!(feature = "testing_only_libclang_3_9") {
- expected.push("libclang-3.9");
+ expectation.push("libclang-3.9");
} else if cfg!(feature = "testing_only_libclang_3_8") {
- expected.push("libclang-3.8");
+ expectation.push("libclang-3.8");
} else {
match clang_version().parsed {
None => {}
@@ -51,38 +132,45 @@ fn compare_generated_header(
} else {
format!("{}.{}", maj, min)
};
- expected.push(format!("libclang-{}", version_str));
+ expectation.push(format!("libclang-{}", version_str));
}
}
}
- expected.push(file_name);
+ expectation.push(file_name);
- if !expected.is_file() {
+ if !expectation.is_file() {
panic!(
"missing test expectation file and/or 'testing_only_libclang_$VERSION' \
feature for header '{}'; looking for expectation file at '{}'",
header.display(),
- expected.display()
+ expectation.display()
);
}
}
// We skip the generate() error here so we get a full diff below
- let output = match builder.generate() {
- Ok(bindings) => bindings.to_string(),
- Err(_) => "".to_string(),
+ let (actual, rustfmt_stderr) = match builder.generate() {
+ Ok(bindings) => {
+ let actual = bindings.to_string();
+ rustfmt(actual)
+ }
+ Err(()) => ("<error generating bindings>".to_string(), "".to_string()),
};
+ println!("{}", rustfmt_stderr);
- let mut buffer = String::new();
+ let mut expected = String::new();
{
- if let Ok(expected_file) = fs::File::open(&expected) {
- try!(BufReader::new(expected_file).read_to_string(&mut buffer));
+ if let Ok(expectation_file) = fs::File::open(&expectation) {
+ try!(BufReader::new(expectation_file).read_to_string(&mut expected));
}
}
- if output == buffer {
- if !output.is_empty() {
+ let (expected, rustfmt_stderr) = rustfmt(expected);
+ println!("{}", rustfmt_stderr);
+
+ if actual == expected {
+ if !actual.is_empty() {
return Ok(());
}
return Err(Error::new(
@@ -91,11 +179,13 @@ fn compare_generated_header(
));
}
+ println!("{}", rustfmt_stderr);
+
println!("diff expected generated");
- println!("--- expected: {:?}", expected);
+ println!("--- expected: {:?}", expectation);
println!("+++ generated from: {:?}", header);
- for diff in diff::lines(&buffer, &output) {
+ for diff in diff::lines(&expected, &actual) {
match diff {
diff::Result::Left(l) => println!("-{}", l),
diff::Result::Both(l, _) => println!(" {}", l),
@@ -105,8 +195,8 @@ fn compare_generated_header(
// Override the diff.
{
- let mut expected_file = try!(fs::File::create(&expected));
- try!(expected_file.write_all(output.as_bytes()));
+ let mut expectation_file = try!(fs::File::create(&expectation));
+ try!(expectation_file.write_all(actual.as_bytes()));
}
Err(Error::new(ErrorKind::Other, "Header and binding differ!"))
@@ -215,19 +305,25 @@ include!(concat!(env!("OUT_DIR"), "/tests.rs"));
#[test]
fn test_header_contents() {
- let bindings = builder()
+ let actual = builder()
.header_contents("test.h", "int foo(const char* a);")
.generate()
.unwrap()
.to_string();
- assert_eq!(
- bindings,
- "/* automatically generated by rust-bindgen */
+
+ let (actual, stderr) = rustfmt(actual);
+ println!("{}", stderr);
+
+ let (expected, _) = rustfmt("/* automatically generated by rust-bindgen */
extern \"C\" {
pub fn foo(a: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
}
-"
+".to_string());
+
+ assert_eq!(
+ expected,
+ actual
);
}
@@ -243,10 +339,14 @@ fn test_multiple_header_calls_in_builder() {
.unwrap()
.to_string();
+ let (actual, stderr) = rustfmt(actual);
+ println!("{}", stderr);
+
let expected = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/expectations/tests/test_multiple_header_calls_in_builder.rs"
));
+ let (expected, _) = rustfmt(expected.to_string());
if actual != expected {
println!("Generated bindings differ from expected!");