Uh... ping?

On Mon, Dec 03, 2007 at 11:09:26PM +0100, pancake wrote:
> I have been looking a bit inside PDDs and parrot source and find no way to
> load a pointer to a function as a PMC inside the VM.
> 
> What I want to do is to embed parrot into a C program and make some of the
> functions of this C program available via NCI to the vm.
> 
> I have achieved this by using the tip noted in docs/compiler_faq.pod (thanks 
> kjs!)
> which says I need to pass a null string to loadlib and compile the parent C 
> program
> with -export-dynamic which is GCC specific... So imho looks like an ugly 
> system-
> dependant 'hack'.
> 
> I have found some interesting funcs in src/inter_misc.c but seems not to fix 
> the problem,
> can anybody give me an appoint? I know that the NCI part is not yet finished, 
> but IMHO
> these functions should follow the Parrot_ name convention and make them 
> available from
> the Parrot API.
> 
> Here's the source:
> 
> #include <parrot/parrot.h>
> 
> void func()
> {
>         printf("Hello World!\n");
> }
> 
> int main(int argc, char **argv)
> {
>         PMC *method;
>         Parrot_Interp pvm = Parrot_new(NULL);
> 
>         register_nci_method(pvm, enum_class_NCI, &func, "func", "v");
> 
>         Parrot_PackFile pf = Parrot_readbc(pvm, "hello.pbc");
>         if (pf == NULL) {
>                 fprintf(stderr, "Oops. Cannot open hello.pbc\n");
>                 return 1;
>         }
> 
> 
>         /* */
>         Parrot_loadbc(pvm, pf);
> 
>         Parrot_runcode(pvm, argc, argv);
> 
>         Parrot_destroy(pvm);
> }
> 
> $ cat hello.pir
> 
> .sub main :main
>         func()
>         say "Hello World"
> .end
> 
> 
> $ cat Makefile
> 
> all:
>         parrot -o hello.pbc hello.pir
>         gcc main.c `pkg-config --cflags --libs parrot` -export-dynamic
> 
> 
>   Thanks!
> 
>   --pancake
> 

Reply via email to