Skip to content

Commit 6dd9c2e

Browse files
committed
[bindings] Be explicit when calling trait methods in generated code
For ChannelManager, at least, we have two separate functions called block_connected, one in the Listen trait, one in the struct, we need to be explicit with which one we're trying to call.
1 parent c21b866 commit 6dd9c2e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

c-bindings-gen/src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,16 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
835835
takes_self = true;
836836
}
837837
}
838+
839+
let mut t_gen_args = String::new();
840+
for (idx, _) in $trait.generics.params.iter().enumerate() {
841+
if idx != 0 { t_gen_args += ", " };
842+
t_gen_args += "_"
843+
}
838844
if takes_self {
839-
write!(w, "unsafe {{ &mut *(this_arg as *mut native{}) }}.{}(", ident, $m.sig.ident).unwrap();
845+
write!(w, "<native{} as {}TraitImport<{}>>::{}(unsafe {{ &mut *(this_arg as *mut native{}) }}, ", ident, $trait.ident, t_gen_args, $m.sig.ident, ident).unwrap();
840846
} else {
841-
write!(w, "{}::{}::{}(", types.orig_crate, resolved_path, $m.sig.ident).unwrap();
847+
write!(w, "<native{} as {}TraitImport<{}>>::{}(", ident, $trait.ident, t_gen_args, $m.sig.ident).unwrap();
842848
}
843849

844850
let mut real_type = "".to_string();

0 commit comments

Comments
 (0)