| 1 | 8 | ▶ | use 5.008003; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | no warnings qw( void once uninitialized ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | package Sub::Accessor::Small; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Carp qw( carp croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Eval::TypeTiny qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Exporter::Tiny qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Scalar::Util qw( blessed reftype ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | *HAS_SUB_UTIL = eval { require Sub::Util } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ? sub(){1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | : sub(){0}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | *HAS_SUB_NAME = !HAS_SUB_UTIL() && eval { require Sub::Name } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ? sub(){1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | : sub(){0}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not &HAS_SUB_UTIL() and eval {
MC/DC0%0/2
not &HAS_SUB_UTIL() and eval {
do {
require Sub::Name
}
}
not &HAS_SUB_UTIL()
eval {
do {
require Sub::Name
}
}
Truth table33%1/3
not(A) and B
A= not &HAS_SUB_UTIL()B= eval {
do {
require Sub::Name
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | *fieldhash = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | eval { require Hash::FieldHash; \&Hash::FieldHash::fieldhash } || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | eval { require Hash::Util::FieldHash; \&Hash::Util::FieldHash::fieldhash } || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | do { require Hash::Util::FieldHash::Compat; \&Hash::Util::FieldHash::Compat::fieldhash } ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=17.3
Condition33%2/6
eval { || do {
eval { or eval {
MC/DC0%0/3
eval {
do {
require Hash::FieldHash;
\&Hash::FieldHash::fieldhash
}
} || eval {
do {
require Hash::Util::FieldHash;
\&Hash::Util::FieldHash::fieldhash
}
} || do {
require Hash::Util::FieldHash::Compat;
\&Hash::Util::FieldHash::Compat::fieldhash
}
eval {
do {
require Hash::FieldHash;
\&Hash::FieldHash::fieldhash
}
}
eval {
do {
require Hash::Util::FieldHash;
\&Hash::Util::FieldHash::fieldhash
}
}
do {
require Hash::Util::FieldHash::Compat;
\&Hash::Util::FieldHash::Compat::fieldhash
}
Truth table25%1/4
A or B || C
A= eval {
do {
require Hash::FieldHash;
\&Hash::FieldHash::fieldhash
}
}B= eval {
do {
require Hash::Util::FieldHash;
\&Hash::Util::FieldHash::fieldhash
}
}C= do {
require Hash::Util::FieldHash::Compat;
\&Hash::Util::FieldHash::Compat::fieldhash
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 8 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 8 | our $VERSION = '0.014'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 8 | our @ISA = qw/ Exporter::Tiny /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 8 | fieldhash( our %FIELDS ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | sub _generate_has : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 8 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_has: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 8 | my (undef, undef, $export_opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | my $code = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 10 | ▶ | my $attr = $me->new_from_has($export_opts, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 10 | $attr->install_accessors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | HAS_SUB_UTIL ? ($code = Sub::Util::set_subname("$me\::has", $code)) : | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | HAS_SUB_NAME ? ($code = Sub::Name::subname("$me\::has", $code)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | my $uniq = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub new_from_has : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_has: called CC=6 SCAR=20.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 24 | ▶ | my $export_opts = ref($_[0]) eq 'HASH' ? shift(@_) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 24 | ▶ | my ($name, %opts) = (@_%2) ? @_ : (undef, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 24 | my $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $package = $export_opts->{into} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 24 | ▶ | if defined($export_opts->{into}) && !ref($export_opts->{into}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $export_opts->{"into"} and not ref $export_opts->{"into"}
MC/DC0%0/2
defined $export_opts->{"into"} and not ref $export_opts->{"into"}
defined $export_opts->{"into"}
not ref $export_opts->{"into"}
Truth table33%1/3
A and not(B)
A= defined $export_opts->{"into"}B= not ref $export_opts->{"into"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 24 | ▶ | $me->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | slot => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | id => $uniq++, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | _export => $export_opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ($package ? (package => $package) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | %opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | sub has : method | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $attr = $me->new_from_has(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $attr->install_accessors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | sub new : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 24 | my (%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 24 | my $self = bless(\%opts, $me); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 24 | $self->canonicalize_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 24 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub install_accessors : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_accessors: called CC=15 SCAR=28.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 24 | for my $type (qw( accessor reader writer predicate clearer )) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 120 | ▶ | next unless defined $me->{$type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 44 | $me->install_coderef($me->{$type}, $me->$type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | ▶ | if (defined $me->{handles}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | my $shv_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | if ($me->{traits} or $me->{handles_via}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$me->{"traits"} or $me->{"handles_via"}
MC/DC0%0/2
$me->{"traits"} or $me->{"handles_via"}
$me->{"traits"}
$me->{"handles_via"}
Truth table33%1/3
A or B
A= $me->{"traits"}B= $me->{"handles_via"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | my @pairs = $me->expand_handles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | my %handles_map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | while ( @pairs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | my ( $name ) = splice( @pairs, 0, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | $handles_map{"$name"} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | require Sub::HandlesVia::Toolkit::SubAccessorSmall; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | my $SHV = 'Sub::HandlesVia::Toolkit::SubAccessorSmall'->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | attr => $me, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | handles_map => \%handles_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | $shv_data = $SHV->clean_spec( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | $me->{package}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | $me->{slot}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | +{%$me}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | $shv_data and $SHV->install_delegations( $shv_data ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | if (!$shv_data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my @pairs = $me->expand_handles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | while (@pairs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my ($target, $method) = splice(@pairs, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $me->install_coderef($target, $me->handles($method)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | my @return = map $$_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | $me->{is} eq 'ro' ? ($me->{reader}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $me->{is} eq 'rw' ? ($me->{accessor}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $me->{is} eq 'rwp' ? ($me->{reader}, $me->{writer}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 24 | ▶ | $me->{is} eq 'lazy' ? ($me->{reader}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 24 | ▶ | wantarray ? @return : $return[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | sub install_coderef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 46 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_coderef: called CC=8 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 46 | my ($target, $coderef) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 46 | ▶ | return unless defined $target; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 46 | ▶ | if (!ref $target and $target =~ /\A[^\W0-9]\w+\z/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $target and $target =~ /\A[^\W0-9]\w+\z/
MC/DC50%1/2
not ref $target and $target =~ /\A[^\W0-9]\w+\z/
not ref $target
$target =~ /\A[^\W0-9]\w+\z/
Truth table66%2/3
not(A) and B
A= not ref $targetB= $target =~ /\A[^\W0-9]\w+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | my $name = "$me->{package}\::$target"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | HAS_SUB_UTIL ? ($coderef = Sub::Util::set_subname($name, $coderef)) : | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | HAS_SUB_NAME ? ($coderef = Sub::Name::subname($name, $coderef)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | *$name = $coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 43 | ▶ | if (ref($target) eq q(SCALAR) and not defined $$target) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $target eq "SCALAR" and not defined $$target
MC/DC0%0/2
ref $target eq "SCALAR" and not defined $$target
ref $target eq "SCALAR"
not defined $$target
Truth table33%1/3
A and not(B)
A= ref $target eq "SCALAR"B= not defined $$target
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 43 | $$target = $coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 43 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if (!ref($target) and $target eq 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $target and $target eq 1
MC/DC0%0/2
not ref $target and $target eq 1
not ref $target
$target eq 1
Truth table0%0/3
not(A) and B
A= not ref $targetB= $target eq 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | croak "Expected installation target to be a reference to an undefined scalar; got $target"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | sub expand_handles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_handles: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if (ref($me->{handles}) eq q(ARRAY)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return map ($_=>$_), @{$me->{handles}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | elsif (ref($me->{handles}) eq q(HASH)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return %{$me->{handles}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | croak "Expected delegations to be a reference to an array or hash; got $me->{handles}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | my %one = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | accessor => [qw/ %s %s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | reader => [qw/ get_%s _get%s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | writer => [qw/ set_%s _set%s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | predicate => [qw/ has_%s _has%s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | clearer => [qw/ clear_%s _clear%s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | trigger => [qw/ _trigger_%s _trigger_%s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | builder => [qw/ _builder_%s _builder_%s /], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sub canonicalize_1 : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_1: called CC=7 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 24 | ▶ | my $is_private = ($me->{slot} =~ /\A_/) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 24 | for my $type (keys %one) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 168 | ▶ | next if !exists($me->{$type}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 48 | ▶ | next if ref($me->{$type}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | next if $me->{$type} ne 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | croak("Cannot interpret $type=>1 because attribute has no name defined") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if !defined $me->{slot}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $me->{$type} = sprintf($one{$type}[$is_private], $me->{slot}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sub canonicalize_builder : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_builder: called CC=5 SCAR=28.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 24 | my $name = $me->{slot}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 24 | ▶ | if (ref $me->{builder} eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | HAS_SUB_UTIL or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | HAS_SUB_NAME or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | do { require Sub::Util }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $code = $me->{builder}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | defined($name) && defined($me->{package}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | or croak("Invalid builder; expected method name as string"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and defined $me->{"package"}
MC/DC0%0/2
defined $name and defined $me->{"package"}
defined $name
defined $me->{"package"}
Truth table0%0/3
A and B
A= defined $nameB= defined $me->{"package"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | my $is_private = ($name =~ /\A_/) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $subname = sprintf($one{builder}[$is_private], $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $fq_subname = "$me->{package}\::$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | $me->_exporter_install_sub( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | $subname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | $me->{_export}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | Sub::Name::subname($fq_subname, $code), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 8 | sub canonicalize_is : method | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_is: called CC=18 SCAR=54.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | my $name = $me->{slot}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | ▶ | if ($me->{is} eq 'rw') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | $me->{accessor} = $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | if !exists($me->{accessor}) and defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $me->{"accessor"} and defined $name
MC/DC0%0/2
not exists $me->{"accessor"} and defined $name
not exists $me->{"accessor"}
defined $name
Truth table0%0/3
not(A) and B
A= not exists $me->{"accessor"}B= defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | elsif ($me->{is} eq 'ro') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | $me->{reader} = $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if !exists($me->{reader}) and defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $me->{"reader"} and defined $name
MC/DC0%0/2
not exists $me->{"reader"} and defined $name
not exists $me->{"reader"}
defined $name
Truth table0%0/3
not(A) and B
A= not exists $me->{"reader"}B= defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | elsif ($me->{is} eq 'rwp') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | $me->{reader} = $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if !exists($me->{reader}) and defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $me->{"reader"} and defined $name
MC/DC0%0/2
not exists $me->{"reader"} and defined $name
not exists $me->{"reader"}
defined $name
Truth table0%0/3
not(A) and B
A= not exists $me->{"reader"}B= defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $me->{writer} = "_set_$name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if !exists($me->{writer}) and defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $me->{"writer"} and defined $name
MC/DC0%0/2
not exists $me->{"writer"} and defined $name
not exists $me->{"writer"}
defined $name
Truth table0%0/3
not(A) and B
A= not exists $me->{"writer"}B= defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | elsif ($me->{is} eq 'lazy') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | $me->{reader} = $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if !exists($me->{reader}) and defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $me->{"reader"} and defined $name
MC/DC0%0/2
not exists $me->{"reader"} and defined $name
not exists $me->{"reader"}
defined $name
Truth table0%0/3
not(A) and B
A= not exists $me->{"reader"}B= defined $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | $me->{lazy} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if !exists($me->{lazy}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | $me->{builder} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | unless $me->{builder} || $me->{default}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$me->{"builder"} or $me->{"default"}
MC/DC0%0/2
$me->{"builder"} or $me->{"default"}
$me->{"builder"}
$me->{"default"}
Truth table0%0/3
A or B
A= $me->{"builder"}B= $me->{"default"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | sub canonicalize_default : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_default: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 24 | ▶ | return unless exists $me->{default}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | ▶ | unless (ref $me->{default}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $value = $me->{default}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | $me->{default} = sub { $value }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | croak("Invalid default; expected a CODE ref") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | ▶ | unless ref $me->{default} eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub canonicalize_isa : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_isa: called CC=7 SCAR=32.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 24 | ▶ | if (my $does = $me->{does}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | $me->{isa} ||= sub { blessed($_[0]) && $_[0]->DOES($does) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
Condition0%0/3
$me->{"isa"} ||= sub {
MC/DC0%0/2
$me->{"isa"} ||= sub {
builtin::blessed($_[0]) and $_[0]->DOES($does);
}
$me->{"isa"}
sub {
builtin::blessed($_[0]) and $_[0]->DOES($does);
}
Truth table0%0/3
A ||= B
A= $me->{"isa"}B= sub {
builtin::blessed($_[0]) and $_[0]->DOES($does);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 24 | ▶ | if (defined $me->{isa} and not ref $me->{isa}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $me->{"isa"} and not ref $me->{"isa"}
MC/DC0%0/2
defined $me->{"isa"} and not ref $me->{"isa"}
defined $me->{"isa"}
not ref $me->{"isa"}
Truth table66%2/3
A and not(B)
A= defined $me->{"isa"}B= not ref $me->{"isa"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $type_name = $me->{isa}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | eval { require Type::Utils } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | or croak("Missing requirement; type constraint strings require Type::Utils"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | $me->{isa} = $me->{package} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | ? Type::Utils::dwim_type($type_name, for => $me->{package}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | : Type::Utils::dwim_type($type_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | sub canonicalize_trigger : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_trigger: called CC=3 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 24 | ▶ | if (defined $me->{trigger} and not ref $me->{trigger}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $me->{"trigger"} and not ref $me->{"trigger"}
MC/DC0%0/2
defined $me->{"trigger"} and not ref $me->{"trigger"}
defined $me->{"trigger"}
not ref $me->{"trigger"}
Truth table66%2/3
A and not(B)
A= defined $me->{"trigger"}B= not ref $me->{"trigger"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $method_name = $me->{trigger}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | $me->{trigger} = sub { my $self = shift; $self->$method_name(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | sub canonicalize_opts : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 24 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_opts: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 24 | ▶ | croak("Initializers are not supported") if $me->{initializer}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 24 | ▶ | croak("Traits are not supported") if $me->{traits}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 24 | ▶ | croak("The lazy_build option is not supported") if $me->{lazy_build}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 24 | $me->canonicalize_1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 24 | $me->canonicalize_is; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 24 | $me->canonicalize_isa; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 24 | $me->canonicalize_default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 24 | $me->canonicalize_builder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 24 | $me->canonicalize_trigger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | sub accessor_kind : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | ▶ | return 'small'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accessor_kind: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | sub inline_to_coderef : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 46 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_to_coderef: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 46 | my ($method_type, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 46 | my $kind = $me->accessor_kind; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 46 | my $src = sprintf(q[sub { %s }], $code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | my $desc = defined($me->{slot}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ? sprintf('%s %s for %s', $kind, $method_type, $me->{slot}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 46 | ▶ | : sprintf('%s %s', $kind, $method_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # warn "#### $desc\n$src\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | return Eval::TypeTiny::eval_closure( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | source => $src, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | environment => $me->{inline_environment}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 46 | description => $desc, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | sub clearer : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 4 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clearer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | $me->inline_to_coderef( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | clearer => $me->inline_clearer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | sub inline_clearer : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 4 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_clearer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 4 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | q[ delete(%s) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | $me->inline_access, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | sub inline_access : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 88 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_access: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | q[ $Sub::Accessor::Small::FIELDS{$_[0]}{%d} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | $me->{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 88 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | sub inline_access_w : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 26 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_access_w: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 26 | my ($expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 26 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | q[ %s = %s ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | $me->inline_access, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | $expr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | sub predicate : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
predicate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 4 | $me->inline_to_coderef( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | predicate => $me->inline_predicate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | sub inline_predicate : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 9 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_predicate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | q[ exists(%s) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | $me->inline_access, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | sub handles : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handles: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my ($method) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $me->inline_to_coderef( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 'delegated method' => $me->inline_handles, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 8 | my $handler_uniq = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | sub inline_handles : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_handles: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my ($method) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my $get = $me->inline_access; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $varname = sprintf('$handler_%d', ++$handler_uniq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $me->{inline_environment}{$varname} = \($method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $death = 'Scalar::Util::blessed($h) or Carp::croak("Expected blessed object to delegate to; got $h")'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if (ref $method eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | q[ %s; my $h = %s; %s; shift; my ($m, @a) = @%s; $h->$m(@a, @_) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | $me->inline_default, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | $get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | $death, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | $varname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | q[ %s; my $h = %s; %s; shift; $h->%s(@_) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | $me->inline_default, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | $get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | $death, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | $varname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | sub inline_get : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 29 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_get: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 29 | my $get = $me->inline_access; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 29 | ▶ | if ($me->{auto_deref}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $get = sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | q[ do { my $x = %s; wantarray ? (ref($x) eq 'ARRAY' ? @$x : ref($x) eq 'HASH' ? %$x : $x ) : $x } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | $get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 29 | return $get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | sub inline_default : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 22 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_default: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 22 | ▶ | if ($me->{lazy}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 5 | my $get = $me->inline_access; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 5 | ▶ | if ($me->{default}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 5 | $me->{inline_environment}{'$default'} = \($me->{default}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 5 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | q[ %s unless %s; ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | $me->inline_access_w( q[$default->($_[0])] ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | $me->inline_predicate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | elsif (defined $me->{builder}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | return sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | q[ %s unless %s; ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $me->inline_access_w( q($_[0]->) . $me->{builder} ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | $me->inline_predicate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 17 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | sub reader : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 17 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reader: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 17 | $me->inline_to_coderef( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | reader => $me->inline_reader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | sub inline_reader : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 22 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_reader: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 22 | join('', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $me->inline_default, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | $me->inline_get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | sub writer : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 9 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
writer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 9 | $me->inline_to_coderef( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | writer => $me->inline_writer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | sub inline_writer : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 9 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_writer: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 9 | my $get = $me->inline_access; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 9 | my $coerce = $me->inline_type_coercion('$_[1]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 9 | ▶ | if ($coerce eq '$_[1]') # i.e. no coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 5 | ▶ | if (!$me->{trigger} and !$me->{weak_ref}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$me->{"trigger"} or $me->{"weak_ref"}
MC/DC0%0/2
$me->{"trigger"} or $me->{"weak_ref"}
$me->{"trigger"}
$me->{"weak_ref"}
Truth table33%1/3
A or B
A= $me->{"trigger"}B= $me->{"weak_ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 5 | return $me->inline_access_w( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | $me->inline_type_assertion('$_[1]'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | '%s; %s; %s; %s; %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | $me->inline_type_assertion('$_[1]'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | $me->inline_trigger('$_[1]', $get), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | $me->inline_access_w('$_[1]'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | $me->inline_weaken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | $me->inline_get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 4 | 'my $val = %s; %s; %s; %s; %s; $val', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | $coerce, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | $me->inline_type_assertion('$val'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | $me->inline_trigger('$val', $get), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | $me->inline_access_w('$val'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | $me->inline_weaken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | sub accessor : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 12 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accessor: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 12 | $me->inline_to_coderef( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | accessor => $me->inline_accessor, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | sub inline_accessor : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 12 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_accessor: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 12 | my $get = $me->inline_access; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 12 | my $coerce = $me->inline_type_coercion('$_[1]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 12 | ▶ | if ($coerce eq '$_[1]') # i.e. no coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 8 | ▶ | if (!$me->{lazy} and !$me->{trigger} and !$me->{weak_ref}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$me->{"lazy"} or $me->{"trigger"} or $me->{"weak_ref"}
$me->{"lazy"} or $me->{"trigger"}
MC/DC33%1/3
$me->{"lazy"} or $me->{"trigger"} or $me->{"weak_ref"}
$me->{"lazy"}
$me->{"trigger"}
$me->{"weak_ref"}
Truth table50%2/4
A or B or C
A= $me->{"lazy"}B= $me->{"trigger"}C= $me->{"weak_ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 7 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | '(@_ > 1) ? (%s) : %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | $me->inline_access_w( $me->inline_type_assertion('$_[1]') ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | $me->inline_get, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 1 | return sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 'if (@_ > 1) { %s; %s; %s; %s }; %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | $me->inline_type_assertion('$_[1]'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | $me->inline_trigger('$_[1]', $get), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | $me->inline_access_w('$_[1]'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | $me->inline_weaken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | $me->inline_reader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 4 | 'if (@_ > 1) { my $val = %s; %s; %s; %s; %s }; %s', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | $coerce, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | $me->inline_type_assertion('$val'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | $me->inline_trigger('$val', $get), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | $me->inline_access_w('$val'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | $me->inline_weaken, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | $me->inline_reader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | sub inline_type_coercion : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 21 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_type_coercion: called CC=14 SCAR=40.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 21 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 21 | ▶ | my $coercion = $me->{coerce} or return $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 8 | ▶ | unless (ref $coercion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 8 | my $type = $me->{isa}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 8 | ▶ | if (blessed($type) and $type->can('coercion')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
builtin::blessed($type) and $type->can("coercion")
MC/DC0%0/2
builtin::blessed($type) and $type->can("coercion")
builtin::blessed($type)
$type->can("coercion")
Truth table33%1/3
A and B
A= builtin::blessed($type)B= $type->can("coercion")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 8 | $coercion = $type->coercion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | ▶ | elsif (blessed($type) and $type->can('coerce')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
builtin::blessed($type) and $type->can("coerce")
MC/DC0%0/2
builtin::blessed($type) and $type->can("coerce")
builtin::blessed($type)
$type->can("coerce")
Truth table0%0/3
A and B
A= builtin::blessed($type)B= $type->can("coerce")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | $coercion = sub { $type->coerce(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | croak("Invalid coerce; type constraint cannot be probed for coercion"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 8 | ▶ | unless (ref $coercion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | carp("Invalid coerce; type constraint has no coercion"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | return $var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 8 | ▶ | if ( blessed($coercion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
builtin::blessed($coercion) and $coercion->can("can_be_inlined") and $coercion->can_be_inlined and $coercion->can("inline_coercion")
builtin::blessed($coercion) and $coercion->can("can_be_inlined") and $coercion->can_be_inlined
builtin::blessed($coercion) and $coercion->can("can_be_inlined")
MC/DC0%0/4
builtin::blessed($coercion) and $coercion->can("can_be_inlined") and $coercion->can_be_inlined and $coercion->can("inline_coercion")
builtin::blessed($coercion)
$coercion->can("can_be_inlined")
$coercion->can_be_inlined
$coercion->can("inline_coercion")
Truth table20%1/5
A and B and C and D
A= builtin::blessed($coercion)B= $coercion->can("can_be_inlined")C= $coercion->can_be_inlinedD= $coercion->can("inline_coercion")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | and $coercion->can('can_be_inlined') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | and $coercion->can_be_inlined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | and $coercion->can('inline_coercion') ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 8 | return $coercion->inline_coercion($var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # Otherwise need to close over $coerce | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $me->{inline_environment}{'$coercion'} = \$coercion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if ( blessed($coercion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($coercion) and $coercion->can("coerce")
MC/DC0%0/2
builtin::blessed($coercion) and $coercion->can("coerce")
builtin::blessed($coercion)
$coercion->can("coerce")
Truth table0%0/3
A and B
A= builtin::blessed($coercion)B= $coercion->can("coerce")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | and $coercion->can('coerce') ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | return sprintf('$coercion->coerce(%s)', $var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | return sprintf('$coercion->(%s)', $var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | sub inline_type_assertion : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 21 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_type_assertion: called CC=14 SCAR=45.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 21 | my ($var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 21 | ▶ | my $type = $me->{isa} or return $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 10 | ▶ | if ( blessed($type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
builtin::blessed($type) and $type->isa("Type::Tiny") and $type->can_be_inlined
builtin::blessed($type) and $type->isa("Type::Tiny")
MC/DC0%0/3
builtin::blessed($type) and $type->isa("Type::Tiny") and $type->can_be_inlined
builtin::blessed($type)
$type->isa("Type::Tiny")
$type->can_be_inlined
Truth table25%1/4
A and B and C
A= builtin::blessed($type)B= $type->isa("Type::Tiny")C= $type->can_be_inlined
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | and $type->isa('Type::Tiny') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | and $type->can_be_inlined ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 10 | my $ass = $type->inline_assert($var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 10 | ▶ | if ($ass =~ /\Ado \{(.+)\};\z/sm) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 10 | return "do { $1 }"; # i.e. drop trailing ";" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # otherwise protect expression from trailing ";" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | return "do { $ass }" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | # Otherwise need to close over $type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | $me->{inline_environment}{'$type'} = \$type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | # non-Type::Tiny but still supports inlining | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | if ( blessed($type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
builtin::blessed($type) and $type->can("can_be_inlined") and $type->can_be_inlined
builtin::blessed($type) and $type->can("can_be_inlined")
MC/DC0%0/3
builtin::blessed($type) and $type->can("can_be_inlined") and $type->can_be_inlined
builtin::blessed($type)
$type->can("can_be_inlined")
$type->can_be_inlined
Truth table0%0/4
A and B and C
A= builtin::blessed($type)B= $type->can("can_be_inlined")C= $type->can_be_inlined
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | and $type->can('can_be_inlined') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | and $type->can_be_inlined ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | my $inliner = $type->can('inline_check') || $type->can('_inline_check'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$type->can('inline_check') || $type->can('_inline_check')
MC/DC0%0/2
$type->can('inline_check') || $type->can('_inline_check')
$type->can('inline_check')
$type->can('_inline_check')
Truth table0%0/3
A || B
A= $type->can('inline_check')B= $type->can('_inline_check')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if ($inliner) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | return sprintf('do { %s } ? %s : Carp::croak($type->get_message(%s))', $type->$inliner($var), $var, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | if ( blessed($type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
builtin::blessed($type) and $type->can("check") and $type->can("get_message")
builtin::blessed($type) and $type->can("check")
MC/DC0%0/3
builtin::blessed($type) and $type->can("check") and $type->can("get_message")
builtin::blessed($type)
$type->can("check")
$type->can("get_message")
Truth table0%0/4
A and B and C
A= builtin::blessed($type)B= $type->can("check")C= $type->can("get_message")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | and $type->can('check') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | and $type->can('get_message') ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | return sprintf('$type->check(%s) ? %s : Carp::croak($type->get_message(%s))', $var, $var, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | return sprintf('$type->(%s) ? %s : Carp::croak("Value %s failed type constraint check")', $var, $var, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | sub inline_weaken : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 9 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_weaken: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 9 | ▶ | return '' unless $me->{weak_ref}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | sprintf( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | q[ Scalar::Util::weaken(%s) if ref(%s) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | $me->inline_access, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | $me->inline_access, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | sub inline_trigger : method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 9 | ▶ | my $me = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_trigger: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 9 | my ($new, $old) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 9 | ▶ | my $trigger = $me->{trigger} or return ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 8 | $me->{inline_environment}{'$trigger'} = \$trigger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 8 | return sprintf('$trigger->($_[0], %s, %s)', $new, $old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | =for stopwords benchmarking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | Sub::Accessor::Small - small toolkit for generating getter/setter methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | package MyClass; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | use Sub::Accessor::Small; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | use Types::Standard qw( Int ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | my $self = bless \$class, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | my %args = @_ == 1 ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # Simple way to initialize each attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | for my $key ( sort keys %args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | $self->$key( $args{$key} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 'Sub::Accessor::Small'->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | package => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | name => "foo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | )->install_accessors(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | my $obj = MyClass->new( foo => 42 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | This is a small toolkit for generating Moose-like attribute accessors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | B<< It does not generate a constructor. >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | It stores attribute values inside-out, but it is designed for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | Sub::Accessor::Small to be subclassed, making it easy to store attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | in other ways. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | Please report any bugs to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | L<http://rt.cpan.org/Dist/Display.html?Queue=Lexical-Accessor>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | L<Lexical::Accessor>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | Toby Inkster E<lt>tobyink@cpan.orgE<gt>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | =head1 COPYRIGHT AND LICENCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | This software is copyright (c) 2013-2014, 2017, 2020 by Toby Inkster. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | =head1 DISCLAIMER OF WARRANTIES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||