From: Matt Corallo Date: Wed, 27 Jan 2021 03:21:14 +0000 (-0500) Subject: Add js-wasm.h from arik's repo X-Git-Tag: v0.0.1~36^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=97c97c3b5dd6455901d84c7a5289b71bf5770146;p=ldk-java Add js-wasm.h from arik's repo --- diff --git a/ts/js-wasm.h b/ts/js-wasm.h new file mode 100644 index 00000000..95db6d2e --- /dev/null +++ b/ts/js-wasm.h @@ -0,0 +1,63 @@ +#ifndef export +#define export __attribute__((visibility("default"))) +#endif + +#ifndef JS_H + +unsigned int +js_strlen(const char *str) +{ + const char *s; + + for (s = str; *s; ++s) + ; + return (s - str); +} + +typedef double JSValue; +typedef int JSFunction; +extern JSFunction js_register_function(char*,unsigned int); +extern JSValue js_invoke_function(JSFunction,JSValue,JSValue,JSValue,JSValue,JSValue,JSValue,JSValue,JSValue,JSValue,JSValue); +extern void js_release(JSValue); + +JSValue const JS_NULL = 0.0; +JSValue const JS_UNDEFINED = 1.0; +JSValue const DOM_SELF = 2.0; +JSValue const DOM_WINDOW = 2.0; +JSValue const DOM_DOCUMENT = 3.0; +JSValue const DOM_BODY = 4.0; + +static inline JSValue js_invoke_function_0(JSFunction fn){ + return js_invoke_function(fn,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_1(JSFunction fn, JSValue a){ + return js_invoke_function(fn,a,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_2(JSFunction fn, JSValue a, JSValue b){ + return js_invoke_function(fn,a,b,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_3(JSFunction fn, JSValue a, JSValue b, JSValue c){ + return js_invoke_function(fn,a,b,c,0.0,0.0,0.0,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_4(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d){ + return js_invoke_function(fn,a,b,c,d,0.0,0.0,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_5(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d, JSValue e){ + return js_invoke_function(fn,a,b,c,d,e,0.0,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_6(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d, JSValue e, JSValue f){ + return js_invoke_function(fn,a,b,c,d,e,f,0.0,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_7(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d, JSValue e, JSValue f, JSValue g){ + return js_invoke_function(fn,a,b,c,d,e,f,g,0.0,0.0,0.0); +} +static inline JSValue js_invoke_function_8(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d, JSValue e, JSValue f, JSValue g, JSValue h){ + return js_invoke_function(fn,a,b,c,d,e,f,g,h,0.0,0.0); +} +static inline JSValue js_invoke_function_9(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d, JSValue e, JSValue f, JSValue g, JSValue h, JSValue i){ + return js_invoke_function(fn,a,b,c,d,e,f,g,h,i,0.0); +} +static inline JSValue js_invoke_function_10(JSFunction fn, JSValue a, JSValue b, JSValue c, JSValue d, JSValue e, JSValue f, JSValue g, JSValue h, JSValue i, JSValue j){ + return js_invoke_function(fn,a,b,c,d,e,f,g,h,i,j); +} +#endif diff --git a/typescript_strings.py b/typescript_strings.py index eb8d36b9..c9f181e2 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -219,7 +219,7 @@ import * as bindings from '../bindings' // TODO: figure out location self.c_fn_args_pfx = "void* ctx_TODO" self.file_ext = ".ts" self.ptr_c_ty = "uint32_t" - self.ptr_native_ty = "number" # "uint32_t" + self.ptr_native_ty = "uint32_t" self.result_c_ty = "uint32_t" self.owned_str_to_c_call = ("conv_owned_string(", ")") self.ptr_arr = "ptrArray"