Calling JavaScript functions from C/C++
Accessing JavaScript's functionality from C/C++ code allows for added flexibility when working with WebAssembly. The methodologies and means of utilizing JavaScript differ considerably between Emscripten's glue code and Wasm-only implementations. In this section, we will cover the various ways you can integrate JavaScript into your C/C++ code with and without Emscripten.
Interacting with JavaScript using glue code
Emscripten provides several techniques for integrating JavaScript with your C/C++ code. The techniques available differ in implementation and complexity, and some only apply to specific execution environments (for example, the browser). Deciding which one to use is contingent on your specific use case. We'll focus on the emscripten_run_script()
function and inlining JavaScript with EM_*
wrappers. The content in the following sections was taken from the Interacting with Code section of Emscripten's site, which can be viewed at https://kripken...