line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use strict; |
4
|
15
|
|
|
15
|
|
104
|
use warnings; |
|
15
|
|
|
|
|
36
|
|
|
15
|
|
|
|
|
432
|
|
5
|
15
|
|
|
15
|
|
75
|
no warnings qw( once void ); |
|
15
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
480
|
|
6
|
15
|
|
|
15
|
|
71
|
|
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
1744
|
|
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
|
15
|
|
|
15
|
|
87
|
( "Mite::Shim", "Mite::Trait::HasRequiredMethods" ); |
15
|
|
|
|
|
|
|
( |
16
|
|
|
|
|
|
|
*after, *around, *before, |
17
|
|
|
|
|
|
|
*field, *has, *param, |
18
|
|
|
|
|
|
|
*requires, *signature_for, *with |
19
|
|
|
|
|
|
|
) |
20
|
|
|
|
|
|
|
= do { |
21
|
15
|
|
|
|
|
41
|
|
22
|
|
|
|
|
|
|
no warnings 'redefine'; |
23
|
|
|
|
|
|
|
( |
24
|
15
|
|
|
15
|
|
89
|
sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) }, |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
5007
|
|
25
|
|
|
|
|
|
|
sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) }, |
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) }, |
27
|
15
|
|
|
15
|
|
59
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
28
|
15
|
|
|
15
|
|
71
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
30
|
15
|
|
|
15
|
|
7890
|
sub { }, |
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) }, |
32
|
|
|
|
0
|
|
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
33
|
0
|
|
|
0
|
|
0
|
); |
34
|
0
|
|
|
0
|
|
0
|
} |
35
|
15
|
|
|
|
|
2301
|
|
36
|
|
|
|
|
|
|
# Mite imports |
37
|
|
|
|
|
|
|
BEGIN { |
38
|
|
|
|
|
|
|
require Scalar::Util; |
39
|
|
|
|
|
|
|
*STRICT = \&Mite::Shim::STRICT; |
40
|
|
|
|
|
|
|
*bare = \&Mite::Shim::bare; |
41
|
15
|
|
|
15
|
|
112
|
*blessed = \&Scalar::Util::blessed; |
42
|
15
|
|
|
|
|
45
|
*carp = \&Mite::Shim::carp; |
43
|
15
|
|
|
|
|
42
|
*confess = \&Mite::Shim::confess; |
44
|
15
|
|
|
|
|
34
|
*croak = \&Mite::Shim::croak; |
45
|
15
|
|
|
|
|
44
|
*false = \&Mite::Shim::false; |
46
|
15
|
|
|
|
|
48
|
*guard = \&Mite::Shim::guard; |
47
|
15
|
|
|
|
|
34
|
*lazy = \&Mite::Shim::lazy; |
48
|
15
|
|
|
|
|
33
|
*ro = \&Mite::Shim::ro; |
49
|
15
|
|
|
|
|
30
|
*rw = \&Mite::Shim::rw; |
50
|
15
|
|
|
|
|
34
|
*rwp = \&Mite::Shim::rwp; |
51
|
15
|
|
|
|
|
53
|
*true = \&Mite::Shim::true; |
52
|
15
|
|
|
|
|
28
|
} |
53
|
15
|
|
|
|
|
29
|
|
54
|
15
|
|
|
|
|
494
|
# 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
|
15
|
|
|
15
|
|
110
|
return { |
|
15
|
|
|
|
|
50
|
|
|
15
|
|
|
|
|
4901
|
|
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
|
|
|
|
|
|
|
# Callback which classes consuming this role will call |
86
|
|
|
|
|
|
|
my ( $me, $target, $args ) = @_; |
87
|
|
|
|
|
|
|
our ( %CONSUMERS, @METHOD_MODIFIERS ); |
88
|
0
|
|
|
0
|
0
|
0
|
|
89
|
|
|
|
|
|
|
# Ensure a given target only consumes this role once. |
90
|
|
|
|
|
|
|
if ( exists $CONSUMERS{$target} ) { |
91
|
|
|
|
|
|
|
return; |
92
|
|
|
|
|
|
|
} |
93
|
15
|
|
|
15
|
|
47
|
$CONSUMERS{$target} = 1; |
94
|
15
|
|
|
|
|
31
|
|
95
|
|
|
|
|
|
|
my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} }; |
96
|
|
|
|
|
|
|
return if $type ne 'Mite::Class'; |
97
|
15
|
50
|
|
|
|
78
|
|
98
|
0
|
|
|
|
|
0
|
my @missing_methods; |
99
|
|
|
|
|
|
|
@missing_methods = grep( !$target->can($_), |
100
|
15
|
|
|
|
|
41
|
"_compile_mop_required_methods", |
101
|
|
|
|
|
|
|
"inject_mite_functions" ) |
102
|
15
|
|
|
15
|
|
145
|
and croak( "$me requires $target to implement methods: " . join q[, ], |
|
15
|
|
|
|
|
40
|
|
|
15
|
|
|
|
|
3694
|
|
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
72
|
|
103
|
15
|
50
|
|
|
|
58
|
@missing_methods ); |
104
|
|
|
|
|
|
|
|
105
|
15
|
|
|
|
|
34
|
my @roles = (); |
106
|
15
|
50
|
|
|
|
380
|
my %nextargs = %{ $args || {} }; |
107
|
|
|
|
|
|
|
( $nextargs{-indirect} ||= 0 )++; |
108
|
|
|
|
|
|
|
croak("PANIC!") if $nextargs{-indirect} > 100; |
109
|
|
|
|
|
|
|
for my $role (@roles) { |
110
|
|
|
|
|
|
|
$role->__FINALIZE_APPLICATION__( $target, {%nextargs} ); |
111
|
|
|
|
|
|
|
} |
112
|
15
|
|
|
|
|
40
|
|
113
|
15
|
50
|
|
|
|
28
|
my $shim = "Mite::Shim"; |
|
15
|
|
|
|
|
165
|
|
114
|
15
|
|
50
|
|
|
104
|
for my $modifier_rule (@METHOD_MODIFIERS) { |
115
|
15
|
50
|
|
|
|
64
|
my ( $modification, $names, $coderef ) = @$modifier_rule; |
116
|
15
|
|
|
|
|
43
|
my $handler = "HANDLE_$modification"; |
117
|
0
|
|
|
|
|
0
|
$shim->$handler( $target, "class", $names, $coderef ); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
15
|
|
|
|
|
30
|
return; |
121
|
15
|
|
|
|
|
47
|
} |
122
|
30
|
|
|
|
|
75
|
|
123
|
30
|
|
|
|
|
65
|
1; |
124
|
30
|
|
|
|
|
121
|
|