Skip to content

Commit 2056a98

Browse files
committed
New manual U5 (from u5) and Witness types
1 parent ffa3026 commit 2056a98

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

gen_type_mapping.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
5656
else:
5757
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) + ";"
5858
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)
59-
if ty_info.rust_obj == "LDKTransaction":
59+
if ty_info.rust_obj == "LDKTransaction" or ty_info.rust_obj == "LDKWitness":
6060
arg_conv = arg_conv + "\n" + arr_name + "_ref.data_is_owned = " + str(holds_ref).lower() + ";"
6161
ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "")
6262
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 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
501501
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,
502502
to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = from_hu_conv)
503503

504-
# The manually-defined types - TxOut, BigEndianScalar, u5, and Error
504+
# The manually-defined types - TxOut, BigEndianScalar, U5, and Error
505505
if ty_info.rust_obj == "LDKError":
506506
assert from_hu_conv is None
507507
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
@@ -510,7 +510,7 @@ def _do_map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, hold
510510
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 + ")") + ";",
511511
to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = ("0", ""))
512512

513-
if ty_info.rust_obj == "LDKu5" or ty_info.rust_obj == "LDKWitnessVersion":
513+
if ty_info.rust_obj == "LDKU5" or ty_info.rust_obj == "LDKWitnessVersion":
514514
assert from_hu_conv is None
515515
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
516516
arg_conv = "", arg_conv_name = "(" + ty_info.rust_obj + "){ ._0 = " + ty_info.var_name + " }", arg_conv_cleanup = None,

genbindings.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ def java_c_types(fn_arg, ret_arr_len):
214214
rust_obj = "LDKTransaction"
215215
assert var_is_arr_regex.match(fn_arg[8:])
216216
arr_access = "data"
217+
elif fn_arg.startswith("LDKWitness ") or fn_arg == "LDKWitness":
218+
fn_arg = "uint8_t (*" + fn_arg[11:] + ")[datalen]"
219+
rust_obj = "LDKWitness"
220+
assert var_is_arr_regex.match(fn_arg[8:])
221+
arr_access = "data"
217222
elif fn_arg.startswith("LDKCVec_"):
218223
is_ptr = False
219224
if "*" in fn_arg:
@@ -273,11 +278,11 @@ def java_c_types(fn_arg, ret_arr_len):
273278
arr_ty = "uint8_t"
274279
fn_arg = fn_arg[7:].strip()
275280
is_primitive = True
276-
elif fn_arg.startswith("LDKu5") or fn_arg.startswith("LDKWitnessVersion"):
281+
elif fn_arg.startswith("LDKU5") or fn_arg.startswith("LDKWitnessVersion"):
277282
java_ty = consts.c_type_map['uint8_t'][0]
278-
if fn_arg.startswith("LDKu5"):
283+
if fn_arg.startswith("LDKU5"):
279284
java_hu_ty = "UInt5"
280-
rust_obj = "LDKu5"
285+
rust_obj = "LDKU5"
281286
fn_arg = fn_arg[6:].strip()
282287
else:
283288
java_hu_ty = "WitnessVersion"

typescript_strings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def release_native_arr_ptr_call(self, ty_info, arr_var, arr_ptr_var):
716716
return None
717717
def create_native_arr_call(self, arr_len, ty_info):
718718
if ty_info.c_ty == "ptrArray":
719-
assert ty_info.rust_obj == "LDKCVec_u5Z" or (ty_info.subty is not None and ty_info.subty.c_ty.endswith("Array"))
719+
assert ty_info.rust_obj == "LDKCVec_U5Z" or (ty_info.subty is not None and ty_info.subty.c_ty.endswith("Array"))
720720
return "init_" + ty_info.c_ty + "(" + arr_len + ", __LINE__)"
721721
def set_native_arr_contents(self, arr_name, arr_len, ty_info):
722722
if ty_info.c_ty == "int8_tArray":
@@ -747,7 +747,7 @@ def cleanup_native_arr_ref_contents(self, arr_name, dest_name, arr_len, ty_info)
747747
return "FREE(" + arr_name + ")"
748748

749749
def map_hu_array_elems(self, arr_name, conv_name, arr_ty, elem_ty):
750-
if elem_ty.rust_obj == "LDKu5":
750+
if elem_ty.rust_obj == "LDKU5":
751751
return arr_name + " != null ? bindings.uint5ArrToBytes(" + arr_name + ") : null"
752752
assert elem_ty.c_ty == "uint64_t" or elem_ty.c_ty.endswith("Array")
753753
return arr_name + " != null ? " + arr_name + ".map(" + conv_name + " => " + elem_ty.from_hu_conv[0] + ") : null"
@@ -774,7 +774,7 @@ def get_java_arr_elem(self, elem_ty, arr_name, idx):
774774
return "bindings.getU32ArrayElem(" + arr_name + ", " + idx + ")"
775775
elif elem_ty.c_ty == "uint64_t":
776776
return "bindings.getU64ArrayElem(" + arr_name + ", " + idx + ")"
777-
elif elem_ty.rust_obj == "LDKu5":
777+
elif elem_ty.rust_obj == "LDKU5":
778778
return "bindings.getU8ArrayElem(" + arr_name + ", " + idx + ")"
779779
else:
780780
assert False

0 commit comments

Comments
 (0)