[Bast-commits] r9745 -
Class-Accessor-Grouped/trunk/lib/Class/Accessor
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Fri Oct 8 12:20:42 GMT 2010
Author: ribasushi
Date: 2010-10-08 13:20:42 +0100 (Fri, 08 Oct 2010)
New Revision: 9745
Modified:
Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm
Log:
Factor out the XSA installing code (needed for later)
Modified: Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm
===================================================================
--- Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm 2010-10-08 11:51:58 UTC (rev 9744)
+++ Class-Accessor-Grouped/trunk/lib/Class/Accessor/Grouped.pm 2010-10-08 12:20:42 UTC (rev 9745)
@@ -18,7 +18,7 @@
$USE_XS = $ENV{CAG_USE_XS}
unless defined $USE_XS;
-my $xsa_loaded;
+my ($xsa_loaded, $xsa_autodetected);
my $load_xsa = sub {
return if $xsa_loaded++;
@@ -32,6 +32,7 @@
return $USE_XS;
}
+ $xsa_autodetected = 1;
$USE_XS = 0;
# Class::XSAccessor is segfaulting on win32, in some
@@ -45,6 +46,14 @@
return $USE_XS;
};
+my $add_xs_accessor = sub {
+ Class::XSAccessor->import({
+ replace => 1,
+ %{shift()}
+ });
+ return undef;
+};
+
=head1 NAME
Class::Accessor::Grouped - Lets you build groups of accessors
@@ -195,14 +204,12 @@
my ($class, $group, $field, $name) = @_;
if ( $group eq 'simple' && $use_xs->() ) {
- Class::XSAccessor->import({
- replace => 1,
+ return $add_xs_accessor->({
class => $class,
accessors => {
$name => $field,
},
});
- return;
}
my $set = "set_$group";
@@ -244,14 +251,12 @@
my($class, $group, $field, $name) = @_;
if ( $group eq 'simple' && $use_xs->() ) {
- Class::XSAccessor->import({
- replace => 1,
+ return $add_xs_accessor->({
class => $class,
getters => {
$name => $field,
},
});
- return;
}
my $get = "get_$group";
@@ -293,14 +298,12 @@
my($class, $group, $field, $name) = @_;
if ( $group eq 'simple' && $use_xs->() ) {
- Class::XSAccessor->import({
- replace => 1,
+ return $add_xs_accessor->({
class => $class,
setters => {
$name => $field,
},
});
- return;
}
my $set = "set_$group";
More information about the Bast-commits
mailing list