line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
package MyTest1; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
6
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
192
|
|
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
|
|
5
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest1" ); |
13
|
1
|
|
|
|
|
1
|
( *after, *around, *before, *has, *requires, *signature_for, *with ) = do { |
14
|
|
|
|
|
|
|
package Mite::Shim; |
15
|
1
|
|
|
1
|
|
11
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
192
|
|
16
|
|
|
|
|
|
|
( |
17
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
18
|
1
|
|
|
|
|
4
|
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
|
|
|
|
|
46
|
); |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
29
|
|
|
|
|
|
|
sub __META__ { |
30
|
1
|
|
|
1
|
|
14
|
no strict 'refs'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
458
|
|
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
|
|
|
|
|
8
|
our %DOES; |
51
|
7
|
50
|
|
|
|
16
|
return $DOES{$role} if exists $DOES{$role}; |
52
|
7
|
50
|
|
|
|
11
|
return 1 if $role eq __PACKAGE__; |
53
|
7
|
50
|
0
|
|
|
14
|
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
|
|
|
|
|
35
|
return $self->SUPER::DOES( $role ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
60
|
|
|
|
|
|
|
sub does { |
61
|
7
|
|
|
7
|
|
2059
|
shift->DOES( @_ ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
65
|
|
|
|
|
|
|
sub __FINALIZE_APPLICATION__ { |
66
|
1
|
|
|
1
|
|
4
|
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
|
|
|
|
5
|
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
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
288
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
76
|
1
|
50
|
|
|
|
4
|
return if $type ne 'Mite::Class'; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
3
|
my @missing_methods; |
79
|
1
|
50
|
|
|
|
8
|
@missing_methods = grep( !$target->can($_), "xyz", "zyx" ) |
80
|
|
|
|
|
|
|
and Mite::Shim::croak( "$me requires $target to implement methods: " . join q[, ], @missing_methods ); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
3
|
my @roles = ( ); |
83
|
1
|
50
|
|
|
|
1
|
my %nextargs = %{ $args || {} }; |
|
1
|
|
|
|
|
9
|
|
84
|
1
|
|
50
|
|
|
5
|
( $nextargs{-indirect} ||= 0 )++; |
85
|
1
|
50
|
|
|
|
4
|
Mite::Shim::croak( "PANIC!" ) if $nextargs{-indirect} > 100; |
86
|
1
|
|
|
|
|
3
|
for my $role ( @roles ) { |
87
|
0
|
|
|
|
|
0
|
$role->__FINALIZE_APPLICATION__( $target, { %nextargs } ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
1
|
my $shim = "Mite::Shim"; |
91
|
1
|
|
|
|
|
24
|
for my $modifier_rule ( @METHOD_MODIFIERS ) { |
92
|
1
|
|
|
|
|
4
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
93
|
1
|
|
|
|
|
3
|
my $handler = "HANDLE_$modification"; |
94
|
1
|
|
|
|
|
5
|
$shim->$handler( $target, "class", $names, $coderef ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
13
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
}{ |
102
|
|
|
|
|
|
|
package MyTest2; |
103
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
104
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
105
|
1
|
|
|
1
|
|
6
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
121
|
|
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
|
|
4
|
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
|
|
|
|
|
196
|
|
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
|
|
|
|
|
3
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
124
|
1
|
|
|
|
|
45
|
); |
125
|
|
|
|
|
|
|
}; |
126
|
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
129
|
|
|
|
|
|
|
sub __META__ { |
130
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
627
|
|
131
|
0
|
|
0
|
0
|
|
0
|
my $class = shift; $class = ref($class) || $class; |
|
0
|
|
|
|
|
0
|
|
132
|
0
|
|
|
|
|
0
|
my $linear_isa = mro::get_linear_isa( $class ); |
133
|
|
|
|
|
|
|
return { |
134
|
|
|
|
|
|
|
BUILD => [ |
135
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
136
|
0
|
|
|
|
|
0
|
map { "$_\::BUILD" } reverse @$linear_isa |
137
|
|
|
|
|
|
|
], |
138
|
|
|
|
|
|
|
DEMOLISH => [ |
139
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
140
|
0
|
|
|
|
|
0
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
0
|
|
|
|
|
0
|
|
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
|
0
|
0
|
|
0
|
|
0
|
my $class = ref($_[0]) ? ref(shift) : shift; |
151
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
152
|
0
|
|
|
|
|
0
|
my $self = bless {}, $class; |
153
|
0
|
0
|
|
|
|
0
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
0
|
|
|
|
0
|
|
154
|
0
|
|
|
|
|
0
|
my $no_build = delete $args->{__no_BUILD__}; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# Call BUILD methods |
159
|
0
|
0
|
0
|
|
|
0
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
0
|
0
|
|
|
|
0
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Unrecognized parameters |
162
|
0
|
0
|
|
|
|
0
|
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
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
0
|
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
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
177
|
0
|
|
0
|
|
|
0
|
my $class = ref( $self ) || $self; |
178
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
179
|
0
|
0
|
|
|
|
0
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
180
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
181
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
182
|
0
|
0
|
|
|
|
0
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
0
|
|
|
|
|
0
|
|
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
|
|
7
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
95
|
|
189
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
190
|
|
|
|
|
|
|
} |
191
|
0
|
|
|
|
|
0
|
return; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
BEGIN { |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
1
|
|
|
1
|
|
188
|
our %DOES = ( "MyTest2" => 1, "MyTest1" => 1 ); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# See UNIVERSAL |
202
|
|
|
|
|
|
|
sub DOES { |
203
|
7
|
|
|
7
|
|
11
|
my ( $self, $role ) = @_; |
204
|
7
|
|
|
|
|
8
|
our %DOES; |
205
|
7
|
50
|
|
|
|
13
|
return $DOES{$role} if exists $DOES{$role}; |
206
|
7
|
50
|
|
|
|
10
|
return 1 if $role eq __PACKAGE__; |
207
|
7
|
50
|
0
|
|
|
15
|
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
|
|
|
|
|
28
|
return $self->SUPER::DOES( $role ); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
214
|
|
|
|
|
|
|
sub does { |
215
|
7
|
|
|
7
|
|
710
|
shift->DOES( @_ ); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |
219
|
|
|
|
|
|
|
} |