@@ -303,7 +303,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
303303 "// Thus, after this call, " + ty_info .var_name + " is reset to null and is now a dummy object.\n " + self .consts .set_null_skip_free (ty_info .var_name ))
304304
305305 opaque_ret_conv_suf = ";\n "
306- opaque_ret_conv_suf += "uintptr_t " + ty_info .var_name + "_ref = 0;\n "
306+ opaque_ret_conv_suf += self . consts . ptr_c_ty + " " + ty_info .var_name + "_ref = 0;\n "
307307 indent = ""
308308 if is_nullable :
309309 opaque_ret_conv_suf += "if ((uintptr_t)" + ty_info .var_name + "_var.inner > 4096) {\n "
@@ -392,7 +392,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
392392 from_hu_conv = (from_hu_conv [0 ], self .consts .add_ref ("this" , ty_info .var_name ))
393393 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
394394 arg_conv = base_conv , arg_conv_name = ty_info .var_name + "_conv" , arg_conv_cleanup = None ,
395- ret_conv = ret_conv , ret_conv_name = "(uintptr_t )" + ty_info .var_name + "_ret" ,
395+ ret_conv = ret_conv , ret_conv_name = "(" + self . consts . ptr_c_ty + " )" + ty_info .var_name + "_ret" ,
396396 to_hu_conv = self .consts .var_decl_statement (ty_info .java_hu_ty , "ret_hu_conv" , "new " + ty_info .java_hu_ty + "(null, " + ty_info .var_name + ")" ) + ";\n " + self .consts .add_ref ("ret_hu_conv" , "this" ) + ";" ,
397397 to_hu_conv_name = "ret_hu_conv" , from_hu_conv = from_hu_conv )
398398 needs_full_clone = not is_free and (not ty_info .is_ptr or ty_info .requires_clone == True ) and ty_info .requires_clone != False
@@ -431,11 +431,11 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
431431 base_conv += self .consts .trait_struct_inc_refcnt (optional_ty_info ).\
432432 replace ("\n " , "\n \t " ).replace (ty_info .var_name + "_conv" , ty_info .var_name + "_conv.some" )
433433 base_conv += "\n }"
434- ret_conv = ("uintptr_t " + ty_info .var_name + "_ref = ((uintptr_t)&" , ") | 1;" )
434+ ret_conv = (self . consts . ptr_c_ty + " " + ty_info .var_name + "_ref = ((uintptr_t)&" , ") | 1;" )
435435 if not holds_ref :
436436 ret_conv = (ty_info .rust_obj + " *" + ty_info .var_name + "_copy = MALLOC(sizeof(" + ty_info .rust_obj + "), \" " + ty_info .rust_obj + "\" );\n " , "" )
437437 ret_conv = (ret_conv [0 ] + "*" + ty_info .var_name + "_copy = " , "" )
438- ret_conv = (ret_conv [0 ], ";\n uintptr_t " + ty_info .var_name + "_ref = (uintptr_t)" + ty_info .var_name + "_copy;" )
438+ ret_conv = (ret_conv [0 ], ";\n " + self . consts . ptr_c_ty + " " + ty_info .var_name + "_ref = (uintptr_t)" + ty_info .var_name + "_copy;" )
439439 if from_hu_conv is None :
440440 from_hu_conv = (self .consts .get_ptr (ty_info .var_name ), "" )
441441 from_hu_conv = (from_hu_conv [0 ], to_hu_conv_sfx )
@@ -456,11 +456,11 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
456456 from_hu_conv = (ty_info .var_name + " != null ? " + self .consts .get_ptr (ty_info .var_name ) + " : 0" , "" )
457457 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
458458 arg_conv = base_conv , arg_conv_name = ty_info .var_name + "_conv" , arg_conv_cleanup = None ,
459- ret_conv = ret_conv , ret_conv_name = "(uintptr_t )" + ty_info .var_name + "_conv" ,
459+ ret_conv = ret_conv , ret_conv_name = "(" + self . consts . ptr_c_ty + " )" + ty_info .var_name + "_conv" ,
460460 to_hu_conv = self .consts .var_decl_statement (ty_info .java_hu_ty , ty_info .var_name + "_hu_conv" , ty_info .java_hu_ty + ".constr_from_ptr(" + ty_info .var_name + ")" ) + ";" ,
461461 to_hu_conv_name = ty_info .var_name + "_hu_conv" , from_hu_conv = from_hu_conv )
462462 if ty_info .rust_obj in self .tuple_types :
463- ret_conv_name = "((uintptr_t )" + ty_info .var_name + "_conv)"
463+ ret_conv_name = "((" + self . consts . ptr_c_ty + " )" + ty_info .var_name + "_conv)"
464464 if holds_ref :
465465 # If we're trying to return a ref, we have to clone.
466466 if (ty_info .rust_obj .replace ("LDK" , "" ) + "_clone" ) not in self .clone_fns :
@@ -497,16 +497,16 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
497497 if not ty_info .is_ptr and not holds_ref :
498498 ret_conv = ("LDKTxOut* " + ty_info .var_name + "_ref = MALLOC(sizeof(LDKTxOut), \" LDKTxOut\" );\n *" + ty_info .var_name + "_ref = " , ";" )
499499 else :
500- ret_conv = ("uintptr_t " + ty_info .var_name + "_ref = ((uintptr_t)&" , ") | 1;" )
500+ ret_conv = (self . consts . ptr_c_ty + " " + ty_info .var_name + "_ref = ((uintptr_t)&" , ") | 1;" )
501501 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
502502 arg_conv = base_conv , arg_conv_name = ty_info .var_name + "_conv" , arg_conv_cleanup = None ,
503- ret_conv = ret_conv , ret_conv_name = "(uintptr_t )" + ty_info .var_name + "_ref" ,
503+ ret_conv = ret_conv , ret_conv_name = "(" + self . consts . ptr_c_ty + " )" + ty_info .var_name + "_ref" ,
504504 to_hu_conv = self .consts .var_decl_statement (ty_info .java_hu_ty , ty_info .var_name + "_conv" , "new " + ty_info .java_hu_ty + "(null, " + ty_info .var_name + ")" ) + ";" ,
505505 to_hu_conv_name = ty_info .var_name + "_conv" , from_hu_conv = (self .consts .get_ptr (ty_info .var_name ), "" ))
506506 elif ty_info .is_ptr :
507507 assert (not is_free )
508508 if ty_info .rust_obj in self .complex_enums :
509- ret_conv = ("uintptr_t ret_" + ty_info .var_name + " = (uintptr_t)" , " | 1; // WARNING: We should clone here!" )
509+ ret_conv = (self . consts . ptr_c_ty + " ret_" + ty_info .var_name + " = (uintptr_t)" , " | 1; // WARNING: We should clone here!" )
510510 from_hu_sfx = self .consts .add_ref ("this" , ty_info .var_name )
511511 if ty_info .rust_obj .replace ("LDK" , "" ) + "_clone" in self .clone_fns :
512512 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 "
@@ -516,7 +516,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
516516 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
517517 arg_conv = ty_info .rust_obj + "* " + ty_info .var_name + "_conv = (" + ty_info .rust_obj + "*)" + ty_info .var_name + ";" ,
518518 arg_conv_name = ty_info .var_name + "_conv" , arg_conv_cleanup = None ,
519- ret_conv = ret_conv , ret_conv_name = "(uintptr_t )ret_" + ty_info .var_name ,
519+ ret_conv = ret_conv , ret_conv_name = "(" + self . consts . ptr_c_ty + " )ret_" + ty_info .var_name ,
520520 to_hu_conv = self .consts .var_decl_statement (ty_info .java_hu_ty , ty_info .var_name + "_hu_conv" , ty_info .java_hu_ty + ".constr_from_ptr(" + ty_info .var_name + ")" ) + ";" ,
521521 to_hu_conv_name = ty_info .var_name + "_hu_conv" ,
522522 from_hu_conv = (ty_info .var_name + " == null ? 0 : " + self .consts .get_ptr (ty_info .var_name ) + " & ~1" , from_hu_sfx ))
@@ -545,19 +545,19 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
545545 arg_conv = arg_conv , arg_conv_name = arg_conv_name , arg_conv_cleanup = None ,
546546 ret_conv = (ty_info .rust_obj + " *" + ty_info .var_name + "_clone = MALLOC(sizeof(" + ty_info .rust_obj + "), \" " + ty_info .rust_obj + "\" );\n " +
547547 "*" + ty_info .var_name + "_clone = " + ty_info .rust_obj .replace ("LDK" , "" ) + "_clone(" , ");" ),
548- ret_conv_name = "(uintptr_t )" + ty_info .var_name + "_clone" ,
548+ ret_conv_name = "(" + self . consts . ptr_c_ty + " )" + ty_info .var_name + "_clone" ,
549549 to_hu_conv = self .consts .var_decl_statement (ty_info .java_hu_ty , "ret_hu_conv" , "new " + ty_info .java_hu_ty + "(null, " + ty_info .var_name + ")" ) + ";\n " + self .consts .add_ref ("ret_hu_conv" , "this" ) + ";" ,
550550 to_hu_conv_name = "ret_hu_conv" ,
551551 from_hu_conv = (ty_info .var_name + " == null ? 0 : " + self .consts .get_ptr (ty_info .var_name ), "" ))
552552 else :
553553 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
554554 arg_conv = arg_conv , arg_conv_name = arg_conv_name , arg_conv_cleanup = None ,
555- ret_conv = ("// WARNING: This object doesn't live past this scope, needs clone!\n uintptr_t ret_" + ty_info .var_name + " = ((uintptr_t)" , ") | 1;" ),
555+ ret_conv = ("// WARNING: This object doesn't live past this scope, needs clone!\n " + self . consts . ptr_c_ty + " ret_" + ty_info .var_name + " = ((uintptr_t)" , ") | 1;" ),
556556 ret_conv_name = "ret_" + ty_info .var_name ,
557557 to_hu_conv = self .consts .var_decl_statement (ty_info .java_hu_ty , "ret_hu_conv" , "new " + ty_info .java_hu_ty + "(null, " + ty_info .var_name + ")" ) + ";\n " + self .consts .add_ref ("ret_hu_conv" , "this" ) + ";" ,
558558 to_hu_conv_name = "ret_hu_conv" ,
559559 from_hu_conv = (ty_info .var_name + " == null ? 0 : " + self .consts .get_ptr (ty_info .var_name ), self .consts .add_ref ("this" , ty_info .var_name )))
560- ret_conv = ("uintptr_t ret_" + ty_info .var_name + " = (uintptr_t)" , ";" )
560+ ret_conv = (self . consts . ptr_c_ty + " ret_" + ty_info .var_name + " = (uintptr_t)" , ";" )
561561 if holds_ref :
562562 ret_conv = (ret_conv [0 ], " | 1;" )
563563 return ConvInfo (ty_info = ty_info , arg_name = ty_info .var_name ,
0 commit comments