On 3 May 2004, at 09:11, Leopold Toetsch wrote:
Arthur Bergman wrote:On 2 May 2004, at 12:37, Leopold Toetsch wrote:
Can't you call that somewhere in an outer frame? E.g. where you createNo, because I might be creating the interpreter in a callback from the application, and then access that interpreter in ANOTHER callback from the application.
the interpreter.
Your are speaking of a usage like "perldoc perlembed" here, I presume. For old code that is totally unaware that its running on Parrot, you'll have to anchor (dod_register) returned PMCs. dodregister() works like REFCNT_inc(), i.e. you can register a PMC multiple times. unregister is like REFCNT_dec(), except there is no immediate destruction if the register count reaches zero.
Such an embeded usage might also need a flag for entering the run loop, so that the stack top is always set at the run loop stack frame.
Arthur
leo
IGNORE PERL5 IGNORE PERLEMBED, IGNORE ANY FUCKING REFERENCE TO PERL5, ALSO USE THE EMBEDDING API NAMES NOT THE INTERNAL ONES
Let us say I want to embed parrot in application x, application x is binary only and has an plugin API, this has three callbacks
app_x_init_plugin app_x_run_plugin app_x_destroy_plugin
When the app loads the plugin, it calls app_x_init_plugin, in this routine I load parrot using Parrot_init(Parrot_Interp); I return from my init function and the program continues to run, ANY STACK AUTO VARIABLE CAPTURED IN THIS FRAME IS FROM NOW ON USELESS
Then when it runs and wants to use me it calls app_x_run_plugin, in here I set up some PMCs,<underlined><bold>REGISTER THEM</bold></underlined> using Parrot_register_pmc, then call into parrot using for example void Parrot_runcode(Parrot_Interp, int argc, char *argv[]); Now my argument is that currently this does not work because the stacktop is not set! so what Parrot_runcode should do is in
{ if(!parrot->stacktop) { set_stacktop } Perl_runcode_real(...) }
So for the embedder it is transparent if the stacktop is set or not.
Arthur