Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perl5 NV values are converted.
  • Loading branch information
pmurias committed Oct 1, 2011
1 parent 18b719f commit f20f832
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/perl5.pl
Expand Up @@ -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");

5 changes: 5 additions & 0 deletions lib/Perl5Interpreter.cs
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/p5embed.c
Expand Up @@ -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;


Expand Down Expand Up @@ -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.