Skip to content

Commit

Permalink
replace dtor by res-drop (still wrong contents)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpetig committed Jul 12, 2024
1 parent eb09bf1 commit 3658850
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,17 @@ impl CppInterfaceGenerator<'_> {
symbol_variant = AbiVariant::GuestImport;
}
}
let func_name = if self.gen.opts.symmetric && matches!(is_drop, SpecialMethod::Dtor) {
// replace [dtor] with [resource_drop]
format!("[resource_drop]{}", &func.name[6..])
} else {
func.name.clone()
};
if self.gen.opts.short_cut {
uwrite!(self.gen.c_src.src, "extern \"C\" ");
} else if self.gen.opts.host {
self.gen.c_src.src.push_str("static ");
} else {
let func_name = &func.name;
let module_prefix = module_name.as_ref().map_or(String::default(), |name| {
let mut res = name.clone();
res.push('#');
Expand All @@ -1078,8 +1083,8 @@ impl CppInterfaceGenerator<'_> {
});
self.gen.c_src.src.push_str(" ");
let export_name = match module_name {
Some(ref module_name) => make_external_symbol(&module_name, &func.name, symbol_variant),
None => make_external_component(&func.name),
Some(ref module_name) => make_external_symbol(&module_name, &func_name, symbol_variant),
None => make_external_component(&func_name),
};
self.gen.c_src.src.push_str(&export_name);
self.gen.c_src.src.push_str("(");
Expand Down Expand Up @@ -1116,7 +1121,7 @@ impl CppInterfaceGenerator<'_> {
if self.gen.opts.host_side() {
let signature = wamr::wamr_signature(self.resolve, func);
let remember = HostFunction {
wasm_name: func.name.clone(),
wasm_name: func_name.clone(),
wamr_signature: signature.to_string(),
host_name: export_name.clone(),
};
Expand Down

0 comments on commit 3658850

Please sign in to comment.