X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=typescript_strings.py;h=a1dcf813bc41ef168124f3c422242b849b1bf572;hb=8cc58d0ad88e41a365fb4599b1b10b010ede2d20;hp=379eaa6bd3f48c58421153c9e1c86307a2fd43c4;hpb=cbb0beb4b0d98b743f600c154a6079c2b1463c9b;p=ldk-java diff --git a/typescript_strings.py b/typescript_strings.py index 379eaa6b..a1dcf813 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -297,6 +297,7 @@ void __attribute__((visibility("default"))) TS_free(uint32_t ptr) { self.hu_struct_file_prefix = """ import CommonBase from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' +import * as InternalUtils from '../InternalUtils.mjs' """ self.c_fn_ty_pfx = "" @@ -308,6 +309,12 @@ import * as bindings from '../bindings.mjs' self.is_arr_some_check = ("", " != 0") self.get_native_arr_len_call = ("", "->arr_len") + with open(outdir + "/InternalUtils.mts", "w") as f: + f.write("export function check_arr_len(arr: Uint8Array, len: number): Uint8Array {\n") + f.write("\tif (arr.length != len) { throw new Error(\"Expected array of length \" + len + \"got \" + arr.length); }\n") + f.write("\treturn arr;\n") + f.write("}") + def release_native_arr_ptr_call(self, ty_info, arr_var, arr_ptr_var): return None def create_native_arr_call(self, arr_len, ty_info):