line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Mite::Trait::HasRoles; |
4
|
109
|
|
|
109
|
|
956
|
use strict; |
|
109
|
|
|
|
|
364
|
|
|
109
|
|
|
|
|
3754
|
|
5
|
109
|
|
|
109
|
|
730
|
use warnings; |
|
109
|
|
|
|
|
371
|
|
|
109
|
|
|
|
|
3460
|
|
6
|
109
|
|
|
109
|
|
635
|
no warnings qw( once void ); |
|
109
|
|
|
|
|
318
|
|
|
109
|
|
|
|
|
14568
|
|
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
|
|
723
|
my ( $SHIM, $CALLER ) = |
15
|
|
|
|
|
|
|
( "Mite::Shim", "Mite::Trait::HasRoles" ); |
16
|
|
|
|
|
|
|
( |
17
|
|
|
|
|
|
|
*after, *around, *before, |
18
|
|
|
|
|
|
|
*field, *has, *param, |
19
|
|
|
|
|
|
|
*requires, *signature_for, *with |
20
|
|
|
|
|
|
|
) |
21
|
109
|
|
|
|
|
351
|
= do { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Mite::Shim; |
24
|
109
|
|
|
109
|
|
875
|
no warnings 'redefine'; |
|
109
|
|
|
|
|
304
|
|
|
109
|
|
|
|
|
26224
|
|
25
|
|
|
|
|
|
|
( |
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
27
|
218
|
|
|
218
|
|
899
|
sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) }, |
28
|
109
|
|
|
109
|
|
609
|
sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) }, |
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
30
|
218
|
|
|
218
|
|
180056
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
32
|
|
|
|
109
|
|
|
sub { }, |
33
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) }, |
34
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
35
|
109
|
|
|
|
|
21543
|
); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Mite imports |
40
|
|
|
|
|
|
|
BEGIN { |
41
|
109
|
|
|
109
|
|
895
|
require Scalar::Util; |
42
|
109
|
|
|
|
|
447
|
*STRICT = \&Mite::Shim::STRICT; |
43
|
109
|
|
|
|
|
364
|
*bare = \&Mite::Shim::bare; |
44
|
109
|
|
|
|
|
329
|
*blessed = \&Scalar::Util::blessed; |
45
|
109
|
|
|
|
|
329
|
*carp = \&Mite::Shim::carp; |
46
|
109
|
|
|
|
|
280
|
*confess = \&Mite::Shim::confess; |
47
|
109
|
|
|
|
|
263
|
*croak = \&Mite::Shim::croak; |
48
|
109
|
|
|
|
|
288
|
*false = \&Mite::Shim::false; |
49
|
109
|
|
|
|
|
338
|
*guard = \&Mite::Shim::guard; |
50
|
109
|
|
|
|
|
317
|
*lazy = \&Mite::Shim::lazy; |
51
|
109
|
|
|
|
|
325
|
*lock = \&Mite::Shim::lock; |
52
|
109
|
|
|
|
|
250
|
*ro = \&Mite::Shim::ro; |
53
|
109
|
|
|
|
|
292
|
*rw = \&Mite::Shim::rw; |
54
|
109
|
|
|
|
|
265
|
*rwp = \&Mite::Shim::rwp; |
55
|
109
|
|
|
|
|
245
|
*true = \&Mite::Shim::true; |
56
|
109
|
|
|
|
|
4368
|
*unlock = \&Mite::Shim::unlock; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
60
|
|
|
|
|
|
|
sub __META__ { |
61
|
109
|
|
|
109
|
|
846
|
no strict 'refs'; |
|
109
|
|
|
|
|
309
|
|
|
109
|
|
|
|
|
48489
|
|
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
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
99
|
|
|
|
|
|
|
sub __FINALIZE_APPLICATION__ { |
100
|
124
|
|
|
124
|
|
564
|
my ( $me, $target, $args ) = @_; |
101
|
124
|
|
|
|
|
308
|
our ( %CONSUMERS, @METHOD_MODIFIERS ); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Ensure a given target only consumes this role once. |
104
|
124
|
50
|
|
|
|
559
|
if ( exists $CONSUMERS{$target} ) { |
105
|
0
|
|
|
|
|
0
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
124
|
|
|
|
|
442
|
$CONSUMERS{$target} = 1; |
108
|
|
|
|
|
|
|
|
109
|
109
|
|
|
109
|
|
1071
|
my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} }; |
|
109
|
|
|
|
|
322
|
|
|
109
|
|
|
|
|
35956
|
|
|
124
|
|
|
|
|
314
|
|
|
124
|
|
|
|
|
299
|
|
|
124
|
|
|
|
|
704
|
|
110
|
124
|
50
|
|
|
|
619
|
return if $type ne 'Mite::Class'; |
111
|
|
|
|
|
|
|
|
112
|
124
|
|
|
|
|
273
|
my @missing_methods; |
113
|
124
|
50
|
|
|
|
2383
|
@missing_methods = grep( !$target->can($_), |
114
|
|
|
|
|
|
|
"_compile_mop_postamble", "compilation_stages", |
115
|
|
|
|
|
|
|
"inject_mite_functions", "native_methods", |
116
|
|
|
|
|
|
|
"source" ) |
117
|
|
|
|
|
|
|
and croak( "$me requires $target to implement methods: " . join q[, ], |
118
|
|
|
|
|
|
|
@missing_methods ); |
119
|
|
|
|
|
|
|
|
120
|
124
|
|
|
|
|
432
|
my @roles = (); |
121
|
124
|
50
|
|
|
|
325
|
my %nextargs = %{ $args || {} }; |
|
124
|
|
|
|
|
1458
|
|
122
|
124
|
|
50
|
|
|
1183
|
( $nextargs{-indirect} ||= 0 )++; |
123
|
124
|
50
|
|
|
|
660
|
croak("PANIC!") if $nextargs{-indirect} > 100; |
124
|
124
|
|
|
|
|
452
|
for my $role (@roles) { |
125
|
0
|
|
|
|
|
0
|
$role->__FINALIZE_APPLICATION__( $target, {%nextargs} ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
124
|
|
|
|
|
368
|
my $shim = "Mite::Shim"; |
129
|
124
|
|
|
|
|
411
|
for my $modifier_rule (@METHOD_MODIFIERS) { |
130
|
372
|
|
|
|
|
1341
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
131
|
372
|
|
|
|
|
946
|
my $handler = "HANDLE_$modification"; |
132
|
372
|
|
|
|
|
1653
|
$shim->$handler( $target, "class", $names, $coderef ); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
124
|
|
|
|
|
758
|
return; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
} |