Calling functions from a Wasm instance is a relatively straightforward process with or without Emscripten's glue code. Utilizing Emscripten's API affords a wider range of functionality and integration at the expense of including the glue code alongside the .wasm file. In this section, we will review the means of interacting with the compiled Wasm instance through JavaScript and the added tooling Emscripten provides.
Calling compiled C/C++ functions from JavaScript
Calling functions from a ModuleÂ
Emscripten provides two functions for calling compiled C/C++ functions from JavaScript: ccall() and cwrap(). Both of these functions are present in the Module object. Deciding which one to use is contingent on whether...