| 1 | package Class::Accessor::Faster; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use base 'Class::Accessor'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use B 'perlstring'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | $Class::Accessor::Faster::VERSION = '0.51'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | my %slot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 26 | ▶ | sub _slot { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_slot: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 26 | my($class, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 26 | my $n = $slot{$class}->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 26 | ▶ | return $n if defined $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 16 | $n = keys %{$slot{$class}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 16 | $slot{$class}->{$field} = $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | return $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | my($proto, $fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | my($class) = ref $proto || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | my $self = bless [], $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | $fields = {} unless defined $fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | for my $k (keys %$fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | my $n = $class->_slot($k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | $self->[$n] = $fields->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | ▶ | sub make_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_accessor: called CC=1 SCAR=0.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | my($class, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | my $n = $class->_slot($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | eval sprintf q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.0
Subroutine
__ANON__: called CC=3 SCAR=14.0
Subroutine
__ANON__: not called CC=3 SCAR=14.0
Subroutine
__ANON__: called CC=3 SCAR=14.0
Subroutine
__ANON__: not called CC=3 SCAR=14.0
Subroutine
__ANON__: called CC=3 SCAR=14.0
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | return $_[0][%d] if scalar(@_) == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | return $_[0][%d] = scalar(@_) == 2 ? $_[1] : [@_[1..$#_]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | }, $n, $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | sub make_ro_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_ro_accessor: called CC=1 SCAR=0.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | my($class, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | my $n = $class->_slot($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | eval sprintf q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.7
Subroutine
__ANON__: not called CC=2 SCAR=8.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | return $_[0][%d] if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | my $caller = caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $_[0]->_croak(sprintf "'$caller' cannot alter the value of '%%s' on objects of class '%%s'", %s, %s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | }, $n, map(perlstring($_), $field, $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | ▶ | sub make_wo_accessor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_wo_accessor: called CC=1 SCAR=0.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | my($class, $field) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | my $n = $class->_slot($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | eval sprintf q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.5
Subroutine
__ANON__: called CC=3 SCAR=11.5
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | if (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | my $caller = caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $_[0]->_croak(sprintf "'$caller' cannot access the value of '%%s' on objects of class '%%s'", %s, %s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | return $_[0][%d] = $_[1] if @_ == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | return (shift)->[%d] = \@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | }, map(perlstring($_), $field, $class), $n, $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||