@@ -240,6 +240,7 @@ def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_re
240240 if (ty_info .rust_obj .replace ("LDK" , "" ) + "_clone" ) in self .clone_fns :
241241 # TODO: This is a bit too naive, even with the checks above, we really need to know if rust wants a ref or not, not just if its pass as a ptr.
242242 opaque_arg_conv = opaque_arg_conv + "\n " + ty_info .var_name + "_conv = " + ty_info .rust_obj .replace ("LDK" , "" ) + "_clone(&" + ty_info .var_name + "_conv);"
243+ from_hu_conv = (from_hu_conv [0 ], "" )
243244 elif ty_info .passed_as_ptr :
244245 opaque_arg_conv = opaque_arg_conv + "\n // Warning: we need a move here but no clone is available for " + ty_info .rust_obj
245246 # TODO: Once we support features cloning (which just isn't in C yet), we can make this a compile error instead!
@@ -422,17 +423,19 @@ def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_re
422423 assert (not is_free )
423424 if ty_info .rust_obj in self .complex_enums :
424425 ret_conv = ("uint64_t ret_" + ty_info .var_name + " = (uint64_t)" , " | 1; // Warning: We should clone here!" )
426+ from_hu_sfx = "this.ptrs_to.add(" + ty_info .var_name + ")"
425427 if ty_info .rust_obj .replace ("LDK" , "" ) + "_clone" in self .clone_fns :
426428 ret_conv_pfx = ty_info .rust_obj + " *ret_" + ty_info .var_name + " = MALLOC(sizeof(" + ty_info .rust_obj + "), \" " + ty_info .rust_obj + " ret conversion\" );\n "
427429 ret_conv_pfx += "*ret_" + ty_info .var_name + " = " + ty_info .rust_obj .replace ("LDK" , "" ) + "_clone("
428430 ret_conv = (ret_conv_pfx , ");" )
431+ from_hu_sfx = ""
429432 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
430433 arg_conv = ty_info .rust_obj + "* " + ty_info .var_name + "_conv = (" + ty_info .rust_obj + "*)" + ty_info .var_name + ";" ,
431434 arg_conv_name = ty_info .var_name + "_conv" , arg_conv_cleanup = None ,
432435 ret_conv = ret_conv , ret_conv_name = "(uint64_t)ret_" + ty_info .var_name ,
433436 to_hu_conv = ty_info .java_hu_ty + " " + ty_info .var_name + "_hu_conv = " + ty_info .java_hu_ty + ".constr_from_ptr(" + ty_info .var_name + ");" ,
434437 to_hu_conv_name = ty_info .var_name + "_hu_conv" ,
435- from_hu_conv = (ty_info .var_name + " == null ? 0 : " + ty_info .var_name + ".ptr & ~1" , "this.ptrs_to.add(" + ty_info . var_name + ")" ))
438+ from_hu_conv = (ty_info .var_name + " == null ? 0 : " + ty_info .var_name + ".ptr & ~1" , from_hu_sfx ))
436439 elif ty_info .rust_obj in self .trait_structs :
437440 if ty_info .nonnull_ptr :
438441 arg_conv = ty_info .rust_obj + "* " + ty_info .var_name + "_conv = (" + ty_info .rust_obj + "*)(((uint64_t)" + ty_info .var_name + ") & ~1);"
@@ -457,7 +460,7 @@ def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_re
457460 ret_conv_name = "(uint64_t)" + ty_info .var_name + "_clone" ,
458461 to_hu_conv = ty_info .java_hu_ty + " ret_hu_conv = new " + ty_info .java_hu_ty + "(null, " + ty_info .var_name + ");\n ret_hu_conv.ptrs_to.add(this);" ,
459462 to_hu_conv_name = "ret_hu_conv" ,
460- from_hu_conv = (ty_info .var_name + " == null ? 0 : " + ty_info .var_name + ".ptr" , "this.ptrs_to.add(" + ty_info . var_name + ") " ))
463+ from_hu_conv = (ty_info .var_name + " == null ? 0 : " + ty_info .var_name + ".ptr" , "" ))
461464 else :
462465 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
463466 arg_conv = arg_conv , arg_conv_name = arg_conv_name , arg_conv_cleanup = None ,
0 commit comments