Chapter 6. Creating a WebAssembly module that talks to JavaScript using function pointers

This chapter covers

  • Adjusting C or C++ code to work with function pointers
  • Using Emscripten’s helper functions to pass JavaScript functions to the WebAssembly module
  • Calling function pointers in the WebAssembly module when not using Emscripten’s plumbing code

In chapter 5, you modified your module so that it was no longer passing a validation error message back to the JavaScript through a parameter. Instead, you modified the module so that it called a JavaScript function directly, as figure 6.1 illustrates.

Figure 6.1. The module calling a function in the JavaScript code

Imagine being able to pass a JavaScript function to the module based on your ...

Get WebAssembly in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.