From 2ded089f793d99e642bbf9eb12d3bf1dbf6747f7 Mon Sep 17 00:00:00 2001 From: Rodrigo Rivas Costa Date: Wed, 18 Oct 2023 16:43:54 +0200 Subject: [PATCH] Add a thiscall_abi test for stable Rust 1.73. --- .../expectations/tests/win32-thiscall_1_73.rs | 41 +++++++++++++++++++ .../tests/headers/win32-thiscall_1_73.hpp | 7 ++++ 2 files changed, 48 insertions(+) create mode 100644 bindgen-tests/tests/expectations/tests/win32-thiscall_1_73.rs create mode 100644 bindgen-tests/tests/headers/win32-thiscall_1_73.hpp diff --git a/bindgen-tests/tests/expectations/tests/win32-thiscall_1_73.rs b/bindgen-tests/tests/expectations/tests/win32-thiscall_1_73.rs new file mode 100644 index 0000000000..2faedf1814 --- /dev/null +++ b/bindgen-tests/tests/expectations/tests/win32-thiscall_1_73.rs @@ -0,0 +1,41 @@ +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![cfg(target = "i686-pc-windows-msvc")] +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Foo { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_Foo() { + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(Foo)), + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(Foo)), + ); +} +extern "thiscall" { + #[link_name = "\u{1}?test@Foo@@QAEXXZ"] + pub fn Foo_test(this: *mut Foo); +} +extern "thiscall" { + #[link_name = "\u{1}?test2@Foo@@QAEHH@Z"] + pub fn Foo_test2( + this: *mut Foo, + var: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +impl Foo { + #[inline] + pub unsafe fn test(&mut self) { + Foo_test(self) + } + #[inline] + pub unsafe fn test2(&mut self, var: ::std::os::raw::c_int) -> ::std::os::raw::c_int { + Foo_test2(self, var) + } +} diff --git a/bindgen-tests/tests/headers/win32-thiscall_1_73.hpp b/bindgen-tests/tests/headers/win32-thiscall_1_73.hpp new file mode 100644 index 0000000000..8c240055b2 --- /dev/null +++ b/bindgen-tests/tests/headers/win32-thiscall_1_73.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --rust-target=1.73 --raw-line '#![cfg(target = "i686-pc-windows-msvc")]' -- --target=i686-pc-windows-msvc + +class Foo { + public: + void test(); + int test2(int var); +};