- Timestamp:
- 05/27/05 02:08:48 (4 years ago)
- svk:copy_cache_prev:
- 5515
- Location:
- src/perl5
- Files:
-
- 2 modified
-
perl5.c (modified) (3 diffs)
-
pugsembed.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/perl5/perl5.c
r3936 r3937 12 12 static PerlInterpreter *my_perl; 13 13 14 const char eval_file_code[] = 14 int __init = 0; 15 16 const char pugs_guts_code[] = 15 17 "use strict;" 16 18 "package pugs;" … … 19 21 "sub AUTOLOAD { }" 20 22 "warn 'perl5 glue compiled';" 21 //"pugs::guts::test();" 22 23 " package pugs::code;"24 " sub new {}"23 24 "package pugs::guts;" 25 "sub code { my ($class, $val) = @_;" 26 " sub { pugs::guts::invoke($val, undef, @_) } }" 25 27 "1;"; 26 28 27 XS(_pugs_guts_test) { 29 XS(_pugs_guts_invoke) { 30 Val *val, *inv, **stack; 31 SV *ret; 32 int i; 28 33 dXSARGS; 29 if (items !=1)34 if (items < 1) 30 35 Perl_croak(aTHX_ "hate software"); 31 36 37 val = pugs_SvToVal(ST(0)); 38 inv = pugs_SvToVal(ST(1)); 39 40 stack = (Val **)malloc(sizeof(Val*)*items-2); 41 for (i = 2; i < items; ++i) { 42 stack[i-2] = pugs_SvToVal(ST(i)); 43 } 44 45 fprintf(stderr, "back to pugs\n"); 46 ret = pugs_ValToSv(pugs_Apply (val, inv, stack)); 47 48 free (stack); 49 32 50 XSRETURN(1); 33 51 } … … 117 135 118 136 exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL); 137 fprintf(stderr, "hello, perl5: %d\n", exitstatus); 119 138 120 139 if (exitstatus == 0) 121 140 exitstatus = perl_run( my_perl ); 122 return exitstatus; 123 141 142 __init = 1; 124 143 fprintf(stderr, "hello, perl5\n"); 125 144 126 newXS((char*) "pugs::guts:: test", _pugs_guts_test, (char*)__FILE__);127 128 eval_pv( eval_file_code, FALSE);145 newXS((char*) "pugs::guts::invoke", _pugs_guts_invoke, (char*)__FILE__); 146 147 eval_pv(pugs_guts_code, TRUE); 129 148 130 149 if (SvTRUE(ERRSV)) { -
src/perl5/pugsembed.c
r3934 r3937 1 1 #include <pugsembed.h> 2 extern int __init; 2 3 3 4 Val * … … 15 16 { 16 17 SV *sv = newSV(0); 18 Val *isa[2]; 19 SV *stack[8]; 20 17 21 fprintf(stderr, "pugs mkvalref: %p\n", val); 18 Val *isa[2]; 22 sv_setref_pv(sv, "pugs", val); 23 19 24 isa[0] = pugs_PvToVal("Code"); 20 25 isa[1] = NULL; 21 if ( pugs_ValToIv(pugs_Apply(pugs_PvToVal("&isa"), val, isa))) {26 if (__init && pugs_ValToIv(pugs_Apply(pugs_PvToVal("&isa"), val, isa))) { 22 27 fprintf(stderr, "got a code!!\n"); 28 stack[0] = newSVpv("pugs::guts", 0); 29 stack[1] = sv; 30 sv = perl5_call("code", 2, stack, NULL, G_SCALAR); 23 31 } 24 sv_setref_pv(sv, "pugs", val);25 32 return (sv); 26 33 }
