Hi list, apologies for bumping the question below, but I've had to put my Emscripten project on hold temporarily as it was running way over the time I had set aside... it would be really good if, when I get back onto it, I can find a solution to this problem quickly. Any pointers would be greatly appreciated.

At the very least, it would be good to get confirmation that dynamic variadic callbacks are impossible with the current template-based C++ callback API would help me plan out realistically how much time I need to spend patching in support for dynamic binding so I can make this work.

I presume such a feature would be of value to anyone who, like me, is writing new library code intended to interact closely with JavaScript in a controlled way, rather than porting across a complete pre-existing C/C++ application, which can have static bindings as it wouldn't be expecting anything else.

TIA,

- Robert

On 22/09/2014 14:05, Robert Tweed wrote:
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