« /usr/local/lib/perl5/5.44.0/File/Path.pm
↑ Summary
/usr/local/lib/perl5/5.44.0/x86_64-linux/IO/Socket/INET.pm »
| 1 | package Method::Generate::Accessor; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use Moo::_Utils qw(_maybe_load_module _install_coderef _module_name_rx); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Moo::Object (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | BEGIN { our @ISA = qw(Moo::Object) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Sub::Quote qw(quote_sub quoted_from_sub quotify sanitize_identifier); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | our @CARP_NOT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 13 | Moo::_Utils | ||||||||||||||||||||||||||||||||||||||||||
| 14 | Moo::Object | ||||||||||||||||||||||||||||||||||||||||||
| 15 | Moo::Role | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=6 SCAR=22.9
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | *_CAN_WEAKEN_READONLY = ( | ||||||||||||||||||||||||||||||||||||||||||
| 20 | "$]" < 5.008_003 or $ENV{MOO_TEST_PRE_583} | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | ) ? sub(){0} : sub(){1}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
"$]" < "5.008003" or $ENV{"MOO_TEST_PRE_583"}
MC/DC0%0/2
"$]" < "5.008003" or $ENV{"MOO_TEST_PRE_583"}
"$]" < "5.008003"
$ENV{"MOO_TEST_PRE_583"}
Truth table33%1/3
A or B
A= "$]" < "5.008003"B= $ENV{"MOO_TEST_PRE_583"}
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | our $CAN_HAZ_XS = | ||||||||||||||||||||||||||||||||||||||||||
| 23 | !$ENV{MOO_XS_DISABLE} | ||||||||||||||||||||||||||||||||||||||||||
| 24 | && | ||||||||||||||||||||||||||||||||||||||||||
| 25 | _maybe_load_module('Class::XSAccessor') | ||||||||||||||||||||||||||||||||||||||||||
| 26 | && | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | (eval { Class::XSAccessor->VERSION('1.07') }) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
!$ENV{'MOO_XS_DISABLE'} && _maybe_load_module('Class::XSAccessor') && eval {
do {
'Class::XSAccessor'->VERSION('1.07')
}
}
not $ENV{"MOO_XS_DISABLE"} and _maybe_load_module("Class::XSAccessor")
MC/DC0%0/3
!$ENV{'MOO_XS_DISABLE'} && _maybe_load_module('Class::XSAccessor') && eval {
do {
'Class::XSAccessor'->VERSION('1.07')
}
}
not $ENV{"MOO_XS_DISABLE"}
_maybe_load_module("Class::XSAccessor")
eval {
do {
'Class::XSAccessor'->VERSION('1.07')
}
}
Truth table25%1/4
not(A) and B && C
A= not $ENV{"MOO_XS_DISABLE"}B= _maybe_load_module("Class::XSAccessor")C= eval {
do {
'Class::XSAccessor'->VERSION('1.07')
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | our $CAN_HAZ_XS_PRED = | ||||||||||||||||||||||||||||||||||||||||||
| 30 | $CAN_HAZ_XS && | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | (eval { Class::XSAccessor->VERSION('1.17') }) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Method::Generate::Accessor::CAN_HAZ_XS && eval {
do {
'Class::XSAccessor'->VERSION('1.17')
}
}
MC/DC0%0/2
$Method::Generate::Accessor::CAN_HAZ_XS && eval {
do {
'Class::XSAccessor'->VERSION('1.17')
}
}
$Method::Generate::Accessor::CAN_HAZ_XS
eval {
do {
'Class::XSAccessor'->VERSION('1.17')
}
}
Truth table33%1/3
A && B
A= $Method::Generate::Accessor::CAN_HAZ_XSB= eval {
do {
'Class::XSAccessor'->VERSION('1.17')
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | package | ||||||||||||||||||||||||||||||||||||||||||
| 36 | Method::Generate::Accessor::_Generated; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | $Carp::Internal{+__PACKAGE__} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _die_overwrite { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_die_overwrite: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ($pkg, $method, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | croak "You cannot overwrite a locally defined method ($method) with " | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$type || 'an accessor'
MC/DC0%0/1
$type || 'an accessor'
$type
Truth table0%0/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | . ( $type || 'an accessor' ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 223 | ▶ | sub generate_method { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_method: called CC=81 SCAR=75.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 223 | my ($self, $into, $name, $spec, $quote_opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 48 | $quote_opts = { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | no_defer => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | package => 'Method::Generate::Accessor::_Generated', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 223 | ▶ | %{ $quote_opts||{} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$quote_opts || {}
MC/DC0%0/1
$quote_opts || {}
$quote_opts
Truth table50%1/2
A
A= $quote_opts
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 223 | ▶ | $spec->{allow_overwrite}++ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | if $name =~ s/^\+//; | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 223 | my $is = $spec->{is}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 223 | ▶ | if (!$is) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | croak "Must have an is"; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | elsif ($is eq 'ro') { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 144 | ▶ | $spec->{reader} = $name unless exists $spec->{reader}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | elsif ($is eq 'rw') { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | $spec->{accessor} = $name unless exists $spec->{accessor} | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | or ( $spec->{reader} and $spec->{writer} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $spec->{"accessor"} or $spec->{"reader"} and $spec->{"writer"}
$spec->{"reader"} and $spec->{"writer"}
MC/DC0%0/3
exists $spec->{"accessor"} or $spec->{"reader"} and $spec->{"writer"}
exists $spec->{"accessor"}
$spec->{"reader"}
$spec->{"writer"}
Truth table0%0/4
A or B and C
A= exists $spec->{"accessor"}B= $spec->{"reader"}C= $spec->{"writer"}
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | elsif ($is eq 'lazy') { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 79 | ▶ | $spec->{reader} = $name unless exists $spec->{reader}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 79 | $spec->{lazy} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 79 | ▶ | $spec->{builder} ||= '_build_'.$name unless exists $spec->{default}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$spec->{"builder"} ||= '_build_' . $name
MC/DC100%1/1
$spec->{"builder"} ||= '_build_' . $name
$spec->{"builder"}
Truth table100%2/2
A
A= $spec->{"builder"}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | elsif ($is eq 'rwp') { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $spec->{reader} = $name unless exists $spec->{reader}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $spec->{writer} = "_set_${name}" unless exists $spec->{writer}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif ($is ne 'bare') { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | croak "Unknown is ${is}"; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 223 | ▶ | if (exists $spec->{builder}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 79 | ▶ | if(ref $spec->{builder}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | $self->_validate_codulatable('builder', $spec->{builder}, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 45 | "$into->$name", 'or a method name'); | |||||||||||||||||||||||||||||||||||||||||
| 85 | 45 | $spec->{builder_sub} = $spec->{builder}; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 45 | $spec->{builder} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 79 | ▶ | $spec->{builder} = '_build_'.$name if ($spec->{builder}||0) eq 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$spec->{'builder'} || 0
MC/DC0%0/1
$spec->{'builder'} || 0
$spec->{'builder'}
Truth table50%1/2
A
A= $spec->{'builder'}
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | croak "Invalid builder for $into->$name - not a valid method name" | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 79 | ▶ | if $spec->{builder} !~ _module_name_rx; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 223 | ▶ | if (($spec->{predicate}||0) eq 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$spec->{'predicate'} || 0
MC/DC0%0/1
$spec->{'predicate'} || 0
$spec->{'predicate'}
Truth table50%1/2
A
A= $spec->{'predicate'}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | $spec->{predicate} = $name =~ /^_/ ? "_has${name}" : "has_${name}"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 223 | ▶ | if (($spec->{clearer}||0) eq 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$spec->{'clearer'} || 0
MC/DC0%0/1
$spec->{'clearer'} || 0
$spec->{'clearer'}
Truth table50%1/2
A
A= $spec->{'clearer'}
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $spec->{clearer} = $name =~ /^_/ ? "_clear${name}" : "clear_${name}"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 223 | ▶ | if (($spec->{trigger}||0) eq 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$spec->{'trigger'} || 0
MC/DC0%0/1
$spec->{'trigger'} || 0
$spec->{'trigger'}
Truth table50%1/2
A
A= $spec->{'trigger'}
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $spec->{trigger} = quote_sub('shift->_trigger_'.$name.'(@_)'); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 223 | ▶ | if (($spec->{coerce}||0) eq 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$spec->{'coerce'} || 0
MC/DC0%0/1
$spec->{'coerce'} || 0
$spec->{'coerce'}
Truth table50%1/2
A
A= $spec->{'coerce'}
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $isa = $spec->{isa}; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if (blessed $isa and $isa->can('coercion')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
builtin::blessed($isa) and $isa->can("coercion")
MC/DC0%0/2
builtin::blessed($isa) and $isa->can("coercion")
builtin::blessed($isa)
$isa->can("coercion")
Truth table0%0/3
A and B
A= builtin::blessed($isa)B= $isa->can("coercion")
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $spec->{coerce} = $isa->coercion; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | ▶ | elsif (blessed $isa and $isa->can('coerce')) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
builtin::blessed($isa) and $isa->can("coerce")
MC/DC0%0/2
builtin::blessed($isa) and $isa->can("coerce")
builtin::blessed($isa)
$isa->can("coerce")
Truth table0%0/3
A and B
A= builtin::blessed($isa)B= $isa->can("coerce")
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $spec->{coerce} = sub { $isa->coerce(@_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | croak "Invalid coercion for $into->$name - no appropriate type constraint"; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 223 | foreach my $setting (qw( isa coerce )) { | |||||||||||||||||||||||||||||||||||||||||
| 119 | next | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 446 | ▶ | if !exists $spec->{$setting}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | $self->_validate_codulatable($setting, $spec->{$setting}, "$into->$name"); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 223 | ▶ | if (exists $spec->{default}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 51 | ▶ | if (ref $spec->{default}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 51 | $self->_validate_codulatable('default', $spec->{default}, "$into->$name", | |||||||||||||||||||||||||||||||||||||||||
| 127 | 'or a non-ref'); | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 223 | ▶ | if (exists $spec->{moosify}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if (ref $spec->{moosify} ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $spec->{moosify} = [$spec->{moosify}]; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | foreach my $spec (@{$spec->{moosify}}) { | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->_validate_codulatable('moosify', $spec, "$into->$name"); | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 223 | my %methods; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 223 | ▶ | if (my $reader = $spec->{reader}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | _die_overwrite($into, $reader, 'a reader') | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 223 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${reader}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$reader";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$reader";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$reader";}
Truth table33%1/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$reader";}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 223 | ▶ | if (our $CAN_HAZ_XS && $self->is_simple_get($name, $spec)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
our $CAN_HAZ_XS and $self->is_simple_get($name, $spec)
MC/DC50%1/2
our $CAN_HAZ_XS and $self->is_simple_get($name, $spec)
our $CAN_HAZ_XS
$self->is_simple_get($name, $spec)
Truth table66%2/3
A and B
A= our $CAN_HAZ_XSB= $self->is_simple_get($name, $spec)
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 144 | $methods{$reader} = $self->_generate_xs( | |||||||||||||||||||||||||||||||||||||||||
| 147 | getters => $into, $reader, $name, $spec | ||||||||||||||||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 79 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | $methods{$reader} = | ||||||||||||||||||||||||||||||||||||||||||
| 153 | quote_sub "${into}::${reader}" | ||||||||||||||||||||||||||||||||||||||||||
| 154 | => ' Carp::croak("'.$reader.' is a read-only accessor") if @_ > 1;'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 155 | .$self->_generate_get($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 156 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 79 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 158 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 223 | ▶ | if (my $accessor = $spec->{accessor}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | _die_overwrite($into, $accessor, 'an accessor') | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${accessor}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$accessor";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$accessor";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$accessor";}
Truth table0%0/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$accessor";}
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
our $CAN_HAZ_XS and $self->is_simple_get($name, $spec) and $self->is_simple_set($name, $spec)
our $CAN_HAZ_XS and $self->is_simple_get($name, $spec)
MC/DC0%0/3
our $CAN_HAZ_XS and $self->is_simple_get($name, $spec) and $self->is_simple_set($name, $spec)
our $CAN_HAZ_XS
$self->is_simple_get($name, $spec)
$self->is_simple_set($name, $spec)
Truth table0%0/4
A and B and C
A= our $CAN_HAZ_XSB= $self->is_simple_get($name, $spec)C= $self->is_simple_set($name, $spec)
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | our $CAN_HAZ_XS | ||||||||||||||||||||||||||||||||||||||||||
| 167 | && $self->is_simple_get($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | && $self->is_simple_set($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $methods{$accessor} = $self->_generate_xs( | |||||||||||||||||||||||||||||||||||||||||
| 171 | accessors => $into, $accessor, $name, $spec | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | $methods{$accessor} = | ||||||||||||||||||||||||||||||||||||||||||
| 177 | quote_sub "${into}::${accessor}" | ||||||||||||||||||||||||||||||||||||||||||
| 178 | => $self->_generate_getset($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 179 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 181 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 223 | ▶ | if (my $writer = $spec->{writer}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | _die_overwrite($into, $writer, 'a writer') | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${writer}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$writer";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$writer";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$writer";}
Truth table0%0/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$writer";}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
our $CAN_HAZ_XS and $self->is_simple_set($name, $spec)
MC/DC0%0/2
our $CAN_HAZ_XS and $self->is_simple_set($name, $spec)
our $CAN_HAZ_XS
$self->is_simple_set($name, $spec)
Truth table0%0/3
A and B
A= our $CAN_HAZ_XSB= $self->is_simple_set($name, $spec)
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | our $CAN_HAZ_XS | ||||||||||||||||||||||||||||||||||||||||||
| 190 | && $self->is_simple_set($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $methods{$writer} = $self->_generate_xs( | |||||||||||||||||||||||||||||||||||||||||
| 193 | setters => $into, $writer, $name, $spec | ||||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 198 | $methods{$writer} = | ||||||||||||||||||||||||||||||||||||||||||
| 199 | quote_sub "${into}::${writer}" | ||||||||||||||||||||||||||||||||||||||||||
| 200 | => $self->_generate_set($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 201 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 203 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 223 | ▶ | if (my $pred = $spec->{predicate}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | _die_overwrite($into, $pred, 'a predicate') | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${pred}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$pred";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$pred";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$pred";}
Truth table0%0/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$pred";}
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (our $CAN_HAZ_XS && our $CAN_HAZ_XS_PRED) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
our $CAN_HAZ_XS and our $CAN_HAZ_XS_PRED
MC/DC0%0/2
our $CAN_HAZ_XS and our $CAN_HAZ_XS_PRED
our $CAN_HAZ_XS
our $CAN_HAZ_XS_PRED
Truth table0%0/3
A and B
A= our $CAN_HAZ_XSB= our $CAN_HAZ_XS_PRED
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $methods{$pred} = $self->_generate_xs( | |||||||||||||||||||||||||||||||||||||||||
| 211 | exists_predicates => $into, $pred, $name, $spec | ||||||||||||||||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | $methods{$pred} = | ||||||||||||||||||||||||||||||||||||||||||
| 217 | quote_sub "${into}::${pred}" | ||||||||||||||||||||||||||||||||||||||||||
| 218 | => $self->_generate_simple_has('$_[0]', $name, $spec)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 219 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 221 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 223 | ▶ | if (my $builder = delete $spec->{builder_sub}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 45 | _install_coderef( "${into}::$spec->{builder}" => $builder ); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 223 | ▶ | if (my $cl = $spec->{clearer}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | _die_overwrite($into, $cl, 'a clearer') | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${cl}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$cl";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$cl";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$cl";}
Truth table0%0/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$cl";}
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | $methods{$cl} = | ||||||||||||||||||||||||||||||||||||||||||
| 234 | quote_sub "${into}::${cl}" | ||||||||||||||||||||||||||||||||||||||||||
| 235 | => $self->_generate_simple_clear('$_[0]', $name, $spec)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 236 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 238 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 223 | ▶ | if (my $hspec = $spec->{handles}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | my $asserter = $spec->{asserter} ||= '_assert_'.$name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$spec->{"asserter"} ||= '_assert_' . $name
MC/DC0%0/1
$spec->{"asserter"} ||= '_assert_' . $name
$spec->{"asserter"}
Truth table0%0/2
A
A= $spec->{"asserter"}
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | my @specs = | ||||||||||||||||||||||||||||||||||||||||||
| 244 | ref $hspec eq 'ARRAY' ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 245 | map [ $_ => $_ ], @$hspec | ||||||||||||||||||||||||||||||||||||||||||
| 246 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 247 | : ref $hspec eq 'HASH' ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | map [ $_ => ref($hspec->{$_}) ? @{$hspec->{$_}} : $hspec->{$_} ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | keys %$hspec | ||||||||||||||||||||||||||||||||||||||||||
| 250 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | : !ref $hspec ? do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | require Moo::Role; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | map [ $_ => $_ ], Moo::Role->methods_provided_by($hspec) | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | : croak "You gave me a handles of ${hspec} and I have no idea why"; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | foreach my $delegation_spec (@specs) { | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my ($proxy, $target, @args) = @$delegation_spec; | |||||||||||||||||||||||||||||||||||||||||
| 259 | _die_overwrite($into, $proxy, 'a delegation') | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${proxy}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$proxy";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$proxy";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$proxy";}
Truth table0%0/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$proxy";}
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 262 | $methods{$proxy} = | ||||||||||||||||||||||||||||||||||||||||||
| 263 | quote_sub "${into}::${proxy}" | ||||||||||||||||||||||||||||||||||||||||||
| 264 | => $self->_generate_delegation($asserter, $target, \@args) | ||||||||||||||||||||||||||||||||||||||||||
| 265 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 267 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 223 | ▶ | if (my $asserter = $spec->{asserter}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | _die_overwrite($into, $asserter, 'an asserter') | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if !$spec->{allow_overwrite} && defined &{"${into}::${asserter}"}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $spec->{"allow_overwrite"} and defined &{"${into}::$asserter";}
MC/DC0%0/2
not $spec->{"allow_overwrite"} and defined &{"${into}::$asserter";}
not $spec->{"allow_overwrite"}
defined &{"${into}::$asserter";}
Truth table0%0/3
not(A) and B
A= not $spec->{"allow_overwrite"}B= defined &{"${into}::$asserter";}
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | local $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 275 | $methods{$asserter} = | ||||||||||||||||||||||||||||||||||||||||||
| 276 | quote_sub "${into}::${asserter}" | ||||||||||||||||||||||||||||||||||||||||||
| 277 | => $self->_generate_asserter($name, $spec) | ||||||||||||||||||||||||||||||||||||||||||
| 278 | => delete $self->{captures} | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | => $quote_opts | |||||||||||||||||||||||||||||||||||||||||
| 280 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 223 | \%methods; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | sub merge_specs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_specs: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my ($self, @specs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $spec = shift @specs; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | for my $old_spec (@specs) { | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | foreach my $key (keys %$old_spec) { | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if ($key eq 'handles') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | elsif ($key eq 'moosify') { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | $spec->{$key} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | map { ref $_ eq 'ARRAY' ? @$_ : $_ } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | grep defined, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ($old_spec->{$key}, $spec->{$key}) | |||||||||||||||||||||||||||||||||||||||||
| 298 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | ▶ | elsif ($key eq 'builder' || $key eq 'default') { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$key eq "builder" or $key eq "default"
MC/DC0%0/2
$key eq "builder" or $key eq "default"
$key eq "builder"
$key eq "default"
Truth table0%0/3
A or B
A= $key eq "builder"B= $key eq "default"
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | $spec->{$key} = $old_spec->{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if !(exists $spec->{builder} || exists $spec->{default}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $spec->{"builder"} or exists $spec->{"default"}
MC/DC0%0/2
exists $spec->{"builder"} or exists $spec->{"default"}
exists $spec->{"builder"}
exists $spec->{"default"}
Truth table0%0/3
A or B
A= exists $spec->{"builder"}B= exists $spec->{"default"}
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | elsif (!exists $spec->{$key}) { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $spec->{$key} = $old_spec->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $spec; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub is_simple_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_simple_attribute: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 314 | # clearer doesn't have to be listed because it doesn't | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # affect whether defined/exists makes a difference | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | !grep $spec->{$_}, | |||||||||||||||||||||||||||||||||||||||||
| 317 | qw(lazy default builder coerce isa trigger predicate weak_ref); | ||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 302 | ▶ | sub is_simple_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_simple_get: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 302 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 302 | ▶ | !($spec->{lazy} and (exists $spec->{default} or $spec->{builder})); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$spec->{'lazy'} && (exists $spec->{'default'} || $spec->{'builder'})
exists $spec->{"default"} or $spec->{"builder"}
MC/DC33%1/3
$spec->{'lazy'} && (exists $spec->{'default'} || $spec->{'builder'})
$spec->{'lazy'}
exists $spec->{"default"}
$spec->{"builder"}
Truth table50%2/4
A && B or C
A= $spec->{'lazy'}B= exists $spec->{"default"}C= $spec->{"builder"}
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | sub is_simple_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_simple_set: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | !grep $spec->{$_}, qw(coerce isa trigger weak_ref); | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 54 | ▶ | sub has_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_default: called CC=4 SCAR=16.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 54 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 54 | ▶ | $spec->{builder} or exists $spec->{default} or (($spec->{is}||'') eq 'lazy'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$spec->{"builder"} or exists $spec->{"default"}
$spec->{'is'} || ''
MC/DC0%0/2
$spec->{"builder"} or exists $spec->{"default"}
$spec->{"builder"}
exists $spec->{"default"}
MC/DC0%0/1
$spec->{'is'} || ''
$spec->{'is'}
Truth table33%1/3
A or B
A= $spec->{"builder"}B= exists $spec->{"default"}
Truth table50%1/2
A
A= $spec->{'is'}
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 153 | ▶ | sub has_eager_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_eager_default: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 153 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 153 | ▶ | (!$spec->{lazy} and (exists $spec->{default} or $spec->{builder})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
!$spec->{'lazy'} && (exists $spec->{'default'} || $spec->{'builder'})
exists $spec->{"default"} or $spec->{"builder"}
MC/DC66%2/3
!$spec->{'lazy'} && (exists $spec->{'default'} || $spec->{'builder'})
!$spec->{'lazy'}
exists $spec->{"default"}
$spec->{"builder"}
Truth table75%3/4
not(A) && B or C
A= !$spec->{'lazy'}B= exists $spec->{"default"}C= $spec->{"builder"}
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 79 | ▶ | sub _generate_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_get: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 79 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 79 | my $simple = $self->_generate_simple_get('$_[0]', $name, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 79 | ▶ | if ($self->is_simple_get($name, $spec)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $simple; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 79 | $self->_generate_use_default( | |||||||||||||||||||||||||||||||||||||||||
| 347 | '$_[0]', $name, $spec, | ||||||||||||||||||||||||||||||||||||||||||
| 348 | $self->_generate_simple_has('$_[0]', $name, $spec), | ||||||||||||||||||||||||||||||||||||||||||
| 349 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub generate_simple_has { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_simple_has: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $code = $self->_generate_simple_has(@_); | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 79 | ▶ | sub _generate_simple_has { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_simple_has: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 79 | my ($self, $me, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 79 | "exists ${me}->{${\quotify $name}}"; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _generate_simple_clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_simple_clear: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ($self, $me, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | " delete ${me}->{${\quotify $name}}\n" | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub generate_get_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_get_default: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $code = $self->_generate_get_default(@_); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub generate_use_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_use_default: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $code = $self->_generate_use_default(@_); | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 79 | ▶ | sub _generate_use_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_use_default: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 79 | my ($self, $me, $name, $spec, $test) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 79 | my $get_value = $self->_generate_get_default($me, $name, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 79 | ▶ | if ($spec->{coerce}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | $get_value = $self->_generate_coerce( | ||||||||||||||||||||||||||||||||||||||||||
| 389 | $name, $get_value, | ||||||||||||||||||||||||||||||||||||||||||
| 390 | $spec->{coerce} | ||||||||||||||||||||||||||||||||||||||||||
| 391 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 393 | $test." ? \n" | ||||||||||||||||||||||||||||||||||||||||||
| 394 | .$self->_generate_simple_get($me, $name, $spec)."\n:" | ||||||||||||||||||||||||||||||||||||||||||
| 395 | .($spec->{isa} ? | ||||||||||||||||||||||||||||||||||||||||||
| 396 | " do {\n my \$value = ".$get_value.";\n" | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 79 | ▶ | ." ".$self->_generate_isa_check($name, '$value', $spec->{isa}).";\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | ." ".$self->_generate_simple_set($me, $name, $spec, '$value')."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 399 | ." }\n" | ||||||||||||||||||||||||||||||||||||||||||
| 400 | : ' ('.$self->_generate_simple_set($me, $name, $spec, $get_value).")\n" | ||||||||||||||||||||||||||||||||||||||||||
| 401 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 101 | ▶ | sub _generate_get_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_get_default: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 101 | my ($self, $me, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 101 | ▶ | if (exists $spec->{default}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | ref $spec->{default} | ||||||||||||||||||||||||||||||||||||||||||
| 408 | ? $self->_generate_call_code($name, 'default', $me, $spec->{default}) | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 22 | ▶ | : quotify $spec->{default}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 79 | "${me}->${\$spec->{builder}}" | |||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub generate_simple_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_simple_get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $code = $self->_generate_simple_get(@args); | |||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 158 | ▶ | sub _generate_simple_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_simple_get: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 158 | my ($self, $me, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 158 | my $name_str = quotify $name; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 158 | "${me}->{${name_str}}"; | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | sub _generate_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_set: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ($me, $source) = ('$_[0]', '$_[1]'); | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if ($self->is_simple_set($name, $spec)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return $self->_generate_simple_set($me, $name, $spec, $source); | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my ($coerce, $trigger, $isa_check) = @{$spec}{qw(coerce trigger isa)}; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if ($coerce) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $source = $self->_generate_coerce($name, $source, $coerce); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if ($isa_check) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | 'scalar do { my $value = '.$source.";\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | .' ('.$self->_generate_isa_check($name, '$value', $isa_check)."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 443 | .' ('.$self->_generate_simple_set($me, $name, $spec, '$value')."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 444 | .($trigger | ||||||||||||||||||||||||||||||||||||||||||
| 445 | ? '('.$self->_generate_trigger($name, $me, '$value', $trigger)."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 446 | : '') | ||||||||||||||||||||||||||||||||||||||||||
| 447 | .' ('.$self->_generate_simple_get($me, $name, $spec)."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ."}"; | ||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | elsif ($trigger) { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $set = $self->_generate_simple_set($me, $name, $spec, $source); | |||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | "scalar (\n" | |||||||||||||||||||||||||||||||||||||||||
| 453 | . ' ('.$self->_generate_trigger($name, $me, "($set)", $trigger)."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 454 | . ' ('.$self->_generate_simple_get($me, $name, $spec)."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 455 | . ")"; | ||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | '('.$self->_generate_simple_set($me, $name, $spec, $source).')'; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | sub generate_coerce { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_coerce: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my $code = $self->_generate_coerce(@_); | |||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | ▶ | sub _attr_desc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attr_desc: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | my ($name, $init_arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | ▶ | return quotify($name) if !defined($init_arg) or $init_arg eq $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $init_arg or $init_arg eq $name
MC/DC0%0/2
not defined $init_arg or $init_arg eq $name
not defined $init_arg
$init_arg eq $name
Truth table33%1/3
not(A) or B
A= not defined $init_argB= $init_arg eq $name
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return quotify($name).' (constructor argument: '.quotify($init_arg).')'; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | sub _generate_coerce { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_coerce: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my ($self, $name, $value, $coerce, $init_arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->_wrap_attr_exception( | |||||||||||||||||||||||||||||||||||||||||
| 478 | $name, | ||||||||||||||||||||||||||||||||||||||||||
| 479 | "coercion", | ||||||||||||||||||||||||||||||||||||||||||
| 480 | $init_arg, | ||||||||||||||||||||||||||||||||||||||||||
| 481 | $self->_generate_call_code($name, 'coerce', "${value}", $coerce), | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 1, | ||||||||||||||||||||||||||||||||||||||||||
| 483 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | sub generate_trigger { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_trigger: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $code = $self->_generate_trigger(@_); | |||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub _generate_trigger { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_trigger: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my ($self, $name, $obj, $value, $trigger) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $self->_generate_call_code($name, 'trigger', "${obj}, ${value}", $trigger); | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | sub generate_isa_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_isa_check: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $code = $self->_generate_isa_check(@args); | |||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 3 | ▶ | sub _wrap_attr_exception { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap_attr_exception: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | my ($self, $name, $step, $arg, $code, $want_return) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | my $prefix = quotify("${step} for "._attr_desc($name, $arg).' failed: '); | |||||||||||||||||||||||||||||||||||||||||
| 508 | 3 | ▶ | "do {\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | .' local $Method::Generate::Accessor::CurrentAttribute = {'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 510 | .' init_arg => '.quotify($arg).",\n" | ||||||||||||||||||||||||||||||||||||||||||
| 511 | .' name => '.quotify($name).",\n" | ||||||||||||||||||||||||||||||||||||||||||
| 512 | .' step => '.quotify($step).",\n" | ||||||||||||||||||||||||||||||||||||||||||
| 513 | ." };\n" | ||||||||||||||||||||||||||||||||||||||||||
| 514 | .($want_return ? ' (my $_return),'."\n" : '') | ||||||||||||||||||||||||||||||||||||||||||
| 515 | .' (my $_error), (my $_old_error = $@);'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 516 | ." (eval {\n" | ||||||||||||||||||||||||||||||||||||||||||
| 517 | .' ($@ = $_old_error),'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 518 | .' (' | ||||||||||||||||||||||||||||||||||||||||||
| 519 | .($want_return ? '$_return ='."\n" : '') | ||||||||||||||||||||||||||||||||||||||||||
| 520 | .$code."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 521 | ." 1\n" | ||||||||||||||||||||||||||||||||||||||||||
| 522 | ." } or\n" | ||||||||||||||||||||||||||||||||||||||||||
| 523 | .' $_error = CORE::ref $@ ? $@ : '.$prefix.'.$@);'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 524 | .' ($@ = $_old_error),'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 525 | .' (defined $_error and CORE::die $_error);'."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 526 | .($want_return ? ' $_return;'."\n" : '') | ||||||||||||||||||||||||||||||||||||||||||
| 527 | ."}\n" | ||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 3 | ▶ | sub _generate_isa_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_isa_check: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 3 | my ($self, $name, $value, $check, $init_arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | $self->_wrap_attr_exception( | |||||||||||||||||||||||||||||||||||||||||
| 533 | $name, | ||||||||||||||||||||||||||||||||||||||||||
| 534 | "isa check", | ||||||||||||||||||||||||||||||||||||||||||
| 535 | $init_arg, | ||||||||||||||||||||||||||||||||||||||||||
| 536 | $self->_generate_call_code($name, 'isa_check', $value, $check) | ||||||||||||||||||||||||||||||||||||||||||
| 537 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 25 | ▶ | sub _generate_call_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_call_code: called CC=6 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 25 | my ($self, $name, $type, $values, $sub) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | $sub = \&{$sub} if blessed($sub); # coderef if blessed | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 25 | ▶ | if (my $quoted = quoted_from_sub($sub)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $local = 1; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if ($values eq '@_' || $values eq '$_[0]') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$values eq "\@_" or $values eq "\$_[0]"
MC/DC0%0/2
$values eq "\@_" or $values eq "\$_[0]"
$values eq "\@_"
$values eq "\$_[0]"
Truth table0%0/3
A or B
A= $values eq "\@_"B= $values eq "\$_[0]"
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $local = 0; | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | $values = '@_'; | |||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $code = $quoted->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if (my $captures = $quoted->[2]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $cap_name = qq{\$${type}_captures_for_}.sanitize_identifier($name); | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $self->{captures}->{$cap_name} = \$captures; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | Sub::Quote::inlinify($code, $values, | |||||||||||||||||||||||||||||||||||||||||
| 554 | Sub::Quote::capture_unroll($cap_name, $captures, 6), $local); | ||||||||||||||||||||||||||||||||||||||||||
| 555 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | Sub::Quote::inlinify($code, $values, undef, $local); | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 25 | my $cap_name = qq{\$${type}_for_}.sanitize_identifier($name); | |||||||||||||||||||||||||||||||||||||||||
| 560 | 25 | $self->{captures}->{$cap_name} = \$sub; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 25 | "${cap_name}->(${values})"; | |||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | sub _sanitize_name { sanitize_identifier($_[1]) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sanitize_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 130 | ▶ | sub generate_populate_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_populate_set: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | 130 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 130 | $self->{captures} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 130 | my $code = $self->_generate_populate_set(@_); | |||||||||||||||||||||||||||||||||||||||||
| 571 | 130 | ($code, delete $self->{captures}); | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | 130 | ▶ | sub _generate_populate_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_populate_set: called CC=12 SCAR=26.6
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 130 | my ($self, $me, $name, $spec, $source, $test, $init_arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 130 | my $has_default = $self->has_eager_default($name, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 578 | 130 | ▶ | if (!($has_default || $test)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$has_default or $test
MC/DC0%0/2
$has_default or $test
$has_default
$test
Truth table66%2/3
A or B
A= $has_defaultB= $test
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 130 | ▶ | if ($has_default) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 22 | my $get_default = $self->_generate_get_default($me, $name, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 583 | 22 | ▶ | $source = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | $test | ||||||||||||||||||||||||||||||||||||||||||
| 585 | ? "(\n ${test}\n" | ||||||||||||||||||||||||||||||||||||||||||
| 586 | ." ? ${source}\n : " | ||||||||||||||||||||||||||||||||||||||||||
| 587 | .$get_default | ||||||||||||||||||||||||||||||||||||||||||
| 588 | .")" | ||||||||||||||||||||||||||||||||||||||||||
| 589 | : $get_default; | ||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 130 | ▶ | if ($spec->{coerce}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | $source = $self->_generate_coerce( | ||||||||||||||||||||||||||||||||||||||||||
| 593 | $name, $source, | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $spec->{coerce}, $init_arg | |||||||||||||||||||||||||||||||||||||||||
| 595 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | 130 | ▶ | if ($spec->{isa}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | $source = 'scalar do { my $value = '.$source.";\n" | ||||||||||||||||||||||||||||||||||||||||||
| 599 | .' ('.$self->_generate_isa_check( | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 3 | $name, '$value', $spec->{isa}, $init_arg | |||||||||||||||||||||||||||||||||||||||||
| 601 | )."),\n" | ||||||||||||||||||||||||||||||||||||||||||
| 602 | ." \$value\n" | ||||||||||||||||||||||||||||||||||||||||||
| 603 | ."}\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 130 | my $set = $self->_generate_simple_set($me, $name, $spec, $source); | |||||||||||||||||||||||||||||||||||||||||
| 606 | my $trigger = $spec->{trigger} ? $self->_generate_trigger( | ||||||||||||||||||||||||||||||||||||||||||
| 607 | $name, $me, $self->_generate_simple_get($me, $name, $spec), | ||||||||||||||||||||||||||||||||||||||||||
| 608 | $spec->{trigger} | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 130 | ▶ | ) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 130 | ▶ | if ($has_default) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 22 | ▶ | "($set)," . ($trigger && $test ? "($test and $trigger)," : '') . "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trigger and $test
MC/DC0%0/2
$trigger and $test
$trigger
$test
Truth table33%1/3
A and B
A= $triggerB= $test
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 613 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 108 | ▶ | "($test and ($set)" . ($trigger ? ", ($trigger)" : '') . "),\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 209 | ▶ | sub _generate_core_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_core_set: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 209 | my ($self, $me, $name, $spec, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 209 | my $name_str = quotify $name; | |||||||||||||||||||||||||||||||||||||||||
| 621 | 209 | "${me}->{${name_str}} = ${value}"; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | 209 | ▶ | sub _generate_simple_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_simple_set: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | 209 | my ($self, $me, $name, $spec, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 626 | 209 | my $name_str = quotify $name; | |||||||||||||||||||||||||||||||||||||||||
| 627 | 209 | my $simple = $self->_generate_core_set($me, $name, $spec, $value); | |||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 209 | ▶ | if ($spec->{weak_ref}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $get = $self->_generate_simple_get($me, $name, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | # Perl < 5.8.3 can't weaken refs to readonly vars | ||||||||||||||||||||||||||||||||||||||||||
| 634 | # (e.g. string constants). This *can* be solved by: | ||||||||||||||||||||||||||||||||||||||||||
| 635 | # | ||||||||||||||||||||||||||||||||||||||||||
| 636 | # &Internals::SvREADONLY($foo, 0); | ||||||||||||||||||||||||||||||||||||||||||
| 637 | # Scalar::Util::weaken($foo); | ||||||||||||||||||||||||||||||||||||||||||
| 638 | # &Internals::SvREADONLY($foo, 1); | ||||||||||||||||||||||||||||||||||||||||||
| 639 | # | ||||||||||||||||||||||||||||||||||||||||||
| 640 | # but requires Internal functions and is just too damn crazy | ||||||||||||||||||||||||||||||||||||||||||
| 641 | # so simply throw a better exception | ||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my $weak_simple = _CAN_WEAKEN_READONLY | |||||||||||||||||||||||||||||||||||||||||
| 643 | ? "do { Scalar::Util::weaken(${simple}); no warnings 'void'; $get }" | ||||||||||||||||||||||||||||||||||||||||||
| 644 | : <<"EOC" | ||||||||||||||||||||||||||||||||||||||||||
| 645 | ( eval { Scalar::Util::weaken($simple); 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | ? do { no warnings 'void'; $get } | ||||||||||||||||||||||||||||||||||||||||||
| 647 | : do { | ||||||||||||||||||||||||||||||||||||||||||
| 648 | if( \$@ =~ /Modification of a read-only value attempted/) { | ||||||||||||||||||||||||||||||||||||||||||
| 649 | require Carp; | ||||||||||||||||||||||||||||||||||||||||||
| 650 | Carp::croak( sprintf ( | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3', | ||||||||||||||||||||||||||||||||||||||||||
| 652 | $name_str, | ||||||||||||||||||||||||||||||||||||||||||
| 653 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 654 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 655 | die \$@; | ||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 659 | EOC | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 209 | $simple; | |||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | sub _generate_getset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_getset: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | q{(@_ > 1}."\n ? ".$self->_generate_set($name, $spec) | |||||||||||||||||||||||||||||||||||||||||
| 668 | ."\n : ".$self->_generate_get($name, $spec)."\n )"; | ||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | sub _generate_asserter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_asserter: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my ($self, $name, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $name_str = quotify($name); | |||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | "do {\n" | |||||||||||||||||||||||||||||||||||||||||
| 675 | ." my \$val = ".$self->_generate_get($name, $spec).";\n" | ||||||||||||||||||||||||||||||||||||||||||
| 676 | ." ".$self->_generate_simple_has('$_[0]', $name, $spec)."\n" | ||||||||||||||||||||||||||||||||||||||||||
| 677 | ." or Carp::croak(q{Attempted to access '}.${name_str}.q{' but it is not set});\n" | ||||||||||||||||||||||||||||||||||||||||||
| 678 | ." \$val;\n" | ||||||||||||||||||||||||||||||||||||||||||
| 679 | ."}\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | sub _generate_delegation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_delegation: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my ($self, $asserter, $target, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $arg_string = do { | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if (@$args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | # I could, I reckon, linearise out non-refs here using quotify | ||||||||||||||||||||||||||||||||||||||||||
| 686 | # plus something to check for numbers but I'm unsure if it's worth it | ||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $self->{captures}{'@curries'} = $args; | |||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | '@curries, @_'; | |||||||||||||||||||||||||||||||||||||||||
| 689 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | '@_'; | |||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | "shift->${asserter}->${target}(${arg_string});"; | |||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 144 | ▶ | sub _generate_xs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_xs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | 144 | my ($self, $type, $into, $name, $slot) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 144 | Class::XSAccessor->import( | |||||||||||||||||||||||||||||||||||||||||
| 699 | class => $into, | ||||||||||||||||||||||||||||||||||||||||||
| 700 | $type => { $name => $slot }, | ||||||||||||||||||||||||||||||||||||||||||
| 701 | replace => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 702 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 144 | $into->can($name); | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 23 | ▶ | sub default_construction_string { '{}' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_construction_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 101 | ▶ | sub _validate_codulatable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_codulatable: called CC=6 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 101 | my ($self, $setting, $value, $into, $appended) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | 101 | my $error; | |||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 101 | ▶ | if (blessed $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 715 | 7 | ▶ | no warnings 'void'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | eval { \&$value; 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | and return 1; | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $error = "could not be converted to a coderef: $@"; | |||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 720 | elsif (ref $value eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 101 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 723 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $error = 'is not a coderef or code-convertible object'; | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | croak "Invalid $setting '" | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | . ($INC{'overload.pm'} ? overload::StrVal($value) : $value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | . "' for $into " . $error | ||||||||||||||||||||||||||||||||||||||||||
| 730 | . ($appended ? " $appended" : ''); | ||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||