line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Set; |
4
|
5
|
|
|
5
|
|
36
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
161
|
|
5
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
137
|
|
6
|
5
|
|
|
5
|
|
26
|
no warnings qw( once void ); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
629
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
9
|
|
|
|
|
|
|
our $MITE_SHIM = "Acme::Mitey::Cards::Mite"; |
10
|
|
|
|
|
|
|
our $MITE_VERSION = "0.011000"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Mite keywords |
13
|
|
|
|
|
|
|
BEGIN { |
14
|
5
|
|
|
5
|
|
32
|
my ( $SHIM, $CALLER ) = |
15
|
|
|
|
|
|
|
( "Acme::Mitey::Cards::Mite", "Acme::Mitey::Cards::Set" ); |
16
|
|
|
|
|
|
|
( |
17
|
|
|
|
|
|
|
*after, *around, *before, *extends, *field, |
18
|
|
|
|
|
|
|
*has, *param, *signature_for, *with |
19
|
|
|
|
|
|
|
) |
20
|
5
|
|
|
|
|
12
|
= do { |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
23
|
5
|
|
|
5
|
|
35
|
no warnings 'redefine'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1159
|
|
24
|
|
|
|
|
|
|
( |
25
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
27
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
28
|
|
|
|
0
|
|
|
sub { }, |
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
30
|
5
|
|
|
5
|
|
33
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
32
|
15
|
|
|
15
|
|
61
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
33
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
34
|
5
|
|
|
|
|
974
|
); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Mite imports |
39
|
|
|
|
|
|
|
BEGIN { |
40
|
5
|
|
|
5
|
|
38
|
require Scalar::Util; |
41
|
5
|
|
|
|
|
19
|
*STRICT = \&Acme::Mitey::Cards::Mite::STRICT; |
42
|
5
|
|
|
|
|
11
|
*bare = \&Acme::Mitey::Cards::Mite::bare; |
43
|
5
|
|
|
|
|
12
|
*blessed = \&Scalar::Util::blessed; |
44
|
5
|
|
|
|
|
11
|
*carp = \&Acme::Mitey::Cards::Mite::carp; |
45
|
5
|
|
|
|
|
11
|
*confess = \&Acme::Mitey::Cards::Mite::confess; |
46
|
5
|
|
|
|
|
9
|
*croak = \&Acme::Mitey::Cards::Mite::croak; |
47
|
5
|
|
|
|
|
13
|
*false = \&Acme::Mitey::Cards::Mite::false; |
48
|
5
|
|
|
|
|
10
|
*guard = \&Acme::Mitey::Cards::Mite::guard; |
49
|
5
|
|
|
|
|
8
|
*lazy = \&Acme::Mitey::Cards::Mite::lazy; |
50
|
5
|
|
|
|
|
9
|
*lock = \&Acme::Mitey::Cards::Mite::lock; |
51
|
5
|
|
|
|
|
12
|
*ro = \&Acme::Mitey::Cards::Mite::ro; |
52
|
5
|
|
|
|
|
9
|
*rw = \&Acme::Mitey::Cards::Mite::rw; |
53
|
5
|
|
|
|
|
11
|
*rwp = \&Acme::Mitey::Cards::Mite::rwp; |
54
|
5
|
|
|
|
|
18
|
*true = \&Acme::Mitey::Cards::Mite::true; |
55
|
5
|
|
|
|
|
167
|
*unlock = \&Acme::Mitey::Cards::Mite::unlock; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
59
|
|
|
|
|
|
|
sub __META__ { |
60
|
5
|
|
|
5
|
|
32
|
no strict 'refs'; |
|
5
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
2000
|
|
61
|
6
|
|
|
6
|
|
17
|
my $class = shift; |
62
|
6
|
|
33
|
|
|
37
|
$class = ref($class) || $class; |
63
|
6
|
|
|
|
|
28
|
my $linear_isa = mro::get_linear_isa($class); |
64
|
|
|
|
|
|
|
return { |
65
|
|
|
|
|
|
|
BUILD => [ |
66
|
11
|
50
|
|
|
|
22
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
11
|
|
|
|
|
77
|
|
|
0
|
|
|
|
|
0
|
|
67
|
11
|
|
|
|
|
38
|
map { "$_\::BUILD" } reverse @$linear_isa |
68
|
|
|
|
|
|
|
], |
69
|
|
|
|
|
|
|
DEMOLISH => [ |
70
|
11
|
50
|
|
|
|
40
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
11
|
|
|
|
|
164
|
|
|
0
|
|
|
|
|
0
|
|
71
|
6
|
|
|
|
|
23
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
11
|
|
|
|
|
32
|
|
72
|
|
|
|
|
|
|
], |
73
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
74
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Moose-compatibility method |
79
|
|
|
|
|
|
|
sub meta { |
80
|
0
|
|
|
0
|
0
|
0
|
require Acme::Mitey::Cards::MOP; |
81
|
0
|
|
0
|
|
|
0
|
Moose::Util::find_meta( ref $_[0] or $_[0] ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
85
|
|
|
|
|
|
|
sub new { |
86
|
6
|
50
|
|
6
|
0
|
1072
|
my $class = ref( $_[0] ) ? ref(shift) : shift; |
87
|
6
|
|
66
|
|
|
28
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
88
|
6
|
|
|
|
|
16
|
my $self = bless {}, $class; |
89
|
|
|
|
|
|
|
my $args = |
90
|
|
|
|
|
|
|
$meta->{HAS_BUILDARGS} |
91
|
|
|
|
|
|
|
? $class->BUILDARGS(@_) |
92
|
6
|
50
|
|
|
|
30
|
: { ( @_ == 1 ) ? %{ $_[0] } : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
93
|
6
|
|
|
|
|
14
|
my $no_build = delete $args->{__no_BUILD__}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Attribute cards (type: CardArray) |
96
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Set.pm, line 11 |
97
|
6
|
100
|
|
|
|
18
|
if ( exists $args->{"cards"} ) { |
98
|
|
|
|
|
|
|
( |
99
|
|
|
|
|
|
|
do { |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
102
|
5
|
|
|
|
|
34
|
ref( $args->{"cards"} ) eq 'ARRAY'; |
103
|
|
|
|
|
|
|
} |
104
|
5
|
50
|
33
|
|
|
9
|
and do { |
105
|
5
|
|
|
|
|
10
|
my $ok = 1; |
106
|
5
|
|
|
|
|
10
|
for my $i ( @{ $args->{"cards"} } ) { |
|
5
|
|
|
|
|
14
|
|
107
|
|
|
|
|
|
|
( $ok = 0, last ) |
108
|
|
|
|
|
|
|
unless ( |
109
|
19
|
50
|
|
|
|
28
|
do { |
110
|
5
|
|
|
5
|
|
41
|
use Scalar::Util (); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
1970
|
|
111
|
19
|
50
|
|
|
|
114
|
Scalar::Util::blessed($i) |
112
|
|
|
|
|
|
|
and $i->isa(q[Acme::Mitey::Cards::Card]); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
}; |
116
|
5
|
|
|
|
|
19
|
$ok; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
) |
119
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
120
|
|
|
|
|
|
|
"cards", "CardArray"; |
121
|
5
|
|
|
|
|
15
|
$self->{"cards"} = $args->{"cards"}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Call BUILD methods |
125
|
6
|
50
|
33
|
|
|
19
|
$self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); |
|
6
|
50
|
|
|
|
25
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Unrecognized parameters |
128
|
6
|
|
|
|
|
10
|
my @unknown = grep not(/\Acards\z/), keys %{$args}; |
|
6
|
|
|
|
|
39
|
|
129
|
|
|
|
|
|
|
@unknown |
130
|
6
|
50
|
|
|
|
30
|
and croak( |
131
|
|
|
|
|
|
|
"Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
132
|
|
|
|
|
|
|
|
133
|
6
|
|
|
|
|
35
|
return $self; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Used by constructor to call BUILD methods |
137
|
|
|
|
|
|
|
sub BUILDALL { |
138
|
0
|
|
|
0
|
0
|
0
|
my $class = ref( $_[0] ); |
139
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
140
|
0
|
0
|
|
|
|
0
|
$_->(@_) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Destructor should call DEMOLISH methods |
144
|
|
|
|
|
|
|
sub DESTROY { |
145
|
11
|
|
|
11
|
|
9207
|
my $self = shift; |
146
|
11
|
|
33
|
|
|
39
|
my $class = ref($self) || $self; |
147
|
11
|
|
66
|
|
|
59
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
148
|
11
|
50
|
|
|
|
46
|
my $in_global_destruction = |
149
|
|
|
|
|
|
|
defined ${^GLOBAL_PHASE} |
150
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
151
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
152
|
11
|
50
|
|
|
|
22
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
11
|
|
|
|
|
43
|
|
153
|
0
|
|
|
|
|
0
|
my $e = do { |
154
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
155
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
156
|
0
|
|
|
|
|
0
|
$@; |
157
|
|
|
|
|
|
|
}; |
158
|
5
|
|
|
5
|
|
38
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
1042
|
|
159
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
160
|
|
|
|
|
|
|
} |
161
|
11
|
|
|
|
|
339
|
return; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $__XS = !$ENV{PERL_ONLY} |
165
|
|
|
|
|
|
|
&& eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Accessors for cards |
168
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Set.pm, line 11 |
169
|
|
|
|
|
|
|
sub cards { |
170
|
41
|
50
|
|
41
|
0
|
97
|
@_ == 1 or croak('Reader "cards" usage: $self->cards()'); |
171
|
|
|
|
|
|
|
( |
172
|
|
|
|
|
|
|
exists( $_[0]{"cards"} ) ? $_[0]{"cards"} : ( |
173
|
41
|
100
|
|
|
|
390
|
$_[0]{"cards"} = do { |
174
|
3
|
|
|
|
|
26
|
my $default_value = $_[0]->_build_cards; |
175
|
3
|
50
|
|
|
|
8
|
do { |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
178
|
3
|
50
|
|
|
|
25
|
( ref($default_value) eq 'ARRAY' ) and do { |
179
|
3
|
|
|
|
|
7
|
my $ok = 1; |
180
|
3
|
|
|
|
|
8
|
for my $i ( @{$default_value} ) { |
|
3
|
|
|
|
|
7
|
|
181
|
|
|
|
|
|
|
( $ok = 0, last ) |
182
|
|
|
|
|
|
|
unless ( |
183
|
54
|
50
|
|
|
|
78
|
do { |
184
|
5
|
|
|
5
|
|
37
|
use Scalar::Util (); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
3857
|
|
185
|
54
|
50
|
|
|
|
209
|
Scalar::Util::blessed($i) |
186
|
|
|
|
|
|
|
and |
187
|
|
|
|
|
|
|
$i->isa(q[Acme::Mitey::Cards::Card]); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
); |
190
|
|
|
|
|
|
|
}; |
191
|
3
|
|
|
|
|
15
|
$ok; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
or croak( "Type check failed in default: %s should be %s", |
195
|
|
|
|
|
|
|
"cards", "CardArray" ); |
196
|
3
|
|
|
|
|
24
|
$default_value; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
) |
199
|
|
|
|
|
|
|
); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# See UNIVERSAL |
203
|
|
|
|
|
|
|
sub DOES { |
204
|
0
|
|
|
0
|
0
|
|
my ( $self, $role ) = @_; |
205
|
0
|
|
|
|
|
|
our %DOES; |
206
|
0
|
0
|
|
|
|
|
return $DOES{$role} if exists $DOES{$role}; |
207
|
0
|
0
|
|
|
|
|
return 1 if $role eq __PACKAGE__; |
208
|
0
|
0
|
0
|
|
|
|
if ( $INC{'Moose/Util.pm'} |
|
|
|
0
|
|
|
|
|
209
|
|
|
|
|
|
|
and my $meta = Moose::Util::find_meta( ref $self or $self ) ) |
210
|
|
|
|
|
|
|
{ |
211
|
0
|
0
|
0
|
|
|
|
$meta->can('does_role') and $meta->does_role($role) and return 1; |
212
|
|
|
|
|
|
|
} |
213
|
0
|
|
|
|
|
|
return $self->SUPER::DOES($role); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
217
|
|
|
|
|
|
|
sub does { |
218
|
0
|
|
|
0
|
0
|
|
shift->DOES(@_); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# Method signatures |
222
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
$SIGNATURE_FOR{"count"} = sub { |
225
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
@_ == 1 |
230
|
|
|
|
|
|
|
or |
231
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
232
|
|
|
|
|
|
|
"count", scalar(@_), "expected exactly 1 parameters" ); |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
237
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
238
|
|
|
|
|
|
|
or croak( "Type check failed in signature for count: %s should be %s", |
239
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
do { @_ = ( @head, @_ ); goto $__NEXT__ }; |
242
|
|
|
|
|
|
|
}; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
$SIGNATURE_FOR{"take"} = sub { |
245
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
@_ == 2 |
250
|
|
|
|
|
|
|
or |
251
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
252
|
|
|
|
|
|
|
"take", scalar(@_), "expected exactly 2 parameters" ); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
257
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
258
|
|
|
|
|
|
|
or croak( "Type check failed in signature for take: %s should be %s", |
259
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
# Parameter $_[0] (type: Int) |
262
|
|
|
|
|
|
|
( |
263
|
|
|
|
|
|
|
do { |
264
|
|
|
|
|
|
|
my $tmp = $_[0]; |
265
|
|
|
|
|
|
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
) |
268
|
|
|
|
|
|
|
or croak( "Type check failed in signature for take: %s should be %s", |
269
|
|
|
|
|
|
|
"\$_[1]", "Int" ); |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
do { @_ = ( @head, @_ ); goto $__NEXT__ }; |
272
|
|
|
|
|
|
|
}; |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
$SIGNATURE_FOR{"to_string"} = sub { |
275
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
@_ == 1 |
280
|
|
|
|
|
|
|
or |
281
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
282
|
|
|
|
|
|
|
"to_string", scalar(@_), "expected exactly 1 parameters" ); |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
287
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
288
|
|
|
|
|
|
|
or croak( |
289
|
|
|
|
|
|
|
"Type check failed in signature for to_string: %s should be %s", |
290
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
do { @_ = ( @head, @_ ); goto $__NEXT__ }; |
293
|
|
|
|
|
|
|
}; |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
1; |
296
|
|
|
|
|
|
|
} |