Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (48 sloc) 1.122 kB
1e1a24e @pmurias Eval runs basic perl5 code. The Makefile needs review to check if it can
pmurias authored
1 #include <EXTERN.h>
2 #include <perl.h>
3
4 /* So that we can load XS using modules from our perl */
5 EXTERN_C void xs_init (pTHX);
6
7 EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
8
9 EXTERN_C void
10 xs_init(pTHX)
11 {
12 char *file = __FILE__;
13 dXSUB_SYS;
14
15 /* DynaLoader is a special case */
16 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
17 }
18
19 static PerlInterpreter *my_perl;
20 void p5embed_initialize()
21 {
22 PERL_SYS_INIT3(0,NULL,NULL);
23 PerlInterpreter* my_perl = perl_alloc();
24 PERL_SET_CONTEXT(my_perl);
25 perl_construct(my_perl);
26 char *embedding[] = { "", "-e", "0" };
27 perl_parse(my_perl, xs_init, 3, embedding, NULL);
28 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
29 eval_pv("use lib 'perl5';use Niecza::Interoperability",TRUE);
30 }
31
4266b44 @pmurias Argumentless method call on perl5 objects.
pmurias authored
32 SV* p5embed_eval(char* code) {
33 return eval_pv(code,TRUE);
1e1a24e @pmurias Eval runs basic perl5 code. The Makefile needs review to check if it can
pmurias authored
34 }
35
36 void p5embed_dispose()
37 {
16ef0c8 @pmurias cleanup the perl5 interpreter in Perl5Interpreter destructor
pmurias authored
38 perl_destruct(my_perl);
39 perl_free(my_perl);
40 PERL_SYS_TERM();
1e1a24e @pmurias Eval runs basic perl5 code. The Makefile needs review to check if it can
pmurias authored
41 }
4266b44 @pmurias Argumentless method call on perl5 objects.
pmurias authored
42
a20956d @pmurias Arguments are passed to perl 5 methods.
pmurias authored
43 void p5method_call(char* name,int* args,int n) {
4266b44 @pmurias Argumentless method call on perl5 objects.
pmurias authored
44 dSP;
45
46
47 /*ENTER;
48 SAVETMPS;*/
49
50 PUSHMARK(SP);
a20956d @pmurias Arguments are passed to perl 5 methods.
pmurias authored
51 int i;
52 for (i=0;i<n;i++) {
53 XPUSHs(args[i]);
54 }
4266b44 @pmurias Argumentless method call on perl5 objects.
pmurias authored
55 PUTBACK;
56
57 call_method(name,G_DISCARD);
58
59 /*FREETMPS;
60 LEAVE;*/
61 }
Something went wrong with that request. Please try again.