line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
package MyTest1; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
7
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
143
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Role"; |
8
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
9
|
|
|
|
|
|
|
our $MITE_VERSION = "0.012000"; |
10
|
|
|
|
|
|
|
# Mite keywords |
11
|
|
|
|
|
|
|
BEGIN { |
12
|
1
|
|
|
1
|
|
6
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest1" ); |
13
|
1
|
|
|
|
|
2
|
( *after, *around, *before, *has, *requires, *signature_for, *with ) = do { |
14
|
|
|
|
|
|
|
package Mite::Shim; |
15
|
1
|
|
|
1
|
|
7
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
228
|
|
16
|
|
|
|
|
|
|
( |
17
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
18
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) }, |
19
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) }, |
20
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
21
|
|
|
|
|
|
|
sub {}, |
22
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) }, |
23
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
24
|
1
|
|
|
|
|
56
|
); |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
29
|
|
|
|
|
|
|
sub __META__ { |
30
|
1
|
|
|
1
|
|
17
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
452
|
|
31
|
0
|
|
0
|
0
|
|
0
|
my $class = shift; $class = ref($class) || $class; |
|
0
|
|
|
|
|
0
|
|
32
|
0
|
|
|
|
|
0
|
my $linear_isa = mro::get_linear_isa( $class ); |
33
|
|
|
|
|
|
|
return { |
34
|
|
|
|
|
|
|
BUILD => [ |
35
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
36
|
0
|
|
|
|
|
0
|
map { "$_\::BUILD" } reverse @$linear_isa |
37
|
|
|
|
|
|
|
], |
38
|
|
|
|
|
|
|
DEMOLISH => [ |
39
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
0
|
|
|
|
|
0
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
0
|
|
|
|
|
0
|
|
41
|
|
|
|
|
|
|
], |
42
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
43
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# See UNIVERSAL |
48
|
|
|
|
|
|
|
sub DOES { |
49
|
7
|
|
|
7
|
|
12
|
my ( $self, $role ) = @_; |
50
|
7
|
|
|
|
|
7
|
our %DOES; |
51
|
7
|
50
|
|
|
|
13
|
return $DOES{$role} if exists $DOES{$role}; |
52
|
7
|
50
|
|
|
|
12
|
return 1 if $role eq __PACKAGE__; |
53
|
7
|
50
|
0
|
|
|
13
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
55
|
|
|
|
|
|
|
} |
56
|
7
|
|
|
|
|
39
|
return $self->SUPER::DOES( $role ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
60
|
|
|
|
|
|
|
sub does { |
61
|
7
|
|
|
7
|
|
1994
|
shift->DOES( @_ ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
65
|
|
|
|
|
|
|
sub __FINALIZE_APPLICATION__ { |
66
|
1
|
|
|
1
|
|
3
|
my ( $me, $target, $args ) = @_; |
67
|
1
|
|
|
|
|
1
|
our ( %CONSUMERS, @METHOD_MODIFIERS ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Ensure a given target only consumes this role once. |
70
|
1
|
50
|
|
|
|
3
|
if ( exists $CONSUMERS{$target} ) { |
71
|
0
|
|
|
|
|
0
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
2
|
$CONSUMERS{$target} = 1; |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
1
|
|
7
|
my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
260
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
76
|
1
|
50
|
|
|
|
4
|
return if $type ne 'Mite::Class'; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
1
|
my @missing_methods; |
79
|
1
|
50
|
|
|
|
3
|
@missing_methods = () |
80
|
|
|
|
|
|
|
and Mite::Shim::croak( "$me requires $target to implement methods: " . join q[, ], @missing_methods ); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
1
|
my @roles = ( ); |
83
|
1
|
50
|
|
|
|
2
|
my %nextargs = %{ $args || {} }; |
|
1
|
|
|
|
|
6
|
|
84
|
1
|
|
50
|
|
|
6
|
( $nextargs{-indirect} ||= 0 )++; |
85
|
1
|
50
|
|
|
|
6
|
Mite::Shim::croak( "PANIC!" ) if $nextargs{-indirect} > 100; |
86
|
1
|
|
|
|
|
2
|
for my $role ( @roles ) { |
87
|
0
|
|
|
|
|
0
|
$role->__FINALIZE_APPLICATION__( $target, { %nextargs } ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
1
|
my $shim = "Mite::Shim"; |
91
|
1
|
|
|
|
|
2
|
for my $modifier_rule ( @METHOD_MODIFIERS ) { |
92
|
0
|
|
|
|
|
0
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
93
|
0
|
|
|
|
|
0
|
my $handler = "HANDLE_$modification"; |
94
|
0
|
|
|
|
|
0
|
$shim->$handler( $target, "class", $names, $coderef ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
4
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
}{ |
102
|
|
|
|
|
|
|
package MyTest2; |
103
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
104
|
1
|
|
|
1
|
|
18
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
105
|
1
|
|
|
1
|
|
6
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
109
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
108
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
109
|
|
|
|
|
|
|
our $MITE_VERSION = "0.012000"; |
110
|
|
|
|
|
|
|
# Mite keywords |
111
|
|
|
|
|
|
|
BEGIN { |
112
|
1
|
|
|
1
|
|
17
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest2" ); |
113
|
1
|
|
|
|
|
2
|
( *after, *around, *before, *extends, *has, *signature_for, *with ) = do { |
114
|
|
|
|
|
|
|
package Mite::Shim; |
115
|
1
|
|
|
1
|
|
7
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
203
|
|
116
|
|
|
|
|
|
|
( |
117
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
118
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
119
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
120
|
|
|
|
|
|
|
sub {}, |
121
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
122
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
123
|
1
|
|
|
|
|
4
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
124
|
1
|
|
|
|
|
48
|
); |
125
|
|
|
|
|
|
|
}; |
126
|
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
129
|
|
|
|
|
|
|
sub __META__ { |
130
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
667
|
|
131
|
1
|
|
33
|
1
|
|
2
|
my $class = shift; $class = ref($class) || $class; |
|
1
|
|
|
|
|
10
|
|
132
|
1
|
|
|
|
|
14
|
my $linear_isa = mro::get_linear_isa( $class ); |
133
|
|
|
|
|
|
|
return { |
134
|
|
|
|
|
|
|
BUILD => [ |
135
|
1
|
50
|
|
|
|
2
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
136
|
1
|
|
|
|
|
4
|
map { "$_\::BUILD" } reverse @$linear_isa |
137
|
|
|
|
|
|
|
], |
138
|
|
|
|
|
|
|
DEMOLISH => [ |
139
|
1
|
50
|
|
|
|
3
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
23
|
|
|
0
|
|
|
|
|
0
|
|
140
|
1
|
|
|
|
|
3
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
1
|
|
|
|
|
24
|
|
141
|
|
|
|
|
|
|
], |
142
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
143
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
144
|
|
|
|
|
|
|
}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
149
|
|
|
|
|
|
|
sub new { |
150
|
1
|
50
|
|
1
|
|
181
|
my $class = ref($_[0]) ? ref(shift) : shift; |
151
|
1
|
|
33
|
|
|
6
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
152
|
1
|
|
|
|
|
3
|
my $self = bless {}, $class; |
153
|
1
|
50
|
|
|
|
6
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
154
|
1
|
|
|
|
|
18
|
my $no_build = delete $args->{__no_BUILD__}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# Call BUILD methods |
159
|
1
|
50
|
33
|
|
|
5
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
1
|
50
|
|
|
|
30
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Unrecognized parameters |
162
|
1
|
0
|
|
|
|
5
|
my @unknown = grep not( do { package MyTest2::__SAFE_NAMESPACE__; defined($_) and do { ref(\$_) eq 'SCALAR' or ref(\(my $val = $_)) eq 'SCALAR' } } ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
50
|
|
|
|
0
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
163
|
|
|
|
|
|
|
|
164
|
1
|
|
|
|
|
4
|
return $self; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Used by constructor to call BUILD methods |
168
|
|
|
|
|
|
|
sub BUILDALL { |
169
|
0
|
|
|
0
|
|
0
|
my $class = ref( $_[0] ); |
170
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
171
|
0
|
0
|
|
|
|
0
|
$_->( @_ ) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Destructor should call DEMOLISH methods |
175
|
|
|
|
|
|
|
sub DESTROY { |
176
|
1
|
|
|
1
|
|
454
|
my $self = shift; |
177
|
1
|
|
33
|
|
|
3
|
my $class = ref( $self ) || $self; |
178
|
1
|
|
33
|
|
|
4
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
179
|
1
|
50
|
|
|
|
4
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
180
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
181
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
182
|
1
|
50
|
|
|
|
2
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
1
|
|
|
|
|
4
|
|
183
|
0
|
|
|
|
|
0
|
my $e = do { |
184
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
185
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
186
|
0
|
|
|
|
|
0
|
$@; |
187
|
|
|
|
|
|
|
}; |
188
|
1
|
|
|
1
|
|
8
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
98
|
|
189
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
190
|
|
|
|
|
|
|
} |
191
|
1
|
|
|
|
|
12
|
return; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
BEGIN { |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
1
|
|
|
1
|
|
238
|
our %DOES = ( "MyTest2" => 1, "MyTest1" => 1 ); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# See UNIVERSAL |
202
|
|
|
|
|
|
|
sub DOES { |
203
|
7
|
|
|
7
|
|
12
|
my ( $self, $role ) = @_; |
204
|
7
|
|
|
|
|
7
|
our %DOES; |
205
|
7
|
50
|
|
|
|
12
|
return $DOES{$role} if exists $DOES{$role}; |
206
|
7
|
50
|
|
|
|
11
|
return 1 if $role eq __PACKAGE__; |
207
|
7
|
50
|
0
|
|
|
13
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
208
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
209
|
|
|
|
|
|
|
} |
210
|
7
|
|
|
|
|
30
|
return $self->SUPER::DOES( $role ); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
214
|
|
|
|
|
|
|
sub does { |
215
|
7
|
|
|
7
|
|
763
|
shift->DOES( @_ ); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# Methods from roles |
219
|
1
|
|
|
1
|
|
8
|
sub def { goto \&MyTest1::abc; } |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
1; |
222
|
|
|
|
|
|
|
} |