await initializeWasmFromUint8Array(bin);
}
+export * from './structs/UtilMethods.mjs';
""")
self.bindings_version_file = """export function get_ldk_java_bindings_version(): String {
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") or ty_info.subty.rust_obj == "LDKStr"))
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":
def map_hu_array_elems(self, arr_name, conv_name, arr_ty, elem_ty):
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")
+ assert elem_ty.c_ty == "uint64_t" or elem_ty.c_ty.endswith("Array") or elem_ty.rust_obj == "LDKStr"
return arr_name + " != null ? " + arr_name + ".map(" + conv_name + " => " + elem_ty.from_hu_conv[0] + ") : null"
def str_ref_to_native_call(self, var_name, str_len):
return "bindings.getU64ArrayElem(" + arr_name + ", " + idx + ")"
elif elem_ty.rust_obj == "LDKU5":
return "bindings.getU8ArrayElem(" + arr_name + ", " + idx + ")"
+ elif elem_ty.rust_obj == "LDKStr":
+ return "bindings.getU32ArrayElem(" + arr_name + ", " + idx + ")"
else:
assert False
def constr_hu_array(self, ty_info, arr_len):
return ("bindings.encodeUint32Array(" + inner + ")", "")
elif mapped_ty.c_ty == "int64_t" or mapped_ty.c_ty == "uint64_t":
return ("bindings.encodeUint64Array(" + inner + ")", "")
+ elif mapped_ty.rust_obj == "LDKStr":
+ return ("XXX-unused", "")
else:
print(mapped_ty.c_ty)
assert False
bindings.write(f"\t\tcase {str(f)}: fn = Object.getOwnPropertyDescriptor(obj, \"{self.function_ptrs[f][1]}\"); break;\n")
bindings.write("""\t\tdefault:
- console.error("Got unknown function call from C!");
- throw new Error("Got unknown function call from C!");
+ console.error("Got unknown function call with id " + fn_id + " from C!");
+ throw new Error("Got unknown function call with id " + fn_id + " from C!");
}
if (fn == null || fn == undefined) {
- console.error("Got function call on incorrect JS object!");
- throw new Error("Got function call on incorrect JS object!");
+ console.error("Got function call with id " + fn_id + " on incorrect JS object: " + obj);
+ throw new Error("Got function call with id " + fn_id + " on incorrect JS object: " + obj);
+ }
+ var ret;
+ try {
+ ret = fn.value.bind(obj)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
+ } catch (e) {
+ console.error("Got an exception calling function with id " + fn_id + "! This is fatal.");
+ console.error(e);
+ throw e;
}
- const ret = fn.value.bind(obj)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
if (ret === undefined || ret === null) return BigInt(0);
return BigInt(ret);
}""")