summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock311
-rw-r--r--Cargo.toml7
-rw-r--r--LICENSE43
-rw-r--r--bindgen-integration/cpp/Test.h6
-rw-r--r--book/src/tutorial-1.md2
-rwxr-xr-xci/deploy-book.sh2
-rwxr-xr-xci/test-book.sh2
-rw-r--r--src/clang.rs41
-rwxr-xr-xsrc/codegen/bitfield_unit.rs33
-rw-r--r--src/codegen/helpers.rs61
-rw-r--r--src/codegen/impl_debug.rs51
-rw-r--r--src/codegen/impl_partialeq.rs11
-rw-r--r--src/codegen/mod.rs334
-rw-r--r--src/codegen/struct_layout.rs19
-rw-r--r--src/features.rs122
-rw-r--r--src/ir/analysis/derive_copy.rs7
-rw-r--r--src/ir/analysis/derive_debug.rs11
-rw-r--r--src/ir/analysis/derive_default.rs9
-rw-r--r--src/ir/analysis/derive_hash.rs24
-rw-r--r--src/ir/analysis/derive_partialeq_or_partialord.rs21
-rw-r--r--src/ir/analysis/has_float.rs12
-rw-r--r--src/ir/analysis/has_type_param_in_array.rs5
-rw-r--r--src/ir/analysis/sizedness.rs6
-rw-r--r--src/ir/comment.rs25
-rw-r--r--src/ir/context.rs130
-rw-r--r--src/ir/derive.rs20
-rw-r--r--src/ir/enum_ty.rs46
-rw-r--r--src/ir/function.rs34
-rw-r--r--src/ir/int.rs15
-rw-r--r--src/ir/item.rs45
-rw-r--r--src/ir/layout.rs65
-rw-r--r--src/ir/template.rs5
-rw-r--r--src/ir/traversal.rs10
-rw-r--r--src/ir/ty.rs88
-rw-r--r--src/ir/var.rs13
-rw-r--r--src/lib.rs218
-rw-r--r--src/options.rs55
-rw-r--r--src/regex_set.rs3
-rw-r--r--tests/expectations/Cargo.toml1
-rw-r--r--tests/expectations/tests/16-byte-alignment_1_0.rs2
-rw-r--r--tests/expectations/tests/anon_enum_trait.rs7
-rw-r--r--tests/expectations/tests/anon_struct_in_union_1_0.rs2
-rw-r--r--tests/expectations/tests/anon_union.rs12
-rw-r--r--tests/expectations/tests/anon_union_1_0.rs2
-rw-r--r--tests/expectations/tests/bitfield-32bit-overflow.rs29
-rw-r--r--tests/expectations/tests/bitfield-large.rs31
-rw-r--r--tests/expectations/tests/bitfield-method-same-name.rs31
-rw-r--r--tests/expectations/tests/bitfield_align.rs29
-rw-r--r--tests/expectations/tests/bitfield_align_2.rs29
-rw-r--r--tests/expectations/tests/bitfield_method_mangling.rs31
-rw-r--r--tests/expectations/tests/blacklist-and-impl-debug.rs2
-rw-r--r--tests/expectations/tests/blacklist-function.rs26
-rw-r--r--tests/expectations/tests/blacklist-item.rs26
-rw-r--r--tests/expectations/tests/blocks-signature.rs24
-rw-r--r--tests/expectations/tests/blocks.rs17
-rw-r--r--tests/expectations/tests/call-conv-typedef.rs13
-rw-r--r--tests/expectations/tests/class.rs2
-rw-r--r--tests/expectations/tests/class_1_0.rs4
-rw-r--r--tests/expectations/tests/class_with_inner_struct_1_0.rs2
-rw-r--r--tests/expectations/tests/constify-enum.rs14
-rw-r--r--tests/expectations/tests/convert-cpp-comment-to-rust.rs15
-rw-r--r--tests/expectations/tests/convert-floats.rs11
-rw-r--r--tests/expectations/tests/default-enum-style-constified-module.rs18
-rw-r--r--tests/expectations/tests/derive-bitfield-method-same-name.rs31
-rw-r--r--tests/expectations/tests/derive-debug-bitfield-core.rs191
-rw-r--r--tests/expectations/tests/derive-debug-bitfield.rs33
-rw-r--r--tests/expectations/tests/derive-debug-function-pointer.rs2
-rw-r--r--tests/expectations/tests/derive-debug-generic.rs2
-rw-r--r--tests/expectations/tests/derive-debug-mangle-name.rs4
-rw-r--r--tests/expectations/tests/derive-debug-opaque-template-instantiation.rs2
-rw-r--r--tests/expectations/tests/derive-debug-opaque.rs4
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs2
-rw-r--r--tests/expectations/tests/derive-partialeq-bitfield.rs31
-rw-r--r--tests/expectations/tests/derive-partialeq-union_1_0.rs2
-rw-r--r--tests/expectations/tests/divide-by-zero-in-struct-layout.rs31
-rw-r--r--tests/expectations/tests/dupe-enum-variant-in-namespace.rs30
-rw-r--r--tests/expectations/tests/enum-doc-bitfield.rs11
-rw-r--r--tests/expectations/tests/enum-doc-mod.rs11
-rw-r--r--tests/expectations/tests/enum-doc-rusty.rs11
-rw-r--r--tests/expectations/tests/enum-doc.rs11
-rw-r--r--tests/expectations/tests/enum_dupe.rs11
-rw-r--r--tests/expectations/tests/enum_in_template_with_typedef.rs12
-rw-r--r--tests/expectations/tests/error-E0600-cannot-apply-unary-negation-to-u32.rs7
-rw-r--r--tests/expectations/tests/extern-const-struct.rs46
-rw-r--r--tests/expectations/tests/i128.rs49
-rw-r--r--tests/expectations/tests/issue-1034.rs31
-rw-r--r--tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs31
-rw-r--r--tests/expectations/tests/issue-1198-alias-rust-enum.rs15
-rw-r--r--tests/expectations/tests/issue-1291.rs8
-rw-r--r--tests/expectations/tests/issue-1350-attribute-overloadable.rs17
-rw-r--r--tests/expectations/tests/issue-1435.rs26
-rw-r--r--tests/expectations/tests/issue-493.rs2
-rw-r--r--tests/expectations/tests/issue-493_1_0.rs2
-rw-r--r--tests/expectations/tests/issue-511.rs11
-rw-r--r--tests/expectations/tests/issue-643-inner-struct.rs2
-rw-r--r--tests/expectations/tests/issue-739-pointer-wide-bitfield.rs29
-rw-r--r--tests/expectations/tests/issue-816.rs29
-rw-r--r--tests/expectations/tests/jsval_layout_opaque.rs29
-rw-r--r--tests/expectations/tests/jsval_layout_opaque_1_0.rs31
-rw-r--r--tests/expectations/tests/layout_align.rs52
-rw-r--r--tests/expectations/tests/layout_arp.rs17
-rw-r--r--tests/expectations/tests/layout_array.rs38
-rw-r--r--tests/expectations/tests/layout_array_too_long.rs51
-rw-r--r--tests/expectations/tests/layout_eth_conf.rs226
-rw-r--r--tests/expectations/tests/layout_eth_conf_1_0.rs228
-rw-r--r--tests/expectations/tests/layout_kni_mbuf.rs17
-rw-r--r--tests/expectations/tests/layout_large_align_field.rs77
-rw-r--r--tests/expectations/tests/layout_mbuf.rs94
-rw-r--r--tests/expectations/tests/layout_mbuf_1_0.rs96
-rw-r--r--tests/expectations/tests/libclang-3.8/abi_variadic_function.rs17
-rw-r--r--tests/expectations/tests/libclang-3.8/auto.rs2
-rw-r--r--tests/expectations/tests/libclang-3.8/const_bool.rs6
-rw-r--r--tests/expectations/tests/libclang-3.8/constant-evaluate.rs14
-rw-r--r--tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs10
-rw-r--r--tests/expectations/tests/libclang-3.9/abi_variadic_function.rs13
-rw-r--r--tests/expectations/tests/libclang-3.9/constant-evaluate.rs4
-rw-r--r--tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs10
-rw-r--r--tests/expectations/tests/libclang-4/abi_variadic_function.rs13
-rw-r--r--tests/expectations/tests/libclang-4/constant-evaluate.rs10
-rw-r--r--tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs10
-rw-r--r--tests/expectations/tests/libclang-5/abi_variadic_function.rs13
-rw-r--r--tests/expectations/tests/libclang-5/constant-evaluate.rs10
-rw-r--r--tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs10
-rw-r--r--tests/expectations/tests/long_double.rs33
-rw-r--r--tests/expectations/tests/macro_const.rs10
-rw-r--r--tests/expectations/tests/only_bitfields.rs31
-rw-r--r--tests/expectations/tests/ord-enum.rs25
-rw-r--r--tests/expectations/tests/prepend-enum-constified-variant.rs11
-rw-r--r--tests/expectations/tests/repr-align.rs9
-rw-r--r--tests/expectations/tests/sentry-defined-multiple-times.rs14
-rw-r--r--tests/expectations/tests/struct_with_anon_union_1_0.rs2
-rw-r--r--tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs2
-rw-r--r--tests/expectations/tests/struct_with_bitfields.rs29
-rw-r--r--tests/expectations/tests/struct_with_nesting_1_0.rs2
-rw-r--r--tests/expectations/tests/transform-op.rs236
-rw-r--r--tests/expectations/tests/typeref_1_0.rs2
-rw-r--r--tests/expectations/tests/union-align.rs39
-rw-r--r--tests/expectations/tests/union-in-ns_1_0.rs2
-rw-r--r--tests/expectations/tests/union_bitfield.rs31
-rw-r--r--tests/expectations/tests/union_bitfield_1_0.rs45
-rw-r--r--tests/expectations/tests/union_dtor_1_0.rs2
-rw-r--r--tests/expectations/tests/union_fields_1_0.rs2
-rw-r--r--tests/expectations/tests/union_template_1_0.rs2
-rw-r--r--tests/expectations/tests/union_with_anon_struct_1_0.rs2
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield.rs31
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs33
-rw-r--r--tests/expectations/tests/union_with_anon_union_1_0.rs2
-rw-r--r--tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs2
-rw-r--r--tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs2
-rw-r--r--tests/expectations/tests/union_with_big_member_1_0.rs2
-rw-r--r--tests/expectations/tests/union_with_nesting_1_0.rs2
-rw-r--r--tests/expectations/tests/use-core_1_0.rs2
-rw-r--r--tests/expectations/tests/vector.rs16
-rw-r--r--tests/expectations/tests/weird_bitfields.rs29
-rw-r--r--tests/expectations/tests/zero-sized-array.rs2
-rw-r--r--tests/headers/abi_variadic_function.hpp4
-rw-r--r--tests/headers/anon_enum.hpp2
-rw-r--r--tests/headers/anon_enum_trait.hpp2
-rw-r--r--tests/headers/anon_enum_whitelist.h2
-rw-r--r--tests/headers/anon_union.hpp2
-rw-r--r--tests/headers/anon_union_1_0.hpp2
-rw-r--r--tests/headers/bitfield-enum-basic.hpp2
-rw-r--r--tests/headers/bitfield_align_2.h2
-rw-r--r--tests/headers/blacklist-function.hpp11
-rw-r--r--tests/headers/blacklist-item.hpp21
-rw-r--r--tests/headers/blocks-signature.hpp4
-rw-r--r--tests/headers/blocks.h3
-rw-r--r--tests/headers/blocks.hpp16
-rw-r--r--tests/headers/call-conv-typedef.h5
-rw-r--r--tests/headers/class_with_inner_struct.hpp2
-rw-r--r--tests/headers/class_with_inner_struct_1_0.hpp2
-rw-r--r--tests/headers/const_enum_unnamed.hpp2
-rw-r--r--tests/headers/constant-evaluate.h3
-rw-r--r--tests/headers/constify-enum.h2
-rw-r--r--tests/headers/constify-module-enums-types.hpp4
-rw-r--r--tests/headers/default-enum-style-constified-module.h4
-rw-r--r--tests/headers/derive-debug-bitfield-core.hpp7
-rw-r--r--tests/headers/dupe-enum-variant-in-namespace.h10
-rw-r--r--tests/headers/enum.h2
-rw-r--r--tests/headers/enum_alias.hpp2
-rw-r--r--tests/headers/enum_and_vtable_mangling.hpp2
-rw-r--r--tests/headers/enum_dupe.h2
-rw-r--r--tests/headers/enum_explicit_type.hpp2
-rw-r--r--tests/headers/enum_in_template_with_typedef.hpp2
-rw-r--r--tests/headers/enum_negative.h2
-rw-r--r--tests/headers/enum_packed.h2
-rw-r--r--tests/headers/extern-const-struct.h5
-rw-r--r--tests/headers/forward-enum-decl.hpp2
-rw-r--r--tests/headers/func_ptr_in_struct.h2
-rw-r--r--tests/headers/i128.h6
-rw-r--r--tests/headers/issue-1350-attribute-overloadable.h2
-rw-r--r--tests/headers/issue-1435.hpp7
-rw-r--r--tests/headers/issue-372.hpp2
-rw-r--r--tests/headers/issue-410.hpp2
-rw-r--r--tests/headers/issue-493.hpp2
-rw-r--r--tests/headers/issue-493_1_0.hpp2
-rw-r--r--tests/headers/issue-569-non-type-template-params-causing-layout-test-failures.hpp2
-rw-r--r--tests/headers/issue-674-1.hpp2
-rw-r--r--tests/headers/issue-674-2.hpp2
-rw-r--r--tests/headers/issue-674-3.hpp2
-rw-r--r--tests/headers/issue-888-enum-var-decl-jump.hpp2
-rw-r--r--tests/headers/jsval_layout_opaque.hpp2
-rw-r--r--tests/headers/jsval_layout_opaque_1_0.hpp2
-rw-r--r--tests/headers/layout_array_too_long.h2
-rw-r--r--tests/headers/layout_cmdline_token.h4
-rw-r--r--tests/headers/layout_eth_conf.h2
-rw-r--r--tests/headers/layout_eth_conf_1_0.h2
-rw-r--r--tests/headers/layout_large_align_field.h2
-rw-r--r--tests/headers/long_double.h5
-rw-r--r--tests/headers/macro_const.h1
-rw-r--r--tests/headers/no-recursive-whitelisting.h2
-rw-r--r--tests/headers/no-std.h2
-rw-r--r--tests/headers/nsStyleAutoArray.hpp2
-rw-r--r--tests/headers/opaque-tracing.hpp2
-rw-r--r--tests/headers/ord-enum.h15
-rw-r--r--tests/headers/overflowed_enum.hpp2
-rw-r--r--tests/headers/prepend-enum-constified-variant.h2
-rw-r--r--tests/headers/short-enums.hpp2
-rw-r--r--tests/headers/struct_typedef.h2
-rw-r--r--tests/headers/struct_typedef_ns.hpp2
-rw-r--r--tests/headers/transform-op.hpp75
-rw-r--r--tests/headers/union-align.h5
-rw-r--r--tests/headers/vector.hpp6
-rw-r--r--tests/headers/weird_bitfields.hpp2
-rw-r--r--tests/quickchecking/src/fuzzers.rs30
225 files changed, 3694 insertions, 1432 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f5ac0e9b..71b41347 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,109 +1,112 @@
[[package]]
name = "aho-corasick"
-version = "0.6.4"
+version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ansi_term"
-version = "0.9.0"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "atty"
-version = "0.2.2"
+version = "0.2.11"
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)",
- "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bindgen"
-version = "0.37.2"
+version = "0.43.1"
dependencies = [
- "cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "clang-sys 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "clang-sys 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "proc-macro2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "which 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bitflags"
-version = "0.8.2"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cc"
-version = "1.0.6"
+version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cexpr"
-version = "0.2.0"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cfg-if"
-version = "0.1.2"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clang-sys"
-version = "0.23.0"
+version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clap"
-version = "2.24.2"
+version = "2.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "diff"
-version = "0.1.10"
+version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "env_logger"
-version = "0.5.10"
+version = "0.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "termcolor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -116,26 +119,20 @@ name = "humantime"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
+name = "lazy_static"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "lazy_static"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "libc"
-version = "0.2.39"
+version = "0.2.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -143,30 +140,35 @@ name = "libloading"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cc 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "log"
-version = "0.4.1"
+version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memchr"
-version = "2.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nom"
-version = "1.2.4"
+version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "peeking_take_while"
@@ -175,7 +177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
-version = "0.3.2"
+version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -183,32 +185,45 @@ dependencies = [
[[package]]
name = "quick-error"
-version = "1.2.1"
+version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
-version = "0.5.1"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "proc-macro2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.1.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "redox_termios"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
-version = "1.0.0"
+version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
-version = "0.6.0"
+version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -221,43 +236,41 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "strsim"
-version = "0.6.0"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "term_size"
-version = "0.3.0"
+name = "termcolor"
+version = "1.0.4"
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)",
- "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "termcolor"
-version = "0.3.4"
+name = "termion"
+version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "thread-id"
-version = "3.1.0"
+name = "textwrap"
+version = "0.10.0"
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)",
- "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "thread_local"
-version = "0.3.3"
+version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "thread-id 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -266,13 +279,8 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "unicode-segmentation"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "unicode-width"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -281,44 +289,31 @@ version = "0.1.0"
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"
-dependencies = [
- "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "utf8-ranges"
-version = "1.0.0"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "vec_map"
-version = "0.8.0"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "void"
-version = "1.0.2"
+name = "version_check"
+version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "which"
-version = "1.0.2"
+version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "winapi"
-version = "0.3.4"
+version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -326,14 +321,17 @@ dependencies = [
]
[[package]]
-name = "winapi-build"
-version = "0.1.1"
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
+name = "winapi-util"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
@@ -342,57 +340,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wincolor"
-version = "0.1.6"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
-"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
-"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
-"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 cc 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fedf677519ac9e865c4ff43ef8f930773b37ed6e6ea61b6b83b400a7b5787f49"
-"checksum cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "393a5f0088efbe41f9d1fcd062f24e83c278608420e62109feb2c8abee07de7d"
-"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
-"checksum clang-sys 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7f7c04e52c35222fffcc3a115b5daf5f7e2bfb71c13c4e2321afe1fc71859c2"
-"checksum clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b8f69e518f967224e628896b54e41ff6acfb4dcfefc5076325c36525dac900f"
-"checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472"
-"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a"
+"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a"
+"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
+"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
+"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
+"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
+"checksum cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc0086be9ca82f7fc89fc873435531cb898b86e850005850de1f820e2db6e9b"
+"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
+"checksum clang-sys 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "778ca7c912184f2012124f2dfe40592c4a9edf608b9bf68a9927c8f52e8082bc"
+"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
+"checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a"
+"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e"
-"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
-"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff"
+"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
+"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
-"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
-"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
-"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
+"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
+"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b"
+"checksum nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "898696750eb5c3ce5eb5afbfbe46e7f7c4e1936e19d3e97be4b7937da7b6d114"
"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
-"checksum proc-macro2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "681c2c8e039ff358cb926dbc5151d561cbd0249089986ace39dfe8e405bb7511"
-"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
-"checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a"
-"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3"
-"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b"
+"checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4"
+"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
+"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
+"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
+"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
+"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341"
+"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d"
"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 term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209"
-"checksum termcolor 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "73e83896da740a4541a6f21606b35f2aa4bada5b65d89dc61114bf9d6ff2dc7e"
-"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 strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
+"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f"
+"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
+"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
+"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
-"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-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
-"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"
-"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
-"checksum which 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d238435618c0f298d2d75596c2d4fa7d4ea469c0c1c3ff824737ed50ad5ab61c"
-"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
-"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
+"checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4"
+"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
+"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051"
+"checksum which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e84a603e7e0b1ce1aa1ee2b109c7be00155ce52df5081590d1ffb93f4f515cb2"
+"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767"
+"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
diff --git a/Cargo.toml b/Cargo.toml
index df455f5a..f5d66272 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ readme = "README.md"
repository = "https://github.com/rust-lang-nursery/rust-bindgen"
documentation = "https://docs.rs/bindgen"
homepage = "https://rust-lang-nursery.github.io/rust-bindgen/"
-version = "0.37.2"
+version = "0.43.1"
build = "build.rs"
include = [
@@ -43,11 +43,12 @@ clap = "2"
shlex = "0.1"
[dependencies]
-cexpr = "0.2"
+bitflags = "1.0.3"
+cexpr = "0.3.3"
cfg-if = "0.1.0"
# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
clap = "2"
-clang-sys = { version = "0.23", features = ["runtime", "clang_6_0"] }
+clang-sys = { version = "0.26", features = ["runtime", "clang_6_0"] }
lazy_static = "1"
peeking_take_while = "0.1.2"
quote = { version = "0.5", default-features = false }
diff --git a/LICENSE b/LICENSE
index 589b5326..62f55f45 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,28 +1,29 @@
-Copyright (c) 2013, Jyun-Yan You
+BSD 3-Clause License
+Copyright (c) 2013, Jyun-Yan You
All rights reserved.
Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. Neither the name of the author nor the names of his contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
-THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h
index e09c9ee7..8b9ad8d5 100644
--- a/bindgen-integration/cpp/Test.h
+++ b/bindgen-integration/cpp/Test.h
@@ -2,6 +2,8 @@
#define TESTMACRO
+#include <cwchar>
+
enum {
MY_ANNOYING_MACRO =
#define MY_ANNOYING_MACRO 1
@@ -172,3 +174,7 @@ struct AutoRestoreBool {
AutoRestoreBool(bool*);
~AutoRestoreBool();
};
+
+struct WithWChar {
+ wchar_t foo[30];
+};
diff --git a/book/src/tutorial-1.md b/book/src/tutorial-1.md
index 161b1c55..3256a605 100644
--- a/book/src/tutorial-1.md
+++ b/book/src/tutorial-1.md
@@ -5,5 +5,5 @@ Declare a build-time dependency on `bindgen` by adding it to the
```toml
[build-dependencies]
-bindgen = "0.26.3"
+bindgen = "0.42.2"
```
diff --git a/ci/deploy-book.sh b/ci/deploy-book.sh
index 8ed3ed46..7067450b 100755
--- a/ci/deploy-book.sh
+++ b/ci/deploy-book.sh
@@ -4,7 +4,7 @@ set -xeu
cd "$(dirname "$0")/../book"
# Ensure mdbook is installed.
-cargo install mdbook --vers "^0.0.22" || true
+cargo install mdbook --vers "^0.2.1" --force || true
export PATH="$PATH:~/.cargo/bin"
# Get the git revision we are on.
diff --git a/ci/test-book.sh b/ci/test-book.sh
index b2007e7c..bc2ea333 100755
--- a/ci/test-book.sh
+++ b/ci/test-book.sh
@@ -3,7 +3,7 @@
set -xeu
cd "$(dirname "$0")/../book"
-cargo install mdbook --vers "^0.0.22" || true
+cargo install mdbook --vers "^0.2.1" --force || true
export PATH="$PATH:~/.cargo/bin"
mdbook build
diff --git a/src/clang.rs b/src/clang.rs
index eefc7cf1..f8f7e581 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -12,7 +12,7 @@ use std::ffi::{CStr, CString};
use std::fmt;
use std::hash::Hash;
use std::hash::Hasher;
-use std::os::raw::{c_char, c_int, c_uint, c_ulong};
+use std::os::raw::{c_char, c_int, c_uint, c_ulong, c_longlong, c_ulonglong};
/// A cursor into the Clang AST, pointing to an AST node.
///
@@ -50,13 +50,6 @@ impl Cursor {
unsafe { clang_isDeclaration(self.kind()) != 0 }
}
- /// Get the null cursor, which has no referent.
- pub fn null() -> Self {
- Cursor {
- x: unsafe { clang_getNullCursor() },
- }
- }
-
/// Get this cursor's referent's spelling.
pub fn spelling(&self) -> String {
unsafe { cxstring_into_string(clang_getCursorSpelling(self.x)) }
@@ -947,6 +940,7 @@ impl Type {
CXType_RValueReference |
CXType_LValueReference |
CXType_MemberPointer |
+ CXType_BlockPointer |
CXType_ObjCObjectPointer => {
let ret = Type {
x: unsafe { clang_getPointeeType(self.x) },
@@ -1793,13 +1787,34 @@ impl EvalResult {
}
/// Try to get back the result as an integer.
- pub fn as_int(&self) -> Option<i32> {
- match self.kind() {
- CXEval_Int => {
- Some(unsafe { clang_EvalResult_getAsInt(self.x) } as i32)
+ pub fn as_int(&self) -> Option<i64> {
+ if self.kind() != CXEval_Int {
+ return None;
+ }
+
+ if !clang_EvalResult_isUnsignedInt::is_loaded() {
+ // FIXME(emilio): There's no way to detect underflow here, and clang
+ // will just happily give us a value.
+ return Some(unsafe { clang_EvalResult_getAsInt(self.x) } as i64)
+ }
+
+ if unsafe { clang_EvalResult_isUnsignedInt(self.x) } != 0 {
+ let value = unsafe { clang_EvalResult_getAsUnsigned(self.x) };
+ if value > i64::max_value() as c_ulonglong {
+ return None;
}
- _ => None,
+
+ return Some(value as i64)
+ }
+
+ let value = unsafe { clang_EvalResult_getAsLongLong(self.x) };
+ if value > i64::max_value() as c_longlong {
+ return None;
+ }
+ if value < i64::min_value() as c_longlong {
+ return None;
}
+ Some(value as i64)
}
/// Evaluates the expression as a literal string, that may or may not be
diff --git a/src/codegen/bitfield_unit.rs b/src/codegen/bitfield_unit.rs
index 3c7c9b7b..7f263fd1 100755
--- a/src/codegen/bitfield_unit.rs
+++ b/src/codegen/bitfield_unit.rs
@@ -27,7 +27,13 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index =
+ if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -40,9 +46,14 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index =
+ if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -60,7 +71,13 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index =
+ if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -76,7 +93,13 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index =
+ if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs
index f1007c51..343f1e30 100644
--- a/src/codegen/helpers.rs
+++ b/src/codegen/helpers.rs
@@ -3,7 +3,6 @@
use ir::context::BindgenContext;
use ir::layout::Layout;
use quote;
-use std::mem;
use proc_macro2::{Term, Span};
pub mod attributes {
@@ -60,14 +59,14 @@ pub mod attributes {
/// 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) -> quote::Tokens {
+pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens {
let opaque = layout.opaque();
// FIXME(emilio, #412): We fall back to byte alignment, but there are
// some things that legitimately are more than 8-byte aligned.
//
// Eventually we should be able to `unwrap` here, but...
- let ty_name = match opaque.known_rust_type_for_array() {
+ let ty_name = match opaque.known_rust_type_for_array(ctx) {
Some(ty) => ty,
None => {
warn!("Found unknown alignment on code generation!");
@@ -77,7 +76,7 @@ pub fn blob(layout: Layout) -> quote::Tokens {
let ty_name = Term::new(ty_name, Span::call_site());
- let data_len = opaque.array_size().unwrap_or(layout.size);
+ let data_len = opaque.array_size(ctx).unwrap_or(layout.size);
if data_len == 1 {
quote! {
@@ -91,13 +90,10 @@ pub fn blob(layout: Layout) -> quote::Tokens {
}
/// Integer type of the same size as the given `Layout`.
-pub fn integer_type(layout: Layout) -> Option<quote::Tokens> {
- // This guard can be weakened when Rust implements u128.
- if layout.size > mem::size_of::<u64>() {
- None
- } else {
- Some(blob(layout))
- }
+pub fn integer_type(ctx: &BindgenContext, layout: Layout) -> Option<quote::Tokens> {
+ let name = Layout::known_type_for_size(ctx, layout.size)?;
+ let name = Term::new(name, Span::call_site());
+ Some(quote! { #name })
}
/// Generates a bitfield allocation unit type for a type with the given `Layout`.
@@ -126,6 +122,7 @@ pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> quote::Tokens {
pub mod ast_ty {
use ir::context::BindgenContext;
use ir::function::FunctionSig;
+ use ir::layout::Layout;
use ir::ty::FloatKind;
use quote;
use proc_macro2;
@@ -148,22 +145,44 @@ pub mod ast_ty {
pub fn float_kind_rust_type(
ctx: &BindgenContext,
fk: FloatKind,
+ layout: Option<Layout>,
) -> quote::Tokens {
- // TODO: we probably should just take the type layout into
- // account?
+ // TODO: we probably should take the type layout into account more
+ // often?
//
// Also, maybe this one shouldn't be the default?
- //
- // 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) => quote! { f32 },
- (FloatKind::Double, true) |
- (FloatKind::LongDouble, true) => quote! { f64 },
+ (FloatKind::Double, true) => quote! { f64 },
(FloatKind::Float, false) => raw_type(ctx, "c_float"),
- (FloatKind::Double, false) |
- (FloatKind::LongDouble, false) => raw_type(ctx, "c_double"),
- (FloatKind::Float128, _) => quote! { [u8; 16] },
+ (FloatKind::Double, false) => raw_type(ctx, "c_double"),
+ (FloatKind::LongDouble, _) => {
+ match layout {
+ Some(layout) => {
+ match layout.size {
+ 4 => quote! { f32 },
+ 8 => quote! { f64 },
+ // TODO(emilio): If rust ever gains f128 we should
+ // use it here and below.
+ _ => super::integer_type(ctx, layout).unwrap_or(quote! { f64 }),
+ }
+ }
+ None => {
+ debug_assert!(
+ false,
+ "How didn't we know the layout for a primitive type?"
+ );
+ quote! { f64 }
+ }
+ }
+ }
+ (FloatKind::Float128, _) => {
+ if ctx.options().rust_features.i128_and_u128 {
+ quote! { u128 }
+ } else {
+ quote! { [u64; 2] }
+ }
+ }
}
}
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs
index ab934ed6..8759bf27 100644
--- a/src/codegen/impl_debug.rs
+++ b/src/codegen/impl_debug.rs
@@ -42,8 +42,10 @@ pub fn gen_debug_impl(
format_string.push_str(" }}");
tokens.insert(0, quote! { #format_string });
+ let prefix = ctx.trait_prefix();
+
quote! {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::#prefix::fmt::Formatter<'_>) -> ::#prefix ::fmt::Result {
write!(f, #( #tokens ),*)
}
}
@@ -154,7 +156,6 @@ impl<'a> ImplDebug<'a> for Item {
TypeKind::Function(..) |
TypeKind::Enum(..) |
TypeKind::Reference(..) |
- TypeKind::BlockPointer |
TypeKind::UnresolvedTypeRef(..) |
TypeKind::ObjCInterface(..) |
TypeKind::ObjCId |
@@ -184,23 +185,49 @@ impl<'a> ImplDebug<'a> for Item {
// The simple case
debug_print(name, quote! { #name_ident })
} else {
- // Let's implement our own print function
+ if ctx.options().use_core {
+ // There is no String in core; reducing field visibility to avoid breaking
+ // no_std setups.
+ Some((
+ format!("{}: [...]", name), vec![]
+ ))
+ } else {
+ // Let's implement our own print function
+ Some((
+ format!("{}: [{{}}]", name),
+ vec![quote! {
+ self.#name_ident
+ .iter()
+ .enumerate()
+ .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
+ .collect::<String>()
+ }],
+ ))
+ }
+ }
+ }
+ TypeKind::Vector(_, len) => {
+ if ctx.options().use_core {
+ // There is no format! in core; reducing field visibility to avoid breaking
+ // no_std setups.
+ Some((
+ format!("{}(...)", name), vec![]
+ ))
+ } else {
+ let self_ids = 0..len;
Some((
- format!("{}: [{{}}]", name),
+ format!("{}({{}})", name),
vec![quote! {
- self.#name_ident
- .iter()
- .enumerate()
- .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
- .collect::<String>()
- }],
+ #(format!("{:?}", self.#self_ids)),*
+ }]
))
}
}
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
// We follow the aliases
ctx.resolve_item(t).impl_debug(ctx, name)
}
@@ -209,7 +236,7 @@ impl<'a> ImplDebug<'a> for Item {
let inner_type = ctx.resolve_type(inner).canonical_type(ctx);
match *inner_type.kind() {
TypeKind::Function(ref sig)
- if !sig.can_trivially_derive_debug() => {
+ if !sig.can_trivially_derive_debug(ctx) => {
Some((format!("{}: FunctionPointer", name), vec![]))
}
_ => debug_print(name, quote! { #name_ident }),
diff --git a/src/codegen/impl_partialeq.rs b/src/codegen/impl_partialeq.rs
index a05c65e7..c8ff6313 100644
--- a/src/codegen/impl_partialeq.rs
+++ b/src/codegen/impl_partialeq.rs
@@ -88,7 +88,6 @@ fn gen_field(ctx: &BindgenContext, ty_item: &Item, name: &str) -> quote::Tokens
TypeKind::Enum(..) |
TypeKind::TypeParam |
TypeKind::UnresolvedTypeRef(..) |
- TypeKind::BlockPointer |
TypeKind::Reference(..) |
TypeKind::ObjCInterface(..) |
TypeKind::ObjCId |
@@ -115,10 +114,18 @@ fn gen_field(ctx: &BindgenContext, ty_item: &Item, name: &str) -> quote::Tokens
&self. #name_ident [..] == &other. #name_ident [..]
}
},
+ TypeKind::Vector(_, len) => {
+ let self_ids = 0..len;
+ let other_ids = 0..len;
+ quote! {
+ #(self.#self_ids == other.#other_ids &&)* true
+ }
+ },
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
let inner_item = ctx.resolve_item(t);
gen_field(ctx, inner_item, name)
}
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 026e9475..34b5b4d9 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -7,7 +7,7 @@ pub mod struct_layout;
#[cfg(test)]
#[allow(warnings)]
pub(crate) mod bitfield_unit;
-#[cfg(test)]
+#[cfg(all(test, target_endian = "little"))]
mod bitfield_unit_tests;
use self::helpers::attributes;
@@ -103,6 +103,9 @@ struct CodegenResult<'a> {
/// Whether Objective C types have been seen at least once.
saw_objc: bool,
+ /// Whether Apple block types have been seen at least once.
+ saw_block: bool,
+
/// Whether a bitfield allocation unit has been seen at least once.
saw_bitfield_unit: bool,
@@ -140,6 +143,7 @@ impl<'a> CodegenResult<'a> {
saw_bindgen_union: false,
saw_incomplete_array: false,
saw_objc: false,
+ saw_block: false,
saw_bitfield_unit: false,
codegen_id: codegen_id,
items_seen: Default::default(),
@@ -166,6 +170,10 @@ impl<'a> CodegenResult<'a> {
self.saw_objc = true;
}
+ fn saw_block(&mut self) {
+ self.saw_block = true;
+ }
+
fn saw_bitfield_unit(&mut self) {
self.saw_bitfield_unit = true;
}
@@ -215,6 +223,7 @@ impl<'a> CodegenResult<'a> {
self.saw_union |= new.saw_union;
self.saw_incomplete_array |= new.saw_incomplete_array;
self.saw_objc |= new.saw_objc;
+ self.saw_block |= new.saw_block;
self.saw_bitfield_unit |= new.saw_bitfield_unit;
new.items
@@ -293,7 +302,6 @@ impl AppendImplicitTemplateParams for quote::Tokens {
TypeKind::Opaque |
TypeKind::Function(..) |
TypeKind::Enum(..) |
- TypeKind::BlockPointer |
TypeKind::ObjCId |
TypeKind::ObjCSel |
TypeKind::TemplateInstantiation(..) => return,
@@ -394,6 +402,9 @@ impl CodeGenerator for Module {
}
if item.id() == ctx.root_module() {
+ if result.saw_block {
+ utils::prepend_block_header(ctx, &mut *result);
+ }
if result.saw_bindgen_union {
utils::prepend_union_types(ctx, &mut *result);
}
@@ -564,10 +575,16 @@ impl CodeGenerator for Var {
attrs.push(attributes::link_name(self.name()));
}
+ let maybe_mut = if self.is_const() {
+ quote! { }
+ } else {
+ quote! { mut }
+ };
+
let mut tokens = quote!(
extern "C" {
#(#attrs)*
- pub static mut #canonical_ident: #ty;
+ pub static #maybe_mut #canonical_ident: #ty;
}
);
@@ -595,8 +612,8 @@ impl CodeGenerator for Type {
TypeKind::Float(..) |
TypeKind::Complex(..) |
TypeKind::Array(..) |
+ TypeKind::Vector(..) |
TypeKind::Pointer(..) |
- TypeKind::BlockPointer |
TypeKind::Reference(..) |
TypeKind::Function(..) |
TypeKind::ResolvedTypeRef(..) |
@@ -609,6 +626,39 @@ impl CodeGenerator for Type {
TypeKind::TemplateInstantiation(ref inst) => {
inst.codegen(ctx, result, item)
}
+ TypeKind::BlockPointer(inner) => {
+ if !ctx.options().generate_block {
+ return;
+ }
+
+ let inner_item = inner.into_resolver()
+ .through_type_refs()
+ .resolve(ctx);
+ let name = item.canonical_name(ctx);
+
+ let inner_rust_type = {
+ if let TypeKind::Function(fnsig) = inner_item.kind().expect_type().kind() {
+ utils::fnsig_block(ctx, fnsig)
+ } else {
+ panic!("invalid block typedef: {:?}", inner_item)
+ }
+ };
+
+ let rust_name = ctx.rust_ident(&name);
+
+ let mut tokens = if let Some(comment) = item.comment(ctx) {
+ attributes::doc(comment)
+ } else {
+ quote! {}
+ };
+
+ tokens.append_all(quote! {
+ pub type #rust_name = #inner_rust_type ;
+ });
+
+ result.push(tokens);
+ result.saw_block();
+ }
TypeKind::Comp(ref ci) => ci.codegen(ctx, result, item),
TypeKind::TemplateAlias(inner, _) |
TypeKind::Alias(inner) => {
@@ -616,6 +666,7 @@ impl CodeGenerator for Type {
.through_type_refs()
.resolve(ctx);
let name = item.canonical_name(ctx);
+ let path = item.canonical_path(ctx);
{
let through_type_aliases = inner.into_resolver()
@@ -628,7 +679,7 @@ impl CodeGenerator for Type {
// typedef struct foo { ... } foo;
//
// here, and also other more complex cases like #946.
- if through_type_aliases.canonical_name(ctx) == name {
+ if through_type_aliases.canonical_path(ctx) == path {
return;
}
}
@@ -994,6 +1045,7 @@ impl<'a> FieldCodegen<'a> for FieldData {
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, &());
+ ty.append_implicit_template_params(ctx, field_item);
// NB: If supported, we use proper `union` types.
let ty = if parent.is_union() && !parent.can_be_rust_union(ctx) {
@@ -1021,7 +1073,6 @@ impl<'a> FieldCodegen<'a> for FieldData {
}
}
} else {
- ty.append_implicit_template_params(ctx, field_item);
ty
};
@@ -1145,7 +1196,7 @@ impl Bitfield {
let bitfield_ty_layout = bitfield_ty.layout(ctx).expect(
"Bitfield without layout? Gah!",
);
- let bitfield_int_ty = helpers::blob(bitfield_ty_layout);
+ let bitfield_int_ty = helpers::blob(ctx, bitfield_ty_layout);
let offset = self.offset_into_unit();
let width = self.width() as u8;
@@ -1327,7 +1378,7 @@ impl<'a> FieldCodegen<'a> for Bitfield {
let bitfield_ty_layout = bitfield_ty.layout(ctx).expect(
"Bitfield without layout? Gah!",
);
- let bitfield_int_ty = match helpers::integer_type(bitfield_ty_layout) {
+ let bitfield_int_ty = match helpers::integer_type(ctx, bitfield_ty_layout) {
Some(int_ty) => {
*bitfield_representable_as_int = true;
int_ty
@@ -1500,27 +1551,6 @@ impl CodeGenerator for CompInfo {
let is_union = self.kind() == CompKind::Union;
let layout = item.kind().expect_type().layout(ctx);
- if is_union && !is_opaque && !self.is_forward_declaration() {
- result.saw_union();
- if !self.can_be_rust_union(ctx) {
- result.saw_bindgen_union();
- }
-
- let layout = layout.expect("Unable to get layout information?");
- let ty = helpers::blob(layout);
-
- fields.push(if self.can_be_rust_union(ctx) {
- quote! {
- _bindgen_union_align: #ty ,
- }
- } else {
- struct_layout.saw_union(layout);
-
- quote! {
- pub bindgen_union_field: #ty ,
- }
- });
- }
let mut explicit_align = None;
if is_opaque {
@@ -1532,7 +1562,7 @@ impl CodeGenerator for CompInfo {
Some(l) => {
explicit_align = Some(l.align);
- let ty = helpers::blob(l);
+ let ty = helpers::blob(ctx, l);
fields.push(quote! {
pub _bindgen_opaque_blob: #ty ,
});
@@ -1554,13 +1584,41 @@ impl CodeGenerator for CompInfo {
packed = true;
} else {
explicit_align = Some(layout.align);
- let ty = helpers::blob(Layout::new(0, layout.align));
- fields.push(quote! {
- pub __bindgen_align: #ty ,
- });
+ if !ctx.options().rust_features.repr_align {
+ let ty = helpers::blob(ctx, Layout::new(0, layout.align));
+ fields.push(quote! {
+ pub __bindgen_align: #ty ,
+ });
+ }
}
}
}
+ } else if is_union && !self.is_forward_declaration() {
+ result.saw_union();
+ if !self.can_be_rust_union(ctx) {
+ result.saw_bindgen_union();
+ }
+
+ // TODO(emilio): It'd be nice to unify this with the struct path
+ // above somehow.
+ let layout = layout.expect("Unable to get layout information?");
+
+ if struct_layout.requires_explicit_align(layout) {
+ explicit_align = Some(layout.align);
+ }
+
+ let ty = helpers::blob(ctx, layout);
+ fields.push(if self.can_be_rust_union(ctx) {
+ quote! {
+ _bindgen_union_align: #ty ,
+ }
+ } else {
+ struct_layout.saw_union(layout);
+
+ quote! {
+ pub bindgen_union_field: #ty ,
+ }
+ });
}
// C++ requires every struct to be addressable, so what C++ compilers do
@@ -1587,7 +1645,7 @@ impl CodeGenerator for CompInfo {
};
if has_address {
- let ty = helpers::blob(Layout::new(1, 1));
+ let ty = helpers::blob(ctx, Layout::new(1, 1));
fields.push(quote! {
pub _address: #ty,
});
@@ -1744,7 +1802,7 @@ impl CodeGenerator for CompInfo {
// all the tests to shit when parsing things like max_align_t.
if self.found_unknown_attr() {
warn!(
- "Type {} has an unkown attribute that may affect layout",
+ "Type {} has an unknown attribute that may affect layout",
canonical_ident.as_str()
);
}
@@ -1842,7 +1900,7 @@ impl CodeGenerator for CompInfo {
}
let mut method_names = Default::default();
- if ctx.options().codegen_config.methods {
+ if ctx.options().codegen_config.methods() {
for method in self.methods() {
assert!(method.kind() != MethodKind::Constructor);
method.codegen_method(
@@ -1855,7 +1913,7 @@ impl CodeGenerator for CompInfo {
}
}
- if ctx.options().codegen_config.constructors {
+ if ctx.options().codegen_config.constructors() {
for sig in self.constructors() {
Method::new(
MethodKind::Constructor,
@@ -1872,7 +1930,7 @@ impl CodeGenerator for CompInfo {
}
}
- if ctx.options().codegen_config.destructors {
+ if ctx.options().codegen_config.destructors() {
if let Some((kind, destructor)) = self.destructor() {
debug_assert!(kind.is_destructor());
Method::new(kind, destructor, false).codegen_method(
@@ -1917,8 +1975,10 @@ impl CodeGenerator for CompInfo {
self.kind(),
);
+ let prefix = ctx.trait_prefix();
+
result.push(quote! {
- impl #generics ::std::fmt::Debug for #ty_for_impl {
+ impl #generics ::#prefix::fmt::Debug for #ty_for_impl {
#impl_
}
});
@@ -1978,11 +2038,12 @@ impl MethodCodegen for Method {
assert!({
let cc = &ctx.options().codegen_config;
match self.kind() {
- MethodKind::Constructor => cc.constructors,
- MethodKind::Destructor => cc.destructors,
- MethodKind::VirtualDestructor { .. } => cc.destructors,
- MethodKind::Static | MethodKind::Normal |
- MethodKind::Virtual { .. } => cc.methods,
+ MethodKind::Constructor => cc.constructors(),
+ MethodKind::Destructor => cc.destructors(),
+ MethodKind::VirtualDestructor { .. } => cc.destructors(),
+ MethodKind::Static |
+ MethodKind::Normal |
+ MethodKind::Virtual { .. } => cc.methods(),
}
});
@@ -2512,22 +2573,10 @@ impl CodeGenerator for Enum {
}
};
- // ModuleConsts has higher precedence before Rust in order to avoid problems with
- // overlapping match patterns
- let variation = if self.is_constified_enum_module(ctx, item) {
- EnumVariation::ModuleConsts
- } else if self.is_bitfield(ctx, item) {
- EnumVariation::Bitfield
- } else if self.is_rustified_enum(ctx, item) {
- EnumVariation::Rust
- } else if self.is_constified_enum(ctx, item) {
- EnumVariation::Consts
- } else {
- ctx.options().default_enum_style
- };
-
let mut attrs = vec![];
+ let variation = self.computed_enum_variation(ctx, item);
+
// TODO(emilio): Delegate this to the builders?
if variation.is_rust() {
attrs.push(attributes::repr(repr_name));
@@ -2540,9 +2589,17 @@ impl CodeGenerator for Enum {
}
if !variation.is_const() {
- attrs.push(attributes::derives(
- &["Debug", "Copy", "Clone", "PartialEq", "Eq", "Hash"],
- ));
+ let mut derives = vec!["Debug", "Copy", "Clone", "PartialEq", "Eq", "Hash"];
+
+ if item.can_derive_partialord(ctx) {
+ derives.push("PartialOrd");
+ }
+
+ if item.can_derive_ord(ctx) {
+ derives.push("Ord");
+ }
+
+ attrs.push(attributes::derives(&derives));
}
fn add_constant<'a>(
@@ -2645,15 +2702,28 @@ impl CodeGenerator for Enum {
};
let existing_variant_name = entry.get();
- add_constant(
- ctx,
- enum_ty,
- &ident,
- &*mangled_name,
- existing_variant_name,
- enum_rust_ty.clone(),
- result,
- );
+ // Use associated constants for named enums.
+ if enum_ty.name().is_some() &&
+ ctx.options().rust_features().associated_const {
+ let enum_canonical_name = &ident;
+ let variant_name = ctx.rust_ident_raw(&*mangled_name);
+ result.push(quote! {
+ impl #enum_rust_ty {
+ pub const #variant_name : #enum_rust_ty =
+ #enum_canonical_name :: #existing_variant_name ;
+ }
+ });
+ } else {
+ add_constant(
+ ctx,
+ enum_ty,
+ &ident,
+ &*mangled_name,
+ existing_variant_name,
+ enum_rust_ty.clone(),
+ result,
+ );
+ }
} else {
builder = builder.with_variant(
ctx,
@@ -2742,7 +2812,7 @@ trait TryToOpaque {
extra: &Self::Extra,
) -> error::Result<quote::Tokens> {
self.try_get_layout(ctx, extra).map(|layout| {
- helpers::blob(layout)
+ helpers::blob(ctx, layout)
})
}
}
@@ -2769,7 +2839,7 @@ trait ToOpaque: TryToOpaque {
extra: &Self::Extra,
) -> quote::Tokens {
let layout = self.get_layout(ctx, extra);
- helpers::blob(layout)
+ helpers::blob(ctx, layout)
}
}
@@ -2827,7 +2897,7 @@ where
|_| if let Ok(layout) =
self.try_get_layout(ctx, extra)
{
- Ok(helpers::blob(layout))
+ Ok(helpers::blob(ctx, layout))
} else {
Err(error::Error::NoLayoutForOpaqueBlob)
},
@@ -2978,6 +3048,12 @@ impl TryToRustTy for Type {
IntKind::ULong => Ok(raw_type(ctx, "c_ulong")),
IntKind::LongLong => Ok(raw_type(ctx, "c_longlong")),
IntKind::ULongLong => Ok(raw_type(ctx, "c_ulonglong")),
+ IntKind::WChar { size } => {
+ let ty = Layout::known_type_for_size(ctx, size)
+ .expect("Non-representable wchar_t?");
+ let ident = ctx.rust_ident_raw(ty);
+ Ok(quote! { #ident })
+ },
IntKind::I8 => Ok(quote! { i8 }),
IntKind::U8 => Ok(quote! { u8 }),
@@ -2995,17 +3071,27 @@ impl TryToRustTy for Type {
#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(quote! { [u64; 2] })
+ IntKind::U128 => {
+ Ok(if ctx.options().rust_features.i128_and_u128 {
+ quote! { u128 }
+ } else {
+ // Best effort thing, but wrong alignment
+ // unfortunately.
+ quote! { [u64; 2] }
+ })
+ }
+ IntKind::I128 => {
+ Ok(if ctx.options().rust_features.i128_and_u128 {
+ quote! { i128 }
+ } else {
+ quote! { [u64; 2] }
+ })
}
}
}
- TypeKind::Float(fk) => Ok(float_kind_rust_type(ctx, fk)),
+ TypeKind::Float(fk) => Ok(float_kind_rust_type(ctx, fk, self.layout(ctx))),
TypeKind::Complex(fk) => {
- let float_path = float_kind_rust_type(ctx, fk);
+ let float_path = float_kind_rust_type(ctx, fk, self.layout(ctx));
ctx.generated_bindgen_complex();
Ok(if ctx.options().enable_cxx_namespaces {
@@ -3030,7 +3116,7 @@ impl TryToRustTy for Type {
::#prefix::option::Option<#ty>
})
}
- TypeKind::Array(item, len) => {
+ TypeKind::Array(item, len) | TypeKind::Vector(item, len) => {
let ty = item.try_to_rust_ty(ctx, &())?;
Ok(quote! {
[ #ty ; #len ]
@@ -3046,20 +3132,20 @@ impl TryToRustTy for Type {
}
TypeKind::ResolvedTypeRef(inner) => inner.try_to_rust_ty(ctx, &()),
TypeKind::TemplateAlias(..) |
- TypeKind::Alias(..) => {
+ TypeKind::Alias(..) |
+ TypeKind::BlockPointer(..) => {
+ if self.is_block_pointer() && !ctx.options().generate_block {
+ let void = raw_type(ctx, "c_void");
+ return Ok(void.to_ptr(/* is_const = */ false));
+ }
let template_params = item.used_template_params(ctx)
.into_iter()
.filter(|param| param.is_template_param(ctx, &()))
.collect::<Vec<_>>();
- let spelling = self.name().expect("Unnamed alias?");
if item.is_opaque(ctx, &()) && !template_params.is_empty() {
self.try_to_opaque(ctx, item)
- } else if let Some(ty) = utils::type_from_named(
- ctx,
- spelling,
- )
- {
+ } else if let Some(ty) = self.name().and_then(|name| utils::type_from_named(ctx, name)) {
Ok(ty)
} else {
utils::build_path(item, ctx)
@@ -3076,13 +3162,6 @@ impl TryToRustTy for Type {
utils::build_path(item, ctx)
}
TypeKind::Opaque => self.try_to_opaque(ctx, item),
- TypeKind::BlockPointer => {
- let void = raw_type(ctx, "c_void");
- Ok(void.to_ptr(
- /* is_const = */
- false
- ))
- }
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) => {
let is_const = ctx.resolve_type(inner).is_const();
@@ -3299,12 +3378,6 @@ impl CodeGenerator for Function {
attributes.push(attributes::doc(comment));
}
- if let Some(mangled) = mangled_name {
- attributes.push(attributes::link_name(mangled));
- } else if name != canonical_name {
- attributes.push(attributes::link_name(name));
- }
-
// Handle overloaded functions by giving each overload its own unique
// suffix.
let times_seen = result.overload_number(&canonical_name);
@@ -3312,11 +3385,23 @@ impl CodeGenerator for Function {
write!(&mut canonical_name, "{}", times_seen).unwrap();
}
+ if let Some(mangled) = mangled_name {
+ if canonical_name != mangled {
+ attributes.push(attributes::link_name(mangled));
+ }
+ } else if name != canonical_name {
+ attributes.push(attributes::link_name(name));
+ }
+
let abi = match signature.abi() {
Abi::ThisCall if !ctx.options().rust_features().thiscall_abi => {
warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target");
return;
}
+ Abi::Win64 if signature.is_variadic() => {
+ warn!("Skipping variadic function with Win64 ABI that isn't supported");
+ return;
+ }
Abi::Unknown(unknown_abi) => {
panic!(
"Invalid or unknown abi {:?} for function {:?} ({:?})",
@@ -3531,6 +3616,25 @@ mod utils {
result.extend(old_items.into_iter());
}
+ pub fn prepend_block_header(
+ ctx: &BindgenContext,
+ result: &mut Vec<quote::Tokens>,
+ ) {
+ let use_block = if ctx.options().block_extern_crate {
+ quote! {
+ extern crate block;
+ }
+ } else {
+ quote! {
+ use block;
+ }
+ };
+
+ let items = vec![use_block];
+ let old_items = mem::replace(result, items);
+ result.extend(old_items.into_iter());
+ }
+
pub fn prepend_union_types(
ctx: &BindgenContext,
result: &mut Vec<quote::Tokens>,
@@ -3587,7 +3691,7 @@ mod utils {
let union_field_debug_impl = quote! {
impl<T> ::#prefix::fmt::Debug for __BindgenUnionField<T> {
- fn fmt(&self, fmt: &mut ::#prefix::fmt::Formatter)
+ fn fmt(&self, fmt: &mut ::#prefix::fmt::Formatter<'_>)
-> ::#prefix::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
@@ -3674,7 +3778,7 @@ mod utils {
let incomplete_array_debug_impl = quote! {
impl<T> ::#prefix::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::#prefix::fmt::Formatter)
+ fn fmt(&self, fmt: &mut ::#prefix::fmt::Formatter<'_>)
-> ::#prefix::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
@@ -3842,4 +3946,26 @@ mod utils {
args
}
+
+ pub fn fnsig_block(
+ ctx: &BindgenContext,
+ sig: &FunctionSig,
+ ) -> quote::Tokens {
+ let args = sig.argument_types().iter().map(|&(_, ty)| {
+ let arg_item = ctx.resolve_item(ty);
+
+ arg_item.to_rust_ty_or_opaque(ctx, &())
+ });
+
+ let return_item = ctx.resolve_item(sig.return_type());
+ let ret_ty = if let TypeKind::Void = *return_item.kind().expect_type().kind() {
+ quote! { () }
+ } else {
+ return_item.to_rust_ty_or_opaque(ctx, &())
+ };
+
+ quote! {
+ *const ::block::Block<(#(#args),*), #ret_ty>
+ }
+ }
}
diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs
index 6de7e030..0ea23ddf 100644
--- a/src/codegen/struct_layout.rs
+++ b/src/codegen/struct_layout.rs
@@ -287,18 +287,23 @@ impl<'a> StructLayoutTracker<'a> {
}
pub fn requires_explicit_align(&self, layout: Layout) -> bool {
+ let repr_align = self.ctx.options().rust_features().repr_align;
+
+ // Always force explicit repr(align) for stuff more than 16-byte aligned
+ // to work-around https://github.com/rust-lang/rust/issues/54341.
+ //
+ // Worst-case this just generates redundant alignment attributes.
+ if repr_align && self.max_field_align >= 16 {
+ return true;
+ }
+
if self.max_field_align >= layout.align {
return false;
}
- // At this point we require explicit alignment, but we may not be able
- // to generate the right bits, let's double check.
- if self.ctx.options().rust_features().repr_align {
- return true;
- }
// We can only generate up-to a word of alignment unless we support
// repr(align).
- layout.align <= self.ctx.target_pointer_size()
+ repr_align || layout.align <= self.ctx.target_pointer_size()
}
fn padding_bytes(&self, layout: Layout) -> usize {
@@ -306,7 +311,7 @@ impl<'a> StructLayoutTracker<'a> {
}
fn padding_field(&mut self, layout: Layout) -> quote::Tokens {
- let ty = helpers::blob(layout);
+ let ty = helpers::blob(self.ctx, layout);
let padding_count = self.padding_count;
self.padding_count += 1;
diff --git a/src/features.rs b/src/features.rs
index 93ebbc34..671464ab 100644
--- a/src/features.rs
+++ b/src/features.rs
@@ -96,6 +96,8 @@ macro_rules! rust_target_base {
=> Stable_1_21 => 1.21;
/// Rust stable 1.25
=> Stable_1_25 => 1.25;
+ /// Rust stable 1.26
+ => Stable_1_26 => 1.26;
/// Nightly rust
=> Nightly => nightly;
);
@@ -110,72 +112,78 @@ pub const LATEST_STABLE_RUST: RustTarget = RustTarget::Stable_1_21;
/// Create RustFeatures struct definition, new(), and a getter for each field
macro_rules! rust_feature_def {
- ( $( $( #[$attr:meta] )* => $feature:ident; )* ) => {
+ (
+ $( $rust_target:ident {
+ $( $( #[$attr:meta] )* => $feature:ident; )*
+ } )*
+ ) => {
/// Features supported by a rust target
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct RustFeatures {
- $(
+ $( $(
$(
#[$attr]
)*
pub $feature: bool,
- )*
+ )* )*
}
impl RustFeatures {
/// Gives a RustFeatures struct with all features disabled
fn new() -> Self {
RustFeatures {
- $(
+ $( $(
$feature: false,
- )*
+ )* )*
}
}
}
- }
-}
-rust_feature_def!(
- /// Untagged unions ([RFC 1444](https://github.com/rust-lang/rfcs/blob/master/text/1444-union.md))
- => untagged_union;
- /// `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
- => thiscall_abi;
- /// builtin impls for `Clone` ([PR](https://github.com/rust-lang/rust/pull/43690))
- => builtin_clone_impls;
- /// repr(align) https://github.com/rust-lang/rust/pull/47006
- => repr_align;
- /// associated constants https://github.com/rust-lang/rust/issues/29646
- => associated_const;
-);
+ impl From<RustTarget> for RustFeatures {
+ fn from(rust_target: RustTarget) -> Self {
+ let mut features = RustFeatures::new();
-impl From<RustTarget> for RustFeatures {
- fn from(rust_target: RustTarget) -> Self {
- let mut features = RustFeatures::new();
-
- if rust_target >= RustTarget::Stable_1_19 {
- features.untagged_union = true;
- }
-
- if rust_target >= RustTarget::Stable_1_20 {
- features.associated_const = true;
- }
-
- if rust_target >= RustTarget::Stable_1_21 {
- features.builtin_clone_impls = true;
- }
-
- if rust_target >= RustTarget::Stable_1_25 {
- features.repr_align = true;
- }
+ $(
+ if rust_target >= RustTarget::$rust_target {
+ $(
+ features.$feature = true;
+ )*
+ }
+ )*
- if rust_target >= RustTarget::Nightly {
- features.thiscall_abi = true;
+ features
+ }
}
-
- features
}
}
+rust_feature_def!(
+ Stable_1_19 {
+ /// Untagged unions ([RFC 1444](https://github.com/rust-lang/rfcs/blob/master/text/1444-union.md))
+ => untagged_union;
+ }
+ Stable_1_20 {
+ /// associated constants ([PR](https://github.com/rust-lang/rust/pull/42809))
+ => associated_const;
+ }
+ Stable_1_21 {
+ /// builtin impls for `Clone` ([PR](https://github.com/rust-lang/rust/pull/43690))
+ => builtin_clone_impls;
+ }
+ Stable_1_25 {
+ /// repr(align) ([PR](https://github.com/rust-lang/rust/pull/47006))
+ => repr_align;
+ }
+ Stable_1_26 {
+ /// [i128 / u128 support](https://doc.rust-lang.org/std/primitive.i128.html)
+ => i128_and_u128;
+ }
+ Nightly {
+ /// `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
+ => thiscall_abi;
+ }
+);
+
impl Default for RustFeatures {
fn default() -> Self {
let default_rust_target: RustTarget = Default::default();
@@ -185,9 +193,37 @@ impl Default for RustFeatures {
#[cfg(test)]
mod test {
-#![allow(unused_imports)]
+ #![allow(unused_imports)]
use super::*;
+ #[test]
+ fn target_features() {
+ let f_1_0 = RustFeatures::from(RustTarget::Stable_1_0);
+ assert!(
+ !f_1_0.untagged_union
+ && !f_1_0.associated_const
+ && !f_1_0.builtin_clone_impls
+ && !f_1_0.repr_align
+ && !f_1_0.thiscall_abi
+ );
+ let f_1_21 = RustFeatures::from(RustTarget::Stable_1_21);
+ assert!(
+ f_1_21.untagged_union
+ && f_1_21.associated_const
+ && f_1_21.builtin_clone_impls
+ && !f_1_21.repr_align
+ && !f_1_21.thiscall_abi
+ );
+ let f_nightly = RustFeatures::from(RustTarget::Nightly);
+ assert!(
+ f_nightly.untagged_union
+ && f_nightly.associated_const
+ && f_nightly.builtin_clone_impls
+ && f_nightly.repr_align
+ && f_nightly.thiscall_abi
+ );
+ }
+
fn test_target(target_str: &str, target: RustTarget) {
let target_string: String = target.into();
assert_eq!(target_str, target_string);
diff --git a/src/ir/analysis/derive_copy.rs b/src/ir/analysis/derive_copy.rs
index 1e8dc819..9d0bcd19 100644
--- a/src/ir/analysis/derive_copy.rs
+++ b/src/ir/analysis/derive_copy.rs
@@ -149,7 +149,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
if item.is_opaque(self.ctx, &()) {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_copy()
+ l.opaque().can_trivially_derive_copy(self.ctx)
});
return if layout_can_derive {
trace!(" we can trivially derive Copy for the layout");
@@ -167,12 +167,12 @@ impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
TypeKind::NullPtr |
TypeKind::Int(..) |
TypeKind::Float(..) |
+ TypeKind::Vector(..) |
TypeKind::Complex(..) |
TypeKind::Function(..) |
TypeKind::Enum(..) |
TypeKind::Reference(..) |
TypeKind::TypeParam |
- TypeKind::BlockPointer |
TypeKind::Pointer(..) |
TypeKind::UnresolvedTypeRef(..) |
TypeKind::ObjCInterface(..) |
@@ -203,7 +203,8 @@ impl<'ctx> MonotoneFramework for CannotDeriveCopy<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
let cant_derive_copy = self.is_not_copy(t);
if cant_derive_copy {
trace!(
diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs
index b191d37d..9210148a 100644
--- a/src/ir/analysis/derive_debug.rs
+++ b/src/ir/analysis/derive_debug.rs
@@ -146,7 +146,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
if item.is_opaque(self.ctx, &()) {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_debug()
+ l.opaque().can_trivially_derive_debug(self.ctx)
});
return if layout_can_derive &&
!(ty.is_union() &&
@@ -182,7 +182,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
TypeKind::Function(..) |
TypeKind::Enum(..) |
TypeKind::Reference(..) |
- TypeKind::BlockPointer |
+ TypeKind::Vector(..) |
TypeKind::TypeParam |
TypeKind::UnresolvedTypeRef(..) |
TypeKind::ObjCInterface(..) |
@@ -212,7 +212,8 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
if self.is_not_debug(t) {
trace!(
" aliases and type refs to T which cannot derive \
@@ -241,7 +242,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
}
if ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_debug()
+ l.opaque().can_trivially_derive_debug(self.ctx)
})
{
trace!(" union layout can trivially derive Debug");
@@ -298,7 +299,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDebug<'ctx> {
let inner_type =
self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
- if !sig.can_trivially_derive_debug() {
+ if !sig.can_trivially_derive_debug(self.ctx) {
trace!(
" function pointer that can't trivially derive Debug"
);
diff --git a/src/ir/analysis/derive_default.rs b/src/ir/analysis/derive_default.rs
index e319166d..2ff07ce9 100644
--- a/src/ir/analysis/derive_default.rs
+++ b/src/ir/analysis/derive_default.rs
@@ -173,7 +173,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
if item.is_opaque(self.ctx, &()) {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_default()
+ l.opaque().can_trivially_derive_default(self.ctx)
});
return if layout_can_derive &&
!(ty.is_union() &&
@@ -204,6 +204,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
TypeKind::Function(..) |
TypeKind::Int(..) |
TypeKind::Float(..) |
+ TypeKind::Vector(..) |
TypeKind::Complex(..) => {
trace!(" simple type that can always derive Default");
ConstrainResult::Same
@@ -214,7 +215,6 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
TypeKind::Reference(..) |
TypeKind::NullPtr |
TypeKind::Pointer(..) |
- TypeKind::BlockPointer |
TypeKind::ObjCId |
TypeKind::ObjCSel |
TypeKind::ObjCInterface(..) |
@@ -243,7 +243,8 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
if self.is_not_default(t) {
trace!(
" aliases and type refs to T which cannot derive \
@@ -277,7 +278,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveDefault<'ctx> {
}
if ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_default()
+ l.opaque().can_trivially_derive_default(self.ctx)
})
{
trace!(" union layout can trivially derive Default");
diff --git a/src/ir/analysis/derive_hash.rs b/src/ir/analysis/derive_hash.rs
index c23a891e..eee6d6f0 100644
--- a/src/ir/analysis/derive_hash.rs
+++ b/src/ir/analysis/derive_hash.rs
@@ -133,7 +133,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
if item.is_opaque(self.ctx, &()) {
let layout_can_derive = ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_hash()
+ l.opaque().can_trivially_derive_hash(self.ctx)
});
return if layout_can_derive &&
!(ty.is_union() &&
@@ -167,7 +167,6 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
TypeKind::Enum(..) |
TypeKind::TypeParam |
TypeKind::UnresolvedTypeRef(..) |
- TypeKind::BlockPointer |
TypeKind::Reference(..) |
TypeKind::ObjCInterface(..) |
TypeKind::ObjCId |
@@ -202,12 +201,24 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
self.insert(id)
}
}
+ TypeKind::Vector(t, len) => {
+ if self.cannot_derive_hash.contains(&t.into()) {
+ trace!(
+ " vectors of T for which we cannot derive Hash \
+ also cannot derive Hash"
+ );
+ return self.insert(id);
+ }
+ assert_ne!(len, 0, "vectors cannot have zero length");
+ trace!(" vector can derive Hash");
+ ConstrainResult::Same
+ }
TypeKind::Pointer(inner) => {
let inner_type =
self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
- if !sig.can_trivially_derive_hash() {
+ if !sig.can_trivially_derive_hash(self.ctx) {
trace!(
" function pointer that can't trivially derive Hash"
);
@@ -219,7 +230,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
}
TypeKind::Function(ref sig) => {
- if !sig.can_trivially_derive_hash() {
+ if !sig.can_trivially_derive_hash(self.ctx) {
trace!(" function that can't trivially derive Hash");
return self.insert(id);
}
@@ -229,7 +240,8 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
if self.cannot_derive_hash.contains(&t.into()) {
trace!(
" aliases and type refs to T which cannot derive \
@@ -263,7 +275,7 @@ impl<'ctx> MonotoneFramework for CannotDeriveHash<'ctx> {
}
if ty.layout(self.ctx).map_or(true, |l| {
- l.opaque().can_trivially_derive_hash()
+ l.opaque().can_trivially_derive_hash(self.ctx)
})
{
trace!(" union layout can trivially derive Hash");
diff --git a/src/ir/analysis/derive_partialeq_or_partialord.rs b/src/ir/analysis/derive_partialeq_or_partialord.rs
index cebdceef..5a9a21c5 100644
--- a/src/ir/analysis/derive_partialeq_or_partialord.rs
+++ b/src/ir/analysis/derive_partialeq_or_partialord.rs
@@ -43,7 +43,7 @@ use std::collections::hash_map::Entry;
pub struct CannotDerivePartialEqOrPartialOrd<'ctx> {
ctx: &'ctx BindgenContext,
- // The incremental result of this analysis's computation.
+ // The incremental result of this analysis's computation.
// Contains information whether particular item can derive `PartialEq`/`PartialOrd`.
can_derive_partialeq_or_partialord: HashMap<ItemId, CanDerive>,
@@ -129,7 +129,7 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
let layout_can_derive = ty.layout(self.ctx)
.map_or(CanDerive::Yes, |l| {
- l.opaque().can_trivially_derive_partialeq_or_partialord()
+ l.opaque().can_trivially_derive_partialeq_or_partialord(self.ctx)
});
match layout_can_derive {
@@ -148,7 +148,7 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
}
match *ty.kind() {
- // Handle the simple cases. These can derive partialeq without further
+ // Handle the simple cases. These can derive partialeq/partialord without further
// information.
TypeKind::Void |
TypeKind::NullPtr |
@@ -158,7 +158,6 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
TypeKind::Enum(..) |
TypeKind::TypeParam |
TypeKind::UnresolvedTypeRef(..) |
- TypeKind::BlockPointer |
TypeKind::Reference(..) |
TypeKind::ObjCInterface(..) |
TypeKind::ObjCId |
@@ -199,12 +198,19 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
return CanDerive::ArrayTooLarge;
}
}
+ TypeKind::Vector(..) => {
+ // FIXME: vectors always can derive PartialEq, but they should
+ // not derive PartialOrd:
+ // https://github.com/rust-lang-nursery/packed_simd/issues/48
+ trace!(" vectors cannot derive `PartialEq`/`PartialOrd`");
+ return CanDerive::No;
+ }
TypeKind::Pointer(inner) => {
let inner_type =
self.ctx.resolve_type(inner).canonical_type(self.ctx);
if let TypeKind::Function(ref sig) = *inner_type.kind() {
- if sig.can_trivially_derive_partialeq_or_partialord()
+ if sig.can_trivially_derive_partialeq_or_partialord(self.ctx)
!= CanDerive::Yes
{
trace!(
@@ -218,7 +224,7 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
}
TypeKind::Function(ref sig) => {
- if sig.can_trivially_derive_partialeq_or_partialord()
+ if sig.can_trivially_derive_partialeq_or_partialord(self.ctx)
!= CanDerive::Yes
{
trace!(
@@ -252,7 +258,7 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
let layout_can_derive =
ty.layout(self.ctx).map_or(CanDerive::Yes, |l| {
l.opaque()
- .can_trivially_derive_partialeq_or_partialord()
+ .can_trivially_derive_partialeq_or_partialord(self.ctx)
});
match layout_can_derive {
CanDerive::Yes => {
@@ -274,6 +280,7 @@ impl<'ctx> CannotDerivePartialEqOrPartialOrd<'ctx> {
TypeKind::ResolvedTypeRef(..) |
TypeKind::TemplateAlias(..) |
TypeKind::Alias(..) |
+ TypeKind::BlockPointer(..) |
TypeKind::TemplateInstantiation(..) => {
return self.constrain_join(item);
}
diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs
index 193862c0..92bbe36c 100644
--- a/src/ir/analysis/has_float.rs
+++ b/src/ir/analysis/has_float.rs
@@ -122,7 +122,6 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
TypeKind::Function(..) |
TypeKind::Enum(..) |
TypeKind::Reference(..) |
- TypeKind::BlockPointer |
TypeKind::TypeParam |
TypeKind::Opaque |
TypeKind::Pointer(..) |
@@ -148,10 +147,19 @@ impl<'ctx> MonotoneFramework for HasFloat<'ctx> {
trace!(" Array with type T that do not have float also do not have float");
ConstrainResult::Same
}
+ TypeKind::Vector(t, _) => {
+ if self.has_float.contains(&t.into()) {
+ trace!(" Vector with type T that has float also has float");
+ return self.insert(id)
+ }
+ trace!(" Vector with type T that do not have float also do not have float");
+ ConstrainResult::Same
+ }
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
if self.has_float.contains(&t.into()) {
trace!(" aliases and type refs to T which have float \
also have float");
diff --git a/src/ir/analysis/has_type_param_in_array.rs b/src/ir/analysis/has_type_param_in_array.rs
index aa8d34be..98288d3c 100644
--- a/src/ir/analysis/has_type_param_in_array.rs
+++ b/src/ir/analysis/has_type_param_in_array.rs
@@ -130,11 +130,11 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
TypeKind::NullPtr |
TypeKind::Int(..) |
TypeKind::Float(..) |
+ TypeKind::Vector(..) |
TypeKind::Complex(..) |
TypeKind::Function(..) |
TypeKind::Enum(..) |
TypeKind::Reference(..) |
- TypeKind::BlockPointer |
TypeKind::TypeParam |
TypeKind::Opaque |
TypeKind::Pointer(..) |
@@ -165,7 +165,8 @@ impl<'ctx> MonotoneFramework for HasTypeParameterInArray<'ctx> {
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |
- TypeKind::Alias(t) => {
+ TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) => {
if self.has_type_parameter_in_array.contains(&t.into()) {
trace!(
" aliases and type refs to T which have array \
diff --git a/src/ir/analysis/sizedness.rs b/src/ir/analysis/sizedness.rs
index e82c1798..9c074355 100644
--- a/src/ir/analysis/sizedness.rs
+++ b/src/ir/analysis/sizedness.rs
@@ -261,7 +261,6 @@ impl<'ctx> MonotoneFramework for SizednessAnalysis<'ctx> {
TypeKind::Enum(..) |
TypeKind::Reference(..) |
TypeKind::NullPtr |
- TypeKind::BlockPointer |
TypeKind::ObjCId |
TypeKind::ObjCSel |
TypeKind::Pointer(..) => {
@@ -276,6 +275,7 @@ impl<'ctx> MonotoneFramework for SizednessAnalysis<'ctx> {
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) |
+ TypeKind::BlockPointer(t) |
TypeKind::ResolvedTypeRef(t) => {
trace!(" aliases and type refs forward to their inner type");
self.forward(t, id)
@@ -295,6 +295,10 @@ impl<'ctx> MonotoneFramework for SizednessAnalysis<'ctx> {
trace!(" arrays of > 0 elements are not zero-sized");
self.insert(id, SizednessResult::NonZeroSized)
}
+ TypeKind::Vector(..) => {
+ trace!(" vectors are not zero-sized");
+ self.insert(id, SizednessResult::NonZeroSized)
+ }
TypeKind::Comp(ref info) => {
trace!(" comp considers its own fields and bases");
diff --git a/src/ir/comment.rs b/src/ir/comment.rs
index 6a87c492..1a76542c 100644
--- a/src/ir/comment.rs
+++ b/src/ir/comment.rs
@@ -35,7 +35,6 @@ fn kind(comment: &str) -> Option<Kind> {
fn make_indent(indent: usize) -> String {
const RUST_INDENTATION: usize = 4;
-
iter::repeat(' ').take(indent * RUST_INDENTATION).collect()
}
@@ -49,12 +48,11 @@ fn preprocess_single_lines(comment: &str, indent: usize) -> String {
let mut is_first = true;
let lines: Vec<_> = comment
.lines()
- .map(|l| l.trim_left_matches('/').trim())
+ .map(|l| l.trim().trim_left_matches('/'))
.map(|l| {
let indent = if is_first { "" } else { &*indent };
is_first = false;
- let maybe_space = if l.is_empty() { "" } else { " " };
- format!("{}///{}{}", indent, maybe_space, l)
+ format!("{}///{}", indent, l)
})
.collect();
lines.join("\n")
@@ -63,30 +61,24 @@ fn preprocess_single_lines(comment: &str, indent: usize) -> String {
fn preprocess_multi_line(comment: &str, indent: usize) -> String {
let comment = comment
.trim_left_matches('/')
- .trim_left_matches('*')
- .trim_left_matches('!')
.trim_right_matches('/')
- .trim_right_matches('*')
- .trim();
+ .trim_right_matches('*');
let indent = make_indent(indent);
// Strip any potential `*` characters preceding each line.
let mut is_first = true;
let mut lines: Vec<_> = comment.lines()
- .map(|line| line.trim().trim_left_matches('*').trim())
- .skip_while(|line| line.is_empty()) // Skip the first empty lines.
+ .map(|line| line.trim().trim_left_matches('*').trim_left_matches('!'))
+ .skip_while(|line| line.trim().is_empty()) // Skip the first empty lines.
.map(|line| {
let indent = if is_first { "" } else { &*indent };
is_first = false;
- let maybe_space = if line.is_empty() { "" } else { " " };
- format!("{}///{}{}", indent, maybe_space, line)
+ format!("{}///{}", indent, line)
})
.collect();
// Remove the trailing line corresponding to the `*/`.
- let last_line_is_empty = lines.last().map_or(false, |l| l.is_empty());
-
- if last_line_is_empty {
+ if lines.last().map_or(false, |l| l.trim().is_empty() || l.trim() == "///") {
lines.pop();
}
@@ -107,6 +99,7 @@ mod test {
fn processes_single_lines_correctly() {
assert_eq!(preprocess("/// hello", 0), "/// hello");
assert_eq!(preprocess("// hello", 0), "/// hello");
+ assert_eq!(preprocess("// hello", 0), "/// hello");
}
#[test]
@@ -118,7 +111,7 @@ mod test {
assert_eq!(
preprocess("/**\nhello\n*world\n*foo\n*/", 0),
- "/// hello\n/// world\n/// foo"
+ "///hello\n///world\n///foo"
);
}
}
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 86dcda56..bdf38428 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -226,7 +226,7 @@ where
}
}
-impl<'a, T> CanDeriveCopy<'a> for T
+impl<T> CanDeriveCopy for T
where
T: Copy + Into<ItemId>
{
@@ -514,12 +514,19 @@ const HOST_TARGET: &'static str =
fn find_effective_target(clang_args: &[String]) -> (String, bool) {
use std::env;
- for opt in clang_args {
+ let mut args = clang_args.iter();
+ while let Some(opt) = args.next() {
if opt.starts_with("--target=") {
let mut split = opt.split('=');
split.next();
return (split.next().unwrap().to_owned(), true);
}
+
+ if opt == "-target" {
+ if let Some(target) = args.next() {
+ return (target.clone(), true);
+ }
+ }
}
// If we're running from a build script, try to find the cargo target.
@@ -562,7 +569,12 @@ impl BindgenContext {
&clang_args,
&options.input_unsaved_files,
parse_options,
- ).expect("TranslationUnit::parse failed")
+ ).expect("libclang error; possible causes include:
+- Invalid flag syntax
+- Unrecognized flags
+- Invalid flag arguments
+- File I/O errors
+If you encounter an error missing from this list, please file an issue or a PR!")
};
let target_info = clang::TargetInfo::new(&translation_unit);
@@ -571,7 +583,10 @@ impl BindgenContext {
{
if let Some(ref ti) = target_info {
if effective_target == HOST_TARGET {
- assert_eq!(ti.pointer_width / 8, mem::size_of::<*mut ()>());
+ assert_eq!(
+ ti.pointer_width / 8, mem::size_of::<*mut ()>(),
+ "{:?} {:?}", effective_target, HOST_TARGET
+ );
}
}
}
@@ -681,7 +696,8 @@ impl BindgenContext {
debug_assert!(
declaration.is_some() || !item.kind().is_type() ||
item.kind().expect_type().is_builtin_or_type_param() ||
- item.kind().expect_type().is_opaque(self, &item),
+ item.kind().expect_type().is_opaque(self, &item) ||
+ item.kind().expect_type().is_unresolved_ref(),
"Adding a type without declaration?"
);
@@ -838,57 +854,58 @@ impl BindgenContext {
name.contains("$") ||
match name {
"abstract" |
- "alignof" |
- "as" |
- "become" |
- "box" |
+ "alignof" |
+ "as" |
+ "async" |
+ "become" |
+ "box" |
"break" |
- "const" |
- "continue" |
- "crate" |
- "do" |
+ "const" |
+ "continue" |
+ "crate" |
+ "do" |
"else" |
- "enum" |
- "extern" |
- "false" |
- "final" |
+ "enum" |
+ "extern" |
+ "false" |
+ "final" |
"fn" |
- "for" |
- "if" |
- "impl" |
- "in" |
+ "for" |
+ "if" |
+ "impl" |
+ "in" |
"let" |
- "loop" |
- "macro" |
- "match" |
- "mod" |
+ "loop" |
+ "macro" |
+ "match" |
+ "mod" |
"move" |
- "mut" |
- "offsetof" |
- "override" |
- "priv" |
+ "mut" |
+ "offsetof" |
+ "override" |
+ "priv" |
"proc" |
- "pub" |
- "pure" |
- "ref" |
- "return" |
+ "pub" |
+ "pure" |
+ "ref" |
+ "return" |
"Self" |
- "self" |
- "sizeof" |
- "static" |
- "struct" |
+ "self" |
+ "sizeof" |
+ "static" |
+ "struct" |
"super" |
- "trait" |
- "true" |
- "type" |
- "typeof" |
+ "trait" |
+ "true" |
+ "type" |
+ "typeof" |
"unsafe" |
- "unsized" |
- "use" |
- "virtual" |
- "where" |
+ "unsized" |
+ "use" |
+ "virtual" |
+ "where" |
"while" |
- "yield" |
+ "yield" |
"bool" |
"_" => true,
_ => false,
@@ -2002,7 +2019,12 @@ impl BindgenContext {
CXType_UChar => TypeKind::Int(IntKind::UChar),
CXType_Short => TypeKind::Int(IntKind::Short),
CXType_UShort => TypeKind::Int(IntKind::UShort),
- CXType_WChar | CXType_Char16 => TypeKind::Int(IntKind::U16),
+ CXType_WChar => {
+ TypeKind::Int(IntKind::WChar {
+ size: ty.fallible_size().expect("Couldn't compute size of wchar_t?"),
+ })
+ },
+ CXType_Char16 => TypeKind::Int(IntKind::U16),
CXType_Char32 => TypeKind::Int(IntKind::U32),
CXType_Long => TypeKind::Int(IntKind::Long),
CXType_ULong => TypeKind::Int(IntKind::ULong),
@@ -2103,21 +2125,9 @@ impl BindgenContext {
}
}
- /// Is the item with the given `name` blacklisted? Or is the item with the given
- /// `name` and `id` replaced by another type, and effectively blacklisted?
- pub fn blacklisted_by_name<Id: Into<ItemId>>(&self, path: &[String], id: Id) -> bool {
- let id = id.into();
- debug_assert!(
- self.in_codegen_phase(),
- "You're not supposed to call this yet"
- );
- self.options.blacklisted_types.matches(&path[1..].join("::")) ||
- self.is_replaced_type(path, id)
- }
-
/// Has the item with the given `name` and `id` been replaced by another
/// type?
- fn is_replaced_type<Id: Into<ItemId>>(&self, path: &[String], id: Id) -> bool {
+ pub fn is_replaced_type<Id: Into<ItemId>>(&self, path: &[String], id: Id) -> bool {
let id = id.into();
match self.replacements.get(path) {
Some(replaced_by) if *replaced_by != id => true,
diff --git a/src/ir/derive.rs b/src/ir/derive.rs
index 65c22158..71854d2e 100644
--- a/src/ir/derive.rs
+++ b/src/ir/derive.rs
@@ -30,15 +30,15 @@ pub trait CanDeriveDebug {
pub trait CanTriviallyDeriveDebug {
/// Return `true` if `Debug` can trivially be derived for this thing,
/// `false` otherwise.
- fn can_trivially_derive_debug(&self) -> bool;
+ fn can_trivially_derive_debug(&self, ctx: &BindgenContext) -> bool;
}
/// A trait that encapsulates the logic for whether or not we can derive `Copy`
/// for a given thing.
-pub trait CanDeriveCopy<'a> {
+pub trait CanDeriveCopy {
/// Return `true` if `Copy` can be derived for this thing, `false`
/// otherwise.
- fn can_derive_copy(&'a self, ctx: &'a BindgenContext) -> bool;
+ fn can_derive_copy(&self, ctx: &BindgenContext) -> bool;
}
/// A trait that encapsulates the logic for whether or not we can trivially
@@ -47,7 +47,7 @@ pub trait CanDeriveCopy<'a> {
pub trait CanTriviallyDeriveCopy {
/// Return `true` if `Copy` can be trivially derived for this thing, `false`
/// otherwise.
- fn can_trivially_derive_copy(&self) -> bool;
+ fn can_trivially_derive_copy(&self, ctx: &BindgenContext) -> bool;
}
/// A trait that encapsulates the logic for whether or not we can derive
@@ -64,7 +64,7 @@ pub trait CanDeriveDefault {
pub trait CanTriviallyDeriveDefault {
/// Return `true` if `Default` can trivially derived for this thing, `false`
/// otherwise.
- fn can_trivially_derive_default(&self) -> bool;
+ fn can_trivially_derive_default(&self, ctx: &BindgenContext) -> bool;
}
/// A trait that encapsulates the logic for whether or not we can derive `Hash`
@@ -111,7 +111,7 @@ pub trait CanDeriveOrd {
pub trait CanTriviallyDeriveHash {
/// Return `true` if `Hash` can trivially be derived for this thing, `false`
/// otherwise.
- fn can_trivially_derive_hash(&self) -> bool;
+ fn can_trivially_derive_hash(&self, ctx: &BindgenContext) -> bool;
}
/// A trait that encapsulates the logic for whether or not we can trivially
@@ -120,11 +120,11 @@ pub trait CanTriviallyDeriveHash {
pub trait CanTriviallyDerivePartialEqOrPartialOrd {
/// Return `Yes` if `PartialEq` or `PartialOrd` can trivially be derived
/// for this thing.
- fn can_trivially_derive_partialeq_or_partialord(&self) -> CanDerive;
+ fn can_trivially_derive_partialeq_or_partialord(&self, ctx: &BindgenContext) -> CanDerive;
}
/// Whether it is possible or not to automatically derive trait for an item.
-///
+///
/// ```ignore
/// No
/// ^
@@ -134,7 +134,7 @@ pub trait CanTriviallyDerivePartialEqOrPartialOrd {
/// |
/// Yes
/// ```
-///
+///
/// Initially we assume that we can derive trait for all types and then
/// update our understanding as we learn more about each type.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord)]
@@ -144,7 +144,7 @@ pub enum CanDerive {
/// The only thing that stops us from automatically deriving is that
/// array with more than maximum number of elements is used.
- ///
+ ///
/// This means we probably can "manually" implement such trait.
ArrayTooLarge,
diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs
index ee705f16..f3da2199 100644
--- a/src/ir/enum_ty.rs
+++ b/src/ir/enum_ty.rs
@@ -2,6 +2,7 @@
use super::context::{BindgenContext, TypeId};
use super::item::Item;
+use super::super::codegen::EnumVariation;
use super::ty::TypeKind;
use clang;
use ir::annotations::Annotations;
@@ -142,32 +143,33 @@ impl Enum {
let path = item.canonical_path(ctx);
let enum_ty = item.expect_type();
- let path_matches = enums.matches(&path[1..].join("::"));
- let enum_is_anon = enum_ty.name().is_none();
- let a_variant_matches = self.variants().iter().any(|v| {
- enums.matches(&v.name())
- });
- path_matches || (enum_is_anon && a_variant_matches)
- }
-
- /// Whether the enum should be a bitfield
- pub fn is_bitfield(&self, ctx: &BindgenContext, item: &Item) -> bool {
- self.is_matching_enum(ctx, &ctx.options().bitfield_enums, item)
- }
+ if enums.matches(&path[1..].join("::")) {
+ return true;
+ }
- /// Whether the enum should be an constified enum module
- pub fn is_constified_enum_module(&self, ctx: &BindgenContext, item: &Item) -> bool {
- self.is_matching_enum(ctx, &ctx.options().constified_enum_modules, item)
- }
+ // Test the variants if the enum is anonymous.
+ if enum_ty.name().is_some() {
+ return false;
+ }
- /// Whether the enum should be an set of constants
- pub fn is_constified_enum(&self, ctx: &BindgenContext, item: &Item) -> bool {
- self.is_matching_enum(ctx, &ctx.options().constified_enums, item)
+ self.variants().iter().any(|v| enums.matches(&v.name()))
}
- /// Whether the enum should be a Rust enum
- pub fn is_rustified_enum(&self, ctx: &BindgenContext, item: &Item) -> bool {
- self.is_matching_enum(ctx, &ctx.options().rustified_enums, item)
+ /// Returns the final representation of the enum.
+ pub fn computed_enum_variation(&self, ctx: &BindgenContext, item: &Item) -> EnumVariation {
+ // ModuleConsts has higher precedence before Rust in order to avoid
+ // problems with overlapping match patterns.
+ if self.is_matching_enum(ctx, &ctx.options().constified_enum_modules, item) {
+ EnumVariation::ModuleConsts
+ } else if self.is_matching_enum(ctx, &ctx.options().bitfield_enums, item) {
+ EnumVariation::Bitfield
+ } else if self.is_matching_enum(ctx, &ctx.options().rustified_enums, item) {
+ EnumVariation::Rust
+ } else if self.is_matching_enum(ctx, &ctx.options().constified_enums, item) {
+ EnumVariation::Consts
+ } else {
+ ctx.options().default_enum_style
+ }
}
}
diff --git a/src/ir/function.rs b/src/ir/function.rs
index 5e8d2fc8..883203e9 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -442,7 +442,16 @@ impl FunctionSig {
ty.ret_type().ok_or(ParseError::Continue)?
};
let ret = Item::from_ty_or_ref(ty_ret_type, cursor, None, ctx);
- let call_conv = ty.call_conv();
+
+ // Clang plays with us at "find the calling convention", see #549 and
+ // co. This seems to be a better fix than that commit.
+ let mut call_conv = ty.call_conv();
+ if let Some(ty) = cursor.cur_type().canonical_type().pointee_type() {
+ let cursor_call_conv = ty.call_conv();
+ if cursor_call_conv != CXCallingConv_Invalid {
+ call_conv = cursor_call_conv;
+ }
+ }
let abi = get_abi(call_conv);
if abi.is_unknown() {
@@ -553,11 +562,7 @@ impl ClangSubItemParser for Function {
name.push_str("_destructor");
}
- let mut mangled_name = cursor_mangling(context, &cursor);
- if mangled_name.as_ref() == Some(&name) {
- mangled_name = None;
- }
-
+ let mangled_name = cursor_mangling(context, &cursor);
let comment = cursor.raw_comment();
let function = Self::new(name, mangled_name, sig, comment, kind, linkage);
@@ -581,26 +586,23 @@ impl Trace for FunctionSig {
}
impl CanTriviallyDeriveDebug for FunctionSig {
- fn can_trivially_derive_debug(&self) -> bool {
+ fn can_trivially_derive_debug(&self, _: &BindgenContext) -> bool {
self.function_pointers_can_derive()
}
}
impl CanTriviallyDeriveHash for FunctionSig {
- fn can_trivially_derive_hash(&self) -> bool {
+ fn can_trivially_derive_hash(&self, _: &BindgenContext) -> bool {
self.function_pointers_can_derive()
}
}
impl CanTriviallyDerivePartialEqOrPartialOrd for FunctionSig {
- fn can_trivially_derive_partialeq_or_partialord(&self) -> CanDerive {
- if self.argument_types.len() > RUST_DERIVE_FUNPTR_LIMIT {
- return CanDerive::No;
- }
-
- match self.abi {
- Abi::C | Abi::Unknown(..) => CanDerive::Yes,
- _ => CanDerive::No,
+ fn can_trivially_derive_partialeq_or_partialord(&self, _: &BindgenContext) -> CanDerive {
+ if self.function_pointers_can_derive() {
+ CanDerive::Yes
+ } else {
+ CanDerive::No
}
}
}
diff --git a/src/ir/int.rs b/src/ir/int.rs
index b7f0f0c5..144a7ded 100644
--- a/src/ir/int.rs
+++ b/src/ir/int.rs
@@ -12,6 +12,12 @@ pub enum IntKind {
/// An `unsigned char`.
UChar,
+ /// An `wchar_t`.
+ WChar {
+ /// The size of the wchar_t in bytes, which will be 2 or 4.
+ size: usize,
+ },
+
/// A platform-dependent `char` type, with the signedness support.
Char {
/// Whether the char is signed for the target platform.
@@ -87,15 +93,16 @@ impl IntKind {
pub fn is_signed(&self) -> bool {
use self::IntKind::*;
match *self {
+ // TODO(emilio): wchar_t can in theory be signed, but we have no way
+ // to know whether it is or not right now (unlike char, there's no
+ // WChar_S / WChar_U).
Bool | UChar | UShort | UInt | ULong | ULongLong | U8 | U16 |
- U32 | U64 | U128 => false,
+ WChar { .. } | U32 | U64 | U128 => false,
SChar | Short | Int | Long | LongLong | I8 | I16 | I32 | I64 |
I128 => true,
- Char {
- is_signed,
- } => is_signed,
+ Char { is_signed } => is_signed,
Custom {
is_signed, ..
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 91ec22b3..5f0ccc0b 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -13,7 +13,7 @@ use super::function::{Function, FunctionKind};
use super::item_kind::ItemKind;
use super::layout::Opaque;
use super::module::Module;
-use super::super::codegen::CONSTIFIED_ENUM_MODULE_REPR_NAME;
+use super::super::codegen::{CONSTIFIED_ENUM_MODULE_REPR_NAME, EnumVariation};
use super::template::{AsTemplateParam, TemplateParameters};
use super::traversal::{EdgeKind, Trace, Tracer};
use super::ty::{Type, TypeKind};
@@ -329,7 +329,7 @@ impl CanDeriveDefault for Item {
}
}
-impl<'a> CanDeriveCopy<'a> for Item {
+impl CanDeriveCopy for Item {
fn can_derive_copy(&self, ctx: &BindgenContext) -> bool {
self.id().can_derive_copy(ctx)
}
@@ -631,8 +631,25 @@ impl Item {
ctx.in_codegen_phase(),
"You're not supposed to call this yet"
);
- self.annotations.hide() ||
- ctx.blacklisted_by_name(&self.canonical_path(ctx), self.id)
+ if self.annotations.hide() {
+ return true;
+ }
+
+ let path = self.canonical_path(ctx);
+ let name = path[1..].join("::");
+ ctx.options().blacklisted_items.matches(&name) ||
+ match self.kind {
+ ItemKind::Type(..) => {
+ ctx.options().blacklisted_types.matches(&name) ||
+ ctx.is_replaced_type(&path, self.id)
+ }
+ ItemKind::Function(..) => {
+ ctx.options().blacklisted_functions.matches(&name)
+ }
+ // TODO: Add constant / namespace blacklisting?
+ ItemKind::Var(..) |
+ ItemKind::Module(..) => false,
+ }
}
/// Is this a reference to another type?
@@ -912,7 +929,7 @@ impl Item {
match *type_.kind() {
TypeKind::Enum(ref enum_) => {
- enum_.is_constified_enum_module(ctx, self)
+ enum_.computed_enum_variation(ctx, self) == EnumVariation::ModuleConsts
}
TypeKind::Alias(inner_id) => {
// TODO(emilio): Make this "hop through type aliases that aren't
@@ -935,21 +952,17 @@ impl Item {
let cc = &ctx.options().codegen_config;
match *self.kind() {
ItemKind::Module(..) => true,
- ItemKind::Var(_) => cc.vars,
- ItemKind::Type(_) => cc.types,
+ ItemKind::Var(_) => cc.vars(),
+ ItemKind::Type(_) => cc.types(),
ItemKind::Function(ref f) => {
match f.kind() {
- FunctionKind::Function => cc.functions,
- FunctionKind::Method(MethodKind::Constructor) => {
- cc.constructors
- }
+ FunctionKind::Function => cc.functions(),
+ FunctionKind::Method(MethodKind::Constructor) => cc.constructors(),
FunctionKind::Method(MethodKind::Destructor) |
- FunctionKind::Method(MethodKind::VirtualDestructor { .. }) => {
- cc.destructors
- }
+ FunctionKind::Method(MethodKind::VirtualDestructor { .. }) => cc.destructors(),
FunctionKind::Method(MethodKind::Static) |
FunctionKind::Method(MethodKind::Normal) |
- FunctionKind::Method(MethodKind::Virtual { .. }) => cc.methods,
+ FunctionKind::Method(MethodKind::Virtual { .. }) => cc.methods(),
}
}
}
@@ -1397,7 +1410,7 @@ impl ClangItemParser for Item {
parent_id.unwrap_or(current_module.into()),
ItemKind::Type(Type::new(None, None, kind, is_const)),
),
- Some(clang::Cursor::null()),
+ None,
None,
);
potential_id.as_type_id_unchecked()
diff --git a/src/ir/layout.rs b/src/ir/layout.rs
index cca33cc3..c34da0e1 100644
--- a/src/ir/layout.rs
+++ b/src/ir/layout.rs
@@ -35,6 +35,21 @@ fn test_layout_for_size() {
}
impl Layout {
+ /// Gets the integer type name for a given known size.
+ pub fn known_type_for_size(
+ ctx: &BindgenContext,
+ size: usize,
+ ) -> Option<&'static str> {
+ Some(match size {
+ 16 if ctx.options().rust_features.i128_and_u128 => "u128",
+ 8 => "u64",
+ 4 => "u32",
+ 2 => "u16",
+ 1 => "u8",
+ _ => return None,
+ })
+ }
+
/// Construct a new `Layout` with the given `size` and `align`. It is not
/// packed.
pub fn new(size: usize, align: usize) -> Self {
@@ -94,20 +109,14 @@ impl Opaque {
/// Return the known rust type we should use to create a correctly-aligned
/// field with this layout.
- pub fn known_rust_type_for_array(&self) -> Option<&'static str> {
- Some(match self.0.align {
- 8 => "u64",
- 4 => "u32",
- 2 => "u16",
- 1 => "u8",
- _ => return None,
- })
+ pub fn known_rust_type_for_array(&self,ctx: &BindgenContext) -> Option<&'static str> {
+ Layout::known_type_for_size(ctx, self.0.align)
}
/// Return the array size that an opaque type for this layout should have if
/// we know the correct type for it, or `None` otherwise.
- pub fn array_size(&self) -> Option<usize> {
- if self.known_rust_type_for_array().is_some() {
+ pub fn array_size(&self, ctx: &BindgenContext) -> Option<usize> {
+ if self.known_rust_type_for_array(ctx).is_some() {
Some(self.0.size / cmp::max(self.0.align, 1))
} else {
None
@@ -117,45 +126,45 @@ impl Opaque {
/// Return `true` if this opaque layout's array size will fit within the
/// maximum number of array elements that Rust allows deriving traits
/// with. Return `false` otherwise.
- pub fn array_size_within_derive_limit(&self) -> bool {
- self.array_size().map_or(false, |size| {
+ pub fn array_size_within_derive_limit(&self, ctx: &BindgenContext) -> bool {
+ self.array_size(ctx).map_or(false, |size| {
size <= RUST_DERIVE_IN_ARRAY_LIMIT
})
}
}
impl CanTriviallyDeriveDebug for Opaque {
- fn can_trivially_derive_debug(&self) -> bool {
- self.array_size_within_derive_limit()
+ fn can_trivially_derive_debug(&self, ctx: &BindgenContext) -> bool {
+ self.array_size_within_derive_limit(ctx)
}
}
impl CanTriviallyDeriveDefault for Opaque {
- fn can_trivially_derive_default(&self) -> bool {
- self.array_size_within_derive_limit()
+ fn can_trivially_derive_default(&self, ctx: &BindgenContext) -> bool {
+ self.array_size_within_derive_limit(ctx)
}
}
impl CanTriviallyDeriveCopy for Opaque {
- fn can_trivially_derive_copy(&self) -> bool {
- self.array_size_within_derive_limit()
+ fn can_trivially_derive_copy(&self, ctx: &BindgenContext) -> bool {
+ self.array_size_within_derive_limit(ctx)
}
}
impl CanTriviallyDeriveHash for Opaque {
- fn can_trivially_derive_hash(&self) -> bool {
- self.array_size_within_derive_limit()
+ fn can_trivially_derive_hash(&self, ctx: &BindgenContext) -> bool {
+ self.array_size_within_derive_limit(ctx)
}
}
impl CanTriviallyDerivePartialEqOrPartialOrd for Opaque {
- fn can_trivially_derive_partialeq_or_partialord(&self) -> CanDerive {
- self.array_size().map_or(CanDerive::No, |size| {
- if size <= RUST_DERIVE_IN_ARRAY_LIMIT {
- CanDerive::Yes
- } else {
- CanDerive::ArrayTooLarge
- }
- })
+ fn can_trivially_derive_partialeq_or_partialord(&self, ctx: &BindgenContext) -> CanDerive {
+ // TODO(emilio): This is inconsistent with the rest of the
+ // CanTriviallyDerive* traits.
+ if self.array_size_within_derive_limit(ctx) {
+ CanDerive::Yes
+ } else {
+ CanDerive::ArrayTooLarge
+ }
}
}
diff --git a/src/ir/template.rs b/src/ir/template.rs
index 61654fe8..14deb6c5 100644
--- a/src/ir/template.rs
+++ b/src/ir/template.rs
@@ -99,7 +99,7 @@ use parse::ClangItemParser;
/// ... |Wtf | ... | [T] |
/// ... |Qux | ... | [] |
/// ----+------+-----+----------------------+
-pub trait TemplateParameters {
+pub trait TemplateParameters : Sized {
/// Get the set of `ItemId`s that make up this template declaration's free
/// template parameters.
///
@@ -108,8 +108,7 @@ pub trait TemplateParameters {
/// parameters. Of course, Rust does not allow generic parameters to be
/// anything but types, so we must treat them as opaque, and avoid
/// instantiating them.
- fn self_template_params(&self, ctx: &BindgenContext)
- -> Vec<TypeId>;
+ fn self_template_params(&self, ctx: &BindgenContext) -> Vec<TypeId>;
/// Get the number of free template parameters this template declaration
/// has.
diff --git a/src/ir/traversal.rs b/src/ir/traversal.rs
index c37b0b5f..dba6ce0e 100644
--- a/src/ir/traversal.rs
+++ b/src/ir/traversal.rs
@@ -232,11 +232,11 @@ pub fn codegen_edges(ctx: &BindgenContext, edge: Edge) -> bool {
EdgeKind::FunctionReturn |
EdgeKind::FunctionParameter |
EdgeKind::VarType |
- EdgeKind::TypeReference => cc.types,
- EdgeKind::InnerVar => cc.vars,
- EdgeKind::Method => cc.methods,
- EdgeKind::Constructor => cc.constructors,
- EdgeKind::Destructor => cc.destructors,
+ EdgeKind::TypeReference => cc.types(),
+ EdgeKind::InnerVar => cc.vars(),
+ EdgeKind::Method => cc.methods(),
+ EdgeKind::Constructor => cc.constructors(),
+ EdgeKind::Destructor => cc.destructors()
}
}
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b805dd62..75d5960d 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -90,6 +90,14 @@ impl Type {
self.name.as_ref().map(|name| &**name)
}
+ /// Whether this is a block pointer type.
+ pub fn is_block_pointer(&self) -> bool {
+ match self.kind {
+ TypeKind::BlockPointer(..) => true,
+ _ => false,
+ }
+ }
+
/// Is this a compound type?
pub fn is_comp(&self) -> bool {
match self.kind {
@@ -155,7 +163,6 @@ impl Type {
TypeKind::Array(..) |
TypeKind::Reference(..) |
TypeKind::Pointer(..) |
- TypeKind::BlockPointer |
TypeKind::Int(..) |
TypeKind::Float(..) |
TypeKind::TypeParam => true,
@@ -216,6 +223,14 @@ impl Type {
}
}
+ /// Is this an unresolved reference?
+ pub fn is_unresolved_ref(&self) -> bool {
+ match self.kind {
+ TypeKind::UnresolvedTypeRef(_, _, _) => true,
+ _ => false,
+ }
+ }
+
/// Is this a incomplete array type?
pub fn is_incomplete_array(&self, ctx: &BindgenContext) -> Option<ItemId> {
match self.kind {
@@ -236,8 +251,7 @@ impl Type {
TypeKind::Comp(ref ci) => ci.layout(ctx),
// FIXME(emilio): This is a hack for anonymous union templates.
// Use the actual pointer size!
- TypeKind::Pointer(..) |
- TypeKind::BlockPointer => {
+ TypeKind::Pointer(..) => {
Some(Layout::new(
ctx.target_pointer_size(),
ctx.target_pointer_size(),
@@ -320,6 +334,7 @@ impl Type {
match self.kind {
TypeKind::TypeParam |
TypeKind::Array(..) |
+ TypeKind::Vector(..) |
TypeKind::Comp(..) |
TypeKind::Opaque |
TypeKind::Int(..) |
@@ -330,7 +345,6 @@ impl Type {
TypeKind::Reference(..) |
TypeKind::Void |
TypeKind::NullPtr |
- TypeKind::BlockPointer |
TypeKind::Pointer(..) |
TypeKind::ObjCId |
TypeKind::ObjCSel |
@@ -338,6 +352,7 @@ impl Type {
TypeKind::ResolvedTypeRef(inner) |
TypeKind::Alias(inner) |
+ TypeKind::BlockPointer(inner) |
TypeKind::TemplateAlias(inner, _) => {
ctx.resolve_type(inner).safe_canonical_type(ctx)
}
@@ -472,10 +487,11 @@ impl TypeKind {
TypeKind::Alias(..) => "Alias",
TypeKind::TemplateAlias(..) => "TemplateAlias",
TypeKind::Array(..) => "Array",
+ TypeKind::Vector(..) => "Vector",
TypeKind::Function(..) => "Function",
TypeKind::Enum(..) => "Enum",
TypeKind::Pointer(..) => "Pointer",
- TypeKind::BlockPointer => "BlockPointer",
+ TypeKind::BlockPointer(..) => "BlockPointer",
TypeKind::Reference(..) => "Reference",
TypeKind::TemplateInstantiation(..) => "TemplateInstantiation",
TypeKind::UnresolvedTypeRef(..) => "UnresolvedTypeRef",
@@ -565,10 +581,11 @@ impl TemplateParameters for TypeKind {
TypeKind::Float(_) |
TypeKind::Complex(_) |
TypeKind::Array(..) |
+ TypeKind::Vector(..) |
TypeKind::Function(_) |
TypeKind::Enum(_) |
TypeKind::Pointer(_) |
- TypeKind::BlockPointer |
+ TypeKind::BlockPointer(_) |
TypeKind::Reference(_) |
TypeKind::UnresolvedTypeRef(..) |
TypeKind::TypeParam |
@@ -627,6 +644,9 @@ pub enum TypeKind {
/// template parameters.
TemplateAlias(TypeId, Vec<TypeId>),
+ /// A packed vector type: element type, number of elements
+ Vector(TypeId, usize),
+
/// An array of a type and a length.
Array(TypeId, usize),
@@ -641,7 +661,7 @@ pub enum TypeKind {
Pointer(TypeId),
/// A pointer to an Apple block.
- BlockPointer,
+ BlockPointer(TypeId),
/// A reference to a type, as in: int& foo().
Reference(TypeId),
@@ -1042,37 +1062,17 @@ impl Type {
CXType_ObjCObjectPointer |
CXType_MemberPointer |
CXType_Pointer => {
- // Fun fact: the canonical type of a pointer type may sometimes
- // contain information we need but isn't present in the concrete
- // type (yeah, I'm equally wat'd).
- //
- // Yet we still have trouble if we unconditionally trust the
- // canonical type, like too-much desugaring (sigh).
- //
- // See tests/headers/call-conv-field.h for an example.
- //
- // Since for now the only identifier cause of breakage is the
- // ABI for function pointers, and different ABI mixed with
- // problematic stuff like that one is _extremely_ unlikely and
- // can be bypassed via blacklisting, we do the check explicitly
- // (as hacky as it is).
- //
- // Yet we should probably (somehow) get the best of both worlds,
- // presumably special-casing function pointers as a whole, yet
- // someone is going to need to care about typedef'd function
- // pointers, etc, which isn't trivial given function pointers
- // are mostly unexposed. I don't have the time for it right now.
- let mut pointee = ty.pointee_type().unwrap();
- let canonical_pointee =
- canonical_ty.pointee_type().unwrap();
- if pointee.call_conv() != canonical_pointee.call_conv() {
- pointee = canonical_pointee;
- }
+ let pointee = ty.pointee_type().unwrap();
let inner =
Item::from_ty_or_ref(pointee, location, None, ctx);
TypeKind::Pointer(inner)
}
- CXType_BlockPointer => TypeKind::BlockPointer,
+ CXType_BlockPointer => {
+ let pointee = ty.pointee_type().expect("Not valid Type?");
+ let inner =
+ Item::from_ty_or_ref(pointee, location, None, ctx);
+ TypeKind::BlockPointer(inner)
+ },
// XXX: RValueReference is most likely wrong, but I don't think we
// can even add bindings for that, so huh.
CXType_RValueReference |
@@ -1148,12 +1148,15 @@ impl Type {
TypeKind::Comp(complex)
}
- // FIXME: We stub vectors as arrays since in 99% of the cases the
- // layout is going to be correct, and there's no way we can generate
- // vector types properly in Rust for now.
- //
- // That being said, that should be fixed eventually.
- CXType_Vector |
+ CXType_Vector => {
+ let inner = Item::from_ty(
+ ty.elem_type().as_ref().unwrap(),
+ location,
+ None,
+ ctx,
+ ).expect("Not able to resolve vector element?");
+ TypeKind::Vector(inner, ty.num_elements().unwrap())
+ }
CXType_ConstantArray => {
let inner = Item::from_ty(
ty.elem_type().as_ref().unwrap(),
@@ -1214,6 +1217,8 @@ impl Trace for Type {
TypeKind::Pointer(inner) |
TypeKind::Reference(inner) |
TypeKind::Array(inner, _) |
+ TypeKind::Vector(inner, _) |
+ TypeKind::BlockPointer(inner) |
TypeKind::Alias(inner) |
TypeKind::ResolvedTypeRef(inner) => {
tracer.visit_kind(inner.into(), EdgeKind::TypeReference);
@@ -1255,8 +1260,7 @@ impl Trace for Type {
TypeKind::Float(_) |
TypeKind::Complex(_) |
TypeKind::ObjCId |
- TypeKind::ObjCSel |
- TypeKind::BlockPointer => {}
+ TypeKind::ObjCSel => {}
}
}
}
diff --git a/src/ir/var.rs b/src/ir/var.rs
index 25ac56d2..e29985ef 100644
--- a/src/ir/var.rs
+++ b/src/ir/var.rs
@@ -265,8 +265,7 @@ impl ClangSubItemParser for Var {
let mut val = cursor
.evaluate()
- .and_then(|v| v.as_int())
- .map(|val| val as i64);
+ .and_then(|v| v.as_int());
if val.is_none() || !kind.signedness_matches(val.unwrap()) {
let tu = ctx.translation_unit();
val = get_integer_literal_from_cursor(&cursor, tu);
@@ -305,14 +304,14 @@ fn parse_macro(
ctx: &BindgenContext,
cursor: &clang::Cursor,
) -> Option<(Vec<u8>, cexpr::expr::EvalResult)> {
- use cexpr::{expr, nom};
+ use cexpr::expr;
let mut cexpr_tokens = cursor.cexpr_tokens()?;
let parser = expr::IdentifierParser::new(ctx.parsed_macros());
match parser.macro_definition(&cexpr_tokens) {
- nom::IResult::Done(_, (id, val)) => {
+ Ok((_, (id, val))) => {
return Some((id.into(), val));
}
_ => {}
@@ -327,20 +326,20 @@ fn parse_macro(
cexpr_tokens.pop()?;
match parser.macro_definition(&cexpr_tokens) {
- nom::IResult::Done(_, (id, val)) => Some((id.into(), val)),
+ Ok((_, (id, val))) => Some((id.into(), val)),
_ => None,
}
}
fn parse_int_literal_tokens(cursor: &clang::Cursor) -> Option<i64> {
- use cexpr::{expr, nom};
+ use cexpr::expr;
use cexpr::expr::EvalResult;
let cexpr_tokens = cursor.cexpr_tokens()?;
// TODO(emilio): We can try to parse other kinds of literals.
match expr::expr(&cexpr_tokens) {
- nom::IResult::Done(_, EvalResult::Int(Wrapping(val))) => Some(val),
+ Ok((_, EvalResult::Int(Wrapping(val)))) => Some(val),
_ => None,
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 7dd39138..039bd39a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,6 +16,8 @@
// `quote!` nests quite deeply.
#![recursion_limit="128"]
+#[macro_use]
+extern crate bitflags;
extern crate cexpr;
#[macro_use]
#[allow(unused_extern_crates)]
@@ -94,48 +96,59 @@ use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::Arc;
-/// A type used to indicate which kind of items do we have to generate.
-///
-/// TODO(emilio): Use `bitflags!`
-#[derive(Debug, Clone)]
-pub struct CodegenConfig {
- /// Whether to generate functions.
- pub functions: bool,
- /// Whether to generate types.
- pub types: bool,
- /// Whether to generate constants.
- pub vars: bool,
- /// Whether to generate methods.
- pub methods: bool,
- /// Whether to generate constructors.
- pub constructors: bool,
- /// Whether to generate destructors.
- pub destructors: bool,
+fn args_are_cpp(clang_args: &[String]) -> bool {
+ return clang_args
+ .windows(2)
+ .any(|w| w[0] == "-xc++" || w[1] == "-xc++" || w == &["-x", "c++"]);
+}
+
+bitflags! {
+ /// A type used to indicate which kind of items we have to generate.
+ pub struct CodegenConfig: u32 {
+ /// Whether to generate functions.
+ const FUNCTIONS = 1 << 0;
+ /// Whether to generate types.
+ const TYPES = 1 << 1;
+ /// Whether to generate constants.
+ const VARS = 1 << 2;
+ /// Whether to generate methods.
+ const METHODS = 1 << 3;
+ /// Whether to generate constructors
+ const CONSTRUCTORS = 1 << 4;
+ /// Whether to generate destructors.
+ const DESTRUCTORS = 1 << 5;
+ }
}
impl CodegenConfig {
- /// Generate all kinds of items.
- pub fn all() -> Self {
- CodegenConfig {
- functions: true,
- types: true,
- vars: true,
- methods: true,
- constructors: true,
- destructors: true,
- }
+ /// Returns true if functions should be generated.
+ pub fn functions(self) -> bool {
+ self.contains(CodegenConfig::FUNCTIONS)
}
- /// Generate nothing.
- pub fn nothing() -> Self {
- CodegenConfig {
- functions: false,
- types: false,
- vars: false,
- methods: false,
- constructors: false,
- destructors: false,
- }
+ /// Returns true if types should be generated.
+ pub fn types(self) -> bool {
+ self.contains(CodegenConfig::TYPES)
+ }
+
+ /// Returns true if constants should be generated.
+ pub fn vars(self) -> bool {
+ self.contains(CodegenConfig::VARS)
+ }
+
+ /// Returns true if methds should be generated.
+ pub fn methods(self) -> bool {
+ self.contains(CodegenConfig::METHODS)
+ }
+
+ /// Returns true if constructors should be generated.
+ pub fn constructors(self) -> bool {
+ self.contains(CodegenConfig::CONSTRUCTORS)
+ }
+
+ /// Returns true if destructors should be generated.
+ pub fn destructors(self) -> bool {
+ self.contains(CodegenConfig::DESTRUCTORS)
}
}
@@ -284,6 +297,34 @@ impl Builder {
})
.count();
+ self.options
+ .blacklisted_functions
+ .get_items()
+ .iter()
+ .map(|item| {
+ output_vector.push("--blacklist-function".into());
+ output_vector.push(
+ item.trim_left_matches("^")
+ .trim_right_matches("$")
+ .into(),
+ );
+ })
+ .count();
+
+ self.options
+ .blacklisted_items
+ .get_items()
+ .iter()
+ .map(|item| {
+ output_vector.push("--blacklist-item".into());
+ output_vector.push(
+ item.trim_left_matches("^")
+ .trim_right_matches("$")
+ .into(),
+ );
+ })
+ .count();
+
if !self.options.layout_tests {
output_vector.push("--no-layout-tests".into());
}
@@ -346,6 +387,14 @@ impl Builder {
output_vector.push("--objc-extern-crate".into());
}
+ if self.options.generate_block {
+ output_vector.push("--generate-block".into());
+ }
+
+ if self.options.block_extern_crate {
+ output_vector.push("--block-extern-crate".into());
+ }
+
if self.options.builtins {
output_vector.push("--builtins".into());
}
@@ -373,7 +422,7 @@ impl Builder {
output_vector.push("--disable-name-namespacing".into());
}
- if !self.options.codegen_config.functions {
+ if !self.options.codegen_config.functions() {
output_vector.push("--ignore-functions".into());
}
@@ -381,28 +430,28 @@ impl Builder {
//Temporary placeholder for below 4 options
let mut options: Vec<String> = Vec::new();
- if self.options.codegen_config.functions {
+ if self.options.codegen_config.functions() {
options.push("function".into());
}
- if self.options.codegen_config.types {
+ if self.options.codegen_config.types() {
options.push("types".into());
}
- if self.options.codegen_config.vars {
+ if self.options.codegen_config.vars() {
options.push("vars".into());
}
- if self.options.codegen_config.methods {
+ if self.options.codegen_config.methods() {
options.push("methods".into());
}
- if self.options.codegen_config.constructors {
+ if self.options.codegen_config.constructors() {
options.push("constructors".into());
}
- if self.options.codegen_config.destructors {
+ if self.options.codegen_config.destructors() {
options.push("destructors".into());
}
output_vector.push(options.join(","));
- if !self.options.codegen_config.methods {
+ if !self.options.codegen_config.methods() {
output_vector.push("--ignore-methods".into());
}
@@ -673,6 +722,19 @@ impl Builder {
self
}
+ /// Generate proper block signatures instead of void pointers.
+ pub fn generate_block(mut self, doit: bool) -> Self {
+ self.options.generate_block = doit;
+ self
+ }
+
+ /// Generate `#[macro_use] extern crate block;` instead of `use block;`
+ /// in the prologue of the files generated from apple block files
+ pub fn block_extern_crate(mut self, doit: bool) -> Self {
+ self.options.block_extern_crate = doit;
+ self
+ }
+
/// Whether to use the clang-provided name mangling. This is true by default
/// and probably needed for C++ features.
///
@@ -699,6 +761,21 @@ impl Builder {
self
}
+ /// Hide the given function from the generated bindings. Regular expressions
+ /// are supported.
+ pub fn blacklist_function<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blacklisted_functions.insert(arg);
+ self
+ }
+
+ /// Hide the given item from the generated bindings, regardless of
+ /// whether it's a type, function, module, etc. Regular
+ /// expressions are supported.
+ pub fn blacklist_item<T: AsRef<str>>(mut self, arg: T) -> Builder {
+ self.options.blacklisted_items.insert(arg);
+ self
+ }
+
/// Treat the given type as opaque in the generated bindings. Regular
/// expressions are supported.
pub fn opaque_type<T: AsRef<str>>(mut self, arg: T) -> Builder {
@@ -1043,13 +1120,13 @@ impl Builder {
/// Ignore functions.
pub fn ignore_functions(mut self) -> Builder {
- self.options.codegen_config.functions = false;
+ self.options.codegen_config.remove(CodegenConfig::FUNCTIONS);
self
}
/// Ignore methods.
pub fn ignore_methods(mut self) -> Builder {
- self.options.codegen_config.methods = false;
+ self.options.codegen_config.remove(CodegenConfig::METHODS);
self
}
@@ -1150,7 +1227,7 @@ impl Builder {
|| name_file.ends_with(".hh")
|| name_file.ends_with(".h++")
}
-
+
let clang = clang_sys::support::Clang::find(None, &[]).ok_or_else(|| {
io::Error::new(io::ErrorKind::Other, "Cannot find clang executable")
})?;
@@ -1160,9 +1237,7 @@ impl Builder {
let mut wrapper_contents = String::new();
// Whether we are working with C or C++ inputs.
- let mut is_cpp = self.options.clang_args.windows(2).any(|w| {
- w[0] == "-x=c++" || w[1] == "-x=c++" || w == &["-x", "c++"]
- });
+ let mut is_cpp = args_are_cpp(&self.options.clang_args);
// For each input header, add `#include "$header"`.
for header in &self.input_headers {
@@ -1256,6 +1331,14 @@ struct BindgenOptions {
/// anywhere in the generated code.
blacklisted_types: RegexSet,
+ /// The set of functions that have been blacklisted and should not appear
+ /// in the generated code.
+ blacklisted_functions: RegexSet,
+
+ /// The set of items, regardless of item-type, that have been
+ /// blacklisted and should not appear in the generated code.
+ blacklisted_items: RegexSet,
+
/// The set of types that should be treated as opaque structures in the
/// generated code.
opaque_types: RegexSet,
@@ -1418,6 +1501,14 @@ struct BindgenOptions {
/// generate '#[macro_use] extern crate objc;'
objc_extern_crate: bool,
+ /// Instead of emitting 'use block;' to files generated from objective c files,
+ /// generate '#[macro_use] extern crate block;'
+ generate_block: bool,
+
+ /// Instead of emitting 'use block;' to files generated from objective c files,
+ /// generate '#[macro_use] extern crate block;'
+ block_extern_crate: bool,
+
/// Whether to use the clang-provided name mangling. This is true and
/// probably needed for C++ features.
///
@@ -1465,6 +1556,8 @@ impl BindgenOptions {
self.whitelisted_types.build();
self.whitelisted_functions.build();
self.blacklisted_types.build();
+ self.blacklisted_functions.build();
+ self.blacklisted_items.build();
self.opaque_types.build();
self.bitfield_enums.build();
self.constified_enums.build();
@@ -1494,9 +1587,11 @@ impl Default for BindgenOptions {
let rust_target = RustTarget::default();
BindgenOptions {
- rust_target: rust_target,
+ rust_target,
rust_features: rust_target.into(),
blacklisted_types: Default::default(),
+ blacklisted_functions: Default::default(),
+ blacklisted_items: Default::default(),
opaque_types: Default::default(),
rustfmt_path: Default::default(),
whitelisted_types: Default::default(),
@@ -1540,7 +1635,9 @@ impl Default for BindgenOptions {
generate_comments: true,
generate_inline_functions: false,
whitelist_recursively: true,
+ generate_block: false,
objc_extern_crate: false,
+ block_extern_crate: false,
enable_mangling: true,
prepend_enum_name: true,
time_phases: false,
@@ -1621,8 +1718,7 @@ impl Bindings {
if let Some(clang) = clang_sys::support::Clang::find(
None,
&clang_args_for_clang_sys,
- )
- {
+ ) {
// If --target is specified, assume caller knows what they're doing
// and don't mess with include paths for them
let has_target_arg = options
@@ -1631,10 +1727,16 @@ impl Bindings {
.rposition(|arg| arg.starts_with("--target"))
.is_some();
if !has_target_arg {
- // TODO: distinguish C and C++ paths? C++'s should be enough, I
- // guess.
- if let Some(cpp_search_paths) = clang.cpp_search_paths {
- for path in cpp_search_paths.into_iter() {
+ // Whether we are working with C or C++ inputs.
+ let is_cpp = args_are_cpp(&options.clang_args);
+ let search_paths = if is_cpp {
+ clang.cpp_search_paths
+ } else {
+ clang.c_search_paths
+ };
+
+ if let Some(search_paths) = search_paths {
+ for path in search_paths.into_iter() {
if let Ok(path) = path.into_os_string().into_string() {
options.clang_args.push("-isystem".to_owned());
options.clang_args.push(path);
diff --git a/src/options.rs b/src/options.rs
index 5169fb9a..3594be4e 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -71,6 +71,20 @@ where
.takes_value(true)
.multiple(true)
.number_of_values(1),
+ Arg::with_name("blacklist-function")
+ .long("blacklist-function")
+ .help("Mark <function> as hidden.")
+ .value_name("function")
+ .takes_value(true)
+ .multiple(true)
+ .number_of_values(1),
+ Arg::with_name("blacklist-item")
+ .long("blacklist-item")
+ .help("Mark <item> as hidden.")
+ .value_name("item")
+ .takes_value(true)
+ .multiple(true)
+ .number_of_values(1),
Arg::with_name("no-layout-tests")
.long("no-layout-tests")
.help("Avoid generating layout tests for any type."),
@@ -125,6 +139,12 @@ where
Arg::with_name("objc-extern-crate")
.long("objc-extern-crate")
.help("Use extern crate instead of use for objc."),
+ Arg::with_name("generate-block")
+ .long("generate-block")
+ .help("Generate block signatures instead of void pointers."),
+ Arg::with_name("block-extern-crate")
+ .long("block-extern-crate")
+ .help("Use extern crate instead of use for block."),
Arg::with_name("distrust-clang-mangling")
.long("distrust-clang-mangling")
.help("Do not trust the libclang-provided mangling"),
@@ -143,6 +163,7 @@ where
.help("Time the different bindgen phases and print to stderr"),
// All positional arguments after the end of options marker, `--`
Arg::with_name("clang-args")
+ .last(true)
.multiple(true),
Arg::with_name("emit-clang-ast")
.long("emit-clang-ast")
@@ -350,6 +371,18 @@ where
}
}
+ if let Some(hidden_functions) = matches.values_of("blacklist-function") {
+ for fun in hidden_functions {
+ builder = builder.blacklist_function(fun);
+ }
+ }
+
+ if let Some(hidden_identifiers) = matches.values_of("blacklist-item") {
+ for id in hidden_identifiers {
+ builder = builder.blacklist_item(id);
+ }
+ }
+
if matches.is_present("builtins") {
builder = builder.emit_builtins();
}
@@ -415,15 +448,15 @@ where
}
if let Some(what_to_generate) = matches.value_of("generate") {
- let mut config = CodegenConfig::nothing();
+ let mut config = CodegenConfig::empty();
for what in what_to_generate.split(",") {
match what {
- "functions" => config.functions = true,
- "types" => config.types = true,
- "vars" => config.vars = true,
- "methods" => config.methods = true,
- "constructors" => config.constructors = true,
- "destructors" => config.destructors = true,
+ "functions" => config.insert(CodegenConfig::FUNCTIONS),
+ "types" => config.insert(CodegenConfig::TYPES),
+ "vars" => config.insert(CodegenConfig::VARS),
+ "methods" => config.insert(CodegenConfig::METHODS),
+ "constructors" => config.insert(CodegenConfig::CONSTRUCTORS),
+ "destructors" => config.insert(CodegenConfig::DESTRUCTORS),
otherwise => {
return Err(Error::new(
ErrorKind::Other,
@@ -479,6 +512,14 @@ where
builder = builder.objc_extern_crate(true);
}
+ if matches.is_present("generate-block") {
+ builder = builder.generate_block(true);
+ }
+
+ if matches.is_present("block-extern-crate") {
+ builder = builder.block_extern_crate(true);
+ }
+
if let Some(opaque_types) = matches.values_of("opaque-type") {
for ty in opaque_types {
builder = builder.opaque_type(ty);
diff --git a/src/regex_set.rs b/src/regex_set.rs
index 8bd3ea7f..ce8714d4 100644
--- a/src/regex_set.rs
+++ b/src/regex_set.rs
@@ -2,9 +2,6 @@
use regex::RegexSet as RxSet;
-// Yeah, I'm aware this is sorta crappy, should be cheaper to compile a regex
-// ORing all the patterns, I guess...
-
/// A dynamic set of regular expressions.
#[derive(Debug)]
pub struct RegexSet {
diff --git a/tests/expectations/Cargo.toml b/tests/expectations/Cargo.toml
index e0da6d5a..6acb1d40 100644
--- a/tests/expectations/Cargo.toml
+++ b/tests/expectations/Cargo.toml
@@ -10,3 +10,4 @@ authors = [
[dependencies]
objc = "0.2"
+block = "0.1" \ No newline at end of file
diff --git a/tests/expectations/tests/16-byte-alignment_1_0.rs b/tests/expectations/tests/16-byte-alignment_1_0.rs
index f37721a4..ae219a7c 100644
--- a/tests/expectations/tests/16-byte-alignment_1_0.rs
+++ b/tests/expectations/tests/16-byte-alignment_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/anon_enum_trait.rs b/tests/expectations/tests/anon_enum_trait.rs
index 6eb9f440..e109c90d 100644
--- a/tests/expectations/tests/anon_enum_trait.rs
+++ b/tests/expectations/tests/anon_enum_trait.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
diff --git a/tests/expectations/tests/anon_struct_in_union_1_0.rs b/tests/expectations/tests/anon_struct_in_union_1_0.rs
index 63e2e45a..d8840029 100644
--- a/tests/expectations/tests/anon_struct_in_union_1_0.rs
+++ b/tests/expectations/tests/anon_struct_in_union_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/anon_union.rs b/tests/expectations/tests/anon_union.rs
index 446cd589..a9b60292 100644
--- a/tests/expectations/tests/anon_union.rs
+++ b/tests/expectations/tests/anon_union.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
pub struct TErrorResult {
@@ -9,8 +14,9 @@ pub struct TErrorResult {
pub mMightHaveUnreported: bool,
pub mUnionState: TErrorResult_UnionState,
}
-pub const TErrorResult_UnionState_HasException: TErrorResult_UnionState =
- TErrorResult_UnionState::HasMessage;
+impl TErrorResult_UnionState {
+ pub const HasException: TErrorResult_UnionState = TErrorResult_UnionState::HasMessage;
+}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum TErrorResult_UnionState {
diff --git a/tests/expectations/tests/anon_union_1_0.rs b/tests/expectations/tests/anon_union_1_0.rs
index 60e2e0c5..e915237d 100644
--- a/tests/expectations/tests/anon_union_1_0.rs
+++ b/tests/expectations/tests/anon_union_1_0.rs
@@ -32,7 +32,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/bitfield-32bit-overflow.rs b/tests/expectations/tests/bitfield-32bit-overflow.rs
index 7270649e..905c7268 100644
--- a/tests/expectations/tests/bitfield-32bit-overflow.rs
+++ b/tests/expectations/tests/bitfield-32bit-overflow.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs
index 7b93f119..1a0dbdb4 100644
--- a/tests/expectations/tests/bitfield-large.rs
+++ b/tests/expectations/tests/bitfield-large.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/bitfield-method-same-name.rs b/tests/expectations/tests/bitfield-method-same-name.rs
index b8700605..8dda4538 100644
--- a/tests/expectations/tests/bitfield-method-same-name.rs
+++ b/tests/expectations/tests/bitfield-method-same-name.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/bitfield_align.rs b/tests/expectations/tests/bitfield_align.rs
index 9821aa6f..0600052b 100644
--- a/tests/expectations/tests/bitfield_align.rs
+++ b/tests/expectations/tests/bitfield_align.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/bitfield_align_2.rs b/tests/expectations/tests/bitfield_align_2.rs
index 5d63699d..7f5f689d 100644
--- a/tests/expectations/tests/bitfield_align_2.rs
+++ b/tests/expectations/tests/bitfield_align_2.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs
index e557f92b..d778dd9b 100644
--- a/tests/expectations/tests/bitfield_method_mangling.rs
+++ b/tests/expectations/tests/bitfield_method_mangling.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/blacklist-and-impl-debug.rs b/tests/expectations/tests/blacklist-and-impl-debug.rs
index a5528af1..140342be 100644
--- a/tests/expectations/tests/blacklist-and-impl-debug.rs
+++ b/tests/expectations/tests/blacklist-and-impl-debug.rs
@@ -40,7 +40,7 @@ impl Default for ShouldManuallyImplDebug {
}
}
impl ::std::fmt::Debug for ShouldManuallyImplDebug {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "ShouldManuallyImplDebug {{ }}")
}
}
diff --git a/tests/expectations/tests/blacklist-function.rs b/tests/expectations/tests/blacklist-function.rs
new file mode 100644
index 00000000..b1d55643
--- /dev/null
+++ b/tests/expectations/tests/blacklist-function.rs
@@ -0,0 +1,26 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
+pub mod root {
+ #[allow(unused_imports)]
+ use self::super::root;
+ pub mod foo {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ }
+ pub mod bar {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ extern "C" {
+ #[link_name = "\u{1}_ZN3bar18NamespacedFunctionEv"]
+ pub fn NamespacedFunction();
+ }
+ }
+}
diff --git a/tests/expectations/tests/blacklist-item.rs b/tests/expectations/tests/blacklist-item.rs
new file mode 100644
index 00000000..b1d55643
--- /dev/null
+++ b/tests/expectations/tests/blacklist-item.rs
@@ -0,0 +1,26 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
+pub mod root {
+ #[allow(unused_imports)]
+ use self::super::root;
+ pub mod foo {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ }
+ pub mod bar {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ extern "C" {
+ #[link_name = "\u{1}_ZN3bar18NamespacedFunctionEv"]
+ pub fn NamespacedFunction();
+ }
+ }
+}
diff --git a/tests/expectations/tests/blocks-signature.rs b/tests/expectations/tests/blocks-signature.rs
new file mode 100644
index 00000000..69dbbed8
--- /dev/null
+++ b/tests/expectations/tests/blocks-signature.rs
@@ -0,0 +1,24 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+#![cfg(target_os = "macos")]
+
+extern crate block;
+extern "C" {
+ #[link_name = "\u{1}_Z8atexit_bU13block_pointerFvvE"]
+ pub fn atexit_b(arg1: _bindgen_ty_id_20);
+}
+pub type dispatch_data_t = *mut ::std::os::raw::c_void;
+pub type dispatch_data_applier_t = _bindgen_ty_id_27;
+extern "C" {
+ #[link_name = "\u{1}_Z19dispatch_data_applyPvU13block_pointerFbS_yPKvyE"]
+ pub fn dispatch_data_apply(data: dispatch_data_t, applier: dispatch_data_applier_t) -> bool;
+}
+pub type _bindgen_ty_id_20 = *const ::block::Block<(), ()>;
+pub type _bindgen_ty_id_27 =
+ *const ::block::Block<(dispatch_data_t, usize, *const ::std::os::raw::c_void, usize), bool>;
diff --git a/tests/expectations/tests/blocks.rs b/tests/expectations/tests/blocks.rs
index 40ee5c50..70b616b8 100644
--- a/tests/expectations/tests/blocks.rs
+++ b/tests/expectations/tests/blocks.rs
@@ -1,9 +1,20 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+#![cfg(target_os = "macos")]
extern "C" {
+ #[link_name = "\u{1}_Z8atexit_bU13block_pointerFvvE"]
pub fn atexit_b(arg1: *mut ::std::os::raw::c_void);
}
+pub type dispatch_data_t = *mut ::std::os::raw::c_void;
+pub type dispatch_data_applier_t = *mut ::std::os::raw::c_void;
+extern "C" {
+ #[link_name = "\u{1}_Z19dispatch_data_applyPvU13block_pointerFbS_yPKvyE"]
+ pub fn dispatch_data_apply(data: dispatch_data_t, applier: dispatch_data_applier_t) -> bool;
+}
diff --git a/tests/expectations/tests/call-conv-typedef.rs b/tests/expectations/tests/call-conv-typedef.rs
new file mode 100644
index 00000000..f30d2356
--- /dev/null
+++ b/tests/expectations/tests/call-conv-typedef.rs
@@ -0,0 +1,13 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+#![cfg(not(test))]
+
+pub type void_fn = ::std::option::Option<unsafe extern "stdcall" fn()>;
+pub type fn_ =
+ ::std::option::Option<unsafe extern "stdcall" fn(id: ::std::os::raw::c_int) -> void_fn>;
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index b5083957..f7639aac 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -30,7 +30,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
diff --git a/tests/expectations/tests/class_1_0.rs b/tests/expectations/tests/class_1_0.rs
index 333a6eb4..a5639b25 100644
--- a/tests/expectations/tests/class_1_0.rs
+++ b/tests/expectations/tests/class_1_0.rs
@@ -30,7 +30,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
@@ -71,7 +71,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/class_with_inner_struct_1_0.rs b/tests/expectations/tests/class_with_inner_struct_1_0.rs
index a2c01b4e..3a8ca37a 100644
--- a/tests/expectations/tests/class_with_inner_struct_1_0.rs
+++ b/tests/expectations/tests/class_with_inner_struct_1_0.rs
@@ -32,7 +32,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs
index 07279cf3..f1dc139c 100644
--- a/tests/expectations/tests/constify-enum.rs
+++ b/tests/expectations/tests/constify-enum.rs
@@ -1,11 +1,17 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const nsCSSPropertyID_eCSSProperty_COUNT_unexistingVariantValue: nsCSSPropertyID =
nsCSSPropertyID::eCSSProperty_COUNT_unexistingVariantValue;
-pub const nsCSSPropertyID_eCSSProperty_COUNT: nsCSSPropertyID =
- nsCSSPropertyID::eCSSPropertyAlias_aa;
+impl nsCSSPropertyID {
+ pub const eCSSProperty_COUNT: nsCSSPropertyID = nsCSSPropertyID::eCSSPropertyAlias_aa;
+}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum nsCSSPropertyID {
@@ -13,6 +19,6 @@ pub enum nsCSSPropertyID {
eCSSProperty_b = 1,
eCSSPropertyAlias_aa = 2,
eCSSPropertyAlias_bb = 3,
- /// < <div rustbindgen constant></div>
+ ///< <div rustbindgen constant></div>
eCSSProperty_COUNT_unexistingVariantValue = 4,
}
diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs
index f9f8e200..8058af10 100644
--- a/tests/expectations/tests/convert-cpp-comment-to-rust.rs
+++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs
@@ -1,19 +1,22 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub type mbedtls_mpi_uint = ::std::os::raw::c_uint;
/// \brief MPI structure
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct mbedtls_mpi {
- /// < integer sign
+ ///< integer sign
pub s: ::std::os::raw::c_int,
- /// < total # of limbs
+ ///< total # of limbs
pub n: ::std::os::raw::c_ulong,
- /// < pointer to limbs
+ ///< pointer to limbs
pub p: *mut mbedtls_mpi_uint,
}
#[test]
diff --git a/tests/expectations/tests/convert-floats.rs b/tests/expectations/tests/convert-floats.rs
index e1e93a13..e6abee16 100644
--- a/tests/expectations/tests/convert-floats.rs
+++ b/tests/expectations/tests/convert-floats.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
@@ -16,7 +19,7 @@ pub struct foo {
pub bar: ::std::os::raw::c_float,
pub baz: ::std::os::raw::c_float,
pub bazz: ::std::os::raw::c_double,
- pub bazzz: *mut ::std::os::raw::c_double,
+ pub bazzz: *mut f64,
pub complexFloat: __BindgenComplex<::std::os::raw::c_float>,
pub complexDouble: __BindgenComplex<::std::os::raw::c_double>,
}
diff --git a/tests/expectations/tests/default-enum-style-constified-module.rs b/tests/expectations/tests/default-enum-style-constified-module.rs
new file mode 100644
index 00000000..4b71efdd
--- /dev/null
+++ b/tests/expectations/tests/default-enum-style-constified-module.rs
@@ -0,0 +1,18 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+pub mod Foo {
+ pub type Type = u32;
+ pub const bar: Type = 0;
+ pub const baz: Type = 1;
+ pub const blap: Type = 2;
+}
+extern "C" {
+ pub fn func(x: Foo::Type);
+}
diff --git a/tests/expectations/tests/derive-bitfield-method-same-name.rs b/tests/expectations/tests/derive-bitfield-method-same-name.rs
index f9d29afd..c23b0264 100644
--- a/tests/expectations/tests/derive-bitfield-method-same-name.rs
+++ b/tests/expectations/tests/derive-bitfield-method-same-name.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -133,7 +152,7 @@ impl Default for Foo {
}
}
impl ::std::fmt::Debug for Foo {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(
f,
"Foo {{ large: [{}], type_ : {:?}, }}",
diff --git a/tests/expectations/tests/derive-debug-bitfield-core.rs b/tests/expectations/tests/derive-debug-bitfield-core.rs
new file mode 100644
index 00000000..59a01dbf
--- /dev/null
+++ b/tests/expectations/tests/derive-debug-bitfield-core.rs
@@ -0,0 +1,191 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern crate core;
+
+#[repr(C)]
+#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub struct __BindgenBitfieldUnit<Storage, Align>
+where
+ Storage: AsRef<[u8]> + AsMut<[u8]>,
+{
+ storage: Storage,
+ align: [Align; 0],
+}
+
+impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
+where
+ Storage: AsRef<[u8]> + AsMut<[u8]>,
+{
+ #[inline]
+ pub fn new(storage: Storage) -> Self {
+ Self { storage, align: [] }
+ }
+
+ #[inline]
+ pub fn get_bit(&self, index: usize) -> bool {
+ debug_assert!(index / 8 < self.storage.as_ref().len());
+
+ let byte_index = index / 8;
+ let byte = self.storage.as_ref()[byte_index];
+
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
+ let mask = 1 << bit_index;
+
+ byte & mask == mask
+ }
+
+ #[inline]
+ pub fn set_bit(&mut self, index: usize, val: bool) {
+ debug_assert!(index / 8 < self.storage.as_ref().len());
+
+ let byte_index = index / 8;
+ let byte = &mut self.storage.as_mut()[byte_index];
+
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
+ let mask = 1 << bit_index;
+ if val {
+ *byte |= mask;
+ } else {
+ *byte &= !mask;
+ }
+ }
+
+ #[inline]
+ pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
+ debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
+
+ let mut val = 0;
+
+ for i in 0..(bit_width as usize) {
+ if self.get_bit(i + bit_offset) {
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
+ }
+ }
+
+ val
+ }
+
+ #[inline]
+ pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
+ debug_assert!(bit_width <= 64);
+ debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
+ debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
+
+ for i in 0..(bit_width as usize) {
+ let mask = 1 << i;
+ let val_bit_is_set = val & mask == mask;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
+ }
+ }
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct C {
+ pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
+ pub large_array: [::std::os::raw::c_int; 50usize],
+}
+#[test]
+fn bindgen_test_layout_C() {
+ assert_eq!(
+ ::core::mem::size_of::<C>(),
+ 204usize,
+ concat!("Size of: ", stringify!(C))
+ );
+ assert_eq!(
+ ::core::mem::align_of::<C>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(C))
+ );
+ assert_eq!(
+ unsafe { &(*(::core::ptr::null::<C>())).large_array as *const _ as usize },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(C),
+ "::",
+ stringify!(large_array)
+ )
+ );
+}
+impl Default for C {
+ fn default() -> Self {
+ unsafe { ::core::mem::zeroed() }
+ }
+}
+impl ::core::fmt::Debug for C {
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ write!(
+ f,
+ "C {{ a : {:?}, b : {:?}, large_array: [...] }}",
+ self.a(),
+ self.b()
+ )
+ }
+}
+impl C {
+ #[inline]
+ pub fn a(&self) -> bool {
+ unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
+ }
+ #[inline]
+ pub fn set_a(&mut self, val: bool) {
+ unsafe {
+ let val: u8 = ::core::mem::transmute(val);
+ self._bitfield_1.set(0usize, 1u8, val as u64)
+ }
+ }
+ #[inline]
+ pub fn b(&self) -> bool {
+ unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) }
+ }
+ #[inline]
+ pub fn set_b(&mut self, val: bool) {
+ unsafe {
+ let val: u8 = ::core::mem::transmute(val);
+ self._bitfield_1.set(1usize, 7u8, val as u64)
+ }
+ }
+ #[inline]
+ pub fn new_bitfield_1(a: bool, b: bool) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
+ let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
+ Default::default();
+ __bindgen_bitfield_unit.set(0usize, 1u8, {
+ let a: u8 = unsafe { ::core::mem::transmute(a) };
+ a as u64
+ });
+ __bindgen_bitfield_unit.set(1usize, 7u8, {
+ let b: u8 = unsafe { ::core::mem::transmute(b) };
+ b as u64
+ });
+ __bindgen_bitfield_unit
+ }
+}
diff --git a/tests/expectations/tests/derive-debug-bitfield.rs b/tests/expectations/tests/derive-debug-bitfield.rs
index 3743b8d9..ccd7155d 100644
--- a/tests/expectations/tests/derive-debug-bitfield.rs
+++ b/tests/expectations/tests/derive-debug-bitfield.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -118,7 +135,7 @@ impl Default for C {
}
}
impl ::std::fmt::Debug for C {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(
f,
"C {{ a : {:?}, b : {:?}, large_array: [{}] }}",
diff --git a/tests/expectations/tests/derive-debug-function-pointer.rs b/tests/expectations/tests/derive-debug-function-pointer.rs
index c7aed70d..237fa1d4 100644
--- a/tests/expectations/tests/derive-debug-function-pointer.rs
+++ b/tests/expectations/tests/derive-debug-function-pointer.rs
@@ -50,7 +50,7 @@ impl Default for Nice {
}
}
impl ::std::fmt::Debug for Nice {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(
f,
"Nice {{ pointer: {:?}, large_array: [{}] }}",
diff --git a/tests/expectations/tests/derive-debug-generic.rs b/tests/expectations/tests/derive-debug-generic.rs
index 6c0b41a6..c793cb8a 100644
--- a/tests/expectations/tests/derive-debug-generic.rs
+++ b/tests/expectations/tests/derive-debug-generic.rs
@@ -15,7 +15,7 @@ impl<T> Default for Generic<T> {
}
}
impl<T> ::std::fmt::Debug for Generic<T> {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "Generic {{ t: Array with length 40 }}")
}
}
diff --git a/tests/expectations/tests/derive-debug-mangle-name.rs b/tests/expectations/tests/derive-debug-mangle-name.rs
index acdcba10..fbf518bd 100644
--- a/tests/expectations/tests/derive-debug-mangle-name.rs
+++ b/tests/expectations/tests/derive-debug-mangle-name.rs
@@ -57,7 +57,7 @@ impl Default for perf_event_attr__bindgen_ty_1 {
}
}
impl ::std::fmt::Debug for perf_event_attr__bindgen_ty_1 {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "perf_event_attr__bindgen_ty_1 {{ union }}")
}
}
@@ -100,7 +100,7 @@ impl Default for perf_event_attr {
}
}
impl ::std::fmt::Debug for perf_event_attr {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(
f,
"perf_event_attr {{ type: {:?}, a: {:?}, __bindgen_anon_1: {:?} }}",
diff --git a/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs b/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs
index f323245e..605ce78f 100644
--- a/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs
+++ b/tests/expectations/tests/derive-debug-opaque-template-instantiation.rs
@@ -37,7 +37,7 @@ impl Default for Instance {
}
}
impl ::std::fmt::Debug for Instance {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "Instance {{ val: opaque }}")
}
}
diff --git a/tests/expectations/tests/derive-debug-opaque.rs b/tests/expectations/tests/derive-debug-opaque.rs
index a18e210c..d7f8878b 100644
--- a/tests/expectations/tests/derive-debug-opaque.rs
+++ b/tests/expectations/tests/derive-debug-opaque.rs
@@ -27,7 +27,7 @@ impl Default for Opaque {
}
}
impl ::std::fmt::Debug for Opaque {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "Opaque {{ opaque }}")
}
}
@@ -64,7 +64,7 @@ impl Default for OpaqueUser {
}
}
impl ::std::fmt::Debug for OpaqueUser {
- fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "OpaqueUser {{ opaque: {:?} }}", self.opaque)
}
}
diff --git a/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs b/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
index 7f56de7b..e95c3391 100644
--- a/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
+++ b/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
@@ -30,7 +30,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
diff --git a/tests/expectations/tests/derive-partialeq-bitfield.rs b/tests/expectations/tests/derive-partialeq-bitfield.rs
index a3715b0c..c1cb18f7 100644
--- a/tests/expectations/tests/derive-partialeq-bitfield.rs
+++ b/tests/expectations/tests/derive-partialeq-bitfield.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/derive-partialeq-union_1_0.rs b/tests/expectations/tests/derive-partialeq-union_1_0.rs
index dab82854..57c415b4 100644
--- a/tests/expectations/tests/derive-partialeq-union_1_0.rs
+++ b/tests/expectations/tests/derive-partialeq-union_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/divide-by-zero-in-struct-layout.rs b/tests/expectations/tests/divide-by-zero-in-struct-layout.rs
index 97093321..1b51a30f 100644
--- a/tests/expectations/tests/divide-by-zero-in-struct-layout.rs
+++ b/tests/expectations/tests/divide-by-zero-in-struct-layout.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/dupe-enum-variant-in-namespace.rs b/tests/expectations/tests/dupe-enum-variant-in-namespace.rs
new file mode 100644
index 00000000..b93100b2
--- /dev/null
+++ b/tests/expectations/tests/dupe-enum-variant-in-namespace.rs
@@ -0,0 +1,30 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
+pub mod root {
+ #[allow(unused_imports)]
+ use self::super::root;
+ pub mod foo {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ impl root::foo::Bar {
+ pub const Foo1: root::foo::Bar = Bar::Foo;
+ }
+ impl root::foo::Bar {
+ pub const Foo3: root::foo::Bar = Bar::Foo2;
+ }
+ #[repr(u32)]
+ #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+ pub enum Bar {
+ Foo = 0,
+ Foo2 = 1,
+ }
+ }
+}
diff --git a/tests/expectations/tests/enum-doc-bitfield.rs b/tests/expectations/tests/enum-doc-bitfield.rs
index 93d1f5f0..9ebfc10e 100644
--- a/tests/expectations/tests/enum-doc-bitfield.rs
+++ b/tests/expectations/tests/enum-doc-bitfield.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
impl B {
/// Document field with three slashes
@@ -15,11 +20,11 @@ impl B {
pub const VAR_C: B = B(2);
}
impl B {
- /// < Document field with following star
+ ///< Document field with following star
pub const VAR_D: B = B(3);
}
impl B {
- /// < Document field with following exclamation
+ ///< Document field with following exclamation
pub const VAR_E: B = B(4);
}
impl B {
diff --git a/tests/expectations/tests/enum-doc-mod.rs b/tests/expectations/tests/enum-doc-mod.rs
index cb10bb3d..1da02f41 100644
--- a/tests/expectations/tests/enum-doc-mod.rs
+++ b/tests/expectations/tests/enum-doc-mod.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub mod B {
/// Document enum
@@ -11,9 +16,9 @@ pub mod B {
pub const VAR_B: Type = 1;
/// Document field with preceeding exclamation
pub const VAR_C: Type = 2;
- /// < Document field with following star
+ ///< Document field with following star
pub const VAR_D: Type = 3;
- /// < Document field with following exclamation
+ ///< Document field with following exclamation
pub const VAR_E: Type = 4;
/// Document field with preceeding star, with a loong long multiline
/// comment.
diff --git a/tests/expectations/tests/enum-doc-rusty.rs b/tests/expectations/tests/enum-doc-rusty.rs
index 2a57fb64..e4209e3e 100644
--- a/tests/expectations/tests/enum-doc-rusty.rs
+++ b/tests/expectations/tests/enum-doc-rusty.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(u32)]
/// Document enum
@@ -12,9 +17,9 @@ pub enum B {
VAR_B = 1,
/// Document field with preceeding exclamation
VAR_C = 2,
- /// < Document field with following star
+ ///< Document field with following star
VAR_D = 3,
- /// < Document field with following exclamation
+ ///< Document field with following exclamation
VAR_E = 4,
/// Document field with preceeding star, with a loong long multiline
/// comment.
diff --git a/tests/expectations/tests/enum-doc.rs b/tests/expectations/tests/enum-doc.rs
index e57728fb..0df3a5a5 100644
--- a/tests/expectations/tests/enum-doc.rs
+++ b/tests/expectations/tests/enum-doc.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
/// Document field with three slashes
pub const B_VAR_A: B = 0;
@@ -8,9 +13,9 @@ pub const B_VAR_A: B = 0;
pub const B_VAR_B: B = 1;
/// Document field with preceeding exclamation
pub const B_VAR_C: B = 2;
-/// < Document field with following star
+///< Document field with following star
pub const B_VAR_D: B = 3;
-/// < Document field with following exclamation
+///< Document field with following exclamation
pub const B_VAR_E: B = 4;
/// Document field with preceeding star, with a loong long multiline
/// comment.
diff --git a/tests/expectations/tests/enum_dupe.rs b/tests/expectations/tests/enum_dupe.rs
index 29bd7502..8462f6d2 100644
--- a/tests/expectations/tests/enum_dupe.rs
+++ b/tests/expectations/tests/enum_dupe.rs
@@ -1,8 +1,15 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
-pub const Foo_Dupe: Foo = Foo::Bar;
+impl Foo {
+ pub const Dupe: Foo = Foo::Bar;
+}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Foo {
diff --git a/tests/expectations/tests/enum_in_template_with_typedef.rs b/tests/expectations/tests/enum_in_template_with_typedef.rs
index a3b4e776..91c22fcd 100644
--- a/tests/expectations/tests/enum_in_template_with_typedef.rs
+++ b/tests/expectations/tests/enum_in_template_with_typedef.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@@ -8,8 +13,9 @@ pub struct std_fbstring_core {
pub _address: u8,
}
pub type std_fbstring_core_category_type = u8;
-pub const std_fbstring_core_Category_Bar: std_fbstring_core_Category =
- std_fbstring_core_Category::Foo;
+impl std_fbstring_core_Category {
+ pub const Bar: std_fbstring_core_Category = std_fbstring_core_Category::Foo;
+}
#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum std_fbstring_core_Category {
diff --git a/tests/expectations/tests/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/error-E0600-cannot-apply-unary-negation-to-u32.rs
deleted file mode 100644
index 9613a7f2..00000000
--- a/tests/expectations/tests/error-E0600-cannot-apply-unary-negation-to-u32.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-/* automatically generated by rust-bindgen */
-
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
-
-pub const a: u32 = 18446744073709551611;
diff --git a/tests/expectations/tests/extern-const-struct.rs b/tests/expectations/tests/extern-const-struct.rs
new file mode 100644
index 00000000..2f9ade8b
--- /dev/null
+++ b/tests/expectations/tests/extern-const-struct.rs
@@ -0,0 +1,46 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct nsFoo {
+ pub details: [f32; 400usize],
+}
+#[test]
+fn bindgen_test_layout_nsFoo() {
+ assert_eq!(
+ ::std::mem::size_of::<nsFoo>(),
+ 1600usize,
+ concat!("Size of: ", stringify!(nsFoo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<nsFoo>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(nsFoo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<nsFoo>())).details as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(nsFoo),
+ "::",
+ stringify!(details)
+ )
+ );
+}
+impl Default for nsFoo {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+extern "C" {
+ #[link_name = "\u{1}gDetails"]
+ pub static gDetails: nsFoo;
+}
diff --git a/tests/expectations/tests/i128.rs b/tests/expectations/tests/i128.rs
new file mode 100644
index 00000000..1fae2bee
--- /dev/null
+++ b/tests/expectations/tests/i128.rs
@@ -0,0 +1,49 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[repr(align(16))]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct foo {
+ pub my_signed: i128,
+ pub my_unsigned: u128,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 32usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).my_signed as *const _ as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(my_signed)
+ )
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).my_unsigned as *const _ as usize },
+ 16usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(foo),
+ "::",
+ stringify!(my_unsigned)
+ )
+ );
+}
diff --git a/tests/expectations/tests/issue-1034.rs b/tests/expectations/tests/issue-1034.rs
index 687c4305..957360b7 100644
--- a/tests/expectations/tests/issue-1034.rs
+++ b/tests/expectations/tests/issue-1034.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs b/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs
index a8a52099..14eb4d5f 100644
--- a/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs
+++ b/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/issue-1198-alias-rust-enum.rs b/tests/expectations/tests/issue-1198-alias-rust-enum.rs
index b2902c89..1659e29e 100644
--- a/tests/expectations/tests/issue-1198-alias-rust-enum.rs
+++ b/tests/expectations/tests/issue-1198-alias-rust-enum.rs
@@ -1,15 +1,24 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
-pub const MyDupeEnum_A_alias: MyDupeEnum = MyDupeEnum::A;
+impl MyDupeEnum {
+ pub const A_alias: MyDupeEnum = MyDupeEnum::A;
+}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MyDupeEnum {
A = 0,
B = 1,
}
-pub const MyOtherDupeEnum_C_alias: MyOtherDupeEnum = MyOtherDupeEnum::C;
+impl MyOtherDupeEnum {
+ pub const C_alias: MyOtherDupeEnum = MyOtherDupeEnum::C;
+}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MyOtherDupeEnum {
diff --git a/tests/expectations/tests/issue-1291.rs b/tests/expectations/tests/issue-1291.rs
index a2330541..f92d364e 100644
--- a/tests/expectations/tests/issue-1291.rs
+++ b/tests/expectations/tests/issue-1291.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[repr(align(16))]
@@ -22,7 +27,6 @@ pub struct RTCRay {
pub primID: ::std::os::raw::c_uint,
pub instID: ::std::os::raw::c_uint,
pub __bindgen_padding_0: [u32; 3usize],
- pub __bindgen_align: [u8; 0usize],
}
#[test]
fn bindgen_test_layout_RTCRay() {
diff --git a/tests/expectations/tests/issue-1350-attribute-overloadable.rs b/tests/expectations/tests/issue-1350-attribute-overloadable.rs
new file mode 100644
index 00000000..39b03406
--- /dev/null
+++ b/tests/expectations/tests/issue-1350-attribute-overloadable.rs
@@ -0,0 +1,17 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern "C" {
+ #[link_name = "\u{1}_Z11my_functioni"]
+ pub fn my_function(a: ::std::os::raw::c_int);
+}
+extern "C" {
+ #[link_name = "\u{1}_Z11my_functionPKc"]
+ pub fn my_function1(a: *const ::std::os::raw::c_char);
+}
diff --git a/tests/expectations/tests/issue-1435.rs b/tests/expectations/tests/issue-1435.rs
new file mode 100644
index 00000000..4c8b52e6
--- /dev/null
+++ b/tests/expectations/tests/issue-1435.rs
@@ -0,0 +1,26 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
+pub mod root {
+ #[allow(unused_imports)]
+ use self::super::root;
+ pub mod ns {
+ #[allow(unused_imports)]
+ use self::super::super::root;
+ pub const AB_A: root::ns::AB = 0;
+ pub const AB_B: root::ns::AB = 1;
+ pub type AB = i32;
+ }
+ pub use self::super::root::ns::AB;
+ extern "C" {
+ #[link_name = "\u{1}_ZL2kA"]
+ pub static kA: root::AB;
+ }
+}
diff --git a/tests/expectations/tests/issue-493.rs b/tests/expectations/tests/issue-493.rs
index 69003faf..c13101d0 100644
--- a/tests/expectations/tests/issue-493.rs
+++ b/tests/expectations/tests/issue-493.rs
@@ -32,7 +32,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/issue-493_1_0.rs b/tests/expectations/tests/issue-493_1_0.rs
index a65cd3e8..3c742e5d 100644
--- a/tests/expectations/tests/issue-493_1_0.rs
+++ b/tests/expectations/tests/issue-493_1_0.rs
@@ -32,7 +32,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/issue-511.rs b/tests/expectations/tests/issue-511.rs
index ff725b33..453fed09 100644
--- a/tests/expectations/tests/issue-511.rs
+++ b/tests/expectations/tests/issue-511.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
extern "C" {
#[link_name = "\u{1}a"]
@@ -12,9 +17,9 @@ extern "C" {
}
extern "C" {
#[link_name = "\u{1}c"]
- pub static mut c: *mut ::std::os::raw::c_char;
+ pub static c: *mut ::std::os::raw::c_char;
}
extern "C" {
#[link_name = "\u{1}d"]
- pub static mut d: *const ::std::os::raw::c_char;
+ pub static d: *const ::std::os::raw::c_char;
}
diff --git a/tests/expectations/tests/issue-643-inner-struct.rs b/tests/expectations/tests/issue-643-inner-struct.rs
index 7f2d4e35..83b52c22 100644
--- a/tests/expectations/tests/issue-643-inner-struct.rs
+++ b/tests/expectations/tests/issue-643-inner-struct.rs
@@ -30,7 +30,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
diff --git a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs
index 81c32bbf..7697660d 100644
--- a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs
+++ b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/issue-816.rs b/tests/expectations/tests/issue-816.rs
index 555769a2..b1a03081 100644
--- a/tests/expectations/tests/issue-816.rs
+++ b/tests/expectations/tests/issue-816.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs
index 7e047f6a..6a03de65 100644
--- a/tests/expectations/tests/jsval_layout_opaque.rs
+++ b/tests/expectations/tests/jsval_layout_opaque.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs
index 29ce27ad..e006ee42 100644
--- a/tests/expectations/tests/jsval_layout_opaque_1_0.rs
+++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -111,7 +130,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs
index a0f7f8ad..a5fd1f69 100644
--- a/tests/expectations/tests/layout_align.rs
+++ b/tests/expectations/tests/layout_align.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -30,7 +33,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +51,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +75,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +96,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -109,7 +131,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
@@ -123,15 +145,15 @@ impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[repr(C)]
#[derive(Debug)]
pub struct rte_kni_fifo {
- /// < Next position to be written
+ ///< Next position to be written
pub write: ::std::os::raw::c_uint,
- /// < Next position to be read
+ ///< Next position to be read
pub read: ::std::os::raw::c_uint,
- /// < Circular buffer length
+ ///< Circular buffer length
pub len: ::std::os::raw::c_uint,
- /// < Pointer size - for 32/64 bit OS
+ ///< Pointer size - for 32/64 bit OS
pub elem_size: ::std::os::raw::c_uint,
- /// < The buffer contains mbuf pointers
+ ///< The buffer contains mbuf pointers
pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>,
pub __bindgen_align: [u64; 0usize],
}
@@ -156,7 +178,7 @@ impl Default for rte_kni_fifo {
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct rte_eth_link {
- /// < ETH_SPEED_NUM_
+ ///< ETH_SPEED_NUM_
pub link_speed: u32,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
pub __bindgen_padding_0: [u8; 3usize],
diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs
index 7516f5e4..28dfd53c 100644
--- a/tests/expectations/tests/layout_arp.rs
+++ b/tests/expectations/tests/layout_arp.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const ETHER_ADDR_LEN: u32 = 6;
pub const ARP_HRD_ETHER: u32 = 1;
@@ -22,7 +27,7 @@ pub const ARP_OP_INVREPLY: u32 = 9;
#[repr(C, packed)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ether_addr {
- /// < Addr bytes in tx order
+ ///< Addr bytes in tx order
pub addr_bytes: [u8; 6usize],
}
#[test]
@@ -52,13 +57,13 @@ fn bindgen_test_layout_ether_addr() {
#[repr(C, packed)]
#[derive(Debug, Default, Copy, Clone)]
pub struct arp_ipv4 {
- /// < sender hardware address
+ ///< sender hardware address
pub arp_sha: ether_addr,
- /// < sender IP address
+ ///< sender IP address
pub arp_sip: u32,
- /// < target hardware address
+ ///< target hardware address
pub arp_tha: ether_addr,
- /// < target IP address
+ ///< target IP address
pub arp_tip: u32,
}
#[test]
diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs
index 15fbfa42..2fd93c4a 100644
--- a/tests/expectations/tests/layout_array.rs
+++ b/tests/expectations/tests/layout_array.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
pub const RTE_MEMPOOL_OPS_NAMESIZE: u32 = 32;
@@ -46,17 +51,17 @@ pub type rte_mempool_get_count =
#[repr(C)]
#[derive(Copy, Clone)]
pub struct rte_mempool_ops {
- /// < Name of mempool ops struct.
+ ///< Name of mempool ops struct.
pub name: [::std::os::raw::c_char; 32usize],
- /// < Allocate private data.
+ ///< Allocate private data.
pub alloc: rte_mempool_alloc_t,
- /// < Free the external pool.
+ ///< Free the external pool.
pub free: rte_mempool_free_t,
- /// < Enqueue an object.
+ ///< Enqueue an object.
pub enqueue: rte_mempool_enqueue_t,
- /// < Dequeue an object.
+ ///< Dequeue an object.
pub dequeue: rte_mempool_dequeue_t,
- /// < Get qty of available objs.
+ ///< Get qty of available objs.
pub get_count: rte_mempool_get_count,
pub __bindgen_padding_0: [u64; 7usize],
}
@@ -135,8 +140,11 @@ impl Default for rte_mempool_ops {
}
impl ::std::cmp::PartialEq for rte_mempool_ops {
fn eq(&self, other: &rte_mempool_ops) -> bool {
- self.name == other.name && self.alloc == other.alloc && self.free == other.free
- && self.enqueue == other.enqueue && self.dequeue == other.dequeue
+ self.name == other.name
+ && self.alloc == other.alloc
+ && self.free == other.free
+ && self.enqueue == other.enqueue
+ && self.dequeue == other.dequeue
&& self.get_count == other.get_count
}
}
@@ -144,7 +152,7 @@ impl ::std::cmp::PartialEq for rte_mempool_ops {
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_spinlock_t {
- /// < lock status 0 = unlocked, 1 = locked
+ ///< lock status 0 = unlocked, 1 = locked
pub locked: ::std::os::raw::c_int,
}
#[test]
@@ -180,9 +188,9 @@ fn bindgen_test_layout_rte_spinlock_t() {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct rte_mempool_ops_table {
- /// < Spinlock for add/delete.
+ ///< Spinlock for add/delete.
pub sl: rte_spinlock_t,
- /// < Number of used ops structs in the table.
+ ///< Number of used ops structs in the table.
pub num_ops: u32,
pub __bindgen_padding_0: [u64; 7usize],
/// Storage for all possible ops structs.
@@ -330,8 +338,10 @@ impl Default for malloc_heap {
}
impl ::std::cmp::PartialEq for malloc_heap {
fn eq(&self, other: &malloc_heap) -> bool {
- self.lock == other.lock && self.free_head == other.free_head
- && self.alloc_count == other.alloc_count && self.total_size == other.total_size
+ self.lock == other.lock
+ && self.free_head == other.free_head
+ && self.alloc_count == other.alloc_count
+ && self.total_size == other.total_size
}
}
#[repr(C)]
diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs
index 24ab41a4..91c74d4b 100644
--- a/tests/expectations/tests/layout_array_too_long.rs
+++ b/tests/expectations/tests/layout_array_too_long.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
pub const RTE_LIBRTE_IP_FRAG_MAX_FRAG: u32 = 4;
@@ -11,11 +16,11 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_1 {
- /// < index of last fragment
+ ///< index of last fragment
IP_LAST_FRAG_IDX = 0,
- /// < index of first fragment
+ ///< index of first fragment
IP_FIRST_FRAG_IDX = 1,
- /// < minimum number of fragments
+ ///< minimum number of fragments
IP_MIN_FRAG_NUM = 2,
IP_MAX_FRAG_NUM = 4,
}
@@ -23,11 +28,11 @@ pub enum _bindgen_ty_1 {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ip_frag {
- /// < offset into the packet
+ ///< offset into the packet
pub ofs: u16,
- /// < length of fragment
+ ///< length of fragment
pub len: u16,
- /// < fragment mbuf
+ ///< fragment mbuf
pub mb: *mut rte_mbuf,
}
#[test]
@@ -82,11 +87,11 @@ impl Default for ip_frag {
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ip_frag_key {
- /// < src address, first 8 bytes used for IPv4
+ ///< src address, first 8 bytes used for IPv4
pub src_dst: [u64; 4usize],
- /// < dst address
+ ///< dst address
pub id: u32,
- /// < src/dst key length
+ ///< src/dst key length
pub key_len: u32,
}
#[test]
@@ -137,19 +142,19 @@ fn bindgen_test_layout_ip_frag_key() {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ip_frag_pkt {
- /// < LRU list
+ ///< LRU list
pub lru: ip_frag_pkt__bindgen_ty_1,
- /// < fragmentation key
+ ///< fragmentation key
pub key: ip_frag_key,
- /// < creation timestamp
+ ///< creation timestamp
pub start: u64,
- /// < expected reassembled size
+ ///< expected reassembled size
pub total_size: u32,
- /// < size of fragments received
+ ///< size of fragments received
pub frag_size: u32,
- /// < index of next entry to fill
+ ///< index of next entry to fill
pub last_idx: u32,
- /// < fragments
+ ///< fragments
pub frags: [ip_frag; 4usize],
pub __bindgen_padding_0: [u64; 6usize],
}
@@ -286,12 +291,16 @@ impl Default for ip_frag_pkt {
}
impl ::std::cmp::PartialEq for ip_frag_pkt {
fn eq(&self, other: &ip_frag_pkt) -> bool {
- self.lru == other.lru && self.key == other.key && self.start == other.start
- && self.total_size == other.total_size && self.frag_size == other.frag_size
- && self.last_idx == other.last_idx && self.frags == other.frags
+ self.lru == other.lru
+ && self.key == other.key
+ && self.start == other.start
+ && self.total_size == other.total_size
+ && self.frag_size == other.frag_size
+ && self.last_idx == other.last_idx
+ && self.frags == other.frags
}
}
-/// < fragment mbuf
+///< fragment mbuf
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_mbuf {
diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs
index 71d03ef6..68aef5c6 100644
--- a/tests/expectations/tests/layout_eth_conf.rs
+++ b/tests/expectations/tests/layout_eth_conf.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -28,7 +33,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +51,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +75,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +96,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -114,8 +138,8 @@ pub const RTE_ETH_FLOW_GENEVE: u32 = 20;
pub const RTE_ETH_FLOW_NVGRE: u32 = 21;
pub const RTE_ETH_FLOW_MAX: u32 = 22;
#[repr(u32)]
-/// A set of values to identify what method is to be used to route
-/// packets to multiple queues.
+/// A set of values to identify what method is to be used to route
+/// packets to multiple queues.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_rx_mq_mode {
/// None of DCB,RSS or VMDQ mode
@@ -141,9 +165,9 @@ pub enum rte_eth_rx_mq_mode {
pub struct rte_eth_rxmode {
/// The multi-queue packet distribution mode to be used, e.g. RSS.
pub mq_mode: rte_eth_rx_mq_mode,
- /// < Only used if jumbo_frame enabled.
+ ///< Only used if jumbo_frame enabled.
pub max_rx_pkt_len: u32,
- /// < hdr buf size (header_split enabled).
+ ///< hdr buf size (header_split enabled).
pub split_hdr_size: u16,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>,
}
@@ -353,20 +377,20 @@ impl rte_eth_rxmode {
/// packets using multi-TCs.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_tx_mq_mode {
- /// < It is in neither DCB nor VT mode.
+ ///< It is in neither DCB nor VT mode.
ETH_MQ_TX_NONE = 0,
- /// < For TX side,only DCB is on.
+ ///< For TX side,only DCB is on.
ETH_MQ_TX_DCB = 1,
- /// < For TX side,both DCB and VT is on.
+ ///< For TX side,both DCB and VT is on.
ETH_MQ_TX_VMDQ_DCB = 2,
- /// < Only VT on, no DCB
+ ///< Only VT on, no DCB
ETH_MQ_TX_VMDQ_ONLY = 3,
}
/// A structure used to configure the TX features of an Ethernet port.
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_txmode {
- /// < TX multi-queues mode.
+ ///< TX multi-queues mode.
pub mq_mode: rte_eth_tx_mq_mode,
pub pvid: u16,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
@@ -486,11 +510,11 @@ impl rte_eth_txmode {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_rss_conf {
- /// < If not NULL, 40-byte hash key.
+ ///< If not NULL, 40-byte hash key.
pub rss_key: *mut u8,
- /// < hash key length in bytes.
+ ///< hash key length in bytes.
pub rss_key_len: u8,
- /// < Hash functions to apply - see below.
+ ///< Hash functions to apply - see below.
pub rss_hf: u64,
}
#[test]
@@ -546,9 +570,9 @@ impl Default for rte_eth_rss_conf {
/// in DCB configratioins
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_nb_tcs {
- /// < 4 TCs with DCB.
+ ///< 4 TCs with DCB.
ETH_4_TCS = 4,
- /// < 8 TCs with DCB.
+ ///< 8 TCs with DCB.
ETH_8_TCS = 8,
}
#[repr(u32)]
@@ -556,13 +580,13 @@ pub enum rte_eth_nb_tcs {
/// in VMDQ configurations.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_nb_pools {
- /// < 8 VMDq pools.
+ ///< 8 VMDq pools.
ETH_8_POOLS = 8,
- /// < 16 VMDq pools.
+ ///< 16 VMDq pools.
ETH_16_POOLS = 16,
- /// < 32 VMDq pools.
+ ///< 32 VMDq pools.
ETH_32_POOLS = 32,
- /// < 64 VMDq pools.
+ ///< 64 VMDq pools.
ETH_64_POOLS = 64,
}
/// A structure used to configure the VMDQ+DCB feature
@@ -577,24 +601,24 @@ pub enum rte_eth_nb_pools {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct rte_eth_vmdq_dcb_conf {
- /// < With DCB, 16 or 32 pools
+ ///< With DCB, 16 or 32 pools
pub nb_queue_pools: rte_eth_nb_pools,
- /// < If non-zero, use a default pool
+ ///< If non-zero, use a default pool
pub enable_default_pool: u8,
- /// < The default pool, if applicable
+ ///< The default pool, if applicable
pub default_pool: u8,
- /// < We can have up to 64 filters/mappings
+ ///< We can have up to 64 filters/mappings
pub nb_pool_maps: u8,
- /// < VMDq vlan pool maps.
+ ///< VMDq vlan pool maps.
pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize],
pub dcb_tc: [u8; 8usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
- /// < The vlan id of the received frame
+ ///< The vlan id of the received frame
pub vlan_id: u16,
- /// < Bitmask of pools for packet rx
+ ///< Bitmask of pools for packet rx
pub pools: u64,
}
#[test]
@@ -729,7 +753,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_dcb_rx_conf {
- /// < Possible DCB TCs, 4 or 8 TCs
+ ///< Possible DCB TCs, 4 or 8 TCs
pub nb_tcs: rte_eth_nb_tcs,
/// Traffic class each UP mapped to.
pub dcb_tc: [u8; 8usize],
@@ -775,7 +799,7 @@ impl Default for rte_eth_dcb_rx_conf {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_dcb_tx_conf {
- /// < With DCB, 16 or 32 pools.
+ ///< With DCB, 16 or 32 pools.
pub nb_queue_pools: rte_eth_nb_pools,
/// Traffic class each UP mapped to.
pub dcb_tc: [u8; 8usize],
@@ -823,7 +847,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_dcb_tx_conf {
- /// < Possible DCB TCs, 4 or 8 TCs.
+ ///< Possible DCB TCs, 4 or 8 TCs.
pub nb_tcs: rte_eth_nb_tcs,
/// Traffic class each UP mapped to.
pub dcb_tc: [u8; 8usize],
@@ -869,7 +893,7 @@ impl Default for rte_eth_dcb_tx_conf {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_tx_conf {
- /// < VMDq mode, 64 pools.
+ ///< VMDq mode, 64 pools.
pub nb_queue_pools: rte_eth_nb_pools,
}
#[test]
@@ -905,27 +929,27 @@ impl Default for rte_eth_vmdq_tx_conf {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct rte_eth_vmdq_rx_conf {
- /// < VMDq only mode, 8 or 64 pools
+ ///< VMDq only mode, 8 or 64 pools
pub nb_queue_pools: rte_eth_nb_pools,
- /// < If non-zero, use a default pool
+ ///< If non-zero, use a default pool
pub enable_default_pool: u8,
- /// < The default pool, if applicable
+ ///< The default pool, if applicable
pub default_pool: u8,
- /// < Enable VT loop back
+ ///< Enable VT loop back
pub enable_loop_back: u8,
- /// < We can have up to 64 filters/mappings
+ ///< We can have up to 64 filters/mappings
pub nb_pool_maps: u8,
- /// < Flags from ETH_VMDQ_ACCEPT_*
+ ///< Flags from ETH_VMDQ_ACCEPT_*
pub rx_mode: u32,
- /// < VMDq vlan pool maps.
+ ///< VMDq vlan pool maps.
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
- /// < The vlan id of the received frame
+ ///< The vlan id of the received frame
pub vlan_id: u16,
- /// < Bitmask of pools for packet rx
+ ///< Bitmask of pools for packet rx
pub pools: u64,
}
#[test]
@@ -1070,56 +1094,56 @@ impl Default for rte_eth_vmdq_rx_conf {
}
}
#[repr(u32)]
-/// Flow Director setting modes: none, signature or perfect.
+/// Flow Director setting modes: none, signature or perfect.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_fdir_mode {
- /// < Disable FDIR support.
+ ///< Disable FDIR support.
RTE_FDIR_MODE_NONE = 0,
- /// < Enable FDIR signature filter mode.
+ ///< Enable FDIR signature filter mode.
RTE_FDIR_MODE_SIGNATURE = 1,
- /// < Enable FDIR perfect filter mode.
+ ///< Enable FDIR perfect filter mode.
RTE_FDIR_MODE_PERFECT = 2,
- /// < Enable FDIR filter mode - MAC VLAN.
+ ///< Enable FDIR filter mode - MAC VLAN.
RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3,
- /// < Enable FDIR filter mode - tunnel.
+ ///< Enable FDIR filter mode - tunnel.
RTE_FDIR_MODE_PERFECT_TUNNEL = 4,
}
#[repr(u32)]
-/// Memory space that can be configured to store Flow Director filters
-/// in the board memory.
+/// Memory space that can be configured to store Flow Director filters
+/// in the board memory.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_fdir_pballoc_type {
- /// < 64k.
+ ///< 64k.
RTE_FDIR_PBALLOC_64K = 0,
- /// < 128k.
+ ///< 128k.
RTE_FDIR_PBALLOC_128K = 1,
- /// < 256k.
+ ///< 256k.
RTE_FDIR_PBALLOC_256K = 2,
}
#[repr(u32)]
-/// Select report mode of FDIR hash information in RX descriptors.
+/// Select report mode of FDIR hash information in RX descriptors.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_fdir_status_mode {
- /// < Never report FDIR hash.
+ ///< Never report FDIR hash.
RTE_FDIR_NO_REPORT_STATUS = 0,
- /// < Only report FDIR hash for matching pkts.
+ ///< Only report FDIR hash for matching pkts.
RTE_FDIR_REPORT_STATUS = 1,
- /// < Always report FDIR hash.
+ ///< Always report FDIR hash.
RTE_FDIR_REPORT_STATUS_ALWAYS = 2,
}
/// A structure used to define the input for IPV4 flow
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_ipv4_flow {
- /// < IPv4 source address in big endian.
+ ///< IPv4 source address in big endian.
pub src_ip: u32,
- /// < IPv4 destination address in big endian.
+ ///< IPv4 destination address in big endian.
pub dst_ip: u32,
- /// < Type of service to match.
+ ///< Type of service to match.
pub tos: u8,
- /// < Time to live to match.
+ ///< Time to live to match.
pub ttl: u8,
- /// < Protocol, next header in big endian.
+ ///< Protocol, next header in big endian.
pub proto: u8,
}
#[test]
@@ -1189,15 +1213,15 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() {
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_ipv6_flow {
- /// < IPv6 source address in big endian.
+ ///< IPv6 source address in big endian.
pub src_ip: [u32; 4usize],
- /// < IPv6 destination address in big endian.
+ ///< IPv6 destination address in big endian.
pub dst_ip: [u32; 4usize],
- /// < Traffic class to match.
+ ///< Traffic class to match.
pub tc: u8,
- /// < Protocol, next header to match.
+ ///< Protocol, next header to match.
pub proto: u8,
- /// < Hop limits to match.
+ ///< Hop limits to match.
pub hop_limits: u8,
}
#[test]
@@ -1263,12 +1287,12 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() {
)
);
}
-/// A structure used to configure FDIR masks that are used by the device
-/// to match the various fields of RX packet headers.
+/// A structure used to configure FDIR masks that are used by the device
+/// to match the various fields of RX packet headers.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_fdir_masks {
- /// < Bit mask for vlan_tci in big endian
+ ///< Bit mask for vlan_tci in big endian
pub vlan_tci_mask: u16,
/// Bit mask for ipv4 flow in big endian.
pub ipv4_mask: rte_eth_ipv4_flow,
@@ -1279,12 +1303,12 @@ pub struct rte_eth_fdir_masks {
/// Bit mask for L4 destination port in big endian.
pub dst_port_mask: u16,
/// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
- /// first byte on the wire
+ ///first byte on the wire
pub mac_addr_byte_mask: u8,
/// Bit mask for tunnel ID in big endian.
pub tunnel_id_mask: u32,
- /// < 1 - Match tunnel type,
- /// 0 - Ignore tunnel type.
+ ///< 1 - Match tunnel type,
+ ///0 - Ignore tunnel type.
pub tunnel_type_mask: u8,
}
#[test]
@@ -1408,7 +1432,7 @@ pub enum rte_eth_payload_type {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_flex_payload_cfg {
- /// < Payload type
+ ///< Payload type
pub type_: rte_eth_payload_type,
pub src_offset: [u16; 16usize],
}
@@ -1500,9 +1524,9 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_eth_fdir_flex_conf {
- /// < The number of following payload cfg
+ ///< The number of following payload cfg
pub nb_payloads: u16,
- /// < The number of following mask
+ ///< The number of following mask
pub nb_flexmasks: u16,
pub flex_set: [rte_eth_flex_payload_cfg; 8usize],
pub flex_mask: [rte_eth_fdir_flex_mask; 22usize],
@@ -1578,11 +1602,11 @@ impl Default for rte_eth_fdir_flex_conf {
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_fdir_conf {
- /// < Flow Director mode.
+ ///< Flow Director mode.
pub mode: rte_fdir_mode,
- /// < Space for FDIR filters.
+ ///< Space for FDIR filters.
pub pballoc: rte_fdir_pballoc_type,
- /// < How to report FDIR hash.
+ ///< How to report FDIR hash.
pub status: rte_fdir_status_mode,
/// RX queue of packets matching a "drop" filter in perfect mode.
pub drop_queue: u8,
@@ -1715,40 +1739,40 @@ fn bindgen_test_layout_rte_intr_conf() {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct rte_eth_conf {
- /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be
- /// used. ETH_LINK_SPEED_FIXED disables link
- /// autonegotiation, and a unique speed shall be
- /// set. Otherwise, the bitmap defines the set of
- /// speeds to be advertised. If the special value
- /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
- /// supported are advertised.
+ ///< bitmap of ETH_LINK_SPEED_XXX of speeds to be
+ ///used. ETH_LINK_SPEED_FIXED disables link
+ ///autonegotiation, and a unique speed shall be
+ ///set. Otherwise, the bitmap defines the set of
+ ///speeds to be advertised. If the special value
+ ///ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
+ ///supported are advertised.
pub link_speeds: u32,
- /// < Port RX configuration.
+ ///< Port RX configuration.
pub rxmode: rte_eth_rxmode,
- /// < Port TX configuration.
+ ///< Port TX configuration.
pub txmode: rte_eth_txmode,
- /// < Loopback operation mode. By default the value
- /// is 0, meaning the loopback mode is disabled.
- /// Read the datasheet of given ethernet controller
- /// for details. The possible values of this field
- /// are defined in implementation of each driver.
+ ///< Loopback operation mode. By default the value
+ ///is 0, meaning the loopback mode is disabled.
+ ///Read the datasheet of given ethernet controller
+ ///for details. The possible values of this field
+ ///are defined in implementation of each driver.
pub lpbk_mode: u32,
- /// < Port RX filtering configuration (union).
+ ///< Port RX filtering configuration (union).
pub rx_adv_conf: rte_eth_conf__bindgen_ty_1,
- /// < Port TX DCB configuration (union).
+ ///< Port TX DCB configuration (union).
pub tx_adv_conf: rte_eth_conf__bindgen_ty_2,
/// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
- /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT.
+ ///is needed,and the variable must be set ETH_DCB_PFC_SUPPORT.
pub dcb_capability_en: u32,
- /// < FDIR configuration.
+ ///< FDIR configuration.
pub fdir_conf: rte_fdir_conf,
- /// < Interrupt mode configuration.
+ ///< Interrupt mode configuration.
pub intr_conf: rte_intr_conf,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct rte_eth_conf__bindgen_ty_1 {
- /// < Port RSS configuration
+ ///< Port RSS configuration
pub rss_conf: rte_eth_rss_conf,
pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf,
pub dcb_rx_conf: rte_eth_dcb_rx_conf,
diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs
index e9a09f54..381ec8ac 100644
--- a/tests/expectations/tests/layout_eth_conf_1_0.rs
+++ b/tests/expectations/tests/layout_eth_conf_1_0.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -28,7 +33,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +51,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +75,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +96,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -111,7 +135,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
@@ -157,8 +181,8 @@ pub const RTE_ETH_FLOW_GENEVE: u32 = 20;
pub const RTE_ETH_FLOW_NVGRE: u32 = 21;
pub const RTE_ETH_FLOW_MAX: u32 = 22;
#[repr(u32)]
-/// A set of values to identify what method is to be used to route
-/// packets to multiple queues.
+/// A set of values to identify what method is to be used to route
+/// packets to multiple queues.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_rx_mq_mode {
/// None of DCB,RSS or VMDQ mode
@@ -184,9 +208,9 @@ pub enum rte_eth_rx_mq_mode {
pub struct rte_eth_rxmode {
/// The multi-queue packet distribution mode to be used, e.g. RSS.
pub mq_mode: rte_eth_rx_mq_mode,
- /// < Only used if jumbo_frame enabled.
+ ///< Only used if jumbo_frame enabled.
pub max_rx_pkt_len: u32,
- /// < hdr buf size (header_split enabled).
+ ///< hdr buf size (header_split enabled).
pub split_hdr_size: u16,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>,
}
@@ -401,20 +425,20 @@ impl rte_eth_rxmode {
/// packets using multi-TCs.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_tx_mq_mode {
- /// < It is in neither DCB nor VT mode.
+ ///< It is in neither DCB nor VT mode.
ETH_MQ_TX_NONE = 0,
- /// < For TX side,only DCB is on.
+ ///< For TX side,only DCB is on.
ETH_MQ_TX_DCB = 1,
- /// < For TX side,both DCB and VT is on.
+ ///< For TX side,both DCB and VT is on.
ETH_MQ_TX_VMDQ_DCB = 2,
- /// < Only VT on, no DCB
+ ///< Only VT on, no DCB
ETH_MQ_TX_VMDQ_ONLY = 3,
}
/// A structure used to configure the TX features of an Ethernet port.
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_txmode {
- /// < TX multi-queues mode.
+ ///< TX multi-queues mode.
pub mq_mode: rte_eth_tx_mq_mode,
pub pvid: u16,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
@@ -539,11 +563,11 @@ impl rte_eth_txmode {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_rss_conf {
- /// < If not NULL, 40-byte hash key.
+ ///< If not NULL, 40-byte hash key.
pub rss_key: *mut u8,
- /// < hash key length in bytes.
+ ///< hash key length in bytes.
pub rss_key_len: u8,
- /// < Hash functions to apply - see below.
+ ///< Hash functions to apply - see below.
pub rss_hf: u64,
}
#[test]
@@ -604,9 +628,9 @@ impl Default for rte_eth_rss_conf {
/// in DCB configratioins
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_nb_tcs {
- /// < 4 TCs with DCB.
+ ///< 4 TCs with DCB.
ETH_4_TCS = 4,
- /// < 8 TCs with DCB.
+ ///< 8 TCs with DCB.
ETH_8_TCS = 8,
}
#[repr(u32)]
@@ -614,13 +638,13 @@ pub enum rte_eth_nb_tcs {
/// in VMDQ configurations.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_eth_nb_pools {
- /// < 8 VMDq pools.
+ ///< 8 VMDq pools.
ETH_8_POOLS = 8,
- /// < 16 VMDq pools.
+ ///< 16 VMDq pools.
ETH_16_POOLS = 16,
- /// < 32 VMDq pools.
+ ///< 32 VMDq pools.
ETH_32_POOLS = 32,
- /// < 64 VMDq pools.
+ ///< 64 VMDq pools.
ETH_64_POOLS = 64,
}
/// A structure used to configure the VMDQ+DCB feature
@@ -635,24 +659,24 @@ pub enum rte_eth_nb_pools {
#[repr(C)]
#[derive(Copy)]
pub struct rte_eth_vmdq_dcb_conf {
- /// < With DCB, 16 or 32 pools
+ ///< With DCB, 16 or 32 pools
pub nb_queue_pools: rte_eth_nb_pools,
- /// < If non-zero, use a default pool
+ ///< If non-zero, use a default pool
pub enable_default_pool: u8,
- /// < The default pool, if applicable
+ ///< The default pool, if applicable
pub default_pool: u8,
- /// < We can have up to 64 filters/mappings
+ ///< We can have up to 64 filters/mappings
pub nb_pool_maps: u8,
- /// < VMDq vlan pool maps.
+ ///< VMDq vlan pool maps.
pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize],
pub dcb_tc: [u8; 8usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
- /// < The vlan id of the received frame
+ ///< The vlan id of the received frame
pub vlan_id: u16,
- /// < Bitmask of pools for packet rx
+ ///< Bitmask of pools for packet rx
pub pools: u64,
}
#[test]
@@ -797,7 +821,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_dcb_rx_conf {
- /// < Possible DCB TCs, 4 or 8 TCs
+ ///< Possible DCB TCs, 4 or 8 TCs
pub nb_tcs: rte_eth_nb_tcs,
/// Traffic class each UP mapped to.
pub dcb_tc: [u8; 8usize],
@@ -848,7 +872,7 @@ impl Default for rte_eth_dcb_rx_conf {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_dcb_tx_conf {
- /// < With DCB, 16 or 32 pools.
+ ///< With DCB, 16 or 32 pools.
pub nb_queue_pools: rte_eth_nb_pools,
/// Traffic class each UP mapped to.
pub dcb_tc: [u8; 8usize],
@@ -901,7 +925,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_dcb_tx_conf {
- /// < Possible DCB TCs, 4 or 8 TCs.
+ ///< Possible DCB TCs, 4 or 8 TCs.
pub nb_tcs: rte_eth_nb_tcs,
/// Traffic class each UP mapped to.
pub dcb_tc: [u8; 8usize],
@@ -952,7 +976,7 @@ impl Default for rte_eth_dcb_tx_conf {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_tx_conf {
- /// < VMDq mode, 64 pools.
+ ///< VMDq mode, 64 pools.
pub nb_queue_pools: rte_eth_nb_pools,
}
#[test]
@@ -993,27 +1017,27 @@ impl Default for rte_eth_vmdq_tx_conf {
#[repr(C)]
#[derive(Copy)]
pub struct rte_eth_vmdq_rx_conf {
- /// < VMDq only mode, 8 or 64 pools
+ ///< VMDq only mode, 8 or 64 pools
pub nb_queue_pools: rte_eth_nb_pools,
- /// < If non-zero, use a default pool
+ ///< If non-zero, use a default pool
pub enable_default_pool: u8,
- /// < The default pool, if applicable
+ ///< The default pool, if applicable
pub default_pool: u8,
- /// < Enable VT loop back
+ ///< Enable VT loop back
pub enable_loop_back: u8,
- /// < We can have up to 64 filters/mappings
+ ///< We can have up to 64 filters/mappings
pub nb_pool_maps: u8,
- /// < Flags from ETH_VMDQ_ACCEPT_*
+ ///< Flags from ETH_VMDQ_ACCEPT_*
pub rx_mode: u32,
- /// < VMDq vlan pool maps.
+ ///< VMDq vlan pool maps.
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
}
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
- /// < The vlan id of the received frame
+ ///< The vlan id of the received frame
pub vlan_id: u16,
- /// < Bitmask of pools for packet rx
+ ///< Bitmask of pools for packet rx
pub pools: u64,
}
#[test]
@@ -1168,56 +1192,56 @@ impl Default for rte_eth_vmdq_rx_conf {
}
}
#[repr(u32)]
-/// Flow Director setting modes: none, signature or perfect.
+/// Flow Director setting modes: none, signature or perfect.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_fdir_mode {
- /// < Disable FDIR support.
+ ///< Disable FDIR support.
RTE_FDIR_MODE_NONE = 0,
- /// < Enable FDIR signature filter mode.
+ ///< Enable FDIR signature filter mode.
RTE_FDIR_MODE_SIGNATURE = 1,
- /// < Enable FDIR perfect filter mode.
+ ///< Enable FDIR perfect filter mode.
RTE_FDIR_MODE_PERFECT = 2,
- /// < Enable FDIR filter mode - MAC VLAN.
+ ///< Enable FDIR filter mode - MAC VLAN.
RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3,
- /// < Enable FDIR filter mode - tunnel.
+ ///< Enable FDIR filter mode - tunnel.
RTE_FDIR_MODE_PERFECT_TUNNEL = 4,
}
#[repr(u32)]
-/// Memory space that can be configured to store Flow Director filters
-/// in the board memory.
+/// Memory space that can be configured to store Flow Director filters
+/// in the board memory.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_fdir_pballoc_type {
- /// < 64k.
+ ///< 64k.
RTE_FDIR_PBALLOC_64K = 0,
- /// < 128k.
+ ///< 128k.
RTE_FDIR_PBALLOC_128K = 1,
- /// < 256k.
+ ///< 256k.
RTE_FDIR_PBALLOC_256K = 2,
}
#[repr(u32)]
-/// Select report mode of FDIR hash information in RX descriptors.
+/// Select report mode of FDIR hash information in RX descriptors.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum rte_fdir_status_mode {
- /// < Never report FDIR hash.
+ ///< Never report FDIR hash.
RTE_FDIR_NO_REPORT_STATUS = 0,
- /// < Only report FDIR hash for matching pkts.
+ ///< Only report FDIR hash for matching pkts.
RTE_FDIR_REPORT_STATUS = 1,
- /// < Always report FDIR hash.
+ ///< Always report FDIR hash.
RTE_FDIR_REPORT_STATUS_ALWAYS = 2,
}
/// A structure used to define the input for IPV4 flow
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_ipv4_flow {
- /// < IPv4 source address in big endian.
+ ///< IPv4 source address in big endian.
pub src_ip: u32,
- /// < IPv4 destination address in big endian.
+ ///< IPv4 destination address in big endian.
pub dst_ip: u32,
- /// < Type of service to match.
+ ///< Type of service to match.
pub tos: u8,
- /// < Time to live to match.
+ ///< Time to live to match.
pub ttl: u8,
- /// < Protocol, next header in big endian.
+ ///< Protocol, next header in big endian.
pub proto: u8,
}
#[test]
@@ -1292,15 +1316,15 @@ impl Clone for rte_eth_ipv4_flow {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_ipv6_flow {
- /// < IPv6 source address in big endian.
+ ///< IPv6 source address in big endian.
pub src_ip: [u32; 4usize],
- /// < IPv6 destination address in big endian.
+ ///< IPv6 destination address in big endian.
pub dst_ip: [u32; 4usize],
- /// < Traffic class to match.
+ ///< Traffic class to match.
pub tc: u8,
- /// < Protocol, next header to match.
+ ///< Protocol, next header to match.
pub proto: u8,
- /// < Hop limits to match.
+ ///< Hop limits to match.
pub hop_limits: u8,
}
#[test]
@@ -1371,12 +1395,12 @@ impl Clone for rte_eth_ipv6_flow {
*self
}
}
-/// A structure used to configure FDIR masks that are used by the device
-/// to match the various fields of RX packet headers.
+/// A structure used to configure FDIR masks that are used by the device
+/// to match the various fields of RX packet headers.
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_fdir_masks {
- /// < Bit mask for vlan_tci in big endian
+ ///< Bit mask for vlan_tci in big endian
pub vlan_tci_mask: u16,
/// Bit mask for ipv4 flow in big endian.
pub ipv4_mask: rte_eth_ipv4_flow,
@@ -1387,12 +1411,12 @@ pub struct rte_eth_fdir_masks {
/// Bit mask for L4 destination port in big endian.
pub dst_port_mask: u16,
/// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the
- /// first byte on the wire
+ ///first byte on the wire
pub mac_addr_byte_mask: u8,
/// Bit mask for tunnel ID in big endian.
pub tunnel_id_mask: u32,
- /// < 1 - Match tunnel type,
- /// 0 - Ignore tunnel type.
+ ///< 1 - Match tunnel type,
+ ///0 - Ignore tunnel type.
pub tunnel_type_mask: u8,
}
#[test]
@@ -1521,7 +1545,7 @@ pub enum rte_eth_payload_type {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_flex_payload_cfg {
- /// < Payload type
+ ///< Payload type
pub type_: rte_eth_payload_type,
pub src_offset: [u16; 16usize],
}
@@ -1623,9 +1647,9 @@ impl Clone for rte_eth_fdir_flex_mask {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_eth_fdir_flex_conf {
- /// < The number of following payload cfg
+ ///< The number of following payload cfg
pub nb_payloads: u16,
- /// < The number of following mask
+ ///< The number of following mask
pub nb_flexmasks: u16,
pub flex_set: [rte_eth_flex_payload_cfg; 8usize],
pub flex_mask: [rte_eth_fdir_flex_mask; 22usize],
@@ -1706,11 +1730,11 @@ impl Default for rte_eth_fdir_flex_conf {
#[repr(C)]
#[derive(Debug, Copy, Hash, PartialEq, Eq)]
pub struct rte_fdir_conf {
- /// < Flow Director mode.
+ ///< Flow Director mode.
pub mode: rte_fdir_mode,
- /// < Space for FDIR filters.
+ ///< Space for FDIR filters.
pub pballoc: rte_fdir_pballoc_type,
- /// < How to report FDIR hash.
+ ///< How to report FDIR hash.
pub status: rte_fdir_status_mode,
/// RX queue of packets matching a "drop" filter in perfect mode.
pub drop_queue: u8,
@@ -1853,40 +1877,40 @@ impl Clone for rte_intr_conf {
#[repr(C)]
#[derive(Copy)]
pub struct rte_eth_conf {
- /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be
- /// used. ETH_LINK_SPEED_FIXED disables link
- /// autonegotiation, and a unique speed shall be
- /// set. Otherwise, the bitmap defines the set of
- /// speeds to be advertised. If the special value
- /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
- /// supported are advertised.
+ ///< bitmap of ETH_LINK_SPEED_XXX of speeds to be
+ ///used. ETH_LINK_SPEED_FIXED disables link
+ ///autonegotiation, and a unique speed shall be
+ ///set. Otherwise, the bitmap defines the set of
+ ///speeds to be advertised. If the special value
+ ///ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
+ ///supported are advertised.
pub link_speeds: u32,
- /// < Port RX configuration.
+ ///< Port RX configuration.
pub rxmode: rte_eth_rxmode,
- /// < Port TX configuration.
+ ///< Port TX configuration.
pub txmode: rte_eth_txmode,
- /// < Loopback operation mode. By default the value
- /// is 0, meaning the loopback mode is disabled.
- /// Read the datasheet of given ethernet controller
- /// for details. The possible values of this field
- /// are defined in implementation of each driver.
+ ///< Loopback operation mode. By default the value
+ ///is 0, meaning the loopback mode is disabled.
+ ///Read the datasheet of given ethernet controller
+ ///for details. The possible values of this field
+ ///are defined in implementation of each driver.
pub lpbk_mode: u32,
- /// < Port RX filtering configuration (union).
+ ///< Port RX filtering configuration (union).
pub rx_adv_conf: rte_eth_conf__bindgen_ty_1,
- /// < Port TX DCB configuration (union).
+ ///< Port TX DCB configuration (union).
pub tx_adv_conf: rte_eth_conf__bindgen_ty_2,
/// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC
- /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT.
+ ///is needed,and the variable must be set ETH_DCB_PFC_SUPPORT.
pub dcb_capability_en: u32,
- /// < FDIR configuration.
+ ///< FDIR configuration.
pub fdir_conf: rte_fdir_conf,
- /// < Interrupt mode configuration.
+ ///< Interrupt mode configuration.
pub intr_conf: rte_intr_conf,
}
#[repr(C)]
#[derive(Copy)]
pub struct rte_eth_conf__bindgen_ty_1 {
- /// < Port RSS configuration
+ ///< Port RSS configuration
pub rss_conf: rte_eth_rss_conf,
pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf,
pub dcb_rx_conf: rte_eth_dcb_rx_conf,
diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs
index 80ab1be9..cd456881 100644
--- a/tests/expectations/tests/layout_kni_mbuf.rs
+++ b/tests/expectations/tests/layout_kni_mbuf.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const RTE_CACHE_LINE_MIN_SIZE: u32 = 64;
pub const RTE_CACHE_LINE_SIZE: u32 = 64;
@@ -10,18 +15,18 @@ pub struct rte_kni_mbuf {
pub buf_addr: *mut ::std::os::raw::c_void,
pub buf_physaddr: u64,
pub pad0: [::std::os::raw::c_char; 2usize],
- /// < Start address of data in segment buffer.
+ ///< Start address of data in segment buffer.
pub data_off: u16,
pub pad1: [::std::os::raw::c_char; 2usize],
- /// < Number of segments.
+ ///< Number of segments.
pub nb_segs: u8,
pub pad4: [::std::os::raw::c_char; 1usize],
- /// < Offload features.
+ ///< Offload features.
pub ol_flags: u64,
pub pad2: [::std::os::raw::c_char; 4usize],
- /// < Total pkt len: sum of all segment data_len.
+ ///< Total pkt len: sum of all segment data_len.
pub pkt_len: u32,
- /// < Amount of data in segment buffer.
+ ///< Amount of data in segment buffer.
pub data_len: u16,
pub __bindgen_padding_0: [u8; 22usize],
pub pad3: [::std::os::raw::c_char; 8usize],
diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs
index af738d04..5a865189 100644
--- a/tests/expectations/tests/layout_large_align_field.rs
+++ b/tests/expectations/tests/layout_large_align_field.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Default)]
@@ -28,7 +33,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
@@ -48,11 +53,11 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum _bindgen_ty_1 {
- /// < index of last fragment
+ ///< index of last fragment
IP_LAST_FRAG_IDX = 0,
- /// < index of first fragment
+ ///< index of first fragment
IP_FIRST_FRAG_IDX = 1,
- /// < minimum number of fragments
+ ///< minimum number of fragments
IP_MIN_FRAG_NUM = 2,
IP_MAX_FRAG_NUM = 4,
}
@@ -60,11 +65,11 @@ pub enum _bindgen_ty_1 {
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ip_frag {
- /// < offset into the packet
+ ///< offset into the packet
pub ofs: u16,
- /// < length of fragment
+ ///< length of fragment
pub len: u16,
- /// < fragment mbuf
+ ///< fragment mbuf
pub mb: *mut rte_mbuf,
}
#[test]
@@ -119,11 +124,11 @@ impl Default for ip_frag {
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ip_frag_key {
- /// < src address, first 8 bytes used for IPv4
+ ///< src address, first 8 bytes used for IPv4
pub src_dst: [u64; 4usize],
- /// < dst address
+ ///< dst address
pub id: u32,
- /// < src/dst key length
+ ///< src/dst key length
pub key_len: u32,
}
#[test]
@@ -174,19 +179,19 @@ fn bindgen_test_layout_ip_frag_key() {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ip_frag_pkt {
- /// < LRU list
+ ///< LRU list
pub lru: ip_frag_pkt__bindgen_ty_1,
- /// < fragmentation key
+ ///< fragmentation key
pub key: ip_frag_key,
- /// < creation timestamp
+ ///< creation timestamp
pub start: u64,
- /// < expected reassembled size
+ ///< expected reassembled size
pub total_size: u32,
- /// < size of fragments received
+ ///< size of fragments received
pub frag_size: u32,
- /// < index of next entry to fill
+ ///< index of next entry to fill
pub last_idx: u32,
- /// < fragments
+ ///< fragments
pub frags: [ip_frag; 4usize],
pub __bindgen_padding_0: [u64; 6usize],
}
@@ -369,17 +374,17 @@ impl Default for ip_pkt_list {
#[repr(C)]
#[derive(Copy, Clone)]
pub struct ip_frag_tbl_stat {
- /// < total # of find/insert attempts.
+ ///< total # of find/insert attempts.
pub find_num: u64,
- /// < # of add ops.
+ ///< # of add ops.
pub add_num: u64,
- /// < # of del ops.
+ ///< # of del ops.
pub del_num: u64,
- /// < # of reuse (del/add) ops.
+ ///< # of reuse (del/add) ops.
pub reuse_num: u64,
- /// < total # of add failures.
+ ///< total # of add failures.
pub fail_total: u64,
- /// < # of 'no space' add failures.
+ ///< # of 'no space' add failures.
pub fail_nospace: u64,
pub __bindgen_padding_0: [u64; 2usize],
}
@@ -459,28 +464,28 @@ impl Default for ip_frag_tbl_stat {
/// fragmentation table
#[repr(C)]
pub struct rte_ip_frag_tbl {
- /// < ttl for table entries.
+ ///< ttl for table entries.
pub max_cycles: u64,
- /// < hash value mask.
+ ///< hash value mask.
pub entry_mask: u32,
- /// < max entries allowed.
+ ///< max entries allowed.
pub max_entries: u32,
- /// < entries in use.
+ ///< entries in use.
pub use_entries: u32,
- /// < hash assocaitivity.
+ ///< hash assocaitivity.
pub bucket_entries: u32,
- /// < total size of the table.
+ ///< total size of the table.
pub nb_entries: u32,
- /// < num of associativity lines.
+ ///< num of associativity lines.
pub nb_buckets: u32,
- /// < last used entry.
+ ///< last used entry.
pub last: *mut ip_frag_pkt,
- /// < LRU list for table entries.
+ ///< LRU list for table entries.
pub lru: ip_pkt_list,
pub __bindgen_padding_0: u64,
- /// < statistics counters.
+ ///< statistics counters.
pub stat: ip_frag_tbl_stat,
- /// < hash table.
+ ///< hash table.
pub pkt: __IncompleteArrayField<ip_frag_pkt>,
}
#[test]
@@ -606,7 +611,7 @@ impl Default for rte_ip_frag_tbl {
unsafe { ::std::mem::zeroed() }
}
}
-/// < fragment mbuf
+///< fragment mbuf
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct rte_mbuf {
diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs
index c42cd0ba..79b6d687 100644
--- a/tests/expectations/tests/layout_mbuf.rs
+++ b/tests/expectations/tests/layout_mbuf.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -28,7 +33,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +51,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +75,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +96,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -91,7 +115,7 @@ pub type MARKER64 = [u64; 0usize];
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_atomic16_t {
- /// < An internal counter value.
+ ///< An internal counter value.
pub cnt: i16,
}
#[test]
@@ -121,40 +145,40 @@ fn bindgen_test_layout_rte_atomic16_t() {
#[repr(C)]
pub struct rte_mbuf {
pub cacheline0: MARKER,
- /// < Virtual address of segment buffer.
+ ///< Virtual address of segment buffer.
pub buf_addr: *mut ::std::os::raw::c_void,
- /// < Physical address of segment buffer.
+ ///< Physical address of segment buffer.
pub buf_physaddr: phys_addr_t,
- /// < Length of segment buffer.
+ ///< Length of segment buffer.
pub buf_len: u16,
pub rearm_data: MARKER8,
pub data_off: u16,
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1,
- /// < Number of segments.
+ ///< Number of segments.
pub nb_segs: u8,
- /// < Input port.
+ ///< Input port.
pub port: u8,
- /// < Offload features.
+ ///< Offload features.
pub ol_flags: u64,
pub rx_descriptor_fields1: MARKER,
pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2,
- /// < Total pkt len: sum of all segments.
+ ///< Total pkt len: sum of all segments.
pub pkt_len: u32,
- /// < Amount of data in segment buffer.
+ ///< Amount of data in segment buffer.
pub data_len: u16,
/// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set.
pub vlan_tci: u16,
- /// < hash information
+ ///< hash information
pub hash: rte_mbuf__bindgen_ty_3,
- /// < Sequence number. See also rte_reorder_insert()
+ ///< Sequence number. See also rte_reorder_insert()
pub seqn: u32,
/// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set.
pub vlan_tci_outer: u16,
pub cacheline1: MARKER,
pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4,
- /// < Pool from which mbuf was allocated.
+ ///< Pool from which mbuf was allocated.
pub pool: *mut rte_mempool,
- /// < Next segment of scattered packet.
+ ///< Next segment of scattered packet.
pub next: *mut rte_mbuf,
pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5,
/// Size of the application private data. In case of an indirect
@@ -173,9 +197,9 @@ pub struct rte_mbuf {
#[repr(C)]
#[derive(Copy, Clone)]
pub union rte_mbuf__bindgen_ty_1 {
- /// < Atomically accessed refcnt
+ ///< Atomically accessed refcnt
pub refcnt_atomic: rte_atomic16_t,
- /// < Non-atomically accessed refcnt
+ ///< Non-atomically accessed refcnt
pub refcnt: u16,
_bindgen_union_align: u16,
}
@@ -222,7 +246,7 @@ impl Default for rte_mbuf__bindgen_ty_1 {
#[repr(C)]
#[derive(Copy, Clone)]
pub union rte_mbuf__bindgen_ty_2 {
- /// < L2/L3/L4 and tunnel information.
+ ///< L2/L3/L4 and tunnel information.
pub packet_type: u32,
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_2__bindgen_ty_1,
_bindgen_union_align: u32,
@@ -406,13 +430,13 @@ impl Default for rte_mbuf__bindgen_ty_2 {
#[repr(C)]
#[derive(Copy, Clone)]
pub union rte_mbuf__bindgen_ty_3 {
- /// < RSS hash result if RSS enabled
+ ///< RSS hash result if RSS enabled
pub rss: u32,
- /// < Filter identifier if FDIR enabled
+ ///< Filter identifier if FDIR enabled
pub fdir: rte_mbuf__bindgen_ty_3__bindgen_ty_1,
- /// < Hierarchical scheduler
+ ///< Hierarchical scheduler
pub sched: rte_mbuf__bindgen_ty_3__bindgen_ty_2,
- /// < User defined tags. See rte_distributor_process()
+ ///< User defined tags. See rte_distributor_process()
pub usr: u32,
_bindgen_union_align: [u32; 2usize],
}
@@ -455,10 +479,7 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindg
);
assert_eq!(
unsafe {
- &(*(::std::ptr::null::<
- rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1,
- >()))
- .hash as *const _ as usize
+ & ( * ( :: std :: ptr :: null :: < rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 > ( ) ) ) . hash as * const _ as usize
},
0usize,
concat!(
@@ -470,10 +491,7 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindg
);
assert_eq!(
unsafe {
- &(*(::std::ptr::null::<
- rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1,
- >()))
- .id as *const _ as usize
+ & ( * ( :: std :: ptr :: null :: < rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 > ( ) ) ) . id as * const _ as usize
},
2usize,
concat!(
@@ -667,9 +685,9 @@ impl Default for rte_mbuf__bindgen_ty_3 {
#[repr(C)]
#[derive(Copy, Clone)]
pub union rte_mbuf__bindgen_ty_4 {
- /// < Can be used for external metadata
+ ///< Can be used for external metadata
pub userdata: *mut ::std::os::raw::c_void,
- /// < Allow 8-byte userdata on 32-bit
+ ///< Allow 8-byte userdata on 32-bit
pub udata64: u64,
_bindgen_union_align: u64,
}
@@ -714,7 +732,7 @@ impl Default for rte_mbuf__bindgen_ty_4 {
#[repr(C)]
#[derive(Copy, Clone)]
pub union rte_mbuf__bindgen_ty_5 {
- /// < combined for easy fetch
+ ///< combined for easy fetch
pub tx_offload: u64,
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_5__bindgen_ty_1,
_bindgen_union_align: u64,
@@ -1102,7 +1120,7 @@ impl Default for rte_mbuf {
unsafe { ::std::mem::zeroed() }
}
}
-/// < Pool from which mbuf was allocated.
+///< Pool from which mbuf was allocated.
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct rte_mempool {
diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs
index 2fd51418..71becc5f 100644
--- a/tests/expectations/tests/layout_mbuf_1_0.rs
+++ b/tests/expectations/tests/layout_mbuf_1_0.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -28,7 +33,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +51,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +75,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +96,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -111,7 +135,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
@@ -134,7 +158,7 @@ pub type MARKER64 = [u64; 0usize];
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_atomic16_t {
- /// < An internal counter value.
+ ///< An internal counter value.
pub cnt: i16,
}
#[test]
@@ -169,40 +193,40 @@ impl Clone for rte_atomic16_t {
#[repr(C)]
pub struct rte_mbuf {
pub cacheline0: MARKER,
- /// < Virtual address of segment buffer.
+ ///< Virtual address of segment buffer.
pub buf_addr: *mut ::std::os::raw::c_void,
- /// < Physical address of segment buffer.
+ ///< Physical address of segment buffer.
pub buf_physaddr: phys_addr_t,
- /// < Length of segment buffer.
+ ///< Length of segment buffer.
pub buf_len: u16,
pub rearm_data: MARKER8,
pub data_off: u16,
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1,
- /// < Number of segments.
+ ///< Number of segments.
pub nb_segs: u8,
- /// < Input port.
+ ///< Input port.
pub port: u8,
- /// < Offload features.
+ ///< Offload features.
pub ol_flags: u64,
pub rx_descriptor_fields1: MARKER,
pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2,
- /// < Total pkt len: sum of all segments.
+ ///< Total pkt len: sum of all segments.
pub pkt_len: u32,
- /// < Amount of data in segment buffer.
+ ///< Amount of data in segment buffer.
pub data_len: u16,
/// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set.
pub vlan_tci: u16,
- /// < hash information
+ ///< hash information
pub hash: rte_mbuf__bindgen_ty_3,
- /// < Sequence number. See also rte_reorder_insert()
+ ///< Sequence number. See also rte_reorder_insert()
pub seqn: u32,
/// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set.
pub vlan_tci_outer: u16,
pub cacheline1: MARKER,
pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4,
- /// < Pool from which mbuf was allocated.
+ ///< Pool from which mbuf was allocated.
pub pool: *mut rte_mempool,
- /// < Next segment of scattered packet.
+ ///< Next segment of scattered packet.
pub next: *mut rte_mbuf,
pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5,
/// Size of the application private data. In case of an indirect
@@ -221,9 +245,9 @@ pub struct rte_mbuf {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_1 {
- /// < Atomically accessed refcnt
+ ///< Atomically accessed refcnt
pub refcnt_atomic: __BindgenUnionField<rte_atomic16_t>,
- /// < Non-atomically accessed refcnt
+ ///< Non-atomically accessed refcnt
pub refcnt: __BindgenUnionField<u16>,
pub bindgen_union_field: u16,
}
@@ -270,7 +294,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_2 {
- /// < L2/L3/L4 and tunnel information.
+ ///< L2/L3/L4 and tunnel information.
pub packet_type: __BindgenUnionField<u32>,
pub __bindgen_anon_1: __BindgenUnionField<rte_mbuf__bindgen_ty_2__bindgen_ty_1>,
pub bindgen_union_field: u32,
@@ -459,13 +483,13 @@ impl Clone for rte_mbuf__bindgen_ty_2 {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_3 {
- /// < RSS hash result if RSS enabled
+ ///< RSS hash result if RSS enabled
pub rss: __BindgenUnionField<u32>,
- /// < Filter identifier if FDIR enabled
+ ///< Filter identifier if FDIR enabled
pub fdir: __BindgenUnionField<rte_mbuf__bindgen_ty_3__bindgen_ty_1>,
- /// < Hierarchical scheduler
+ ///< Hierarchical scheduler
pub sched: __BindgenUnionField<rte_mbuf__bindgen_ty_3__bindgen_ty_2>,
- /// < User defined tags. See rte_distributor_process()
+ ///< User defined tags. See rte_distributor_process()
pub usr: __BindgenUnionField<u32>,
pub bindgen_union_field: [u32; 2usize],
}
@@ -509,10 +533,7 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindg
);
assert_eq!(
unsafe {
- &(*(::std::ptr::null::<
- rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1,
- >()))
- .hash as *const _ as usize
+ & ( * ( :: std :: ptr :: null :: < rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 > ( ) ) ) . hash as * const _ as usize
},
0usize,
concat!(
@@ -524,10 +545,7 @@ fn bindgen_test_layout_rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindg
);
assert_eq!(
unsafe {
- &(*(::std::ptr::null::<
- rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1,
- >()))
- .id as *const _ as usize
+ & ( * ( :: std :: ptr :: null :: < rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 > ( ) ) ) . id as * const _ as usize
},
2usize,
concat!(
@@ -731,9 +749,9 @@ impl Clone for rte_mbuf__bindgen_ty_3 {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_4 {
- /// < Can be used for external metadata
+ ///< Can be used for external metadata
pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>,
- /// < Allow 8-byte userdata on 32-bit
+ ///< Allow 8-byte userdata on 32-bit
pub udata64: __BindgenUnionField<u64>,
pub bindgen_union_field: u64,
}
@@ -778,7 +796,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 {
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mbuf__bindgen_ty_5 {
- /// < combined for easy fetch
+ ///< combined for easy fetch
pub tx_offload: __BindgenUnionField<u64>,
pub __bindgen_anon_1: __BindgenUnionField<rte_mbuf__bindgen_ty_5__bindgen_ty_1>,
pub bindgen_union_field: u64,
@@ -1171,7 +1189,7 @@ impl Default for rte_mbuf {
unsafe { ::std::mem::zeroed() }
}
}
-/// < Pool from which mbuf was allocated.
+///< Pool from which mbuf was allocated.
#[repr(C)]
#[derive(Debug, Default, Copy, Hash, PartialEq, Eq)]
pub struct rte_mempool {
diff --git a/tests/expectations/tests/libclang-3.8/abi_variadic_function.rs b/tests/expectations/tests/libclang-3.8/abi_variadic_function.rs
new file mode 100644
index 00000000..ef1769dd
--- /dev/null
+++ b/tests/expectations/tests/libclang-3.8/abi_variadic_function.rs
@@ -0,0 +1,17 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern "C" {
+ #[link_name = "\u{1}_Z1acz"]
+ pub fn a(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char;
+}
+extern "C" {
+ #[link_name = "\u{1}_Z1bcz"]
+ pub fn b(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char;
+}
diff --git a/tests/expectations/tests/libclang-3.8/auto.rs b/tests/expectations/tests/libclang-3.8/auto.rs
index 8db72d0f..920023f3 100644
--- a/tests/expectations/tests/libclang-3.8/auto.rs
+++ b/tests/expectations/tests/libclang-3.8/auto.rs
@@ -11,7 +11,7 @@ pub struct Foo {
}
extern "C" {
#[link_name = "\u{1}_ZN3Foo4kFooE"]
- pub static mut Foo_kFoo: bool;
+ pub static Foo_kFoo: bool;
}
#[test]
fn bindgen_test_layout_Foo() {
diff --git a/tests/expectations/tests/libclang-3.8/const_bool.rs b/tests/expectations/tests/libclang-3.8/const_bool.rs
index 35636842..af5adcaf 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 = "\u{1}_ZL1k"]
- pub static mut k: bool;
+ pub static k: bool;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@@ -15,7 +15,7 @@ pub struct A {
}
extern "C" {
#[link_name = "\u{1}_ZN1A1kE"]
- pub static mut A_k: bool;
+ pub static A_k: bool;
}
#[test]
fn bindgen_test_layout_A() {
@@ -33,5 +33,5 @@ fn bindgen_test_layout_A() {
pub type foo = bool;
extern "C" {
#[link_name = "\u{1}_ZL2k2"]
- pub static mut k2: foo;
+ pub static 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 8faddfe9..fa54df27 100644
--- a/tests/expectations/tests/libclang-3.8/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-3.8/constant-evaluate.rs
@@ -13,23 +13,27 @@ pub type EasyToOverflow = ::std::os::raw::c_ulonglong;
pub const k: EasyToOverflow = 2147483648;
extern "C" {
#[link_name = "\u{1}k_expr"]
- pub static mut k_expr: EasyToOverflow;
+ pub static k_expr: EasyToOverflow;
+}
+extern "C" {
+ #[link_name = "\u{1}wow"]
+ pub static wow: EasyToOverflow;
}
extern "C" {
#[link_name = "\u{1}BAZ"]
- pub static mut BAZ: ::std::os::raw::c_longlong;
+ pub static BAZ: ::std::os::raw::c_longlong;
}
extern "C" {
#[link_name = "\u{1}fuzz"]
- pub static mut fuzz: f64;
+ pub static fuzz: f64;
}
extern "C" {
#[link_name = "\u{1}BAZZ"]
- pub static mut BAZZ: ::std::os::raw::c_char;
+ pub static BAZZ: ::std::os::raw::c_char;
}
extern "C" {
#[link_name = "\u{1}WAT"]
- pub static mut WAT: ::std::os::raw::c_char;
+ pub static WAT: ::std::os::raw::c_char;
}
extern "C" {
#[link_name = "\u{1}bytestring"]
diff --git a/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs
new file mode 100644
index 00000000..68eab7a2
--- /dev/null
+++ b/tests/expectations/tests/libclang-3.8/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+pub const a: u32 = 18446744073709551611;
diff --git a/tests/expectations/tests/libclang-3.9/abi_variadic_function.rs b/tests/expectations/tests/libclang-3.9/abi_variadic_function.rs
new file mode 100644
index 00000000..89cf9a64
--- /dev/null
+++ b/tests/expectations/tests/libclang-3.9/abi_variadic_function.rs
@@ -0,0 +1,13 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern "C" {
+ #[link_name = "\u{1}_Z1bcz"]
+ pub fn b(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char;
+}
diff --git a/tests/expectations/tests/libclang-3.9/constant-evaluate.rs b/tests/expectations/tests/libclang-3.9/constant-evaluate.rs
index 159dba7c..6a3c8a36 100644
--- a/tests/expectations/tests/libclang-3.9/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-3.9/constant-evaluate.rs
@@ -15,6 +15,10 @@ pub enum _bindgen_ty_1 {
pub type EasyToOverflow = ::std::os::raw::c_ulonglong;
pub const k: EasyToOverflow = 2147483648;
pub const k_expr: EasyToOverflow = 0;
+extern "C" {
+ #[link_name = "\u{1}wow"]
+ pub static wow: EasyToOverflow;
+}
pub const BAZ: ::std::os::raw::c_longlong = 24;
pub const fuzz: f64 = 51.0;
pub const BAZZ: ::std::os::raw::c_char = 53;
diff --git a/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs
new file mode 100644
index 00000000..68eab7a2
--- /dev/null
+++ b/tests/expectations/tests/libclang-3.9/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+pub const a: u32 = 18446744073709551611;
diff --git a/tests/expectations/tests/libclang-4/abi_variadic_function.rs b/tests/expectations/tests/libclang-4/abi_variadic_function.rs
new file mode 100644
index 00000000..89cf9a64
--- /dev/null
+++ b/tests/expectations/tests/libclang-4/abi_variadic_function.rs
@@ -0,0 +1,13 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern "C" {
+ #[link_name = "\u{1}_Z1bcz"]
+ pub fn b(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char;
+}
diff --git a/tests/expectations/tests/libclang-4/constant-evaluate.rs b/tests/expectations/tests/libclang-4/constant-evaluate.rs
index 045710f9..07df8114 100644
--- a/tests/expectations/tests/libclang-4/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-4/constant-evaluate.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo;
pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar;
@@ -12,7 +17,8 @@ pub enum _bindgen_ty_1 {
}
pub type EasyToOverflow = ::std::os::raw::c_ulonglong;
pub const k: EasyToOverflow = 2147483648;
-pub const k_expr: EasyToOverflow = 0;
+pub const k_expr: EasyToOverflow = 1152921504606846976;
+pub const wow: EasyToOverflow = 2147483648;
pub const BAZ: ::std::os::raw::c_longlong = 24;
pub const fuzz: f64 = 51.0;
pub const BAZZ: ::std::os::raw::c_char = 53;
diff --git a/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs
new file mode 100644
index 00000000..7ad2fc1c
--- /dev/null
+++ b/tests/expectations/tests/libclang-4/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+pub const a: u32 = 4294967291;
diff --git a/tests/expectations/tests/libclang-5/abi_variadic_function.rs b/tests/expectations/tests/libclang-5/abi_variadic_function.rs
new file mode 100644
index 00000000..89cf9a64
--- /dev/null
+++ b/tests/expectations/tests/libclang-5/abi_variadic_function.rs
@@ -0,0 +1,13 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern "C" {
+ #[link_name = "\u{1}_Z1bcz"]
+ pub fn b(arg1: ::std::os::raw::c_char, ...) -> ::std::os::raw::c_char;
+}
diff --git a/tests/expectations/tests/libclang-5/constant-evaluate.rs b/tests/expectations/tests/libclang-5/constant-evaluate.rs
index 045710f9..07df8114 100644
--- a/tests/expectations/tests/libclang-5/constant-evaluate.rs
+++ b/tests/expectations/tests/libclang-5/constant-evaluate.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo;
pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar;
@@ -12,7 +17,8 @@ pub enum _bindgen_ty_1 {
}
pub type EasyToOverflow = ::std::os::raw::c_ulonglong;
pub const k: EasyToOverflow = 2147483648;
-pub const k_expr: EasyToOverflow = 0;
+pub const k_expr: EasyToOverflow = 1152921504606846976;
+pub const wow: EasyToOverflow = 2147483648;
pub const BAZ: ::std::os::raw::c_longlong = 24;
pub const fuzz: f64 = 51.0;
pub const BAZZ: ::std::os::raw::c_char = 53;
diff --git a/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs b/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs
new file mode 100644
index 00000000..7ad2fc1c
--- /dev/null
+++ b/tests/expectations/tests/libclang-5/error-E0600-cannot-apply-unary-negation-to-u32.rs
@@ -0,0 +1,10 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+pub const a: u32 = 4294967291;
diff --git a/tests/expectations/tests/long_double.rs b/tests/expectations/tests/long_double.rs
new file mode 100644
index 00000000..632eeb5a
--- /dev/null
+++ b/tests/expectations/tests/long_double.rs
@@ -0,0 +1,33 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[repr(align(16))]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct foo {
+ pub bar: u128,
+}
+#[test]
+fn bindgen_test_layout_foo() {
+ assert_eq!(
+ ::std::mem::size_of::<foo>(),
+ 16usize,
+ concat!("Size of: ", stringify!(foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<foo>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(foo))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<foo>())).bar as *const _ as usize },
+ 0usize,
+ concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar))
+ );
+}
diff --git a/tests/expectations/tests/macro_const.rs b/tests/expectations/tests/macro_const.rs
index 382af9a5..851dd54e 100644
--- a/tests/expectations/tests/macro_const.rs
+++ b/tests/expectations/tests/macro_const.rs
@@ -1,12 +1,16 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
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 LONG: u32 = 3;
pub const INVALID_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];
diff --git a/tests/expectations/tests/only_bitfields.rs b/tests/expectations/tests/only_bitfields.rs
index 09bd8737..13713ed2 100644
--- a/tests/expectations/tests/only_bitfields.rs
+++ b/tests/expectations/tests/only_bitfields.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/ord-enum.rs b/tests/expectations/tests/ord-enum.rs
new file mode 100644
index 00000000..579817bc
--- /dev/null
+++ b/tests/expectations/tests/ord-enum.rs
@@ -0,0 +1,25 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
+pub enum A {
+ A0 = 0,
+ A1 = 1,
+ A2 = 2,
+ A3 = -1,
+}
+#[repr(i32)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
+pub enum B {
+ B0 = 1,
+ B1 = 4,
+ B2 = 3,
+ B3 = -1,
+}
diff --git a/tests/expectations/tests/prepend-enum-constified-variant.rs b/tests/expectations/tests/prepend-enum-constified-variant.rs
index 7f3b6746..d0323e12 100644
--- a/tests/expectations/tests/prepend-enum-constified-variant.rs
+++ b/tests/expectations/tests/prepend-enum-constified-variant.rs
@@ -1,8 +1,15 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
-pub const AV_CODEC_ID_TTF: AVCodecID = AVCodecID::AV_CODEC_ID_FIRST_UNKNOWN;
+impl AVCodecID {
+ pub const AV_CODEC_ID_TTF: AVCodecID = AVCodecID::AV_CODEC_ID_FIRST_UNKNOWN;
+}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum AVCodecID {
diff --git a/tests/expectations/tests/repr-align.rs b/tests/expectations/tests/repr-align.rs
index 1827ca9d..8a0c9023 100644
--- a/tests/expectations/tests/repr-align.rs
+++ b/tests/expectations/tests/repr-align.rs
@@ -1,6 +1,11 @@
/* automatically generated by rust-bindgen */
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#![cfg(feature = "nightly")]
#[repr(C)]
@@ -9,7 +14,6 @@
pub struct a {
pub b: ::std::os::raw::c_int,
pub c: ::std::os::raw::c_int,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_a() {
@@ -40,7 +44,6 @@ fn bindgen_test_layout_a() {
pub struct b {
pub b: ::std::os::raw::c_int,
pub c: ::std::os::raw::c_int,
- pub __bindgen_align: [u64; 0usize],
}
#[test]
fn bindgen_test_layout_b() {
diff --git a/tests/expectations/tests/sentry-defined-multiple-times.rs b/tests/expectations/tests/sentry-defined-multiple-times.rs
index 887d84bb..7f96b450 100644
--- a/tests/expectations/tests/sentry-defined-multiple-times.rs
+++ b/tests/expectations/tests/sentry-defined-multiple-times.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
@@ -274,10 +277,7 @@ pub mod root {
);
assert_eq!(
unsafe {
- &(*(::std::ptr::null::<
- OuterDoubleInlineWrapper_InnerDoubleInlineWrapper_sentry,
- >()))
- .i_am_double_wrapper_inline_sentry as *const _ as usize
+ & ( * ( :: std :: ptr :: null :: < OuterDoubleInlineWrapper_InnerDoubleInlineWrapper_sentry > ( ) ) ) . i_am_double_wrapper_inline_sentry as * const _ as usize
},
0usize,
concat!(
diff --git a/tests/expectations/tests/struct_with_anon_union_1_0.rs b/tests/expectations/tests/struct_with_anon_union_1_0.rs
index 7e2855c9..88e27efe 100644
--- a/tests/expectations/tests/struct_with_anon_union_1_0.rs
+++ b/tests/expectations/tests/struct_with_anon_union_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
index c7a73b17..43ff66bc 100644
--- a/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
+++ b/tests/expectations/tests/struct_with_anon_unnamed_union_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs
index a45472d5..7abd1087 100644
--- a/tests/expectations/tests/struct_with_bitfields.rs
+++ b/tests/expectations/tests/struct_with_bitfields.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/struct_with_nesting_1_0.rs b/tests/expectations/tests/struct_with_nesting_1_0.rs
index ff65ea03..569a7b81 100644
--- a/tests/expectations/tests/struct_with_nesting_1_0.rs
+++ b/tests/expectations/tests/struct_with_nesting_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/transform-op.rs b/tests/expectations/tests/transform-op.rs
new file mode 100644
index 00000000..c3273ca2
--- /dev/null
+++ b/tests/expectations/tests/transform-op.rs
@@ -0,0 +1,236 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl<T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self {
+ __BindgenUnionField(::std::marker::PhantomData)
+ }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T {
+ ::std::mem::transmute(self)
+ }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T {
+ ::std::mem::transmute(self)
+ }
+}
+impl<T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self {
+ Self::new()
+ }
+}
+impl<T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self {
+ Self::new()
+ }
+}
+impl<T> ::std::marker::Copy for __BindgenUnionField<T> {}
+impl<T> ::std::fmt::Debug for __BindgenUnionField<T> {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
+ fmt.write_str("__BindgenUnionField")
+ }
+}
+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::Eq for __BindgenUnionField<T> {}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StylePoint<T> {
+ pub x: T,
+ pub y: T,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StylePoint<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct StyleFoo<T> {
+ pub __bindgen_anon_1: __BindgenUnionField<StyleFoo__bindgen_ty_1>,
+ pub foo: __BindgenUnionField<StyleFoo_Foo_Body<T>>,
+ pub bar: __BindgenUnionField<StyleFoo_Bar_Body<T>>,
+ pub baz: __BindgenUnionField<StyleFoo_Baz_Body<T>>,
+ pub bindgen_union_field: [u8; 0usize],
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+pub const StyleFoo_Tag_Foo: StyleFoo_Tag = 0;
+pub const StyleFoo_Tag_Bar: StyleFoo_Tag = 0;
+pub const StyleFoo_Tag_Baz: StyleFoo_Tag = 0;
+pub const StyleFoo_Tag_Bazz: StyleFoo_Tag = 0;
+pub type StyleFoo_Tag = u8;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleFoo_Foo_Body<T> {
+ pub tag: StyleFoo_Tag,
+ pub x: i32,
+ pub y: StylePoint<T>,
+ pub z: StylePoint<f32>,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleFoo_Foo_Body<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleFoo_Bar_Body<T> {
+ pub tag: StyleFoo_Tag,
+ pub _0: T,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleFoo_Bar_Body<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleFoo_Baz_Body<T> {
+ pub tag: StyleFoo_Tag,
+ pub _0: StylePoint<T>,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleFoo_Baz_Body<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleFoo__bindgen_ty_1 {
+ pub tag: StyleFoo_Tag,
+}
+impl Default for StyleFoo__bindgen_ty_1 {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl<T> Default for StyleFoo<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct StyleBar<T> {
+ pub tag: StyleBar_Tag,
+ pub __bindgen_anon_1: StyleBar__bindgen_ty_1<T>,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+pub const StyleBar_Tag_Bar1: StyleBar_Tag = 0;
+pub const StyleBar_Tag_Bar2: StyleBar_Tag = 0;
+pub const StyleBar_Tag_Bar3: StyleBar_Tag = 0;
+pub const StyleBar_Tag_Bar4: StyleBar_Tag = 0;
+pub type StyleBar_Tag = i32;
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleBar_StyleBar1_Body<T> {
+ pub x: i32,
+ pub y: StylePoint<T>,
+ pub z: StylePoint<f32>,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleBar_StyleBar1_Body<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleBar_StyleBar2_Body<T> {
+ pub _0: T,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleBar_StyleBar2_Body<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct StyleBar_StyleBar3_Body<T> {
+ pub _0: StylePoint<T>,
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleBar_StyleBar3_Body<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct StyleBar__bindgen_ty_1<T> {
+ pub bar1: __BindgenUnionField<StyleBar_StyleBar1_Body<T>>,
+ pub bar2: __BindgenUnionField<StyleBar_StyleBar2_Body<T>>,
+ pub bar3: __BindgenUnionField<StyleBar_StyleBar3_Body<T>>,
+ pub bindgen_union_field: [u8; 0usize],
+ pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
+}
+impl<T> Default for StyleBar__bindgen_ty_1<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+impl<T> Default for StyleBar<T> {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
+#[test]
+fn __bindgen_test_layout_StylePoint_open0_float_close0_instantiation() {
+ assert_eq!(
+ ::std::mem::size_of::<StylePoint<f32>>(),
+ 8usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify!(StylePoint<f32>)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<StylePoint<f32>>(),
+ 4usize,
+ concat!(
+ "Alignment of template specialization: ",
+ stringify!(StylePoint<f32>)
+ )
+ );
+}
+#[test]
+fn __bindgen_test_layout_StylePoint_open0_float_close0_instantiation_1() {
+ assert_eq!(
+ ::std::mem::size_of::<StylePoint<f32>>(),
+ 8usize,
+ concat!(
+ "Size of template specialization: ",
+ stringify!(StylePoint<f32>)
+ )
+ );
+ assert_eq!(
+ ::std::mem::align_of::<StylePoint<f32>>(),
+ 4usize,
+ concat!(
+ "Alignment of template specialization: ",
+ stringify!(StylePoint<f32>)
+ )
+ );
+}
diff --git a/tests/expectations/tests/typeref_1_0.rs b/tests/expectations/tests/typeref_1_0.rs
index 649d41fa..2f5351a9 100644
--- a/tests/expectations/tests/typeref_1_0.rs
+++ b/tests/expectations/tests/typeref_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union-align.rs b/tests/expectations/tests/union-align.rs
new file mode 100644
index 00000000..01eb78b7
--- /dev/null
+++ b/tests/expectations/tests/union-align.rs
@@ -0,0 +1,39 @@
+/* automatically generated by rust-bindgen */
+
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[repr(align(16))]
+#[derive(Copy, Clone)]
+pub union Bar {
+ pub foo: ::std::os::raw::c_uchar,
+ _bindgen_union_align: u128,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(
+ ::std::mem::size_of::<Bar>(),
+ 16usize,
+ concat!("Size of: ", stringify!(Bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Bar>(),
+ 16usize,
+ concat!("Alignment of ", stringify!(Bar))
+ );
+ assert_eq!(
+ unsafe { &(*(::std::ptr::null::<Bar>())).foo as *const _ as usize },
+ 0usize,
+ concat!("Offset of field: ", stringify!(Bar), "::", stringify!(foo))
+ );
+}
+impl Default for Bar {
+ fn default() -> Self {
+ unsafe { ::std::mem::zeroed() }
+ }
+}
diff --git a/tests/expectations/tests/union-in-ns_1_0.rs b/tests/expectations/tests/union-in-ns_1_0.rs
index 8635727f..e3a6272e 100644
--- a/tests/expectations/tests/union-in-ns_1_0.rs
+++ b/tests/expectations/tests/union-in-ns_1_0.rs
@@ -36,7 +36,7 @@ pub mod root {
}
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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_bitfield.rs b/tests/expectations/tests/union_bitfield.rs
index 1f75ee4d..0f884bfc 100644
--- a/tests/expectations/tests/union_bitfield.rs
+++ b/tests/expectations/tests/union_bitfield.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/union_bitfield_1_0.rs b/tests/expectations/tests/union_bitfield_1_0.rs
index a85fad4c..a86cee18 100644
--- a/tests/expectations/tests/union_bitfield_1_0.rs
+++ b/tests/expectations/tests/union_bitfield_1_0.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -30,7 +33,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +51,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +75,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +96,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -113,7 +135,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
@@ -262,3 +284,8 @@ impl Default for HasBigBitfield {
unsafe { ::std::mem::zeroed() }
}
}
+impl ::std::cmp::PartialEq for HasBigBitfield {
+ fn eq(&self, other: &HasBigBitfield) -> bool {
+ &self.bindgen_union_field[..] == &other.bindgen_union_field[..]
+ }
+}
diff --git a/tests/expectations/tests/union_dtor_1_0.rs b/tests/expectations/tests/union_dtor_1_0.rs
index 77a73427..0814b780 100644
--- a/tests/expectations/tests/union_dtor_1_0.rs
+++ b/tests/expectations/tests/union_dtor_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_fields_1_0.rs b/tests/expectations/tests/union_fields_1_0.rs
index 090f1662..6da625d1 100644
--- a/tests/expectations/tests/union_fields_1_0.rs
+++ b/tests/expectations/tests/union_fields_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_template_1_0.rs b/tests/expectations/tests/union_template_1_0.rs
index 7b350b07..a5ab7984 100644
--- a/tests/expectations/tests/union_template_1_0.rs
+++ b/tests/expectations/tests/union_template_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_anon_struct_1_0.rs b/tests/expectations/tests/union_with_anon_struct_1_0.rs
index cdd17136..2638fa5a 100644
--- a/tests/expectations/tests/union_with_anon_struct_1_0.rs
+++ b/tests/expectations/tests/union_with_anon_struct_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
index 9e671741..f5986246 100644
--- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs
+++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
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 f2d63c3e..9a976071 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
@@ -1,9 +1,7 @@
/* automatically generated by rust-bindgen */
-
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
@@ -30,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -43,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -63,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -79,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
@@ -113,7 +130,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_anon_union_1_0.rs b/tests/expectations/tests/union_with_anon_union_1_0.rs
index 2ccf1739..8e6c01ee 100644
--- a/tests/expectations/tests/union_with_anon_union_1_0.rs
+++ b/tests/expectations/tests/union_with_anon_union_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
index cbfd4702..80c83acb 100644
--- a/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
+++ b/tests/expectations/tests/union_with_anon_unnamed_struct_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
index 45054739..bda49e24 100644
--- a/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
+++ b/tests/expectations/tests/union_with_anon_unnamed_union_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_big_member_1_0.rs b/tests/expectations/tests/union_with_big_member_1_0.rs
index c41e64e2..c636c8e5 100644
--- a/tests/expectations/tests/union_with_big_member_1_0.rs
+++ b/tests/expectations/tests/union_with_big_member_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/union_with_nesting_1_0.rs b/tests/expectations/tests/union_with_nesting_1_0.rs
index 9c7956ea..b9fc908f 100644
--- a/tests/expectations/tests/union_with_nesting_1_0.rs
+++ b/tests/expectations/tests/union_with_nesting_1_0.rs
@@ -34,7 +34,7 @@ impl<T> ::std::clone::Clone 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 {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/use-core_1_0.rs b/tests/expectations/tests/use-core_1_0.rs
index 8a867817..3ce8fe5c 100644
--- a/tests/expectations/tests/use-core_1_0.rs
+++ b/tests/expectations/tests/use-core_1_0.rs
@@ -35,7 +35,7 @@ impl<T> ::core::clone::Clone for __BindgenUnionField<T> {
}
impl<T> ::core::marker::Copy for __BindgenUnionField<T> {}
impl<T> ::core::fmt::Debug for __BindgenUnionField<T> {
- fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.write_str("__BindgenUnionField")
}
}
diff --git a/tests/expectations/tests/vector.rs b/tests/expectations/tests/vector.rs
index 357b9ef4..86a9d737 100644
--- a/tests/expectations/tests/vector.rs
+++ b/tests/expectations/tests/vector.rs
@@ -1,8 +1,11 @@
/* automatically generated by rust-bindgen */
-
-#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
@@ -32,3 +35,10 @@ fn bindgen_test_layout_foo() {
)
);
}
+pub type __m128 = [f32; 4usize];
+pub type __m128d = [f64; 2usize];
+pub type __m128i = [::std::os::raw::c_longlong; 2usize];
+extern "C" {
+ #[link_name = "\u{1}_Z3fooDv2_xDv2_d"]
+ pub fn foo(arg1: __m128i, arg2: __m128d) -> __m128;
+}
diff --git a/tests/expectations/tests/weird_bitfields.rs b/tests/expectations/tests/weird_bitfields.rs
index 8ab2987c..5bedcadd 100644
--- a/tests/expectations/tests/weird_bitfields.rs
+++ b/tests/expectations/tests/weird_bitfields.rs
@@ -28,7 +28,12 @@ where
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
- let bit_index = index % 8;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+
let mask = 1 << bit_index;
byte & mask == mask
@@ -41,9 +46,13 @@ where
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
- let bit_index = index % 8;
- let mask = 1 << bit_index;
+ let bit_index = if cfg!(target_endian = "big") {
+ 7 - (index % 8)
+ } else {
+ index % 8
+ };
+ let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
@@ -61,7 +70,12 @@ where
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
- val |= 1 << i;
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ val |= 1 << index;
}
}
@@ -77,7 +91,12 @@ where
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
- self.set_bit(i + bit_offset, val_bit_is_set);
+ let index = if cfg!(target_endian = "big") {
+ bit_width as usize - 1 - i
+ } else {
+ i
+ };
+ self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
diff --git a/tests/expectations/tests/zero-sized-array.rs b/tests/expectations/tests/zero-sized-array.rs
index fe78ae86..11ad0fe6 100644
--- a/tests/expectations/tests/zero-sized-array.rs
+++ b/tests/expectations/tests/zero-sized-array.rs
@@ -30,7 +30,7 @@ impl<T> __IncompleteArrayField<T> {
}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
- fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+ fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_str("__IncompleteArrayField")
}
}
diff --git a/tests/headers/abi_variadic_function.hpp b/tests/headers/abi_variadic_function.hpp
new file mode 100644
index 00000000..2141535c
--- /dev/null
+++ b/tests/headers/abi_variadic_function.hpp
@@ -0,0 +1,4 @@
+// bindgen-flags: -- -std=c++11
+
+char __attribute__((ms_abi)) a(char, ...);
+char b(char, ...);
diff --git a/tests/headers/anon_enum.hpp b/tests/headers/anon_enum.hpp
index 23dc5ceb..bbd52240 100644
--- a/tests/headers/anon_enum.hpp
+++ b/tests/headers/anon_enum.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
struct Test {
int foo;
float bar;
diff --git a/tests/headers/anon_enum_trait.hpp b/tests/headers/anon_enum_trait.hpp
index 6383c748..cc0cd389 100644
--- a/tests/headers/anon_enum_trait.hpp
+++ b/tests/headers/anon_enum_trait.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
template<typename _Tp>
class DataType {
diff --git a/tests/headers/anon_enum_whitelist.h b/tests/headers/anon_enum_whitelist.h
index fc4810e0..a35e4886 100644
--- a/tests/headers/anon_enum_whitelist.h
+++ b/tests/headers/anon_enum_whitelist.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --whitelist-var NODE_.* --rustified-enum .*
+// bindgen-flags: --whitelist-var "NODE_.*" --rustified-enum ".*"
enum {
NODE_FLAG_FOO,
diff --git a/tests/headers/anon_union.hpp b/tests/headers/anon_union.hpp
index 19c478d1..e4be25bc 100644
--- a/tests/headers/anon_union.hpp
+++ b/tests/headers/anon_union.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
template<typename T>
struct TErrorResult {
enum UnionState {
diff --git a/tests/headers/anon_union_1_0.hpp b/tests/headers/anon_union_1_0.hpp
index 314215bf..3d9ae3dd 100644
--- a/tests/headers/anon_union_1_0.hpp
+++ b/tests/headers/anon_union_1_0.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
template<typename T>
struct TErrorResult {
diff --git a/tests/headers/bitfield-enum-basic.hpp b/tests/headers/bitfield-enum-basic.hpp
index c03f0e70..339fb4d5 100644
--- a/tests/headers/bitfield-enum-basic.hpp
+++ b/tests/headers/bitfield-enum-basic.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --bitfield-enum "Foo|Buz|NS_.*|DUMMY_.*" --rustified-enum .* -- -std=c++11
+// bindgen-flags: --bitfield-enum "Foo|Buz|NS_.*|DUMMY_.*" --rustified-enum ".*" -- -std=c++11
enum Foo {
Bar = 1 << 1,
diff --git a/tests/headers/bitfield_align_2.h b/tests/headers/bitfield_align_2.h
index 31d37f76..b6a6cd28 100644
--- a/tests/headers/bitfield_align_2.h
+++ b/tests/headers/bitfield_align_2.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum MyEnum {
ONE,
TWO,
diff --git a/tests/headers/blacklist-function.hpp b/tests/headers/blacklist-function.hpp
new file mode 100644
index 00000000..c4a923fc
--- /dev/null
+++ b/tests/headers/blacklist-function.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: --blacklist-function "ExternFunction" --blacklist-function "foo::NamespacedFunction" --enable-cxx-namespaces
+
+extern "C" void ExternFunction();
+
+namespace foo {
+ void NamespacedFunction();
+}
+
+namespace bar {
+ void NamespacedFunction();
+}
diff --git a/tests/headers/blacklist-item.hpp b/tests/headers/blacklist-item.hpp
new file mode 100644
index 00000000..8d569dde
--- /dev/null
+++ b/tests/headers/blacklist-item.hpp
@@ -0,0 +1,21 @@
+// bindgen-flags: --blacklist-item "SomeFunction" --blacklist-item "SOME_DEFUN" --blacklist-item "someVar" --blacklist-item "ExternFunction" --blacklist-item "foo::NamespacedFunction" --blacklist-item "someClass.*" --enable-cxx-namespaces
+
+void SomeFunction();
+extern int someVar;
+#define SOME_DEFUN 123
+
+class someClass {
+ void somePrivateMethod();
+public:
+ void somePublicMethod(int foo);
+};
+
+extern "C" void ExternFunction();
+
+namespace foo {
+ void NamespacedFunction();
+}
+
+namespace bar {
+ void NamespacedFunction();
+}
diff --git a/tests/headers/blocks-signature.hpp b/tests/headers/blocks-signature.hpp
new file mode 100644
index 00000000..eaa72526
--- /dev/null
+++ b/tests/headers/blocks-signature.hpp
@@ -0,0 +1,4 @@
+// bindgen-flags: --generate-block --block-extern-crate -- -fblocks
+// bindgen-osx-only
+
+#include "blocks.hpp"
diff --git a/tests/headers/blocks.h b/tests/headers/blocks.h
deleted file mode 100644
index 80420e6e..00000000
--- a/tests/headers/blocks.h
+++ /dev/null
@@ -1,3 +0,0 @@
-// bindgen-flags: -- -fblocks
-
-void atexit_b(void (^)(void));
diff --git a/tests/headers/blocks.hpp b/tests/headers/blocks.hpp
new file mode 100644
index 00000000..b8bc71f9
--- /dev/null
+++ b/tests/headers/blocks.hpp
@@ -0,0 +1,16 @@
+// bindgen-flags: --block-extern-crate -- -fblocks
+// bindgen-osx-only
+
+typedef unsigned long long size_t;
+
+void atexit_b(void (^)(void));
+
+typedef void *dispatch_data_t;
+
+typedef bool (^dispatch_data_applier_t)(dispatch_data_t region,
+ size_t offset,
+ const void *buffer,
+ size_t size);
+
+bool dispatch_data_apply(dispatch_data_t data,
+ dispatch_data_applier_t applier); \ No newline at end of file
diff --git a/tests/headers/call-conv-typedef.h b/tests/headers/call-conv-typedef.h
new file mode 100644
index 00000000..3b911dda
--- /dev/null
+++ b/tests/headers/call-conv-typedef.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --raw-line "#![cfg(not(test))]" -- --target=i686-pc-win32
+
+
+typedef void (__stdcall *void_fn)();
+typedef void_fn (__stdcall *fn)(int id);
diff --git a/tests/headers/class_with_inner_struct.hpp b/tests/headers/class_with_inner_struct.hpp
index 66c2bd3f..fd195fb7 100644
--- a/tests/headers/class_with_inner_struct.hpp
+++ b/tests/headers/class_with_inner_struct.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
// bindgen-flags: -- -std=c++11
class A {
diff --git a/tests/headers/class_with_inner_struct_1_0.hpp b/tests/headers/class_with_inner_struct_1_0.hpp
index 1bae249f..34ed96e7 100644
--- a/tests/headers/class_with_inner_struct_1_0.hpp
+++ b/tests/headers/class_with_inner_struct_1_0.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
// bindgen-flags: -- -std=c++11
class A {
diff --git a/tests/headers/const_enum_unnamed.hpp b/tests/headers/const_enum_unnamed.hpp
index bdd9700f..cee87e64 100644
--- a/tests/headers/const_enum_unnamed.hpp
+++ b/tests/headers/const_enum_unnamed.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum {
FOO_BAR,
diff --git a/tests/headers/constant-evaluate.h b/tests/headers/constant-evaluate.h
index ee9cfaa5..812553ed 100644
--- a/tests/headers/constant-evaluate.h
+++ b/tests/headers/constant-evaluate.h
@@ -1,5 +1,5 @@
// bindgen-unstable
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum {
foo = 4,
@@ -10,6 +10,7 @@ typedef unsigned long long EasyToOverflow;
const EasyToOverflow k = 0x80000000;
const EasyToOverflow k_expr = 1ULL << 60;
+const EasyToOverflow wow = 1ULL << 31;
const long long BAZ = (1 << foo) | bar;
const double fuzz = (1 + 50.0f);
diff --git a/tests/headers/constify-enum.h b/tests/headers/constify-enum.h
index 9a9058d3..b8e0be3e 100644
--- a/tests/headers/constify-enum.h
+++ b/tests/headers/constify-enum.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum nsCSSPropertyID {
eCSSProperty_a,
diff --git a/tests/headers/constify-module-enums-types.hpp b/tests/headers/constify-module-enums-types.hpp
index 2c652499..decf935a 100644
--- a/tests/headers/constify-module-enums-types.hpp
+++ b/tests/headers/constify-module-enums-types.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --constified-enum-module .*
+// bindgen-flags: --constified-enum-module ".*"
typedef enum foo {
THIS,
@@ -75,4 +75,4 @@ class Thing {
};
foo func3(Thing<foo> arg1);
-foo func4(Thing< Thing<foo> > arg1); \ No newline at end of file
+foo func4(Thing< Thing<foo> > arg1);
diff --git a/tests/headers/default-enum-style-constified-module.h b/tests/headers/default-enum-style-constified-module.h
new file mode 100644
index 00000000..a5ba6531
--- /dev/null
+++ b/tests/headers/default-enum-style-constified-module.h
@@ -0,0 +1,4 @@
+// bindgen-flags: --default-enum-style moduleconsts
+
+typedef enum { bar, baz, blap } Foo;
+void func(Foo x);
diff --git a/tests/headers/derive-debug-bitfield-core.hpp b/tests/headers/derive-debug-bitfield-core.hpp
new file mode 100644
index 00000000..5d78e743
--- /dev/null
+++ b/tests/headers/derive-debug-bitfield-core.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --impl-debug --use-core --raw-line "extern crate core;"
+
+class C {
+ bool a: 1;
+ bool b: 7;
+ int large_array[50];
+};
diff --git a/tests/headers/dupe-enum-variant-in-namespace.h b/tests/headers/dupe-enum-variant-in-namespace.h
new file mode 100644
index 00000000..2b6fb93a
--- /dev/null
+++ b/tests/headers/dupe-enum-variant-in-namespace.h
@@ -0,0 +1,10 @@
+// bindgen-flags: --rustified-enum ".*" --enable-cxx-namespaces -- -x c++ -std=c++11
+
+namespace foo {
+ enum class Bar : unsigned {
+ Foo = 0,
+ Foo1 = 0,
+ Foo2,
+ Foo3 = Foo2,
+ };
+}
diff --git a/tests/headers/enum.h b/tests/headers/enum.h
index 38ce4eee..f04c213e 100644
--- a/tests/headers/enum.h
+++ b/tests/headers/enum.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum Foo {
Bar = 0,
diff --git a/tests/headers/enum_alias.hpp b/tests/headers/enum_alias.hpp
index c3ecc351..8ddb25c3 100644
--- a/tests/headers/enum_alias.hpp
+++ b/tests/headers/enum_alias.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++11
+// bindgen-flags: --rustified-enum ".*" -- -std=c++11
typedef unsigned char uint8_t;
diff --git a/tests/headers/enum_and_vtable_mangling.hpp b/tests/headers/enum_and_vtable_mangling.hpp
index e332fc57..659a8bd1 100644
--- a/tests/headers/enum_and_vtable_mangling.hpp
+++ b/tests/headers/enum_and_vtable_mangling.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum {
match,
diff --git a/tests/headers/enum_dupe.h b/tests/headers/enum_dupe.h
index 826568fb..b8d9689a 100644
--- a/tests/headers/enum_dupe.h
+++ b/tests/headers/enum_dupe.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum Foo {
Bar = 1,
diff --git a/tests/headers/enum_explicit_type.hpp b/tests/headers/enum_explicit_type.hpp
index 3cb93138..d9713471 100644
--- a/tests/headers/enum_explicit_type.hpp
+++ b/tests/headers/enum_explicit_type.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++11
+// bindgen-flags: --rustified-enum ".*" -- -std=c++11
enum Foo: unsigned char {
Bar = 0,
diff --git a/tests/headers/enum_in_template_with_typedef.hpp b/tests/headers/enum_in_template_with_typedef.hpp
index 244d916c..87290ece 100644
--- a/tests/headers/enum_in_template_with_typedef.hpp
+++ b/tests/headers/enum_in_template_with_typedef.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++11
+// bindgen-flags: --rustified-enum ".*" -- -std=c++11
namespace std {
template <typename Char> class fbstring_core;
diff --git a/tests/headers/enum_negative.h b/tests/headers/enum_negative.h
index 267f799f..0fa0df97 100644
--- a/tests/headers/enum_negative.h
+++ b/tests/headers/enum_negative.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum Foo {
Bar = -2,
diff --git a/tests/headers/enum_packed.h b/tests/headers/enum_packed.h
index 1c89b992..cc70c816 100644
--- a/tests/headers/enum_packed.h
+++ b/tests/headers/enum_packed.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
enum __attribute__((packed)) Foo {
Bar = 0,
diff --git a/tests/headers/extern-const-struct.h b/tests/headers/extern-const-struct.h
new file mode 100644
index 00000000..10006e82
--- /dev/null
+++ b/tests/headers/extern-const-struct.h
@@ -0,0 +1,5 @@
+struct nsFoo {
+ float details[400];
+};
+
+extern const struct nsFoo gDetails;
diff --git a/tests/headers/forward-enum-decl.hpp b/tests/headers/forward-enum-decl.hpp
index a3df8584..81a0eee7 100644
--- a/tests/headers/forward-enum-decl.hpp
+++ b/tests/headers/forward-enum-decl.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++11
+// bindgen-flags: --rustified-enum ".*" -- -std=c++11
enum class CSSPseudoClassType : int;
diff --git a/tests/headers/func_ptr_in_struct.h b/tests/headers/func_ptr_in_struct.h
index dd608549..ef075df7 100644
--- a/tests/headers/func_ptr_in_struct.h
+++ b/tests/headers/func_ptr_in_struct.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
//
enum baz;
diff --git a/tests/headers/i128.h b/tests/headers/i128.h
new file mode 100644
index 00000000..6ec399c7
--- /dev/null
+++ b/tests/headers/i128.h
@@ -0,0 +1,6 @@
+// bindgen-flags: --rust-target 1.26
+
+struct foo {
+ __int128 my_signed;
+ unsigned __int128 my_unsigned;
+};
diff --git a/tests/headers/issue-1350-attribute-overloadable.h b/tests/headers/issue-1350-attribute-overloadable.h
new file mode 100644
index 00000000..4b0ec2a6
--- /dev/null
+++ b/tests/headers/issue-1350-attribute-overloadable.h
@@ -0,0 +1,2 @@
+void my_function(int a) __attribute__((overloadable));
+void my_function(const char *a) __attribute__((overloadable));
diff --git a/tests/headers/issue-1435.hpp b/tests/headers/issue-1435.hpp
new file mode 100644
index 00000000..fbf3c507
--- /dev/null
+++ b/tests/headers/issue-1435.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --enable-cxx-namespaces
+
+namespace ns {
+enum class AB { A, B };
+}
+using AB = ns::AB;
+static const AB kA = AB::A;
diff --git a/tests/headers/issue-372.hpp b/tests/headers/issue-372.hpp
index de144776..7127be2c 100644
--- a/tests/headers/issue-372.hpp
+++ b/tests/headers/issue-372.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --rustified-enum .*
+// bindgen-flags: --enable-cxx-namespaces --rustified-enum ".*"
template <typename a, int b> class c { a e[b]; };
class d;
template <typename g, g f> class C { c<d, f> h; };
diff --git a/tests/headers/issue-410.hpp b/tests/headers/issue-410.hpp
index c91c83d1..b5d502f3 100644
--- a/tests/headers/issue-410.hpp
+++ b/tests/headers/issue-410.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --whitelist-type JS::Value --rustified-enum .*
+// bindgen-flags: --enable-cxx-namespaces --whitelist-type JS::Value --rustified-enum ".*"
namespace JS {
class Value;
diff --git a/tests/headers/issue-493.hpp b/tests/headers/issue-493.hpp
index 280b8736..8b122ceb 100644
--- a/tests/headers/issue-493.hpp
+++ b/tests/headers/issue-493.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
template<class _CharT, class _Traits, class _Allocator>
class basic_string
{
diff --git a/tests/headers/issue-493_1_0.hpp b/tests/headers/issue-493_1_0.hpp
index 7406d893..af6fd47c 100644
--- a/tests/headers/issue-493_1_0.hpp
+++ b/tests/headers/issue-493_1_0.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
template<class _CharT, class _Traits, class _Allocator>
class basic_string
diff --git a/tests/headers/issue-569-non-type-template-params-causing-layout-test-failures.hpp b/tests/headers/issue-569-non-type-template-params-causing-layout-test-failures.hpp
index 964b69cb..297d1112 100644
--- a/tests/headers/issue-569-non-type-template-params-causing-layout-test-failures.hpp
+++ b/tests/headers/issue-569-non-type-template-params-causing-layout-test-failures.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++14
+// bindgen-flags: --rustified-enum ".*" -- -std=c++14
// Generated by C-Reduce, cleaned up and given names for readability.
diff --git a/tests/headers/issue-674-1.hpp b/tests/headers/issue-674-1.hpp
index f5c05917..aa3c6118 100644
--- a/tests/headers/issue-674-1.hpp
+++ b/tests/headers/issue-674-1.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --whitelist-type CapturingContentInfo --opaque-type 'mozilla::Maybe' -- -- -std=c++14
+// bindgen-flags: --enable-cxx-namespaces --whitelist-type CapturingContentInfo --opaque-type 'mozilla::Maybe' -- -std=c++14
namespace mozilla {
template <class T> class Maybe { using ValueType = T; };
diff --git a/tests/headers/issue-674-2.hpp b/tests/headers/issue-674-2.hpp
index 5f65a05b..58abcae2 100644
--- a/tests/headers/issue-674-2.hpp
+++ b/tests/headers/issue-674-2.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --whitelist-type StaticRefPtr --opaque-type 'JS::Rooted' -- -- -std=c++14
+// bindgen-flags: --enable-cxx-namespaces --whitelist-type StaticRefPtr --opaque-type 'JS::Rooted' -- -std=c++14
namespace JS {
template <typename T> class Rooted { using ElementType = T; };
diff --git a/tests/headers/issue-674-3.hpp b/tests/headers/issue-674-3.hpp
index c1bd2f32..2794c192 100644
--- a/tests/headers/issue-674-3.hpp
+++ b/tests/headers/issue-674-3.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --whitelist-type nsCSSValue --opaque-type 'nsRefPtrHashtable' -- -- -std=c++14
+// bindgen-flags: --enable-cxx-namespaces --whitelist-type nsCSSValue --opaque-type 'nsRefPtrHashtable' -- -std=c++14
template <class PtrType> class nsRefPtrHashtable {
typedef PtrType *UserDataType;
diff --git a/tests/headers/issue-888-enum-var-decl-jump.hpp b/tests/headers/issue-888-enum-var-decl-jump.hpp
index d7182c3c..fa4ba56b 100644
--- a/tests/headers/issue-888-enum-var-decl-jump.hpp
+++ b/tests/headers/issue-888-enum-var-decl-jump.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --enable-cxx-namespaces --rustified-enum .*
+// bindgen-flags: --enable-cxx-namespaces --rustified-enum ".*"
namespace Halide {
struct Type;
diff --git a/tests/headers/jsval_layout_opaque.hpp b/tests/headers/jsval_layout_opaque.hpp
index 7a1957cf..ef13b85b 100644
--- a/tests/headers/jsval_layout_opaque.hpp
+++ b/tests/headers/jsval_layout_opaque.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
// bindgen-flags: -- -std=c++11
/**
diff --git a/tests/headers/jsval_layout_opaque_1_0.hpp b/tests/headers/jsval_layout_opaque_1_0.hpp
index dcf6274d..c8e66551 100644
--- a/tests/headers/jsval_layout_opaque_1_0.hpp
+++ b/tests/headers/jsval_layout_opaque_1_0.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
// bindgen-flags: -- -std=c++11
/**
diff --git a/tests/headers/layout_array_too_long.h b/tests/headers/layout_array_too_long.h
index 1d8b1b63..d0d34ba0 100644
--- a/tests/headers/layout_array_too_long.h
+++ b/tests/headers/layout_array_too_long.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --impl-partialeq --rustified-enum ".*"
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
diff --git a/tests/headers/layout_cmdline_token.h b/tests/headers/layout_cmdline_token.h
index 68dd53b8..da1bfc2e 100644
--- a/tests/headers/layout_cmdline_token.h
+++ b/tests/headers/layout_cmdline_token.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
/**
* Stores a pointer to the ops struct, and the offset: the place to
@@ -61,4 +61,4 @@ struct cmdline_token_num {
struct cmdline_token_hdr hdr;
struct cmdline_token_num_data num_data;
};
-typedef struct cmdline_token_num cmdline_parse_token_num_t; \ No newline at end of file
+typedef struct cmdline_token_num cmdline_parse_token_num_t;
diff --git a/tests/headers/layout_eth_conf.h b/tests/headers/layout_eth_conf.h
index 71a430bf..93ab8408 100644
--- a/tests/headers/layout_eth_conf.h
+++ b/tests/headers/layout_eth_conf.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
diff --git a/tests/headers/layout_eth_conf_1_0.h b/tests/headers/layout_eth_conf_1_0.h
index cf6fa6ad..48ba39ff 100644
--- a/tests/headers/layout_eth_conf_1_0.h
+++ b/tests/headers/layout_eth_conf_1_0.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --rust-target 1.0 --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
diff --git a/tests/headers/layout_large_align_field.h b/tests/headers/layout_large_align_field.h
index 5e87c2a1..f292bb70 100644
--- a/tests/headers/layout_large_align_field.h
+++ b/tests/headers/layout_large_align_field.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
diff --git a/tests/headers/long_double.h b/tests/headers/long_double.h
new file mode 100644
index 00000000..91c4ed6c
--- /dev/null
+++ b/tests/headers/long_double.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --rust-target 1.26
+
+struct foo {
+ long double bar;
+};
diff --git a/tests/headers/macro_const.h b/tests/headers/macro_const.h
index c28a3f6b..7c5aa438 100644
--- a/tests/headers/macro_const.h
+++ b/tests/headers/macro_const.h
@@ -3,5 +3,6 @@
#define CHARR '\0'
#define FLOAT 5.09f
#define FLOAT_EXPR (5 / 1000.0f)
+#define LONG 3L
#define INVALID_UTF8 "\xf0\x28\x8c\x28"
diff --git a/tests/headers/no-recursive-whitelisting.h b/tests/headers/no-recursive-whitelisting.h
index 8eb8afea..c94cc491 100644
--- a/tests/headers/no-recursive-whitelisting.h
+++ b/tests/headers/no-recursive-whitelisting.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --no-recursive-whitelist --whitelist-type "Foo" --raw-line "pub enum Bar {}" --rustified-enum .*
+// bindgen-flags: --no-recursive-whitelist --whitelist-type "Foo" --raw-line "pub enum Bar {}" --rustified-enum ".*"
struct Bar;
diff --git a/tests/headers/no-std.h b/tests/headers/no-std.h
index 9248cc3d..d98abced 100644
--- a/tests/headers/no-std.h
+++ b/tests/headers/no-std.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --ctypes-prefix "libc" --use-core --raw-line "#![no_std]" --raw-line "mod libc { pub type c_int = i32; pub enum c_void {} }" --rustified-enum .*
+// bindgen-flags: --ctypes-prefix "libc" --use-core --raw-line "#![no_std]" --raw-line "mod libc { pub type c_int = i32; pub enum c_void {} }" --rustified-enum ".*"
struct foo {
int a, b;
void* bar;
diff --git a/tests/headers/nsStyleAutoArray.hpp b/tests/headers/nsStyleAutoArray.hpp
index 2a0bc216..3049ea21 100644
--- a/tests/headers/nsStyleAutoArray.hpp
+++ b/tests/headers/nsStyleAutoArray.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
template<typename T>
class nsTArray {
diff --git a/tests/headers/opaque-tracing.hpp b/tests/headers/opaque-tracing.hpp
index 326ebbe7..9f7319cc 100644
--- a/tests/headers/opaque-tracing.hpp
+++ b/tests/headers/opaque-tracing.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --opaque-type=.* --whitelist-function=foo --with-derive-hash --with-derive-partialeq --with-derive-eq
+// bindgen-flags: --opaque-type ".*" --whitelist-function=foo --with-derive-hash --with-derive-partialeq --with-derive-eq
class Container;
diff --git a/tests/headers/ord-enum.h b/tests/headers/ord-enum.h
new file mode 100644
index 00000000..364f711e
--- /dev/null
+++ b/tests/headers/ord-enum.h
@@ -0,0 +1,15 @@
+// bindgen-flags: --rustified-enum * --with-derive-ord
+
+enum A {
+ A0 = 0,
+ A1 = 1,
+ A2 = 2,
+ A3 = A0 - 1,
+};
+
+enum B {
+ B0 = 1,
+ B1 = B0 + 3,
+ B2 = B0 + 2,
+ B3 = B0 - 2,
+}; \ No newline at end of file
diff --git a/tests/headers/overflowed_enum.hpp b/tests/headers/overflowed_enum.hpp
index 53a05ddf..18d3fe41 100644
--- a/tests/headers/overflowed_enum.hpp
+++ b/tests/headers/overflowed_enum.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++11 -Wno-narrowing
+// bindgen-flags: --rustified-enum ".*" -- -std=c++11 -Wno-narrowing
enum Foo {
BAP_ARM = 0x93fcb9,
diff --git a/tests/headers/prepend-enum-constified-variant.h b/tests/headers/prepend-enum-constified-variant.h
index 06ae264f..e9ba0e73 100644
--- a/tests/headers/prepend-enum-constified-variant.h
+++ b/tests/headers/prepend-enum-constified-variant.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --no-prepend-enum-name --rustified-enum .*
+// bindgen-flags: --no-prepend-enum-name --rustified-enum ".*"
enum AVCodecID {
AV_CODEC_ID_FIRST_UNKNOWN = 0x18000,
diff --git a/tests/headers/short-enums.hpp b/tests/headers/short-enums.hpp
index 0b517d6f..14f833de 100644
--- a/tests/headers/short-enums.hpp
+++ b/tests/headers/short-enums.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .* -- -std=c++11 -fshort-enums
+// bindgen-flags: --rustified-enum ".*" -- -std=c++11 -fshort-enums
typedef enum {
SOME_VALUE = 0x1,
diff --git a/tests/headers/struct_typedef.h b/tests/headers/struct_typedef.h
index e996b28f..2ed7aabd 100644
--- a/tests/headers/struct_typedef.h
+++ b/tests/headers/struct_typedef.h
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --rustified-enum ".*"
//
typedef struct {
_Bool has_name;
diff --git a/tests/headers/struct_typedef_ns.hpp b/tests/headers/struct_typedef_ns.hpp
index a5a8f9a6..40a7c680 100644
--- a/tests/headers/struct_typedef_ns.hpp
+++ b/tests/headers/struct_typedef_ns.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --enable-cxx-namespaces --rustified-enum .*
+// bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq --enable-cxx-namespaces --rustified-enum ".*"
namespace whatever {
typedef struct {
diff --git a/tests/headers/transform-op.hpp b/tests/headers/transform-op.hpp
new file mode 100644
index 00000000..aa6118eb
--- /dev/null
+++ b/tests/headers/transform-op.hpp
@@ -0,0 +1,75 @@
+// bindgen-flags: --rust-target 1.0 -- -std=c++11
+
+typedef unsigned char uint8_t;
+typedef int int32_t;
+
+template<typename T>
+struct StylePoint {
+ T x;
+ T y;
+};
+
+template<typename T>
+union StyleFoo {
+ enum class Tag : uint8_t {
+ Foo,
+ Bar,
+ Baz,
+ Bazz,
+ };
+
+ struct Foo_Body {
+ Tag tag;
+ int32_t x;
+ StylePoint<T> y;
+ StylePoint<float> z;
+ };
+
+ struct Bar_Body {
+ Tag tag;
+ T _0;
+ };
+
+ struct Baz_Body {
+ Tag tag;
+ StylePoint<T> _0;
+ };
+
+ struct {
+ Tag tag;
+ };
+ Foo_Body foo;
+ Bar_Body bar;
+ Baz_Body baz;
+};
+
+template<typename T>
+struct StyleBar {
+ enum class Tag {
+ Bar1,
+ Bar2,
+ Bar3,
+ Bar4,
+ };
+
+ struct StyleBar1_Body {
+ int32_t x;
+ StylePoint<T> y;
+ StylePoint<float> z;
+ };
+
+ struct StyleBar2_Body {
+ T _0;
+ };
+
+ struct StyleBar3_Body {
+ StylePoint<T> _0;
+ };
+
+ Tag tag;
+ union {
+ StyleBar1_Body bar1;
+ StyleBar2_Body bar2;
+ StyleBar3_Body bar3;
+ };
+};
diff --git a/tests/headers/union-align.h b/tests/headers/union-align.h
new file mode 100644
index 00000000..94e60ef1
--- /dev/null
+++ b/tests/headers/union-align.h
@@ -0,0 +1,5 @@
+// bindgen-flags: --rust-target 1.26
+
+union Bar {
+ unsigned char foo;
+} __attribute__ ((__aligned__ (16)));
diff --git a/tests/headers/vector.hpp b/tests/headers/vector.hpp
index 4707f77f..173aa022 100644
--- a/tests/headers/vector.hpp
+++ b/tests/headers/vector.hpp
@@ -1,3 +1,9 @@
struct foo {
__attribute__((__vector_size__(1 * sizeof(long long)))) long long mMember;
};
+
+typedef float __m128 __attribute__ ((__vector_size__ (16)));
+typedef double __m128d __attribute__((__vector_size__(16)));
+typedef long long __m128i __attribute__((__vector_size__(16)));
+
+__m128 foo(__m128i, __m128d);
diff --git a/tests/headers/weird_bitfields.hpp b/tests/headers/weird_bitfields.hpp
index 7236d60a..b2761a80 100644
--- a/tests/headers/weird_bitfields.hpp
+++ b/tests/headers/weird_bitfields.hpp
@@ -1,4 +1,4 @@
-// bindgen-flags: --rustified-enum .*
+// bindgen-flags: --rustified-enum ".*"
// You can guess where this is taken from...
enum nsStyleSVGOpacitySource {
diff --git a/tests/quickchecking/src/fuzzers.rs b/tests/quickchecking/src/fuzzers.rs
index 2876da86..7c764425 100644
--- a/tests/quickchecking/src/fuzzers.rs
+++ b/tests/quickchecking/src/fuzzers.rs
@@ -196,7 +196,7 @@ impl Arbitrary for DeclarationC {
/// Enables to string and format for DeclarationC types.
impl fmt::Display for DeclarationC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
DeclarationC::FunctionPtrDecl(ref d) => write!(f, "{}", d),
DeclarationC::StructDecl(ref d) => write!(f, "{}", d),
@@ -219,7 +219,7 @@ impl Arbitrary for DeclarationListC {
/// Enables to string and format for DeclarationListC types.
impl fmt::Display for DeclarationListC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut display = String::new();
for decl in &self.decls {
display += &format!("{}", decl);
@@ -274,7 +274,7 @@ impl Arbitrary for BaseTypeC {
/// Enables to string and format for BaseTypeC types,
impl fmt::Display for BaseTypeC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.def)
}
}
@@ -292,7 +292,7 @@ impl Arbitrary for TypeQualifierC {
/// Enables to string and format for TypeQualifierC types.
impl fmt::Display for TypeQualifierC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.def)
}
}
@@ -310,7 +310,7 @@ impl Arbitrary for PointerLevelC {
/// Enables to string and format for PointerLevelC types.
impl fmt::Display for PointerLevelC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.def)
}
}
@@ -340,7 +340,7 @@ impl Arbitrary for ArrayDimensionC {
/// Enables to string and format for ArrayDimensionC types.
impl fmt::Display for ArrayDimensionC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.def)
}
}
@@ -369,7 +369,7 @@ impl Arbitrary for BasicTypeDeclarationC {
/// Enables to string and format for BasicTypeDeclarationC types.
impl fmt::Display for BasicTypeDeclarationC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{} {} {} ident_{}{};",
@@ -421,7 +421,7 @@ impl Arbitrary for StructDeclarationC {
/// Enables to string and format for StructDeclarationC types.
impl fmt::Display for StructDeclarationC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"struct {{ {} }} struct_{}{};",
@@ -471,7 +471,7 @@ impl Arbitrary for UnionDeclarationC {
/// Enables to string and format for UnionDeclarationC types.
impl fmt::Display for UnionDeclarationC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"union {{ {} }} union_{}{};",
@@ -506,7 +506,7 @@ impl Arbitrary for FunctionPointerDeclarationC {
/// Enables to string and format for FunctionPointerDeclarationC types.
impl fmt::Display for FunctionPointerDeclarationC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{} {} {} (*func_ptr_{})({});",
@@ -543,7 +543,7 @@ impl Arbitrary for FunctionPrototypeC {
/// Enables to string and format for FunctionPrototypeC types.
impl fmt::Display for FunctionPrototypeC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{} {} {} func_{}({});",
@@ -570,7 +570,7 @@ impl Arbitrary for ParameterC {
/// Enables to string and format for ParameterC types.
impl fmt::Display for ParameterC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{} {} {}",
@@ -593,7 +593,7 @@ impl Arbitrary for ParameterListC {
/// Enables to string and format for ParameterListC types.
impl fmt::Display for ParameterListC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut display = String::new();
for (i, p) in self.params.iter().enumerate() {
match i {
@@ -619,7 +619,7 @@ impl Arbitrary for HeaderC {
/// Enables to string and format for HeaderC types.
impl fmt::Display for HeaderC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut display = String::new();
for decl in &self.def.decls {
display += &format!("{}", decl);
@@ -631,7 +631,7 @@ impl fmt::Display for HeaderC {
/// Use Display trait for Debug so that any failing property tests report
/// generated C code rather than the data structures that contain it.
impl fmt::Debug for HeaderC {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
}
}