From: Matt Corallo Date: Tue, 27 Dec 2022 16:49:49 +0000 (+0000) Subject: New manual U5 (from u5) and Witness types X-Git-Tag: v0.0.113.0^2~16 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=2056a98d21238f0761b5ed11c264cdc5bbffab64;p=ldk-java New manual U5 (from u5) and Witness types --- diff --git a/gen_type_mapping.py b/gen_type_mapping.py index eac96eb8..c5a434ac 100644 --- a/gen_type_mapping.py +++ b/gen_type_mapping.py @@ -56,7 +56,7 @@ class TypeMappingGenerator: else: arg_conv = arg_conv + arr_name + "_ref." + ty_info.arr_access + " = " + self.consts.get_native_arr_contents(arr_name, "NO_DEST", arr_name + "_ref." + arr_len, ty_info, False) + ";" arg_conv_cleanup = self.consts.cleanup_native_arr_ref_contents(arr_name, arr_name + "_ref." + ty_info.arr_access, arr_name + "_ref." + arr_len, ty_info) - if ty_info.rust_obj == "LDKTransaction": + if ty_info.rust_obj == "LDKTransaction" or ty_info.rust_obj == "LDKWitness": arg_conv = arg_conv + "\n" + arr_name + "_ref.data_is_owned = " + str(holds_ref).lower() + ";" ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "") ret_conv = (ret_conv[0], ";\nint8_tArray " + arr_name + "_arr = " + self.consts.create_native_arr_call(arr_name + "_var." + arr_len, ty_info) + ";\n") @@ -501,7 +501,7 @@ 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, BigEndianScalar, u5, and Error + # The manually-defined types - TxOut, BigEndianScalar, 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, @@ -510,7 +510,7 @@ class TypeMappingGenerator: 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" or ty_info.rust_obj == "LDKWitnessVersion": + if ty_info.rust_obj == "LDKU5" or ty_info.rust_obj == "LDKWitnessVersion": assert from_hu_conv is None return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = "", arg_conv_name = "(" + ty_info.rust_obj + "){ ._0 = " + ty_info.var_name + " }", arg_conv_cleanup = None, diff --git a/genbindings.py b/genbindings.py index fb3ad681..a7dc0181 100755 --- a/genbindings.py +++ b/genbindings.py @@ -214,6 +214,11 @@ def java_c_types(fn_arg, ret_arr_len): rust_obj = "LDKTransaction" assert var_is_arr_regex.match(fn_arg[8:]) arr_access = "data" + elif fn_arg.startswith("LDKWitness ") or fn_arg == "LDKWitness": + fn_arg = "uint8_t (*" + fn_arg[11:] + ")[datalen]" + rust_obj = "LDKWitness" + assert var_is_arr_regex.match(fn_arg[8:]) + arr_access = "data" elif fn_arg.startswith("LDKCVec_"): is_ptr = False if "*" in fn_arg: @@ -273,11 +278,11 @@ def java_c_types(fn_arg, ret_arr_len): arr_ty = "uint8_t" fn_arg = fn_arg[7:].strip() is_primitive = True - elif fn_arg.startswith("LDKu5") or fn_arg.startswith("LDKWitnessVersion"): + elif fn_arg.startswith("LDKU5") or fn_arg.startswith("LDKWitnessVersion"): java_ty = consts.c_type_map['uint8_t'][0] - if fn_arg.startswith("LDKu5"): + if fn_arg.startswith("LDKU5"): java_hu_ty = "UInt5" - rust_obj = "LDKu5" + rust_obj = "LDKU5" fn_arg = fn_arg[6:].strip() else: java_hu_ty = "WitnessVersion" diff --git a/typescript_strings.py b/typescript_strings.py index 15e35d45..46a2991c 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -716,7 +716,7 @@ import * as bindings from '../bindings.mjs' return None def create_native_arr_call(self, arr_len, ty_info): if ty_info.c_ty == "ptrArray": - assert ty_info.rust_obj == "LDKCVec_u5Z" or (ty_info.subty is not None and ty_info.subty.c_ty.endswith("Array")) + assert ty_info.rust_obj == "LDKCVec_U5Z" or (ty_info.subty is not None and ty_info.subty.c_ty.endswith("Array")) return "init_" + ty_info.c_ty + "(" + arr_len + ", __LINE__)" def set_native_arr_contents(self, arr_name, arr_len, ty_info): if ty_info.c_ty == "int8_tArray": @@ -747,7 +747,7 @@ import * as bindings from '../bindings.mjs' return "FREE(" + arr_name + ")" def map_hu_array_elems(self, arr_name, conv_name, arr_ty, elem_ty): - if elem_ty.rust_obj == "LDKu5": + if elem_ty.rust_obj == "LDKU5": return arr_name + " != null ? bindings.uint5ArrToBytes(" + arr_name + ") : null" assert elem_ty.c_ty == "uint64_t" or elem_ty.c_ty.endswith("Array") return arr_name + " != null ? " + arr_name + ".map(" + conv_name + " => " + elem_ty.from_hu_conv[0] + ") : null" @@ -774,7 +774,7 @@ import * as bindings from '../bindings.mjs' return "bindings.getU32ArrayElem(" + arr_name + ", " + idx + ")" elif elem_ty.c_ty == "uint64_t": return "bindings.getU64ArrayElem(" + arr_name + ", " + idx + ")" - elif elem_ty.rust_obj == "LDKu5": + elif elem_ty.rust_obj == "LDKU5": return "bindings.getU8ArrayElem(" + arr_name + ", " + idx + ")" else: assert False