@@ -53,7 +53,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
5353 for (var i = 0; i < iovec_array_len; i++) {
5454 const bytes_view = new Uint8Array(wasm.memory.buffer, ptr_len_view[i*2], ptr_len_view[i*2+1]);
5555 console.log("[fd " + fd + "]: " + String.fromCharCode(...bytes_view));
56- bytes_written += ptr_len_view[i*2+1];
56+ bytes_written += ptr_len_view[i*2+1]! ;
5757 }
5858 const written_view = new Uint32Array(wasm.memory.buffer, bytes_written_ptr, 1);
5959 written_view[0] = bytes_written;
@@ -82,7 +82,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
8282 out_len_view[0] = 0;
8383 return 0;
8484 },
85- "environ_get": (environ_ptr : number, environ_buf_ptr : number) => {
85+ "environ_get": (_environ_ptr : number, _environ_buf_ptr : number) => {
8686 // This is called before fd_write to format + print panic messages,
8787 // but only if we have variables in environ_sizes_get, so shouldn't ever actually happen!
8888 console.log("wasi_snapshot_preview1:environ_get");
@@ -150,7 +150,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
150150export function uint5ArrToBytes(inputArray: Array<UInt5>): Uint8Array {
151151 const arr = new Uint8Array(inputArray.length);
152152 for (var i = 0; i < inputArray.length; i++) {
153- arr[i] = inputArray[i].getVal();
153+ arr[i] = inputArray[i]! .getVal();
154154 }
155155 return arr;
156156}
@@ -159,7 +159,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
159159export function WitnessVersionArrToBytes(inputArray: Array<WitnessVersion>): Uint8Array {
160160 const arr = new Uint8Array(inputArray.length);
161161 for (var i = 0; i < inputArray.length; i++) {
162- arr[i] = inputArray[i].getVal();
162+ arr[i] = inputArray[i]! .getVal();
163163 }
164164 return arr;
165165}
@@ -197,15 +197,15 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
197197}
198198
199199/* @internal */
200- export function check_arr_len(arr: Uint8Array|null, len: number): Uint8Array {
200+ export function check_arr_len(arr: Uint8Array|null, len: number): Uint8Array|null {
201201 if (arr !== null && arr.length != len) { throw new Error("Expected array of length " + len + " got " + arr.length); }
202202 return arr;
203203}
204204
205205/* @internal */
206206export function getArrayLength(arrayPointer: number): number {
207207 const arraySizeViewer = new BigUint64Array(wasm.memory.buffer, arrayPointer, 1);
208- const len = arraySizeViewer[0];
208+ const len = arraySizeViewer[0]! ;
209209 if (len >= (2n ** 32n)) throw new Error("Bogus Array Size");
210210 return Number(len % (2n ** 32n));
211211}
@@ -260,19 +260,19 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
260260/* @internal */
261261export function getU64ArrayElem(arrayPointer: number, idx: number): bigint {
262262 const actualArrayViewer = new BigUint64Array(wasm.memory.buffer, arrayPointer + 8, idx + 1);
263- return actualArrayViewer[idx];
263+ return actualArrayViewer[idx]! ;
264264}
265265
266266/* @internal */
267267export function getU32ArrayElem(arrayPointer: number, idx: number): number {
268268 const actualArrayViewer = new Uint32Array(wasm.memory.buffer, arrayPointer + 8, idx + 1);
269- return actualArrayViewer[idx];
269+ return actualArrayViewer[idx]! ;
270270}
271271
272272/* @internal */
273273export function getU8ArrayElem(arrayPointer: number, idx: number): number {
274274 const actualArrayViewer = new Uint8Array(wasm.memory.buffer, arrayPointer + 8, idx + 1);
275- return actualArrayViewer[idx];
275+ return actualArrayViewer[idx]! ;
276276}
277277
278278
@@ -384,7 +384,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
384384}
385385
386386export class UnqualifiedError {
387- public constructor(val : number) {}
387+ public constructor(_val : number) {}
388388}
389389"""
390390
@@ -395,7 +395,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
395395 public value: bigint;
396396
397397 /* @internal */
398- public constructor(_dummy: object , ptr: bigint) {
398+ public constructor(_dummy: null , ptr: bigint) {
399399 super(ptr, bindings.TxOut_free);
400400 this.script_pubkey = bindings.decodeUint8Array(bindings.TxOut_get_script_pubkey(ptr));
401401 this.value = bindings.TxOut_get_value(ptr);
@@ -411,7 +411,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
411411 public scalar_bytes: Uint8Array;
412412
413413 /* @internal */
414- public constructor(_dummy: object , ptr: bigint) {
414+ public constructor(_dummy: null , ptr: bigint) {
415415 super(ptr, bindings.BigEndianScalar_free);
416416 this.scalar_bytes = bindings.decodeUint8Array(bindings.BigEndianScalar_get_bytes(ptr));
417417 }
@@ -874,7 +874,7 @@ def native_c_map_trait(self, struct_name, field_var_conversions, flattened_field
874874 else :
875875 bindings_instantiator += ", " + first_to_lower (var .arg_name )
876876 else :
877- bindings_instantiator += ", " + first_to_lower (var [1 ]) + ".instance_idx"
877+ bindings_instantiator += ", " + first_to_lower (var [1 ]) + ".instance_idx! "
878878 super_instantiator += first_to_lower (var [1 ]) + "_impl, "
879879 pointer_to_adder += "\t \t impl_holder.held.ptrs_to.push(" + first_to_lower (var [1 ]) + ");\n "
880880 impl_constructor_arguments += f", { first_to_lower (var [1 ])} _impl: { var [0 ].replace ('LDK' , '' )} Interface"
@@ -886,7 +886,7 @@ def native_c_map_trait(self, struct_name, field_var_conversions, flattened_field
886886 trait_constructor_arguments += ", " + var .arg_name
887887 else :
888888 super_constructor_statements += "\t \t const " + first_to_lower (var [1 ]) + " = " + var [1 ] + ".new_impl(" + super_instantiator + ");\n "
889- trait_constructor_arguments += ", " + first_to_lower (var [1 ]) + ".instance_idx"
889+ trait_constructor_arguments += ", " + first_to_lower (var [1 ]) + ".instance_idx! "
890890 for suparg in var [2 ]:
891891 if isinstance (suparg , ConvInfo ):
892892 trait_constructor_arguments += ", " + suparg .arg_name
@@ -958,21 +958,21 @@ def native_c_map_trait(self, struct_name, field_var_conversions, flattened_field
958958{ out_java_interface } }}
959959
960960class { struct_name } Holder {{
961- held: { struct_name .replace ("LDK" , "" )} ;
961+ held: { struct_name .replace ("LDK" , "" )} |null = null ;
962962}}
963963
964964/**
965965 * { formatted_trait_docs }
966966 */
967967export class { struct_name .replace ("LDK" ,"" )} extends CommonBase {{
968968 /* @internal */
969- public bindings_instance? : bindings.{ struct_name } ;
969+ public bindings_instance: bindings.{ struct_name } |null ;
970970
971971 /* @internal */
972972 public instance_idx?: number;
973973
974974 /* @internal */
975- constructor(_dummy: object , ptr: bigint) {{
975+ constructor(_dummy: null , ptr: bigint) {{
976976 super(ptr, bindings.{ struct_name .replace ("LDK" ,"" )} _free);
977977 this.bindings_instance = null;
978978 }}
@@ -987,7 +987,7 @@ class {struct_name}Holder {{
987987 impl_holder.held = new { struct_name .replace ("LDK" , "" )} (null, ptr_idx[0]);
988988 impl_holder.held.instance_idx = ptr_idx[1];
989989 impl_holder.held.bindings_instance = structImplementation;
990- { pointer_to_adder } return impl_holder.held;
990+ { pointer_to_adder } return impl_holder.held! ;
991991 }}
992992
993993"""
@@ -1214,7 +1214,7 @@ def map_complex_enum(self, struct_name, variant_list, camel_to_snake, enum_doc_c
12141214
12151215 java_hu_class = "/**\n * " + enum_doc_comment .replace ("\n " , "\n * " ) + "\n */\n "
12161216 java_hu_class += "export class " + java_hu_type + " extends CommonBase {\n "
1217- java_hu_class += "\t protected constructor(_dummy: object , ptr: bigint) { super(ptr, bindings." + bindings_type + "_free); }\n "
1217+ java_hu_class += "\t protected constructor(_dummy: null , ptr: bigint) { super(ptr, bindings." + bindings_type + "_free); }\n "
12181218 java_hu_class += "\t /* @internal */\n "
12191219 java_hu_class += f"\t public static constr_from_ptr(ptr: bigint): { java_hu_type } {{\n "
12201220 java_hu_class += f"\t \t const raw_ty: number = bindings." + struct_name + "_ty_from_ptr(ptr);\n "
@@ -1306,7 +1306,7 @@ def map_opaque_struct(self, struct_name, struct_doc_comment):
13061306 */
13071307export class { hu_name } extends CommonBase { implementations } {{
13081308 /* @internal */
1309- public constructor(_dummy: object , ptr: bigint) {{
1309+ public constructor(_dummy: null , ptr: bigint) {{
13101310 { constructor_body }
13111311 }}{ extra_body }
13121312
@@ -1325,7 +1325,7 @@ def map_result(self, struct_name, res_map, err_map):
13251325 suffixes += "\t public res: " + res_map .java_hu_ty + ";\n "
13261326 suffixes += f"""
13271327 /* @internal */
1328- public constructor(_dummy: object , ptr: bigint) {{
1328+ public constructor(_dummy: null , ptr: bigint) {{
13291329 super(_dummy, ptr);
13301330"""
13311331 if res_map .java_hu_ty == "void" :
@@ -1343,7 +1343,7 @@ def map_result(self, struct_name, res_map, err_map):
13431343 suffixes += "\t public err: " + err_map .java_hu_ty + ";\n "
13441344 suffixes += f"""
13451345 /* @internal */
1346- public constructor(_dummy: object , ptr: bigint) {{
1346+ public constructor(_dummy: null , ptr: bigint) {{
13471347 super(_dummy, ptr);
13481348"""
13491349 if err_map .java_hu_ty == "void" :
@@ -1362,7 +1362,7 @@ def map_result(self, struct_name, res_map, err_map):
13621362 return f"""{ self .hu_struct_file_prefix }
13631363
13641364export class { human_ty } extends CommonBase {{
1365- protected constructor(_dummy: object , ptr: bigint) {{
1365+ protected constructor(_dummy: null , ptr: bigint) {{
13661366 super(ptr, bindings.{ struct_name .replace ("LDK" ,"" )} _free);
13671367 }}
13681368 /* @internal */
@@ -1443,6 +1443,8 @@ def map_function(self, argument_types, c_call_string, method_name, meth_n, retur
14431443 out_java_struct += arg .arg_name + "_" + explode_arg .arg_name + ": " + explode_arg .java_hu_ty
14441444 else :
14451445 out_java_struct += arg .arg_name + ": " + arg .java_hu_ty
1446+ if arg .nullable :
1447+ out_java_struct += "|null"
14461448
14471449 out_c += (") {\n " )
14481450 if out_java_struct is not None :
@@ -1549,12 +1551,12 @@ def cleanup(self):
15491551 bindings .write ("""
15501552
15511553js_invoke = function(obj_ptr: number, fn_id: number, arg1: bigint|number, arg2: bigint|number, arg3: bigint|number, arg4: bigint|number, arg5: bigint|number, arg6: bigint|number, arg7: bigint|number, arg8: bigint|number, arg9: bigint|number, arg10: bigint|number) {
1552- const weak: WeakRef<object> = js_objs[obj_ptr];
1554+ const weak: WeakRef<object>|undefined = js_objs[obj_ptr];
15531555 if (weak == null || weak == undefined) {
15541556 console.error("Got function call on unknown/free'd JS object!");
15551557 throw new Error("Got function call on unknown/free'd JS object!");
15561558 }
1557- const obj: object = weak.deref();
1559+ const obj = weak.deref();
15581560 if (obj == null || obj == undefined) {
15591561 console.error("Got function call on GC'd JS object!");
15601562 throw new Error("Got function call on GC'd JS object!");
0 commit comments