From: Matt S Trout Date: Sun, 1 Jul 2007 19:58:15 +0000 (+0000) Subject: split usepack and namepack X-Git-Tag: 0.005000~135 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9026391e1fe16f5efd1d3af249a55b669f0e3618;p=p5sagit%2FDevel-Declare.git split usepack and namepack --- diff --git a/Declare.xs b/Declare.xs index c1407a0..0dec6a0 100644 --- a/Declare.xs +++ b/Declare.xs @@ -51,7 +51,7 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o) { HV* is_declarator_pack_hash; SV** is_declarator_flag_ref; int dd_flags; - char* cb_args[5]; + char* cb_args[6]; dSP; /* define stack pointer for later call stuff */ char* retstr; STRLEN n_a; /* for POPpx */ @@ -185,9 +185,10 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o) { #endif cb_args[0] = HvNAME(stash); cb_args[1] = GvNAME(kGVOP_gv); - cb_args[2] = found_name; - cb_args[3] = found_proto; - cb_args[4] = NULL; + cb_args[2] = HvNAME(PL_curstash); + cb_args[3] = found_name; + cb_args[4] = found_proto; + cb_args[5] = NULL; if (len && found_proto) in_declare = 2; diff --git a/lib/Devel/Declare.pm b/lib/Devel/Declare.pm index 4d4e3c9..707f3e1 100644 --- a/lib/Devel/Declare.pm +++ b/lib/Devel/Declare.pm @@ -67,14 +67,14 @@ my $temp_name; my $temp_save; sub init_declare { - my ($pack, $use, $name, $proto) = @_; + my ($usepack, $use, $inpack, $name, $proto) = @_; my ($name_h, $XX_h, $extra_code) - = $declarator_handlers{$pack}{$use}->( - $pack, $use, $name, $proto, defined(wantarray) + = $declarator_handlers{$usepack}{$use}->( + $usepack, $use, $inpack, $name, $proto, defined(wantarray) ); ($temp_name, $temp_save) = ([], []); if ($name) { - $name = "${pack}::${name}" unless $name =~ /::/; + $name = "${inpack}::${name}" unless $name =~ /::/; push(@$temp_name, $name); no strict 'refs'; push(@$temp_save, \&{$name}); @@ -83,12 +83,12 @@ sub init_declare { *{$name} = $name_h; } if ($XX_h) { - push(@$temp_name, "${pack}::X"); + push(@$temp_name, "${inpack}::X"); no strict 'refs'; - push(@$temp_save, \&{"${pack}::X"}); + push(@$temp_save, \&{"${inpack}::X"}); no warnings 'redefine'; no warnings 'prototype'; - *{"${pack}::X"} = $XX_h; + *{"${inpack}::X"} = $XX_h; } if (defined wantarray) { return $extra_code || '0;'; diff --git a/t/pack.t b/t/pack.t index 0222dbd..c4711d4 100644 --- a/t/pack.t +++ b/t/pack.t @@ -5,7 +5,7 @@ use Test::More 'no_plan'; sub class { $_[0]->(); } sub handle_class { - my ($pack, $use, $name, $proto, $is_block) = @_; + my ($usepack, $use, $inpack, $name, $proto, $is_block) = @_; return (sub (&) { shift; }, undef, "package ${name};"); } diff --git a/t/proto.t b/t/proto.t index 240eb09..ab08455 100644 --- a/t/proto.t +++ b/t/proto.t @@ -7,7 +7,7 @@ sub fun :lvalue { return my $sv; } sub X { "what?" } sub handle_fun { - my ($pack, $use, $name, $proto) = @_; + my ($usepack, $use, $inpack, $name, $proto) = @_; my $XX = sub (&) { my $cr = $_[0]; return sub { diff --git a/t/simple.t b/t/simple.t index 9b022d0..edc09d3 100644 --- a/t/simple.t +++ b/t/simple.t @@ -3,14 +3,14 @@ use warnings; use Test::More 'no_plan'; sub method { - my ($pack, $name, $sub) = @_; + my ($usepack, $name, $inpack, $sub) = @_; no strict 'refs'; - *{"${pack}::${name}"} = $sub; + *{"${inpack}::${name}"} = $sub; } sub handle_method { - my ($pack, $use, $name) = @_; - return sub (&) { ($pack, $name, $_[0]); }; + my ($usepack, $use, $inpack, $name) = @_; + return sub (&) { ($usepack, $name, $inpack, $_[0]); }; } use Devel::Declare 'method' => \&handle_method;