Skip to content

Commit

Permalink
Merge pull request #1330 from google/subclass-opaque
Browse files Browse the repository at this point in the history
Test behavior when subclassing something that depends on opaque types
  • Loading branch information
adetaylor authored Sep 12, 2023
2 parents 762dbf3 + 2e84300 commit e8012a0
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions integration-tests/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7771,6 +7771,58 @@ fn test_pv_subclass_ptr_param() {
);
}

#[test]
fn test_pv_subclass_opaque_param() {
let hdr = indoc! {"
#include <cstdint>
typedef uint32_t MyUnsupportedType[4];
struct MySupportedType {
uint32_t a;
};
class MySuperType {
public:
virtual void foo(const MyUnsupportedType* foo, const MySupportedType* bar) const = 0;
virtual ~MySuperType() = default;
};
"};
run_test_ex(
"",
hdr,
quote! {
MySubType::new_rust_owned(MySubType { a: 3, cpp_peer: Default::default() });
},
quote! {
subclass!("MySuperType",MySubType)
extern_cpp_opaque_type!("MyUnsupportedType", crate::ffi2::MyUnsupportedType)
},
None,
None,
Some(quote! {

#[cxx::bridge]
pub mod ffi2 {
unsafe extern "C++" {
include!("input.h");
type MyUnsupportedType;
}
}
use autocxx::subclass::CppSubclass;
use ffi::MySuperType_methods;
#[autocxx::subclass::subclass]
pub struct MySubType {
a: u32
}
impl MySuperType_methods for MySubType {
unsafe fn foo(&self, _foo: *const ffi2::MyUnsupportedType, _bar: *const ffi::MySupportedType) {
}
}
}),
);
}

#[test]
fn test_pv_subclass_return() {
let hdr = indoc! {"
Expand Down

0 comments on commit e8012a0

Please sign in to comment.