| 1 | package Object::InsideOut; { | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | my $GBL = {}; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | sub generate_CUMULATIVE :Sub(Private) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_CUMULATIVE: called CC=34 SCAR=48.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | { | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ($GBL) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my $g_cu = $$GBL{'sub'}{'cumu'}; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | my $cumu_td = $$g_cu{'new'}{'td'} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$g_cu->{'new'}{'td'} || []
MC/DC0%0/1
$g_cu->{'new'}{'td'} || []
$g_cu->{'new'}{'td'}
Truth table50%1/2
A
A= $g_cu->{'new'}{'td'}
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | my $cumu_bu = $$g_cu{'new'}{'bu'} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$g_cu->{'new'}{'bu'} || []
MC/DC0%0/1
$g_cu->{'new'}{'bu'} || []
$g_cu->{'new'}{'bu'}
Truth table50%1/2
A
A= $g_cu->{'new'}{'bu'}
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | delete($$g_cu{'new'}); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | if (! exists($$g_cu{'td'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | $$GBL{'sub'}{'cumu'} = { | |||||||||||||||||||||||||||||||||||||||||
| 18 | td => {}, # 'Top down' | ||||||||||||||||||||||||||||||||||||||||||
| 19 | bu => {}, # 'Bottom up' | ||||||||||||||||||||||||||||||||||||||||||
| 20 | restrict => {}, # :Restricted | ||||||||||||||||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | $g_cu = $$GBL{'sub'}{'cumu'}; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my $cu_td = $$g_cu{'td'}; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | my $cu_bu = $$g_cu{'bu'}; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $cu_restr = $$g_cu{'restrict'}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # Get names for :CUMULATIVE methods | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my (%cum_loc); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | while (my $info = shift(@{$cumu_td})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | $$info{'name'} ||= sub_name($$info{'code'}, ':CUMULATIVE', $$info{'loc'}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$info->{"name"} ||= sub_name($info->{"code"}, ":CUMULATIVE", $info->{"loc"})
MC/DC0%0/2
$info->{"name"} ||= sub_name($info->{"code"}, ":CUMULATIVE", $info->{"loc"})
$info->{"name"}
sub_name($info->{"code"}, ":CUMULATIVE", $info->{"loc"})
Truth table33%1/3
A ||= B
A= $info->{"name"}B= sub_name($info->{"code"}, ":CUMULATIVE", $info->{"loc"})
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my $package = $$info{'pkg'}; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | my $name = $$info{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | $cum_loc{$name}{$package} = $$info{'loc'}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | $$cu_td{$name}{$package} = $$info{'wrap'}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | if (exists($$info{'exempt'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | push(@{$$cu_restr{$package}{$name}}, | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sort grep {$_} split(/[,'\s]+/, $$info{'exempt'} || '')); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$info->{'exempt'} || ''
MC/DC0%0/1
$info->{'exempt'} || ''
$info->{'exempt'}
Truth table50%1/2
A
A= $info->{'exempt'}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # Get names for :CUMULATIVE(BOTTOM UP) methods | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | while (my $info = shift(@{$cumu_bu})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | $$info{'name'} ||= sub_name($$info{'code'}, ':CUMULATIVE(BOTTOM UP)', $$info{'loc'}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$info->{"name"} ||= sub_name($info->{"code"}, ":CUMULATIVE(BOTTOM UP)", $info->{"loc"})
MC/DC0%0/2
$info->{"name"} ||= sub_name($info->{"code"}, ":CUMULATIVE(BOTTOM UP)", $info->{"loc"})
$info->{"name"}
sub_name($info->{"code"}, ":CUMULATIVE(BOTTOM UP)", $info->{"loc"})
Truth table0%0/3
A ||= B
A= $info->{"name"}B= sub_name($info->{"code"}, ":CUMULATIVE(BOTTOM UP)", $info->{"loc"})
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $package = $$info{'pkg'}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $name = $$info{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # Check for conflicting definitions of 'name' | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($$cu_td{$name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | foreach my $other_package (keys(%{$$cu_td{$name}})) { | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($other_package->isa($package) || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$other_package->isa($package) or $package->isa($other_package)
MC/DC0%0/2
$other_package->isa($package) or $package->isa($other_package)
$other_package->isa($package)
$package->isa($other_package)
Truth table0%0/3
A or B
A= $other_package->isa($package)B= $package->isa($other_package)
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | $package->isa($other_package)) | ||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my ($pkg, $file, $line) = @{$cum_loc{$name}{$other_package}}; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ($pkg2, $file2, $line2) = @{$$info{'loc'}}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | OIO::Attribute->die( | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | 'location' => $$info{'loc'}, | |||||||||||||||||||||||||||||||||||||||||
| 60 | 'message' => "Conflicting definitions for cumulative method '$name'", | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 'Info' => "Declared as :CUMULATIVE in class '$pkg' (file '$file', line $line), but declared as :CUMULATIVE(BOTTOM UP) in class '$pkg2' (file '$file2' line $line2)"); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $$cu_bu{$name}{$package} = $$info{'wrap'}; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (exists($$info{'exempt'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | push(@{$$cu_restr{$package}{$name}}, | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sort grep {$_} split(/[,'\s]+/, $$info{'exempt'} || '')); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'exempt'} || ''
MC/DC0%0/1
$info->{'exempt'} || ''
$info->{'exempt'}
Truth table0%0/2
A
A= $info->{'exempt'}
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # Propagate restrictions | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my $reapply = 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my $trees = $$GBL{'tree'}{'td'}; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | while ($reapply) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $reapply = 0; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | foreach my $pkg (keys(%{$cu_restr})) { | |||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | foreach my $class (keys(%{$trees})) { | |||||||||||||||||||||||||||||||||||||||||
| 80 | 12 | ▶ | next if (! grep { $_ eq $pkg } @{$$trees{$class}}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 6 | foreach my $p (@{$$trees{$class}}) { | |||||||||||||||||||||||||||||||||||||||||
| 82 | 14 | foreach my $n (keys(%{$$cu_restr{$pkg}})) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 14 | ▶ | if (exists($$cu_restr{$p}{$n})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 14 | ▶ | next if ($$cu_restr{$p}{$n} == $$cu_restr{$pkg}{$n}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | my $equal = (@{$$cu_restr{$p}{$n}} == @{$$cu_restr{$pkg}{$n}}); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | if ($equal) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | for (1..@{$$cu_restr{$p}{$n}}) { | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($$cu_restr{$pkg}{$n}[$_-1] ne $$cu_restr{$p}{$n}[$_-1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $equal = 0; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | if (! $equal) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my %restr = map { $_ => 1 } @{$$cu_restr{$p}{$n}}, @{$$cu_restr{$pkg}{$n}}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $$cu_restr{$pkg}{$n} = [ sort(keys(%restr)) ]; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $reapply = 1; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $reapply = 1; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | $$cu_restr{$p}{$n} = $$cu_restr{$pkg}{$n}; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | # Implement :CUMULATIVE methods | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | foreach my $name (keys(%{$cu_td})) { | |||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | my $code = create_CUMULATIVE($name, $trees, $$cu_td{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | foreach my $package (keys(%{$$cu_td{$name}})) { | |||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | *{$package.'::'.$name} = $code; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | add_meta($package, $name, 'kind', 'cumulative'); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | if (exists($$cu_restr{$package}{$name})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | add_meta($package, $name, 'restrict', 1); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # Implement :CUMULATIVE(BOTTOM UP) methods | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | foreach my $name (keys(%{$cu_bu})) { | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $code = create_CUMULATIVE($name, $$GBL{'tree'}{'bu'}, $$cu_bu{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | foreach my $package (keys(%{$$cu_bu{$name}})) { | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | *{$package.'::'.$name} = $code; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | add_meta($package, $name, 'kind', 'cumulative (bottom up)'); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if (exists($$cu_restr{$package}{$name})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | add_meta($package, $name, 'restrict', 1); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # Returns a closure back to initialize() that is used to setup CUMULATIVE | ||||||||||||||||||||||||||||||||||||||||||
| 139 | # and CUMULATIVE(BOTTOM UP) methods for a particular method name. | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | sub create_CUMULATIVE :Sub(Private) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_CUMULATIVE: called CC=1 SCAR=0.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # $name - method name | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # $tree - either $GBL{'tree'}{'td'} or $GBL{'tree'}{'bu'} | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # $code_refs - hash ref by package of code refs for a particular method name | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | my ($name, $tree, $code_refs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=31.5
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | my $class = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | ▶ | if (! $class) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | OIO::Method->die('message' => "Must call '$name' as a method"); | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | my $list_context = wantarray; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | my (@results, @classes); | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | # Caller must be in class hierarchy | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | my $restr = $$GBL{'sub'}{'cumu'}{'restrict'}; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | ▶ | if ($restr && exists($$restr{$class}{$name})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$restr and exists $restr->{$class}{$name}
MC/DC50%1/2
$restr and exists $restr->{$class}{$name}
$restr
exists $restr->{$class}{$name}
Truth table66%2/3
A and B
A= $restrB= exists $restr->{$class}{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | my $caller = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (! ((grep { $_ eq $caller } @{$$restr{$class}{$name}}) || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
grep {$_ eq $caller;} @{$$restr{$class}{$name};} or $caller->isa($class) or $class->isa($caller)
grep {$_ eq $caller;} @{$$restr{$class}{$name};} or $caller->isa($class)
MC/DC0%0/3
grep {$_ eq $caller;} @{$$restr{$class}{$name};} or $caller->isa($class) or $class->isa($caller)
grep {$_ eq $caller;} @{$$restr{$class}{$name};}
$caller->isa($class)
$class->isa($caller)
Truth table25%1/4
A or B or C
A= grep {$_ eq $caller;} @{$$restr{$class}{$name};}B= $caller->isa($class)C= $class->isa($caller)
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | $caller->isa($class) || | ||||||||||||||||||||||||||||||||||||||||||
| 161 | $class->isa($caller))) | ||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | OIO::Method->die('message' => "Can't call restricted method '$class->$name' from class '$caller'"); | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # Accumulate results | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | foreach my $pkg (@{$$tree{$class}}) { | |||||||||||||||||||||||||||||||||||||||||
| 169 | 9 | ▶ | if (my $code = $$code_refs{$pkg}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 9 | local $SIG{'__DIE__'} = 'OIO::trap'; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 9 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 9 | ▶ | if (defined($list_context)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 9 | push(@classes, $pkg); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | ▶ | if ($list_context) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | # List context | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | push(@results, $code->(@args)); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # Scalar context | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 9 | push(@results, scalar($code->(@args))); | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # void context | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $code->(@args); | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # Return results | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | ▶ | if (defined($list_context)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | ▶ | if ($list_context) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | # List context | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return (@results); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | # Scalar context - returns object | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | return (Object::InsideOut::Results->new('VALUES' => \@results, | |||||||||||||||||||||||||||||||||||||||||
| 196 | 'CLASSES' => \@classes)); | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | } # End of package's lexical scope | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | package Object::InsideOut::Results; { | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | our $VERSION = '4.05'; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | ▶ | use Object::InsideOut 4.05; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | use Object::InsideOut::Metadata 4.05; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my @VALUES :Field :Arg(VALUES); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | my @CLASSES :Field :Arg(CLASSES); | |||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my @HASHES :Field; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub as_string :Stringify | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return (join('', grep(defined, @{$VALUES[${$_[0]}]}))); | |||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub count :Numerify | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return (scalar(@{$VALUES[${$_[0]}]})); | |||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub have_any :Boolify | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
have_any: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return (@{$VALUES[${$_[0]}]} > 0); | |||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | sub values :Arrayify | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
values: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | return ($VALUES[${$_[0]}]); | |||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | sub as_hash :Hashify | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | ▶ | if (! defined($HASHES[$$self])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | my %hash; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | @hash{@{$CLASSES[$$self]}} = @{$VALUES[$$self]}; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | $self->set(\@HASHES, \%hash); | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | return ($HASHES[$$self]); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | # Our metadata | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | add_meta('Object::InsideOut::Results', { | |||||||||||||||||||||||||||||||||||||||||
| 254 | 'new' => {'hidden' => 1}, | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 'create_field' => {'hidden' => 1}, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 'add_class' => {'hidden' => 1}, | ||||||||||||||||||||||||||||||||||||||||||
| 257 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | } # End of package's lexical scope | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # Ensure correct versioning | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | ▶ | ($Object::InsideOut::VERSION eq '4.05') | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Object::InsideOut::VERSION eq '4.05' || die("Version mismatch\n")
MC/DC0%0/1
$Object::InsideOut::VERSION eq '4.05' || die("Version mismatch\n")
$Object::InsideOut::VERSION eq '4.05'
Truth table50%1/2
A
A= $Object::InsideOut::VERSION eq '4.05'
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | or die("Version mismatch\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | # EOF | ||||||||||||||||||||||||||||||||||||||||||