- if "LDK" + optional_ty in self.trait_structs:
- base_conv += "\nif (" + ty_info.var_name + "_conv.tag == " + ty_info.rust_obj + "_Some) {"
- base_conv += "\n\t// Manually implement clone for Java trait instances"
- optional_ty_info = self.java_c_types("LDK" + optional_ty + " " + ty_info.var_name, None)
- base_conv += self.consts.trait_struct_inc_refcnt(optional_ty_info).\
- replace("\n", "\n\t").replace(ty_info.var_name + "_conv", ty_info.var_name + "_conv.some")
- base_conv += "\n}"
- ret_conv = ("uint64_t " + ty_info.var_name + "_ref = ((uint64_t)&", ") | 1;")
+ assert "LDK" + optional_ty in self.trait_structs # We don't support contained traits for anything else yet
+ to_hu_conv_sfx = self.consts.add_ref("this", ty_info.var_name)
+ base_conv += "\nif (" + ty_info.var_name + "_conv.tag == " + ty_info.rust_obj + "_Some) {"
+ base_conv += "\n\t// Manually implement clone for Java trait instances"
+ optional_ty_info = self.java_c_types("LDK" + optional_ty + " " + ty_info.var_name, None)
+ base_conv += self.consts.trait_struct_inc_refcnt(optional_ty_info).\
+ replace("\n", "\n\t").replace(ty_info.var_name + "_conv", ty_info.var_name + "_conv.some")
+ base_conv += "\n}"
+ ret_conv = (self.consts.ptr_c_ty + " " + ty_info.var_name + "_ref = ((uintptr_t)&", ") | 1;")