I want to be able to register a JavaScript function at runtime and call it with a dynamically-generated argument list, similar to function.apply(context,args) except the caller will be C++.

Let's say for instance that I want to dynamically bind console.log. I need to construct an argument list, call the function (using a pointer or handle), and accept anything it returns, without knowing anything about the function at compile time. I also expect to handle different return types dynamically, e.g., with a switch based on type. It should cope with functions that can return multiple types and therefore cannot be known in advance.

I will need to dynamically create an array (or vector) of arguments, which might all be different types. std::vector<T> is no good for the argument list unless T is a complex type like a tagged union - possibly EM_VAL?

Having searched the docs and poked around in the source code a bit, I'm not seeing any obvious way to do this. The public stuff in bind.h and val.h all seems to rely on templates, which require that the argument list and return types are known at compile time. That's not what I want.

Any suggestions?

Also, I'm having trouble fully understanding the code in bind.h and val.h because a lot of it is implemented natively in JavaScript, but I haven't been able to figure out where that code is (or what other code generates it).

- Robert

--
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to