Skip to content
This repository
Newer
Older
100644 78 lines (63 sloc) 1.389 kb
1e1a24ea » pmurias
2011-09-23 Eval runs basic perl5 code. The Makefile needs review to check if it can
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
4266b444 » pmurias
2011-09-24 Argumentless method call on perl5 objects.
32 SV* p5embed_eval(char* code) {
33 return eval_pv(code,TRUE);
1e1a24ea » pmurias
2011-09-23 Eval runs basic perl5 code. The Makefile needs review to check if it can
34 }
35
36 void p5embed_dispose()
37 {
16ef0c81 » pmurias
2011-09-24 cleanup the perl5 interpreter in Perl5Interpreter destructor
38 perl_destruct(my_perl);
39 perl_free(my_perl);
40 PERL_SYS_TERM();
1e1a24ea » pmurias
2011-09-23 Eval runs basic perl5 code. The Makefile needs review to check if it can
41 }
4266b444 » pmurias
2011-09-24 Argumentless method call on perl5 objects.
42
f20f8320 » pmurias
2011-10-01 Perl5 NV values are converted.
43 void p5method_call(char* name,SV** args,int n) {
4266b444 » pmurias
2011-09-24 Argumentless method call on perl5 objects.
44 dSP;
45
46
47 /*ENTER;
48 SAVETMPS;*/
49
50 PUSHMARK(SP);
a20956d9 » pmurias
2011-09-24 Arguments are passed to perl 5 methods.
51 int i;
52 for (i=0;i<n;i++) {
53 XPUSHs(args[i]);
54 }
4266b444 » pmurias
2011-09-24 Argumentless method call on perl5 objects.
55 PUTBACK;
56
57 call_method(name,G_DISCARD);
58
59 /*FREETMPS;
60 LEAVE;*/
61 }
18b719fb » pmurias
2011-10-01 Perl5 integers are converted rather than wrapped.
62
63 int p5embed_SvIOKp(SV* sv) {
64 return SvIOKp(sv);
65 }
66 int p5embed_SvNOKp(SV* sv) {
67 return SvNOKp(sv);
68 }
69 int p5embed_SvPOKp(SV* sv) {
70 return SvPOKp(sv);
71 }
72
73 int p5embed_SvIV(SV* sv) {
74 return SvIV(sv);
75 }
f20f8320 » pmurias
2011-10-01 Perl5 NV values are converted.
76 double p5embed_SvNV(SV* sv) {
77 return SvNV(sv);
78 }
Something went wrong with that request. Please try again.