X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=typescript_strings.py;h=cbde654d453ae302847e8018fde36d1dbfebfc88;hb=ba97d8dee5ef43b8b61c9a61e30789cdf8eb9c5e;hp=6a5815034c5a7d4853ee133f7a653a3aac5f6c5b;hpb=6884c87ff29249df35c246e86e4d6e38bc930d34;p=ldk-java diff --git a/typescript_strings.py b/typescript_strings.py index 6a581503..cbde654d 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -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