Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support import list in $p5.use
  • Loading branch information
niner committed Oct 14, 2014
1 parent ac78b77 commit 2f51f44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/Inline/Perl5.pm6
Expand Up @@ -199,6 +199,9 @@ sub p5_is_wrapped_p6_object(Perl5Interpreter, OpaquePointer)
sub p5_unwrap_p6_object(Perl5Interpreter, OpaquePointer)
returns Int { ... }
native(&p5_unwrap_p6_object);
sub p5_use(Perl5Interpreter, OpaquePointer)
{ ... }
native(&p5_use);
sub p5_terminate()
{ ... }
native(&p5_terminate);
Expand Down Expand Up @@ -510,8 +513,10 @@ method rebless(Perl5Object $obj) {
p5_rebless_object($!p5, $obj.ptr);
}

method use(Str $module) {
self.run("use $module;");
method use(Str $module, *@args) {
my $module_sv = self.p6_to_p5($module);
p5_use($!p5, $module_sv);
self.invoke($module, 'import', @args.list);
}

submethod DESTROY {
Expand Down
4 changes: 4 additions & 0 deletions p5helper.c
Expand Up @@ -585,3 +585,7 @@ XS(p5_call_p6_callable) {
XSRETURN(1);
}
}

void p5_use(PerlInterpreter *my_perl, SV *module) {
load_module(PERL_LOADMOD_NOIMPORT, module, NULL);
}
3 changes: 1 addition & 2 deletions t/use.t
Expand Up @@ -4,9 +4,8 @@ use v6;
use Inline::Perl5;

my $p5 = Inline::Perl5.new();
$p5.use('Test::More');
$p5.use('Test::More', 'tests', 1);
$p5.call('Test::More::ok', 1);
$p5.call('Test::More::done_testing');

$p5.DESTROY;

Expand Down

0 comments on commit 2f51f44

Please sign in to comment.