On Wed Mar 07 17:02:47 2007, mdiep wrote: > This gets us close to what I want: > > > > void* invoke(void *next) { > STRING *meth = CONST_STRING(interp, "__invoke"); > STRING *meth_v = CONST_STRING(interp, "invoke"); > PMC *sub = Parrot_find_vtable_meth(interp, pmc, meth_v); > if (PMC_IS_NULL(sub)) > sub = find_or_die(interp, pmc, meth); > (void*) Parrot_run_meth_fromc_args(interp, sub, > pmc, meth, "??", next); > return next; > }
We all missed the obvious solution: just invoking the sub, rather than entering a new runloop. This has the benefits of not creating a new runloop and of handling parameters and return values properly. It may even make invoke work with :multi (it might need a bit more work for that). Fixed in r17385. -- Matt Diephouse void* invoke(void *next) { STRING *meth = CONST_STRING(interp, "__invoke"); STRING *meth_v = CONST_STRING(interp, "invoke"); PMC *sub = Parrot_find_vtable_meth(interp, pmc, meth_v); if (PMC_IS_NULL(sub)) sub = find_or_die(interp, pmc, meth); INTERP->current_object = SELF; return VTABLE_invoke(interp, sub, next); }