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