Change 34572 by [EMAIL PROTECTED] on 2008/10/24 20:56:48
Revert Attribute::Handlers to the version that shipped with 5.8.8.
Then add that Rafael is now the maintainer, and bump the $VERSION to
0.78_03 to reflect this difference. I don't feel comfortable shipping
a moderately different Attribute::Handlers, when it hasn't been on
CPAN to shake other peoples' bugs out, and can be put (back) on CPAN,
so that modules that know they need it can explicitly depend on it.
Affected files ...
... //depot/maint-5.8/perl/MANIFEST#450 edit
... //depot/maint-5.8/perl/lib/Attribute/Handlers.pm#10 edit
... //depot/maint-5.8/perl/lib/Attribute/Handlers/Changes#5 edit
... //depot/maint-5.8/perl/lib/Attribute/Handlers/README#4 edit
... //depot/maint-5.8/perl/lib/Attribute/Handlers/t/constants.t#2 delete
... //depot/maint-5.8/perl/lib/Attribute/Handlers/t/data_convert.t#2 delete
... //depot/maint-5.8/perl/lib/Attribute/Handlers/t/linerep.t#2 delete
... //depot/maint-5.8/perl/lib/Attribute/Handlers/t/multi.t#5 edit
Differences ...
==== //depot/maint-5.8/perl/MANIFEST#450 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#449~34550~ 2008-10-21 10:02:10.000000000 -0700
+++ perl/MANIFEST 2008-10-24 13:56:48.000000000 -0700
@@ -1313,9 +1313,6 @@
lib/Attribute/Handlers/demo/MyClass.pm Attribute::Handlers demo
lib/Attribute/Handlers.pm Attribute::Handlers
lib/Attribute/Handlers/README Attribute::Handlers
-lib/Attribute/Handlers/t/constants.t Test constants and Attribute::Handlers
-lib/Attribute/Handlers/t/data_convert.t Test attribute data conversion
-lib/Attribute/Handlers/t/linerep.t See if Attribute::Handlers works
lib/Attribute/Handlers/t/multi.t See if Attribute::Handlers works
lib/attributes.pm For "sub foo : attrlist"
lib/AutoLoader.pm Autoloader base class
==== //depot/maint-5.8/perl/lib/Attribute/Handlers.pm#10 (text) ====
Index: perl/lib/Attribute/Handlers.pm
--- perl/lib/Attribute/Handlers.pm#9~33930~ 2008-05-25 15:33:32.000000000
-0700
+++ perl/lib/Attribute/Handlers.pm 2008-10-24 13:56:48.000000000 -0700
@@ -2,9 +2,7 @@
use 5.006;
use Carp;
use warnings;
-use strict;
-use vars qw($VERSION $AUTOLOAD);
-$VERSION = '0.80';
+$VERSION = '0.78_03';
# $DB::single=1;
my %symcache;
@@ -13,10 +11,7 @@
return $symcache{$pkg,$ref} if $symcache{$pkg,$ref};
$type ||= ref($ref);
my $found;
- no strict 'refs';
foreach my $sym ( values %{$pkg."::"} ) {
- use strict;
- next unless ref ( \$sym ) eq 'GLOB';
return $symcache{$pkg,$ref} = \$sym
if *{$sym}{$type} && *{$sym}{$type} == $ref;
}
@@ -65,7 +60,7 @@
my $args = $3||'()';
_usage_AH_ $class unless $attr =~ $qual_id
&& $tieclass =~ $qual_id
- && eval "use base q\0$tieclass\0; 1";
+ && eval "use base $tieclass; 1";
if ($tieclass->isa('Exporter')) {
local $Exporter::ExportLevel = 2;
$tieclass->import(eval $args);
@@ -99,31 +94,29 @@
warn "Declaration of $name attribute in package $lastattr{pkg} may
clash with future reserved word\n"
if $^W and $name !~ /[A-Z]/;
foreach ( @{$validtype{$lastattr{type}}} ) {
- no strict 'refs';
*{"$lastattr{pkg}::_ATTR_${_}_${name}"} = $lastattr{ref};
}
%lastattr = ();
}
sub AUTOLOAD {
- return if $AUTOLOAD =~ /::DESTROY$/;
my ($class) = $AUTOLOAD =~ m/(.*)::/g;
$AUTOLOAD =~ m/_ATTR_(.*?)_(.*)/ or
croak "Can't locate class method '$AUTOLOAD' via package '$class'";
croak "Attribute handler '$2' doesn't handle $1 attributes";
}
+sub DESTROY {}
+
my $builtin = qr/lvalue|method|locked|unique|shared/;
sub _gen_handler_AH_() {
return sub {
_resolve_lastattr;
my ($pkg, $ref, @attrs) = @_;
- my (undef, $filename, $linenum) = caller 2;
foreach (@attrs) {
my ($attr, $data) = /^([a-z_]\w*)(?:[(](.*)[)])?$/is or next;
if ($attr eq 'ATTR') {
- no strict 'refs';
$data ||= "ANY";
$raw{$ref} = $data =~ s/\s*,?\s*RAWDATA\s*,?\s*//;
$phase{$ref}{BEGIN} = 1
@@ -148,7 +141,7 @@
my $handler = $pkg->can("_ATTR_${type}_${attr}");
next unless $handler;
my $decl = [$pkg, $ref, $attr, $data,
- $raw{$handler}, $phase{$handler},
$filename, $linenum];
+ $raw{$handler}, $phase{$handler}];
foreach my $gphase (@global_phases) {
_apply_handler_AH_($decl,$gphase)
if $global_phases{$gphase} <= $global_phase;
@@ -172,17 +165,14 @@
}
}
-{
- no strict 'refs';
- *{"Attribute::Handlers::UNIVERSAL::MODIFY_${_}_ATTRIBUTES"} =
- _gen_handler_AH_ foreach @{$validtype{ANY}};
-}
+*{"Attribute::Handlers::UNIVERSAL::MODIFY_${_}_ATTRIBUTES"} =
+ _gen_handler_AH_ foreach @{$validtype{ANY}};
push @UNIVERSAL::ISA, 'Attribute::Handlers::UNIVERSAL'
unless grep /^Attribute::Handlers::UNIVERSAL$/, @UNIVERSAL::ISA;
sub _apply_handler_AH_ {
my ($declaration, $phase) = @_;
- my ($pkg, $ref, $attr, $data, $raw, $handlerphase, $filename, $linenum)
= @$declaration;
+ my ($pkg, $ref, $attr, $data, $raw, $handlerphase) = @$declaration;
return unless $handlerphase->{$phase};
# print STDERR "Handling $attr on $ref in $phase with [$data]\n";
my $type = ref $ref;
@@ -190,21 +180,16 @@
my $sym = findsym($pkg, $ref);
$sym ||= $type eq 'CODE' ? 'ANON' : 'LEXICAL';
no warnings;
- if (!$raw && defined($data)) {
- if ($data ne '') {
- my $evaled = eval("package $pkg; no warnings; no strict;
- local \$SIG{__WARN__}=sub{die}; [$data]");
- $data = $evaled unless $@;
- }
- else { $data = undef }
- }
+ my $evaled = !$raw && eval("package $pkg; no warnings;
+ local \$SIG{__WARN__}=sub{die}; [$data]");
+ $data = ($evaled && $data =~ /^\s*\[/) ? [$evaled]
+ : ($evaled) ? $evaled
+ : [$data];
$pkg->$handler($sym,
(ref $sym eq 'GLOB' ? *{$sym}{ref $ref}||$ref : $ref),
$attr,
- $data,
+ (@$data>1? $data : $data->[0]),
$phase,
- $filename,
- $linenum,
);
return 1;
}
@@ -234,8 +219,8 @@
=head1 VERSION
-This document describes version 0.79 of Attribute::Handlers,
-released November 25, 2007.
+This document describes version 0.78 of Attribute::Handlers,
+released October 5, 2002.
=head1 SYNOPSIS
@@ -306,27 +291,25 @@
derived from that package may be given attributes with the same names as
the attribute handler subroutines, which will then be called in one of
the compilation phases (i.e. in a C<BEGIN>, C<CHECK>, C<INIT>, or C<END>
-block). (C<UNITCHECK> blocks don't correspond to a global compilation
-phase, so they can't be specified here.)
+block).
To create a handler, define it as a subroutine with the same name as
the desired attribute, and declare the subroutine itself with the
attribute C<:ATTR>. For example:
- package LoudDecl;
- use Attribute::Handlers;
+ package LoudDecl;
+ use Attribute::Handlers;
- sub Loud :ATTR {
- my ($package, $symbol, $referent, $attr, $data, $phase, $filename,
$linenum) = @_;
- print STDERR
- ref($referent), " ",
- *{$symbol}{NAME}, " ",
- "($referent) ", "was just declared ",
- "and ascribed the ${attr} attribute ",
- "with data ($data)\n",
- "in phase $phase\n",
- "in file $filename at line $linenum\n";
- }
+ sub Loud :ATTR {
+ my ($package, $symbol, $referent, $attr, $data, $phase) = @_;
+ print STDERR
+ ref($referent), " ",
+ *{$symbol}{NAME}, " ",
+ "($referent) ", "was just declared ",
+ "and ascribed the ${attr} attribute ",
+ "with data ($data)\n",
+ "in phase $phase\n";
+ }
This creates a handler for the attribute C<:Loud> in the class LoudDecl.
Thereafter, any subroutine declared with a C<:Loud> attribute in the class
@@ -362,15 +345,7 @@
=item [5]
-the name of the phase in which the handler is being invoked;
-
-=item [6]
-
-the filename in which the handler is being invoked;
-
-=item [7]
-
-the line number in this file.
+the name of the phase in which the handler is being invoked.
=back
@@ -395,46 +370,40 @@
string C<'LEXICAL'> in that case. Likewise, ascribing an attribute to
an anonymous subroutine results in a symbol table argument of C<'ANON'>.
-The data argument passes in the value (if any) associated with the
+The data argument passes in the value (if any) associated with the
attribute. For example, if C<&foo> had been declared:
sub foo :Loud("turn it up to 11, man!") {...}
-then a reference to an array containing the string
-C<"turn it up to 11, man!"> would be passed as the last argument.
+then the string C<"turn it up to 11, man!"> would be passed as the
+last argument.
Attribute::Handlers makes strenuous efforts to convert
the data argument (C<$_[4]>) to a useable form before passing it to
the handler (but see L<"Non-interpretive attribute handlers">).
-If those efforts succeed, the interpreted data is passed in an array
-reference; if they fail, the raw data is passed as a string.
For example, all of these:
- sub foo :Loud(till=>ears=>are=>bleeding) {...}
- sub foo :Loud(qw/till ears are bleeding/) {...}
- sub foo :Loud(qw/my, ears, are, bleeding/) {...}
- sub foo :Loud(till,ears,are,bleeding) {...}
+ sub foo :Loud(till=>ears=>are=>bleeding) {...}
+ sub foo :Loud(['till','ears','are','bleeding']) {...}
+ sub foo :Loud(qw/till ears are bleeding/) {...}
+ sub foo :Loud(qw/my, ears, are, bleeding/) {...}
+ sub foo :Loud(till,ears,are,bleeding) {...}
causes it to pass C<['till','ears','are','bleeding']> as the handler's
-data argument. While:
-
- sub foo :Loud(['till','ears','are','bleeding']) {...}
-
-causes it to pass C<[ ['till','ears','are','bleeding'] ]>; the array
-reference specified in the data being passed inside the standard
-array reference indicating successful interpretation.
-
-However, if the data can't be parsed as valid Perl, then
+data argument. However, if the data can't be parsed as valid Perl, then
it is passed as an uninterpreted string. For example:
- sub foo :Loud(my,ears,are,bleeding) {...}
- sub foo :Loud(qw/my ears are bleeding) {...}
+ sub foo :Loud(my,ears,are,bleeding) {...}
+ sub foo :Loud(qw/my ears are bleeding) {...}
+
+cause the strings C<'my,ears,are,bleeding'> and C<'qw/my ears are bleeding'>
+respectively to be passed as the data argument.
-cause the strings C<'my,ears,are,bleeding'> and
-C<'qw/my ears are bleeding'> respectively to be passed as the
-data argument.
+If the attribute has only a single associated scalar data value, that value is
+passed as a scalar. If multiple values are associated, they are passed as an
+array reference. If no value is associated with the attribute, C<undef> is
+passed.
-If no value is associated with the attribute, C<undef> is passed.
=head2 Typed lexicals
@@ -686,7 +655,7 @@
sub fn :Ugly(sister) :Omni('po',tent()) {...}
my @arr :Good :Omni(s/cie/nt/);
- my %hsh :Good(q/bye/) :Omni(q/bus/);
+ my %hsh :Good(q/bye) :Omni(q/bus/);
would cause the following handlers to be invoked:
==== //depot/maint-5.8/perl/lib/Attribute/Handlers/Changes#5 (text) ====
Index: perl/lib/Attribute/Handlers/Changes
--- perl/lib/Attribute/Handlers/Changes#4~33183~ 2008-02-02
04:40:48.000000000 -0800
+++ perl/lib/Attribute/Handlers/Changes 2008-10-24 13:56:48.000000000 -0700
@@ -100,12 +100,3 @@
the proper approach is to use { '__CALLER__::foo' => __PACKAGE }.
The documentation is updated to reflect this.
Reported by Dave Cross
-
-0.79
-
- - The version released with Perl 5.10.0
- - All interpreted attributes are now passed as array references,
- eventually nested.
- - Don't AUTOLOAD DESTROY (Jerry D Hedden, cpan bug #1911)
- - A::H is now able to report caller's file and line number
- (David Feldman)
==== //depot/maint-5.8/perl/lib/Attribute/Handlers/README#4 (text) ====
Index: perl/lib/Attribute/Handlers/README
--- perl/lib/Attribute/Handlers/README#3~33183~ 2008-02-02 04:40:48.000000000
-0800
+++ perl/lib/Attribute/Handlers/README 2008-10-24 13:56:48.000000000 -0700
@@ -1,5 +1,5 @@
==============================================================================
- Release of version 0.79 of Attribute::Handlers
+ Release of version 0.78 of Attribute::Handlers
==============================================================================
@@ -44,26 +44,28 @@
Damian Conway ([EMAIL PROTECTED])
COPYRIGHT
- Copyright (c) 2001-2007, Damian Conway. All Rights Reserved.
+ Copyright (c) 2001-2002, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
==============================================================================
-0.79
-
- - The version released with Perl 5.10.0
- - All interpreted attributes are now passed as array references,
- eventually nested.
- - Don't AUTOLOAD DESTROY (Jerry D Hedden, cpan bug #1911)
- - A::H is now able to report caller's file and line number
- (David Feldman)
+0.78 Sat Oct 5 07:18:09 CEST 2002
+
+ - [#17940] Includes :unique and :shared in the builtin types
+
+ - From perl 5.8 { __CALLER__::foo => __PACKAGE } is missparsed,
+ the proper approach is to use { '__CALLER__::foo' => __PACKAGE }.
+ The documentation is updated to reflect this.
==============================================================================
AVAILABILITY
Attribute::Handlers has been uploaded to the CPAN
+and is also available from:
+
+ http://www.csse.monash.edu.au/~damian/CPAN/Attribute-Handlers.tar.gz
==============================================================================
==== //depot/maint-5.8/perl/lib/Attribute/Handlers/t/multi.t#5 (text) ====
Index: perl/lib/Attribute/Handlers/t/multi.t
--- perl/lib/Attribute/Handlers/t/multi.t#4~33183~ 2008-02-02
04:40:48.000000000 -0800
+++ perl/lib/Attribute/Handlers/t/multi.t 2008-10-24 13:56:48.000000000
-0700
@@ -1,12 +1,3 @@
-#!perl
-
-BEGIN {
- if ($ENV{PERL_CORE}) {
- chdir 't' if -d 't';
- @INC = '../lib';
- }
-}
-
END {print "not ok 1\n" unless $loaded;}
use v5.6.0;
use Attribute::Handlers;
End of Patch.