Permalink
Browse files

Perl5 NV values are converted.

  • Loading branch information...
1 parent 18b719f commit f20f83209cd0b3c35e40f0766219c7d8549f18e9 @pmurias pmurias committed Oct 1, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −0 examples/perl5.pl
  2. +5 −0 lib/Perl5Interpreter.cs
  3. +4 −1 lib/p5embed.c
View
@@ -20,4 +20,5 @@ sub new {
my $foo = eval(:lang<perl5>,'Foo->new');
$foo.baz(eval(:lang<perl5>,'"Perl hacker"'));
say eval(:lang<perl5>,"125");
+say eval(:lang<perl5>,"13.5");
View
@@ -15,6 +15,9 @@ public class Perl5Interpreter : IForeignInterpreter {
[DllImport("obj/p5embed.so", EntryPoint="p5embed_SvIV")]
public static extern int SvIV(IntPtr sv);
+ [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvNV")]
+ public static extern double SvNV(IntPtr sv);
+
[DllImport("obj/p5embed.so", EntryPoint="p5embed_SvIOKp")]
public static extern int SvIOKp(IntPtr sv);
@@ -27,6 +30,8 @@ public class Perl5Interpreter : IForeignInterpreter {
public static Variable SVToVariable(IntPtr sv) {
if (SvIOKp(sv) != 0) {
return Builtins.MakeInt(SvIV(sv));
+ } else if (SvNOKp(sv) != 0) {
+ return Builtins.MakeFloat(SvNV(sv));
} else {
return new SVVariable(sv);
}
View
@@ -40,7 +40,7 @@ void p5embed_dispose()
PERL_SYS_TERM();
}
-void p5method_call(char* name,int* args,int n) {
+void p5method_call(char* name,SV** args,int n) {
dSP;
@@ -73,3 +73,6 @@ int p5embed_SvPOKp(SV* sv) {
int p5embed_SvIV(SV* sv) {
return SvIV(sv);
}
+double p5embed_SvNV(SV* sv) {
+ return SvNV(sv);
+}

0 comments on commit f20f832

Please sign in to comment.