# New Ticket Created by Jerry Gay # Please include the string: [perl #50878] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=50878 >
'cotto' on #parrot came to me with a problem today. he is unable to call VTABLE_is_equal(...) inside a .pmc file. i'll use src/pmc/exporter.pmc as an example pmc file, because i know its internals. here's a patch: Index: src/pmc/exporter.pmc =================================================================== --- src/pmc/exporter.pmc (revision 25720) +++ src/pmc/exporter.pmc (working copy) @@ -100,6 +100,17 @@ */ +static void test(PARROT_INTERP) { + PMC *p1 = pmc_new(interp, enum_class_String); + PMC *p2 = pmc_new(interp, enum_class_String); + INTVAL cmp; + VTABLE_set_string_native(interp, p1, const_string(interp, "test")); + VTABLE_set_string_native(interp, p2, const_string(interp, "test")); + + cmp = VTABLE_is_equal(interp, p1, p2); + printf("<<<%d>>>\n", cmp); +} + pmclass Exporter need_ext { @@ -117,6 +128,7 @@ void init() { Parrot_Exporter *exp = NULL; + test(INTERP); /* Set up the object. */ exp = mem_allocate_zeroed_typed(Parrot_Exporter); exp->ns_src = PMCNULL; compiling with this patch produces an error like: exporter.obj : error LNK2019: unresolved external symbol _VTABLE_is_equal referenced in function _test err, wha? it's in docs/pdds/pdd17_pmc.pod. it should be there. why on earth isn't it callable? i went digging in include/parrot/vtable.h, tools/build/vtable_h.pl, src/vtable.tbl, lib/Parrot/Vtable.pm. i can't figure out what's going on. i can see that there's no VTABLE_ macro for is_equal (or cmp, for that matter). i just can't put my finger on *why*. i wondered if it was just the missing VTABLE_ accessor macros, so i unrolled the macro. + cmp = (p1)->vtable->is_equal(interp, p1, p2); didn't work: .\src\pmc\exporter.pmc(110) : error C2039: 'is_equal' : is not a member of '_vtable' i was able to work around the problem, looking at how 'eq' is implemented in src/ops/cmp.ops gave me an idea. if i replace the line + cmp = VTABLE_is_equal(interp, p1, p2); with + cmp = mmd_dispatch_i_pp(interp, p1, p2, MMD_EQ); then it works. so, mmd dispatch is working. the functions are there. what am i missing? i'm guessing it's something in the perl that generates the c, but i have to step away for a while. i'd be happy if somebody else put their eyes on it, too. chromatic? anyone? ~jerry