Tour de WebAssembly Table des Matières

[Untranslated] Context Of Dynamic Invocation

When our dynamically invoked functions are called, the functions need to have access to the module's memory. We can place important resources on a context object so our function has all the available tools to do it's job.

let log_handle = register_function("
  (context, msgStart, msgEnd) => {
    let msg = context.getUtf8FromMemory(msgStart,msgEnd);
    console.log(msg); 
  }");

let msg = "hello world";

js_invoke_with_2_params( log_handle,msg.as_ptr() as f64, 
  msg.len() as f64);

Look at the example for the complete implementation.