Skip to content

Commit e8012a0

Browse files
authored
Merge pull request #1330 from google/subclass-opaque
Test behavior when subclassing something that depends on opaque types
2 parents 762dbf3 + 2e84300 commit e8012a0

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

integration-tests/tests/integration_test.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7771,6 +7771,58 @@ fn test_pv_subclass_ptr_param() {
77717771
);
77727772
}
77737773

7774+
#[test]
7775+
fn test_pv_subclass_opaque_param() {
7776+
let hdr = indoc! {"
7777+
#include <cstdint>
7778+
7779+
typedef uint32_t MyUnsupportedType[4];
7780+
7781+
struct MySupportedType {
7782+
uint32_t a;
7783+
};
7784+
7785+
class MySuperType {
7786+
public:
7787+
virtual void foo(const MyUnsupportedType* foo, const MySupportedType* bar) const = 0;
7788+
virtual ~MySuperType() = default;
7789+
};
7790+
"};
7791+
run_test_ex(
7792+
"",
7793+
hdr,
7794+
quote! {
7795+
MySubType::new_rust_owned(MySubType { a: 3, cpp_peer: Default::default() });
7796+
},
7797+
quote! {
7798+
subclass!("MySuperType",MySubType)
7799+
extern_cpp_opaque_type!("MyUnsupportedType", crate::ffi2::MyUnsupportedType)
7800+
},
7801+
None,
7802+
None,
7803+
Some(quote! {
7804+
7805+
#[cxx::bridge]
7806+
pub mod ffi2 {
7807+
unsafe extern "C++" {
7808+
include!("input.h");
7809+
type MyUnsupportedType;
7810+
}
7811+
}
7812+
use autocxx::subclass::CppSubclass;
7813+
use ffi::MySuperType_methods;
7814+
#[autocxx::subclass::subclass]
7815+
pub struct MySubType {
7816+
a: u32
7817+
}
7818+
impl MySuperType_methods for MySubType {
7819+
unsafe fn foo(&self, _foo: *const ffi2::MyUnsupportedType, _bar: *const ffi::MySupportedType) {
7820+
}
7821+
}
7822+
}),
7823+
);
7824+
}
7825+
77747826
#[test]
77757827
fn test_pv_subclass_return() {
77767828
let hdr = indoc! {"

0 commit comments

Comments
 (0)