Skip to content

Commit

Permalink
autocxx: Generate impls for abstract types too
Browse files Browse the repository at this point in the history
Backport of google/autocxx#1137.

Change-Id: I80e69a93880adf3f907078a55fbdb4e99f15ff2b
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
  • Loading branch information
bsilver8192 committed Aug 15, 2022
1 parent 0562f0f commit 0d1d5d9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ impl<'a> RsCodeGenerator<'a> {
extern_c_mod_items: vec![
self.generate_cxxbridge_type(name, false, doc_attrs)
],
bridge_items: create_impl_items(&id, movable, destroyable, self.config),
bindgen_mod_items,
materializations,
..Default::default()
Expand Down
37 changes: 37 additions & 0 deletions third_party/autocxx/integration-tests/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9429,6 +9429,43 @@ fn test_abstract_up() {
run_test("", hdr, rs, &["A", "get_a"], &[]);
}

#[test]
fn test_abstract_up_multiple_bridge() {
let hdr = indoc! {"
#include <memory>
class A {
public:
virtual void foo() const = 0;
virtual ~A() {}
};
class B : public A {
public:
void foo() const {}
};
inline std::unique_ptr<A> get_a() { return std::make_unique<B>(); }
"};
let hexathorpe = Token![#](Span::call_site());
let rs = quote! {
autocxx::include_cpp! {
#hexathorpe include "input.h"
safety!(unsafe_ffi)
generate!("A")
}
autocxx::include_cpp! {
#hexathorpe include "input.h"
safety!(unsafe_ffi)
name!(ffi2)
extern_cpp_type!("A", crate::ffi::A)
generate!("get_a")
}
fn main() {
let a = ffi2::get_a();
a.foo();
}
};
do_run_test_manual("", hdr, rs, None, None).unwrap();
}

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

0 comments on commit 0d1d5d9

Please sign in to comment.