line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
130
|
|
6
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Role"; |
7
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
8
|
|
|
|
|
|
|
our $MITE_VERSION = "0.010008"; |
9
|
|
|
|
|
|
|
# Mite keywords |
10
|
|
|
|
|
|
|
BEGIN { |
11
|
|
|
|
|
|
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest::R" ); |
12
|
1
|
|
|
1
|
|
4
|
( *after, *around, *before, *field, *has, *param, *requires, *signature_for, *with ) = do { |
13
|
1
|
|
|
|
|
1
|
no warnings 'redefine'; |
14
|
|
|
|
|
|
|
( |
15
|
1
|
|
|
1
|
|
6
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
202
|
|
16
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) }, |
17
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) }, |
18
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
19
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
20
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
21
|
0
|
|
|
|
|
0
|
sub {}, |
22
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) }, |
23
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
24
|
1
|
|
|
|
|
3
|
); |
25
|
0
|
|
|
|
|
0
|
}; |
26
|
1
|
|
|
|
|
154
|
|
27
|
|
|
|
|
|
|
# Mite imports |
28
|
|
|
|
|
|
|
BEGIN { |
29
|
|
|
|
|
|
|
require Scalar::Util; |
30
|
|
|
|
|
|
|
*STRICT = \&Mite::Shim::STRICT; |
31
|
|
|
|
|
|
|
*bare = \&Mite::Shim::bare; |
32
|
1
|
|
|
1
|
|
5
|
*blessed = \&Scalar::Util::blessed; |
33
|
1
|
|
|
|
|
3
|
*carp = \&Mite::Shim::carp; |
34
|
1
|
|
|
|
|
1
|
*confess = \&Mite::Shim::confess; |
35
|
1
|
|
|
|
|
2
|
*croak = \&Mite::Shim::croak; |
36
|
1
|
|
|
|
|
2
|
*false = \&Mite::Shim::false; |
37
|
1
|
|
|
|
|
2
|
*guard = \&Mite::Shim::guard; |
38
|
1
|
|
|
|
|
1
|
*lazy = \&Mite::Shim::lazy; |
39
|
1
|
|
|
|
|
1
|
*ro = \&Mite::Shim::ro; |
40
|
1
|
|
|
|
|
2
|
*rw = \&Mite::Shim::rw; |
41
|
1
|
|
|
|
|
1
|
*rwp = \&Mite::Shim::rwp; |
42
|
1
|
|
|
|
|
8
|
*true = \&Mite::Shim::true; |
43
|
1
|
|
|
|
|
10
|
}; |
44
|
1
|
|
|
|
|
3
|
|
45
|
1
|
|
|
|
|
34
|
# Gather metadata for constructor and destructor |
46
|
|
|
|
|
|
|
no strict 'refs'; |
47
|
|
|
|
|
|
|
my $class = shift; $class = ref($class) || $class; |
48
|
|
|
|
|
|
|
my $linear_isa = mro::get_linear_isa( $class ); |
49
|
|
|
|
|
|
|
return { |
50
|
1
|
|
|
1
|
|
4
|
BUILD => [ |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
653
|
|
51
|
0
|
|
0
|
0
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
52
|
0
|
|
|
|
|
0
|
map { "$_\::BUILD" } reverse @$linear_isa |
53
|
|
|
|
|
|
|
], |
54
|
|
|
|
|
|
|
DEMOLISH => [ |
55
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
56
|
0
|
|
|
|
|
0
|
map { "$_\::DEMOLISH" } @$linear_isa |
57
|
|
|
|
|
|
|
], |
58
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
59
|
0
|
0
|
|
|
|
0
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
60
|
0
|
|
|
|
|
0
|
}; |
|
0
|
|
|
|
|
0
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# See UNIVERSAL |
64
|
|
|
|
|
|
|
my ( $self, $role ) = @_; |
65
|
|
|
|
|
|
|
our %DOES; |
66
|
|
|
|
|
|
|
return $DOES{$role} if exists $DOES{$role}; |
67
|
|
|
|
|
|
|
return 1 if $role eq __PACKAGE__; |
68
|
|
|
|
|
|
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
69
|
22
|
|
|
22
|
|
28
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
70
|
22
|
|
|
|
|
16
|
} |
71
|
22
|
50
|
|
|
|
29
|
return $self->SUPER::DOES( $role ); |
72
|
22
|
50
|
|
|
|
30
|
} |
73
|
22
|
50
|
0
|
|
|
28
|
|
|
|
|
33
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
0
|
# Alias for Moose/Moo-compatibility |
75
|
|
|
|
|
|
|
shift->DOES( @_ ); |
76
|
22
|
|
|
|
|
75
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Method signatures |
79
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
80
|
|
|
|
|
|
|
|
81
|
22
|
|
|
22
|
|
1969
|
$SIGNATURE_FOR{"foo"} = sub { |
82
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my ( @out, %tmp, $tmp, $dtmp, @head ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
@_ == 3 |
87
|
|
|
|
|
|
|
or croak( "Wrong number of parameters in signature for %s: got %d, %s", "foo", scalar( @_ ), "expected exactly 3 parameters" ); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
92
|
|
|
|
|
|
|
(defined($head[0])) |
93
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_[0]", "Defined" ); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Parameter $_[0] (type: Int) |
96
|
|
|
|
|
|
|
(do { my $tmp = $_[0]; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ }) |
97
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_[1]", "Int" ); |
98
|
|
|
|
|
|
|
push( @out, $_[0] ); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Parameter $_[1] (type: Bool) |
101
|
|
|
|
|
|
|
$tmp = ((!ref $_[1] and (!defined $_[1] or $_[1] eq q() or $_[1] eq '0' or $_[1] eq '1'))) ? $_[1] : ((!!1)) ? scalar(do { local $_ = $_[1]; !!$_ }) : $_[1]; |
102
|
|
|
|
|
|
|
(!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1')) |
103
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_[2]", "Bool" ); |
104
|
|
|
|
|
|
|
push( @out, $tmp ); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
do { @_ = ( @head, @out ); goto $__NEXT__ }; |
107
|
|
|
|
|
|
|
}; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
111
|
|
|
|
|
|
|
my ( $me, $target, $args ) = @_; |
112
|
|
|
|
|
|
|
our ( %CONSUMERS, @METHOD_MODIFIERS ); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Ensure a given target only consumes this role once. |
115
|
|
|
|
|
|
|
if ( exists $CONSUMERS{$target} ) { |
116
|
|
|
|
|
|
|
return; |
117
|
|
|
|
|
|
|
} |
118
|
1
|
|
|
1
|
|
2
|
$CONSUMERS{$target} = 1; |
119
|
1
|
|
|
|
|
7
|
|
120
|
|
|
|
|
|
|
my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} }; |
121
|
|
|
|
|
|
|
return if $type ne 'Mite::Class'; |
122
|
1
|
50
|
|
|
|
2
|
|
123
|
0
|
|
|
|
|
0
|
my @missing_methods; |
124
|
|
|
|
|
|
|
@missing_methods = () |
125
|
1
|
|
|
|
|
2
|
and croak( "$me requires $target to implement methods: " . join q[, ], @missing_methods ); |
126
|
|
|
|
|
|
|
|
127
|
1
|
|
|
1
|
|
13
|
my @roles = ( ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
217
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
128
|
1
|
50
|
|
|
|
3
|
my %nextargs = %{ $args || {} }; |
129
|
|
|
|
|
|
|
( $nextargs{-indirect} ||= 0 )++; |
130
|
1
|
|
|
|
|
2
|
croak( "PANIC!" ) if $nextargs{-indirect} > 100; |
131
|
1
|
50
|
|
|
|
2
|
for my $role ( @roles ) { |
132
|
|
|
|
|
|
|
$role->__FINALIZE_APPLICATION__( $target, { %nextargs } ); |
133
|
|
|
|
|
|
|
} |
134
|
1
|
|
|
|
|
2
|
|
135
|
1
|
50
|
|
|
|
1
|
my $shim = "Mite::Shim"; |
|
1
|
|
|
|
|
6
|
|
136
|
1
|
|
50
|
|
|
4
|
for my $modifier_rule ( @METHOD_MODIFIERS ) { |
137
|
1
|
50
|
|
|
|
2
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
138
|
1
|
|
|
|
|
2
|
my $handler = "HANDLE_$modification"; |
139
|
0
|
|
|
|
|
0
|
$shim->$handler( $target, "class", $names, $coderef ); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
1
|
return; |
143
|
1
|
|
|
|
|
2
|
} |
144
|
1
|
|
|
|
|
1
|
|
145
|
1
|
|
|
|
|
2
|
1; |
146
|
1
|
|
|
|
|
3
|
use strict; |
147
|
|
|
|
|
|
|
use warnings; |
148
|
|
|
|
|
|
|
no warnings qw( once void ); |
149
|
1
|
|
|
|
|
4
|
|
150
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
151
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
152
|
|
|
|
|
|
|
our $MITE_VERSION = "0.010008"; |
153
|
|
|
|
|
|
|
# Mite keywords |
154
|
|
|
|
|
|
|
BEGIN { |
155
|
1
|
|
|
1
|
|
6
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest" ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
156
|
1
|
|
|
1
|
|
4
|
( *after, *around, *before, *extends, *has, *signature_for, *with ) = do { |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
157
|
1
|
|
|
1
|
|
4
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
103
|
|
158
|
|
|
|
|
|
|
( |
159
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
160
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
161
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
162
|
|
|
|
|
|
|
sub {}, |
163
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
164
|
1
|
|
|
1
|
|
4
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
165
|
1
|
|
|
|
|
2
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
166
|
|
|
|
|
|
|
); |
167
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
233
|
|
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
# Gather metadata for constructor and destructor |
170
|
0
|
|
|
|
|
0
|
no strict 'refs'; |
171
|
0
|
|
|
|
|
0
|
my $class = shift; $class = ref($class) || $class; |
172
|
|
|
|
|
|
|
my $linear_isa = mro::get_linear_isa( $class ); |
173
|
0
|
|
|
|
|
0
|
return { |
174
|
0
|
|
|
|
|
0
|
BUILD => [ |
175
|
1
|
|
|
|
|
3
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
176
|
1
|
|
|
|
|
39
|
map { "$_\::BUILD" } reverse @$linear_isa |
177
|
|
|
|
|
|
|
], |
178
|
|
|
|
|
|
|
DEMOLISH => [ |
179
|
|
|
|
|
|
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
180
|
|
|
|
|
|
|
map { "$_\::DEMOLISH" } @$linear_isa |
181
|
|
|
|
|
|
|
], |
182
|
1
|
|
|
1
|
|
5
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
513
|
|
183
|
0
|
|
0
|
0
|
|
0
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
|
0
|
|
|
|
|
0
|
|
184
|
0
|
|
|
|
|
0
|
}; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
188
|
0
|
|
|
|
|
0
|
# Standard Moose/Moo-style constructor |
189
|
|
|
|
|
|
|
my $class = ref($_[0]) ? ref(shift) : shift; |
190
|
|
|
|
|
|
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
191
|
0
|
0
|
|
|
|
0
|
my $self = bless {}, $class; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
192
|
0
|
|
|
|
|
0
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
|
|
|
|
0
|
|
193
|
|
|
|
|
|
|
my $no_build = delete $args->{__no_BUILD__}; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# Call BUILD methods |
198
|
|
|
|
|
|
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# Unrecognized parameters |
201
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
0
|
|
0
|
return $self; |
203
|
0
|
|
0
|
|
|
0
|
} |
204
|
0
|
|
|
|
|
0
|
|
205
|
0
|
0
|
|
|
|
0
|
# Used by constructor to call BUILD methods |
|
0
|
0
|
|
|
|
0
|
|
206
|
0
|
|
|
|
|
0
|
my $class = ref( $_[0] ); |
207
|
|
|
|
|
|
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
208
|
|
|
|
|
|
|
$_->( @_ ) for @{ $meta->{BUILD} || [] }; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
0
|
0
|
0
|
|
|
0
|
# Destructor should call DEMOLISH methods |
|
0
|
0
|
|
|
|
0
|
|
212
|
|
|
|
|
|
|
my $self = shift; |
213
|
|
|
|
|
|
|
my $class = ref( $self ) || $self; |
214
|
0
|
0
|
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
215
|
|
|
|
|
|
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
216
|
0
|
|
|
|
|
0
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
217
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
218
|
|
|
|
|
|
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
219
|
|
|
|
|
|
|
my $e = do { |
220
|
|
|
|
|
|
|
local ( $?, $@ ); |
221
|
0
|
|
|
0
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
222
|
0
|
|
0
|
|
|
0
|
$@; |
223
|
0
|
0
|
|
|
|
0
|
}; |
|
0
|
|
|
|
|
0
|
|
224
|
|
|
|
|
|
|
no warnings 'misc'; # avoid (in cleanup) warnings |
225
|
|
|
|
|
|
|
die $e if $e; # rethrow |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
return; |
228
|
0
|
|
|
0
|
|
0
|
} |
229
|
0
|
|
0
|
|
|
0
|
|
230
|
0
|
|
0
|
|
|
0
|
|
231
|
0
|
0
|
|
|
|
0
|
BEGIN { |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
0
|
our %DOES = ( "MyTest" => 1, "MyTest::R" => 1 ); |
|
0
|
|
|
|
|
0
|
|
235
|
0
|
|
|
|
|
0
|
} |
236
|
0
|
|
|
|
|
0
|
|
237
|
0
|
|
|
|
|
0
|
# See UNIVERSAL |
|
0
|
|
|
|
|
0
|
|
238
|
0
|
|
|
|
|
0
|
my ( $self, $role ) = @_; |
239
|
|
|
|
|
|
|
our %DOES; |
240
|
1
|
|
|
1
|
|
6
|
return $DOES{$role} if exists $DOES{$role}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
241
|
0
|
0
|
|
|
|
0
|
return 1 if $role eq __PACKAGE__; |
242
|
|
|
|
|
|
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
243
|
0
|
|
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
return $self->SUPER::DOES( $role ); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
249
|
|
|
|
|
|
|
shift->DOES( @_ ); |
250
|
1
|
|
|
1
|
|
163
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
1; |