X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=gen_type_mapping.py;h=5dfb9bf1c0ea9b5d83a3fddf9cde6c6a8c1aa172;hb=adb79d6aab43c765dfab7031d09f3fb583b7260c;hp=9c05e5ec7f7dd12f054085d4ee20e5caaf715d9c;hpb=8bc2f20781c249d8018a52a392cca25b4c98d15d;p=ldk-java diff --git a/gen_type_mapping.py b/gen_type_mapping.py index 9c05e5ec..5dfb9bf1 100644 --- a/gen_type_mapping.py +++ b/gen_type_mapping.py @@ -168,17 +168,15 @@ class TypeMappingGenerator: if ty_info.arr_access is None: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - ret_conv = ("jstring " + ty_info.var_name + "_conv = " + self.consts.owned_str_to_c_call[0], self.consts.owned_str_to_c_call[1] + ";"), ret_conv_name = ty_info.var_name + "_conv", + ret_conv = ("const char* " + ty_info.var_name + "_str = ", + ";\njstring " + ty_info.var_name + "_conv = " + self.consts.str_ref_to_c_call(ty_info.var_name + "_str", "strlen(" + ty_info.var_name + "_str)") + ";"), + ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) else: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, ret_conv = ("LDKStr " + ty_info.var_name + "_str = ", - ";\nchar* " + ty_info.var_name + "_buf = MALLOC(" + ty_info.var_name + "_str." + ty_info.arr_len + " + 1, \"str conv buf\");\n" + - "memcpy(" + ty_info.var_name + "_buf, " + ty_info.var_name + "_str." + ty_info.arr_access + ", " + ty_info.var_name + "_str." + ty_info.arr_len + ");\n" + - ty_info.var_name + "_buf[" + ty_info.var_name + "_str." + ty_info.arr_len + "] = 0;\n" + - "jstring " + ty_info.var_name + "_conv = " + self.consts.owned_str_to_c_call[0] + ty_info.var_name + "_str." + ty_info.arr_access + self.consts.owned_str_to_c_call[1] + ";\n" + - "FREE(" + ty_info.var_name + "_buf);"), + ";\njstring " + ty_info.var_name + "_conv = " + self.consts.str_ref_to_c_call(ty_info.var_name + "_str." + ty_info.arr_access, ty_info.var_name + "_str." + ty_info.arr_len) + ";"), ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) elif ty_info.var_name == "" and not print_void: # We don't have a parameter name, and want one, just call it arg