X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=gen_type_mapping.py;h=ad7d46fcfa5b8ce1628503f8e33fe6bac83c7b9e;hb=1ef2dc8b8a3e0e244ad82ac08e286df489eca4b7;hp=0b0e135902353a24564876be51573fafc5c390e2;hpb=97e1121dc704985a3b4d6a4a4d4156cc7427bc8c;p=ldk-java diff --git a/gen_type_mapping.py b/gen_type_mapping.py index 0b0e1359..ad7d46fc 100644 --- a/gen_type_mapping.py +++ b/gen_type_mapping.py @@ -309,7 +309,7 @@ class TypeMappingGenerator: opaque_ret_conv_suf += "if ((uintptr_t)" + ty_info.var_name + "_var.inner > 4096) {\n" indent = "\t" if not holds_ref and ty_info.is_ptr and (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns: # is_ptr, not holds_ref implies passing a pointed-to value to java, which needs copied - opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(" + ty_info.var_name + ");\n" + opaque_ret_conv_suf += indent + ty_info.var_name + "_var = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&" + ty_info.var_name + "_var);\n" elif not holds_ref and ty_info.is_ptr: opaque_ret_conv_suf += indent + "// WARNING: we may need a move here but no clone is available for " + ty_info.rust_obj + "\n" @@ -439,10 +439,12 @@ class TypeMappingGenerator: if from_hu_conv is None: from_hu_conv = (self.consts.get_ptr(ty_info.var_name), "") from_hu_conv = (from_hu_conv[0], to_hu_conv_sfx) + fully_qualified_ty = self.consts.fully_qualified_hu_ty_path(ty_info) + to_hu_call = fully_qualified_ty + ".constr_from_ptr(" + ty_info.var_name + ")" return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = ret_conv, ret_conv_name = ty_info.var_name + "_ref", - 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 + ")") + ";\n" + self.consts.add_ref(ty_info.var_name + "_hu_conv", "this") + ";", + to_hu_conv = self.consts.var_decl_statement(fully_qualified_ty, ty_info.var_name + "_hu_conv", to_hu_call) + ";\n" + self.consts.add_ref(ty_info.var_name + "_hu_conv", "this") + ";", to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = from_hu_conv) if ty_info.rust_obj in self.result_types: if holds_ref: @@ -484,7 +486,15 @@ class TypeMappingGenerator: to_hu_conv = self.consts.var_decl_statement(ty_info.java_hu_ty, ty_info.var_name + "_hu_conv", "new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ")") + ";" + to_hu_conv_sfx, to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = from_hu_conv) - # The manually-defined types - TxOut and u5 + # The manually-defined types - TxOut, u5, and Error + if ty_info.rust_obj == "LDKError": + assert from_hu_conv is None + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = "", arg_conv_name = "(LDKError){ ._dummy = 0 }", arg_conv_cleanup = None, + ret_conv = ("/*", "*/"), ret_conv_name = "0", + to_hu_conv = self.consts.var_decl_statement(ty_info.java_hu_ty, ty_info.var_name + "_conv", "new " + ty_info.java_hu_ty + "(" + ty_info.var_name + ")") + ";", + to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = ("0", "")) + if ty_info.rust_obj == "LDKu5": assert from_hu_conv is None return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,