From a0911dbf766eeff370f28b9dbbd47854aaeb472a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 19 Jun 2011 11:58:07 -0700 Subject: [PATCH] Fix bug in Parrot_sub_new_from_c_func cause by not using PARROT_CALLIN_(START|END) and attempt to add test coverage --- src/extend.c | 4 ++++ t/src/embed.t | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/extend.c b/src/extend.c index bc6130ca6d..af1315f542 100644 --- a/src/extend.c +++ b/src/extend.c @@ -715,10 +715,14 @@ Parrot_sub_new_from_c_func(PARROT_INTERP, ARGIN(void (*func)(void)), ARGIN(const char * signature)) { ASSERT_ARGS(Parrot_sub_new_from_c_func) + PARROT_CALLIN_START(interp); + Parrot_String sig = Parrot_new_string(interp, signature, strlen(signature), (char *) NULL, 0); Parrot_PMC sub = Parrot_pmc_new(interp, enum_class_NCI); VTABLE_set_pointer_keyed_str(interp, sub, sig, F2DPTR(func)); + + PARROT_CALLIN_END(interp); return sub; } diff --git a/t/src/embed.t b/t/src/embed.t index c9ff6fc82d..e4bb739594 100644 --- a/t/src/embed.t +++ b/t/src/embed.t @@ -42,6 +42,7 @@ my $common = linedirective(__LINE__) . <<'CODE'; #include "parrot/embed.h" #include "parrot/extend.h" #include "parrot/extend_vtable.h" +#include "imcc/api.h" static void fail(const char *msg); static Parrot_String createstring(Parrot_Interp interp, const char * value); @@ -580,12 +581,13 @@ int main(void) Parrot_String compiler; Parrot_String errstr; Parrot_PMC code; - Parrot_PMC hellosub; + Parrot_PMC hellosub, pir_compiler, pasm_compiler, interp_pmc; /* Create the interpreter */ - interp = Parrot_new(NULL); - if (! interp) - fail("Cannot create parrot interpreter"); + interp = new_interp(); + + imcc_get_pir_compreg_api(interp_pmc, 1, &pir_compiler); + imcc_get_pir_compreg_api(interp_pmc, 1, &pasm_compiler); /* Compile pir */ compiler = createstring(interp, "PIR"); @@ -620,7 +622,7 @@ void hello(Parrot_Interp interp) int main(void) { Parrot_Interp interp; - Parrot_String compiler; + Parrot_String compiler, pir_compiler; Parrot_String errstr; Parrot_PMC code; Parrot_PMC hellosub; @@ -635,6 +637,7 @@ int main(void) if (! interp) fail("Cannot create parrot interpreter"); + /* Compile pir */ compiler = createstring(interp, "PIR"); code = Parrot_compile_string(interp, compiler,