Skip to content

Commit

Permalink
support methods again
Browse files Browse the repository at this point in the history
  • Loading branch information
cpetig committed Apr 22, 2024
1 parent f1a0e9f commit 685d5cc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,14 +2362,16 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
let op = &operands[0];
results.push(format!("{op}.get_handle()"));
}
abi::Instruction::HandleLift { .. } => {
// does it make a difference whether we own or borrow?
// if so we could look at handle
abi::Instruction::HandleLift { handle, .. } => {
let op = &operands[0];
if self.gen.gen.opts.host_side() {
results.push(format!("wit::ResourceExportBase{{{op}}}"));
} else {
results.push(format!("wit::ResourceImportBase{{{op}}}"));
match (handle, self.gen.gen.opts.host_side()) {
(Handle::Own(_), true) => {
results.push(format!("wit::{RESOURCE_EXPORT_BASE_CLASS_NAME}{{{op}}}"))
}
(Handle::Own(_), false) => {
results.push(format!("wit::{RESOURCE_IMPORT_BASE_CLASS_NAME}{{{op}}}"))
}
(Handle::Borrow(_), _) => results.push(op.clone()),
}
}
abi::Instruction::TupleLower { tuple, .. } => {
Expand Down

0 comments on commit 685d5cc

Please sign in to comment.