diff --git a/engine/src/conversion/codegen_cpp/mod.rs b/engine/src/conversion/codegen_cpp/mod.rs index 02c494f95..c7817819d 100644 --- a/engine/src/conversion/codegen_cpp/mod.rs +++ b/engine/src/conversion/codegen_cpp/mod.rs @@ -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("::"); ( diff --git a/integration-tests/tests/integration_test.rs b/integration-tests/tests/integration_test.rs index 9d6590023..58947e314 100644 --- a/integration-tests/tests/integration_test.rs +++ b/integration-tests/tests/integration_test.rs @@ -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() {