Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (46 sloc) 1.109 kb
1e1a24e Pawel Murias 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 Pawel Murias Argumentless method call on perl5 objects.
pmurias authored
32 SV* p5embed_eval(char* code) {
33 return eval_pv(code,TRUE);
1e1a24e Pawel Murias Eval runs basic perl5 code. The Makefile needs review to check if it can
pmurias authored
34 }
35
36 void p5embed_dispose()
37 {
16ef0c8 Pawel Murias cleanup the perl5 interpreter in Perl5Interpreter destructor
pmurias authored
38 perl_destruct(my_perl);
39 perl_free(my_perl);
40 PERL_SYS_TERM();
1e1a24e Pawel Murias Eval runs basic perl5 code. The Makefile needs review to check if it can
pmurias authored
41 }
4266b44 Pawel Murias Argumentless method call on perl5 objects.
pmurias authored
42
43 void p5method_call(char* name,SV* invocant) {
44 dSP;
45
46 SvREFCNT_inc(invocant);
47
48 /*ENTER;
49 SAVETMPS;*/
50
51 PUSHMARK(SP);
52 XPUSHs(invocant);
53 PUTBACK;
54
55 call_method(name,G_DISCARD);
56
57 /*FREETMPS;
58 LEAVE;*/
59 }
Something went wrong with that request. Please try again.