def map_type(self, fn_arg, print_void, ret_arr_len, is_free, holds_ref):
ty_info = self.java_c_types(fn_arg, ret_arr_len)
- return self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref)
+ mapped_info = self.map_type_with_info(ty_info, print_void, ret_arr_len, is_free, holds_ref)
+ return mapped_info
def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_ref):
if ty_info.c_ty == "void":
if needs_full_clone and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns:
base_conv = base_conv + "\n" + ty_info.var_name + "_conv = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");"
else:
- base_conv = base_conv + "\nif (" + ty_info.var_name + "_conv.free == " + ty_info.rust_obj + "_JCalls_free) {\n"
- base_conv = base_conv + "\t// If this_arg is a JCalls struct, then we need to increment the refcnt in it.\n"
- base_conv = base_conv + "\t" + ty_info.rust_obj + "_JCalls_clone(" + ty_info.var_name + "_conv.this_arg);\n}"
+ base_conv = base_conv + self.consts.trait_struct_inc_refcnt(ty_info)
if needs_full_clone:
base_conv = base_conv + "// Warning: we may need a move here but can't do a full clone!\n"