[TS] Correct TS call semantics for some function types
[ldk-java] / typescript_strings.py
index cc7b236315c6be51e1f593b74f3a04be3916fb4f..52dd12ce03bf0822023beb18390e429e2f0bd65a 100644 (file)
@@ -403,6 +403,21 @@ export class UnqualifiedError {
 }"""
         self.obj_defined(["TxOut"], "structs")
 
+        self.scalar_defn = """export class BigEndianScalar extends CommonBase {
+       /** The bytes of the scalar value, in big endian */
+       public scalar_bytes: Uint8Array;
+
+       /* @internal */
+       public constructor(_dummy: object, ptr: bigint) {
+               super(ptr, bindings.BigEndianScalar_free);
+               this.scalar_bytes = bindings.decodeUint8Array(bindings.BigEndianScalar_get_bytes(ptr));
+       }
+       public static constructor_new(scalar_bytes: Uint8Array): BigEndianScalar {
+               return new BigEndianScalar(null, bindings.BigEndianScalar_new(bindings.encodeUint8Array(scalar_bytes)));
+       }
+}"""
+        self.obj_defined(["BigEndianScalar"], "structs")
+
         self.c_file_pfx = """#include "js-wasm.h"
 #include <stdatomic.h>
 #include <lightning.h>
@@ -1067,7 +1082,7 @@ export class {struct_name.replace("LDK","")} extends CommonBase {{
                 elif not fn_line.ret_ty_info.passed_as_ptr:
                     out_c += "\treturn js_invoke_function_" + fn_suffix + "(j_calls->instance_ptr, " + str(self.function_ptr_counter)
                 else:
-                    out_c += "\tuint32_t ret = js_invoke_function_" + fn_suffix + "(j_calls->instance_ptr, " + str(self.function_ptr_counter)
+                    out_c += "\tuint64_t ret = js_invoke_function_" + fn_suffix + "(j_calls->instance_ptr, " + str(self.function_ptr_counter)
 
                 self.function_ptrs[self.function_ptr_counter] = (struct_name, fn_line.fn_name)
                 self.function_ptr_counter += 1