[Bast-commits] r9795 -
Class-Accessor-Grouped/trunk/lib/Class/Accessor
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Nov 25 14:33:45 GMT 2010
Author: ribasushi
Date: 2010-11-25 14:33:45 +0000 (Thu, 25 Nov 2010)
New Revision: 9795
Modified:
Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm
Log:
Fix stupid pure-perl caching omission
Modified: Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm
===================================================================
--- Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm 2010-11-25 14:22:45 UTC (rev 9794)
+++ Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm 2010-11-25 14:33:45 UTC (rev 9795)
@@ -547,9 +547,9 @@
rw => {
xs_call => 'accessors',
pp_code => sub {
- my $set = "set_$_[1]";
- my $get = "get_$_[1]";
- my $field = $_[2];
+ my $set = "set_$_[0]";
+ my $get = "get_$_[0]";
+ my $field = $_[1];
$field =~ s/'/\\'/g;
"
@@ -562,8 +562,8 @@
ro => {
xs_call => 'getters',
pp_code => sub {
- my $get = "get_$_[1]";
- my $field = $_[2];
+ my $get = "get_$_[0]";
+ my $field = $_[1];
$field =~ s/'/\\'/g;
"
@@ -571,8 +571,9 @@
? shift->$get('$field')
: do {
my \$caller = caller;
- Carp::croak(\"'\$caller' cannot alter the value of '$field' on \".
- \"objects of class '$_[0]'\");
+ my \$class = ref \$_[0] || \$_[0];
+ Carp::croak(\"'\$caller' cannot alter the value of '$field' \".
+ \"(read-only attributes of class '\$class')\");
}
"
},
@@ -580,8 +581,8 @@
wo => {
xs_call => 'setters',
pp_code => sub {
- my $set = "set_$_[1]";
- my $field = $_[2];
+ my $set = "set_$_[0]";
+ my $field = $_[1];
$field =~ s/'/\\'/g;
"
@@ -589,8 +590,9 @@
? shift->$set('$field', \@_)
: do {
my \$caller = caller;
- Carp::croak(\"'\$caller' cannot access the value of '$field' on \".
- \"objects of class '$_[0]'\");
+ my \$class = ref \$_[0] || \$_[0];
+ Carp::croak(\"'\$caller' cannot access the value of '$field' \".
+ \"(write-only attributes of class '\$class')\");
}
"
},
@@ -673,16 +675,15 @@
# no Sub::Name - just install the coderefs directly (compiling every time)
elsif (__CAG_NO_SUBNAME) {
- my $pp_code = $maker_templates->{$type}{pp_code}->($class, $group, $field);
+ my $pp_code = $maker_templates->{$type}{pp_code}->($group, $field);
eval "sub ${class}::${methname} { $pp_code }; 1" or die $@;
undef; # so that no attempt will be made to install anything
}
# a coderef generator with a variable pad (returns a fresh cref on every invocation)
- # also since it is much simpler than the xs one it needs less cache-keys
else {
- ($accessor_maker_cache->{pp}{$field}{$type} ||= do {
- my $pp_code = $maker_templates->{$type}{pp_code}->($class, $group, $field);
+ ($accessor_maker_cache->{pp}{$group}{$field}{$type} ||= do {
+ my $pp_code = $maker_templates->{$type}{pp_code}->($group, $field);
eval "sub { my \$dummy; sub { \$dummy if 0; $pp_code } }" or die $@;
})->()
}
More information about the Bast-commits
mailing list