Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add support for calling arbitrary P6 functions from P5
  • Loading branch information
niner committed Feb 7, 2015
1 parent 8268489 commit f2963bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Inline/Perl5.pm6
Expand Up @@ -457,7 +457,10 @@ class Perl6Callbacks {
return;
}
method run($code) {
return $!p5.p6_to_p5(EVAL $code);
return EVAL $code;
}
method call(Str $name, @args) {
return &::($name)(|@args);
}
}

Expand Down Expand Up @@ -505,6 +508,11 @@ method init_callbacks {
return $p6->run($code);
}
sub call {
my ($name, @args) = @_;
return $p6->call($name, \@args);
}
sub import {
$package = scalar caller;
}
Expand Down
18 changes: 18 additions & 0 deletions t/call_p6_function_from_p5.t
@@ -0,0 +1,18 @@
#!/usr/bin/env perl6

use v6;
use Inline::Perl5;

my $p5 = Inline::Perl5.new();
$p5.run(q:to/PERL5/);
use 5.10.0;
STDOUT->autoflush(1);
say '1..2';
v6::call('say', 'ok 1');
PERL5

say 'ok 2';

# vim: ft=perl6

0 comments on commit f2963bb

Please sign in to comment.