177
177
$self->_mk_group_accessors('make_group_wo_accessor', $group, @fields);
180
=head2 make_group_accessor
182
__PACKAGE__->make_group_accessor(simple => 'hair_length', 'hair_length');
186
=item Arguments: $group, $field, $method
188
Returns: \&accessor_coderef ?
192
Called by mk_group_accessors for each entry in @fieldspec. Either returns
193
a coderef which will be installed at C<&__PACKAGE__::$method>, or returns
194
C<undef> if it elects to install the coderef on its own.
198
sub make_group_accessor { $gen_accessor->('rw', @_) }
200
=head2 make_group_ro_accessor
202
__PACKAGE__->make_group_ro_accessor(simple => 'birthdate', 'birthdate');
206
=item Arguments: $group, $field, $method
208
Returns: \&accessor_coderef ?
212
Called by mk_group_ro_accessors for each entry in @fieldspec. Either returns
213
a coderef which will be installed at C<&__PACKAGE__::$method>, or returns
214
C<undef> if it elects to install the coderef on its own.
218
sub make_group_ro_accessor { $gen_accessor->('ro', @_) }
220
=head2 make_group_wo_accessor
222
__PACKAGE__->make_group_wo_accessor(simple => 'lie', 'lie');
226
=item Arguments: $group, $field, $method
228
Returns: \&accessor_coderef ?
232
Called by mk_group_wo_accessors for each entry in @fieldspec. Either returns
233
a coderef which will be installed at C<&__PACKAGE__::$method>, or returns
234
C<undef> if it elects to install the coderef on its own.
238
sub make_group_wo_accessor { $gen_accessor->('wo', @_) }
240
180
=head2 get_simple
422
362
return $_[0]->set_inherited($_[1], $_[2]);
365
=head1 INTERNAL METHODS
367
These methods are documented for clarity, but are never meant to be called
368
directly, and are not really meant for overriding either.
425
370
=head2 get_super_paths
427
Returns a list of 'parent' or 'super' class names that the current class inherited from.
372
Returns a list of 'parent' or 'super' class names that the current class
373
inherited from. This is what drives the traversal done by L</get_inherited>.
432
378
return @{mro::get_linear_isa( ref($_[0]) || $_[0] )};
381
=head2 make_group_accessor
383
__PACKAGE__->make_group_accessor('simple', 'hair_length', 'hair_length');
384
__PACKAGE__->make_group_accessor('simple', 'hc', 'hair_color');
388
=item Arguments: $group, $field, $accessor
390
Returns: \&accessor_coderef ?
394
Called by mk_group_accessors for each entry in @fieldspec. Either returns
395
a coderef which will be installed at C<&__PACKAGE__::$accessor>, or returns
396
C<undef> if it elects to install the coderef on its own.
400
sub make_group_accessor { $gen_accessor->('rw', @_) }
402
=head2 make_group_ro_accessor
404
__PACKAGE__->make_group_ro_accessor('simple', 'birthdate', 'birthdate');
405
__PACKAGE__->make_group_ro_accessor('simple', 'ssn', 'social_security_number');
409
=item Arguments: $group, $field, $accessor
411
Returns: \&accessor_coderef ?
415
Called by mk_group_ro_accessors for each entry in @fieldspec. Either returns
416
a coderef which will be installed at C<&__PACKAGE__::$accessor>, or returns
417
C<undef> if it elects to install the coderef on its own.
421
sub make_group_ro_accessor { $gen_accessor->('ro', @_) }
423
=head2 make_group_wo_accessor
425
__PACKAGE__->make_group_wo_accessor('simple', 'lie', 'lie');
426
__PACKAGE__->make_group_wo_accessor('simple', 'subj', 'subject');
430
=item Arguments: $group, $field, $accessor
432
Returns: \&accessor_coderef ?
436
Called by mk_group_wo_accessors for each entry in @fieldspec. Either returns
437
a coderef which will be installed at C<&__PACKAGE__::$accessor>, or returns
438
C<undef> if it elects to install the coderef on its own.
442
sub make_group_wo_accessor { $gen_accessor->('wo', @_) }
435
445
=head1 PERFORMANCE
437
447
To provide total flexibility L<Class::Accessor::Grouped> calls methods
548
558
delete $INC{'Class/XSAccessor.pm'};
551
*__CAG_NO_CXSA = $err
561
*__CAG_ENV__::NO_CXSA = $err
552
562
? sub () { $err }
557
*__CAG_BROKEN_GOTO = ($] < '5.008009')
563
*__CAG_UNSTABLE_DOLLARAT = ($] < '5.013002')
569
*__CAG_TRACK_UNDEFER_FAIL = (
567
*__CAG_ENV__::BROKEN_GOTO = ($] < '5.008009')
573
*__CAG_ENV__::UNSTABLE_DOLLARAT = ($] < '5.013002')
579
*__CAG_ENV__::TRACK_UNDEFER_FAIL = (
570
580
$INC{'Test/Builder.pm'} || $INC{'Test/Builder2.pm'}
572
582
$0 =~ m|^ x?t / .+ \.t $|x
663
673
# Thus the final method (properly labeled and all) is installed in the
664
674
# calling-package's namespace
665
675
if ($USE_XS and $group eq 'simple') {
666
die sprintf( "Class::XSAccessor requested but not available:\n%s\n", __CAG_NO_CXSA )
676
die sprintf( "Class::XSAccessor requested but not available:\n%s\n", __CAG_ENV__::NO_CXSA )
677
if __CAG_ENV__::NO_CXSA;
669
679
my ($expected_cref, $cached_implementation);
670
680
my $ret = $expected_cref = sub {
728
738
# older perls segfault if the cref behind the goto throws
729
739
# http://rt.perl.org/rt3/Public/Bug/Display.html?id=35878
730
return $resolved_implementation->(@_) if __CAG_BROKEN_GOTO;
740
return $resolved_implementation->(@_) if __CAG_ENV__::BROKEN_GOTO;
732
742
goto $resolved_implementation;
735
if (__CAG_TRACK_UNDEFER_FAIL) {
745
if (__CAG_ENV__::TRACK_UNDEFER_FAIL) {
736
746
my $deferred_calls_seen = do {
737
747
no strict 'refs';
738
748
\%{"${current_class}::__cag_deferred_xs_shim_invocations"}
770
780
# older perls segfault if the cref behind the goto throws
771
781
# http://rt.perl.org/rt3/Public/Bug/Display.html?id=35878
772
return $resolved_implementation->(@_) if __CAG_BROKEN_GOTO;
782
return $resolved_implementation->(@_) if __CAG_ENV__::BROKEN_GOTO;
774
784
goto $resolved_implementation;
781
791
# no Sub::Name - just install the coderefs directly (compiling every time)
782
elsif (__CAG_NO_SUBNAME) {
792
elsif (__CAG_ENV__::NO_SUBNAME) {
783
793
my $src = $accessor_maker_cache->{source}{$type}{$group}{$field} ||=
784
794
$maker_templates->{$type}{pp_code}->($group, $field);
786
796
no warnings 'redefine';
787
local $@ if __CAG_UNSTABLE_DOLLARAT;
797
local $@ if __CAG_ENV__::UNSTABLE_DOLLARAT;
788
798
eval "sub ${class}::${methname} { $src }";
790
800
undef; # so that no further attempt will be made to install anything
796
806
my $src = $accessor_maker_cache->{source}{$type}{$group}{$field} ||=
797
807
$maker_templates->{$type}{pp_code}->($group, $field);
799
local $@ if __CAG_UNSTABLE_DOLLARAT;
809
local $@ if __CAG_ENV__::UNSTABLE_DOLLARAT;
800
810
eval "sub { my \$dummy; sub { \$dummy if 0; $src } }" or die $@;