line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Set; |
4
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
107
|
|
5
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
567
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
8
|
|
|
|
|
|
|
our $MITE_SHIM = "Acme::Mitey::Cards::Mite"; |
9
|
|
|
|
|
|
|
our $MITE_VERSION = "0.007003"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
4
|
|
|
4
|
|
31
|
require Scalar::Util; |
13
|
4
|
|
|
|
|
11
|
*bare = \&Acme::Mitey::Cards::Mite::bare; |
14
|
4
|
|
|
|
|
11
|
*blessed = \&Scalar::Util::blessed; |
15
|
4
|
|
|
|
|
11
|
*carp = \&Acme::Mitey::Cards::Mite::carp; |
16
|
4
|
|
|
|
|
7
|
*confess = \&Acme::Mitey::Cards::Mite::confess; |
17
|
4
|
|
|
|
|
14
|
*croak = \&Acme::Mitey::Cards::Mite::croak; |
18
|
4
|
|
|
|
|
5
|
*false = \&Acme::Mitey::Cards::Mite::false; |
19
|
4
|
|
|
|
|
8
|
*guard = \&Acme::Mitey::Cards::Mite::guard; |
20
|
4
|
|
|
|
|
13
|
*lazy = \&Acme::Mitey::Cards::Mite::lazy; |
21
|
4
|
|
|
|
|
9
|
*ro = \&Acme::Mitey::Cards::Mite::ro; |
22
|
4
|
|
|
|
|
7
|
*rw = \&Acme::Mitey::Cards::Mite::rw; |
23
|
4
|
|
|
|
|
7
|
*rwp = \&Acme::Mitey::Cards::Mite::rwp; |
24
|
4
|
|
|
|
|
629
|
*true = \&Acme::Mitey::Cards::Mite::true; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
6
|
50
|
|
6
|
0
|
1010
|
my $class = ref( $_[0] ) ? ref(shift) : shift; |
29
|
6
|
|
66
|
|
|
20
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
30
|
6
|
|
|
|
|
14
|
my $self = bless {}, $class; |
31
|
|
|
|
|
|
|
my $args = |
32
|
|
|
|
|
|
|
$meta->{HAS_BUILDARGS} |
33
|
|
|
|
|
|
|
? $class->BUILDARGS(@_) |
34
|
6
|
50
|
|
|
|
23
|
: { ( @_ == 1 ) ? %{ $_[0] } : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
35
|
6
|
|
|
|
|
9
|
my $no_build = delete $args->{__no_BUILD__}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Attribute: cards |
38
|
6
|
100
|
|
|
|
14
|
if ( exists $args->{"cards"} ) { |
39
|
|
|
|
|
|
|
( |
40
|
|
|
|
|
|
|
do { |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
43
|
5
|
|
|
|
|
18
|
ref( $args->{"cards"} ) eq 'ARRAY'; |
44
|
|
|
|
|
|
|
} |
45
|
5
|
50
|
33
|
|
|
6
|
and do { |
46
|
5
|
|
|
|
|
7
|
my $ok = 1; |
47
|
5
|
|
|
|
|
7
|
for my $i ( @{ $args->{"cards"} } ) { |
|
5
|
|
|
|
|
11
|
|
48
|
|
|
|
|
|
|
( $ok = 0, last ) |
49
|
|
|
|
|
|
|
unless ( |
50
|
19
|
50
|
|
|
|
22
|
do { |
51
|
4
|
|
|
4
|
|
26
|
use Scalar::Util (); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1673
|
|
52
|
19
|
50
|
|
|
|
94
|
Scalar::Util::blessed($i) |
53
|
|
|
|
|
|
|
and $i->isa(q[Acme::Mitey::Cards::Card]); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
}; |
57
|
5
|
|
|
|
|
14
|
$ok; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
) |
60
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
61
|
|
|
|
|
|
|
"cards", "CardArray"; |
62
|
5
|
|
|
|
|
14
|
$self->{"cards"} = $args->{"cards"}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Enforce strict constructor |
66
|
6
|
|
|
|
|
7
|
my @unknown = grep not(/\Acards\z/), keys %{$args}; |
|
6
|
|
|
|
|
31
|
|
67
|
|
|
|
|
|
|
@unknown |
68
|
6
|
50
|
|
|
|
14
|
and croak( |
69
|
|
|
|
|
|
|
"Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Call BUILD methods |
72
|
6
|
50
|
33
|
|
|
15
|
$self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); |
|
6
|
50
|
|
|
|
20
|
|
73
|
|
|
|
|
|
|
|
74
|
6
|
|
|
|
|
23
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub BUILDALL { |
78
|
0
|
|
|
0
|
0
|
0
|
my $class = ref( $_[0] ); |
79
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
80
|
0
|
0
|
|
|
|
0
|
$_->(@_) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub DESTROY { |
84
|
10
|
|
|
10
|
|
4952
|
my $self = shift; |
85
|
10
|
|
33
|
|
|
33
|
my $class = ref($self) || $self; |
86
|
10
|
|
33
|
|
|
28
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
87
|
10
|
50
|
|
|
|
42
|
my $in_global_destruction = |
88
|
|
|
|
|
|
|
defined ${^GLOBAL_PHASE} |
89
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
90
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
91
|
10
|
50
|
|
|
|
13
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
10
|
|
|
|
|
28
|
|
92
|
0
|
|
|
|
|
0
|
my $e = do { |
93
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
94
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
95
|
0
|
|
|
|
|
0
|
$@; |
96
|
|
|
|
|
|
|
}; |
97
|
4
|
|
|
4
|
|
25
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
301
|
|
98
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
99
|
|
|
|
|
|
|
} |
100
|
10
|
|
|
|
|
172
|
return; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub __META__ { |
104
|
4
|
|
|
4
|
|
23
|
no strict 'refs'; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
141
|
|
105
|
4
|
|
|
4
|
|
20
|
no warnings 'once'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1367
|
|
106
|
5
|
|
|
5
|
|
12
|
my $class = shift; |
107
|
5
|
|
33
|
|
|
23
|
$class = ref($class) || $class; |
108
|
5
|
|
|
|
|
21
|
my $linear_isa = mro::get_linear_isa($class); |
109
|
|
|
|
|
|
|
return { |
110
|
|
|
|
|
|
|
BUILD => [ |
111
|
8
|
50
|
|
|
|
13
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
8
|
|
|
|
|
37
|
|
|
0
|
|
|
|
|
0
|
|
112
|
8
|
|
|
|
|
24
|
map { "$_\::BUILD" } reverse @$linear_isa |
113
|
|
|
|
|
|
|
], |
114
|
|
|
|
|
|
|
DEMOLISH => [ |
115
|
8
|
50
|
|
|
|
12
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
8
|
|
|
|
|
82
|
|
|
0
|
|
|
|
|
0
|
|
116
|
5
|
|
|
|
|
11
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
8
|
|
|
|
|
18
|
|
117
|
|
|
|
|
|
|
], |
118
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
119
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub DOES { |
124
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $role ) = @_; |
125
|
0
|
|
|
|
|
0
|
our %DOES; |
126
|
0
|
0
|
|
|
|
0
|
return $DOES{$role} if exists $DOES{$role}; |
127
|
0
|
0
|
|
|
|
0
|
return 1 if $role eq __PACKAGE__; |
128
|
0
|
|
|
|
|
0
|
return $self->SUPER::DOES($role); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub does { |
132
|
0
|
|
|
0
|
0
|
0
|
shift->DOES(@_); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $__XS = !$ENV{MITE_PURE_PERL} |
136
|
|
|
|
|
|
|
&& eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# Accessors for cards |
139
|
|
|
|
|
|
|
sub cards { |
140
|
0
|
|
|
|
|
0
|
@_ > 1 ? croak("cards is a read-only attribute of @{[ref $_[0]]}") : ( |
141
|
|
|
|
|
|
|
exists( $_[0]{"cards"} ) ? $_[0]{"cards"} : ( |
142
|
41
|
100
|
|
41
|
0
|
369
|
$_[0]{"cards"} = do { |
|
|
50
|
|
|
|
|
|
143
|
3
|
|
|
|
|
22
|
my $default_value = $_[0]->_build_cards; |
144
|
3
|
50
|
|
|
|
6
|
do { |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
147
|
3
|
50
|
|
|
|
11
|
( ref($default_value) eq 'ARRAY' ) and do { |
148
|
3
|
|
|
|
|
6
|
my $ok = 1; |
149
|
3
|
|
|
|
|
19
|
for my $i ( @{$default_value} ) { |
|
3
|
|
|
|
|
8
|
|
150
|
|
|
|
|
|
|
( $ok = 0, last ) |
151
|
|
|
|
|
|
|
unless ( |
152
|
54
|
50
|
|
|
|
58
|
do { |
153
|
4
|
|
|
4
|
|
30
|
use Scalar::Util (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1787
|
|
154
|
54
|
50
|
|
|
|
173
|
Scalar::Util::blessed($i) |
155
|
|
|
|
|
|
|
and |
156
|
|
|
|
|
|
|
$i->isa(q[Acme::Mitey::Cards::Card]); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
}; |
160
|
3
|
|
|
|
|
12
|
$ok; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
or croak( "Type check failed in default: %s should be %s", |
164
|
|
|
|
|
|
|
"cards", "CardArray" ); |
165
|
3
|
|
|
|
|
43
|
$default_value; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
) |
168
|
|
|
|
|
|
|
); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$SIGNATURE_FOR{"count"} = sub { |
174
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
@_ == 1 |
179
|
|
|
|
|
|
|
or croak( |
180
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: %s, got %d", |
181
|
|
|
|
|
|
|
"count", "expected exactly 1 parameters", |
182
|
|
|
|
|
|
|
scalar(@_) |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# Parameter $head[0] (type: Defined) |
188
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
189
|
|
|
|
|
|
|
or croak( "Type check failed in signature for count: %s should be %s", |
190
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
return ( &$__NEXT__( @head, @_ ) ); |
193
|
|
|
|
|
|
|
}; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
$SIGNATURE_FOR{"take"} = sub { |
196
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
@_ == 2 |
201
|
|
|
|
|
|
|
or croak( |
202
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: %s, got %d", |
203
|
|
|
|
|
|
|
"take", "expected exactly 2 parameters", |
204
|
|
|
|
|
|
|
scalar(@_) |
205
|
|
|
|
|
|
|
); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# Parameter $head[0] (type: Defined) |
210
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
211
|
|
|
|
|
|
|
or croak( "Type check failed in signature for take: %s should be %s", |
212
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# Parameter $_[0] (type: Int) |
215
|
|
|
|
|
|
|
( |
216
|
|
|
|
|
|
|
do { |
217
|
|
|
|
|
|
|
my $tmp = $_[0]; |
218
|
|
|
|
|
|
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
) |
221
|
|
|
|
|
|
|
or croak( "Type check failed in signature for take: %s should be %s", |
222
|
|
|
|
|
|
|
"\$_[1]", "Int" ); |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
return ( &$__NEXT__( @head, @_ ) ); |
225
|
|
|
|
|
|
|
}; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
$SIGNATURE_FOR{"to_string"} = sub { |
228
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
@_ == 1 |
233
|
|
|
|
|
|
|
or croak( |
234
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: %s, got %d", |
235
|
|
|
|
|
|
|
"to_string", "expected exactly 1 parameters", |
236
|
|
|
|
|
|
|
scalar(@_) |
237
|
|
|
|
|
|
|
); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# Parameter $head[0] (type: Defined) |
242
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
243
|
|
|
|
|
|
|
or croak( |
244
|
|
|
|
|
|
|
"Type check failed in signature for to_string: %s should be %s", |
245
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
return ( &$__NEXT__( @head, @_ ) ); |
248
|
|
|
|
|
|
|
}; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
1; |
251
|
|
|
|
|
|
|
} |