Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test behavior when subclassing something that depends on opaque types #1330

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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