| 1 | package JE::Object::Proxy; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | our $VERSION = '0.066'; | |||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; no warnings 'utf8'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # ~~~ delegate overloaded methods? | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use JE::Code 'add_line_number'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Scalar::Util 1.09 qw'refaddr'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | require JE::Object; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | our @ISA = 'JE::Object'; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | JE::Object::Proxy - JS wrapper for Perl objects | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | $proxy = new JE::Object::Proxy $JE_object, $some_Perl_object; | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 62 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 62 | my($class, $global, $obj) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 62 | my $class_info = $$$global{classes}{ref $obj}; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | my $self = ($class eq __PACKAGE__ # allow subclassing | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | && ($$class_info{hash} || $$class_info{array}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ? __PACKAGE__."::Array" : $class) | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ->JE::Object::new($global, | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 62 | ▶ | { prototype => $$class_info{prototype} }); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$class eq __PACKAGE__ and $class_info->{"hash"} || $class_info->{"array"}
$class_info->{"hash"} or $class_info->{"array"}
MC/DC66%2/3
$class eq __PACKAGE__ and $class_info->{"hash"} || $class_info->{"array"}
$class eq __PACKAGE__
$class_info->{"hash"}
$class_info->{"array"}
Truth table75%3/4
A and B or C
A= $class eq __PACKAGE__B= $class_info->{"hash"}C= $class_info->{"array"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 62 | @$$self{qw/class_info value/} = ($class_info, $obj); | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 62 | ▶ | while(my($name,$args) = each %{$$class_info{props}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 85 | $self->prop({ name => $name, @$args }); | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 62 | $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 15 | ▶ | sub class { $${$_[0]}{class_info}{name} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 141 | ▶ | sub value { $${$_[0]}{value} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 34 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 34 | refaddr $${$_[0]}{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 29 | ▶ | sub to_primitive { # ~~~ This code should probably be moved to | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_primitive: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # &JE::bind_class for the sake of efficiency. | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 29 | my($self, $hint) = (shift, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 29 | my $guts = $$self; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 29 | my $value = $$guts{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 29 | my $class_info = $$guts{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 29 | ▶ | if(exists $$class_info{to_primitive}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 11 | my $tp = $$class_info{to_primitive}; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 11 | ▶ | if(defined $tp) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ref $tp eq 'CODE' and | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | return $$guts{global}->upgrade( | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 7 | ▶ | &$tp($value, @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ($tp, my $type) = JE::_split_meth($tp); | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | return defined $type | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ? $$guts{global}->_cast($value->$tp(@_),$type) | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | : $$guts{global}->upgrade($value->$tp(@_)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | die add_line_number | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | "The object ($$class_info{name}) cannot " | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | . "be converted to a primitive"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 18 | ▶ | if(overload::Method($value,'""') || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
overload::Method($value, "\"\"") or overload::Method($value, "0+") or overload::Method($value, "bool")
overload::Method($value, "\"\"") or overload::Method($value, "0+")
MC/DC33%1/3
overload::Method($value, "\"\"") or overload::Method($value, "0+") or overload::Method($value, "bool")
overload::Method($value, "\"\"")
overload::Method($value, "0+")
overload::Method($value, "bool")
Truth table50%2/4
A or B or C
A= overload::Method($value, "\"\"")B= overload::Method($value, "0+")C= overload::Method($value, "bool")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | overload::Method($value,'0+') || | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | overload::Method($value,'bool')){ | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | return $$guts{global}->upgrade("$value"); | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 15 | return SUPER::to_primitive $self @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 20 | ▶ | sub to_string { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 20 | my($self, $hint) = (shift, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 20 | my $guts = $$self; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 20 | my $value = $$guts{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 20 | my $class_info = $$guts{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 20 | ▶ | if(exists $$class_info{to_string}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | my $tp = $$class_info{to_string}; | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | ▶ | if(defined $tp) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ref $tp eq 'CODE' and | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | return $$guts{global}->upgrade( | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | ▶ | &$tp($value, @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | )->to_string; | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ($tp, my $type) = JE::_split_meth $tp; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | return ( defined $type | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ? $$guts{global}->upgrade($value->$tp(@_)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | : $$guts{global}->_cast($value->$tp(@_),$type) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | )->to_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | die add_line_number | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | "The object ($$class_info{name}) cannot " | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | . "be converted to a string"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 15 | return SUPER::to_string $self @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | ▶ | sub to_number { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_number: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 10 | my($self, $hint) = (shift, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 10 | my $guts = $$self; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 10 | my $value = $$guts{value}; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 10 | my $class_info = $$guts{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 10 | ▶ | if(exists $$class_info{to_number}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | my $tp = $$class_info{to_number}; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 5 | ▶ | if(defined $tp) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ref $tp eq 'CODE' and | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | return $$guts{global}->upgrade( | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | &$tp($value, @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | )->to_number; | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ($tp, my $type) = JE::_split_meth $tp; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | return ( defined $type | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ? $$guts{global}->upgrade($value->$tp(@_)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | : $$guts{global}->_cast($value->$tp(@_),$type) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | )->to_number | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | die add_line_number | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | "The object ($$class_info{name}) cannot " | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | . "be converted to a number"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | return SUPER::to_number $self @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | package JE::Object::Proxy::Array; # so this extra stuff doesn't slow down | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | our $VERSION = '0.066'; # 'normal' usage | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | our @ISA = 'JE::Object::Proxy'; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | require JE::Number; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 30 | ▶ | sub prop { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prop: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 30 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 30 | my $wrappee = $self->value; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 30 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 30 | my $class_info = $$$self{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 30 | ▶ | if ($$class_info{array}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 24 | ▶ | if($name eq 'length') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 9 | ▶ | @_ ? ($#$wrappee = $_[0]-1, return shift) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | : return new JE::Number | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $self->global, scalar @$wrappee | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 15 | ▶ | if($name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295
MC/DC50%1/2
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295
$name =~ /^(?:0|[1-9]\d*)\z/
$name < 4294967295
Truth table66%2/3
A and B
A= $name =~ /^(?:0|[1-9]\d*)\z/B= $name < 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | @_ ? $$class_info{array}{store}( | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | $wrappee,$name,$_[0]) && return shift | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 13 | ▶ | : do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$class_info->{"array"}{"store"}->($wrappee, $name, $_[0]) and return shift()
MC/DC100%1/1
$class_info->{"array"}{"store"}->($wrappee, $name, $_[0]) and return shift()
$class_info->{"array"}{"store"}->($wrappee, $name, $_[0])
Truth table100%2/2
A
A= $class_info->{"array"}{"store"}->($wrappee, $name, $_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | my $ret = | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | $$class_info{array}{fetch}( | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | $wrappee,$name); | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 11 | ▶ | defined $ret and return $ret; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 13 | ▶ | if ($$class_info{hash}and !exists $$class_info{props}{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$class_info->{"hash"} and not exists $class_info->{"props"}{$name}
MC/DC50%1/2
$class_info->{"hash"} and not exists $class_info->{"props"}{$name}
$class_info->{"hash"}
not exists $class_info->{"props"}{$name}
Truth table66%2/3
A and not(B)
A= $class_info->{"hash"}B= not exists $class_info->{"props"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | ▶ | if(@_){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | $$class_info{hash}{store}->( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | $wrappee,$name,$_[0] | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ) and return shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | my $ret = $$class_info{hash}{fetch} | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 8 | ($wrappee,$name); | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 8 | ▶ | defined $ret and return $ret; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 7 | SUPER::prop $self $name, @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 32 | ▶ | sub keys { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 32 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | 32 | my $wrappee = $self->value; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | 32 | my $class_info = $$$self{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 32 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 32 | ▶ | if ($$class_info{array}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 16 | @keys = grep(exists $wrappee->[$_], 0..$#$wrappee); | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 32 | ▶ | if($$class_info{hash}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 20 | push @keys, keys %$wrappee; | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 32 | push @keys, SUPER::keys $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 32 | my @new_keys; my %seen; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 32 | ▶ | $seen{$_}++ or push @new_keys, $_ for @keys; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 32 | @new_keys; | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=9 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | my $wrappee = $self->value; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | my($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | my $class_info = $$$self{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | ▶ | if ($$class_info{array}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | if ($name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295 and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295 and exists $wrappee->[$name]
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295
MC/DC0%0/3
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295 and exists $wrappee->[$name]
$name =~ /^(?:0|[1-9]\d*)\z/
$name < 4294967295
exists $wrappee->[$name]
Truth table25%1/4
A and B and C
A= $name =~ /^(?:0|[1-9]\d*)\z/B= $name < 4294967295C= exists $wrappee->[$name]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | exists $wrappee->[$name]) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | delete $wrappee->[$name]; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | return !$self->exists($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | elsif ($name eq 'length') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return !1 | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if($$class_info{hash} && !exists $$class_info{props}{$name} and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$class_info->{"hash"} and not exists $class_info->{"props"}{$name} and exists $wrappee->{$name}
$class_info->{"hash"} and not exists $class_info->{"props"}{$name}
MC/DC0%0/3
$class_info->{"hash"} and not exists $class_info->{"props"}{$name} and exists $wrappee->{$name}
$class_info->{"hash"}
not exists $class_info->{"props"}{$name}
exists $wrappee->{$name}
Truth table0%0/4
A and not(B) and C
A= $class_info->{"hash"}B= not exists $class_info->{"props"}{$name}C= exists $wrappee->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | exists $wrappee->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | delete $wrappee->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return !exists $wrappee->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | SUPER::delete $self @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | ▶ | sub exists { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=8 SCAR=22.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 4 | my $wrappee = $self->value; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | my($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | my $class_info = $$$self{class_info}; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | if ($$class_info{array}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | ▶ | if ($name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295
MC/DC0%0/2
$name =~ /^(?:0|[1-9]\d*)\z/ and $name < 4294967295
$name =~ /^(?:0|[1-9]\d*)\z/
$name < 4294967295
Truth table33%1/3
A and B
A= $name =~ /^(?:0|[1-9]\d*)\z/B= $name < 4294967295
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | ▶ | return 1 if exists $wrappee->[$name]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # If it doesn’t exists, try hash keys below. | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | elsif ($name eq 'length') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return 1 | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | ▶ | if($$class_info{hash}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | ▶ | return 1 if exists $wrappee->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | SUPER::exists $self @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||