Skip to content

Commit 0b07fe1

Browse files
committed
[TS] Support arrays of strings for LDK 0.0.115
1 parent 09a0906 commit 0b07fe1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

typescript_strings.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def release_native_arr_ptr_call(self, ty_info, arr_var, arr_ptr_var):
735735
return None
736736
def create_native_arr_call(self, arr_len, ty_info):
737737
if ty_info.c_ty == "ptrArray":
738-
assert ty_info.rust_obj == "LDKCVec_U5Z" or (ty_info.subty is not None and ty_info.subty.c_ty.endswith("Array"))
738+
assert ty_info.rust_obj == "LDKCVec_U5Z" or (ty_info.subty is not None and (ty_info.subty.c_ty.endswith("Array") or ty_info.subty.rust_obj == "LDKStr"))
739739
return "init_" + ty_info.c_ty + "(" + arr_len + ", __LINE__)"
740740
def set_native_arr_contents(self, arr_name, arr_len, ty_info):
741741
if ty_info.c_ty == "int8_tArray":
@@ -773,7 +773,7 @@ def cleanup_native_arr_ref_contents(self, arr_name, dest_name, arr_len, ty_info)
773773
def map_hu_array_elems(self, arr_name, conv_name, arr_ty, elem_ty):
774774
if elem_ty.rust_obj == "LDKU5":
775775
return arr_name + " != null ? bindings.uint5ArrToBytes(" + arr_name + ") : null"
776-
assert elem_ty.c_ty == "uint64_t" or elem_ty.c_ty.endswith("Array")
776+
assert elem_ty.c_ty == "uint64_t" or elem_ty.c_ty.endswith("Array") or elem_ty.rust_obj == "LDKStr"
777777
return arr_name + " != null ? " + arr_name + ".map(" + conv_name + " => " + elem_ty.from_hu_conv[0] + ") : null"
778778

779779
def str_ref_to_native_call(self, var_name, str_len):
@@ -800,6 +800,8 @@ def get_java_arr_elem(self, elem_ty, arr_name, idx):
800800
return "bindings.getU64ArrayElem(" + arr_name + ", " + idx + ")"
801801
elif elem_ty.rust_obj == "LDKU5":
802802
return "bindings.getU8ArrayElem(" + arr_name + ", " + idx + ")"
803+
elif elem_ty.rust_obj == "LDKStr":
804+
return "bindings.getU32ArrayElem(" + arr_name + ", " + idx + ")"
803805
else:
804806
assert False
805807
def constr_hu_array(self, ty_info, arr_len):
@@ -827,6 +829,8 @@ def primitive_arr_from_hu(self, arr_ty, fixed_len, arr_name):
827829
return ("bindings.encodeUint32Array(" + inner + ")", "")
828830
elif mapped_ty.c_ty == "int64_t" or mapped_ty.c_ty == "uint64_t":
829831
return ("bindings.encodeUint64Array(" + inner + ")", "")
832+
elif mapped_ty.rust_obj == "LDKStr":
833+
return ("XXX-unused", "")
830834
else:
831835
print(mapped_ty.c_ty)
832836
assert False

0 commit comments

Comments
 (0)