X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=typescript_strings.py;h=84b27c5723a66521d7f737ac486313b1aac52cb2;hb=a05d98212a06a79b3dedc8b6a07e24c343752182;hp=d1eae4e066f4c133aa10ce6a5503beba923004ea;hpb=db1a11032b4164540a2d3403696be12bbca70e94;p=ldk-java diff --git a/typescript_strings.py b/typescript_strings.py index d1eae4e0..84b27c57 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,7 +120,7 @@ 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) > 1024) { free(p); } #define DO_ASSERT(a) (void)(a) #define CHECK(a) """ @@ -172,7 +174,7 @@ 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 < 1024) return; // Rust loves to create pointers to the NULL page for dummys alloc_freed(ptr); __real_free(ptr); } @@ -261,6 +263,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 @@ -720,10 +724,12 @@ const decodeString = (stringPointer, free = true) => { out_c = out_c + "\t" + fn_line.ret_ty_info.c_ty + " ret = js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth" elif fn_line.ret_ty_info.java_ty == "void": out_c = out_c + "\tjs_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth" + elif fn_line.ret_ty_info.java_ty == "String": + out_c = out_c + "\tuint32_t ret = js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth" elif not fn_line.ret_ty_info.passed_as_ptr: out_c = out_c + "\treturn js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth" else: - out_c = out_c + "\t" + fn_line.ret_ty_info.rust_obj + "* ret = (" + fn_line.ret_ty_info.rust_obj + "*)js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth" + out_c = out_c + "\tuint32_t ret = js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth" for idx, arg_info in enumerate(fn_line.args_ty): if arg_info.ret_conv is not None: @@ -933,7 +939,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 @@ -986,7 +995,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 + "(")