$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++;
return $USE_XS;
}
+ $xsa_autodetected = 1;
$USE_XS = 0;
# Class::XSAccessor is segfaulting on win32, in some
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
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";
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";
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";