X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=typescript_strings.py;h=6e2ce6fa3bea22e77394852fffcaf91e4b4808dd;hb=74dbe11368db19528436facc532edef09b13ac52;hp=6a5815034c5a7d4853ee133f7a653a3aac5f6c5b;hpb=9f93df58323e1dea5f3900d5d06b8506b8bc3278;p=ldk-java diff --git a/typescript_strings.py b/typescript_strings.py index 6a581503..6e2ce6fa 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -214,7 +214,7 @@ import * as bindings from '../bindings' // TODO: figure out location self.c_fn_args_pfx = "void* ctx_TODO" self.file_ext = ".ts" self.ptr_c_ty = "uint32_t" - self.ptr_native_ty = "uint32_t" + self.ptr_native_ty = "number" # "uint32_t" self.result_c_ty = "uint32_t" self.ptr_arr = "uint32_tArray" self.get_native_arr_len_call = ("", ".len") @@ -726,3 +726,34 @@ const wasm = wasmInstance.exports; out_java_enum += ("}\n") out_java_enum += (java_hu_subclasses) return (out_java, out_java_enum, out_c) + + def map_opaque_struct(self, struct_name): + + implementations = "" + method_header = "" + if struct_name.startswith("LDKLocked"): + implementations += "implements AutoCloseable " + method_header = """ + public close() { + """ + else: + method_header = """ + protected finalize() { + super.finalize(); + """ + + out_opaque_struct_human = f""" + {self.hu_struct_file_prefix} + + export default class {struct_name.replace("LDK","")} extends CommonBase {implementations}{{ + constructor(_dummy: object, ptr: number) {{ + super(ptr); + }} + + {method_header} + if (this.ptr != 0) {{ + bindings.{struct_name.replace("LDK","")}_free(this.ptr); + }} + }} + """ + return out_opaque_struct_human