At 02:17 PM 6/1/2002 -0400, Melvin Smith wrote:
># t.pasm
>loadlib P0, "libpqt.so"
>print "Loaded\n"
>callnative P1, P0, "PQt_init"
>end
The correct code is actually:
loadlib P0, "libpqt.so"
print "Loaded\n"
# Save an argument for native method
save "Testing..."
# callnative calls a native method and caches the handle in P1
callnative P1, P0, "PQt_init"
end
And the lib should be:
int PQt_init(Parrot_Interp interp) {
int i;
char * s;
fprintf(stderr, "PQt_init\n");
if(!interp)
fprintf(stderr, "NULL Interp!\n");
fprintf(stderr, "Interp has %d ops\n", interp->op_count);
s = PXS_shiftcs(interp);
fprintf(stderr, "arg1[%s]\n", s);
return 0;
}
But the question still stands...
-Melvin
>/* libpqt.c */
>int PQt_init(Interp * interp) {
> STRING * s;
> if(!interp) {
> fprintf(stderr, "NULL Interp!\n");
> return -1;
> }
>
> fprintf(stderr, "Interp has %d ops\n", interp->op_count);
>
> /* Get a STRING off the user stack */
> PXS_shifts(interp, s);
>
> /* Oops, shifting s off the Parrot stack might have been
> * removed it from the root set.
> */
>
>}
>
>
>Now there are a dozen ways to handle this. Using flags, keeping args on the
>stack until return, yada yada yada...
>
>I'd like to hear suggestions, or maybe reference to past discussions I might
>have missed on how we shall handle this. Actually I want more than
>suggestions,
>I want a voice from the sky to boom, "Go that way!"
>
>-Melvin