quantumech

Untitled

Apr 22nd, 2019
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Function to be reference by C/C++ via function pointer
  2. function func() {
  3.     console.log("Hello world")
  4.     return 3;
  5. }
  6.  
  7. // Cannot register functions until Emscripten is initialized
  8. Module.onRuntimeInitialized = function()
  9. {
  10.     // Get memory address of func()
  11.     var funcPtr = addFunction(func, 'v');
  12.  
  13.     // Invoke C method that calls function pointer
  14.     Module._callFuncPtr(funcPtr);
  15. };
RAW Paste Data