ret_conv = ("long " + ty_info.var_name + "_ref = (long)(&", ") | 1;"), ret_conv_name = ty_info.var_name + "_ref",
to_hu_conv = to_hu_conv, to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", from_hu_conv_sfx))
- # The manually-defined types - TxOut and Transaction
+ # The manually-defined types - TxOut and u5
+ if ty_info.rust_obj == "LDKu5":
+ return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
+ arg_conv = "", arg_conv_name = "(LDKu5){ ._0 = " + ty_info.var_name + " }", arg_conv_cleanup = None,
+ ret_conv = ("uint8_t " + ty_info.var_name + "_val = ", "._0;"), ret_conv_name = ty_info.var_name + "_val",
+ to_hu_conv = 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 = (ty_info.var_name + ".ptr", ""))
+
assert ty_info.rust_obj == "LDKTxOut"
if not ty_info.is_ptr and not holds_ref:
ret_conv = ("LDKTxOut* " + ty_info.var_name + "_ref = MALLOC(sizeof(LDKTxOut), \"LDKTxOut\");\n*" + ty_info.var_name + "_ref = ", ";")
assert var_is_arr_regex.match(fn_arg[8:])
rust_obj = "LDKSignature"
arr_access = "compact_form"
+ elif fn_arg.startswith("LDKRecoverableSignature"):
+ fn_arg = "uint8_t (*" + fn_arg[25:] + ")[68]"
+ assert var_is_arr_regex.match(fn_arg[8:])
+ rust_obj = "LDKRecoverableSignature"
+ arr_access = "serialized_form"
elif fn_arg.startswith("LDKThreeBytes"):
fn_arg = "uint8_t (*" + fn_arg[14:] + ")[3]"
assert var_is_arr_regex.match(fn_arg[8:])
assert var_is_arr_regex.match(fn_arg[8:])
rust_obj = "LDKSixteenBytes"
arr_access = "data"
+ elif fn_arg.startswith("LDKTwentyBytes"):
+ fn_arg = "uint8_t (*" + fn_arg[15:] + ")[20]"
+ assert var_is_arr_regex.match(fn_arg[8:])
+ rust_obj = "LDKTwentyBytes"
+ arr_access = "data"
elif fn_arg.startswith("LDKTenBytes"):
fn_arg = "uint8_t (*" + fn_arg[12:] + ")[10]"
assert var_is_arr_regex.match(fn_arg[8:])
fn_ty_arg = "B"
fn_arg = fn_arg[7:].strip()
is_primitive = True
+ elif fn_arg.startswith("LDKu5"):
+ java_ty = consts.c_type_map['uint8_t'][0]
+ java_hu_ty = "UInt5"
+ rust_obj = "LDKu5"
+ c_ty = "int8_t"
+ fn_ty_arg = "B"
+ fn_arg = fn_arg[6:].strip()
elif fn_arg.startswith("uint16_t"):
mapped_type = consts.c_type_map['uint16_t']
java_ty = mapped_type[0]
--- /dev/null
+package org.ldk.util;
+
+/**
+ * A 5-bit unsigned integer
+ */
+public class UInt5 {
+ byte val;
+ public UInt5(byte val) {
+ if (val > 32 || val < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.val = val;
+ }
+}