From c760c918c71b4e55dc300234d0a8679a6bdf1e3c Mon Sep 17 00:00:00 2001 From: Richard Clamp Date: Mon, 9 Dec 2002 11:10:24 +0000 Subject: [PATCH] Integrate changes to Attribute::Handlers from maint-5.8 (18404 and 18427). Subject: [PATCH] Re: Attribute::Handlers phase variance Message-ID: <20021209111024.GA14365@mirth.demon.co.uk> p4raw-id: //depot/perl@18499 p4raw-integrated: from //depot/maint-5.8/perl@18498 'copy in' lib/Attribute/Handlers.pm (@18080..) lib/Attribute/Handlers/t/multi.t (@18404..) --- lib/Attribute/Handlers.pm | 3 ++- lib/Attribute/Handlers/t/multi.t | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Attribute/Handlers.pm b/lib/Attribute/Handlers.pm index a26ed18..9dfe783 100644 --- a/lib/Attribute/Handlers.pm +++ b/lib/Attribute/Handlers.pm @@ -137,7 +137,8 @@ sub _gen_handler_AH_() { %lastattr=(pkg=>$pkg,ref=>$ref,type=>$data); } else { - my $handler = $pkg->can($attr); + my $type = ref $ref; + my $handler = $pkg->can("_ATTR_${type}_${attr}"); next unless $handler; my $decl = [$pkg, $ref, $attr, $data, $raw{$handler}, $phase{$handler}]; diff --git a/lib/Attribute/Handlers/t/multi.t b/lib/Attribute/Handlers/t/multi.t index cddab91..db00b1c 100644 --- a/lib/Attribute/Handlers/t/multi.t +++ b/lib/Attribute/Handlers/t/multi.t @@ -184,3 +184,20 @@ ok(1,52 ,"# Skip, no difference between lexical handlers and normal handlers pri ok( $match, 52 ); } + +# The next two check for the phase invariance that Marcel spotted. +# Subject: Attribute::Handlers phase variance +# Message-Id: <54EDDB80-FD75-11D6-A18D-00039379E28A@noug.at> + +my ($code_applied, $scalar_applied); +sub Scotty :ATTR(CODE,BEGIN) { $code_applied = $_[5] } +{ +no warnings 'redefine'; +sub Scotty :ATTR(SCALAR,CHECK) { $scalar_applied = $_[5] } +} + +sub warp_coil :Scotty {} +my $photon_torpedo :Scotty; + +ok( $code_applied eq 'BEGIN', 53, "# phase variance" ); +ok( $scalar_applied eq 'CHECK', 54 ); -- 2.7.4