Call C++ function pointer from Javascript -


is possible pass function pointers c++ (compiled javascript using emscripten) directly-written js? i've found ways of creating function pointers of javascript functions pass c++, not way of exposing function pointer, given value @ runtime in c++ code, javascript.

code-wide, i'm after able complete code snippet below in order call function passed cfunctionpointer i'm doing console.log

void passtojs(void (*cfunctionpointer)()) {   em_asm_args({     // prints out integer. able     // call function represents.     console.log($0);   }, cfunctionpointer); } 

found answer @ https://stackoverflow.com/a/25584986/1319998. can use runtime.dyncall function:

void passtojs(void (*cfunctionpointer)()) {   em_asm_args({     module.runtime.dyncall('v', $0, []);   }, cfunctionpointer); } 

the 'v' signature of void function doesn't take arguments.

apparently supports other signatures, such 'vii', void function takes 2 integer arguments. integer arguments have passed in array 3rd argument of runtime.dyncall.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -