| 1 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de> | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # File: GX/Meta/Attribute.pm | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | package GX::Meta::Attribute; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 277 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 277 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 277 | ▶ | use GX::Meta::Accessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 277 | ▶ | use GX::Meta::Constants qw( REGEX_CLASS_NAME REGEX_METHOD_NAME ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 277 | ▶ | use GX::Meta::Delegator; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 277 | ▶ | use GX::Meta::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 277 | ▶ | use GX::Meta::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 277 | ▶ | use Scalar::Util qw( blessed weaken ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # Constants | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 277 | ▶ | use constant ACCESS_PUBLIC => 1 << 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 277 | ▶ | use constant ACCESS_PROTECTED => 1 << 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 277 | ▶ | use constant ACCESS_PRIVATE => 1 << 2; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2041 | ▶ | sub TYPE_CONSTRAINT () {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TYPE_CONSTRAINT: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # Overloading | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | use overload | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 3364 | ▶ | 'bool' => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | '0+' => sub { $_[0] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 87 | ▶ | '""' => sub { $_[0]->name }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 277 | 'fallback' => 1; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # Subclasses | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 277 | my %TYPE_REGISTRY; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1939 | ▶ | sub __register_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__register_type: called CC=6 SCAR=22.5
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1939 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1939 | my $attribute_type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 1939 | my $attribute_metaclass = shift; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 1939 | ▶ | if ( $invocant ne __PACKAGE__ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | complain "register_type() must be called on " . __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1939 | ▶ | if ( $attribute_type !~ REGEX_CLASS_NAME ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | complain "Invalid attribute type identifier"; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1939 | ▶ | if ( $attribute_metaclass !~ REGEX_CLASS_NAME ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | complain "Invalid attribute metaclass name"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1939 | ▶ | if ( defined $TYPE_REGISTRY{$attribute_type} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return if $TYPE_REGISTRY{$attribute_type} eq $attribute_metaclass; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | complain sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 71 | "Attribute type \"%s\" is already mapped to class %s", | ||||||||||||||||||||||||||||||||||||||||||
| 72 | $attribute_type, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $TYPE_REGISTRY{$attribute_type} | |||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1939 | $TYPE_REGISTRY{$attribute_type} = $attribute_metaclass; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1939 | return; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 277 | for ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 85 | Array | ||||||||||||||||||||||||||||||||||||||||||
| 86 | Bool | ||||||||||||||||||||||||||||||||||||||||||
| 87 | Hash | ||||||||||||||||||||||||||||||||||||||||||
| 88 | Hash::Ordered | ||||||||||||||||||||||||||||||||||||||||||
| 89 | Object | ||||||||||||||||||||||||||||||||||||||||||
| 90 | Scalar | ||||||||||||||||||||||||||||||||||||||||||
| 91 | String | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 1939 | __PACKAGE__->__register_type( $_ => __PACKAGE__ . '::' . $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 98 | # Constructor | ||||||||||||||||||||||||||||||||||||||||||
| 99 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 3602 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=25.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 3602 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 3602 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 3602 | ▶ | if ( $class eq __PACKAGE__ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 3402 | ▶ | if ( exists $args{'isa'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 3348 | ▶ | if ( ! defined $args{'isa'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | complain "Invalid argument (\"isa\")"; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 3348 | $class = $TYPE_REGISTRY{$args{'isa'}}; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 3348 | ▶ | if ( ! defined $class ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 15 | ▶ | if ( $args{'isa'} !~ REGEX_CLASS_NAME ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | complain "Invalid argument (\"isa\")"; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 15 | $class = $args{'isa'}; | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 3348 | delete $args{'isa'}; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | elsif ( exists $args{'type'} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 15 | ▶ | if ( ! defined $args{'type'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | complain "Invalid argument (\"type\")"; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 15 | $class = $TYPE_REGISTRY{$args{'type'}}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 15 | ▶ | if ( ! defined $class ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | complain "Unknown attribute type"; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 15 | delete $args{'type'}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 39 | $class = $TYPE_REGISTRY{'Scalar'}; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 3602 | ▶ | if ( ! GX::Meta::Util::load_module( $class ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | complain "Cannot load attribute metaclass \"$class\""; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 3602 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 3602 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 157 | 3602 | $self->__initialize( \%args ); | |||||||||||||||||||||||||||||||||||||||||
| 158 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 3602 | ▶ | complain $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 3583 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # Public methods | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 3472 | ▶ | sub accessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accessors: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 3472 | ▶ | return @{ $_[0]->{'accessors'} || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]{'accessors'} || (return)
MC/DC100%1/1
$_[0]{'accessors'} || (return)
$_[0]{'accessors'}
Truth table100%2/2
A
A= $_[0]{'accessors'}
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 4544 | ▶ | sub add_accessor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_accessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 4544 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 4544 | my $accessor = eval { | |||||||||||||||||||||||||||||||||||||||||
| 182 | 4544 | $self->create_accessor( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 4544 | ▶ | if ( ! $accessor ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 187 | message => "Cannot create accessor", | ||||||||||||||||||||||||||||||||||||||||||
| 188 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 189 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 4544 | push @{$self->{'accessors'}}, $accessor; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 4544 | return $accessor; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 34 | ▶ | sub add_preprocessor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_preprocessor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 34 | my $processor = shift; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 34 | ▶ | if ( ! $self->_validate_processor( $processor ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | complain "Bad attribute preprocessor"; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 34 | push @{$self->{'preprocessors'}}, $processor; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 34 | return $processor; | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 101 | ▶ | sub add_processor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_processor: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 101 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 101 | my $processor = shift; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 101 | ▶ | if ( ! $self->_validate_processor( $processor ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | complain "Bad attribute processor"; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 101 | push @{$self->{'processors'}}, $processor; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 101 | return $processor; | |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 1561 | ▶ | sub add_type_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_type_constraint: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 1561 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 1561 | my $constraint = shift; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 1561 | ▶ | if ( ! $self->_validate_constraint( $constraint ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | complain "Bad attribute type constraint"; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 1561 | push @{$self->{'type_constraints'}}, $constraint; | |||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1561 | return $constraint; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 788 | ▶ | sub add_value_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_value_constraint: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 788 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 788 | my $constraint = shift; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 788 | ▶ | if ( ! $self->_validate_constraint( $constraint ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | complain "Bad attribute value constraint"; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 788 | push @{$self->{'value_constraints'}}, $constraint; | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 788 | return $constraint; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 14079 | ▶ | sub class { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 14079 | return $_[0]->{'class'}; | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 725 | ▶ | sub default_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 725 | return $_[0]->{'default_value'}; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 4222 | ▶ | sub has_default_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_default_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 4222 | return exists $_[0]->{'default_value'}; | |||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 5339 | ▶ | sub has_initializer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_initializer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 5339 | return defined $_[0]->{'initializer'}; | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 1268 | ▶ | sub initializer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initializer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 1268 | return $_[0]->{'initializer'}; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 3356 | ▶ | sub install { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 3356 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 3356 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 293 | 3356 | $self->install_accessors; | |||||||||||||||||||||||||||||||||||||||||
| 294 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 3356 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | complain $@; | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 3356 | return; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 3438 | ▶ | sub install_accessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_accessors: called CC=4 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 3438 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 3438 | for my $accessor ( $self->accessors ) { | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 4544 | ▶ | if ( my $method = $self->class->method( $accessor->name ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | next if $method->code == $accessor->code; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | complain sprintf( "Cannot install accessor (method &%s already exists)", $method->full_name ); | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 4544 | $self->class->add_method( $accessor->name, $accessor->code ); | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 3438 | return; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 4564 | ▶ | sub is_private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_private: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 4564 | return $_[0]->{'access_specifier'} & ACCESS_PRIVATE; | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 4559 | ▶ | sub is_protected { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_protected: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 4559 | return $_[0]->{'access_specifier'} & ACCESS_PROTECTED; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 4 | ▶ | sub is_public { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_public: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 4 | return $_[0]->{'access_specifier'} & ACCESS_PUBLIC; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 3822 | ▶ | sub is_required { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_required: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 3822 | return $_[0]->{'options'}{'required'}; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 13306 | ▶ | sub is_static { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_static: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 13306 | return $_[0]->{'static'}; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 3784 | ▶ | sub is_sticky { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_sticky: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 3784 | return $_[0]->{'options'}{'sticky'}; | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 22497 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 22497 | return $_[0]->{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 4 | ▶ | sub preprocessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preprocessors: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | ▶ | return @{ $_[0]->{'preprocessors'} || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]{'preprocessors'} || (return)
MC/DC100%1/1
$_[0]{'preprocessors'} || (return)
$_[0]{'preprocessors'}
Truth table100%2/2
A
A= $_[0]{'preprocessors'}
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 4 | ▶ | sub processors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
processors: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | ▶ | return @{ $_[0]->{'processors'} || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]{'processors'} || (return)
MC/DC100%1/1
$_[0]{'processors'} || (return)
$_[0]{'processors'}
Truth table100%2/2
A
A= $_[0]{'processors'}
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 11844 | ▶ | sub quoted_slot_key { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quoted_slot_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 11844 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 11844 | my $slot_key = $self->slot_key; | |||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 11844 | $slot_key =~ s/'/\\'/g; | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 11844 | return "'$slot_key'"; | |||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 14322 | ▶ | sub slot_key { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slot_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 14322 | return $_[0]->{'slot_key'}; | |||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | complain "Abstract method"; | |||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 2 | ▶ | sub type_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type_constraints: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 2 | ▶ | return @{ $_[0]->{'type_constraints'} || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]{'type_constraints'} || (return)
MC/DC0%0/1
$_[0]{'type_constraints'} || (return)
$_[0]{'type_constraints'}
Truth table50%1/2
A
A= $_[0]{'type_constraints'}
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 10 | ▶ | sub value_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_constraints: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 10 | ▶ | return @{ $_[0]->{'value_constraints'} || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]{'value_constraints'} || (return)
MC/DC100%1/1
$_[0]{'value_constraints'} || (return)
$_[0]{'value_constraints'}
Truth table100%2/2
A
A= $_[0]{'value_constraints'}
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # Internal methods | ||||||||||||||||||||||||||||||||||||||||||
| 416 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub access_specifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
access_specifier: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | return $_[0]->{'access_specifier'}; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 303 | ▶ | sub assign_to_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_to_slot: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 303 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 303 | my $store = shift; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 303 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 303 | $store->{$self->slot_key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 303 | return; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 959 | ▶ | sub check_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_constraints: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 959 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 959 | my $exception; | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | { | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 959 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 959 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 447 | 959 | $self->check_type_constraints( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 448 | 766 | $self->check_value_constraints( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 449 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 959 | $exception = $@; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 959 | ▶ | if ( $exception ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 210 | ▶ | return if defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 191 | complain $exception; | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 749 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 959 | ▶ | sub check_type_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_type_constraints: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 959 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 959 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 959 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 959 | ▶ | my $constraints = $self->_get_type_constraints or return 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 517 | for my $constraint ( @$constraints ) { | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 517 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 475 | my $exception; | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | { | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 517 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 517 | $result = eval { | |||||||||||||||||||||||||||||||||||||||||
| 482 | 517 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 517 | ▶ | ref $constraint ? $constraint->( $constraint, $value ) : $context->$constraint( $value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 517 | $exception = $@; | |||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 517 | ▶ | if ( ! $result ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 193 | ▶ | return if defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 193 | ▶ | complain( $exception || "Invalid value for attribute \"" . $self->name . "\"" ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$exception || 'Invalid value for attribute "' . $self->name . '"'
MC/DC0%0/1
$exception || 'Invalid value for attribute "' . $self->name . '"'
$exception
Truth table50%1/2
A
A= $exception
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 324 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 766 | ▶ | sub check_value_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_value_constraints: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 766 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 766 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 766 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 766 | ▶ | my $constraints = $self->_get_value_constraints or return 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 32 | for my $constraint ( @$constraints ) { | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 36 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 512 | my $exception; | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | { | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 36 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 36 | $result = eval { | |||||||||||||||||||||||||||||||||||||||||
| 519 | 36 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||
| 520 | 36 | ▶ | ref $constraint ? $constraint->( $constraint, $value ) : $context->$constraint( $value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 36 | $exception = $@; | |||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 36 | ▶ | if ( ! $result ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 17 | ▶ | return if defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 17 | ▶ | complain( $exception || "Invalid value for attribute \"" . $self->name . "\"" ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$exception || 'Invalid value for attribute "' . $self->name . '"'
MC/DC100%1/1
$exception || 'Invalid value for attribute "' . $self->name . '"'
$exception
Truth table100%2/2
A
A= $exception
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 15 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 142 | ▶ | sub clear_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_slot: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 142 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 541 | 142 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 542 | 142 | my $store = shift; | |||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | 142 | return delete $store->{$self->slot_key}; | |||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | sub clear_class_data_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_class_data_slot: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my $class = $self->class; | |||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return $self->clear_slot( $class->name, $class->class_data ); | |||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | 142 | ▶ | sub clear_instance_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_instance_slot: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 142 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 142 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 142 | return $self->clear_slot( $object, $object ); | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | sub create_accessor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_accessor: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | throw "Abstract method"; | |||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 963 | ▶ | sub initialize_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_slot: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 963 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 963 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 963 | my $store = shift; | |||||||||||||||||||||||||||||||||||||||||
| 578 | 963 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 963 | ▶ | return if exists $store->{$self->slot_key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 811 | ▶ | if ( $data && exists $data->{$self->name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$data and exists $$data{$self->name}
MC/DC100%2/2
$data and exists $$data{$self->name}
$data
exists $$data{$self->name}
Truth table100%3/3
A and B
A= $dataB= exists $$data{$self->name}
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 631 | $self->set_value( $context, $store, $data->{$self->name} ); | |||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | } elsif ( $self->is_required ) { | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | throw "Missing argument (\"$self\")"; | |||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | } elsif ( $self->_get_options->{'initialize'} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | 100 | ▶ | if ( my $initializer = $self->initializer ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 50 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | { | ||||||||||||||||||||||||||||||||||||||||||
| 597 | 50 | local $_ = $context; | |||||||||||||||||||||||||||||||||||||||||
| 598 | 50 | ▶ | $value = ref $initializer ? $initializer->( $context ) : $context->$initializer; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 50 | $self->assign_to_slot( $store, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | elsif ( $self->has_default_value ) { | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 25 | $self->assign_to_slot( $store, $self->default_value ); | |||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 25 | $self->assign_to_slot( $store, $self->native_value ); | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 613 | 78 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 540 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 120 | ▶ | sub initialize_class_data_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_class_data_slot: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 120 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 623 | 120 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 120 | my $class = $self->class; | |||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 120 | return $self->initialize_slot( $class->name, $class->class_data, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 843 | ▶ | sub initialize_instance_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initialize_instance_slot: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | 843 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 843 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 635 | 843 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 843 | return $self->initialize_slot( $object, $object, $data ); | |||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 3641 | ▶ | sub inline_clear_instance_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_clear_instance_slot: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 3641 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 644 | 3641 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 3641 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 3641 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | 3641 | ▶ | $data->{'slot'} //= $data->{'invocant'} . '->{' . $self->quoted_slot_key . '}'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"slot"} //= $data->{"invocant"} . '->{' . $self->quoted_slot_key . '}'
MC/DC0%0/1
$data->{"slot"} //= $data->{"invocant"} . '->{' . $self->quoted_slot_key . '}'
$data->{"slot"}
Truth table50%1/2
A
A= $data->{"slot"}
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 3641 | $self->_inline_delete_slot( $data, $code, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 3641 | return; | |||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 3642 | ▶ | sub inline_initialize_instance_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_initialize_instance_slot: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | 3642 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 659 | 3642 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 3642 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 661 | 3642 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 3642 | ▶ | $data->{'slot'} //= $data->{'invocant'} . '->{' . $self->quoted_slot_key . '}'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"slot"} //= $data->{"invocant"} . '->{' . $self->quoted_slot_key . '}'
MC/DC0%0/1
$data->{"slot"} //= $data->{"invocant"} . '->{' . $self->quoted_slot_key . '}'
$data->{"slot"}
Truth table50%1/2
A
A= $data->{"slot"}
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 3642 | my $var_value = $data->{'args'} . '->{' . $self->name . '}'; | |||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | 3642 | push @$code, 'if ( ! exists ' . $data->{'slot'} . ' ) {'; | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 3642 | push @$code, 'if ( exists ' . $var_value . ' ) {'; | |||||||||||||||||||||||||||||||||||||||||
| 670 | 3642 | $self->_inline_set_value( $data, $code, $vars, $var_value ); | |||||||||||||||||||||||||||||||||||||||||
| 671 | 3642 | push @$code, '}'; | |||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 3642 | ▶ | if ( $self->is_required ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | 386 | push @$code, | |||||||||||||||||||||||||||||||||||||||||
| 676 | 'else {', | ||||||||||||||||||||||||||||||||||||||||||
| 677 | ' GX::Meta::Exception->complain( "Missing argument (\"' . $self->name . '\")" );', | ||||||||||||||||||||||||||||||||||||||||||
| 678 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | elsif ( $self->_get_options->{'initialize'} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 1321 | push @$code, 'else {'; | |||||||||||||||||||||||||||||||||||||||||
| 684 | 1321 | $self->_inline_initialize_slot( $data, $code, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 685 | 1321 | push @$code, '}'; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 3642 | push @$code, '}'; | |||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | 3642 | return; | |||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 17 | ▶ | sub native_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
native_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 17 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | return %{$_[0]->{'options'}}; | |||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 631 | ▶ | sub preprocess_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preprocess_value: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 631 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 710 | 631 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | 631 | ▶ | my $preprocessors = $self->_get_preprocessors or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | 10 | for my $processor ( @$preprocessors ) { | |||||||||||||||||||||||||||||||||||||||||
| 715 | 10 | ▶ | ref $processor ? $processor->( $processor, $_ ) : $context->$processor( $_ ) for $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 10 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 440 | ▶ | sub process_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_value: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 440 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 725 | 440 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | 440 | ▶ | my $processors = $self->_get_processors or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 9 | for my $processor ( @$processors ) { | |||||||||||||||||||||||||||||||||||||||||
| 730 | 9 | ▶ | ref $processor ? $processor->( $processor, $_ ) : $context->$processor( $_ ) for $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 548 | ▶ | sub set_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 548 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 740 | 548 | my $context = shift; | |||||||||||||||||||||||||||||||||||||||||
| 741 | 548 | my $store = shift; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 548 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | 548 | $self->preprocess_value( $context, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 745 | 548 | $self->check_constraints( $context, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 746 | 358 | $self->process_value( $context, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 747 | 358 | $self->assign_to_slot( $store, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | 358 | return; | |||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 755 | # Private methods | ||||||||||||||||||||||||||||||||||||||||||
| 756 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | sub _get_accessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_accessors: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | return $_[0]->{'accessors'}; | |||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | 10476 | ▶ | sub _get_options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | 10476 | return $_[0]->{'options'}; | |||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | 6121 | ▶ | sub _get_preprocessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_preprocessors: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | 6121 | return $_[0]->{'preprocessors'}; | |||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 5952 | ▶ | sub _get_processors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_processors: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | 5952 | return $_[0]->{'processors'}; | |||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 7652 | ▶ | sub _get_type_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_type_constraints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | 7652 | return $_[0]->{'type_constraints'}; | |||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 6945 | ▶ | sub _get_value_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_value_constraints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | 6945 | return $_[0]->{'value_constraints'}; | |||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||
| 794 | 4560 | ▶ | sub _inline_accessor_prologue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_accessor_prologue: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | 4560 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 797 | 4560 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 798 | 4560 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 799 | 4560 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 4560 | ▶ | $data->{'invocant'} //= '$_[0]'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$data->{"invocant"} //= "\$_[0]"
MC/DC100%1/1
$data->{"invocant"} //= "\$_[0]"
$data->{"invocant"}
Truth table100%2/2
A
A= $data->{"invocant"}
| |||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | 4560 | ▶ | if ( $self->is_private ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 5 | push @$code, | |||||||||||||||||||||||||||||||||||||||||
| 806 | 'if ( caller ne \'' . $self->class->name . '\' ) {', | ||||||||||||||||||||||||||||||||||||||||||
| 807 | ' my $method = ( caller( 0 ) )[3];', | ||||||||||||||||||||||||||||||||||||||||||
| 808 | ' GX::Meta::Exception->complain(', | ||||||||||||||||||||||||||||||||||||||||||
| 809 | ' "Private method " . ', | ||||||||||||||||||||||||||||||||||||||||||
| 810 | ' ( substr( $method, -8 ) ne \'__ANON__\' ? "&$method " : \'\' ) . ', | ||||||||||||||||||||||||||||||||||||||||||
| 811 | ' "called"', | ||||||||||||||||||||||||||||||||||||||||||
| 812 | ' );', | ||||||||||||||||||||||||||||||||||||||||||
| 813 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||
| 816 | elsif ( $self->is_protected ) { | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | 5 | push @$code, | |||||||||||||||||||||||||||||||||||||||||
| 819 | 'if ( ! caller->isa( \'' . $self->class->name . '\' ) ) {', | ||||||||||||||||||||||||||||||||||||||||||
| 820 | ' my $method = ( caller( 0 ) )[3];', | ||||||||||||||||||||||||||||||||||||||||||
| 821 | ' GX::Meta::Exception->complain(', | ||||||||||||||||||||||||||||||||||||||||||
| 822 | ' "Protected method " . ', | ||||||||||||||||||||||||||||||||||||||||||
| 823 | ' ( substr( $method, -8 ) ne \'__ANON__\' ? "&$method " : \'\' ) . ', | ||||||||||||||||||||||||||||||||||||||||||
| 824 | ' "called"', | ||||||||||||||||||||||||||||||||||||||||||
| 825 | ' );', | ||||||||||||||||||||||||||||||||||||||||||
| 826 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | 4560 | ▶ | if ( $self->is_static ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | 403 | ▶ | $data->{'class_data_identifier'} //= $self->class->class_data_identifier; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$data->{"class_data_identifier"} //= $self->class->class_data_identifier
MC/DC0%0/2
$data->{"class_data_identifier"} //= $self->class->class_data_identifier
$data->{"class_data_identifier"}
$self->class->class_data_identifier
Truth table33%1/3
A //= B
A= $data->{"class_data_identifier"}B= $self->class->class_data_identifier
| |||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | push @$code, | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 'my $CLASS_DATA = do {', | ||||||||||||||||||||||||||||||||||||||||||
| 836 | ' no strict \'refs\';', | ||||||||||||||||||||||||||||||||||||||||||
| 837 | ' \%{ ( ref ' . $data->{'invocant'} . ' || ' . | ||||||||||||||||||||||||||||||||||||||||||
| 838 | 403 | $data->{'invocant'} . ' ) . \'::' . $data->{'class_data_identifier'} . '\' };', | |||||||||||||||||||||||||||||||||||||||||
| 839 | '};'; | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | 403 | $data->{'slot'} = '$CLASS_DATA->{' . $self->quoted_slot_key . '}'; | |||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||
| 844 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 845 | 4157 | $data->{'slot'} = $data->{'invocant'} . '->{' . $self->quoted_slot_key . '}'; | |||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | 4560 | return; | |||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 10424 | ▶ | sub _inline_assign_to_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_assign_to_slot: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | 10424 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 855 | 10424 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 856 | 10424 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 857 | 10424 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 858 | 10424 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | 10424 | push @$code, $data->{'slot'} . ' = ' . $var . ';'; | |||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | 10424 | return; | |||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | 5064 | ▶ | sub _inline_check_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_check_constraints: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | 5064 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | 5064 | $self->_inline_check_type_constraints( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 871 | 5064 | $self->_inline_check_value_constraints( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | 5064 | return; | |||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 5064 | ▶ | sub _inline_check_type_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_check_type_constraints: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 5064 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 880 | 5064 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 881 | 5064 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 882 | 5064 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 883 | 5064 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | 5064 | ▶ | if ( $self->_get_type_constraints ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | 1629 | my $var_constraints = '$EVAL_VAR_' . keys %$vars; | |||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | 1629 | $vars->{$var_constraints} = $self->_get_type_constraints; | |||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | push @$code, | ||||||||||||||||||||||||||||||||||||||||||
| 892 | 'for my $constraint ( @' . $var_constraints . ' ) {', | ||||||||||||||||||||||||||||||||||||||||||
| 893 | ' eval { ', | ||||||||||||||||||||||||||||||||||||||||||
| 894 | ' local $_ = ' . $var . ';', | ||||||||||||||||||||||||||||||||||||||||||
| 895 | ' ref $constraint', | ||||||||||||||||||||||||||||||||||||||||||
| 896 | ' ? $constraint->( $constraint, ' . $var . ' )', | ||||||||||||||||||||||||||||||||||||||||||
| 897 | 1629 | ' : ' . $data->{'invocant'} . '->$constraint( ' . $var . ' );', | |||||||||||||||||||||||||||||||||||||||||
| 898 | ' } or GX::Meta::Exception->complain(', | ||||||||||||||||||||||||||||||||||||||||||
| 899 | ' $@ || "Invalid value for attribute \"' . $self->name . '\""', | ||||||||||||||||||||||||||||||||||||||||||
| 900 | ' );', | ||||||||||||||||||||||||||||||||||||||||||
| 901 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | 5064 | return; | |||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | 5272 | ▶ | sub _inline_check_value_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_check_value_constraints: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | 5272 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 912 | 5272 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 913 | 5272 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 914 | 5272 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 915 | 5272 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | 5272 | ▶ | if ( $self->_get_value_constraints ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | 817 | my $var_constraints = '$EVAL_VAR_' . keys %$vars; | |||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | 817 | $vars->{$var_constraints} = $self->_get_value_constraints; | |||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||
| 923 | push @$code, | ||||||||||||||||||||||||||||||||||||||||||
| 924 | 'for my $constraint ( @' . $var_constraints . ' ) {', | ||||||||||||||||||||||||||||||||||||||||||
| 925 | ' eval { ', | ||||||||||||||||||||||||||||||||||||||||||
| 926 | ' local $_ = ' . $var . ';', | ||||||||||||||||||||||||||||||||||||||||||
| 927 | ' ref $constraint', | ||||||||||||||||||||||||||||||||||||||||||
| 928 | ' ? $constraint->( $constraint, ' . $var . ' )', | ||||||||||||||||||||||||||||||||||||||||||
| 929 | 817 | ' : ' . $data->{'invocant'} . '->$constraint( ' . $var . ' );', | |||||||||||||||||||||||||||||||||||||||||
| 930 | ' } or GX::Meta::Exception->complain(', | ||||||||||||||||||||||||||||||||||||||||||
| 931 | ' $@ || "Invalid value for attribute \"' . $self->name . '\""', | ||||||||||||||||||||||||||||||||||||||||||
| 932 | ' );', | ||||||||||||||||||||||||||||||||||||||||||
| 933 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | 5272 | return; | |||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | 3728 | ▶ | sub _inline_delete_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_delete_slot: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | 3728 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 944 | 3728 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 945 | 3728 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 946 | 3728 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||
| 948 | 3728 | push @$code, 'delete ' . $data->{'slot'} . ';'; | |||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | 3728 | return; | |||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | 5338 | ▶ | sub _inline_initialize_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_initialize_slot: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 5338 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 5338 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 958 | 5338 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 959 | 5338 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 5338 | ▶ | if ( $self->has_initializer ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 962 | 1167 | $self->_inline_set_slot_to_initializer_value( $data, $code, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||
| 964 | elsif ( $self->has_default_value ) { | ||||||||||||||||||||||||||||||||||||||||||
| 965 | 545 | $self->_inline_set_slot_to_default_value( $data, $code, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 968 | 3626 | $self->_inline_set_slot_to_native_value( $data, $code, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||
| 971 | 5338 | return; | |||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | 4017 | ▶ | sub _inline_prepare_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_prepare_slot: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | 4017 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 978 | 4017 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 979 | 4017 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 980 | 4017 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||
| 982 | 4017 | push @$code, 'if ( ! exists ' . $data->{'slot'} . ' ) {'; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 4017 | $self->_inline_initialize_slot( $data, $code, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 984 | 4017 | push @$code, '}'; | |||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||
| 986 | 4017 | return; | |||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 1322 | ▶ | sub _inline_preprocess_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_preprocess_value: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | 1322 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 993 | 1322 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 994 | 1322 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 995 | 1322 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 996 | 1322 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | 1322 | ▶ | if ( $self->_get_preprocessors ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 52 | my $var_preprocessors = '$EVAL_VAR_' . keys %$vars; | |||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 52 | $vars->{$var_preprocessors} = $self->_get_preprocessors; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | push @$code, | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | 'for my $processor ( @' . $var_preprocessors . ' ) {', | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | ' ref( $processor )', | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | ' ? $processor->( $processor, $_ )', | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | 52 | ' : ' . $data->{'invocant'} . '->$processor( $_ )', | |||||||||||||||||||||||||||||||||||||||||
| 1009 | ' for ' . $var . ';', | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | 1322 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 1322 | ▶ | sub _inline_process_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_process_value: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 1322 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1021 | 1322 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | 1322 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1023 | 1322 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | 1322 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 1322 | ▶ | if ( $self->_get_processors ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 118 | my $var_processors = '$EVAL_VAR_' . keys %$vars; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 118 | $vars->{$var_processors} = $self->_get_processors; | |||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | push @$code, | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | 'for my $processor ( @' . $var_processors . ' ) {', | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | ' ref( $processor )', | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | ' ? $processor->( $processor, $_ )', | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | 118 | ' : ' . $data->{'invocant'} . '->$processor( $_ )', | |||||||||||||||||||||||||||||||||||||||||
| 1037 | ' for ' . $var . ';', | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | 1322 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||
| 1046 | 2448 | ▶ | sub _inline_return_slot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_return_slot: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | 2448 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1049 | 2448 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1050 | 2448 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1051 | 2448 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | 2448 | push @$code, 'return ' . $data->{'slot'} . ';'; | |||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 2448 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 405 | ▶ | sub _inline_set_slot_to_default_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_set_slot_to_default_value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||
| 1061 | 405 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | 405 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 405 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1064 | 405 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 405 | $self->_inline_set_slot_to_value( $data, $code, $vars, $self->default_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 405 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | 1167 | ▶ | sub _inline_set_slot_to_initializer_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_set_slot_to_initializer_value: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 1167 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 1167 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | 1167 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1077 | 1167 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||
| 1079 | 1167 | my $initializer = $self->initializer; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | 1167 | my $var_value; | |||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | 1167 | ▶ | if ( ref $initializer ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 528 | my $var_initializer = '$EVAL_VAR_' . keys %$vars; | |||||||||||||||||||||||||||||||||||||||||
| 1085 | 528 | $vars->{$var_initializer} = $initializer; | |||||||||||||||||||||||||||||||||||||||||
| 1086 | 528 | $var_value = $var_initializer . '->( ' . $data->{'invocant'} . ' )'; | |||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | 639 | $var_value = $data->{'invocant'} . '->' . $initializer; | |||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||
| 1092 | push @$code, | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | '{', | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | 1167 | 'local $_ = ' . $data->{'invocant'} . ';'; | |||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 1167 | $self->_inline_assign_to_slot( $data, $code, $vars, $var_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | 1167 | push @$code, | |||||||||||||||||||||||||||||||||||||||||
| 1099 | '}'; | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | 1167 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 1784 | ▶ | sub _inline_set_slot_to_native_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_set_slot_to_native_value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | 1784 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1108 | 1784 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1109 | 1784 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1110 | 1784 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | 1784 | $self->_inline_assign_to_slot( $data, $code, $vars, 'undef' ); | |||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||
| 1114 | 1784 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 216 | ▶ | sub _inline_set_slot_to_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_set_slot_to_value: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 216 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1121 | 216 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1122 | 216 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1123 | 216 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1124 | 216 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | 216 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1127 | 216 | my $var_value = '$EVAL_VAR_' . keys %$vars; | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 216 | $vars->{$var_value} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1129 | 216 | $self->_inline_assign_to_slot( $data, $code, $vars, $var_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | $self->_inline_assign_to_slot( $data, $code, $vars, 'undef' ); | |||||||||||||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||
| 1135 | 216 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | 3650 | ▶ | sub _inline_set_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inline_set_value: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | 3650 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1142 | 3650 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1143 | 3650 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1144 | 3650 | my $vars = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | 3650 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||
| 1147 | 3650 | ▶ | if ( $self->_get_preprocessors || $self->_get_processors ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_get_preprocessors or $self->_get_processors
MC/DC100%2/2
$self->_get_preprocessors or $self->_get_processors
$self->_get_preprocessors
$self->_get_processors
Truth table100%3/3
A or B
A= $self->_get_preprocessorsB= $self->_get_processors
| |||||||||||||||||||||||||||||||||||||||||||
| 1148 | 76 | push @$code, 'my $value = ' . $var . ';'; | |||||||||||||||||||||||||||||||||||||||||
| 1149 | 76 | $self->_inline_preprocess_value( $data, $code, $vars, '$value' ); | |||||||||||||||||||||||||||||||||||||||||
| 1150 | 76 | $self->_inline_check_constraints( $data, $code, $vars, '$value' ); | |||||||||||||||||||||||||||||||||||||||||
| 1151 | 76 | $self->_inline_process_value( $data, $code, $vars, '$value' ); | |||||||||||||||||||||||||||||||||||||||||
| 1152 | 76 | $self->_inline_assign_to_slot( $data, $code, $vars, '$value' ); | |||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | 3574 | $self->_inline_check_constraints( $data, $code, $vars, $var ); | |||||||||||||||||||||||||||||||||||||||||
| 1156 | 3574 | $self->_inline_assign_to_slot( $data, $code, $vars, $var ); | |||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||
| 1159 | 3650 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||
| 1163 | 2349 | ▶ | sub _validate_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_constraint: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||
| 1165 | 2349 | ▶ | return ref $_[1] eq 'CODE' || blessed $_[1] || $_[1] =~ REGEX_METHOD_NAME; | ||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
ref $_[1] eq 'CODE' || builtin::blessed($_[1]) || $_[1] =~ /^[a-zA-Z_]\w*$/
ref $_[1] eq "CODE" or builtin::blessed($_[1])
MC/DC0%0/3
ref $_[1] eq 'CODE' || builtin::blessed($_[1]) || $_[1] =~ /^[a-zA-Z_]\w*$/
ref $_[1] eq "CODE"
builtin::blessed($_[1])
$_[1] =~ /^[a-zA-Z_]\w*$/
Truth table75%3/4
A or B || C
A= ref $_[1] eq "CODE"B= builtin::blessed($_[1])C= $_[1] =~ /^[a-zA-Z_]\w*$/
| |||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||
| 1169 | 135 | ▶ | sub _validate_processor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_processor: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||
| 1171 | 135 | ▶ | return ref $_[1] eq 'CODE' || blessed $_[1] || $_[1] =~ REGEX_METHOD_NAME; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
ref $_[1] eq 'CODE' || builtin::blessed($_[1]) || $_[1] =~ /^[a-zA-Z_]\w*$/
ref $_[1] eq "CODE" or builtin::blessed($_[1])
MC/DC0%0/3
ref $_[1] eq 'CODE' || builtin::blessed($_[1]) || $_[1] =~ /^[a-zA-Z_]\w*$/
ref $_[1] eq "CODE"
builtin::blessed($_[1])
$_[1] =~ /^[a-zA-Z_]\w*$/
Truth table50%2/4
A or B || C
A= ref $_[1] eq "CODE"B= builtin::blessed($_[1])C= $_[1] =~ /^[a-zA-Z_]\w*$/
| |||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||
| 1176 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | # Object initialization | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||
| 1180 | 3602 | ▶ | sub __initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize: called CC=13 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | 3602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1183 | 3602 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 3602 | for ( qw( class name ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 7204 | ▶ | defined $args->{$_} or throw "Missing argument (\"$_\")"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 3602 | ▶ | if ( ! blessed $args->{'class'} || ! $args->{'class'}->isa( 'GX::Meta::Class' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($args->{"class"}) and $args->{"class"}->isa("GX::Meta::Class")
MC/DC0%0/2
builtin::blessed($args->{"class"}) and $args->{"class"}->isa("GX::Meta::Class")
builtin::blessed($args->{"class"})
$args->{"class"}->isa("GX::Meta::Class")
Truth table33%1/3
A and B
A= builtin::blessed($args->{"class"})B= $args->{"class"}->isa("GX::Meta::Class")
| |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | throw "Invalid argument (\"class\" must be a GX::Meta::Class object)"; | |||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 3602 | ▶ | if ( ! length $args->{'name'} || ref $args->{'name'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not length $args->{"name"} or ref $args->{"name"}
MC/DC0%0/2
not length $args->{"name"} or ref $args->{"name"}
not length $args->{"name"}
ref $args->{"name"}
Truth table33%1/3
not(A) or B
A= not length $args->{"name"}B= ref $args->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | throw "Invalid argument (\"name\" must be a non-empty string)"; | |||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||
| 1197 | 3602 | $self->{'class'} = delete $args->{'class'}; | |||||||||||||||||||||||||||||||||||||||||
| 1198 | 3602 | $self->{'name'} = delete $args->{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 1199 | 3602 | ▶ | $self->{'static'} = delete $args->{'static'} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1200 | 3602 | $self->{'options'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||
| 1202 | 3602 | ▶ | if ( exists $args->{'slot'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | ▶ | if ( ! defined $args->{'slot'} || ! length $args->{'slot'} || ref $args->{'slot'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not defined $args->{"slot"} && length $args->{"slot"} or ref $args->{"slot"}
defined $args->{'slot'} && length $args->{'slot'}
MC/DC0%0/3
not defined $args->{"slot"} && length $args->{"slot"} or ref $args->{"slot"}
defined $args->{'slot'}
length $args->{'slot'}
ref $args->{"slot"}
Truth table0%0/4
not(A && B) or C
A= defined $args->{'slot'}B= length $args->{'slot'}C= ref $args->{"slot"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | throw "Invalid argument (\"slot\" must be a non-empty string)"; | |||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | $self->{'slot_key'} = delete $args->{'slot'}; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | 3602 | $self->{'slot_key'} = $self->{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||
| 1215 | 3602 | weaken $self->{'class'}; | |||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 3602 | $self->__initialize_options( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1218 | 3602 | $self->__initialize_type_constraints( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1219 | 3602 | $self->__initialize_value_constraints( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1220 | 3602 | $self->__initialize_preprocessors( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1221 | 3602 | $self->__initialize_processors( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1222 | 3602 | $self->__initialize_default_value( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 3583 | $self->__initialize_initializer( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1224 | 3583 | $self->__initialize_access_specifier( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1225 | 3583 | $self->__initialize_accessors( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1226 | 3583 | $self->__initialize_other( $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||
| 1228 | 3583 | ▶ | if ( keys %$args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | throw sprintf( "Unknown argument (\"%s\")", ( sort keys %$args )[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 3583 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||
| 1236 | 3583 | ▶ | sub __initialize_access_specifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_access_specifier: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||
| 1238 | 3583 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1239 | 3583 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||
| 1241 | 3583 | ▶ | if ( $args->{'private'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1242 | 1 | $self->{'access_specifier'} = ACCESS_PRIVATE; | |||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | elsif ( $args->{'protected'} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1245 | 1 | $self->{'access_specifier'} = ACCESS_PROTECTED; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | 3581 | $self->{'access_specifier'} = ACCESS_PUBLIC; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||
| 1251 | 3583 | delete @$args{ qw( public protected private ) }; | |||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||
| 1253 | 3583 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 3583 | ▶ | sub __initialize_accessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_accessors: called CC=15 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 3583 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 3583 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||
| 1262 | 3583 | my @accessors; | |||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | 3583 | ▶ | if ( exists $args->{'accessor'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||||||||||
| 1266 | 1235 | ▶ | if ( defined $args->{'accessor'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||
| 1268 | 1165 | ▶ | if ( ref $args->{'accessor'} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1269 | 1163 | push @accessors, { name => $self->name, %{$args->{'accessor'}} }; | |||||||||||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | elsif ( $args->{'accessor'} =~ REGEX_METHOD_NAME ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | 2 | push @accessors, { name => $args->{'accessor'} }; | |||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | throw "Invalid accessor definition"; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||
| 1280 | 1235 | delete $args->{'accessor'}; | |||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||
| 1282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||
| 1284 | 3583 | ▶ | if ( exists $args->{'accessors'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1285 | |||||||||||||||||||||||||||||||||||||||||||
| 1286 | 1019 | ▶ | if ( defined $args->{'accessors'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||
| 1288 | 1019 | ▶ | if ( ref $args->{'accessors'} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||
| 1290 | 1007 | ▶ | while ( my ( $name, $options ) = each %{$args->{'accessors'}} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | 1751 | ▶ | if ( ref $options ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | throw "Invalid accessor definition"; | |||||||||||||||||||||||||||||||||||||||||
| 1294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||
| 1296 | 1751 | push @accessors, { %$options, name => $name }; | |||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | elsif ( ref $args->{'accessors'} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||
| 1303 | 12 | for ( @{$args->{'accessors'}} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||
| 1305 | 12 | ▶ | if ( ref $_ eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1306 | 8 | push @accessors, { name => $self->name, %$_ }; | |||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | elsif ( ! ref $_ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | 4 | push @accessors, { name => $_ }; | |||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | throw "Invalid accessor definition"; | |||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | throw "Invalid argument (\"accessors\" must be an array or a hash reference)"; | |||||||||||||||||||||||||||||||||||||||||
| 1320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||
| 1324 | 1019 | delete $args->{'accessors'}; | |||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||
| 1328 | 3583 | for ( @accessors ) { | |||||||||||||||||||||||||||||||||||||||||
| 1329 | 2928 | $self->add_accessor( %$_ ); | |||||||||||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||
| 1332 | 3583 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | 3393 | ▶ | sub __initialize_default_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_default_value: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||
| 1338 | 3393 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1339 | 3393 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||
| 1341 | 3393 | ▶ | if ( exists $args->{'default'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||
| 1343 | 252 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1344 | 252 | $self->check_constraints( $self->class->name, $args->{'default'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1345 | } or throw "Invalid default value"; | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||
| 1347 | 233 | $self->{'default_value'} = delete $args->{'default'}; | |||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||
| 1349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||
| 1351 | 3374 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||
| 1353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||
| 1355 | 3583 | ▶ | sub __initialize_initializer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_initializer: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||
| 1357 | 3583 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1358 | 3583 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | 3583 | ▶ | if ( exists $args->{'initializer'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||
| 1362 | 637 | ▶ | if ( defined $args->{'initializer'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 637 | ▶ | if ( ref $args->{'initializer'} ne 'CODE' && $args->{'initializer'} !~ REGEX_METHOD_NAME ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $args->{"initializer"} ne "CODE" and not $args->{"initializer"} =~ /^[a-zA-Z_]\w*$/
MC/DC0%0/2
ref $args->{"initializer"} ne "CODE" and not $args->{"initializer"} =~ /^[a-zA-Z_]\w*$/
ref $args->{"initializer"} ne "CODE"
not $args->{"initializer"} =~ /^[a-zA-Z_]\w*$/
Truth table66%2/3
A and not(B)
A= ref $args->{"initializer"} ne "CODE"B= not $args->{"initializer"} =~ /^[a-zA-Z_]\w*$/
| |||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | throw "Bad attribute initializer"; | |||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||
| 1368 | 637 | $self->{'initializer'} = $args->{'initializer'}; | |||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||
| 1370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||
| 1372 | 637 | delete $args->{'initializer'}; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||
| 1374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||
| 1376 | 3583 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||
| 1378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||
| 1380 | 3602 | ▶ | sub __initialize_options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_options: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||
| 1382 | 3602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | 3602 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||
| 1385 | 3602 | for ( qw( initialize required sticky ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 1386 | 10806 | ▶ | $self->_get_options->{$_} = 1 if delete $args->{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||
| 1389 | 3602 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||
| 1393 | 3461 | ▶ | sub __initialize_other { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_other: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | # Abstract method | ||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||
| 1399 | 3602 | ▶ | sub __initialize_processors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_processors: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||
| 1401 | 3602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1402 | 3602 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||
| 1404 | 3602 | ▶ | if ( exists $args->{'processor'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||
| 1406 | 101 | ▶ | if ( defined $args->{'processor'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1407 | 101 | $self->add_processor( $args->{'processor'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||
| 1410 | 101 | delete $args->{'processor'}; | |||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||
| 1412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||
| 1414 | 3602 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||
| 1416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||
| 1418 | 3602 | ▶ | sub __initialize_preprocessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_preprocessors: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||
| 1420 | 3602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1421 | 3602 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||
| 1423 | 3602 | ▶ | if ( exists $args->{'preprocessor'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||
| 1425 | 34 | ▶ | if ( defined $args->{'preprocessor'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1426 | 34 | $self->add_preprocessor( $args->{'preprocessor'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||
| 1429 | 34 | delete $args->{'preprocessor'}; | |||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||
| 1431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||
| 1433 | 3602 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||
| 1437 | 3602 | ▶ | sub __initialize_type_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_type_constraints: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||
| 1439 | 3602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1440 | 3602 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||
| 1442 | 3602 | ▶ | if ( $self->TYPE_CONSTRAINT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1443 | 1561 | $self->add_type_constraint( $self->TYPE_CONSTRAINT ); | |||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||
| 1446 | 3602 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||
| 1448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||
| 1450 | 3602 | ▶ | sub __initialize_value_constraints { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__initialize_value_constraints: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||
| 1452 | 3602 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1453 | 3602 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||
| 1455 | 3602 | my @constraints; | |||||||||||||||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||||||||||||||||
| 1457 | 3602 | ▶ | if ( exists $args->{'constraint'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||
| 1459 | 779 | ▶ | if ( defined $args->{'constraint'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1460 | 779 | push @constraints, $args->{'constraint'}; | |||||||||||||||||||||||||||||||||||||||||
| 1461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||
| 1463 | 779 | delete $args->{'constraint'}; | |||||||||||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||
| 1467 | 3602 | ▶ | if ( exists $args->{'constraints'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||
| 1469 | 4 | ▶ | if ( ref $args->{'constraints'} ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | throw "Invalid argument (\"constraints\" must be an array reference)"; | |||||||||||||||||||||||||||||||||||||||||
| 1471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||
| 1473 | 4 | push @constraints, @{$args->{'constraints'}}; | |||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||
| 1475 | 4 | delete $args->{'constraints'}; | |||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||
| 1477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||
| 1479 | 3602 | for ( @constraints ) { | |||||||||||||||||||||||||||||||||||||||||
| 1480 | 788 | $self->add_value_constraint( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||
| 1483 | 3602 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||
| 1485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||
| 1488 | 277 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||
| 1490 | __END__ | ||||||||||||||||||||||||||||||||||||||||||