blib/lib/Class/Struct/FIELDS.pm

filter: Statementstmt 97.2% 463 / 476 Branchbran 51.1% 87 / 170 Conditioncond 12.4% 15 / 121 MC/DCmcdc 10.0% 5 / 50 Subroutinesub 100% 130 / 130 Podpod 50.0% 1 / 2 totaltotal 73.8% 701 / 949 CC 223 SCAR 24.5
CC
223
Cov
74%
struct
89.0
ary
10.4
ary
10.4
CRAP 11.6
↑ Summary
1 package Class::Struct::FIELDS;
2  
3 14 require 5.005_64;
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # AutoLoader would be nice, but it mucks up with evaling the package
10 # definitions in 'struct'. Hmmm.
11  
12 5 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # Items to export into callers namespace by default. Note: do not
16 # export names by default without a very good reason. Use EXPORT_OK
17 # instead. Do not simply export all your public
18 # functions/methods/constants.
19  
20 # This allows declaration use Class::Struct::FIELDS ':all'; If you do
21 # not need this, moving things directly into @EXPORT or @EXPORT_OK
22 # will save memory.
23  
24 16 our %EXPORT_TAGS = (all => [qw(struct)]);
25 16 our @EXPORT_OK = (@{$EXPORT_TAGS{all}});
26 4 our @EXPORT = qw(struct);
27  
28 # I'd like to say "our $VERSION = v1.1;", but MakeMaker--even in perl
29 # 5.6.0--, doesn't grok that and has trouble creating a Makefile.
30 4 our $VERSION = '1.1';
31 5 my $rcs = qq$Id: FIELDS.pm,v 1.1.1.1 2001/04/08 23:28:31 binkley Exp $;
32  
33 # my %SEEN_PKGS = ();
34  
35 sub struct;
36  
37 sub _array ($$;$);
38 sub _arraytie ($$);
39 sub _arrayref ($$;$);
40 sub _code ($$;$);
41 sub _coderef ($$;$);
42 sub _baseclass_warning ($$);
43 sub _get_isa ($$);
44 sub _hash ($$;$);
45 sub _hashtie ($$);
46 sub _hashref ($$;$);
47 sub _mini_prolog ($$);
48 sub _new_new_warning ($);
49 sub _object ($$$$;$);
50 sub _array_object ($$$$;$);
51 sub _hash_object ($$$$;$);
52 sub _objectref ($$$$;$);
53 sub _override_warning ($$);
54 sub _postlog ( );
55 sub _prolog ($$$);
56 sub _regexp ($$;$);
57 sub _regexpref ($$;$);
58 sub _scalar ($$;$);
59 sub _scalarref ($$;$);
60 sub _stringify ( );
61 sub _usage_error;
62  
63 # Preloaded methods go here.
64  
65 39 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
66 39 my ($class) = shift;
67  
68 # We consume all of @_, so don't pass it along.
69 39 $class->export_to_level (1);
70  
71 # Consume our own frame so that &struct thinks our caller is the
72 # real caller.
73 39 ▶ goto &struct if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 28 11 39
74 }
75  
76 29 ▶sub struct {
Subroutine struct: called CC=46 SCAR=44.9
Pod documented
77 29 my ($class, $isa, $decls);
78 29 my $caller = caller;
79  
80 29 ▶ if (my $ref = ref $_[0]) { # guess class from caller
Branch: 1 branch
BranchTrueFalseTotal
if (my $ref = ref $_[0]) { } 4 25 29
81 4 ▶ if ($ref eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'ARRAY') { } 3 1 4
elsif ($ref eq 'HASH') { } 1 0 1
82 3 ▶ if ($ref = ref $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = ref $_[1]) { } 1 2 3
83 1 ▶ if ($ref eq 'HASH') { # called as "{LIST}, [LIST]"
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq 'HASH') { } 1 0 1
84 1 ($class, $isa, $decls) = ($caller, shift, shift);
85 1 ▶ _usage_error if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
86 }
87  
88 else {
89 0 _usage_error;
90 }
91 }
92  
93 else { # called as "[LIST], LIST"
94 2 ($class, $isa, $decls) = ($caller, shift, {@_});
95 }
96 }
97  
98 elsif ($ref eq 'HASH') { # called as "{LIST}"
99 1 ($class, $isa, $decls) = ($caller, [], shift);
100 1 ▶ _usage_error if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
101 }
102  
103 else {
104 0 _usage_error;
105 }
106 }
107  
108 else { # caller listed
109 25 ▶ if ($ref = ref $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = ref $_[1]) { } 19 6 25
110 19 ▶ if ($ref eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'ARRAY') { } 11 8 19
elsif ($ref eq 'HASH') { } 8 0 8
111 11 ▶ if ($ref = ref $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = ref $_[2]) { } 2 9 11
112 2 ▶ if ($ref eq 'HASH') { # called as "[LIST], {LIST}"
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq 'HASH') { } 2 0 2
113 2 ($class, $isa, $decls) = (shift, shift, shift);
114 2 ▶ _usage_error if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
115 }
116  
117 else {
118 0 _usage_error;
119 }
120 }
121  
122 else { # called as "[LIST], LIST"
123 9 ($class, $isa, $decls) = (shift, shift, {@_});
124 }
125 }
126  
127 elsif ($ref eq 'HASH') { # called as "CLASS, {LIST}"
128 8 ($class, $isa, $decls) = (shift, [], shift);
129 8 ▶ _usage_error if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 8 8
130 }
131  
132 else {
133 0 _usage_error;
134 }
135 }
136  
137 else {
138 6 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 6 0 6
139 6 ▶ if (@_ % 2) { # called as "LIST" with CLASS
Branch: 1 branch
BranchTrueFalseTotal
if (@_ % 2) { } 6 0 6
140 6 ($class, $isa, $decls) = (shift, [], {@_});
141 }
142  
143 else { # called as "LIST" without CLASS
144 0 ($class, $isa, $decls) = ($caller, [], {});
145 }
146 }
147  
148 else { # called as plain "&struct"
149 0 ($class, $isa, $decls) = ($caller, [], {});
150 }
151 }
152 }
153  
154 29 ▶ eval _mini_prolog ($class, $isa); # baseclass warnings
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
155 29 my $eval = _prolog ($class, $isa, $decls);
156  
157 # Automagic overload support.
158 $eval .= _stringify
159 5 ▶ if (do { no strict qw(refs); exists &{"$class\::as_string"} });
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if do { no strict 'refs'; exists &{"${class}::as_string";} } 1 28 29
160  
161 29 ▶ while (my ($k, $v) = each %$decls) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$decls) 29 29 58
162 29 my $hidden = undef;
163  
164 # Don't make subroutines for "private" keys; you should access
165 # them directly: $self->{_blah_blah}; See fields.
166 29 ▶ next if $k =~ /^_/o;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^_/o 0 29 29
167  
168 # Check for three cases:
169 #
170 # 1. Caller has already defined an accessor.
171 #
172 # 2. Base class has a same-named method.
173 #
174 # 3. Take care to use exists instead of defined so that caller can
175 # use sub declarations before actually defining the access
176 # method.
177  
178 5 ▶ if (do { no strict qw(refs); exists &{"$class\::$k"} }) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (do { no strict 'refs'; exists &{"${class}::$k";} }) 3 26 29
179 3 _override_warning ($class, $k);
180 3 $hidden = 1;
181 # next;
182 }
183  
184 # This doesn't work? XXX
185 29 ▶ _baseclass_warning ($class, $k) if UNIVERSAL::can ($class, $k);
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::can($class, $k) 3 26 29
186  
187 29 ▶ if ($v eq '$') {
Branch: 18 branches
BranchTrueFalseTotal
if ($v eq '$') { } 11 18 29
elsif ($v eq '\\$' or $v eq '*$') { } 1 17 18
elsif ($v eq '@') { } 1 16 17
elsif ($v eq '+@') { } 1 15 16
elsif ($v eq '\\@' or $v eq '*@') { } 1 14 15
elsif ($v eq '%') { } 2 12 14
elsif ($v eq '+%') { } 1 11 12
elsif ($v eq '\\%' or $v eq '*%') { } 1 10 11
elsif ($v eq '&') { } 1 9 10
elsif ($v eq '\\&' or $v eq '*&') { } 1 8 9
elsif ($v eq '/') { } 1 7 8
elsif ($v eq '\\/' or $v eq '*/') { } 1 6 7
elsif ($v =~ s/^\+@(\w+(?:::\w+)*)$/$1/o) { } 1 5 6
elsif ($v =~ s/^@(\w+(?:::\w+)*)$/$1/o) { } 0 5 5
elsif ($v =~ s/^\+%(\w+(?:::\w+)*)$/$1/o) { } 1 4 5
elsif ($v =~ s/^%(\w+(?:::\w+)*)$/$1/o) { } 0 4 4
elsif ($v =~ s/^[\\*](\w+(?:::\w+)*)$/$1/o) { } 1 3 4
elsif ($v =~ /^\w+(?:::\w+)*$/o) { } 3 0 3
188 11 $eval .= _scalar ($class, $k, $hidden);
189 }
190  
191 ▶ elsif ($v eq '\$' or $v eq '*$') {
Condition66%2/3
$v eq "\\\$" or $v eq "*\$"
l!l&&r!l&&!r
1017
MC/DC50%1/2
$v eq "\\\$" or $v eq "*\$"
$v eq "\\\$" $v eq "*\$"
Truth table66%2/3
A or B
A= $v eq "\\\$"B= $v eq "*\$"
ABresult
1X1
011
000
192 1 $eval .= _scalarref ($class, $k, $hidden);
193 }
194  
195 elsif ($v eq '@') {
196 1 $eval .= _array ($class, $k, $hidden);
197 }
198  
199 # EXPERIMENTAL XXX
200 elsif ($v eq '+@') {
201 1 $eval .= _arraytie ($class, $k);
202 1 $eval .= _array ($class, $k, $hidden);
203 }
204  
205 ▶ elsif ($v eq '\@' or $v eq '*@') {
Condition66%2/3
$v eq "\\\@" or $v eq "*\@"
l!l&&r!l&&!r
1014
MC/DC50%1/2
$v eq "\\\@" or $v eq "*\@"
$v eq "\\\@" $v eq "*\@"
Truth table66%2/3
A or B
A= $v eq "\\\@"B= $v eq "*\@"
ABresult
1X1
011
000
206 1 $eval .= _arrayref ($class, $k, $hidden);
207 }
208  
209 elsif ($v eq '%') {
210 2 $eval .= _hash ($class, $k, $hidden);
211 }
212  
213 # EXPERIMENTAL XXX
214 elsif ($v eq '+%') {
215 1 $eval .= _hashtie ($class, $k);
216 1 $eval .= _hash ($class, $k, $hidden);
217 }
218  
219 ▶ elsif ($v eq '\%' or $v eq '*%') {
Condition66%2/3
$v eq "\\%" or $v eq "*%"
l!l&&r!l&&!r
1010
MC/DC50%1/2
$v eq "\\%" or $v eq "*%"
$v eq "\\%" $v eq "*%"
Truth table66%2/3
A or B
A= $v eq "\\%"B= $v eq "*%"
ABresult
1X1
011
000
220 1 $eval .= _hashref ($class, $k, $hidden);
221 }
222  
223 elsif ($v eq '&') {
224 1 $eval .= _code ($class, $k, $hidden);
225 }
226  
227 ▶ elsif ($v eq '\&' or $v eq '*&') {
Condition66%2/3
$v eq "\\&" or $v eq "*&"
l!l&&r!l&&!r
108
MC/DC50%1/2
$v eq "\\&" or $v eq "*&"
$v eq "\\&" $v eq "*&"
Truth table66%2/3
A or B
A= $v eq "\\&"B= $v eq "*&"
ABresult
1X1
011
000
228 1 $eval .= _coderef ($class, $k, $hidden);
229 }
230  
231 elsif ($v eq '/') {
232 1 $eval .= _regexp ($class, $k, $hidden);
233 }
234  
235 ▶ elsif ($v eq '\/' or $v eq '*/') {
Condition66%2/3
$v eq "\\/" or $v eq "*/"
l!l&&r!l&&!r
106
MC/DC50%1/2
$v eq "\\/" or $v eq "*/"
$v eq "\\/" $v eq "*/"
Truth table66%2/3
A or B
A= $v eq "\\/"B= $v eq "*/"
ABresult
1X1
011
000
236 1 $eval .= _regexpref ($class, $k, $hidden);
237 }
238  
239 # EXPERIMENTAL XXX
240 elsif ($v =~ s/^\+@(\w+(?:::\w+)*)$/$1/o) {
241 # $SEEN_PKGS{$class}->{$k} = $v;
242 1 $eval .= _arraytie ($class, $k);
243 1 $eval .= _array_object ($class, $caller, $k, $v, $hidden);
244 }
245  
246 # EXPERIMENTAL XXX
247 elsif ($v =~ s/^@(\w+(?:::\w+)*)$/$1/o) {
248 # $SEEN_PKGS{$class}->{$k} = $v;
249 0 $eval .= _array_object ($class, $caller, $k, $v, $hidden);
250 }
251  
252 # EXPERIMENTAL XXX
253 elsif ($v =~ s/^\+%(\w+(?:::\w+)*)$/$1/o) {
254 # $SEEN_PKGS{$class}->{$k} = $v;
255 1 $eval .= _hashtie ($class, $k);
256 1 $eval .= _hash_object ($class, $caller, $k, $v, $hidden);
257 }
258  
259 # EXPERIMENTAL XXX
260 elsif ($v =~ s/^%(\w+(?:::\w+)*)$/$1/o) {
261 # $SEEN_PKGS{$class}->{$k} = $v;
262 0 $eval .= _hash_object ($class, $caller, $k, $v, $hidden);
263 }
264  
265 elsif ($v =~ s/^[\\*](\w+(?:::\w+)*)$/$1/o) {
266 # $SEEN_PKGS{$class}->{$k} = $v;
267 1 $eval .= _objectref ($class, $caller, $k, $v, $hidden);
268 }
269  
270 elsif ($v =~ /^\w+(?:::\w+)*$/o) {
271 # $SEEN_PKGS{$class}->{$k} = $v;
272 3 $eval .= _object ($class, $caller, $k, $v, $hidden);
273 }
274  
275 else {
276 0 _usage_error;
277 }
278 }
279  
280 29 $eval .= _postlog;
281  
282 29 ▶ eval $eval;
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Branch: 39 branches
BranchTrueFalseTotal
if (() = each %init) 3 2 5
if $c = "Akron"->can($k) 0 2 2
if (() = each %init) 0 1 1
if $c = "Baltimore"->can($k) 0 3 3
if (() = each %init) 0 1 1
if $c = "Cleveland"->can($k) 0 1 1
if (() = each %init) 0 1 1
if $c = "Dayton"->can($k) 0 1 1
if (() = each %init) 0 1 1
if $c = "Anise"->can($k) 1 2 3
if (() = each %init) 0 3 3
if $c = "Banana"->can($k) 0 2 2
if (() = each %init) 0 2 2
if $c = "Cranberry"->can($k) 0 2 2
if (() = each %init) 0 1 1
if $c = "Dillweed"->can($k) 0 1 1
if (() = each %init) 0 0 0
if $c = "Eggplant"->can($k) 0 0 0
if (() = each %init) 0 0 0
if $c = "Fruit"->can($k) 0 0 0
if (() = each %init) 0 0 0
if $c = "Ginger"->can($k) 0 0 0
if (() = each %init) 0 0 0
if $c = "Horseradish"->can($k) 0 0 0
if (() = each %init) 0 0 0
if $c = "Ice"->can($k) 0 0 0
if (() = each %init) 0 0 0
if $c = "Jello"->can($k) 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
@_ == 2 ? : 0 0 0
if (@_ == 3) { } 0 0 0
elsif (@_ == 2) { } 0 0 0
if (my $ref = ref $_[1]) { } 0 0 0
Condition3%4/103
ref $this || $this || __PACKAGE__
l!l
050
ref $this or $this
l!l&&r!l&&!r
220
ref $this || $this || __PACKAGE__
l!l
030
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
ref $this || $this || __PACKAGE__
l!l
000
ref $this or $this
l!l&&r!l&&!r
000
$self->{"cc"} ||= []
l!l
000
$self->{"dd"} ||= []
l!l
00
$self->{"ee"} ||= {}
l!l
000
$self->{"ff"} ||= {}
l!l
00
defined $_[1] and ref $_[1] ne "CODE"
!ll&&!rl&&r
000
defined $_[1] and ref $_[1] ne "CODE"
!ll&&!rl&&r
000
defined $_[1] and ref $_[1] ne "Regexp"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/2
ref $this || $this || __PACKAGE__
ref $this $this
MC/DC0%0/1
$self->{"cc"} ||= []
$self->{"cc"}
MC/DC0%0/1
$self->{"dd"} ||= []
$self->{"dd"}
MC/DC0%0/1
$self->{"ee"} ||= {}
$self->{"ee"}
MC/DC0%0/1
$self->{"ff"} ||= {}
$self->{"ff"}
MC/DC0%0/2
defined $_[1] and ref $_[1] ne "CODE"
defined $_[1] ref $_[1] ne "CODE"
MC/DC0%0/2
defined $_[1] and ref $_[1] ne "CODE"
defined $_[1] ref $_[1] ne "CODE"
MC/DC0%0/2
defined $_[1] and ref $_[1] ne "Regexp"
defined $_[1] ref $_[1] ne "Regexp"
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= ref $thisB= $this
ABresult
1X1
011
000
Truth table0%0/2
A
A= $self->{"cc"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"dd"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"ee"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"ff"}
Aresult
11
00
Truth table0%0/3
A and B
A= defined $_[1]B= ref $_[1] ne "CODE"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[1]B= ref $_[1] ne "CODE"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[1]B= ref $_[1] ne "Regexp"
ABresult
0X0
100
111
283 29 ▶ carp $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 29 29
284  
285 29 $class;
286 }
287  
288 # Work around a broken UNIVERSAL::isa in 5.6.0:
289 5 ▶if ($^V eq v5.6.0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^V eq v5.6.0) 5 11 16
if ($^V eq v5.6.0) 0 0 0
290 5 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
291  
292 # sub UNIVERSAL::isa {
293 2 ▶ sub isa {
Subroutine isa: called CC=3 SCAR=13.5
Pod undocumented
294 2 my ($class, $super) = @_;
295 2 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
200
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
296 2 ▶ return 1 if $class eq $super; # trivial case
Branch: 1 branch
BranchTrueFalseTotal
if $class eq $super 0 0 0
297  
298 2 ▶ my $f = sub {
Subroutine __ANON__: called CC=3 SCAR=14.2
299 5 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
300  
301 2 my ($class, $super, $g) = @_;
302 2 my @supers = @{"$class\::ISA"};
303  
304 0 foreach my $s (@supers) {
305 0 ▶ return 1 if $s eq $super;
Branch: 1 branch
BranchTrueFalseTotal
if $s eq $super 0 0 0
306 # Does Perl optimizer understand tail recursion?
307 0 return $g->($s, $super, $g);
308 }
309  
310 0 return '';
311 2 };
312  
313 2 return $f->($class, $super, $f);
314 }
315  
316 3 *UNIVERSAL::isa = \&isa;
317 }
318  
319 58 ▶sub _get_isa ($$) {
Subroutine _get_isa: called CC=1 SCAR=0.0
320 58 my ($class, $isa) = @_;
321 58 my @isa;
322  
323 {
324 5 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
325  
326 58 @isa = (@{"$class\::ISA"}, @$isa); # preserve the existing @ISA
327 }
328  
329 58 return @isa;
330 }
331  
332 29 ▶sub _mini_prolog ($$) {
Subroutine _mini_prolog: called CC=1 SCAR=0.0
333 29 my ($class, $isa) = @_;
334 29 my @isa = _get_isa ($class, $isa);
335  
336 29 <<EOC;
337 {
338 package $class;
339 use base qw(@isa);
340 }
341 EOC
342 }
343  
344 29 ▶sub _prolog ($$$) {
Subroutine _prolog: called CC=1 SCAR=0.0
345 29 my ($class, $isa, $decls) = @_;
346 29 my @isa = _get_isa ($class, $isa);
347 29 my @fields = keys %$decls;
348  
349 29 <<EOC;
350 {
351 package $class;
352  
353 require 5.005_64;
354 use strict;
355 use warnings;
356  
357 use Carp;
358  
359 use base qw(@isa);
360 use fields qw(@fields);
361  
362 # Allow user to provide their own new as long as they return
363 # \$self->_init (\@_);
364 unless (do { no strict qw(refs); exists &{$class\::new} }) {
365 *{$class\::new} = sub {
366 my \$this = shift;
367 my \$class = ref \$this || \$this || __PACKAGE__;
368 my $class \$self = fields::new (\$class);
369  
370 \$self->_init (\@_);
371 };
372 }
373  
374 else {
375 Class::Struct::FIELDS::_new_new_warning ('$class');
376 }
377  
378 # Two-step initialization so that user-defined init's will have the
379 # parents' fields all ready to go. This relies on cooperation from
380 # sub new.
381 sub _init {
382 my $class \$self = shift;
383 my \%init = \@_;
384  
385 # Simple solution for now. Some problems:
386 #
387 # 1. Diamond inheritance can call _init multiple times. I don't
388 # know if it's a good thing, or a bad thing, but fields forbids
389 # multiple inheritance.
390 #
391 # 2. Member initialization gets called every time through.
392  
393 for (qw(@isa)) {
394 eval { bless \$self, \$_; \$self = \$self->_init (\@_) };
395 }
396  
397 bless \$self, qw($class);
398  
399 # Init our fields to be like Class::Struct. According to the
400 # documentation for fields, the call to fields::new should have
401 # set up our parents as well, so that we can init their fields
402 # too. Make sure to call the accessors so that user-defined ones
403 # are invoked (instead of assigning directly to the pseudo-hash.)
404 {
405 no strict qw(refs);
406  
407 # Only invoke valid keys; pass the rest through unmolested.
408 my \$c;
409  
410 while (my (\$k, \$v) = each \%init) {
411 \$self->\$c (\$v) if \$c = $class\::->can (\$k);
412 }
413 }
414  
415 eval { \$self = \$self->init (\@_) }; # if \$self->can ('init');
416  
417 \$self;
418 }
419 EOC
420 }
421  
422 29 ▶sub _postlog ( ) {
Subroutine _postlog: called CC=1 SCAR=0.0
423 29 <<EOC;
424  
425 1;
426 }
427 EOC
428 }
429  
430 6 1;
431  
432 # Autoload methods go after __END__, and are processed by the
433 # autosplit program.
434  
435 __END__
↑ Summary