Calling compiled C/C++ functions from JavaScript
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 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 the function will be called more than once. The content in the following sections was taken from Emscripten's API reference documentation for preamble.js
, which can be viewed at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html.
Note
You don't need to prefix...