diff --git a/Cargo.lock b/Cargo.lock index 29d849688d..a1bfb8c27f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,6 +91,21 @@ dependencies = [ "syn", ] +[[package]] +name = "bindgen-tests" +version = "0.1.0" +dependencies = [ + "autocxx-bindgen", + "owo-colors", + "prettyplease", + "proc-macro2", + "regex", + "shlex", + "similar", + "syn", + "tempfile", +] + [[package]] name = "bitflags" version = "2.6.0" @@ -184,6 +199,34 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi", + "windows-targets", +] + [[package]] name = "glob" version = "0.3.1" @@ -227,6 +270,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "log" version = "0.4.22" @@ -255,6 +304,18 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "owo-colors" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" + [[package]] name = "prettyplease" version = "0.2.25" @@ -318,12 +379,31 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + [[package]] name = "strsim" version = "0.11.1" @@ -341,6 +421,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +dependencies = [ + "cfg-if", + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys", +] + [[package]] name = "unicode-ident" version = "1.0.14" @@ -359,6 +453,15 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "windows-sys" version = "0.59.0" @@ -431,3 +534,12 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] diff --git a/Cargo.toml b/Cargo.toml index b447d1237b..4ee16257cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "bindgen", #"bindgen-cli", #"bindgen-integration", - #"bindgen-tests", + "bindgen-tests", #"bindgen-tests/tests/quickchecking", #"bindgen-tests/tests/expectations", ] @@ -22,7 +22,7 @@ edition = "2021" # All dependency version management is centralized here [workspace.dependencies] annotate-snippets = "0.11.4" -bindgen = { version = "0.71.1", path = "./bindgen", default-features = false } +autocxx-bindgen = { version = "0.71.1", path = "./bindgen", default-features = false } bitflags = "2.2.1" block = "0.1" cc = "1.0" diff --git a/bindgen-tests/Cargo.toml b/bindgen-tests/Cargo.toml index 77a28ca3cb..43fc507b39 100644 --- a/bindgen-tests/Cargo.toml +++ b/bindgen-tests/Cargo.toml @@ -8,7 +8,7 @@ rust-version.workspace = true edition.workspace = true [dev-dependencies] -bindgen = { workspace = true, default-features = true, features = ["__cli", "experimental"] } +autocxx-bindgen = { workspace = true, default-features = true, features = ["__cli", "experimental"] } owo-colors.workspace = true prettyplease = { workspace = true, features = ["verbatim"] } proc-macro2.workspace = true @@ -19,10 +19,10 @@ syn.workspace = true tempfile.workspace = true [features] -logging = ["bindgen/logging"] -static = ["bindgen/static"] -runtime = ["bindgen/runtime"] +logging = ["autocxx-bindgen/logging"] +static = ["autocxx-bindgen/static"] +runtime = ["autocxx-bindgen/runtime"] -__testing_only_extra_assertions = ["bindgen/__testing_only_extra_assertions"] -__testing_only_libclang_9 = ["bindgen/__testing_only_libclang_9"] -__testing_only_libclang_16 = ["bindgen/__testing_only_libclang_16"] +__testing_only_extra_assertions = ["autocxx-bindgen/__testing_only_extra_assertions"] +__testing_only_libclang_9 = ["autocxx-bindgen/__testing_only_libclang_9"] +__testing_only_libclang_16 = ["autocxx-bindgen/__testing_only_libclang_16"] diff --git a/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs b/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs index 24d88ea14b..ed893c21df 100644 --- a/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs +++ b/bindgen-tests/tests/expectations/tests/381-decltype-alias.rs @@ -1,9 +1,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("allocator_traits")] pub struct std_allocator_traits { pub _address: u8, } -#[bindgen_original_name("allocator_traits::__size_type")] pub type std_allocator_traits___size_type<_Alloc> = _Alloc; diff --git a/bindgen-tests/tests/expectations/tests/allowlist_basic.rs b/bindgen-tests/tests/expectations/tests/allowlist_basic.rs index b61bac5d86..a1c6919739 100644 --- a/bindgen-tests/tests/expectations/tests/allowlist_basic.rs +++ b/bindgen-tests/tests/expectations/tests/allowlist_basic.rs @@ -8,7 +8,6 @@ pub struct AllowlistMe { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("AllowlistMe::Inner")] pub struct AllowlistMe_Inner { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub bar: T, diff --git a/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs b/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs index d836c83629..cfd4d03200 100644 --- a/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs +++ b/bindgen-tests/tests/expectations/tests/anon_enum_trait.rs @@ -4,13 +4,9 @@ pub struct DataType { pub _address: u8, } -#[bindgen_original_name("DataType::value_type")] pub type DataType_value_type<_Tp> = _Tp; -#[bindgen_original_name("DataType::work_type")] pub type DataType_work_type<_Tp> = DataType_value_type<_Tp>; -#[bindgen_original_name("DataType::channel_type")] pub type DataType_channel_type<_Tp> = DataType_value_type<_Tp>; -#[bindgen_original_name("DataType::vec_type")] pub type DataType_vec_type<_Tp> = DataType_value_type<_Tp>; pub const DataType_generic_type: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; pub const DataType_depth: DataType__bindgen_ty_1 = DataType__bindgen_ty_1::generic_type; diff --git a/bindgen-tests/tests/expectations/tests/anon_union.rs b/bindgen-tests/tests/expectations/tests/anon_union.rs index e1201a59f6..d9bf3cf183 100644 --- a/bindgen-tests/tests/expectations/tests/anon_union.rs +++ b/bindgen-tests/tests/expectations/tests/anon_union.rs @@ -10,20 +10,17 @@ impl TErrorResult_UnionState { pub const HasException: TErrorResult_UnionState = TErrorResult_UnionState::HasMessage; } #[repr(i32)] -#[bindgen_original_name("TErrorResult::UnionState")] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum TErrorResult_UnionState { HasMessage = 0, } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("TErrorResult::Message")] pub struct TErrorResult_Message { _unused: [u8; 0], } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("TErrorResult::DOMExceptionInfo")] pub struct TErrorResult_DOMExceptionInfo { _unused: [u8; 0], } diff --git a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs index 8019074a67..07eb7a80f6 100644 --- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs +++ b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result.rs @@ -11,7 +11,6 @@ fn bindgen_test_layout_Foo() { } extern "C" { #[must_use] - #[bindgen_original_name("foo")] #[link_name = "\u{1}_ZN3Foo3fooEi"] pub fn Foo_foo(this: *mut Foo, arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int; } diff --git a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs index f547795d4e..aa01540b0e 100644 --- a/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs +++ b/bindgen-tests/tests/expectations/tests/attribute_warn_unused_result_no_attribute_detection.rs @@ -10,7 +10,6 @@ fn bindgen_test_layout_Foo() { assert_eq!(::std::mem::align_of::(), 1usize, "Alignment of Foo"); } extern "C" { - #[bindgen_original_name("foo")] #[link_name = "\u{1}_ZN3Foo3fooEi"] pub fn Foo_foo(this: *mut Foo, arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int; } diff --git a/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs b/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs index 4e583fa17c..9ad8429e3c 100644 --- a/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs +++ b/bindgen-tests/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("char_traits")] pub struct std_char_traits { pub _address: u8, } @@ -16,7 +15,6 @@ impl Default for std_char_traits { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("char_traits")] pub struct __gnu_cxx_char_traits { pub _address: u8, } diff --git a/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs b/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs index bfaa7a2534..25cc182929 100644 --- a/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs +++ b/bindgen-tests/tests/expectations/tests/bitfield-method-same-name.rs @@ -153,17 +153,14 @@ const _: () = { ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("type")] #[link_name = "\u{1}_ZN3Foo4typeEv"] pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_char; } unsafe extern "C" { - #[bindgen_original_name("set_type_")] #[link_name = "\u{1}_ZN3Foo9set_type_Ec"] pub fn Foo_set_type_(this: *mut Foo, c: ::std::os::raw::c_char); } unsafe extern "C" { - #[bindgen_original_name("set_type")] #[link_name = "\u{1}_ZN3Foo8set_typeEc"] pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char); } diff --git a/bindgen-tests/tests/expectations/tests/builtin-template.rs b/bindgen-tests/tests/expectations/tests/builtin-template.rs index 92cb0a6e6e..53e3fbf9bf 100644 --- a/bindgen-tests/tests/expectations/tests/builtin-template.rs +++ b/bindgen-tests/tests/expectations/tests/builtin-template.rs @@ -1,3 +1,2 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[bindgen_original_name("make_integer_sequence")] pub type std_make_integer_sequence = u8; diff --git a/bindgen-tests/tests/expectations/tests/call-conv-typedef.rs b/bindgen-tests/tests/expectations/tests/call-conv-typedef.rs index 83a66c77a6..c62756f364 100644 --- a/bindgen-tests/tests/expectations/tests/call-conv-typedef.rs +++ b/bindgen-tests/tests/expectations/tests/call-conv-typedef.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #![cfg(not(test))] pub type void_fn = ::std::option::Option; -#[bindgen_original_name("fn")] pub type fn_ = ::std::option::Option< unsafe extern "stdcall" fn(id: ::std::os::raw::c_int) -> void_fn, >; diff --git a/bindgen-tests/tests/expectations/tests/class_nested.rs b/bindgen-tests/tests/expectations/tests/class_nested.rs index 20f17bf2e4..080f5968bc 100644 --- a/bindgen-tests/tests/expectations/tests/class_nested.rs +++ b/bindgen-tests/tests/expectations/tests/class_nested.rs @@ -6,7 +6,6 @@ pub struct A { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("A::B")] pub struct A_B { pub member_b: ::std::os::raw::c_int, } @@ -18,7 +17,6 @@ const _: () = { }; #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("A::D")] pub struct A_D { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub foo: T, @@ -40,7 +38,6 @@ const _: () = { }; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("A::C")] pub struct A_C { pub baz: ::std::os::raw::c_int, } @@ -84,7 +81,6 @@ pub struct Templated { } #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("Templated::Templated_inner")] pub struct Templated_Templated_inner { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub member_ptr: *mut T, diff --git a/bindgen-tests/tests/expectations/tests/class_with_enum.rs b/bindgen-tests/tests/expectations/tests/class_with_enum.rs index 7da777c193..ca1806357c 100644 --- a/bindgen-tests/tests/expectations/tests/class_with_enum.rs +++ b/bindgen-tests/tests/expectations/tests/class_with_enum.rs @@ -1,10 +1,4 @@ -#![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)] pub struct A { @@ -12,18 +6,9 @@ pub struct A { } pub const A_B_B1: A_B = 0; pub const A_B_B2: A_B = 1; -#[bindgen_original_name("A::B")] pub type A_B = ::std::os::raw::c_uint; -#[test] -fn bindgen_test_layout_A() { - assert_eq!( - ::std::mem::size_of::(), - 1usize, - concat!("Size of: ", stringify!(A)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(A)) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of A"][::std::mem::size_of::() - 1usize]; + ["Alignment of A"][::std::mem::align_of::() - 1usize]; +}; diff --git a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs index 419228ee94..73f2b55cc3 100644 --- a/bindgen-tests/tests/expectations/tests/class_with_typedef.rs +++ b/bindgen-tests/tests/expectations/tests/class_with_typedef.rs @@ -9,9 +9,7 @@ pub struct C { pub d: AnotherInt, pub other_ptr: *mut AnotherInt, } -#[bindgen_original_name("C::MyInt")] pub type C_MyInt = ::std::os::raw::c_int; -#[bindgen_original_name("C::Lookup")] pub type C_Lookup = *const ::std::os::raw::c_char; #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { @@ -24,24 +22,18 @@ const _: () = { ["Offset of field: C::other_ptr"][::std::mem::offset_of!(C, other_ptr) - 64usize]; }; unsafe extern "C" { - #[bindgen_original_name("method")] #[link_name = "\u{1}_ZN1C6methodEi"] pub fn C_method(this: *mut C, c: C_MyInt); } unsafe extern "C" { - #[bindgen_arg_type_reference(c)] - #[bindgen_original_name("methodRef")] #[link_name = "\u{1}_ZN1C9methodRefERi"] pub fn C_methodRef(this: *mut C, c: *mut C_MyInt); } unsafe extern "C" { - #[bindgen_arg_type_reference(c)] - #[bindgen_original_name("complexMethodRef")] #[link_name = "\u{1}_ZN1C16complexMethodRefERPKc"] pub fn C_complexMethodRef(this: *mut C, c: *mut C_Lookup); } unsafe extern "C" { - #[bindgen_original_name("anotherMethod")] #[link_name = "\u{1}_ZN1C13anotherMethodEi"] pub fn C_anotherMethod(this: *mut C, c: AnotherInt); } @@ -59,12 +51,10 @@ impl C { pub unsafe fn method(&mut self, c: C_MyInt) { C_method(self, c) } - #[bindgen_arg_type_reference(c)] #[inline] pub unsafe fn methodRef(&mut self, c: *mut C_MyInt) { C_methodRef(self, c) } - #[bindgen_arg_type_reference(c)] #[inline] pub unsafe fn complexMethodRef(&mut self, c: *mut C_Lookup) { C_complexMethodRef(self, c) diff --git a/bindgen-tests/tests/expectations/tests/comment-indent.rs b/bindgen-tests/tests/expectations/tests/comment-indent.rs index 6c777617ad..72b167d00c 100644 --- a/bindgen-tests/tests/expectations/tests/comment-indent.rs +++ b/bindgen-tests/tests/expectations/tests/comment-indent.rs @@ -16,7 +16,6 @@ pub mod root { This class is not so interesting, but worth a bit of docs too!*/ #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("Foo::Bar")] pub struct Foo_Bar { pub _address: u8, } diff --git a/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs b/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs index ae7200a730..968ec350aa 100644 --- a/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs +++ b/bindgen-tests/tests/expectations/tests/constant-non-specialized-tp.rs @@ -11,7 +11,6 @@ pub struct Outer { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("Outer::Inner")] pub struct Outer_Inner { pub _address: u8, } diff --git a/bindgen-tests/tests/expectations/tests/constructor-tp.rs b/bindgen-tests/tests/expectations/tests/constructor-tp.rs index c84e169e8a..2585311d29 100644 --- a/bindgen-tests/tests/expectations/tests/constructor-tp.rs +++ b/bindgen-tests/tests/expectations/tests/constructor-tp.rs @@ -15,8 +15,6 @@ const _: () = { ["Alignment of Bar"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("Bar")] - #[bindgen_special_member("default_ctor")] #[link_name = "\u{1}_ZN3BarC1Ev"] pub fn Bar_Bar(this: *mut Bar); } diff --git a/bindgen-tests/tests/expectations/tests/constructors.rs b/bindgen-tests/tests/expectations/tests/constructors.rs index 3b686ccd4f..45c29e61e5 100644 --- a/bindgen-tests/tests/expectations/tests/constructors.rs +++ b/bindgen-tests/tests/expectations/tests/constructors.rs @@ -10,7 +10,6 @@ const _: () = { ["Alignment of TestOverload"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("TestOverload")] #[link_name = "\u{1}_ZN12TestOverloadC1Ei"] pub fn TestOverload_TestOverload( this: *mut TestOverload, @@ -18,7 +17,6 @@ unsafe extern "C" { ); } unsafe extern "C" { - #[bindgen_original_name("TestOverload")] #[link_name = "\u{1}_ZN12TestOverloadC1Ed"] pub fn TestOverload_TestOverload1(this: *mut TestOverload, arg1: f64); } @@ -49,8 +47,6 @@ const _: () = { ][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("TestPublicNoArgs")] - #[bindgen_special_member("default_ctor")] #[link_name = "\u{1}_ZN16TestPublicNoArgsC1Ev"] pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs); } diff --git a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs index 9ba2899246..0563b4e65d 100644 --- a/bindgen-tests/tests/expectations/tests/constructors_1_33.rs +++ b/bindgen-tests/tests/expectations/tests/constructors_1_33.rs @@ -15,7 +15,6 @@ fn bindgen_test_layout_TestOverload() { } extern "C" { /// Calling this should use `mem::unintialized()` and not `MaybeUninit()` as only rust 1.36 includes that. - #[bindgen_original_name("TestOverload")] #[link_name = "\u{1}_ZN12TestOverloadC1Ei"] pub fn TestOverload_TestOverload( this: *mut TestOverload, @@ -24,7 +23,6 @@ extern "C" { } extern "C" { /// Calling this should use `mem::unintialized()` and not `MaybeUninit()` as only rust 1.36 includes that. - #[bindgen_original_name("TestOverload")] #[link_name = "\u{1}_ZN12TestOverloadC1Ed"] pub fn TestOverload_TestOverload1(this: *mut TestOverload, arg1: f64); } @@ -61,8 +59,6 @@ fn bindgen_test_layout_TestPublicNoArgs() { ); } extern "C" { - #[bindgen_original_name("TestPublicNoArgs")] - #[bindgen_special_member("default_ctor")] #[link_name = "\u{1}_ZN16TestPublicNoArgsC1Ev"] pub fn TestPublicNoArgs_TestPublicNoArgs(this: *mut TestPublicNoArgs); } diff --git a/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs b/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs index d6a77453d2..05e66a72bc 100644 --- a/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs +++ b/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs @@ -111,17 +111,14 @@ fn bindgen_test_layout_Foo() { ); } extern "C" { - #[bindgen_original_name("type")] #[link_name = "\u{1}_ZN3Foo4typeEv"] pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_char; } extern "C" { - #[bindgen_original_name("set_type_")] #[link_name = "\u{1}_ZN3Foo9set_type_Ec"] pub fn Foo_set_type_(this: *mut Foo, c: ::std::os::raw::c_char); } extern "C" { - #[bindgen_original_name("set_type")] #[link_name = "\u{1}_ZN3Foo8set_typeEc"] pub fn Foo_set_type(this: *mut Foo, c: ::std::os::raw::c_char); } diff --git a/bindgen-tests/tests/expectations/tests/derive-debug-function-pointer.rs b/bindgen-tests/tests/expectations/tests/derive-debug-function-pointer.rs index bca4935abe..9fe1f5518c 100644 --- a/bindgen-tests/tests/expectations/tests/derive-debug-function-pointer.rs +++ b/bindgen-tests/tests/expectations/tests/derive-debug-function-pointer.rs @@ -5,7 +5,6 @@ pub struct Nice { pub pointer: Nice_Function, pub large_array: [::std::os::raw::c_int; 34usize], } -#[bindgen_original_name("Nice::Function")] pub type Nice_Function = ::std::option::Option< unsafe extern "C" fn(data: ::std::os::raw::c_int), >; diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs index 134104bc7f..b214d0ef4e 100644 --- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs +++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs @@ -11,17 +11,14 @@ const _: () = { ["Offset of field: X::_x"][::std::mem::offset_of!(X, _x) - 0usize]; }; unsafe extern "C" { - #[bindgen_original_name("some_function")] #[link_name = "\u{1}_ZN1X13some_functionEv"] pub fn X_some_function(this: *mut X); } unsafe extern "C" { - #[bindgen_original_name("some_other_function")] #[link_name = "\u{1}_ZN1X19some_other_functionEv"] pub fn X_some_other_function(this: *mut X); } unsafe extern "C" { - #[bindgen_original_name("X")] #[link_name = "\u{1}_ZN1XC1Ei"] pub fn X_X(this: *mut X, x: ::std::os::raw::c_int); } diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs index 38db7ff59e..6395b0c6d3 100644 --- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs +++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs @@ -11,17 +11,14 @@ const _: () = { ["Offset of field: A::_x"][::std::mem::offset_of!(A, _x) - 0usize]; }; unsafe extern "C" { - #[bindgen_original_name("some_function")] #[link_name = "\u{1}_ZN1A13some_functionEv"] pub fn A_some_function(this: *mut A); } unsafe extern "C" { - #[bindgen_original_name("some_other_function")] #[link_name = "\u{1}_ZN1A19some_other_functionEv"] pub fn A_some_other_function(this: *mut A); } unsafe extern "C" { - #[bindgen_original_name("A")] #[link_name = "\u{1}_ZN1AC1Ei"] pub fn A_A(this: *mut A, x: ::std::os::raw::c_int); } diff --git a/bindgen-tests/tests/expectations/tests/elaborated.rs b/bindgen-tests/tests/expectations/tests/elaborated.rs index 672f6c1364..81c0733089 100644 --- a/bindgen-tests/tests/expectations/tests/elaborated.rs +++ b/bindgen-tests/tests/expectations/tests/elaborated.rs @@ -1,4 +1,4 @@ -#[bindgen_original_name("whatever_t")] +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] pub type whatever_whatever_t = ::std::os::raw::c_int; unsafe extern "C" { #[link_name = "\u{1}_Z9somethingPKi"] diff --git a/bindgen-tests/tests/expectations/tests/enum_and_vtable_mangling.rs b/bindgen-tests/tests/expectations/tests/enum_and_vtable_mangling.rs index 5a05d095f9..0a7e16d6dd 100644 --- a/bindgen-tests/tests/expectations/tests/enum_and_vtable_mangling.rs +++ b/bindgen-tests/tests/expectations/tests/enum_and_vtable_mangling.rs @@ -33,7 +33,6 @@ impl Default for C { } } unsafe extern "C" { - #[bindgen_original_name("match")] #[link_name = "\u{1}_ZN1C5matchEv"] pub fn C_match(this: *mut ::std::os::raw::c_void); } diff --git a/bindgen-tests/tests/expectations/tests/enum_in_template.rs b/bindgen-tests/tests/expectations/tests/enum_in_template.rs index 813975a9a0..e54a97b5f4 100644 --- a/bindgen-tests/tests/expectations/tests/enum_in_template.rs +++ b/bindgen-tests/tests/expectations/tests/enum_in_template.rs @@ -6,5 +6,4 @@ pub struct Foo { } pub const Foo_Bar_A: Foo_Bar = 0; pub const Foo_Bar_B: Foo_Bar = 0; -#[bindgen_original_name("Foo::Bar")] pub type Foo_Bar = i32; diff --git a/bindgen-tests/tests/expectations/tests/enum_in_template_with_typedef.rs b/bindgen-tests/tests/expectations/tests/enum_in_template_with_typedef.rs index 40a9d106f1..b71923e10f 100644 --- a/bindgen-tests/tests/expectations/tests/enum_in_template_with_typedef.rs +++ b/bindgen-tests/tests/expectations/tests/enum_in_template_with_typedef.rs @@ -1,17 +1,14 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("fbstring_core")] pub struct std_fbstring_core { pub _address: u8, } -#[bindgen_original_name("fbstring_core::category_type")] pub type std_fbstring_core_category_type = u8; impl std_fbstring_core_Category { pub const Bar: std_fbstring_core_Category = std_fbstring_core_Category::Foo; } #[repr(u8)] -#[bindgen_original_name("fbstring_core::Category")] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum std_fbstring_core_Category { Foo = 0, diff --git a/bindgen-tests/tests/expectations/tests/eval-value-dependent.rs b/bindgen-tests/tests/expectations/tests/eval-value-dependent.rs index 976202e1b1..b9b2709cfa 100644 --- a/bindgen-tests/tests/expectations/tests/eval-value-dependent.rs +++ b/bindgen-tests/tests/expectations/tests/eval-value-dependent.rs @@ -4,5 +4,4 @@ pub struct e { pub _address: u8, } -#[bindgen_original_name("e::f")] pub type e_f = d; diff --git a/bindgen-tests/tests/expectations/tests/forward-inherit-struct-with-fields.rs b/bindgen-tests/tests/expectations/tests/forward-inherit-struct-with-fields.rs index eca8d86456..069c76fead 100644 --- a/bindgen-tests/tests/expectations/tests/forward-inherit-struct-with-fields.rs +++ b/bindgen-tests/tests/expectations/tests/forward-inherit-struct-with-fields.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("RootedBase")] pub struct js_RootedBase { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub foo: *mut T, diff --git a/bindgen-tests/tests/expectations/tests/forward-inherit-struct.rs b/bindgen-tests/tests/expectations/tests/forward-inherit-struct.rs index aa86ed2336..52888c4626 100644 --- a/bindgen-tests/tests/expectations/tests/forward-inherit-struct.rs +++ b/bindgen-tests/tests/expectations/tests/forward-inherit-struct.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("RootedBase")] pub struct js_RootedBase { pub _address: u8, } diff --git a/bindgen-tests/tests/expectations/tests/gen-constructors.rs b/bindgen-tests/tests/expectations/tests/gen-constructors.rs index 75376b7a52..80e6a25d70 100644 --- a/bindgen-tests/tests/expectations/tests/gen-constructors.rs +++ b/bindgen-tests/tests/expectations/tests/gen-constructors.rs @@ -10,7 +10,6 @@ const _: () = { ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("Foo")] #[link_name = "\u{1}_ZN3FooC1Ei"] pub fn Foo_Foo(this: *mut Foo, a: ::std::os::raw::c_int); } diff --git a/bindgen-tests/tests/expectations/tests/gen-destructors.rs b/bindgen-tests/tests/expectations/tests/gen-destructors.rs index 92c788ae85..c860c9985f 100644 --- a/bindgen-tests/tests/expectations/tests/gen-destructors.rs +++ b/bindgen-tests/tests/expectations/tests/gen-destructors.rs @@ -11,8 +11,6 @@ const _: () = { ["Offset of field: Foo::bar"][::std::mem::offset_of!(Foo, bar) - 0usize]; }; unsafe extern "C" { - #[bindgen_original_name("Foo_destructor")] - #[bindgen_special_member("dtor")] #[link_name = "\u{1}_ZN3FooD1Ev"] pub fn Foo_Foo_destructor(this: *mut Foo); } diff --git a/bindgen-tests/tests/expectations/tests/generate-inline.rs b/bindgen-tests/tests/expectations/tests/generate-inline.rs index 08afc26ce3..c100f3936c 100644 --- a/bindgen-tests/tests/expectations/tests/generate-inline.rs +++ b/bindgen-tests/tests/expectations/tests/generate-inline.rs @@ -10,7 +10,6 @@ const _: () = { ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("bar")] #[link_name = "\u{1}_ZN3Foo3barEv"] pub fn Foo_bar() -> ::std::os::raw::c_int; } diff --git a/bindgen-tests/tests/expectations/tests/in_class_typedef.rs b/bindgen-tests/tests/expectations/tests/in_class_typedef.rs index 967cd6bb22..ccb73520d7 100644 --- a/bindgen-tests/tests/expectations/tests/in_class_typedef.rs +++ b/bindgen-tests/tests/expectations/tests/in_class_typedef.rs @@ -4,13 +4,10 @@ pub struct Foo { pub _address: u8, } -#[bindgen_original_name("Foo::elem_type")] pub type Foo_elem_type = T; -#[bindgen_original_name("Foo::ptr_type")] pub type Foo_ptr_type = *mut T; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("Foo::Bar")] pub struct Foo_Bar { pub x: ::std::os::raw::c_int, pub y: ::std::os::raw::c_int, diff --git a/bindgen-tests/tests/expectations/tests/inherit-namespaced.rs b/bindgen-tests/tests/expectations/tests/inherit-namespaced.rs index aa86ed2336..52888c4626 100644 --- a/bindgen-tests/tests/expectations/tests/inherit-namespaced.rs +++ b/bindgen-tests/tests/expectations/tests/inherit-namespaced.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("RootedBase")] pub struct js_RootedBase { pub _address: u8, } diff --git a/bindgen-tests/tests/expectations/tests/inline_namespace_no_ns_enabled.rs b/bindgen-tests/tests/expectations/tests/inline_namespace_no_ns_enabled.rs index fa3e3718a9..66359bd51b 100644 --- a/bindgen-tests/tests/expectations/tests/inline_namespace_no_ns_enabled.rs +++ b/bindgen-tests/tests/expectations/tests/inline_namespace_no_ns_enabled.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug)] -#[bindgen_original_name("basic_string")] pub struct std_basic_string { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub hider: std_basic_string_Alloc_hider, @@ -10,7 +9,6 @@ pub struct std_basic_string { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("basic_string::Alloc_hider")] pub struct std_basic_string_Alloc_hider { pub storage: *mut ::std::os::raw::c_void, } diff --git a/bindgen-tests/tests/expectations/tests/issue-1113-template-references.rs b/bindgen-tests/tests/expectations/tests/issue-1113-template-references.rs index a61916f3c8..c0e76d8047 100644 --- a/bindgen-tests/tests/expectations/tests/issue-1113-template-references.rs +++ b/bindgen-tests/tests/expectations/tests/issue-1113-template-references.rs @@ -21,11 +21,9 @@ impl Default for Entry { pub struct nsBaseHashtable { pub _address: u8, } -#[bindgen_original_name("nsBaseHashtable::EntryType")] pub type nsBaseHashtable_EntryType = Entry; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("nsBaseHashtable::EntryPtr")] pub struct nsBaseHashtable_EntryPtr { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs b/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs index 0a63f036bf..7df1cdb741 100644 --- a/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs +++ b/bindgen-tests/tests/expectations/tests/issue-1118-using-forward-decl.rs @@ -1,5 +1,4 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[bindgen_unused_template_param] pub type c = nsTArray; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -60,7 +59,6 @@ impl Default for nsIContent { } } unsafe extern "C" { - #[bindgen_unused_template_param_in_arg_or_return] #[link_name = "\u{1}_Z35Gecko_GetAnonymousContentForElementv"] pub fn Gecko_GetAnonymousContentForElement() -> *mut nsTArray; } diff --git a/bindgen-tests/tests/expectations/tests/issue-1197-pure-virtual-stuff.rs b/bindgen-tests/tests/expectations/tests/issue-1197-pure-virtual-stuff.rs index 0d258fadc8..10c769c38c 100644 --- a/bindgen-tests/tests/expectations/tests/issue-1197-pure-virtual-stuff.rs +++ b/bindgen-tests/tests/expectations/tests/issue-1197-pure-virtual-stuff.rs @@ -20,16 +20,3 @@ impl Default for Foo { } } } -extern "C" { - #[bindgen_pure_virtual] - #[bindgen_original_name("Bar")] - #[link_name = "\u{1}_ZN3Foo3BarEv"] - pub fn Foo_Bar(this: *mut ::std::os::raw::c_void); -} -extern "C" { - #[bindgen_pure_virtual] - #[bindgen_original_name("Foo_destructor")] - #[bindgen_special_member("dtor")] - #[link_name = "\u{1}_ZN3FooD1Ev"] - pub fn Foo_Foo_destructor(this: *mut Foo); -} diff --git a/bindgen-tests/tests/expectations/tests/issue-1350-attribute-overloadable.rs b/bindgen-tests/tests/expectations/tests/issue-1350-attribute-overloadable.rs index a317d6ae21..c033570793 100644 --- a/bindgen-tests/tests/expectations/tests/issue-1350-attribute-overloadable.rs +++ b/bindgen-tests/tests/expectations/tests/issue-1350-attribute-overloadable.rs @@ -4,7 +4,6 @@ unsafe extern "C" { pub fn my_function(a: ::std::os::raw::c_int); } unsafe extern "C" { - #[bindgen_original_name("my_function")] #[link_name = "\u{1}_Z11my_functionPKc"] pub fn my_function1(a: *const ::std::os::raw::c_char); } diff --git a/bindgen-tests/tests/expectations/tests/issue-1514.rs b/bindgen-tests/tests/expectations/tests/issue-1514.rs index 38e483b955..aef63037ae 100644 --- a/bindgen-tests/tests/expectations/tests/issue-1514.rs +++ b/bindgen-tests/tests/expectations/tests/issue-1514.rs @@ -6,7 +6,6 @@ pub struct Thing { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("Thing::Inner")] pub struct Thing_Inner { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub ptr: *mut T, @@ -22,7 +21,6 @@ impl Default for Thing_Inner { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("Thing::AnotherInner")] pub struct Thing_AnotherInner { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _base: Thing_Inner, diff --git a/bindgen-tests/tests/expectations/tests/issue-2019.rs b/bindgen-tests/tests/expectations/tests/issue-2019.rs index 90c9c6634a..4c91cf9972 100644 --- a/bindgen-tests/tests/expectations/tests/issue-2019.rs +++ b/bindgen-tests/tests/expectations/tests/issue-2019.rs @@ -32,7 +32,6 @@ const _: () = { ["Offset of field: B::b"][::std::mem::offset_of!(B, b) - 0usize]; }; unsafe extern "C" { - #[bindgen_original_name("make")] #[link_name = "\u{1}_ZN1B4makeEv"] pub fn make1() -> B; } diff --git a/bindgen-tests/tests/expectations/tests/issue-358.rs b/bindgen-tests/tests/expectations/tests/issue-358.rs index b73885bbcd..ff915e9fba 100644 --- a/bindgen-tests/tests/expectations/tests/issue-358.rs +++ b/bindgen-tests/tests/expectations/tests/issue-358.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("PersistentRooted")] pub struct JS_PersistentRooted { pub _base: a, } diff --git a/bindgen-tests/tests/expectations/tests/issue-410.rs b/bindgen-tests/tests/expectations/tests/issue-410.rs index 8423668dc2..cda9b6e338 100644 --- a/bindgen-tests/tests/expectations/tests/issue-410.rs +++ b/bindgen-tests/tests/expectations/tests/issue-410.rs @@ -17,7 +17,6 @@ pub mod root { ["Alignment of Value"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("a")] #[link_name = "\u{1}_ZN2JS5Value1aE10JSWhyMagic"] pub fn Value_a(this: *mut root::JS::Value, arg1: root::JSWhyMagic); } diff --git a/bindgen-tests/tests/expectations/tests/issue-447.rs b/bindgen-tests/tests/expectations/tests/issue-447.rs index 8723262d48..8867a359a2 100644 --- a/bindgen-tests/tests/expectations/tests/issue-447.rs +++ b/bindgen-tests/tests/expectations/tests/issue-447.rs @@ -40,7 +40,6 @@ pub mod root { ][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("JSAutoCompartment")] #[link_name = "\u{1}_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"] pub fn JSAutoCompartment_JSAutoCompartment( this: *mut root::JSAutoCompartment, diff --git a/bindgen-tests/tests/expectations/tests/issue-493.rs b/bindgen-tests/tests/expectations/tests/issue-493.rs index ef55a41836..d2e4ea5375 100644 --- a/bindgen-tests/tests/expectations/tests/issue-493.rs +++ b/bindgen-tests/tests/expectations/tests/issue-493.rs @@ -47,15 +47,11 @@ impl ::std::cmp::Eq for __BindgenUnionField {} pub struct basic_string { pub _address: u8, } -#[bindgen_original_name("basic_string::size_type")] pub type basic_string_size_type = ::std::os::raw::c_ulonglong; -#[bindgen_original_name("basic_string::value_type")] pub type basic_string_value_type = ::std::os::raw::c_char; -#[bindgen_original_name("basic_string::pointer")] pub type basic_string_pointer = *mut basic_string_value_type; #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("basic_string::__long")] pub struct basic_string___long { pub __cap_: basic_string_size_type, pub __size_: basic_string_size_type, @@ -77,7 +73,6 @@ pub enum basic_string__bindgen_ty_1 { __min_cap = 0, } #[repr(C)] -#[bindgen_original_name("basic_string::__short")] pub struct basic_string___short { pub __bindgen_anon_1: basic_string___short__bindgen_ty_1, pub __data_: *mut basic_string_value_type, @@ -107,7 +102,6 @@ impl Default for basic_string___short { } #[repr(C)] #[repr(align(1))] -#[bindgen_original_name("basic_string::__ulx")] pub struct basic_string___ulx { pub __lx: __BindgenUnionField, pub __lxx: __BindgenUnionField, @@ -130,7 +124,6 @@ pub enum basic_string__bindgen_ty_2 { } #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("basic_string::__raw")] pub struct basic_string___raw { pub __words: *mut basic_string_size_type, } @@ -144,7 +137,6 @@ impl Default for basic_string___raw { } } #[repr(C)] -#[bindgen_original_name("basic_string::__rep")] pub struct basic_string___rep { pub __bindgen_anon_1: basic_string___rep__bindgen_ty_1, } diff --git a/bindgen-tests/tests/expectations/tests/issue-544-stylo-creduce-2.rs b/bindgen-tests/tests/expectations/tests/issue-544-stylo-creduce-2.rs index 7c608a4f39..8a752f6999 100644 --- a/bindgen-tests/tests/expectations/tests/issue-544-stylo-creduce-2.rs +++ b/bindgen-tests/tests/expectations/tests/issue-544-stylo-creduce-2.rs @@ -14,9 +14,7 @@ impl Default for __BindgenOpaqueArray { pub struct Foo { pub member: *mut Foo_SecondAlias, } -#[bindgen_original_name("Foo::FirstAlias")] pub type Foo_FirstAlias = __BindgenOpaqueArray; -#[bindgen_original_name("Foo::SecondAlias")] pub type Foo_SecondAlias = Foo; impl Default for Foo { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs b/bindgen-tests/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs index 68941b8c43..567325b82d 100644 --- a/bindgen-tests/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs +++ b/bindgen-tests/tests/expectations/tests/issue-569-non-type-template-params-causing-layout-test-failures.rs @@ -7,11 +7,9 @@ pub enum _bindgen_ty_1 { ENUM_VARIANT_1 = 0, ENUM_VARIANT_2 = 1, } -#[bindgen_original_name("Alias")] pub type JS_Alias = u8; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("Base")] pub struct JS_Base { pub f: JS_Alias, } @@ -26,7 +24,6 @@ impl Default for JS_Base { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("AutoIdVector")] pub struct JS_AutoIdVector { pub _base: JS_Base, } diff --git a/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs b/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs index 8026e3b964..2a85837e3d 100644 --- a/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs +++ b/bindgen-tests/tests/expectations/tests/issue-584-stylo-template-analysis-panic.rs @@ -5,7 +5,6 @@ pub type RefPtr = T; pub struct A { pub _address: u8, } -#[bindgen_original_name("A::a")] pub type A_a = b; #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { diff --git a/bindgen-tests/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs b/bindgen-tests/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs index b8a7333fad..db94687737 100644 --- a/bindgen-tests/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs +++ b/bindgen-tests/tests/expectations/tests/issue-638-stylo-cannot-find-T-in-this-scope.rs @@ -20,7 +20,6 @@ pub struct UsesRefPtrWithAliasedTypeParam { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub member: RefPtr>, } -#[bindgen_original_name("UsesRefPtrWithAliasedTypeParam::V")] pub type UsesRefPtrWithAliasedTypeParam_V = U; impl Default for UsesRefPtrWithAliasedTypeParam { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/issue-639-typedef-anon-field.rs b/bindgen-tests/tests/expectations/tests/issue-639-typedef-anon-field.rs index 6e2eebd1a1..e940db1103 100644 --- a/bindgen-tests/tests/expectations/tests/issue-639-typedef-anon-field.rs +++ b/bindgen-tests/tests/expectations/tests/issue-639-typedef-anon-field.rs @@ -6,7 +6,6 @@ pub struct Foo { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("Foo::Bar")] pub struct Foo_Bar { pub abc: ::std::os::raw::c_int, } @@ -29,7 +28,6 @@ pub struct Baz { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("Baz::Bar")] pub struct Baz_Bar { pub abc: ::std::os::raw::c_int, } diff --git a/bindgen-tests/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs b/bindgen-tests/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs index 52cb00d660..82e2ab4c42 100644 --- a/bindgen-tests/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs +++ b/bindgen-tests/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs @@ -6,7 +6,6 @@ pub struct HasRefPtr { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub refptr_member: RefPtr>, } -#[bindgen_original_name("HasRefPtr::TypedefOfT")] pub type HasRefPtr_TypedefOfT = T; impl Default for HasRefPtr { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/issue-674-1.rs b/bindgen-tests/tests/expectations/tests/issue-674-1.rs index 3dc5323bd2..1a3dce44d0 100644 --- a/bindgen-tests/tests/expectations/tests/issue-674-1.rs +++ b/bindgen-tests/tests/expectations/tests/issue-674-1.rs @@ -11,7 +11,6 @@ pub mod root { pub struct Maybe { pub _address: u8, } - #[bindgen_original_name("Maybe::ValueType")] pub type Maybe_ValueType = T; } #[repr(C)] diff --git a/bindgen-tests/tests/expectations/tests/issue-674-2.rs b/bindgen-tests/tests/expectations/tests/issue-674-2.rs index 56be11ad5a..980928fe97 100644 --- a/bindgen-tests/tests/expectations/tests/issue-674-2.rs +++ b/bindgen-tests/tests/expectations/tests/issue-674-2.rs @@ -11,7 +11,6 @@ pub mod root { pub struct Rooted { pub _address: u8, } - #[bindgen_original_name("Rooted::ElementType")] pub type Rooted_ElementType = T; } #[repr(C)] diff --git a/bindgen-tests/tests/expectations/tests/issue-674-3.rs b/bindgen-tests/tests/expectations/tests/issue-674-3.rs index d89d7574cc..4e2f26a46f 100644 --- a/bindgen-tests/tests/expectations/tests/issue-674-3.rs +++ b/bindgen-tests/tests/expectations/tests/issue-674-3.rs @@ -8,7 +8,6 @@ pub mod root { pub struct nsRefPtrHashtable { pub _address: u8, } - #[bindgen_original_name("nsRefPtrHashtable::UserDataType")] pub type nsRefPtrHashtable_UserDataType = *mut PtrType; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] diff --git a/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs b/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs index 0a7d579bf8..3d3ee5e590 100644 --- a/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs +++ b/bindgen-tests/tests/expectations/tests/issue-807-opaque-types-methods-being-generated.rs @@ -41,12 +41,10 @@ const _: () = { ["Alignment of Opaque"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("eleven_out_of_ten")] #[link_name = "\u{1}_ZN6Opaque17eleven_out_of_tenEv"] pub fn Opaque_eleven_out_of_ten(this: *mut Opaque) -> SuchWow; } unsafe extern "C" { - #[bindgen_original_name("Opaque")] #[link_name = "\u{1}_ZN6OpaqueC1E6Pupper"] pub fn Opaque_Opaque(this: *mut Opaque, pup: Pupper); } diff --git a/bindgen-tests/tests/expectations/tests/issue-820-unused-template-param-in-alias.rs b/bindgen-tests/tests/expectations/tests/issue-820-unused-template-param-in-alias.rs index 370a18dbcc..a367e2e0e1 100644 --- a/bindgen-tests/tests/expectations/tests/issue-820-unused-template-param-in-alias.rs +++ b/bindgen-tests/tests/expectations/tests/issue-820-unused-template-param-in-alias.rs @@ -1,3 +1,2 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[bindgen_original_name("Foo::self_type")] pub type Foo_self_type = u8; diff --git a/bindgen-tests/tests/expectations/tests/issue-833-1.rs b/bindgen-tests/tests/expectations/tests/issue-833-1.rs index fdc882919a..5aa8c3078b 100644 --- a/bindgen-tests/tests/expectations/tests/issue-833-1.rs +++ b/bindgen-tests/tests/expectations/tests/issue-833-1.rs @@ -4,6 +4,5 @@ pub struct nsTArray { pub hdr: *const (), } unsafe extern "C" { - #[bindgen_unused_template_param_in_arg_or_return] pub fn func() -> *mut nsTArray; } diff --git a/bindgen-tests/tests/expectations/tests/maddness-is-avoidable.rs b/bindgen-tests/tests/expectations/tests/maddness-is-avoidable.rs index 46d2dbf3b0..0876aeb904 100644 --- a/bindgen-tests/tests/expectations/tests/maddness-is-avoidable.rs +++ b/bindgen-tests/tests/expectations/tests/maddness-is-avoidable.rs @@ -6,7 +6,6 @@ pub struct RefPtr { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("RefPtr::Proxy")] pub struct RefPtr_Proxy { pub _address: u8, } diff --git a/bindgen-tests/tests/expectations/tests/method-mangling.rs b/bindgen-tests/tests/expectations/tests/method-mangling.rs index f4bbb5b788..4c86825cce 100644 --- a/bindgen-tests/tests/expectations/tests/method-mangling.rs +++ b/bindgen-tests/tests/expectations/tests/method-mangling.rs @@ -10,7 +10,6 @@ const _: () = { ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("type")] #[link_name = "\u{1}_ZN3Foo4typeEv"] pub fn Foo_type(this: *mut Foo) -> ::std::os::raw::c_int; } diff --git a/bindgen-tests/tests/expectations/tests/nested.rs b/bindgen-tests/tests/expectations/tests/nested.rs index c53f324f92..5e0a8b07c8 100644 --- a/bindgen-tests/tests/expectations/tests/nested.rs +++ b/bindgen-tests/tests/expectations/tests/nested.rs @@ -17,14 +17,12 @@ pub struct Test { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("Test::Size")] pub struct Test_Size { pub mWidth: Test_Size_Dimension, pub mHeight: Test_Size_Dimension, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("Test::Size::Dimension")] pub struct Test_Size_Dimension { pub _base: Calc, } diff --git a/bindgen-tests/tests/expectations/tests/nested_vtable.rs b/bindgen-tests/tests/expectations/tests/nested_vtable.rs index 69581a08e9..12aa2ea441 100644 --- a/bindgen-tests/tests/expectations/tests/nested_vtable.rs +++ b/bindgen-tests/tests/expectations/tests/nested_vtable.rs @@ -25,7 +25,6 @@ impl Default for nsISupports { } } unsafe extern "C" { - #[bindgen_original_name("QueryInterface")] #[link_name = "\u{1}_ZN11nsISupports14QueryInterfaceEv"] pub fn nsISupports_QueryInterface( this: *mut ::std::os::raw::c_void, diff --git a/bindgen-tests/tests/expectations/tests/nested_within_namespace.rs b/bindgen-tests/tests/expectations/tests/nested_within_namespace.rs index d1c152242f..f470571ddc 100644 --- a/bindgen-tests/tests/expectations/tests/nested_within_namespace.rs +++ b/bindgen-tests/tests/expectations/tests/nested_within_namespace.rs @@ -13,7 +13,6 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("Bar::Baz")] pub struct Bar_Baz { pub foo: ::std::os::raw::c_int, } diff --git a/bindgen-tests/tests/expectations/tests/nsBaseHashtable.rs b/bindgen-tests/tests/expectations/tests/nsBaseHashtable.rs index c28407f31d..32fcc37aba 100644 --- a/bindgen-tests/tests/expectations/tests/nsBaseHashtable.rs +++ b/bindgen-tests/tests/expectations/tests/nsBaseHashtable.rs @@ -24,14 +24,10 @@ pub struct nsTHashtable { pub struct nsBaseHashtable { pub _address: u8, } -#[bindgen_original_name("nsBaseHashtable::KeyType")] pub type nsBaseHashtable_KeyType = __BindgenOpaqueArray; -#[bindgen_unused_template_param] -#[bindgen_original_name("nsBaseHashtable::EntryType")] pub type nsBaseHashtable_EntryType = nsBaseHashtableET; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("nsBaseHashtable::LookupResult")] pub struct nsBaseHashtable_LookupResult { pub mEntry: *mut nsBaseHashtable_EntryType, pub mTable: *mut nsBaseHashtable, @@ -47,7 +43,6 @@ impl Default for nsBaseHashtable_LookupResult { } #[repr(C)] #[derive(Debug)] -#[bindgen_original_name("nsBaseHashtable::EntryPtr")] pub struct nsBaseHashtable_EntryPtr { pub mEntry: *mut nsBaseHashtable_EntryType, pub mExistingEntry: bool, diff --git a/bindgen-tests/tests/expectations/tests/nsStyleAutoArray.rs b/bindgen-tests/tests/expectations/tests/nsStyleAutoArray.rs index c288574b75..3d8edcfdc1 100644 --- a/bindgen-tests/tests/expectations/tests/nsStyleAutoArray.rs +++ b/bindgen-tests/tests/expectations/tests/nsStyleAutoArray.rs @@ -22,7 +22,6 @@ pub struct nsStyleAutoArray { pub mOtherElements: nsTArray, } #[repr(i32)] -#[bindgen_original_name("nsStyleAutoArray::WithSingleInitialElement")] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum nsStyleAutoArray_WithSingleInitialElement { WITH_SINGLE_INITIAL_ELEMENT = 0, diff --git a/bindgen-tests/tests/expectations/tests/opaque_typedef.rs b/bindgen-tests/tests/expectations/tests/opaque_typedef.rs index 468ce09af4..90c3b709e3 100644 --- a/bindgen-tests/tests/expectations/tests/opaque_typedef.rs +++ b/bindgen-tests/tests/expectations/tests/opaque_typedef.rs @@ -6,5 +6,4 @@ pub struct RandomTemplate { } ///
pub type ShouldBeOpaque = u8; -#[bindgen_unused_template_param] pub type ShouldNotBeOpaque = RandomTemplate; diff --git a/bindgen-tests/tests/expectations/tests/overloading.rs b/bindgen-tests/tests/expectations/tests/overloading.rs index ced4021f05..96504b38eb 100644 --- a/bindgen-tests/tests/expectations/tests/overloading.rs +++ b/bindgen-tests/tests/expectations/tests/overloading.rs @@ -4,17 +4,14 @@ unsafe extern "C" { pub fn Evaluate(r: ::std::os::raw::c_char) -> bool; } unsafe extern "C" { - #[bindgen_original_name("Evaluate")] #[link_name = "\u{1}_Z8Evaluateii"] pub fn Evaluate1(x: ::std::os::raw::c_int, y: ::std::os::raw::c_int) -> bool; } unsafe extern "C" { - #[bindgen_original_name("MyFunction")] #[link_name = "\u{1}_ZN3foo10MyFunctionEv"] pub fn foo_MyFunction(); } unsafe extern "C" { - #[bindgen_original_name("MyFunction")] #[link_name = "\u{1}_ZN3bar10MyFunctionEv"] pub fn bar_MyFunction(); } diff --git a/bindgen-tests/tests/expectations/tests/packed-vtable.rs b/bindgen-tests/tests/expectations/tests/packed-vtable.rs index 0dce68cf1f..362017a233 100644 --- a/bindgen-tests/tests/expectations/tests/packed-vtable.rs +++ b/bindgen-tests/tests/expectations/tests/packed-vtable.rs @@ -25,8 +25,6 @@ impl Default for PackedVtable { } } extern "C" { - #[bindgen_original_name("PackedVtable_destructor")] - #[bindgen_special_member("dtor")] #[link_name = "\u{1}_ZN12PackedVtableD1Ev"] pub fn PackedVtable_PackedVtable_destructor(this: *mut PackedVtable); } diff --git a/bindgen-tests/tests/expectations/tests/public-dtor.rs b/bindgen-tests/tests/expectations/tests/public-dtor.rs index 3e1c55f619..578d3e76a5 100644 --- a/bindgen-tests/tests/expectations/tests/public-dtor.rs +++ b/bindgen-tests/tests/expectations/tests/public-dtor.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default)] -#[bindgen_original_name("Foo")] pub struct cv_Foo { pub _address: u8, } @@ -11,8 +10,6 @@ const _: () = { ["Alignment of cv_Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("Foo_destructor")] - #[bindgen_special_member("dtor")] #[link_name = "\u{1}_ZN2cv3FooD1Ev"] pub fn cv_Foo_Foo_destructor(this: *mut cv_Foo); } diff --git a/bindgen-tests/tests/expectations/tests/ref_argument_array.rs b/bindgen-tests/tests/expectations/tests/ref_argument_array.rs index 1693a9f686..4928a185fe 100644 --- a/bindgen-tests/tests/expectations/tests/ref_argument_array.rs +++ b/bindgen-tests/tests/expectations/tests/ref_argument_array.rs @@ -27,8 +27,6 @@ impl Default for nsID { } } unsafe extern "C" { - #[bindgen_arg_type_reference(aDest)] - #[bindgen_original_name("ToProvidedString")] #[link_name = "\u{1}_ZN4nsID16ToProvidedStringERA10_c"] pub fn nsID_ToProvidedString( this: *mut ::std::os::raw::c_void, diff --git a/bindgen-tests/tests/expectations/tests/replace_template_alias.rs b/bindgen-tests/tests/expectations/tests/replace_template_alias.rs index cb60d68660..2efa164ddf 100644 --- a/bindgen-tests/tests/expectations/tests/replace_template_alias.rs +++ b/bindgen-tests/tests/expectations/tests/replace_template_alias.rs @@ -2,11 +2,9 @@ /** But the replacement type does use T!
*/ -#[bindgen_original_name("MaybeWrapped")] pub type JS_detail_MaybeWrapped = T; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("Rooted")] pub struct JS_Rooted { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub ptr: JS_detail_MaybeWrapped, diff --git a/bindgen-tests/tests/expectations/tests/replaces_double.rs b/bindgen-tests/tests/expectations/tests/replaces_double.rs index fa8a0e1d07..e764113f21 100644 --- a/bindgen-tests/tests/expectations/tests/replaces_double.rs +++ b/bindgen-tests/tests/expectations/tests/replaces_double.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("Wrapper::Wrapped")] pub struct Wrapper_Wrapped { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub t: T, @@ -15,7 +14,6 @@ impl Default for Wrapper_Wrapped { } } } -#[bindgen_original_name("Wrapper::Type")] pub type Wrapper_Type = Wrapper_Wrapped; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -24,7 +22,6 @@ pub struct Rooted { pub ptr: Rooted_MaybeWrapped, } ///
-#[bindgen_original_name("Rooted::Rooted_MaybeWrapped")] pub type Rooted_MaybeWrapped = T; impl Default for Rooted { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/sentry-defined-multiple-times.rs b/bindgen-tests/tests/expectations/tests/sentry-defined-multiple-times.rs index ddb73684f2..0fe153e700 100644 --- a/bindgen-tests/tests/expectations/tests/sentry-defined-multiple-times.rs +++ b/bindgen-tests/tests/expectations/tests/sentry-defined-multiple-times.rs @@ -13,7 +13,6 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("Wrapper::sentry")] pub struct Wrapper_sentry { pub i_am_wrapper_sentry: ::std::os::raw::c_int, } @@ -46,7 +45,6 @@ pub mod root { }; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("NotTemplateWrapper::sentry")] pub struct NotTemplateWrapper_sentry { pub i_am_not_template_wrapper_sentry: ::std::os::raw::c_char, } @@ -71,7 +69,6 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("InlineNotTemplateWrapper::sentry")] pub struct InlineNotTemplateWrapper_sentry { pub i_am_inline_not_template_wrapper_sentry: bool, } @@ -105,7 +102,6 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("InlineTemplateWrapper::sentry")] pub struct InlineTemplateWrapper_sentry { pub i_am_inline_template_wrapper_sentry: ::std::os::raw::c_int, } @@ -116,7 +112,6 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("OuterDoubleWrapper::InnerDoubleWrapper")] pub struct OuterDoubleWrapper_InnerDoubleWrapper { pub _address: u8, } @@ -140,9 +135,6 @@ pub mod root { }; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name( - "OuterDoubleWrapper::InnerDoubleWrapper::sentry" - )] pub struct OuterDoubleWrapper_InnerDoubleWrapper_sentry { pub i_am_double_wrapper_sentry: ::std::os::raw::c_int, } @@ -169,17 +161,11 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name( - "OuterDoubleInlineWrapper::InnerDoubleInlineWrapper" - )] pub struct OuterDoubleInlineWrapper_InnerDoubleInlineWrapper { pub _address: u8, } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name( - "OuterDoubleInlineWrapper::InnerDoubleInlineWrapper::sentry" - )] pub struct OuterDoubleInlineWrapper_InnerDoubleInlineWrapper_sentry { pub i_am_double_wrapper_inline_sentry: ::std::os::raw::c_int, } @@ -230,7 +216,6 @@ pub mod root { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] - #[bindgen_original_name("OutsideNamespaceWrapper::sentry")] pub struct OutsideNamespaceWrapper_sentry { pub i_am_outside_namespace_wrapper_sentry: ::std::os::raw::c_int, } diff --git a/bindgen-tests/tests/expectations/tests/special-members.rs b/bindgen-tests/tests/expectations/tests/special-members.rs index 0039ad411c..4f54670c86 100644 --- a/bindgen-tests/tests/expectations/tests/special-members.rs +++ b/bindgen-tests/tests/expectations/tests/special-members.rs @@ -1,51 +1,27 @@ -#![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)] pub struct A { pub _address: u8, } -#[test] -fn bindgen_test_layout_A() { - assert_eq!( - ::std::mem::size_of::
(), - 1usize, - concat!("Size of: ", stringify!(A)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(A)) - ); -} -extern "C" { - #[bindgen_original_name("A")] - #[bindgen_special_member("default_ctor")] +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of A"][::std::mem::size_of::() - 1usize]; + ["Alignment of A"][::std::mem::align_of::() - 1usize]; +}; +unsafe extern "C" { #[link_name = "\u{1}_ZN1AC1Ev"] pub fn A_A(this: *mut A); } -extern "C" { - #[bindgen_arg_type_reference(arg1)] - #[bindgen_original_name("A")] - #[bindgen_special_member("copy_ctor")] +unsafe extern "C" { #[link_name = "\u{1}_ZN1AC1ERS_"] pub fn A_A1(this: *mut A, arg1: *mut A); } -extern "C" { - #[bindgen_arg_type_reference(arg1)] - #[bindgen_original_name("A")] - #[bindgen_special_member("move_ctor")] +unsafe extern "C" { #[link_name = "\u{1}_ZN1AC1EOS_"] pub fn A_A2(this: *mut A, arg1: *mut A); } -extern "C" { - #[bindgen_original_name("A_destructor")] - #[bindgen_special_member("dtor")] +unsafe extern "C" { #[link_name = "\u{1}_ZN1AD1Ev"] pub fn A_A_destructor(this: *mut A); } @@ -56,14 +32,12 @@ impl A { A_A(__bindgen_tmp.as_mut_ptr()); __bindgen_tmp.assume_init() } - #[bindgen_arg_type_reference(arg1)] #[inline] pub unsafe fn new1(arg1: *mut A) -> Self { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); A_A1(__bindgen_tmp.as_mut_ptr(), arg1); __bindgen_tmp.assume_init() } - #[bindgen_arg_type_reference(arg1)] #[inline] pub unsafe fn new2(arg1: *mut A) -> Self { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); diff --git a/bindgen-tests/tests/expectations/tests/struct_with_typedef_template_arg.rs b/bindgen-tests/tests/expectations/tests/struct_with_typedef_template_arg.rs index cf1ba13fff..2aaae12dcf 100644 --- a/bindgen-tests/tests/expectations/tests/struct_with_typedef_template_arg.rs +++ b/bindgen-tests/tests/expectations/tests/struct_with_typedef_template_arg.rs @@ -4,5 +4,4 @@ pub struct Proxy { pub _address: u8, } -#[bindgen_original_name("Proxy::foo")] pub type Proxy_foo = ::std::option::Option; diff --git a/bindgen-tests/tests/expectations/tests/template-fun-ty.rs b/bindgen-tests/tests/expectations/tests/template-fun-ty.rs index ffa49bcd50..5337af037a 100644 --- a/bindgen-tests/tests/expectations/tests/template-fun-ty.rs +++ b/bindgen-tests/tests/expectations/tests/template-fun-ty.rs @@ -4,7 +4,6 @@ pub struct Foo { pub _address: u8, } -#[bindgen_original_name("Foo::FunctionPtr")] pub type Foo_FunctionPtr = ::std::option::Option T>; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -13,11 +12,9 @@ pub struct RefPtr { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("RefPtr::Proxy")] pub struct RefPtr_Proxy { pub _address: u8, } -#[bindgen_original_name("RefPtr::Proxy::member_function")] pub type RefPtr_Proxy_member_function = ::std::option::Option< unsafe extern "C" fn(arg1: Args) -> R, >; diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-10.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-10.rs index b2aa888df5..a4e5d0ce82 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-10.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-10.rs @@ -6,13 +6,10 @@ pub struct DoublyIndirectUsage { pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub doubly_indirect: DoublyIndirectUsage_IndirectUsage, } -#[bindgen_original_name("DoublyIndirectUsage::Aliased")] pub type DoublyIndirectUsage_Aliased = T; -#[bindgen_original_name("DoublyIndirectUsage::Typedefed")] pub type DoublyIndirectUsage_Typedefed = U; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("DoublyIndirectUsage::IndirectUsage")] pub struct DoublyIndirectUsage_IndirectUsage { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-2.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-2.rs index 9dba60933b..4c671ce2ab 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-2.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-2.rs @@ -7,7 +7,6 @@ pub struct UsesTemplateParameter { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("UsesTemplateParameter::AlsoUsesTemplateParameter")] pub struct UsesTemplateParameter_AlsoUsesTemplateParameter { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub also: T, diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-3.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-3.rs index 982bdc7efe..511365e656 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-3.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-3.rs @@ -7,9 +7,6 @@ pub struct UsesTemplateParameter { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name( - "UsesTemplateParameter::AlsoUsesTemplateParameterAndMore" -)] pub struct UsesTemplateParameter_AlsoUsesTemplateParameterAndMore { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-4.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-4.rs index f3d441d187..5655a6d260 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-4.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-4.rs @@ -7,7 +7,6 @@ pub struct UsesTemplateParameter { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] -#[bindgen_original_name("UsesTemplateParameter::DoesNotUseTemplateParameters")] pub struct UsesTemplateParameter_DoesNotUseTemplateParameters { pub x: ::std::os::raw::c_int, } diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-5.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-5.rs index 0f4e5b5efb..5049559b33 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-5.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-5.rs @@ -5,7 +5,6 @@ pub struct IndirectlyUsesTemplateParameter { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub aliased: IndirectlyUsesTemplateParameter_Aliased, } -#[bindgen_original_name("IndirectlyUsesTemplateParameter::Aliased")] pub type IndirectlyUsesTemplateParameter_Aliased = T; impl Default for IndirectlyUsesTemplateParameter { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-6.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-6.rs index ff9c80a971..0a08bc9da9 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-6.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-6.rs @@ -4,5 +4,4 @@ pub struct DoesNotUseTemplateParameter { pub x: ::std::os::raw::c_int, } -#[bindgen_original_name("DoesNotUseTemplateParameter::ButAliasDoesUseIt")] pub type DoesNotUseTemplateParameter_ButAliasDoesUseIt = T; diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-7.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-7.rs index 15951e5aab..1552ae852f 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-7.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-7.rs @@ -16,5 +16,4 @@ impl Default for DoesNotUseU { } } } -#[bindgen_unused_template_param] pub type Alias = DoesNotUseU<::std::os::raw::c_int, ::std::os::raw::c_char>; diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-8.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-8.rs index 3b9a13464d..61de18a833 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-8.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-8.rs @@ -7,9 +7,7 @@ pub struct IndirectUsage { pub member1: IndirectUsage_Typedefed, pub member2: IndirectUsage_Aliased, } -#[bindgen_original_name("IndirectUsage::Typedefed")] pub type IndirectUsage_Typedefed = T; -#[bindgen_original_name("IndirectUsage::Aliased")] pub type IndirectUsage_Aliased = U; impl Default for IndirectUsage { fn default() -> Self { diff --git a/bindgen-tests/tests/expectations/tests/template-param-usage-9.rs b/bindgen-tests/tests/expectations/tests/template-param-usage-9.rs index 7c3c23be4b..ff0eedc8ae 100644 --- a/bindgen-tests/tests/expectations/tests/template-param-usage-9.rs +++ b/bindgen-tests/tests/expectations/tests/template-param-usage-9.rs @@ -4,13 +4,10 @@ pub struct DoesNotUse { pub _address: u8, } -#[bindgen_original_name("DoesNotUse::Aliased")] pub type DoesNotUse_Aliased = T; -#[bindgen_original_name("DoesNotUse::Typedefed")] pub type DoesNotUse_Typedefed = U; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("DoesNotUse::IndirectUsage")] pub struct DoesNotUse_IndirectUsage { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, diff --git a/bindgen-tests/tests/expectations/tests/template_alias.rs b/bindgen-tests/tests/expectations/tests/template_alias.rs index 4c75f0c330..b270c9f3a4 100644 --- a/bindgen-tests/tests/expectations/tests/template_alias.rs +++ b/bindgen-tests/tests/expectations/tests/template_alias.rs @@ -1,9 +1,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[bindgen_original_name("Wrapped")] pub type JS_detail_Wrapped = T; #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("Rooted")] pub struct JS_Rooted { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub ptr: JS_detail_Wrapped, diff --git a/bindgen-tests/tests/expectations/tests/template_typedef_transitive_param.rs b/bindgen-tests/tests/expectations/tests/template_typedef_transitive_param.rs index 375ab83f04..2efdde944e 100644 --- a/bindgen-tests/tests/expectations/tests/template_typedef_transitive_param.rs +++ b/bindgen-tests/tests/expectations/tests/template_typedef_transitive_param.rs @@ -6,7 +6,6 @@ pub struct Wrapper { } #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("Wrapper::Wrapped")] pub struct Wrapper_Wrapped { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub t: T, @@ -20,5 +19,4 @@ impl Default for Wrapper_Wrapped { } } } -#[bindgen_original_name("Wrapper::Type")] pub type Wrapper_Type = Wrapper_Wrapped; diff --git a/bindgen-tests/tests/expectations/tests/template_typedefs.rs b/bindgen-tests/tests/expectations/tests/template_typedefs.rs index 90cad61f4b..71f0732a63 100644 --- a/bindgen-tests/tests/expectations/tests/template_typedefs.rs +++ b/bindgen-tests/tests/expectations/tests/template_typedefs.rs @@ -5,11 +5,8 @@ pub type foo = ::std::option::Option = T; -#[bindgen_original_name("Foo::FooPtrTypedef")] pub type Foo_FooPtrTypedef = *mut Foo_Char; -#[bindgen_original_name("Foo::nsCOMArrayEnumFunc")] pub type Foo_nsCOMArrayEnumFunc = ::std::option::Option< unsafe extern "C" fn(aElement: *mut T, aData: *mut ::std::os::raw::c_void) -> bool, >; diff --git a/bindgen-tests/tests/expectations/tests/templateref_opaque.rs b/bindgen-tests/tests/expectations/tests/templateref_opaque.rs index 12a06388c8..8f73e86c31 100644 --- a/bindgen-tests/tests/expectations/tests/templateref_opaque.rs +++ b/bindgen-tests/tests/expectations/tests/templateref_opaque.rs @@ -1,17 +1,13 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("PointerType")] pub struct detail_PointerType { pub _address: u8, } -#[bindgen_original_name("PointerType::Type")] pub type detail_PointerType_Type = *mut T; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct UniquePtr { pub _address: u8, } -#[bindgen_unused_template_param] -#[bindgen_original_name("UniquePtr::Pointer")] pub type UniquePtr_Pointer = detail_PointerType; diff --git a/bindgen-tests/tests/expectations/tests/transform-op.rs b/bindgen-tests/tests/expectations/tests/transform-op.rs index ca7552a8aa..c626049b46 100644 --- a/bindgen-tests/tests/expectations/tests/transform-op.rs +++ b/bindgen-tests/tests/expectations/tests/transform-op.rs @@ -72,11 +72,9 @@ 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; -#[bindgen_original_name("StyleFoo::Tag")] pub type StyleFoo_Tag = u8; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("StyleFoo::Foo_Body")] pub struct StyleFoo_Foo_Body { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub tag: StyleFoo_Tag, @@ -95,7 +93,6 @@ impl Default for StyleFoo_Foo_Body { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("StyleFoo::Bar_Body")] pub struct StyleFoo_Bar_Body { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub tag: StyleFoo_Tag, @@ -112,7 +109,6 @@ impl Default for StyleFoo_Bar_Body { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("StyleFoo::Baz_Body")] pub struct StyleFoo_Baz_Body { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub tag: StyleFoo_Tag, @@ -160,11 +156,9 @@ 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; -#[bindgen_original_name("StyleBar::Tag")] pub type StyleBar_Tag = ::std::os::raw::c_int; #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("StyleBar::StyleBar1_Body")] pub struct StyleBar_StyleBar1_Body { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub x: i32, @@ -182,7 +176,6 @@ impl Default for StyleBar_StyleBar1_Body { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("StyleBar::StyleBar2_Body")] pub struct StyleBar_StyleBar2_Body { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _0: T, @@ -198,7 +191,6 @@ impl Default for StyleBar_StyleBar2_Body { } #[repr(C)] #[derive(Debug, Copy, Clone)] -#[bindgen_original_name("StyleBar::StyleBar3_Body")] pub struct StyleBar_StyleBar3_Body { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, pub _0: StylePoint, diff --git a/bindgen-tests/tests/expectations/tests/typeref.rs b/bindgen-tests/tests/expectations/tests/typeref.rs index f36c8dfaca..e48f0eb254 100644 --- a/bindgen-tests/tests/expectations/tests/typeref.rs +++ b/bindgen-tests/tests/expectations/tests/typeref.rs @@ -1,7 +1,6 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("FragmentOrURL")] pub struct mozilla_FragmentOrURL { pub mIsLocalRef: bool, } @@ -19,7 +18,6 @@ const _: () = { }; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -#[bindgen_original_name("Position")] pub struct mozilla_Position { pub _address: u8, } @@ -31,7 +29,6 @@ const _: () = { ][::std::mem::align_of::() - 1usize]; }; #[repr(C)] -#[bindgen_original_name("StyleShapeSource")] pub struct mozilla_StyleShapeSource { pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1, } diff --git a/bindgen-tests/tests/expectations/tests/union_dtor.rs b/bindgen-tests/tests/expectations/tests/union_dtor.rs index 15627bb7d9..3b89587098 100644 --- a/bindgen-tests/tests/expectations/tests/union_dtor.rs +++ b/bindgen-tests/tests/expectations/tests/union_dtor.rs @@ -16,8 +16,6 @@ const _: () = { ][::std::mem::offset_of!(UnionWithDtor, mBar) - 0usize]; }; unsafe extern "C" { - #[bindgen_original_name("UnionWithDtor_destructor")] - #[bindgen_special_member("dtor")] #[link_name = "\u{1}_ZN13UnionWithDtorD1Ev"] pub fn UnionWithDtor_UnionWithDtor_destructor(this: *mut UnionWithDtor); } diff --git a/bindgen-tests/tests/expectations/tests/var-tracing.rs b/bindgen-tests/tests/expectations/tests/var-tracing.rs index 80f6fb2926..76ce0c50d6 100644 --- a/bindgen-tests/tests/expectations/tests/var-tracing.rs +++ b/bindgen-tests/tests/expectations/tests/var-tracing.rs @@ -11,7 +11,6 @@ const _: () = { ["Offset of field: Bar::m_baz"][::std::mem::offset_of!(Bar, m_baz) - 0usize]; }; unsafe extern "C" { - #[bindgen_original_name("Bar")] #[link_name = "\u{1}_ZN3BarC1Ei"] pub fn Bar_Bar(this: *mut Bar, baz: ::std::os::raw::c_int); } diff --git a/bindgen-tests/tests/expectations/tests/variadic-method.rs b/bindgen-tests/tests/expectations/tests/variadic-method.rs index e8a34f4803..deac5f719e 100644 --- a/bindgen-tests/tests/expectations/tests/variadic-method.rs +++ b/bindgen-tests/tests/expectations/tests/variadic-method.rs @@ -14,7 +14,6 @@ const _: () = { ["Alignment of Bar"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("foo")] #[link_name = "\u{1}_ZN3Bar3fooEPKcz"] pub fn Bar_foo(this: *mut Bar, fmt: *const ::std::os::raw::c_char, ...); } diff --git a/bindgen-tests/tests/expectations/tests/virtual_dtor.rs b/bindgen-tests/tests/expectations/tests/virtual_dtor.rs index 3d1ba9288b..d42be25202 100644 --- a/bindgen-tests/tests/expectations/tests/virtual_dtor.rs +++ b/bindgen-tests/tests/expectations/tests/virtual_dtor.rs @@ -21,8 +21,6 @@ impl Default for nsSlots { } } unsafe extern "C" { - #[bindgen_original_name("nsSlots_destructor")] - #[bindgen_special_member("dtor")] #[link_name = "\u{1}_ZN7nsSlotsD1Ev"] pub fn nsSlots_nsSlots_destructor(this: *mut nsSlots); } diff --git a/bindgen-tests/tests/expectations/tests/virtual_overloaded.rs b/bindgen-tests/tests/expectations/tests/virtual_overloaded.rs index bdb28f34b1..4c3702faeb 100644 --- a/bindgen-tests/tests/expectations/tests/virtual_overloaded.rs +++ b/bindgen-tests/tests/expectations/tests/virtual_overloaded.rs @@ -24,12 +24,10 @@ impl Default for C { } } unsafe extern "C" { - #[bindgen_original_name("do_thing")] #[link_name = "\u{1}_ZN1C8do_thingEc"] pub fn C_do_thing(this: *mut ::std::os::raw::c_void, arg1: ::std::os::raw::c_char); } unsafe extern "C" { - #[bindgen_original_name("do_thing")] #[link_name = "\u{1}_ZN1C8do_thingEi"] pub fn C_do_thing1(this: *mut ::std::os::raw::c_void, arg1: ::std::os::raw::c_int); } diff --git a/bindgen-tests/tests/expectations/tests/vtable_recursive_sig.rs b/bindgen-tests/tests/expectations/tests/vtable_recursive_sig.rs index 8b04bfd82d..9b9c2467aa 100644 --- a/bindgen-tests/tests/expectations/tests/vtable_recursive_sig.rs +++ b/bindgen-tests/tests/expectations/tests/vtable_recursive_sig.rs @@ -23,7 +23,6 @@ impl Default for Base { } } unsafe extern "C" { - #[bindgen_original_name("AsDerived")] #[link_name = "\u{1}_ZN4Base9AsDerivedEv"] pub fn Base_AsDerived(this: *mut ::std::os::raw::c_void) -> *mut Derived; } diff --git a/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs b/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs index 178ead5e2e..ee26600a6b 100644 --- a/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs +++ b/bindgen-tests/tests/expectations/tests/wasm-constructor-returns.rs @@ -10,7 +10,6 @@ const _: () = { ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "C" { - #[bindgen_original_name("Foo")] #[link_name = "\u{1}_ZN3FooC1Ei"] pub fn Foo_Foo( this: *mut Foo, diff --git a/bindgen-tests/tests/expectations/tests/what_is_going_on.rs b/bindgen-tests/tests/expectations/tests/what_is_going_on.rs index e56da9829a..aaeab668e1 100644 --- a/bindgen-tests/tests/expectations/tests/what_is_going_on.rs +++ b/bindgen-tests/tests/expectations/tests/what_is_going_on.rs @@ -26,5 +26,4 @@ impl Default for PointTyped { } } } -#[bindgen_unused_template_param] pub type IntPoint = PointTyped; diff --git a/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs b/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs index 1734683d9a..87b63574a9 100644 --- a/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs +++ b/bindgen-tests/tests/expectations/tests/win32-thiscall_nightly.rs @@ -12,12 +12,10 @@ const _: () = { ["Alignment of Foo"][::std::mem::align_of::() - 1usize]; }; unsafe extern "thiscall" { - #[bindgen_original_name("test")] #[link_name = "\u{1}?test@Foo@@QAEXXZ"] pub fn Foo_test(this: *mut Foo); } unsafe extern "thiscall" { - #[bindgen_original_name("test2")] #[link_name = "\u{1}?test2@Foo@@QAEHH@Z"] pub fn Foo_test2( this: *mut Foo, diff --git a/bindgen-tests/tests/parse_callbacks/item_discovery_callback/header_item_discovery.h b/bindgen-tests/tests/parse_callbacks/item_discovery_callback/header_item_discovery.h index 10e97ea480..b2bb04f15f 100644 --- a/bindgen-tests/tests/parse_callbacks/item_discovery_callback/header_item_discovery.h +++ b/bindgen-tests/tests/parse_callbacks/item_discovery_callback/header_item_discovery.h @@ -1,4 +1,4 @@ -// Unions +// Structs void function_using_anonymous_struct(struct {} arg0); struct NamedStruct { @@ -13,4 +13,16 @@ void function_using_anonymous_union(union {} arg0); union NamedUnion { }; -typedef union NamedUnion AliasOfNamedUnion; \ No newline at end of file +typedef union NamedUnion AliasOfNamedUnion; + +// Enums + +// We don't include an anonymous enum because such enums +// are not visible outside the function, and thus tend not +// to be useful - bindgen doesn't handle them for this reason. + +enum NamedEnum { + Fish, +}; + +typedef enum NamedEnum AliasOfNamedEnum; \ No newline at end of file diff --git a/bindgen-tests/tests/parse_callbacks/item_discovery_callback/mod.rs b/bindgen-tests/tests/parse_callbacks/item_discovery_callback/mod.rs index da37eeec97..4a259cb913 100644 --- a/bindgen-tests/tests/parse_callbacks/item_discovery_callback/mod.rs +++ b/bindgen-tests/tests/parse_callbacks/item_discovery_callback/mod.rs @@ -4,6 +4,7 @@ use std::rc::Rc; use regex::Regex; +use autocxx_bindgen as bindgen; use bindgen::callbacks::{DiscoveredItem, DiscoveredItemId, ParseCallbacks}; use bindgen::Builder; @@ -60,6 +61,19 @@ pub fn test_item_discovery_callback() { alias_for: DiscoveredItemId::new(20), }, ), + ( + DiscoveredItemId::new(27), + DiscoveredItem::Alias { + alias_name: "AliasOfNamedEnum".to_string(), + alias_for: DiscoveredItemId::new(24), + }, + ), + ( + DiscoveredItemId::new(24), + DiscoveredItem::Enum { + final_name: "NamedEnum".to_string(), + }, + ), ( DiscoveredItemId::new(30), DiscoveredItem::Struct { @@ -128,6 +142,11 @@ fn compare_item_info( expected, generated, ), + DiscoveredItem::Enum { .. } => compare_enum_info(expected_item, generated_item), + // DiscoveredItem::Mod { final_name } => todo!(), + // DiscoveredItem::Function { final_name } => todo!(), + // DiscoveredItem::Method { final_name, parent } => todo!(), + _ => true, } } @@ -205,6 +224,31 @@ pub fn compare_union_info( } } + +pub fn compare_enum_info( + expected_item: &DiscoveredItem, + generated_item: &DiscoveredItem, +) -> bool { + let DiscoveredItem::Enum { + final_name: expected_final_name, + } = expected_item + else { + unreachable!() + }; + + let DiscoveredItem::Enum { + final_name: generated_final_name, + } = generated_item + else { + unreachable!() + }; + + if !compare_names(expected_final_name, generated_final_name) { + return false; + } + true +} + pub fn compare_alias_info( expected_item: &DiscoveredItem, generated_item: &DiscoveredItem, diff --git a/bindgen-tests/tests/parse_callbacks/mod.rs b/bindgen-tests/tests/parse_callbacks/mod.rs index 7aca0fd1a1..f7a6aab754 100644 --- a/bindgen-tests/tests/parse_callbacks/mod.rs +++ b/bindgen-tests/tests/parse_callbacks/mod.rs @@ -1,5 +1,6 @@ mod item_discovery_callback; +use autocxx_bindgen as bindgen; use bindgen::callbacks::*; use bindgen::FieldVisibilityKind; diff --git a/bindgen/callbacks.rs b/bindgen/callbacks.rs index 8a21e98dea..9e8c379893 100644 --- a/bindgen/callbacks.rs +++ b/bindgen/callbacks.rs @@ -1,9 +1,12 @@ //! A public API for more fine-grained customization of bindgen behavior. pub use crate::ir::analysis::DeriveTrait; +pub use crate::ir::comp::SpecialMemberKind; pub use crate::ir::derive::CanDerive as ImplementsTrait; pub use crate::ir::enum_ty::{EnumVariantCustomBehavior, EnumVariantValue}; +pub use crate::ir::function::Visibility; pub use crate::ir::int::IntKind; +pub use crate::ir::layout::Layout; use std::fmt; /// An enum to allow ignoring parsing of macros. @@ -166,6 +169,40 @@ pub trait ParseCallbacks: fmt::Debug { /// This will get called everytime an item (currently struct, union, and alias) is found with some information about it fn new_item_found(&self, _id: DiscoveredItemId, _item: DiscoveredItem) {} + /// Where the original C++ name differs + fn denote_cpp_name(&self, _id: DiscoveredItemId, _original_name: Option<&str>, _namespace_mod: Option) {} + + /// Note that a function is a C++ virtual or pure virtual function. + fn denote_virtualness(&self, _id: DiscoveredItemId, _virtualness: Virtualness) {} + + /// Note that a C++ function has been marked defaulted or deleted. + fn denote_explicit(&self, _id: DiscoveredItemId, _explicitness: Explicitness) {} + + /// Note that a C++ function has been marked defaulted. + fn denote_special_member(&self, _id: DiscoveredItemId, _kind: SpecialMemberKind) {} + + /// Note the visibility of a C++ function. Note that this is just reporting + /// the C++ visibility; as opposed to [`field_visibility`] this does not + /// allow changes. + fn denote_visibility(&self, _id: DiscoveredItemId, _visibility: Visibility) {} + + /// Note where in the source code a given item was encountered. + fn denote_source_location(&self, _id: DiscoveredItemId, _location: &SourceLocation) {} + + /// Notes the layout of an item. + fn denote_layout(&self, _id: DiscoveredItemId, _layout: &Layout) {} + + /// Notes that this type does not use all the template params + /// which were present in C++. Sometimes those template parameters + /// are not useful in Rust because they don't actually impact the + /// data stored in the type, so bindgen drops them. But this also means + /// that the bindgen output does not contain full and comprehensive + /// output about the original nature of the C++ type, so higher level + /// code generators may wish to behave differently. For example, + /// it would not be OK to attempt to generate additional C++ code + /// based on this. + fn denote_discards_template_param(&self, _id: DiscoveredItemId) {} + // TODO add callback for ResolvedTypeRef } @@ -217,7 +254,38 @@ pub enum DiscoveredItem { /// The identifier of the discovered type alias_for: DiscoveredItemId, - }, // functions, modules, etc. + }, + + /// Represents an enum. + Enum { + /// The final name of the generated binding + final_name: String, + }, + + /// A module, typically representing a C++ namespace. + Mod { + /// The final name used. + final_name: String, + + /// The parent ID. Typically another module, indicating that C++ + /// namespaces are in use. If it's the root module, will be None. + parent_id: Option, + }, + + /// A function or method. + Function { + /// The final name used. + final_name: String, + }, + + /// A method. + Method { + /// The final name used. + final_name: String, + + /// Type to which this method belongs. + parent: DiscoveredItemId, + } } /// Relevant information about a type to which new derive attributes will be added using @@ -283,3 +351,44 @@ pub struct FieldInfo<'a> { /// The name of the type of the field. pub field_type_name: Option<&'a str>, } + +/// Whether a method is virtual or pure virtual. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum Virtualness { + /// Not pure virtual. + Virtual, + /// Pure virtual. + PureVirtual +} + +/// Whether a field is a regular lvalue reference or rvalue reference +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum Referenceness { + /// Normal reference, i.e. lvalue + Reference, + /// RValue reference + RValueReference +} + +/// Whether a C++ method has been explicitly defaulted or deleted. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum Explicitness { + /// Defaulted function, i.e. `=default` + Defaulted, + /// Deleted function, i.e. `=delete` + Deleted, +} + +/// Location in the source code. Roughly equivalent to the same type +/// within `clang_sys`. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct SourceLocation { + /// Line number. + pub line: usize, + /// Column number within line. + pub col: usize, + /// Byte offset within file. + pub byte_offset: usize, + /// Filename, if known. + pub file_name: Option, +} diff --git a/bindgen/codegen/error.rs b/bindgen/codegen/error.rs index 0fb4e94f3e..b82ba2aef1 100644 --- a/bindgen/codegen/error.rs +++ b/bindgen/codegen/error.rs @@ -12,9 +12,6 @@ pub(crate) enum Error { /// template specialization). InstantiationOfOpaqueType, - /// Type was a reference not a pointer, but we had nowhere to record that fact. - ReferenceButCouldNotRecord, - /// Function ABI is not supported. UnsupportedAbi(&'static str), @@ -36,9 +33,6 @@ impl fmt::Display for Error { "Instantiation of opaque template type or partial template specialization." .fmt(f) } - Error::ReferenceButCouldNotRecord => { - "Type was a reference in a context where we only expected other types".fmt(f) - } Error::UnsupportedAbi(abi) => { write!( f, diff --git a/bindgen/codegen/helpers.rs b/bindgen/codegen/helpers.rs index ebbefbd986..df621b7666 100644 --- a/bindgen/codegen/helpers.rs +++ b/bindgen/codegen/helpers.rs @@ -1,12 +1,9 @@ //! Helpers for code generation that don't need macro expansion. -use proc_macro2::{Ident, Span, TokenStream}; +use proc_macro2::{Ident, Span}; -use crate::ir::comp::SpecialMemberKind; -use crate::ir::function::Visibility; use crate::ir::context::BindgenContext; use crate::ir::layout::Layout; -use crate::BindgenOptions; pub(crate) mod attributes { use proc_macro2::{Ident, Span, TokenStream}; @@ -78,190 +75,6 @@ pub(crate) mod attributes { } } -pub(crate) trait CppSemanticAttributeCreator { - fn do_add(&mut self, ts: TokenStream); - fn is_enabled(&self) -> bool; - - fn add(&mut self, tokens: TokenStream) { - if self.is_enabled() { - self.do_add(quote! { - #[cpp_semantics(#tokens)] - }) - } - } - - fn add_ident(&mut self, desc: &str) { - if self.is_enabled() { - let id = Ident::new(desc, Span::call_site()); - self.add(quote! { #id }) - } - } - - fn special_member(&mut self, kind: SpecialMemberKind) { - let kind_str = match kind { - SpecialMemberKind::DefaultConstructor => "default_ctor", - SpecialMemberKind::CopyConstructor => "copy_ctor", - SpecialMemberKind::MoveConstructor => "move_ctor", - SpecialMemberKind::Destructor => "dtor", - SpecialMemberKind::AssignmentOperator => "assignment_operator", - }; - self.add(quote! { - special_member(#kind_str) - }) - } - - fn original_name(&mut self, name: &str) { - self.add(quote! { - original_name(#name) - }) - } - - fn ret_type_reference(&mut self) { - self.add_ident("ret_type_reference") - } - - fn ret_type_rvalue_reference(&mut self) { - self.add_ident("ret_type_rvalue_reference") - } - - fn arg_type_reference(&mut self, arg_name: &Ident) { - self.add(quote! { - arg_type_reference(#arg_name) - }) - } - - fn field_type_reference(&mut self) { - self.add_ident("reference") - } - - fn field_type_rvalue_reference(&mut self) { - self.add_ident("rvalue_reference") - } - - fn is_virtual(&mut self) { - self.add_ident("bindgen_virtual") - } - - fn arg_type_rvalue_reference(&mut self, arg_name: &Ident) { - self.add(quote! { - arg_type_rvalue_reference(#arg_name) - }) - } - - fn is_pure_virtual(&mut self) { - self.add_ident("pure_virtual") - } - - fn visibility(&mut self, visibility: Visibility) { - match visibility { - Visibility::Protected => self.add_ident("visibility_protected"), - Visibility::Private => self.add_ident("visibility_private"), - _ => {} - } - } - - fn incomprehensible_param_in_arg_or_return(&mut self) { - self.add_ident("incomprehensible_param_in_arg_or_return") - } - - fn discards_template_param(&mut self) { - self.add_ident("unused_template_param") - } - - fn deleted_fn(&mut self) { - self.add_ident("deleted") - } - - fn defaulted_fn(&mut self) { - self.add_ident("defaulted") - } - - fn layout(&mut self, layout: &Layout) { - let sz = ast_ty::int_expr(layout.size as i64); - let align = ast_ty::int_expr(layout.align as i64); - let packed = if layout.packed { - quote! { true } - } else { - quote! { false } - }; - self.add(quote! { - layout(#sz, #align, #packed) - }) - } - - fn location(&mut self, - location: Option<&crate::clang::SourceLocation>, - ) { - if let Some(location) = location { - let (file, line, col, byte_offset) = location.location(); - let line = ast_ty::int_expr(line as i64); - let col = ast_ty::int_expr(col as i64); - let byte_offset = ast_ty::int_expr(byte_offset as i64); - let file = file.name(); - if let Some(filename) = file { - self.add(quote! { - source_location(#filename, #line, #col, #byte_offset) - }); - } - } - } -} - -pub struct CppSemanticAttributeAdder<'a> { - enabled: bool, - attrs: &'a mut Vec, -} - -impl<'a> CppSemanticAttributeAdder<'a> { - pub(crate) fn new( - opts: &BindgenOptions, - attrs: &'a mut Vec, - ) -> Self { - Self { - enabled: opts.cpp_semantic_attributes, - attrs, - } - } -} - -impl<'a> CppSemanticAttributeCreator for CppSemanticAttributeAdder<'a> { - fn do_add(&mut self, ts: TokenStream) { - self.attrs.push(ts) - } - - fn is_enabled(&self) -> bool { - self.enabled - } -} - -pub struct CppSemanticAttributeSingle { - enabled: bool, - attr: TokenStream, -} - -impl CppSemanticAttributeSingle { - pub(crate) fn new(opts: &BindgenOptions) -> Self { - Self { - enabled: opts.cpp_semantic_attributes, - attr: quote! {}, - } - } - - pub(crate) fn result(self) -> TokenStream { - self.attr - } -} - -impl CppSemanticAttributeCreator for CppSemanticAttributeSingle { - fn do_add(&mut self, ts: TokenStream) { - self.attr.extend(ts); - } - - fn is_enabled(&self) -> bool { - self.enabled - } -} - /// The `ffi_safe` argument should be true if this is a type that the user might /// reasonably use, e.g. not struct padding, where the `__BindgenOpaqueArray` is /// just noise. @@ -272,6 +85,19 @@ pub(crate) fn blob( layout: Layout, ffi_safe: bool, ) -> syn::Type { + let inner_blob = blob_inner(ctx, layout, ffi_safe); + if ctx.options().use_opaque_newtype_wrapper { + syn::parse_quote! { __bindgen_marker_Opaque < #inner_blob > } + } else { + inner_blob + } +} + +pub(crate) fn blob_inner( + ctx: &BindgenContext, + layout: Layout, + ffi_safe: bool, + ) -> syn::Type { let opaque = layout.opaque(); // FIXME(emilio, #412): We fall back to byte alignment, but there are @@ -575,3 +401,24 @@ pub(crate) mod ast_ty { .collect() } } + +pub(crate) fn reference(ty_ptr: syn::TypePtr, is_rvalue: bool, ctx: &BindgenContext) -> syn::Type { + let ptr = syn::Type::Ptr(ty_ptr); + if ctx.options().use_reference_newtype_wrapper { + if is_rvalue { + syn::parse_quote! { __bindgen_marker_RValueReference < #ptr >} + } else { + syn::parse_quote! { __bindgen_marker_Reference < #ptr >} + } + } else { + ptr + } +} + +pub(crate) fn with_unused_template_args(inner: syn::Type, ctx: &BindgenContext) -> syn::Type { + if ctx.options().use_unused_template_param_newtype_wrapper { + syn::parse_quote! { __bindgen_marker_UnusedTemplateParam< #inner > } + } else { + inner + } +} diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index f6f635d3fa..6d6898be86 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -21,14 +21,9 @@ use self::struct_layout::StructLayoutTracker; use super::BindgenOptions; use crate::callbacks::{ - AttributeInfo, DeriveInfo, DiscoveredItem, DiscoveredItemId, FieldInfo, - TypeKind as DeriveTypeKind, + AttributeInfo, DeriveInfo, DiscoveredItem, DiscoveredItemId, Explicitness, FieldInfo, TypeKind as DeriveTypeKind }; use crate::codegen::error::Error; -use crate::codegen::helpers::{ - CppSemanticAttributeAdder, CppSemanticAttributeCreator, - CppSemanticAttributeSingle, -}; use crate::ir::analysis::{HasVtable, Sizedness}; use crate::ir::annotations::{ Annotations, FieldAccessorKind, FieldVisibilityKind, @@ -456,7 +451,7 @@ impl WithImplicitTemplateParams for syn::Type { Some(params.into_iter().map(|p| { p.try_to_rust_ty(ctx, &()).expect( "template params cannot fail to be a rust type", - ).into_unannotated_ts().expect("Oh, inner type had annotations") + ) })) } } @@ -470,20 +465,6 @@ impl WithImplicitTemplateParams for syn::Type { } } -impl WithImplicitTemplateParams for RustTy { - fn with_implicit_template_params( - self, - ctx: &BindgenContext, - item: &Item, - ) -> Self { - let (ty, annotation) = self.into_outer_type(); - Self { - ty: ty.with_implicit_template_params(ctx, item), - annotation - } - } -} - trait CodeGenerator { /// Extra information from the caller. type Extra; @@ -550,7 +531,7 @@ impl CodeGenerator for Item { module.codegen(ctx, result, self); } ItemKind::Function(ref fun) => { - fun.codegen(ctx, result, self); + fun.codegen(ctx, result, self); } ItemKind::Var(ref var) => { var.codegen(ctx, result, self); @@ -645,6 +626,24 @@ impl CodeGenerator for Module { } let name = item.canonical_name(ctx); + + let parent_id = if item.id() == item.parent_id() { + None // root mod + } else { + utils::find_reportable_parent_mod(ctx, item) + }; + ctx.options().for_each_callback(|cb| { + let discovered_item = DiscoveredItem::Mod { + final_name: name.clone(), + parent_id, + }; + + cb.new_item_found( + DiscoveredItemId::new(item.id().as_usize()), + discovered_item, + ); + }); + let ident = ctx.rust_ident(name); result.push(if item.id() == ctx.root_module() { quote! { @@ -699,7 +698,7 @@ impl CodeGenerator for Var { } let var_ty = self.ty(); - let ty = var_ty.to_rust_ty_or_opaque(ctx, &()).ignore_annotations(); + let ty = var_ty.to_rust_ty_or_opaque(ctx, &()); if let Some(val) = self.val() { match *val { @@ -836,7 +835,6 @@ impl CodeGenerator for Var { canonical_ident, self.ty() .to_rust_ty_or_opaque(ctx, &()) - .ignore_annotations() .into_token_stream(), ctx.options().dynamic_link_require_all, ctx.options().wrap_unsafe_ops, @@ -860,6 +858,7 @@ impl CodeGenerator for Type { ) { debug!("::codegen: item = {item:?}"); debug_assert!(item.is_enabled_for_codegen(ctx)); + let id = DiscoveredItemId::new(item.id().as_usize()); match *self.kind() { TypeKind::Void | @@ -982,13 +981,9 @@ impl CodeGenerator for Type { // Its possible that we have better layout information than // the inner type does, so fall back to an opaque blob based // on our layout if converting the inner item fails. - let (inner_ty, _) = inner_item + inner_item .try_to_rust_ty_or_opaque(ctx, &()) - .map(|ty| ty.into_outer_type()) - .unwrap_or_else(|_| { - (self.to_opaque(ctx, item), RustTyAnnotation::None) - }); - inner_ty + .unwrap_or_else(|_| self.to_opaque(ctx, item)) .with_implicit_template_params(ctx, inner_item) }; @@ -1034,8 +1029,6 @@ impl CodeGenerator for Type { } else { quote! {} }; - let mut semantic_annotations = - CppSemanticAttributeSingle::new(ctx.options()); // We are handling (essentially) type X = Y; // We want to denote only if X has unused template params, e.g. // type X = Y; @@ -1043,9 +1036,10 @@ impl CodeGenerator for Type { // type X = Y // because that information will be recorded against the definition of Y. if has_unused_template_args { - semantic_annotations.discards_template_param(); + ctx.options().for_each_callback(|cb| { + cb.denote_discards_template_param(id); + }) } - tokens.append_all(semantic_annotations.result()); let alias_style = if ctx.options().type_alias.matches(&name) { AliasVariation::TypeAlias @@ -1077,21 +1071,10 @@ impl CodeGenerator for Type { return; } - let mut attributes = Vec::new(); - if let Some(original_name) = item.original_name(ctx) { - if name != original_name { - let mut semantic_annotations = - CppSemanticAttributeAdder::new( - ctx.options(), - &mut attributes, - ); - semantic_annotations.original_name(&original_name); - } - } + utils::callback_with_cpp_name(ctx, item, item.original_name(ctx).as_ref().map(String::as_str)); tokens.append_all(match alias_style { AliasVariation::TypeAlias => quote! { - #( #attributes )* pub type #rust_name }, AliasVariation::NewType | AliasVariation::NewTypeDeref => { @@ -1155,7 +1138,7 @@ impl CodeGenerator for Type { .map(|p| { p.try_to_rust_ty(ctx, &()).expect( "type parameters can always convert to rust ty OK", - ).ignore_annotations() + ) }) .collect(); @@ -1279,8 +1262,8 @@ impl CodeGenerator for Vtable<'_> { // FIXME: Need to account for overloading with times_seen (separately from regular function path). let function_name = ctx.rust_ident(function_name); - let (mut args, _) = utils::fnsig_arguments(ctx, signature); - let (ret, _) = utils::fnsig_return_ty(ctx, signature); + let mut args = utils::fnsig_arguments(ctx, signature); + let ret = utils::fnsig_return_ty(ctx, signature); args[0] = if m.is_const() { quote! { this: *const #class_ident } @@ -1325,9 +1308,9 @@ impl TryToRustTy for Vtable<'_> { &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { let name = ctx.rust_ident(self.canonical_name(ctx)); - Ok(RustTy::new(syn::parse_quote! { #name })) + Ok(syn::parse_quote! { #name }) } } @@ -1383,8 +1366,7 @@ impl CodeGenerator for TemplateInstantiation { }; let prefix = ctx.trait_prefix(); - let ident = - item.to_rust_ty_or_opaque(ctx, &()).ignore_annotations(); + let ident = item.to_rust_ty_or_opaque(ctx, &()); let size_of_expr = quote! { ::#prefix::mem::size_of::<#ident>() }; @@ -1550,11 +1532,9 @@ impl FieldCodegen<'_> for FieldData { let field_item = self.ty().into_resolver().through_type_refs().resolve(ctx); let field_ty = field_item.expect_type(); - let (mut ty, ty_annotations) = self + let ty = self .ty() .to_rust_ty_or_opaque(ctx, &()) - .into_outer_type(); - ty = ty .with_implicit_template_params(ctx, field_item); // NB: If supported, we use proper `union` types. @@ -1568,7 +1548,7 @@ impl FieldCodegen<'_> for FieldData { } else { result.saw_incomplete_array(); - let inner = item.to_rust_ty_or_opaque(ctx, &()).ignore_annotations(); + let inner = item.to_rust_ty_or_opaque(ctx, &()); if ctx.options().enable_cxx_namespaces { syn::parse_quote! { root::__IncompleteArrayField<#inner> } @@ -1617,33 +1597,19 @@ impl FieldCodegen<'_> for FieldData { let accessor_kind = self.annotations().accessor_kind().unwrap_or(accessor_kind); - let mut attributes = Vec::new(); - let mut csaa = - CppSemanticAttributeAdder::new(ctx.options(), &mut attributes); - match ty_annotations { - RustTyAnnotation::Reference => csaa.field_type_reference(), - RustTyAnnotation::RValueReference => { - csaa.field_type_rvalue_reference() - } - _ => {} - }; - match visibility { FieldVisibilityKind::Private => { field.append_all(quote! { - #(#attributes),* #field_ident : #ty , }); } FieldVisibilityKind::PublicCrate => { field.append_all(quote! { - #(#attributes),* pub(crate) #field_ident : #ty , }); } FieldVisibilityKind::Public => { field.append_all(quote! { - #(#attributes),* pub #field_ident : #ty , }); } @@ -1917,9 +1883,8 @@ impl FieldCodegen<'_> for BitfieldUnit { let param_name = bitfield_getter_name(ctx, bf); let bitfield_ty_item = ctx.resolve_item(bf.ty()); let bitfield_ty = bitfield_ty_item.expect_type(); - let bitfield_ty = bitfield_ty - .to_rust_ty_or_opaque(ctx, bitfield_ty_item) - .ignore_annotations(); + let bitfield_ty = + bitfield_ty.to_rust_ty_or_opaque(ctx, bitfield_ty_item); ctor_params.push(quote! { #param_name : #bitfield_ty @@ -2043,9 +2008,8 @@ impl<'a> FieldCodegen<'a> for Bitfield { return; }; - let bitfield_ty = bitfield_ty - .to_rust_ty_or_opaque(ctx, bitfield_ty_item) - .ignore_annotations(); + let bitfield_ty = + bitfield_ty.to_rust_ty_or_opaque(ctx, bitfield_ty_item); let offset = self.offset_into_unit(); let width = self.width() as u8; @@ -2189,18 +2153,45 @@ impl CodeGenerator for CompInfo { debug!("::codegen: item = {item:?}"); debug_assert!(item.is_enabled_for_codegen(ctx)); - // Don't output classes with template parameters that aren't types, and - // also don't output template specializations, neither total or partial. - if self.has_non_type_template_params() { - return; - } - let ty = item.expect_type(); let layout = ty.layout(ctx); let mut packed = self.is_packed(ctx, layout.as_ref()); let canonical_name = item.canonical_name(ctx); let canonical_ident = ctx.rust_ident(&canonical_name); + let id = DiscoveredItemId::new(item.id().as_usize()); + + ctx.options().for_each_callback(|cb| { + let discovered_item = match self.kind() { + CompKind::Struct => DiscoveredItem::Struct { + original_name: item + .kind() + .expect_type() + .name() + .map(String::from), + final_name: canonical_ident.to_string(), + }, + CompKind::Union => DiscoveredItem::Union { + original_name: item + .kind() + .expect_type() + .name() + .map(String::from), + final_name: canonical_ident.to_string(), + }, + }; + + cb.new_item_found( + id, + discovered_item, + ); + }); + + // Don't output classes with template parameters that aren't types, and + // also don't output template specializations, neither total or partial. + if self.has_non_type_template_params() { + return; + } // Generate the vtable from the method list if appropriate. // @@ -2256,7 +2247,6 @@ impl CodeGenerator for CompInfo { let vtable_type = vtable .try_to_rust_ty(ctx, &()) .expect("vtable to Rust type conversion is infallible") - .ignore_annotations() .to_ptr(true); fields.push(quote! { @@ -2274,8 +2264,7 @@ impl CodeGenerator for CompInfo { let inner_item = ctx.resolve_item(base.ty); let inner = inner_item .to_rust_ty_or_opaque(ctx, &()) - .with_implicit_template_params(ctx, inner_item) - .ignore_annotations(); + .with_implicit_template_params(ctx, inner_item); let field_name = ctx.rust_ident(&base.field_name); struct_layout.saw_base(inner_item.expect_type()); @@ -2362,7 +2351,13 @@ impl CodeGenerator for CompInfo { if has_address { let layout = Layout::new(1, 1); - let ty = helpers::blob(ctx, Layout::new(1, 1), false); + // Normally for opaque data we use helpers::blob, + // which may wrap it in __bindgen_marker_Opaque. + // Downstream tools may then use this as a sign that + // the type is complex or can't be stack-allocated, + // etc. But in this case this one-byte field is harmless + // so we'll just represent it without that extra marker. + let ty = helpers::blob_inner(ctx, Layout::new(1, 1), false); struct_layout.saw_field_with_layout( "_address", layout, @@ -2430,7 +2425,7 @@ impl CodeGenerator for CompInfo { { match self.flex_array_member(ctx) { Some(ty) => { - let inner = ty.to_rust_ty_or_opaque(ctx, &()).ignore_annotations(); + let inner = ty.to_rust_ty_or_opaque(ctx, &()); ( Some(quote! { FAM: ?Sized = [ #inner; 0 ] }), Some(quote! { #inner }), @@ -2502,16 +2497,14 @@ impl CodeGenerator for CompInfo { } else { attributes.push(attributes::repr("C")); } - let mut semantic_annotations = - CppSemanticAttributeAdder::new(ctx.options(), &mut attributes); if unused_template_params { - semantic_annotations.discards_template_param(); + ctx.options().for_each_callback(|cb| cb.denote_discards_template_param(id)); } - semantic_annotations.visibility(self.visibility()); + ctx.options().for_each_callback(|cb| cb.denote_visibility(id, self.visibility())); + utils::callback_with_source_location(ctx, id, item.location()); if let Some(layout) = layout { - semantic_annotations.layout(&layout); + ctx.options().for_each_callback(|cb| cb.denote_layout(id, &layout)); } - semantic_annotations.location(item.location()); if true { if let Some(explicit) = explicit_align { @@ -2559,32 +2552,6 @@ impl CodeGenerator for CompInfo { let is_rust_union = is_union && struct_layout.is_rust_union(); - ctx.options().for_each_callback(|cb| { - let discovered_item = match self.kind() { - CompKind::Struct => DiscoveredItem::Struct { - original_name: item - .kind() - .expect_type() - .name() - .map(String::from), - final_name: canonical_ident.to_string(), - }, - CompKind::Union => DiscoveredItem::Union { - original_name: item - .kind() - .expect_type() - .name() - .map(String::from), - final_name: canonical_ident.to_string(), - }, - }; - - cb.new_item_found( - DiscoveredItemId::new(item.id().as_usize()), - discovered_item, - ); - }); - // The custom derives callback may return a list of derive attributes; // add them to the end of the list. let custom_derives = ctx.options().all_callbacks(|cb| { @@ -2604,15 +2571,7 @@ impl CodeGenerator for CompInfo { attributes.push(attributes::derives(&derives)); } - if let Some(original_name) = item.original_name(ctx) { - if canonical_name != original_name { - let mut semantic_annotations = CppSemanticAttributeAdder::new( - ctx.options(), - &mut attributes, - ); - semantic_annotations.original_name(&original_name); - } - } + utils::callback_with_cpp_name(ctx, item, item.original_name(ctx).as_ref().map(String::as_str)); attributes.extend( item.annotations() @@ -2802,6 +2761,7 @@ impl CodeGenerator for CompInfo { &mut method_names, result, self, + id, ); } } @@ -2820,6 +2780,7 @@ impl CodeGenerator for CompInfo { &mut method_names, result, self, + id, ); } } @@ -2833,6 +2794,7 @@ impl CodeGenerator for CompInfo { &mut method_names, result, self, + id, ); } } @@ -3090,6 +3052,7 @@ impl Method { method_names: &mut HashSet, result: &mut CodegenResult<'_>, _parent: &CompInfo, + parent_id: DiscoveredItemId, ) { assert!({ let cc = &ctx.options().codegen_config; @@ -3110,6 +3073,7 @@ impl Method { // First of all, output the actual function. let function_item = ctx.resolve_item(self.signature()); + let id = DiscoveredItemId::new(function_item.id().as_usize()); if !function_item.process_before_codegen(ctx, result) { return; } @@ -3156,14 +3120,18 @@ impl Method { method_names.insert(name.clone()); + ctx.options().for_each_callback(|cb| cb.new_item_found(id, DiscoveredItem::Method { + parent: parent_id, + final_name: name.clone(), + })); + let mut function_name = function_item.canonical_name(ctx); if times_seen > 0 { write!(&mut function_name, "{times_seen}").unwrap(); } let function_name = ctx.rust_ident(function_name); - let (mut args, args_attributes) = - utils::fnsig_arguments(ctx, signature); - let (mut ret, ret_attr) = utils::fnsig_return_ty(ctx, signature); + let mut args = utils::fnsig_arguments(ctx, signature); + let mut ret = utils::fnsig_return_ty(ctx, signature); if !self.is_static() && !self.is_constructor() { args[0] = if self.is_const() { @@ -3239,9 +3207,7 @@ impl Method { let block = ctx.wrap_unsafe_ops(quote! ( #( #stmts );*)); - let mut attrs = args_attributes; - attrs.push(ret_attr); - attrs.push(attributes::inline()); + let mut attrs = vec![attributes::inline()]; if signature.must_use() { attrs.push(attributes::must_use()); @@ -3689,6 +3655,7 @@ impl CodeGenerator for Enum { let enum_ty = item.expect_type(); let layout = enum_ty.layout(ctx); let variation = self.computed_enum_variation(ctx, item); + let id = DiscoveredItemId::new(item.id().as_usize()); let repr_translated; let repr = match self.repr().map(|repr| ctx.resolve_type(repr)) { @@ -3750,15 +3717,10 @@ impl CodeGenerator for Enum { let mut attrs = vec![]; - let mut semantic_annotations = - CppSemanticAttributeAdder::new(ctx.options(), &mut attrs); - if let Some(original_name) = item.original_name(ctx) { - if name != original_name { - semantic_annotations.original_name(&original_name); - } - } - semantic_annotations.visibility(self.visibility); - semantic_annotations.location(item.location()); + utils::callback_with_cpp_name(ctx, item, item.original_name(ctx).as_ref().map(String::as_str)); + + ctx.options().for_each_callback(|cb| cb.denote_visibility(id, self.visibility)); + utils::callback_with_source_location(ctx, id, item.location()); // TODO(emilio): Delegate this to the builders? match variation { @@ -3871,16 +3833,24 @@ impl CodeGenerator for Enum { }); } - let repr = repr.to_rust_ty_or_opaque(ctx, item).ignore_annotations(); + let repr = repr.to_rust_ty_or_opaque(ctx, item); let has_typedef = ctx.is_enum_typedef_combo(item.id()); + ctx.options().for_each_callback(|cb| { + cb.new_item_found( + DiscoveredItemId::new(item.id().as_usize()), + DiscoveredItem::Enum { + final_name: name.to_string(), + }, + ); + }); + let mut builder = EnumBuilder::new(&name, attrs, repr, variation, has_typedef); // A map where we keep a value -> variant relation. let mut seen_values = HashMap::<_, Ident>::default(); - let enum_rust_ty = - item.to_rust_ty_or_opaque(ctx, &()).ignore_annotations(); + let enum_rust_ty = item.to_rust_ty_or_opaque(ctx, &()); let is_toplevel = item.is_toplevel(ctx); // Used to mangle the constants we generate in the unnamed-enum case. @@ -4168,9 +4138,9 @@ pub(crate) trait TryToOpaque { &self, ctx: &BindgenContext, extra: &Self::Extra, - ) -> error::Result { + ) -> error::Result { self.try_get_layout(ctx, extra) - .map(|layout| helpers::blob(ctx, layout, true).into()) + .map(|layout| helpers::blob(ctx, layout, true)) } } @@ -4216,7 +4186,7 @@ pub(crate) trait TryToRustTy { &self, ctx: &BindgenContext, extra: &Self::Extra, - ) -> error::Result; + ) -> error::Result; } /// Fallible conversion to a Rust type or an opaque blob with the correct size @@ -4231,7 +4201,7 @@ pub(crate) trait TryToRustTyOrOpaque: TryToRustTy + TryToOpaque { &self, ctx: &BindgenContext, extra: &::Extra, - ) -> error::Result; + ) -> error::Result; } impl TryToRustTyOrOpaque for T @@ -4244,10 +4214,10 @@ where &self, ctx: &BindgenContext, extra: &E, - ) -> error::Result { + ) -> error::Result { self.try_to_rust_ty(ctx, extra).or_else(|_| { if let Ok(layout) = self.try_get_layout(ctx, extra) { - Ok(helpers::blob(ctx, layout, true).into()) + Ok(helpers::blob(ctx, layout, true)) } else { Err(Error::NoLayoutForOpaqueBlob) } @@ -4279,7 +4249,7 @@ pub(crate) trait ToRustTyOrOpaque: TryToRustTy + ToOpaque { &self, ctx: &BindgenContext, extra: &::Extra, - ) -> RustTy; + ) -> syn::Type; } impl ToRustTyOrOpaque for T @@ -4288,9 +4258,13 @@ where { type Extra = E; - fn to_rust_ty_or_opaque(&self, ctx: &BindgenContext, extra: &E) -> RustTy { + fn to_rust_ty_or_opaque( + &self, + ctx: &BindgenContext, + extra: &E, + ) -> syn::Type { self.try_to_rust_ty(ctx, extra) - .unwrap_or_else(|_| RustTy::new_opaque(self.to_opaque(ctx, extra))) + .unwrap_or_else(|_| self.to_opaque(ctx, extra)) } } @@ -4319,7 +4293,7 @@ where &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { ctx.resolve_item((*self).into()).try_to_rust_ty(ctx, &()) } } @@ -4343,7 +4317,7 @@ impl TryToRustTy for Item { &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { self.kind().expect_type().try_to_rust_ty(ctx, self) } } @@ -4360,111 +4334,6 @@ impl TryToOpaque for Type { } } -enum RustTyAnnotation { - None, - Reference, - RValueReference, - HasUnusedTemplateArgs, - Opaque, -} - -pub(crate) struct RustTy { - ty: syn::Type, - annotation: RustTyAnnotation, -} - -impl From for RustTy { - fn from(ty: syn::Type) -> Self { - RustTy::new(ty) - } -} - -impl RustTy { - fn new(ty: syn::Type) -> Self { - Self { - ty, - annotation: RustTyAnnotation::None, - } - } - - fn new_opaque(ty: syn::Type) -> Self { - Self { - ty, - annotation: RustTyAnnotation::Opaque, - } - } - - fn new_reference( - ty: syn::Type, - inner: RustTyAnnotation, - ) -> Self { - let annotation = match inner { - RustTyAnnotation::HasUnusedTemplateArgs | - RustTyAnnotation::Opaque => inner, - _ => RustTyAnnotation::Reference, - }; - Self { ty, annotation } - } - - fn new_rvalue_reference( - ty: syn::Type, - inner: RustTyAnnotation, - ) -> Self { - let annotation = match inner { - RustTyAnnotation::HasUnusedTemplateArgs | - RustTyAnnotation::Opaque => inner, - _ => RustTyAnnotation::RValueReference, - }; - Self { ty, annotation } - } - - // We're constructing some outer type composed of an inner type, - // e.g. a reference to a T - the inner type is T - fn wraps(ty: syn::Type, inner: RustTyAnnotation) -> Self { - let annotation = match inner { - RustTyAnnotation::HasUnusedTemplateArgs => { - RustTyAnnotation::HasUnusedTemplateArgs - } - _ => RustTyAnnotation::None, - }; - Self { ty, annotation } - } - - fn with_unused_template_args( - ty: syn::Type, - has_unused_args: bool, - ) -> Self { - Self { - ty, - annotation: if has_unused_args { - RustTyAnnotation::HasUnusedTemplateArgs - } else { - RustTyAnnotation::None - }, - } - } - - // Where this is called, we're discarding information about whether - // a type is a reference or a pointer. This is not desirable. - fn ignore_annotations(self) -> syn::Type { - self.ty - } - - // Use when this is an inner type and will become part of an outer type. - // Pass the annotation into [wraps] - fn into_outer_type(self) -> (syn::Type, RustTyAnnotation) { - (self.ty, self.annotation) - } - - fn into_unannotated_ts(self) -> error::Result { - if matches!(self.annotation, RustTyAnnotation::None) { - Ok(self.ty) - } else { - Err(error::Error::ReferenceButCouldNotRecord) - } - } -} - impl TryToRustTy for Type { type Extra = Item; @@ -4472,50 +4341,50 @@ impl TryToRustTy for Type { &self, ctx: &BindgenContext, item: &Item, - ) -> error::Result { + ) -> error::Result { use self::helpers::ast_ty::*; match *self.kind() { - TypeKind::Void => Ok(c_void(ctx).into()), + TypeKind::Void => Ok(c_void(ctx)), // TODO: we should do something smart with nullptr, or maybe *const // c_void is enough? - TypeKind::NullPtr => Ok(c_void(ctx).to_ptr(true).into()), + TypeKind::NullPtr => Ok(c_void(ctx).to_ptr(true)), TypeKind::Int(ik) => { - Ok(int_kind_rust_type(ctx, ik, self.layout(ctx)).into()) + Ok(int_kind_rust_type(ctx, ik, self.layout(ctx))) } TypeKind::Float(fk) => { - Ok(float_kind_rust_type(ctx, fk, self.layout(ctx)).into()) + Ok(float_kind_rust_type(ctx, fk, self.layout(ctx))) } TypeKind::Complex(fk) => { let float_path = float_kind_rust_type(ctx, fk, self.layout(ctx)); ctx.generated_bindgen_complex(); - Ok(RustTy::new(if ctx.options().enable_cxx_namespaces { + Ok(if ctx.options().enable_cxx_namespaces { syn::parse_quote! { root::__BindgenComplex<#float_path> } } else { syn::parse_quote! { __BindgenComplex<#float_path> } - })) + }) } TypeKind::Function(ref signature) => { // We can't rely on the sizeof(Option>) == // sizeof(NonZero<_>) optimization with opaque blobs (because // they aren't NonZero), so don't *ever* use an or_opaque // variant here. - let ty = signature.try_to_rust_ty(ctx, item)?.into_unannotated_ts()?; + let ty = signature.try_to_rust_ty(ctx, item)?; let prefix = ctx.trait_prefix(); - Ok(RustTy::new(syn::parse_quote! { ::#prefix::option::Option<#ty> })) + Ok(syn::parse_quote! { ::#prefix::option::Option<#ty> }) } TypeKind::Array(item, len) | TypeKind::Vector(item, len) => { - let ty = item.try_to_rust_ty(ctx, &())?.into_unannotated_ts()?; - Ok(RustTy::new(syn::parse_quote! { [ #ty ; #len ] })) + let ty = item.try_to_rust_ty(ctx, &())?; + Ok(syn::parse_quote! { [ #ty ; #len ] }) } TypeKind::Enum(..) => { let path = item.namespace_aware_canonical_path(ctx); let path = proc_macro2::TokenStream::from_str(&path.join("::")) .unwrap(); - Ok(RustTy::new(syn::parse_quote!(#path))) + Ok(syn::parse_quote!(#path)) } TypeKind::TemplateInstantiation(ref inst) => { inst.try_to_rust_ty(ctx, item) @@ -4526,7 +4395,7 @@ impl TryToRustTy for Type { TypeKind::BlockPointer(..) => { if self.is_block_pointer() && !ctx.options().generate_block { let void = c_void(ctx); - return Ok(void.to_ptr(/* is_const = */ false).into()); + return Ok(void.to_ptr(/* is_const = */ false)); } let (used_template_params, _) = item.used_template_params(ctx); @@ -4539,9 +4408,9 @@ impl TryToRustTy for Type { .name() .and_then(|name| utils::type_from_named(ctx, name)) { - Ok(ty.into()) + Ok(ty) } else { - Ok(utils::build_path(item, ctx)?.into()) + utils::build_path(item, ctx) } } TypeKind::Comp(ref info) => { @@ -4552,7 +4421,7 @@ impl TryToRustTy for Type { return self.try_to_opaque(ctx, item); } - Ok(utils::build_path(item, ctx)?.into()) + utils::build_path(item, ctx) } TypeKind::Opaque => self.try_to_opaque(ctx, item), TypeKind::Pointer(inner) | TypeKind::Reference(inner, _) => { @@ -4567,10 +4436,6 @@ impl TryToRustTy for Type { } let is_const = ctx.resolve_type(inner).is_const(); - let is_reference = - matches!(self.kind(), TypeKind::Reference(_, false)); - let is_rvalue_reference = - matches!(self.kind(), TypeKind::Reference(_, true)); let inner = inner.into_resolver().through_type_refs().resolve(ctx); @@ -4582,37 +4447,39 @@ impl TryToRustTy for Type { // Regardless if we can properly represent the inner type, we // should always generate a proper pointer here, so use // infallible conversion of the inner type. - let (inner_ty_ty, inner_annotations) = inner + let inner_ty_ty = inner .to_rust_ty_or_opaque(ctx, &()) - .with_implicit_template_params(ctx, inner) - .into_outer_type(); + .with_implicit_template_params(ctx, inner); // Avoid the first function pointer level, since it's already // represented in Rust. if inner_ty.canonical_type(ctx).is_function() || is_objc_pointer { - Ok(RustTy::wraps(inner_ty_ty, inner_annotations)) + Ok(inner_ty_ty) } else { let ty_ptr = inner_ty_ty.to_ptr(is_const); - Ok(if is_rvalue_reference { - RustTy::new_rvalue_reference(ty_ptr, inner_annotations) - } else if is_reference { - RustTy::new_reference(ty_ptr, inner_annotations) + Ok(if let syn::Type::Ptr(ty_ptr_inside) = &ty_ptr { + // It always should be Type::Ptr, but just in case + if let TypeKind::Reference(_, rvalue) = self.kind() { + helpers::reference(ty_ptr_inside.clone(), *rvalue, ctx) + } else { + ty_ptr + } } else { - RustTy::wraps(ty_ptr, inner_annotations) + ty_ptr }) } } TypeKind::TypeParam => { let name = item.canonical_name(ctx); let ident = ctx.rust_ident(name); - Ok(RustTy::new(syn::parse_quote! { #ident })) + Ok(syn::parse_quote! { #ident }) } - TypeKind::ObjCSel => Ok(RustTy::new(syn::parse_quote! { objc::runtime::Sel })), - TypeKind::ObjCId => Ok(RustTy::new(syn::parse_quote! { id })), + TypeKind::ObjCSel => Ok(syn::parse_quote! { objc::runtime::Sel }), + TypeKind::ObjCId => Ok(syn::parse_quote! { id }), TypeKind::ObjCInterface(ref interface) => { let name = ctx.rust_ident(interface.name()); - Ok(RustTy::new(syn::parse_quote! { #name })) + Ok(syn::parse_quote! { #name }) } ref u @ TypeKind::UnresolvedTypeRef(..) => { unreachable!("Should have been resolved after parsing {u:?}!") @@ -4642,7 +4509,7 @@ impl TryToRustTy for TemplateInstantiation { &self, ctx: &BindgenContext, item: &Item, - ) -> error::Result { + ) -> error::Result { if self.is_opaque(ctx, item) { return Err(Error::InstantiationOfOpaqueType); } @@ -4688,8 +4555,7 @@ impl TryToRustTy for TemplateInstantiation { let arg = arg.into_resolver().through_type_refs().resolve(ctx); let ty = arg .try_to_rust_ty(ctx, &())? - .with_implicit_template_params(ctx, arg) - .into_unannotated_ts()?; + .with_implicit_template_params(ctx, arg); Ok(ty) }) .collect::>>()?; @@ -4699,11 +4565,16 @@ impl TryToRustTy for TemplateInstantiation { // Only pass type arguments for the type parameters that // the def uses. .any(|param| !ctx.uses_template_parameter(def.id(), *param)); - Ok(RustTy::with_unused_template_args(if template_args.is_empty() { + let inner = if template_args.is_empty() { syn::parse_quote! { #ty } } else { syn::parse_quote! { #ty<#(#template_args),*> } - }, has_unused_template_args)) + }; + Ok(if has_unused_template_args { + helpers::with_unused_template_args(inner, ctx) + } else { + inner + }) } } @@ -4714,17 +4585,15 @@ impl TryToRustTy for FunctionSig { &self, ctx: &BindgenContext, item: &Item, - ) -> error::Result { + ) -> error::Result { // TODO: we might want to consider ignoring the reference return value. - let (ret, _) = utils::fnsig_return_ty(ctx, self); - let (arguments, _) = utils::fnsig_arguments(ctx, self); + let ret = utils::fnsig_return_ty(ctx, self); + let arguments = utils::fnsig_arguments(ctx, self); match self.abi(ctx, None) { - Ok(abi) => { - let ty: syn::Type = syn::parse_quote! { unsafe extern #abi fn ( #( #arguments ),* ) #ret }; - Ok(ty.into() - , - )}, + Ok(abi) => Ok( + syn::parse_quote! { unsafe extern #abi fn ( #( #arguments ),* ) #ret }, + ), Err(err) => { if matches!(err, Error::UnsupportedAbi(_)) { unsupported_abi_diagnostic( @@ -4757,6 +4626,7 @@ impl CodeGenerator for Function { ) -> Self::Return { debug!("::codegen: item = {item:?}"); debug_assert!(item.is_enabled_for_codegen(ctx)); + let id = DiscoveredItemId::new(item.id().as_usize()); let is_internal = matches!(self.linkage(), Linkage::Internal); @@ -4787,6 +4657,12 @@ impl CodeGenerator for Function { } _ => false, }; + if is_pure_virtual && !ctx.options().generate_pure_virtuals { + // Pure virtual methods have no actual symbol, so we can't generate + // something meaningful for them. Downstream code postprocessors + // might want to find out about them. + return None; + } let is_virtual = matches!( self.kind(), @@ -4844,19 +4720,14 @@ impl CodeGenerator for Function { attributes.push(attributes::doc(comment)); } - let mut semantic_annotations = - CppSemanticAttributeAdder::new(ctx.options(), &mut attributes); - if is_pure_virtual { - semantic_annotations.is_pure_virtual(); + ctx.options().for_each_callback(|cb| cb.denote_virtualness(id, crate::callbacks::Virtualness::PureVirtual)); + } else if is_virtual { + ctx.options().for_each_callback(|cb| cb.denote_virtualness(id, crate::callbacks::Virtualness::Virtual)); } - if is_virtual { - semantic_annotations.is_virtual(); - } - - semantic_annotations.visibility(self.visibility()); - semantic_annotations.location(item.location()); + ctx.options().for_each_callback(|cb| cb.denote_visibility(id, self.visibility())); + utils::callback_with_source_location(ctx, id, item.location()); let abi = match signature.abi(ctx, Some(name)) { Err(err) => { @@ -4886,18 +4757,23 @@ impl CodeGenerator for Function { if times_seen > 0 { write!(&mut canonical_name, "{times_seen}").unwrap(); } - if canonical_name != self.name() { - semantic_annotations.original_name(self.name()); - } + ctx.options().for_each_callback(|cb| { + cb.new_item_found( + id, + DiscoveredItem::Function { + final_name: canonical_name.to_string(), + } + ); + }); + utils::callback_with_cpp_name(ctx, item, Some(&self.name())); if let Some(special_member_kind) = self.special_member() { - semantic_annotations.special_member(special_member_kind); + ctx.options().for_each_callback(|cb| cb.denote_special_member(id, special_member_kind)); } if self.deleted_fn() { - semantic_annotations.deleted_fn(); - } - if self.defaulted_fn() { - semantic_annotations.defaulted_fn(); + ctx.options().for_each_callback(|cb| cb.denote_explicit(id, Explicitness::Deleted)); + } else if self.defaulted_fn() { + ctx.options().for_each_callback(|cb| cb.denote_explicit(id, Explicitness::Defaulted)); } let mut has_link_name_attr = false; @@ -4940,7 +4816,7 @@ impl CodeGenerator for Function { None }; - let (ident, (args, args_attrs)) = if let Some(WrapAsVariadic { + let (ident, args) = if let Some(WrapAsVariadic { idx_of_va_list_arg, new_name, }) = &wrap_as_variadic @@ -4966,9 +4842,7 @@ impl CodeGenerator for Function { } else { (&canonical_name, utils::fnsig_arguments(ctx, signature)) }; - let (ret, ret_attr) = utils::fnsig_return_ty(ctx, signature); - attributes.extend(args_attrs.into_iter()); - attributes.push(ret_attr); + let ret = utils::fnsig_return_ty(ctx, signature); let ident = ctx.rust_ident(ident); @@ -5006,7 +4880,7 @@ impl CodeGenerator for Function { args, args_identifiers, ret, - ret_ty.0, + ret_ty, attributes, ctx, ); @@ -5126,9 +5000,8 @@ fn objc_method_codegen( } let signature = method.signature(); - let (fn_args, _) = utils::fnsig_arguments(ctx, signature); - let (fn_ret, _) = utils::fnsig_return_ty(ctx, signature); - // We disregard reference vs pointer attributes for objc methods for now. + let fn_args = utils::fnsig_arguments(ctx, signature); + let fn_ret = utils::fnsig_return_ty(ctx, signature); let sig = if method.is_class_method() { quote! { @@ -5439,12 +5312,10 @@ pub(crate) mod utils { use super::helpers::BITFIELD_UNIT; use super::serialize::CSerialize; use super::{ - error, CodegenError, CodegenResult, RustTy, RustTyAnnotation, + error, CodegenError, CodegenResult, ToRustTyOrOpaque, }; - use crate::codegen::helpers::{ - CppSemanticAttributeCreator, CppSemanticAttributeSingle, - }; + use crate::callbacks::DiscoveredItemId; use crate::ir::context::BindgenContext; use crate::ir::context::TypeId; use crate::ir::function::{Abi, ClangAbi, FunctionSig}; @@ -5931,9 +5802,9 @@ pub(crate) mod utils { fn fnsig_return_ty_internal( ctx: &BindgenContext, sig: &FunctionSig, - ) -> RustTy { + ) -> syn::Type { if sig.is_divergent() { - return RustTy::new(syn::parse_quote! { ! }); + return syn::parse_quote! { ! }; } let canonical_type_kind = sig @@ -5947,7 +5818,7 @@ pub(crate) mod utils { .kind(); match canonical_type_kind { - TypeKind::Void => RustTy::new(syn::parse_quote! { () }), + TypeKind::Void => syn::parse_quote! { () }, _ => sig.return_type().to_rust_ty_or_opaque(ctx, &()), } } @@ -5955,39 +5826,21 @@ pub(crate) mod utils { pub(crate) fn fnsig_return_ty( ctx: &BindgenContext, sig: &FunctionSig, - ) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) { - let (ret_ty, ret_ty_annotations) = fnsig_return_ty_internal(ctx, sig).into_outer_type(); - match ret_ty { + ) -> proc_macro2::TokenStream { + match fnsig_return_ty_internal(ctx, sig) { syn::Type::Tuple(syn::TypeTuple { elems, .. }) if elems.is_empty() => { - (quote! {}, quote! {}) - } - ty => { - let mut semantic_annotation = - CppSemanticAttributeSingle::new(ctx.options()); - match ret_ty_annotations { - super::RustTyAnnotation::None => {} - super::RustTyAnnotation::Reference => { - semantic_annotation.ret_type_reference() - } - super::RustTyAnnotation::RValueReference => { - semantic_annotation.ret_type_rvalue_reference() - } - super::RustTyAnnotation::HasUnusedTemplateArgs | - super::RustTyAnnotation::Opaque => { - semantic_annotation.incomprehensible_param_in_arg_or_return() - } - }; - (quote! { -> #ty }, semantic_annotation.result()) + quote! {} } + ty => quote! { -> #ty }, } } pub(crate) fn fnsig_argument_type( ctx: &BindgenContext, ty: &TypeId, - ) -> RustTy { + ) -> syn::Type { use super::ToPtr; let arg_item = ctx.resolve_item(ty); @@ -6008,10 +5861,8 @@ pub(crate) mod utils { } else { t.to_rust_ty_or_opaque(ctx, &()) }; - let (stream_ty, stream_annotations) = stream.into_outer_type(); - let stream_ty = stream_ty - .to_ptr(ctx.resolve_type(t).is_const() || arg_ty.is_const()); - RustTy::wraps(stream_ty, stream_annotations) + stream + .to_ptr(ctx.resolve_type(t).is_const() || arg_ty.is_const()) } TypeKind::Pointer(inner) => { let inner = ctx.resolve_item(inner); @@ -6020,7 +5871,7 @@ pub(crate) mod utils { *inner_ty.canonical_type(ctx).kind() { let name = ctx.rust_ident(interface.name()); - RustTy::new(syn::parse_quote! { #name }) + syn::parse_quote! { #name } } else { arg_item.to_rust_ty_or_opaque(ctx, &()) } @@ -6036,11 +5887,11 @@ pub(crate) mod utils { ctx: &BindgenContext, args_iter: I, is_variadic: bool, - ) -> (Vec, Vec) { + ) -> Vec { let mut unnamed_arguments = 0; - let mut args: (Vec, Vec) = args_iter + let mut args = args_iter .map(|(name, ty)| { - let arg_details = fnsig_argument_type(ctx, ty); + let arg_ty = fnsig_argument_type(ctx, ty); let arg_name = if let Some(ref name) = *name { ctx.rust_mangle(name).into_owned() @@ -6051,34 +5902,15 @@ pub(crate) mod utils { assert!(!arg_name.is_empty()); let arg_name = ctx.rust_ident(arg_name); - let mut semantic_annotation = - CppSemanticAttributeSingle::new(ctx.options()); - let (arg_ty, arg_annotation) = arg_details.into_outer_type(); - match arg_annotation { - RustTyAnnotation::None => {} - RustTyAnnotation::Reference => { - semantic_annotation.arg_type_reference(&arg_name) - } - RustTyAnnotation::RValueReference => { - semantic_annotation.arg_type_rvalue_reference(&arg_name) - } - RustTyAnnotation::HasUnusedTemplateArgs | - RustTyAnnotation::Opaque => semantic_annotation - .incomprehensible_param_in_arg_or_return(), - }; - ( - quote! { - #arg_name : #arg_ty - }, - semantic_annotation.result(), - ) + quote! { + #arg_name : #arg_ty + } }) - .unzip(); + .collect::>(); if is_variadic { - args.0.push(quote! { ... }); - args.1.push(quote! {}); + args.push(quote! { ... }); } args @@ -6087,7 +5919,7 @@ pub(crate) mod utils { pub(crate) fn fnsig_arguments( ctx: &BindgenContext, sig: &FunctionSig, - ) -> (Vec, Vec) { + ) -> Vec { fnsig_arguments_iter( ctx, sig.argument_types().iter(), @@ -6130,10 +5962,10 @@ pub(crate) mod utils { let args = sig.argument_types().iter().map(|&(_, ty)| { let arg_item = ctx.resolve_item(ty); - arg_item.to_rust_ty_or_opaque(ctx, &()).ignore_annotations() + arg_item.to_rust_ty_or_opaque(ctx, &()) }); - let ret_ty = fnsig_return_ty_internal(ctx, sig).ignore_annotations(); + let ret_ty = fnsig_return_ty_internal(ctx, sig); quote! { *const ::block::Block<(#(#args,)*), #ret_ty> } @@ -6213,4 +6045,54 @@ pub(crate) mod utils { true } + + pub(super) fn callback_with_source_location(ctx: &BindgenContext, id: DiscoveredItemId, clang_location: Option<&crate::clang::SourceLocation>) { + if let Some(clang_location) = clang_location { + // Convert from the clang SourceLocation to a callback-safe version. + let (file, line, col, byte_offset) = clang_location.location(); + let file_name = file.name(); + let location = crate::callbacks::SourceLocation { + line, + col, + byte_offset, + file_name, + }; + ctx.options().for_each_callback(|cb| cb.denote_source_location(id, &location)); + } + } + + pub(super) fn callback_with_cpp_name(ctx: &BindgenContext, item: &Item, original_name: Option<&str>) { + ctx.options().for_each_callback(|cb| cb.denote_cpp_name(DiscoveredItemId::new(item.id().as_usize()), original_name, find_reportable_parent_mod(ctx, item))); + } + + /// Identify a suitable parent, the details of which will have + /// been passed to `ParseCallbacks`. We don't inform `ParseCallbacks` + /// about everything - notably, not inline namespaces - and we always + /// want to ensure that the `parent_id`` we report in a couple of + /// callbacks always corresponds to a namespace/mod which we'll have + /// told the client about. This function hops back through the parent + /// chain until it finds a reportabl ID. + pub(super) fn find_reportable_parent_mod(ctx: &BindgenContext, item: &Item) -> Option { + let mut parent_item = ctx.resolve_item(item.parent_id()); + while !is_reportable_module(&parent_item) { + let parent_id = parent_item.parent_id(); + if parent_id == parent_item.id() { + return None; + } + parent_item = ctx.resolve_item(parent_id); + } + Some(DiscoveredItemId::new(parent_item.id().as_usize())) + } + + /// For the sake of callbacks, we want to report full-fat namespaces + /// rather than inline namespaces or other layers of parentage such + /// as struct. + fn is_reportable_module(item: &Item) -> bool { + if item.is_module() { + let item_mod = item.as_module().unwrap(); + !item_mod.is_inline() + } else { + false + } + } } diff --git a/bindgen/ir/comp.rs b/bindgen/ir/comp.rs index 3cff25d49d..0e569b48c9 100644 --- a/bindgen/ir/comp.rs +++ b/bindgen/ir/comp.rs @@ -74,15 +74,20 @@ impl MethodKind { } } -// The kind of C++ special member. +/// The kind of C++ special member. // TODO: We don't currently cover copy assignment or move assignment operator // because libclang doesn't provide a way to query for them. #[derive(Debug, Copy, Clone, PartialEq)] pub enum SpecialMemberKind { + /// The default constructor. DefaultConstructor, + /// A copy constructor. CopyConstructor, + /// A move constructor. MoveConstructor, + /// A destructor. Destructor, + /// The assignment operator. AssignmentOperator, } diff --git a/bindgen/ir/function.rs b/bindgen/ir/function.rs index d6a9e4cdfc..7be4f50fa5 100644 --- a/bindgen/ir/function.rs +++ b/bindgen/ir/function.rs @@ -72,11 +72,14 @@ pub(crate) enum Linkage { Internal, } -/// Visibility +/// C++ visibility. #[derive(Debug, Clone, Copy)] pub enum Visibility { + /// `public` visibility. Public, + /// `protected` visibility. Protected, + /// `private` visibility. Private, } @@ -524,6 +527,15 @@ impl FunctionSig { let spelling = cursor.spelling(); + // Don't parse operatorxx functions in C++ + let is_operator = |spelling: &str| { + spelling.starts_with("operator") && + !clang::is_valid_identifier(spelling) + }; + if is_operator(&spelling) && !ctx.options().represent_cxx_operators { + return Err(ParseError::Continue); + } + // Constructors of non-type template parameter classes for some reason // include the template parameter in their name. Just skip them, since // we don't handle well non-type template parameters anyway. @@ -821,6 +833,9 @@ impl ClangSubItemParser for Function { if visibility != CXVisibility_Default { return Err(ParseError::Continue); } + if cursor.access_specifier() == CX_CXXPrivate && !context.options().generate_private_functions { + return Err(ParseError::Continue); + } let visibility = Visibility::from(cursor.access_specifier()); @@ -840,6 +855,10 @@ impl ClangSubItemParser for Function { return Err(ParseError::Continue); } + if cursor.is_deleted_function() && !context.options().generate_deleted_functions { + return Err(ParseError::Continue); + } + // We cannot handle `inline` functions that are not `static`. if context.options().wrap_static_fns && cursor.is_inlined_function() && @@ -883,14 +902,18 @@ impl ClangSubItemParser for Function { // We can't represent operatorxx functions as-is because // they are not valid identifiers if context.options().represent_cxx_operators { - let (new_suffix, special_member) = match operator_suffix { - "=" => ("equals", SpecialMemberKind::AssignmentOperator), + let (new_name, special_member) = match operator_suffix { + "=" => ("operator_equals", Some(SpecialMemberKind::AssignmentOperator)), + _ if clang::is_valid_identifier(&name) => (name.as_str(), None), _ => return Err(ParseError::Continue), }; - name = format!("operator_{}", new_suffix); - Some(special_member) + name = new_name.to_string(); + special_member } else { - return Err(ParseError::Continue); + // Without 'represent_cxx_operators' enabled, we will have already rejected + // troublesomely-named operators; any left over from this point are + // something like operator_information and are thus harmless. + None } } else { None diff --git a/bindgen/options/cli.rs b/bindgen/options/cli.rs index 1a17695946..37a74af0fd 100644 --- a/bindgen/options/cli.rs +++ b/bindgen/options/cli.rs @@ -1,6 +1,5 @@ #![allow(unused_qualifications)] // Clap somehow generates a lot of these -use autocxx_bindgen as bindgen; use crate::{ builder, callbacks::{ @@ -253,7 +252,7 @@ struct BindgenCommand { /// Avoid including doc comments in the output, see: #[arg(long)] no_doc_comments: bool, - /// Disable allowlisting types recursively. This will cause bindgen to emit Rust code that won't compile! See the `bindgen::Builder::allowlist_recursively` method's documentation for details. + /// Disable allowlisting types recursively. This will cause bindgen to emit Rust code that won't compile! See the `autocxx_bindgen::Builder::allowlist_recursively` method's documentation for details. #[arg(long)] no_recursive_allowlist: bool, /// Use extern crate instead of use for objc. @@ -448,10 +447,6 @@ struct BindgenCommand { /// Output C++ overloaded operators #[arg(long)] represent_cxx_operators: bool, - /// Output additional attributes denoting the intende semantics of each C++ function and type. - /// Useful for downstream code generators. - #[arg(long)] - cpp_semantic_attributes: bool, /// Use distinct char16_t #[arg(long)] use_distinct_char16_t: bool, @@ -645,7 +640,6 @@ where explicit_padding, use_specific_virtual_function_receiver, represent_cxx_operators, - cpp_semantic_attributes, use_distinct_char16_t, vtable_generation, sort_semantically, @@ -944,6 +938,9 @@ where translate_enum_integer_types, c_naming, explicit_padding, + use_specific_virtual_function_receiver, + represent_cxx_operators, + use_distinct_char16_t, vtable_generation, sort_semantically, merge_extern_blocks, diff --git a/bindgen/options/mod.rs b/bindgen/options/mod.rs index 2d998e941b..a43127b972 100644 --- a/bindgen/options/mod.rs +++ b/bindgen/options/mod.rs @@ -168,19 +168,6 @@ options! { as_args: "--use-specific-virtual-function-receiver", }, - /// Whether we should emit C++ semantics attributes. - cpp_semantic_attributes: bool { - methods: { - /// If this is true, add attributes with details of underlying C++ semantics. - /// Disabled by default. - pub fn cpp_semantic_attributes(mut self, doit: bool) -> Builder { - self.options.cpp_semantic_attributes = doit; - self - } - }, - as_args: "--cpp-semantic-attributes", - }, - /// Whether we should output information about C++ overloaded operators. represent_cxx_operators: bool { methods: { @@ -208,6 +195,79 @@ options! { as_args: "--use-distinct-char16-t", }, + /// Use a newtype wrapper to clearly denote "opaque" types; that is, + /// types where bindgen has generated a type matching the size and + /// alignment of the C++ type but without any knowledge of what's + /// inside it. The newtype wrapper will be a fake type called + /// `bindgen_marker_Opaque`. It's assumed that you will replace this with some + /// real sensible newtype wrapper of your own, either by post-processing + /// the output of bindgen, or by using a `use` statemet injected using + /// `--module-raw-lines` or similar. + use_opaque_newtype_wrapper: bool { + methods: { + /// If this is true, wrap opaque types in a fake newtype + /// wrapper which post-processors can replace with something + /// more sensible. + pub fn use_opaque_newtype_wrapper(mut self, doit: bool) -> Builder { + self.options.use_opaque_newtype_wrapper = doit; + self + } + }, + as_args: "--use-opaque-newtype-wrapper", + }, + + /// Use a newtype wrapper to clearly denote C++ reference types. + /// These are always generated as raw Rust pointers, and so otherwise + /// there's no way to distinguish references from pointers. + /// The newtype wrapper will be a fake type either called + /// `bindgen_marker_Reference` or `bindgen_marker_RVAlueReference`. + /// It's assumed that you will replace this with some + /// real sensible newtype wrapper of your own, either by post-processing + /// the output of bindgen, or by using a `use` statemet injected using + /// `--module-raw-lines` or similar. + use_reference_newtype_wrapper: bool { + methods: { + /// If this is true, wrap C++ references in a fake newtype + /// wrapper which post-processors can replace with something + /// more sensible. + pub fn use_reference_newtype_wrapper(mut self, doit: bool) -> Builder { + self.options.use_reference_newtype_wrapper = doit; + self + } + }, + as_args: "--use-reference-newtype-wrapper", + }, + + /// Use a newtype wrapper to denote types with "missing" C++ template + /// arguments. Sometimes bindgen is unable to see the purpose of + /// a given template argument, because it doesn't translate to + /// a real purpose in the generated Rust code (e.g. for SFINAE type + /// tricks for compile-time evaluation on the C++ side). Bindgen + /// thus omits these template parameters. But this can cause problems + /// for postprocessors which expect to see all template parameters; + /// when this option is enabled we denote these types using a newtype + /// wrapper. + /// The newtype wrapper will be a fake type called + /// `bindgen_marker_MissingTemplateParam`. + /// It's assumed that you will replace this with some + /// real sensible newtype wrapper of your own, either by post-processing + /// the output of bindgen, or by using a `use` statemet injected using + /// `--module-raw-lines` or similar. + use_unused_template_param_newtype_wrapper: bool { + methods: { + /// If this is true, wrap types that don't have a complete set + /// of template parameters in a fake newtype + /// wrapper which post-processors can replace with something + /// more sensible. + pub fn use_unused_template_param_newtype_wrapper(mut self, doit: bool) -> Builder { + self.options.use_unused_template_param_newtype_wrapper = doit; + self + } + }, + as_args: "--use-unused-template-param-newtype-wrapper", + }, + + /// Types that have been blocklisted and should not appear anywhere in the generated code. blocklisted_types: RegexSet { methods: { @@ -2221,4 +2281,52 @@ options! { }, as_args: "--clang-macro-fallback-build-dir", } + /// Whether to always report C++ "deleted" functions. + generate_deleted_functions: bool { + methods: { + /// Set whether to generate C++ functions even marked "=deleted" + /// + /// Although not useful to call these functions, downstream code + /// generators may need to know whether they've been deleted in + /// order to determine the relocatability of a C++ type. + pub fn generate_deleted_functions(mut self, doit: bool) -> Self { + self.options.generate_deleted_functions = doit; + self + } + + }, + as_args: "--respect-cxx-access-specs", + }, + /// Whether to always report C++ "pure virtual" functions. + generate_pure_virtuals: bool { + methods: { + /// Set whether to generate C++ functions that are pure virtual. + /// + /// These functions can't be called, so the only reason + /// to generate them is if downstream postprocessors + /// need to know of their existence. + pub fn generate_pure_virtuals(mut self, doit: bool) -> Self { + self.options.generate_pure_virtuals = doit; + self + } + + }, + as_args: "--generate-pure-virtuals", + }, + /// Whether to always report C++ "private" functions. + generate_private_functions: bool { + methods: { + /// Set whether to generate C++ functions that are private. + /// + /// These functions can't be called, so the only reason + /// to generate them is if downstream postprocessors + /// need to know of their existence. + pub fn generate_private_functions(mut self, doit: bool) -> Self { + self.options.generate_private_functions = doit; + self + } + + }, + as_args: "--generate-private-functions", + }, }