| 1 | 117 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 117 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 117 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package Mite::Trait::HasAttributes; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 117 | ▶ | use Mite::Miteception -role, -all; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 117 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 117 | our $VERSION = '0.013000'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 117 | requires qw( _function_for_croak ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | has attributes => | ||||||||||||||||||||||||||||||||||||||||||
| 14 | is => ro, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => HashRef[MiteAttribute], | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 156 | ▶ | default => sub { {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 287 | ▶ | sub all_attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_attributes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 287 | shift->attributes; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 117 | signature_for add_attributes => ( | |||||||||||||||||||||||||||||||||||||||||
| 23 | pos => [ slurpy ArrayRef[MiteAttribute] ], | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 123 | ▶ | sub add_attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_attributes: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 123 | my ( $self, $attributes ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 123 | for my $attribute (@$attributes) { | |||||||||||||||||||||||||||||||||||||||||
| 30 | croak '%s already has an attribute called %s', $self->name, $attribute->_q_name | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 128 | ▶ | if $self->attributes->{ $attribute->name }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 128 | $self->attributes->{ $attribute->name } = $attribute; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 123 | return; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 118 | ▶ | sub add_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_attribute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 118 | shift->add_attributes( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub extend_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extend_attribute: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | my ($self, %attr_args) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $name = delete $attr_args{name}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my $attr = $self->attributes->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | croak <<'ERROR', $name, $self->name unless $attr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | Could not find an attribute by the name of '%s' to extend in %s | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ERROR | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | if ( ref $attr_args{default} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $attr_args{_class_for_default} = $self; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | $self->attributes->{$name} = $attr->clone(%attr_args); | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 119 | ▶ | before inject_mite_functions => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 119 | my ( $self, $file, $arg ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 119 | ▶ | my $requested = sub { $arg->{$_[0]} ? 1 : $arg->{'!'.$_[0]} ? 0 : $arg->{'-all'} ? 1 : $_[1]; }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 119 | my $defaults = ! $arg->{'!-defaults'}; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 119 | my $shim = $self->shim_name; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 119 | my $package = $self->name; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 119 | my $kind = $self->kind; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 106 | ▶ | my $ctxt = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 106 | my $level = shift; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 106 | my @info = caller( $level ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 106 | 'toolkit' => 'Mite', | |||||||||||||||||||||||||||||||||||||||||
| 75 | 'package' => $info[0], | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 'file' => $info[1], | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 'line' => $info[2], | ||||||||||||||||||||||||||||||||||||||||||
| 78 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 119 | }; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 117 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 106 | ▶ | my $has = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 106 | my $names = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 106 | ▶ | if ( @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | my $default = shift; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | unshift @_, ( 'CODE' eq ref( $default ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | ? ( is => lazy, builder => $default ) | ||||||||||||||||||||||||||||||||||||||||||
| 90 | : ( is => ro, default => $default ); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 106 | my %spec = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 106 | ▶ | $spec{definition_context} ||= $ctxt->( 1, file => "$file", type => $kind, context => 'has declaration' ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$spec{"definition_context"} ||= &$ctxt(1, "file", "$file", "type", $kind, "context", "has declaration")
MC/DC0%0/2
$spec{"definition_context"} ||= &$ctxt(1, "file", "$file", "type", $kind, "context", "has declaration")
$spec{"definition_context"}
&$ctxt(1, "file", "$file", "type", $kind, "context", "has declaration")
Truth table66%2/3
A ||= B
A= $spec{"definition_context"}B= &$ctxt(1, "file", "$file", "type", $kind, "context", "has declaration")
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 106 | ▶ | for my $name ( ref($names) ? @$names : $names ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 109 | ▶ | if( my $is_extension = $name =~ s{^\+}{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 4 | $self->extend_attribute( | |||||||||||||||||||||||||||||||||||||||||
| 98 | class => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 99 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | %spec | ||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 105 | require Mite::Attribute; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 105 | my $attribute = Mite::Attribute->new( | |||||||||||||||||||||||||||||||||||||||||
| 106 | class => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | %spec | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 105 | $self->add_attribute($attribute); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 109 | my $code; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 'CODE' eq ref( $code = $spec{builder} ) | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 109 | ▶ | and *{"$package\::_build_$name"} = $code; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 'CODE' eq ref( $code = $spec{trigger} ) | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | and *{"$package\::_trigger_$name"} = $code; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 'CODE' eq ref( $code = $spec{clone} ) | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 109 | ▶ | and *{"$package\::_clone_$name"} = $code; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 106 | return; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 119 | }; | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 119 | ▶ | if ( $requested->( 'has', $defaults ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 118 | *{ $package .'::has' } = $has; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 118 | $self->imported_keywords->{has} = 'sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }'; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 119 | ▶ | if ( $requested->( 'param', false ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 11 | ▶ | *{"$package\::param"} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | my ( $names, %spec ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ▶ | $spec{is} = ro unless exists $spec{is}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | $spec{required} = true unless exists $spec{required}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | $spec{definition_context} ||= $ctxt->( 1, file => "$file", type => $kind, context => 'param declaration' ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$spec{"definition_context"} ||= &$ctxt(1, "file", "$file", "type", $kind, "context", "param declaration")
MC/DC0%0/2
$spec{"definition_context"} ||= &$ctxt(1, "file", "$file", "type", $kind, "context", "param declaration")
$spec{"definition_context"}
&$ctxt(1, "file", "$file", "type", $kind, "context", "param declaration")
Truth table33%1/3
A ||= B
A= $spec{"definition_context"}B= &$ctxt(1, "file", "$file", "type", $kind, "context", "param declaration")
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | $has->( $names, %spec ); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 11 | $self->imported_keywords->{param} = 'sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }'; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 119 | ▶ | if ( $requested->( 'field', false ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 11 | ▶ | *{"$package\::field"} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=26.6
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my ( $names, %spec ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | $spec{is} ||= ( $spec{builder} || exists $spec{default} ) ? lazy : rwp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$spec{"is"} ||= $spec{"builder"} || exists $spec{"default"} ? "lazy" : "rwp"
$spec{"builder"} or exists $spec{"default"}
MC/DC0%0/3
$spec{"is"} ||= $spec{"builder"} || exists $spec{"default"} ? "lazy" : "rwp"
$spec{"is"}
$spec{"builder"}
exists $spec{"default"}
Truth table0%0/4
A ||= B or C
A= $spec{"is"}B= $spec{"builder"}C= exists $spec{"default"}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | $spec{init_arg} = undef unless exists $spec{init_arg}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | if ( defined $spec{init_arg} and $spec{init_arg} !~ /^_/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $spec{"init_arg"} and not $spec{"init_arg"} =~ /^_/
MC/DC0%0/2
defined $spec{"init_arg"} and not $spec{"init_arg"} =~ /^_/
defined $spec{"init_arg"}
not $spec{"init_arg"} =~ /^_/
Truth table33%1/3
A and not(B)
A= defined $spec{"init_arg"}B= not $spec{"init_arg"} =~ /^_/
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | croak "A defined 'field.init_arg' must begin with an underscore: %s ", $spec{init_arg}; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | $spec{definition_context} ||= $ctxt->( 1, file => "$file", type => $kind, context => 'field declaration' ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$spec{"definition_context"} ||= &$ctxt(1, "file", "$file", "type", $kind, "context", "field declaration")
MC/DC0%0/2
$spec{"definition_context"} ||= &$ctxt(1, "file", "$file", "type", $kind, "context", "field declaration")
$spec{"definition_context"}
&$ctxt(1, "file", "$file", "type", $kind, "context", "field declaration")
Truth table33%1/3
A ||= B
A= $spec{"definition_context"}B= &$ctxt(1, "file", "$file", "type", $kind, "context", "field declaration")
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | $has->( $names, %spec ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 11 | $self->imported_keywords->{field} = 'sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }'; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 117 | }; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 106 | ▶ | sub _compile_init_attributes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compile_init_attributes: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 106 | my ( $self, $classvar, $selfvar, $argvar, $metavar ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 106 | my @code; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 106 | my $depth = 1; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 106 | my %depth = map { $_ => $depth++; } $self->linear_isa; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 106 | my @attributes = do { | |||||||||||||||||||||||||||||||||||||||||
| 168 | 117 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | sort { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 52 | ▶ | eval { $depth{$b->class->name} <=> $depth{$a->class->name} } | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
eval {
do {
$depth{$b->class->name} <=> $depth{$a->class->name}
}
} || $a->_order <=> $b->_order
MC/DC0%0/2
eval {
do {
$depth{$b->class->name} <=> $depth{$a->class->name}
}
} || $a->_order <=> $b->_order
eval {
do {
$depth{$b->class->name} <=> $depth{$a->class->name}
}
}
$a->_order <=> $b->_order
Truth table66%2/3
A || B
A= eval {
do {
$depth{$b->class->name} <=> $depth{$a->class->name}
}
}B= $a->_order <=> $b->_order
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | or $a->_order <=> $b->_order; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 106 | values %{ $self->all_attributes }; | |||||||||||||||||||||||||||||||||||||||||
| 174 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 106 | for my $attr ( @attributes ) { | |||||||||||||||||||||||||||||||||||||||||
| 176 | 118 | my $guard = $attr->locally_set_compiling_class( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 118 | my @lines = grep !!$_, $attr->compile_init( $selfvar, $argvar ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 118 | ▶ | if ( @lines ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 115 | ▶ | push @code, sprintf "# Attribute %s%s", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | $attr->name, $attr->type ? sprintf( ' (type: %s)', $attr->type->display_name ) : ''; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 115 | push @code, sprintf '# %s', | |||||||||||||||||||||||||||||||||||||||||
| 182 | $attr->definition_context_to_pretty_string; | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 115 | push @code, @lines; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 115 | push @code, ''; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 106 | ▶ | return join "\n", map { /\S/ ? " $_" : '' } @code; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub _needs_accessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_needs_accessors: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return false; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 128 | ▶ | around _compile_pragmas => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 128 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 128 | my $code = $self->$next( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 199 | return $code unless | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 131 | ▶ | grep { defined($_) and $_ eq true } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && $_ eq !0
MC/DC100%2/2
defined $_ && $_ eq !0
defined $_
$_ eq !0
Truth table100%3/3
A && B
A= defined $_B= $_ eq !0
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 131 | map { $_->cloner_method } | |||||||||||||||||||||||||||||||||||||||||
| 202 | 128 | ▶ | values %{ $self->all_attributes }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | return "use Storable ();\n" . $code; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 117 | }; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 128 | ▶ | around compilation_stages => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 128 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 128 | my @stages = $self->$next( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 128 | ▶ | push @stages, qw( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | _compile_attribute_accessors | ||||||||||||||||||||||||||||||||||||||||||
| 212 | ) if $self->_needs_accessors; | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 128 | return @stages; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 117 | }; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 119 | ▶ | sub _compile_attribute_accessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compile_attribute_accessors: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 119 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 119 | my $attributes = $self->attributes; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 119 | ▶ | keys %$attributes or return ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 80 | my $code = 'my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };' . "\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 80 | for my $name ( sort keys %$attributes ) { | |||||||||||||||||||||||||||||||||||||||||
| 224 | 109 | my $guard = $attributes->{$name}->locally_set_compiling_class( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 225 | 109 | $code .= $attributes->{$name}->compile( xs_condition => '$__XS' ); | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 80 | return $code; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | around _compile_mop_attributes => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $code = $self->$next( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | my @attrs = | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | sort { $a->_order <=> $b->_order } | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | values %{ $self->attributes }; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ( @attrs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $code .= " my \%ATTR;\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | for my $attr ( @attrs ) { | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $guard = $attr->locally_set_compiling_class( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $attr_code = $attr->_compile_mop; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $attr_code =~ s/^/ /gm; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $code .= $attr_code . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return $code; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 117 | }; | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 117 | 1; | |||||||||||||||||||||||||||||||||||||||||