X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=typescript_strings.py;h=54159d8d85099d3c0db71e0710dd7194d5618c2f;hb=d294ad273a3d99aa2857efb10b225a2e20c84a16;hp=f3a7f29adcd6fa5879a23e532aacbece19e65dbd;hpb=7d6be8a5ef72a4ebfe07660cce55f43f6cc30b80;p=ldk-java diff --git a/typescript_strings.py b/typescript_strings.py index f3a7f29a..54159d8d 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -71,6 +71,8 @@ public static native long new_empty_slice_vec(); """ + self.bindings_version_file = "" + self.bindings_footer = """ export async function initializeWasm(allowDoubleInitialization: boolean = false): Promise { if(isWasmInitialized && !allowDoubleInitialization) { @@ -118,9 +120,10 @@ void *malloc(size_t size); void free(void *ptr); #define MALLOC(a, _) malloc(a) -#define FREE(p) if ((long)(p) > 1024) { free(p); } +#define FREE(p) if ((unsigned long)(p) > 4096) { free(p); } #define DO_ASSERT(a) (void)(a) #define CHECK(a) +#define CHECK_ACCESS(p) """ else: self.c_file_pfx = self.c_file_pfx + """ @@ -172,11 +175,21 @@ static void alloc_freed(void* ptr) { __real_free(it); } static void FREE(void* ptr) { - if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys + if ((unsigned long)ptr <= 4096) return; // Rust loves to create pointers to the NULL page for dummys alloc_freed(ptr); __real_free(ptr); } +static void CHECK_ACCESS(void* ptr) { + allocation* it = allocation_ll; + while (it->ptr != ptr) { + it = it->next; + if (it == NULL) { + return; // addrsan should catch malloc-unknown and print more info than we have + } + } +} + void* __wrap_malloc(size_t len) { void* res = __real_malloc(len); new_allocation(res, "malloc call"); @@ -261,6 +274,8 @@ void __attribute__((visibility("default"))) TS_free(uint32_t ptr) { } """ + self.c_version_file = "" + self.hu_struct_file_prefix = f""" import CommonBase from './CommonBase'; import * as bindings from '../bindings' // TODO: figure out location @@ -935,7 +950,10 @@ const decodeString = (stringPointer, free = true) => { """ return out_opaque_struct_human - def map_function(self, argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_as_ref, args_known, type_mapping_generator, doc_comment): + def map_tuple(self, struct_name): + return self.map_opaque_struct(struct_name, "A Tuple") + + def map_function(self, argument_types, c_call_string, method_name, meth_n, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_as_ref, args_known, type_mapping_generator, doc_comment): out_java = "" out_c = "" out_java_struct = None @@ -988,7 +1006,6 @@ const decodeString = (stringPointer, free = true) => { if not args_known: out_java_struct += ("\t// Skipped " + method_name + "\n") else: - meth_n = method_name[len(struct_meth) + 1:] if not takes_self: out_java_struct += ( "\tpublic static " + return_type_info.java_hu_ty + " constructor_" + meth_n + "(")