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")
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,
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,
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:
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"
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":
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"
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