Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 12 additions & 6 deletions engine/src/conversion/codegen_cpp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,22 @@ impl<'a> CppCodeGenerator<'a> {
}
},
CppFunctionBody::StaticMethodCall(ns, ty_id, fn_id) => {
// handle nested struct: A_B -> A::B
let full_name = QualifiedName::new(ns, ty_id.clone());

let ty_path = self
.original_name_map
.get(&full_name)
.map(|name| name.to_string())
.unwrap_or_else(|| ty_id.to_string());

let underlying_function_call = ns
.into_iter()
.cloned()
.chain(
[
ty_id.to_string(),
fn_id.to_string_for_cpp_generation().to_string(),
]
.iter()
.cloned(),
[ty_path, fn_id.to_string_for_cpp_generation().to_string()]
.iter()
.cloned(),
)
.join("::");
(
Expand Down
15 changes: 15 additions & 0 deletions integration-tests/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,21 @@ fn test_nested_with_destructor() {
run_test("", hdr, rs, &["A", "A_B"], &[]);
}

#[test]
fn test_nested_with_static_call() {
let hdr = indoc! {"
struct A {
struct B {
static void f() {}
};
};
"};
let rs = quote! {
ffi::A_B::new().within_unique_ptr();
};
run_test("", hdr, rs, &["A", "A_B"], &[]);
}

// Even without a `safety!`, we still need to generate a safe `fn drop`.
#[test]
fn test_destructor_no_safety() {
Expand Down