| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
{ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use strict; |
|
4
|
108
|
|
|
108
|
|
765
|
use warnings; |
|
|
108
|
|
|
|
|
247
|
|
|
|
108
|
|
|
|
|
3040
|
|
|
5
|
108
|
|
|
108
|
|
515
|
no warnings qw( once void ); |
|
|
108
|
|
|
|
|
227
|
|
|
|
108
|
|
|
|
|
3235
|
|
|
6
|
108
|
|
|
108
|
|
510
|
|
|
|
108
|
|
|
|
|
232
|
|
|
|
108
|
|
|
|
|
11756
|
|
|
7
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Role"; |
|
8
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
|
9
|
|
|
|
|
|
|
our $MITE_VERSION = "0.010007"; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Mite keywords |
|
12
|
|
|
|
|
|
|
BEGIN { |
|
13
|
|
|
|
|
|
|
my ( $SHIM, $CALLER ) = |
|
14
|
108
|
|
|
108
|
|
921
|
( "Mite::Shim", "Mite::Trait::HasAttributes" ); |
|
15
|
|
|
|
|
|
|
( |
|
16
|
|
|
|
|
|
|
*after, *around, *before, |
|
17
|
|
|
|
|
|
|
*field, *has, *param, |
|
18
|
|
|
|
|
|
|
*requires, *signature_for, *with |
|
19
|
|
|
|
|
|
|
) |
|
20
|
|
|
|
|
|
|
= do { |
|
21
|
108
|
|
|
|
|
215
|
|
|
22
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
23
|
|
|
|
|
|
|
( |
|
24
|
108
|
|
|
108
|
|
699
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
|
|
108
|
|
|
|
|
258
|
|
|
|
108
|
|
|
|
|
22759
|
|
|
25
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) }, |
|
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) }, |
|
27
|
324
|
|
|
324
|
|
814
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
|
28
|
108
|
|
|
108
|
|
7523
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
|
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
|
30
|
108
|
|
|
108
|
|
254189
|
sub { }, |
|
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) }, |
|
32
|
|
|
|
108
|
|
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
|
33
|
108
|
|
|
108
|
|
151859
|
); |
|
34
|
0
|
|
|
0
|
|
0
|
} |
|
35
|
108
|
|
|
|
|
16903
|
|
|
36
|
|
|
|
|
|
|
# Mite imports |
|
37
|
|
|
|
|
|
|
BEGIN { |
|
38
|
|
|
|
|
|
|
require Scalar::Util; |
|
39
|
|
|
|
|
|
|
*STRICT = \&Mite::Shim::STRICT; |
|
40
|
|
|
|
|
|
|
*bare = \&Mite::Shim::bare; |
|
41
|
108
|
|
|
108
|
|
689
|
*blessed = \&Scalar::Util::blessed; |
|
42
|
108
|
|
|
|
|
391
|
*carp = \&Mite::Shim::carp; |
|
43
|
108
|
|
|
|
|
246
|
*confess = \&Mite::Shim::confess; |
|
44
|
108
|
|
|
|
|
282
|
*croak = \&Mite::Shim::croak; |
|
45
|
108
|
|
|
|
|
238
|
*false = \&Mite::Shim::false; |
|
46
|
108
|
|
|
|
|
283
|
*guard = \&Mite::Shim::guard; |
|
47
|
108
|
|
|
|
|
333
|
*lazy = \&Mite::Shim::lazy; |
|
48
|
108
|
|
|
|
|
691
|
*ro = \&Mite::Shim::ro; |
|
49
|
108
|
|
|
|
|
358
|
*rw = \&Mite::Shim::rw; |
|
50
|
108
|
|
|
|
|
215
|
*rwp = \&Mite::Shim::rwp; |
|
51
|
108
|
|
|
|
|
237
|
*true = \&Mite::Shim::true; |
|
52
|
108
|
|
|
|
|
233
|
} |
|
53
|
108
|
|
|
|
|
216
|
|
|
54
|
108
|
|
|
|
|
3714
|
# Gather metadata for constructor and destructor |
|
55
|
|
|
|
|
|
|
no strict 'refs'; |
|
56
|
|
|
|
|
|
|
my $class = shift; |
|
57
|
|
|
|
|
|
|
$class = ref($class) || $class; |
|
58
|
|
|
|
|
|
|
my $linear_isa = mro::get_linear_isa($class); |
|
59
|
108
|
|
|
108
|
|
611
|
return { |
|
|
108
|
|
|
|
|
230
|
|
|
|
108
|
|
|
|
|
45008
|
|
|
60
|
0
|
|
|
0
|
|
0
|
BUILD => [ |
|
61
|
0
|
|
0
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
62
|
0
|
|
|
|
|
0
|
map { "$_\::BUILD" } reverse @$linear_isa |
|
63
|
|
|
|
|
|
|
], |
|
64
|
|
|
|
|
|
|
DEMOLISH => [ |
|
65
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
66
|
0
|
|
|
|
|
0
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
67
|
|
|
|
|
|
|
], |
|
68
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
|
69
|
0
|
0
|
|
|
|
0
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
70
|
0
|
|
|
|
|
0
|
}; |
|
|
0
|
|
|
|
|
0
|
|
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# See UNIVERSAL |
|
74
|
|
|
|
|
|
|
my ( $self, $role ) = @_; |
|
75
|
|
|
|
|
|
|
our %DOES; |
|
76
|
|
|
|
|
|
|
return $DOES{$role} if exists $DOES{$role}; |
|
77
|
|
|
|
|
|
|
return 1 if $role eq __PACKAGE__; |
|
78
|
|
|
|
|
|
|
return $self->SUPER::DOES($role); |
|
79
|
0
|
|
|
0
|
0
|
0
|
} |
|
80
|
0
|
|
|
|
|
0
|
|
|
81
|
0
|
0
|
|
|
|
0
|
# Alias for Moose/Moo-compatibility |
|
82
|
0
|
0
|
|
|
|
0
|
shift->DOES(@_); |
|
83
|
0
|
|
|
|
|
0
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Method signatures |
|
86
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
0
|
0
|
0
|
$SIGNATURE_FOR{"add_attributes"} = sub { |
|
89
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my ( @out, %tmp, $tmp, $dtmp, @head ); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
@_ >= 1 |
|
94
|
|
|
|
|
|
|
or |
|
95
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
|
96
|
|
|
|
|
|
|
"add_attributes", scalar(@_), "expected exactly 1 parameters" ); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
|
101
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
|
102
|
|
|
|
|
|
|
or croak( |
|
103
|
|
|
|
|
|
|
"Type check failed in signature for add_attributes: %s should be %s", |
|
104
|
|
|
|
|
|
|
"\$_[0]", "Defined" |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $SLURPY = [ @_[ 0 .. $#_ ] ]; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Parameter $SLURPY (type: Slurpy[ArrayRef[Mite::Attribute]]) |
|
110
|
|
|
|
|
|
|
( |
|
111
|
|
|
|
|
|
|
do { |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
( ref($SLURPY) eq 'ARRAY' ) and do { |
|
114
|
|
|
|
|
|
|
my $ok = 1; |
|
115
|
|
|
|
|
|
|
for my $i ( @{$SLURPY} ) { |
|
116
|
|
|
|
|
|
|
( $ok = 0, last ) |
|
117
|
|
|
|
|
|
|
unless ( |
|
118
|
|
|
|
|
|
|
do { |
|
119
|
|
|
|
|
|
|
use Scalar::Util (); |
|
120
|
|
|
|
|
|
|
Scalar::Util::blessed($i) |
|
121
|
|
|
|
|
|
|
and $i->isa(q[Mite::Attribute]); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
); |
|
124
|
|
|
|
|
|
|
}; |
|
125
|
|
|
|
|
|
|
$ok; |
|
126
|
108
|
|
|
108
|
|
808
|
} |
|
|
108
|
|
|
|
|
243
|
|
|
|
108
|
|
|
|
|
19529
|
|
|
127
|
|
|
|
|
|
|
) |
|
128
|
|
|
|
|
|
|
or croak( |
|
129
|
|
|
|
|
|
|
"Type check failed in signature for add_attributes: %s should be %s", |
|
130
|
|
|
|
|
|
|
"\$SLURPY", "ArrayRef[Mite::Attribute]" |
|
131
|
|
|
|
|
|
|
); |
|
132
|
|
|
|
|
|
|
push( @out, $SLURPY ); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
do { @_ = ( @head, @out ); goto $__NEXT__ }; |
|
135
|
|
|
|
|
|
|
}; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
|
138
|
|
|
|
|
|
|
my ( $me, $target, $args ) = @_; |
|
139
|
|
|
|
|
|
|
our ( %CONSUMERS, @METHOD_MODIFIERS ); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Ensure a given target only consumes this role once. |
|
142
|
|
|
|
|
|
|
if ( exists $CONSUMERS{$target} ) { |
|
143
|
|
|
|
|
|
|
return; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
$CONSUMERS{$target} = 1; |
|
146
|
|
|
|
|
|
|
|
|
147
|
123
|
|
|
123
|
|
435
|
my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} }; |
|
148
|
123
|
|
|
|
|
242
|
return if $type ne 'Mite::Class'; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my @missing_methods; |
|
151
|
123
|
50
|
|
|
|
443
|
@missing_methods = grep( !$target->can($_), |
|
152
|
0
|
|
|
|
|
0
|
"_compile_mop_attributes", "_compile_pragmas", |
|
153
|
|
|
|
|
|
|
"_function_for_croak", "compilation_stages", |
|
154
|
123
|
|
|
|
|
385
|
"inject_mite_functions" ) |
|
155
|
|
|
|
|
|
|
and croak( "$me requires $target to implement methods: " . join q[, ], |
|
156
|
108
|
|
|
108
|
|
753
|
@missing_methods ); |
|
|
108
|
|
|
|
|
276
|
|
|
|
108
|
|
|
|
|
28620
|
|
|
|
123
|
|
|
|
|
223
|
|
|
|
123
|
|
|
|
|
228
|
|
|
|
123
|
|
|
|
|
529
|
|
|
157
|
123
|
50
|
|
|
|
465
|
|
|
158
|
|
|
|
|
|
|
my @roles = (); |
|
159
|
123
|
|
|
|
|
233
|
my %nextargs = %{ $args || {} }; |
|
160
|
123
|
50
|
|
|
|
2313
|
( $nextargs{-indirect} ||= 0 )++; |
|
161
|
|
|
|
|
|
|
croak("PANIC!") if $nextargs{-indirect} > 100; |
|
162
|
|
|
|
|
|
|
for my $role (@roles) { |
|
163
|
|
|
|
|
|
|
$role->__FINALIZE_APPLICATION__( $target, {%nextargs} ); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $shim = "Mite::Shim"; |
|
167
|
123
|
|
|
|
|
324
|
for my $modifier_rule (@METHOD_MODIFIERS) { |
|
168
|
123
|
50
|
|
|
|
249
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
|
|
123
|
|
|
|
|
906
|
|
|
169
|
123
|
|
50
|
|
|
931
|
my $handler = "HANDLE_$modification"; |
|
170
|
123
|
50
|
|
|
|
528
|
$shim->$handler( $target, "class", $names, $coderef ); |
|
171
|
123
|
|
|
|
|
382
|
} |
|
172
|
0
|
|
|
|
|
0
|
|
|
173
|
|
|
|
|
|
|
return; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
123
|
|
|
|
|
287
|
|
|
176
|
123
|
|
|
|
|
330
|
1; |
|
177
|
615
|
|
|
|
|
1663
|
|