# New Ticket Created by Ronald Blaschke # Please include the string: [perl #47153] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=47153 >
Parrot currently uses indirect DLL linkage, which means that exported data, including PMCNULL, used by PMC_IS_NULL, can not be accessed. Attached patch introduces a function PMC_is_null which should be used instead. An alternative solution would be to use direct DLL linkage, but this would require more work (i.e., get __declspec(dllexport/dllimport) right). What do you guys think? (Should it be possible to use data exported by libparrot?) Changed Files: src/pmc.c include/parrot/pmc.h t/src/compiler.t Ron
Index: src/pmc.c =================================================================== --- src/pmc.c (revision 22695) +++ src/pmc.c (working copy) @@ -39,12 +39,36 @@ #if PARROT_CATCH_NULL -PARROT_API PMC * PMCNULL; +PMC * PMCNULL; #endif /* =item C<PARROT_API +INTVAL +PMC_is_null(PARROT_INTERP, NULLOK(PMC *pmc))> + +Tests if the given pmc is null. + +=cut + +*/ + +PARROT_API +INTVAL +PMC_is_null(PARROT_INTERP, NULLOK(PMC *pmc)) +{ +#if PARROT_CATCH_NULL + return pmc == PMCNULL || pmc == NULL; +#else + return pmc == NULL; +#endif +} + + +/* + +=item C<PARROT_API PARROT_CANNOT_RETURN_NULL PARROT_MALLOC PMC * Index: include/parrot/pmc.h =================================================================== --- include/parrot/pmc.h (revision 22695) +++ include/parrot/pmc.h (working copy) @@ -48,6 +48,10 @@ __attribute__nonnull__(1); PARROT_API +INTVAL PMC_is_null(PARROT_INTERP, NULLOK(PMC *pmc)) + __attribute__nonnull__(1); + +PARROT_API PARROT_CANNOT_RETURN_NULL PARROT_MALLOC PMC * pmc_new(PARROT_INTERP, INTVAL base_type) Index: t/src/compiler.t =================================================================== --- t/src/compiler.t (revision 22695) +++ t/src/compiler.t (working copy) @@ -8,9 +8,7 @@ use Test::More; use Parrot::Test; -plan $^O =~ m/MSWin32|cygwin/ - ? ( skip_all => 'broken on win32 && cygwin' ) - : ( tests => 6 ); +plan tests => 6; =head1 NAME @@ -53,7 +51,7 @@ IGLOBALS_COMPREG_HASH); pir = const_string(interp, "PIR"); comp = VTABLE_get_pmc_keyed_str(interp, compreg, pir); - if (PMC_IS_NULL(comp) || !VTABLE_defined(interp, comp)) { + if (PMC_is_null(interp, comp) || !VTABLE_defined(interp, comp)) { PIO_eprintf(interp, "Pir compiler not loaded"); exit(EXIT_FAILURE); } @@ -62,7 +60,7 @@ */ prog = imcc_compile_pir(interp, c_src); - if (PMC_IS_NULL(prog) || !VTABLE_defined(interp, prog)) { + if (PMC_is_null(interp, prog) || !VTABLE_defined(interp, prog)) { PIO_eprintf(interp, "Pir compiler returned no prog"); exit(EXIT_FAILURE); } @@ -136,7 +134,7 @@ IGLOBALS_COMPREG_HASH); pir = const_string(interp, "PIR"); comp = VTABLE_get_pmc_keyed_str(interp, compreg, pir); - if (PMC_IS_NULL(comp) || !VTABLE_defined(interp, comp)) { + if (PMC_is_null(interp, comp) || !VTABLE_defined(interp, comp)) { PIO_eprintf(interp, "Pir compiler not loaded"); exit(EXIT_FAILURE); } @@ -146,7 +144,7 @@ */ prog = Parrot_compile_string(interp, pir, c_src, &error); - if (PMC_IS_NULL(prog) || !VTABLE_defined(interp, prog)) { + if (PMC_is_null(interp, prog) || !VTABLE_defined(interp, prog)) { PIO_eprintf(interp, "Pir compiler returned no prog"); exit(EXIT_FAILURE); } @@ -211,7 +209,7 @@ opcode_t *dest; prog = Parrot_compile_string(interp, type, src, &error); - if (PMC_IS_NULL(prog) || !VTABLE_defined(interp, prog)) { + if (PMC_is_null(interp, prog) || !VTABLE_defined(interp, prog)) { PIO_eprintf(interp, "Pir compiler returned no prog"); exit(EXIT_FAILURE); } @@ -247,7 +245,7 @@ IGLOBALS_COMPREG_HASH); pir = const_string(interp, "PIR"); comp = VTABLE_get_pmc_keyed_str(interp, compreg, pir); - if (PMC_IS_NULL(comp) || !VTABLE_defined(interp, comp)) { + if (PMC_is_null(interp, comp) || !VTABLE_defined(interp, comp)) { PIO_eprintf(interp, "Pir compiler not loaded"); exit(EXIT_FAILURE); } @@ -302,7 +300,7 @@ opcode_t *dest; prog = Parrot_compile_string(interp, type, src, &error); - if (PMC_IS_NULL(prog) || !VTABLE_defined(interp, prog)) { + if (PMC_is_null(interp, prog) || !VTABLE_defined(interp, prog)) { PIO_eprintf(interp, "Pir compiler returned no prog\n"); return; } @@ -338,7 +336,7 @@ IGLOBALS_COMPREG_HASH); pir = const_string(interp, "PIR"); comp = VTABLE_get_pmc_keyed_str(interp, compreg, pir); - if (PMC_IS_NULL(comp) || !VTABLE_defined(interp, comp)) { + if (PMC_is_null(interp, comp) || !VTABLE_defined(interp, comp)) { PIO_eprintf(interp, "Pir compiler not loaded"); return NULL; } @@ -393,7 +391,7 @@ opcode_t *dest; prog = Parrot_compile_string(interp, type, src, &error); - if (PMC_IS_NULL(prog) || !VTABLE_defined(interp, prog)) { + if (PMC_is_null(interp, prog) || !VTABLE_defined(interp, prog)) { PIO_eprintf(interp, "Pir compiler returned no prog\n"); return; } @@ -429,7 +427,7 @@ IGLOBALS_COMPREG_HASH); pir = const_string(interp, "PIR"); comp = VTABLE_get_pmc_keyed_str(interp, compreg, pir); - if (PMC_IS_NULL(comp) || !VTABLE_defined(interp, comp)) { + if (PMC_is_null(interp, comp) || !VTABLE_defined(interp, comp)) { PIO_eprintf(interp, "Pir compiler not loaded"); return NULL; } @@ -484,7 +482,7 @@ opcode_t *dest; prog = Parrot_compile_string(interp, type, src, &error); - if (PMC_IS_NULL(prog) || !VTABLE_defined(interp, prog)) { + if (PMC_is_null(interp, prog) || !VTABLE_defined(interp, prog)) { PIO_eprintf(interp, "Pir compiler returned no prog\n"); return; } @@ -519,7 +517,7 @@ IGLOBALS_COMPREG_HASH); pir = const_string(interp, "PIR"); comp = VTABLE_get_pmc_keyed_str(interp, compreg, pir); - if (PMC_IS_NULL(comp) || !VTABLE_defined(interp, comp)) { + if (PMC_is_null(interp, comp) || !VTABLE_defined(interp, comp)) { PIO_eprintf(interp, "Pir compiler not loaded"); return NULL; }