Skip to content

Commit

Permalink
Fix bug in Parrot_sub_new_from_c_func cause by not using PARROT_CALLI…
Browse files Browse the repository at this point in the history
…N_(START|END) and attempt to add test coverage
  • Loading branch information
leto committed Jun 19, 2011
1 parent a418dad commit a0911db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/extend.c
Expand Up @@ -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;
}

Expand Down
13 changes: 8 additions & 5 deletions t/src/embed.t
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit a0911db

Please sign in to comment.