WasmFunctions
A WASM module exposes all exported functions to the user, but they are in "raw" form. That is, they perform no argument or result type conversion and only support data types supported by WASM (i.e. only numeric types). That's fine for functions which only accept and return numbers, but is generally less helpful for functions which take or return strings or have output pointers. For usability reasons, it's desirable to reduce the JS/C friction by automatically performing mundane tasks such as the allocation and deallocation of memory needed for converting strings between JS and WASM.
Additionally, it's often useful to add new functions to the WASM runtime from JS, which requires compiling binary WASM code on the fly. A common example of this is creating user-defined SQL functions. For the most part, the JS bindings of the sqlite3 API take care of such conversions for the user, but there are cases where client code will need to, or want to, perform such conversions itself.
Inheritors
Functions
Given a function pointer, returns the WASM function table entry if found, else returns a falsy value.
Returns the WASM module's indirect function table.
Expects a JS function and signature, exactly as for wasm.jsFuncToWasm(). It uses that function to create a WASM-exported function, installs that function to the next available slot of wasm.functionTable(), and returns the function's index in that table (which acts as a pointer to that function). The returned pointer can be passed to wasm.uninstallFunction() to uninstall it and free up the table slot for reuse.
Installs a JS function.
Creates a WASM function which wraps the given JS function and returns the JS binding of that WASM function. The function signature string must be in the form used by jaccwabyt or Emscripten's addFunction(). In short: in may have one of the following formats:
This works exactly like installFunction() except that the installation is scoped to the current allocation scope and is uninstalled when the current allocation scope is popped. It will throw if no allocation scope is active.
Requires a pointer value previously returned from wasm.installFunction(). Removes that function from the WASM function table, marks its table slot as free for re-use, and returns that function. It is illegal to call this before installFunction() has been called and results are undefined if the argument was not returned by that function. The returned function may be passed back to installFunction() to reinstall it.
Calls a WASM-exported function by name, passing on all supplied arguments (which may optionally be supplied as an array). If throws if the function is not exported or if the argument count does not match. This routine does no type conversion and is essentially equivalent to:
Functions like xCall() but performs argument and result type conversions as for xWrap().
Returns a WASM-exported function by name, or throws if the function is not found.