Permalink
Browse files

Perl5 integers are converted rather than wrapped.

  • Loading branch information...
1 parent d2c05c8 commit 18b719fb709fa5cf3270bb38ace9614704f82c2b @pmurias pmurias committed Oct 1, 2011
Showing with 35 additions and 1 deletion.
  1. +2 −0 examples/perl5.pl
  2. +19 −1 lib/Perl5Interpreter.cs
  3. +14 −0 lib/p5embed.c
View
@@ -19,3 +19,5 @@ sub new {
PERL5
my $foo = eval(:lang<perl5>,'Foo->new');
$foo.baz(eval(:lang<perl5>,'"Perl hacker"'));
+say eval(:lang<perl5>,"125");
+
View
@@ -12,7 +12,25 @@ public class Perl5Interpreter : IForeignInterpreter {
[DllImport("obj/p5embed.so", EntryPoint="p5embed_eval")]
public static extern IntPtr EvalPerl5(string code);
+ [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvIV")]
+ public static extern int SvIV(IntPtr sv);
+ [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvIOKp")]
+ public static extern int SvIOKp(IntPtr sv);
+
+ [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvNOKp")]
+ public static extern int SvNOKp(IntPtr sv);
+
+ [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvPOKp")]
+ public static extern int SvPOKp(IntPtr sv);
+
+ public static Variable SVToVariable(IntPtr sv) {
+ if (SvIOKp(sv) != 0) {
+ return Builtins.MakeInt(SvIV(sv));
+ } else {
+ return new SVVariable(sv);
+ }
+ }
public Perl5Interpreter() {
Initialize();
@@ -21,7 +39,7 @@ public class Perl5Interpreter : IForeignInterpreter {
Dispose();
}
public Variable Eval(string code) {
- return new SVVariable(EvalPerl5(code));
+ return SVToVariable(EvalPerl5(code));
}
}
View
@@ -59,3 +59,17 @@ void p5method_call(char* name,int* args,int n) {
/*FREETMPS;
LEAVE;*/
}
+
+int p5embed_SvIOKp(SV* sv) {
+ return SvIOKp(sv);
+}
+int p5embed_SvNOKp(SV* sv) {
+ return SvNOKp(sv);
+}
+int p5embed_SvPOKp(SV* sv) {
+ return SvPOKp(sv);
+}
+
+int p5embed_SvIV(SV* sv) {
+ return SvIV(sv);
+}

0 comments on commit 18b719f

Please sign in to comment.