On Aug 23, 2005, at 14:38, Klaas-Jan Stol wrote:


Leopold Toetsch wrote:

Klaas-Jan Stol wrote:

void print_pmc(void *PMC)
{
   // how to access the string in P?
}


If it's a stringish PMC, then STRING *s = VTABLE_get_string(INTERP, p); will do it.

The C code is just in a .c file, it's not like a PMC or something. So, I don't think I can use "INTERP", or VTABLE_get_string() at all. Or should I link to parrotlib.a or something?

INTERP is just translated to interpreter (see any classes/.c file). VTABLE_get_string is available in the whole Parrot tree, it's a macro define in include/parrot/vtable.h. I don't know in what relation your "plain" .c file is to parrot, but you might have a look at src/extend.c, which also provides interfaces for such stuff.

Is there some public API for accessing the fields in a PMC (for standard PMCs, so accessing the intval for the Integer PMC and its decendents, floatval for Float PMC, stringval for String PMCs, etc) ?

Have a look at src/extend.c for the most abstract API.

You might also consider switching to branches/leo-ctx5. The new calling conventions do auto-conversion betwen PMCs and I/S/N in both directions for NCI too.

Forgive my ignorance, but I don't really understand. I'm only using PMCs, no I/S/N values. Why would using these auto-conversions be interesting?

If you are calling a NCI method, which takes native types (or returns one) from PIR, you can still pass in PMCs (and will get a PMC as result, if appropriate).


Btw, I also got this leo-ctx5 branch, compiled it, and run it from the directory where my lua stuff is, like this:

   $ ../leo-ctx5/parrot a.pir

it says:

   PackFile_FixupTable_unpack: Unknown fixup type 1953066601!
   PackFile_unpack segment 'FIXUP_luaglobals.pir' failed

$ make realclean and be sure to delete your .pbc files too. You can't share PBCs between trunk and leo-ctx5 - run a.pir in distinct directories.

klaas-jan

leo

Reply via email to