line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Mite::Trait::HasAttributes; |
4
|
109
|
|
|
109
|
|
1021
|
use strict; |
|
109
|
|
|
|
|
363
|
|
|
109
|
|
|
|
|
3768
|
|
5
|
109
|
|
|
109
|
|
1345
|
use warnings; |
|
109
|
|
|
|
|
384
|
|
|
109
|
|
|
|
|
3588
|
|
6
|
109
|
|
|
109
|
|
664
|
no warnings qw( once void ); |
|
109
|
|
|
|
|
334
|
|
|
109
|
|
|
|
|
13701
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Role"; |
9
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
10
|
|
|
|
|
|
|
our $MITE_VERSION = "0.011000"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Mite keywords |
13
|
|
|
|
|
|
|
BEGIN { |
14
|
109
|
|
|
109
|
|
691
|
my ( $SHIM, $CALLER ) = |
15
|
|
|
|
|
|
|
( "Mite::Shim", "Mite::Trait::HasAttributes" ); |
16
|
|
|
|
|
|
|
( |
17
|
|
|
|
|
|
|
*after, *around, *before, |
18
|
|
|
|
|
|
|
*field, *has, *param, |
19
|
|
|
|
|
|
|
*requires, *signature_for, *with |
20
|
|
|
|
|
|
|
) |
21
|
109
|
|
|
|
|
379
|
= do { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Mite::Shim; |
24
|
109
|
|
|
109
|
|
1127
|
no warnings 'redefine'; |
|
109
|
|
|
|
|
309
|
|
|
109
|
|
|
|
|
26273
|
|
25
|
|
|
|
|
|
|
( |
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
27
|
327
|
|
|
327
|
|
1129
|
sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) }, |
28
|
109
|
|
|
109
|
|
9405
|
sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) }, |
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
30
|
109
|
|
|
109
|
|
322487
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
32
|
|
|
|
109
|
|
|
sub { }, |
33
|
109
|
|
|
109
|
|
196121
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) }, |
34
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
35
|
109
|
|
|
|
|
22025
|
); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Mite imports |
40
|
|
|
|
|
|
|
BEGIN { |
41
|
109
|
|
|
109
|
|
920
|
require Scalar::Util; |
42
|
109
|
|
|
|
|
453
|
*STRICT = \&Mite::Shim::STRICT; |
43
|
109
|
|
|
|
|
334
|
*bare = \&Mite::Shim::bare; |
44
|
109
|
|
|
|
|
396
|
*blessed = \&Scalar::Util::blessed; |
45
|
109
|
|
|
|
|
306
|
*carp = \&Mite::Shim::carp; |
46
|
109
|
|
|
|
|
307
|
*confess = \&Mite::Shim::confess; |
47
|
109
|
|
|
|
|
297
|
*croak = \&Mite::Shim::croak; |
48
|
109
|
|
|
|
|
266
|
*false = \&Mite::Shim::false; |
49
|
109
|
|
|
|
|
300
|
*guard = \&Mite::Shim::guard; |
50
|
109
|
|
|
|
|
253
|
*lazy = \&Mite::Shim::lazy; |
51
|
109
|
|
|
|
|
281
|
*lock = \&Mite::Shim::lock; |
52
|
109
|
|
|
|
|
289
|
*ro = \&Mite::Shim::ro; |
53
|
109
|
|
|
|
|
300
|
*rw = \&Mite::Shim::rw; |
54
|
109
|
|
|
|
|
270
|
*rwp = \&Mite::Shim::rwp; |
55
|
109
|
|
|
|
|
283
|
*true = \&Mite::Shim::true; |
56
|
109
|
|
|
|
|
4314
|
*unlock = \&Mite::Shim::unlock; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
60
|
|
|
|
|
|
|
sub __META__ { |
61
|
109
|
|
|
109
|
|
909
|
no strict 'refs'; |
|
109
|
|
|
|
|
340
|
|
|
109
|
|
|
|
|
59644
|
|
62
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
63
|
0
|
|
0
|
|
|
0
|
$class = ref($class) || $class; |
64
|
0
|
|
|
|
|
0
|
my $linear_isa = mro::get_linear_isa($class); |
65
|
|
|
|
|
|
|
return { |
66
|
|
|
|
|
|
|
BUILD => [ |
67
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
68
|
0
|
|
|
|
|
0
|
map { "$_\::BUILD" } reverse @$linear_isa |
69
|
|
|
|
|
|
|
], |
70
|
|
|
|
|
|
|
DEMOLISH => [ |
71
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
72
|
0
|
|
|
|
|
0
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
0
|
|
|
|
|
0
|
|
73
|
|
|
|
|
|
|
], |
74
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
75
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# See UNIVERSAL |
80
|
|
|
|
|
|
|
sub DOES { |
81
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $role ) = @_; |
82
|
0
|
|
|
|
|
0
|
our %DOES; |
83
|
0
|
0
|
|
|
|
0
|
return $DOES{$role} if exists $DOES{$role}; |
84
|
0
|
0
|
|
|
|
0
|
return 1 if $role eq __PACKAGE__; |
85
|
0
|
0
|
0
|
|
|
0
|
if ( $INC{'Moose/Util.pm'} |
|
|
|
0
|
|
|
|
|
86
|
|
|
|
|
|
|
and my $meta = Moose::Util::find_meta( ref $self or $self ) ) |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
0
|
0
|
|
|
0
|
$meta->can('does_role') and $meta->does_role($role) and return 1; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
0
|
return $self->SUPER::DOES($role); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
94
|
|
|
|
|
|
|
sub does { |
95
|
0
|
|
|
0
|
0
|
0
|
shift->DOES(@_); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Method signatures |
99
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$SIGNATURE_FOR{"add_attributes"} = sub { |
102
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my ( @out, %tmp, $tmp, $dtmp, @head ); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
@_ >= 1 |
107
|
|
|
|
|
|
|
or |
108
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
109
|
|
|
|
|
|
|
"add_attributes", scalar(@_), "expected exactly 1 parameters" ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
114
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
115
|
|
|
|
|
|
|
or croak( |
116
|
|
|
|
|
|
|
"Type check failed in signature for add_attributes: %s should be %s", |
117
|
|
|
|
|
|
|
"\$_[0]", "Defined" |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $SLURPY = [ @_[ 0 .. $#_ ] ]; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Parameter $SLURPY (type: Slurpy[ArrayRef[Mite::Attribute]]) |
123
|
|
|
|
|
|
|
( |
124
|
|
|
|
|
|
|
do { |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package Mite::Shim; |
127
|
|
|
|
|
|
|
( ref($SLURPY) eq 'ARRAY' ) and do { |
128
|
|
|
|
|
|
|
my $ok = 1; |
129
|
|
|
|
|
|
|
for my $i ( @{$SLURPY} ) { |
130
|
|
|
|
|
|
|
( $ok = 0, last ) |
131
|
|
|
|
|
|
|
unless ( |
132
|
|
|
|
|
|
|
do { |
133
|
109
|
|
|
109
|
|
1108
|
use Scalar::Util (); |
|
109
|
|
|
|
|
316
|
|
|
109
|
|
|
|
|
23375
|
|
134
|
|
|
|
|
|
|
Scalar::Util::blessed($i) |
135
|
|
|
|
|
|
|
and $i->isa(q[Mite::Attribute]); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
); |
138
|
|
|
|
|
|
|
}; |
139
|
|
|
|
|
|
|
$ok; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
) |
143
|
|
|
|
|
|
|
or croak( |
144
|
|
|
|
|
|
|
"Type check failed in signature for add_attributes: %s should be %s", |
145
|
|
|
|
|
|
|
"\$SLURPY", "ArrayRef[Mite::Attribute]" |
146
|
|
|
|
|
|
|
); |
147
|
|
|
|
|
|
|
push( @out, $SLURPY ); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
do { @_ = ( @head, @out ); goto $__NEXT__ }; |
150
|
|
|
|
|
|
|
}; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
153
|
|
|
|
|
|
|
sub __FINALIZE_APPLICATION__ { |
154
|
124
|
|
|
124
|
|
587
|
my ( $me, $target, $args ) = @_; |
155
|
124
|
|
|
|
|
274
|
our ( %CONSUMERS, @METHOD_MODIFIERS ); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Ensure a given target only consumes this role once. |
158
|
124
|
50
|
|
|
|
672
|
if ( exists $CONSUMERS{$target} ) { |
159
|
0
|
|
|
|
|
0
|
return; |
160
|
|
|
|
|
|
|
} |
161
|
124
|
|
|
|
|
441
|
$CONSUMERS{$target} = 1; |
162
|
|
|
|
|
|
|
|
163
|
109
|
|
|
109
|
|
1108
|
my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} }; |
|
109
|
|
|
|
|
361
|
|
|
109
|
|
|
|
|
34886
|
|
|
124
|
|
|
|
|
290
|
|
|
124
|
|
|
|
|
261
|
|
|
124
|
|
|
|
|
806
|
|
164
|
124
|
50
|
|
|
|
623
|
return if $type ne 'Mite::Class'; |
165
|
|
|
|
|
|
|
|
166
|
124
|
|
|
|
|
294
|
my @missing_methods; |
167
|
124
|
50
|
|
|
|
2872
|
@missing_methods = grep( !$target->can($_), |
168
|
|
|
|
|
|
|
"_compile_mop_attributes", "_compile_pragmas", |
169
|
|
|
|
|
|
|
"_function_for_croak", "compilation_stages", |
170
|
|
|
|
|
|
|
"inject_mite_functions" ) |
171
|
|
|
|
|
|
|
and croak( "$me requires $target to implement methods: " . join q[, ], |
172
|
|
|
|
|
|
|
@missing_methods ); |
173
|
|
|
|
|
|
|
|
174
|
124
|
|
|
|
|
468
|
my @roles = (); |
175
|
124
|
50
|
|
|
|
323
|
my %nextargs = %{ $args || {} }; |
|
124
|
|
|
|
|
1164
|
|
176
|
124
|
|
50
|
|
|
1321
|
( $nextargs{-indirect} ||= 0 )++; |
177
|
124
|
50
|
|
|
|
807
|
croak("PANIC!") if $nextargs{-indirect} > 100; |
178
|
124
|
|
|
|
|
497
|
for my $role (@roles) { |
179
|
0
|
|
|
|
|
0
|
$role->__FINALIZE_APPLICATION__( $target, {%nextargs} ); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
124
|
|
|
|
|
378
|
my $shim = "Mite::Shim"; |
183
|
124
|
|
|
|
|
503
|
for my $modifier_rule (@METHOD_MODIFIERS) { |
184
|
620
|
|
|
|
|
2488
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
185
|
620
|
|
|
|
|
1479
|
my $handler = "HANDLE_$modification"; |
186
|
620
|
|
|
|
|
2484
|
$shim->$handler( $target, "class", $names, $coderef ); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
124
|
|
|
|
|
749
|
return; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
193
|
|
|
|
|
|
|
} |