Maybe I wasn't understanding you before. A concrete code sample might help.
- Alon On Thu, Apr 30, 2015 at 2:13 PM, <[email protected]> wrote: > Thank you for your answer! > > Although I am totally not getting anything from that 19 lines of test case > and how anything is supposed to work with that, let alone what that test > case is actually doing. Looks very cryptic to me. :) > But if you say it's gonna work this way, then I will try further. > > I just don't know how it can be possible to invoke a function whose > signature I cannot express in C code at compile time with a prototype, > since the actual signature is encoded via some other mechanism as a string > that I can query at runtime, such as "(II)V", meaning "take two integers > and return void". > > And I don't know how to put arguments from the emscripten HEAP on the C > stack and call that function then. > > dlfnc symbols seem to be needing a compile-time function prototype to cast > against before invoking the function. > But I don't have that. And I think that's also the problem that libffi is > solving with all that assembler magic, because one has no function > prototype/signature at compile time. > > So the original question was whether it would then make more sense to > generate asm.js code during runtime which is able to decode the signature > string (i.e. the "(II)V") of the function into a real JavaScript function > invocation. > > Thanks again! > > Am Samstag, 25. April 2015 10:26:53 UTC+2 schrieb [email protected]: >> >> Hi there, >> >> I was wondering what would be a possible solution to dynamically call an >> Emscripten-compiled function within the same application (no dynamic >> library). >> The issue is that during compile-time I do not know the target function's >> signature and therefore do not have static C caller code that could invoke >> the required function, but must instead build such code during runtime. >> >> For native languages there exists libffi for exactly this purpose and it >> is using assembler code to put function arguments on the stack. >> I was wondering what the best approach with emscripten is to link a >> dynamic function call to its target function. >> The information I have at a possible caller-site is: (function name, >> function signature, base stack pointer on the heap of the first argument). >> I was thinking about dynamically building a small asm.js module which >> reads the arguments from the heap starting at the base pointer and which >> then builds an appropriate function call. >> This script I would then eval() in order to get an asm.js-compiled >> libffi-like interface. >> >> Would this be a viable approach? >> >> Thanks! >> >> Kind regards, >> Kai >> > -- > 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. > -- 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.
