line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
package Thingy; |
3
|
1
|
|
|
1
|
|
13
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
69
|
|
4
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
110
|
|
5
|
1
|
|
|
1
|
|
11
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
261
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
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", "Thingy" ); |
13
|
1
|
|
|
|
|
7
|
( *after, *around, *before, *extends, *has, *signature_for, *with ) = do { |
14
|
|
|
|
|
|
|
package Mite::Shim; |
15
|
1
|
|
|
1
|
|
13
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
295
|
|
16
|
|
|
|
|
|
|
( |
17
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
18
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
19
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
20
|
|
|
|
|
|
|
sub {}, |
21
|
1
|
|
|
|
|
6
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
22
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
23
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
24
|
1
|
|
|
|
|
81
|
); |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
29
|
|
|
|
|
|
|
sub __META__ { |
30
|
1
|
|
|
1
|
|
13
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
835
|
|
31
|
1
|
|
33
|
1
|
|
2
|
my $class = shift; $class = ref($class) || $class; |
|
1
|
|
|
|
|
7
|
|
32
|
1
|
|
|
|
|
8
|
my $linear_isa = mro::get_linear_isa( $class ); |
33
|
|
|
|
|
|
|
return { |
34
|
|
|
|
|
|
|
BUILD => [ |
35
|
1
|
50
|
|
|
|
2
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
36
|
1
|
|
|
|
|
4
|
map { "$_\::BUILD" } reverse @$linear_isa |
37
|
|
|
|
|
|
|
], |
38
|
|
|
|
|
|
|
DEMOLISH => [ |
39
|
1
|
50
|
|
|
|
2
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
42
|
|
|
0
|
|
|
|
|
0
|
|
40
|
1
|
|
|
|
|
2
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
1
|
|
|
|
|
3
|
|
41
|
|
|
|
|
|
|
], |
42
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
43
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
49
|
|
|
|
|
|
|
sub new { |
50
|
1
|
50
|
|
1
|
|
151
|
my $class = ref($_[0]) ? ref(shift) : shift; |
51
|
1
|
|
33
|
|
|
12
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
52
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
53
|
1
|
50
|
|
|
|
6
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
54
|
1
|
|
|
|
|
2
|
my $no_build = delete $args->{__no_BUILD__}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Attribute xyz |
57
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 3 |
58
|
1
|
50
|
|
|
|
4
|
if ( exists $args->{"xyz"} ) { $self->{"xyz"} = $args->{"xyz"}; } ; |
|
1
|
|
|
|
|
5
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Call BUILD methods |
62
|
1
|
50
|
33
|
|
|
4
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
1
|
50
|
|
|
|
6
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Unrecognized parameters |
65
|
1
|
50
|
|
|
|
2
|
my @unknown = grep not( /\Axyz\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
9
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Used by constructor to call BUILD methods |
71
|
|
|
|
|
|
|
sub BUILDALL { |
72
|
0
|
|
|
0
|
|
0
|
my $class = ref( $_[0] ); |
73
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
74
|
0
|
0
|
|
|
|
0
|
$_->( @_ ) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Destructor should call DEMOLISH methods |
78
|
|
|
|
|
|
|
sub DESTROY { |
79
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
80
|
1
|
|
33
|
|
|
3
|
my $class = ref( $self ) || $self; |
81
|
1
|
|
33
|
|
|
3
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
82
|
1
|
50
|
|
|
|
3
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
83
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
84
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
85
|
1
|
50
|
|
|
|
2
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
1
|
|
|
|
|
4
|
|
86
|
0
|
|
|
|
|
0
|
my $e = do { |
87
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
88
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
89
|
0
|
|
|
|
|
0
|
$@; |
90
|
|
|
|
|
|
|
}; |
91
|
1
|
|
|
1
|
|
7
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
428
|
|
92
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
93
|
|
|
|
|
|
|
} |
94
|
1
|
|
|
|
|
11
|
return; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Accessors for xyz |
100
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 3 |
101
|
|
|
|
|
|
|
if ( $__XS ) { |
102
|
|
|
|
|
|
|
Class::XSAccessor->import( |
103
|
|
|
|
|
|
|
chained => 1, |
104
|
|
|
|
|
|
|
"getters" => { "xyz" => "xyz" }, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
else { |
108
|
|
|
|
|
|
|
*xyz = sub { @_ == 1 or Mite::Shim::croak( 'Reader "xyz" usage: $self->xyz()' ); $_[0]{"xyz"} }; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# See UNIVERSAL |
113
|
|
|
|
|
|
|
sub DOES { |
114
|
7
|
|
|
7
|
|
11
|
my ( $self, $role ) = @_; |
115
|
7
|
|
|
|
|
7
|
our %DOES; |
116
|
7
|
50
|
|
|
|
12
|
return $DOES{$role} if exists $DOES{$role}; |
117
|
7
|
50
|
|
|
|
14
|
return 1 if $role eq __PACKAGE__; |
118
|
7
|
50
|
0
|
|
|
10
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
119
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
120
|
|
|
|
|
|
|
} |
121
|
7
|
|
|
|
|
36
|
return $self->SUPER::DOES( $role ); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
125
|
|
|
|
|
|
|
sub does { |
126
|
7
|
|
|
7
|
|
661
|
shift->DOES( @_ ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
}{ |
131
|
|
|
|
|
|
|
package MyTest; |
132
|
1
|
|
|
1
|
|
19
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
35
|
|
133
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
134
|
1
|
|
|
1
|
|
6
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
134
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
137
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
138
|
|
|
|
|
|
|
our $MITE_VERSION = "0.012000"; |
139
|
|
|
|
|
|
|
# Mite keywords |
140
|
|
|
|
|
|
|
BEGIN { |
141
|
1
|
|
|
1
|
|
8
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest" ); |
142
|
1
|
|
|
|
|
1
|
( *after, *around, *before, *extends, *has, *signature_for, *with ) = do { |
143
|
|
|
|
|
|
|
package Mite::Shim; |
144
|
1
|
|
|
1
|
|
6
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
218
|
|
145
|
|
|
|
|
|
|
( |
146
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
147
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
148
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
149
|
|
|
|
|
|
|
sub {}, |
150
|
1
|
|
|
|
|
3
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
151
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
152
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
153
|
1
|
|
|
|
|
70
|
); |
154
|
|
|
|
|
|
|
}; |
155
|
|
|
|
|
|
|
}; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
158
|
|
|
|
|
|
|
sub __META__ { |
159
|
1
|
|
|
1
|
|
12
|
no strict 'refs'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
642
|
|
160
|
1
|
|
33
|
1
|
|
2
|
my $class = shift; $class = ref($class) || $class; |
|
1
|
|
|
|
|
4
|
|
161
|
1
|
|
|
|
|
4
|
my $linear_isa = mro::get_linear_isa( $class ); |
162
|
|
|
|
|
|
|
return { |
163
|
|
|
|
|
|
|
BUILD => [ |
164
|
1
|
50
|
|
|
|
2
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
7
|
|
|
0
|
|
|
|
|
0
|
|
165
|
1
|
|
|
|
|
12
|
map { "$_\::BUILD" } reverse @$linear_isa |
166
|
|
|
|
|
|
|
], |
167
|
|
|
|
|
|
|
DEMOLISH => [ |
168
|
1
|
50
|
|
|
|
1
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
13
|
|
|
0
|
|
|
|
|
0
|
|
169
|
1
|
|
|
|
|
3
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
1
|
|
|
|
|
3
|
|
170
|
|
|
|
|
|
|
], |
171
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
172
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
173
|
|
|
|
|
|
|
}; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
178
|
|
|
|
|
|
|
sub new { |
179
|
2
|
50
|
|
2
|
|
33
|
my $class = ref($_[0]) ? ref(shift) : shift; |
180
|
2
|
|
66
|
|
|
8
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
181
|
2
|
|
|
|
|
5
|
my $self = bless {}, $class; |
182
|
2
|
50
|
|
|
|
10
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
183
|
2
|
|
|
|
|
2
|
my $no_build = delete $args->{__no_BUILD__}; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# Attribute foo |
186
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 8 |
187
|
2
|
50
|
|
|
|
6
|
Mite::Shim::croak "Missing key in constructor: foo" unless exists $args->{"foo"}; |
188
|
2
|
|
|
|
|
5
|
$self->{"foo"} = $args->{"foo"}; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# Call BUILD methods |
192
|
2
|
50
|
33
|
|
|
6
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
2
|
50
|
|
|
|
18
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# Unrecognized parameters |
195
|
2
|
50
|
|
|
|
3
|
my @unknown = grep not( /\Afoo\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
7
|
|
196
|
|
|
|
|
|
|
|
197
|
2
|
|
|
|
|
12
|
return $self; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# Used by constructor to call BUILD methods |
201
|
|
|
|
|
|
|
sub BUILDALL { |
202
|
0
|
|
|
0
|
|
0
|
my $class = ref( $_[0] ); |
203
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
204
|
0
|
0
|
|
|
|
0
|
$_->( @_ ) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# Destructor should call DEMOLISH methods |
208
|
|
|
|
|
|
|
sub DESTROY { |
209
|
2
|
|
|
2
|
|
1510
|
my $self = shift; |
210
|
2
|
|
33
|
|
|
7
|
my $class = ref( $self ) || $self; |
211
|
2
|
|
33
|
|
|
16
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
212
|
2
|
50
|
|
|
|
14
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
213
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
214
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
215
|
2
|
50
|
|
|
|
3
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
2
|
|
|
|
|
7
|
|
216
|
0
|
|
|
|
|
0
|
my $e = do { |
217
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
218
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
219
|
0
|
|
|
|
|
0
|
$@; |
220
|
|
|
|
|
|
|
}; |
221
|
1
|
|
|
1
|
|
9
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
586
|
|
222
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
223
|
|
|
|
|
|
|
} |
224
|
2
|
|
|
|
|
7
|
return; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# Accessors for foo |
230
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 8 |
231
|
|
|
|
|
|
|
if ( $__XS ) { |
232
|
|
|
|
|
|
|
Class::XSAccessor->import( |
233
|
|
|
|
|
|
|
chained => 1, |
234
|
|
|
|
|
|
|
"accessors" => { "foo" => "foo" }, |
235
|
|
|
|
|
|
|
); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
else { |
238
|
|
|
|
|
|
|
*foo = sub { @_ > 1 ? do { $_[0]{"foo"} = $_[1]; $_[0]; } : ( $_[0]{"foo"} ) }; |
239
|
|
|
|
|
|
|
} |
240
|
3
|
100
|
66
|
3
|
|
13
|
sub _assert_blessed_foo { my $object = do { $_[0]{"foo"} }; require Scalar::Util && Scalar::Util::blessed($object) or Mite::Shim::croak( "foo is not a blessed object" ); $object } |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
49
|
|
|
2
|
|
|
|
|
35
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# Delegated methods for foo |
243
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 8 |
244
|
1
|
|
|
1
|
|
3
|
sub bar { shift->_assert_blessed_foo->xyz( @_ ) } |
245
|
2
|
|
|
2
|
|
15
|
sub xyz { shift->_assert_blessed_foo->xyz( @_ ) } |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# See UNIVERSAL |
249
|
|
|
|
|
|
|
sub DOES { |
250
|
7
|
|
|
7
|
|
12
|
my ( $self, $role ) = @_; |
251
|
7
|
|
|
|
|
8
|
our %DOES; |
252
|
7
|
50
|
|
|
|
15
|
return $DOES{$role} if exists $DOES{$role}; |
253
|
7
|
50
|
|
|
|
12
|
return 1 if $role eq __PACKAGE__; |
254
|
7
|
50
|
0
|
|
|
15
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
255
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
256
|
|
|
|
|
|
|
} |
257
|
7
|
|
|
|
|
35
|
return $self->SUPER::DOES( $role ); |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
261
|
|
|
|
|
|
|
sub does { |
262
|
7
|
|
|
7
|
|
860
|
shift->DOES( @_ ); |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
1; |
266
|
|
|
|
|
|
|
}{ |
267
|
|
|
|
|
|
|
package MyTest2; |
268
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
269
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
270
|
1
|
|
|
1
|
|
6
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
112
|
|
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
273
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
274
|
|
|
|
|
|
|
our $MITE_VERSION = "0.012000"; |
275
|
|
|
|
|
|
|
# Mite keywords |
276
|
|
|
|
|
|
|
BEGIN { |
277
|
1
|
|
|
1
|
|
5
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest2" ); |
278
|
1
|
|
|
|
|
3
|
( *after, *around, *before, *extends, *has, *signature_for, *with ) = do { |
279
|
|
|
|
|
|
|
package Mite::Shim; |
280
|
1
|
|
|
1
|
|
11
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
189
|
|
281
|
|
|
|
|
|
|
( |
282
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
283
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
284
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
285
|
|
|
|
|
|
|
sub {}, |
286
|
1
|
|
|
|
|
5
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
287
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
288
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
289
|
1
|
|
|
|
|
53
|
); |
290
|
|
|
|
|
|
|
}; |
291
|
|
|
|
|
|
|
}; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
294
|
|
|
|
|
|
|
sub __META__ { |
295
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
680
|
|
296
|
1
|
|
33
|
1
|
|
3
|
my $class = shift; $class = ref($class) || $class; |
|
1
|
|
|
|
|
47
|
|
297
|
1
|
|
|
|
|
8
|
my $linear_isa = mro::get_linear_isa( $class ); |
298
|
|
|
|
|
|
|
return { |
299
|
|
|
|
|
|
|
BUILD => [ |
300
|
1
|
50
|
|
|
|
2
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
7
|
|
|
0
|
|
|
|
|
0
|
|
301
|
1
|
|
|
|
|
4
|
map { "$_\::BUILD" } reverse @$linear_isa |
302
|
|
|
|
|
|
|
], |
303
|
|
|
|
|
|
|
DEMOLISH => [ |
304
|
1
|
50
|
|
|
|
9
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
1
|
|
|
|
|
23
|
|
|
0
|
|
|
|
|
0
|
|
305
|
1
|
|
|
|
|
2
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
1
|
|
|
|
|
3
|
|
306
|
|
|
|
|
|
|
], |
307
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
308
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
309
|
|
|
|
|
|
|
}; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
314
|
|
|
|
|
|
|
sub new { |
315
|
1
|
50
|
|
1
|
|
14
|
my $class = ref($_[0]) ? ref(shift) : shift; |
316
|
1
|
|
33
|
|
|
8
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
317
|
1
|
|
|
|
|
3
|
my $self = bless {}, $class; |
318
|
1
|
50
|
|
|
|
7
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
319
|
1
|
|
|
|
|
1
|
my $no_build = delete $args->{__no_BUILD__}; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
# Attribute foo |
322
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 18 |
323
|
1
|
50
|
|
|
|
4
|
Mite::Shim::croak "Missing key in constructor: foo" unless exists $args->{"foo"}; |
324
|
1
|
|
|
|
|
4
|
$self->{"foo"} = $args->{"foo"}; |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
# Call BUILD methods |
328
|
1
|
50
|
33
|
|
|
6
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
1
|
50
|
|
|
|
5
|
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# Unrecognized parameters |
331
|
1
|
50
|
|
|
|
1
|
my @unknown = grep not( /\Afoo\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
5
|
|
332
|
|
|
|
|
|
|
|
333
|
1
|
|
|
|
|
4
|
return $self; |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# Used by constructor to call BUILD methods |
337
|
|
|
|
|
|
|
sub BUILDALL { |
338
|
0
|
|
|
0
|
|
0
|
my $class = ref( $_[0] ); |
339
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
340
|
0
|
0
|
|
|
|
0
|
$_->( @_ ) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
# Destructor should call DEMOLISH methods |
344
|
|
|
|
|
|
|
sub DESTROY { |
345
|
1
|
|
|
1
|
|
581
|
my $self = shift; |
346
|
1
|
|
33
|
|
|
4
|
my $class = ref( $self ) || $self; |
347
|
1
|
|
33
|
|
|
4
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
348
|
1
|
50
|
|
|
|
4
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
349
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
350
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
351
|
1
|
50
|
|
|
|
2
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
1
|
|
|
|
|
4
|
|
352
|
0
|
|
|
|
|
0
|
my $e = do { |
353
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
354
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
355
|
0
|
|
|
|
|
0
|
$@; |
356
|
|
|
|
|
|
|
}; |
357
|
1
|
|
|
1
|
|
18
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
520
|
|
358
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
359
|
|
|
|
|
|
|
} |
360
|
1
|
|
|
|
|
4
|
return; |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# Accessors for foo |
366
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 18 |
367
|
|
|
|
|
|
|
if ( $__XS ) { |
368
|
|
|
|
|
|
|
Class::XSAccessor->import( |
369
|
|
|
|
|
|
|
chained => 1, |
370
|
|
|
|
|
|
|
"accessors" => { "foo" => "foo" }, |
371
|
|
|
|
|
|
|
); |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
else { |
374
|
|
|
|
|
|
|
*foo = sub { @_ > 1 ? do { $_[0]{"foo"} = $_[1]; $_[0]; } : ( $_[0]{"foo"} ) }; |
375
|
|
|
|
|
|
|
} |
376
|
2
|
50
|
33
|
2
|
|
2
|
sub _assert_blessed_foo { my $object = do { $_[0]{"foo"} }; require Scalar::Util && Scalar::Util::blessed($object) or Mite::Shim::croak( "foo is not a blessed object" ); $object } |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
13
|
|
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
# Delegated methods for foo |
379
|
|
|
|
|
|
|
# has declaration, file ../../../../tmp/4RD3UeTP8Z, line 18 |
380
|
1
|
|
|
1
|
|
3
|
sub foo_bar { shift->_assert_blessed_foo->xyz( @_ ) } |
381
|
1
|
|
|
1
|
|
6
|
sub foo_xyz { shift->_assert_blessed_foo->xyz( @_ ) } |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
# See UNIVERSAL |
385
|
|
|
|
|
|
|
sub DOES { |
386
|
7
|
|
|
7
|
|
13
|
my ( $self, $role ) = @_; |
387
|
7
|
|
|
|
|
6
|
our %DOES; |
388
|
7
|
50
|
|
|
|
25
|
return $DOES{$role} if exists $DOES{$role}; |
389
|
7
|
50
|
|
|
|
14
|
return 1 if $role eq __PACKAGE__; |
390
|
7
|
50
|
0
|
|
|
15
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
391
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
392
|
|
|
|
|
|
|
} |
393
|
7
|
|
|
|
|
35
|
return $self->SUPER::DOES( $role ); |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
397
|
|
|
|
|
|
|
sub does { |
398
|
7
|
|
|
7
|
|
842
|
shift->DOES( @_ ); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
1; |
402
|
|
|
|
|
|
|
} |