line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
package MyTest2; |
3
|
1
|
|
|
1
|
|
27
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
121
|
|
4
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
169
|
|
5
|
1
|
|
|
1
|
|
18
|
no warnings qw( once void ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
493
|
|
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
|
|
47
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest2" ); |
13
|
1
|
|
|
|
|
14
|
( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do { |
14
|
|
|
|
|
|
|
package Mite::Shim; |
15
|
1
|
|
|
1
|
|
19
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
478
|
|
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
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
22
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
23
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
24
|
2
|
|
|
|
|
25
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
25
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
26
|
1
|
|
|
|
|
507
|
); |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Mite imports |
31
|
|
|
|
|
|
|
BEGIN { |
32
|
1
|
|
|
1
|
|
44
|
require Scalar::Util; |
33
|
1
|
|
|
|
|
10
|
*STRICT = \&Mite::Shim::STRICT; |
34
|
1
|
|
|
|
|
3
|
*bare = \&Mite::Shim::bare; |
35
|
1
|
|
|
|
|
10
|
*blessed = \&Scalar::Util::blessed; |
36
|
1
|
|
|
|
|
6
|
*carp = \&Mite::Shim::carp; |
37
|
1
|
|
|
|
|
9
|
*confess = \&Mite::Shim::confess; |
38
|
1
|
|
|
|
|
4
|
*croak = \&Mite::Shim::croak; |
39
|
1
|
|
|
|
|
18
|
*false = \&Mite::Shim::false; |
40
|
1
|
|
|
|
|
12
|
*guard = \&Mite::Shim::guard; |
41
|
1
|
|
|
|
|
11
|
*lazy = \&Mite::Shim::lazy; |
42
|
1
|
|
|
|
|
3
|
*lock = \&Mite::Shim::lock; |
43
|
1
|
|
|
|
|
14
|
*ro = \&Mite::Shim::ro; |
44
|
1
|
|
|
|
|
9
|
*rw = \&Mite::Shim::rw; |
45
|
1
|
|
|
|
|
5
|
*rwp = \&Mite::Shim::rwp; |
46
|
1
|
|
|
|
|
3
|
*true = \&Mite::Shim::true; |
47
|
1
|
|
|
|
|
101
|
*unlock = \&Mite::Shim::unlock; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
51
|
|
|
|
|
|
|
sub __META__ { |
52
|
1
|
|
|
1
|
|
22
|
no strict 'refs'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1081
|
|
53
|
0
|
|
0
|
0
|
|
0
|
my $class = shift; $class = ref($class) || $class; |
|
0
|
|
|
|
|
0
|
|
54
|
0
|
|
|
|
|
0
|
my $linear_isa = mro::get_linear_isa( $class ); |
55
|
|
|
|
|
|
|
return { |
56
|
|
|
|
|
|
|
BUILD => [ |
57
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
58
|
0
|
|
|
|
|
0
|
map { "$_\::BUILD" } reverse @$linear_isa |
59
|
|
|
|
|
|
|
], |
60
|
|
|
|
|
|
|
DEMOLISH => [ |
61
|
0
|
0
|
|
|
|
0
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
62
|
0
|
|
|
|
|
0
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
], |
64
|
|
|
|
|
|
|
HAS_BUILDARGS => $class->can('BUILDARGS'), |
65
|
|
|
|
|
|
|
HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'), |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
71
|
|
|
|
|
|
|
sub new { |
72
|
0
|
0
|
|
0
|
|
0
|
my $class = ref($_[0]) ? ref(shift) : shift; |
73
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
74
|
0
|
|
|
|
|
0
|
my $self = bless {}, $class; |
75
|
0
|
0
|
|
|
|
0
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
0
|
|
|
|
0
|
|
76
|
0
|
|
|
|
|
0
|
my $no_build = delete $args->{__no_BUILD__}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Call BUILD methods |
81
|
0
|
0
|
0
|
|
|
0
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
0
|
0
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Unrecognized parameters |
84
|
0
|
0
|
|
|
|
0
|
my @unknown = grep not( do { package MyTest2::__SAFE_NAMESPACE__; defined($_) and do { ref(\$_) eq 'SCALAR' or ref(\(my $val = $_)) eq 'SCALAR' } } ), keys %{$args}; @unknown and croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
return $self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Used by constructor to call BUILD methods |
90
|
|
|
|
|
|
|
sub BUILDALL { |
91
|
0
|
|
|
0
|
|
0
|
my $class = ref( $_[0] ); |
92
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
93
|
0
|
0
|
|
|
|
0
|
$_->( @_ ) for @{ $meta->{BUILD} || [] }; |
|
0
|
|
|
|
|
0
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Destructor should call DEMOLISH methods |
97
|
|
|
|
|
|
|
sub DESTROY { |
98
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
99
|
0
|
|
0
|
|
|
0
|
my $class = ref( $self ) || $self; |
100
|
0
|
|
0
|
|
|
0
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
101
|
0
|
0
|
|
|
|
0
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
102
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
103
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
104
|
0
|
0
|
|
|
|
0
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
0
|
|
|
|
|
0
|
|
105
|
0
|
|
|
|
|
0
|
my $e = do { |
106
|
0
|
|
|
|
|
0
|
local ( $?, $@ ); |
107
|
0
|
|
|
|
|
0
|
eval { $demolisher->( $self, $in_global_destruction ) }; |
|
0
|
|
|
|
|
0
|
|
108
|
0
|
|
|
|
|
0
|
$@; |
109
|
|
|
|
|
|
|
}; |
110
|
1
|
|
|
1
|
|
9
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
713
|
|
111
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
0
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# See UNIVERSAL |
118
|
|
|
|
|
|
|
sub DOES { |
119
|
24
|
|
|
24
|
|
32
|
my ( $self, $role ) = @_; |
120
|
24
|
|
|
|
|
29
|
our %DOES; |
121
|
24
|
50
|
|
|
|
43
|
return $DOES{$role} if exists $DOES{$role}; |
122
|
24
|
50
|
|
|
|
34
|
return 1 if $role eq __PACKAGE__; |
123
|
24
|
50
|
0
|
|
|
45
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
124
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
125
|
|
|
|
|
|
|
} |
126
|
24
|
|
|
|
|
104
|
return $self->SUPER::DOES( $role ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
130
|
|
|
|
|
|
|
sub does { |
131
|
24
|
|
|
24
|
|
1380
|
shift->DOES( @_ ); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Method signatures |
135
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$SIGNATURE_FOR{"bar"} = sub { |
138
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my ( %out, %in, %tmp, $tmp, $dtmp, @head ); |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
@_ == 2 && (ref($_[1]) eq 'HASH') |
143
|
|
|
|
|
|
|
or @_ % 2 == 1 && @_ == 5 |
144
|
|
|
|
|
|
|
or croak( "Wrong number of parameters in signature for %s: got %d, %s", "bar", scalar( @_ ), "that does not seem right" ); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
149
|
|
|
|
|
|
|
(defined($head[0])) |
150
|
|
|
|
|
|
|
or croak( "Type check failed in signature for bar: %s should be %s", "\$_[0]", "Defined" ); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
%in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Parameter xxx (type: Num) |
155
|
|
|
|
|
|
|
exists( $in{"xxx"} ) |
156
|
|
|
|
|
|
|
or croak( "Failure in signature for bar: " . 'Missing required parameter: xxx' ); |
157
|
1
|
|
|
1
|
|
23
|
(do { package Mite::Shim; use Scalar::Util (); defined($in{"xxx"}) && !ref($in{"xxx"}) && Scalar::Util::looks_like_number($in{"xxx"}) }) |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
140
|
|
158
|
|
|
|
|
|
|
or croak( "Type check failed in signature for bar: %s should be %s", "\$_{\"xxx\"}", "Num" ); |
159
|
|
|
|
|
|
|
$out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} ); |
160
|
|
|
|
|
|
|
delete( $in{"xxx"} ); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# Parameter yyy (type: Object) |
163
|
|
|
|
|
|
|
exists( $in{"yyy"} ) |
164
|
|
|
|
|
|
|
or croak( "Failure in signature for bar: " . 'Missing required parameter: yyy' ); |
165
|
1
|
|
|
1
|
|
12
|
(do { package Mite::Shim; use Scalar::Util (); Scalar::Util::blessed($in{"yyy"}) }) |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
309
|
|
166
|
|
|
|
|
|
|
or croak( "Type check failed in signature for bar: %s should be %s", "\$_{\"yyy\"}", "Object" ); |
167
|
|
|
|
|
|
|
$out{"yyy"} = $in{"yyy"} if exists( $in{"yyy"} ); |
168
|
|
|
|
|
|
|
delete( $in{"yyy"} ); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# Unrecognized parameters |
171
|
|
|
|
|
|
|
croak( "Failure in signature for bar: " . sprintf( q{Unrecognized parameter%s: %s}, keys( %in ) > 1 ? q{s} : q{}, join( q{, }, sort keys %in ) ) ) if keys %in; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
do { @_ = ( @head, bless( \%out, "MyTest2::__NAMED_ARGUMENTS__::bar" ) ); goto $__NEXT__ }; |
174
|
|
|
|
|
|
|
}; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
{ |
177
|
|
|
|
|
|
|
package MyTest2::__NAMED_ARGUMENTS__::bar; |
178
|
1
|
|
|
1
|
|
14
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
41
|
|
179
|
1
|
|
|
1
|
|
7
|
no warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
868
|
|
180
|
0
|
|
|
0
|
|
0
|
sub xxx { $_[0]{"xxx"} } |
181
|
0
|
|
|
0
|
|
0
|
sub yyy { $_[0]{"yyy"} } |
182
|
|
|
|
|
|
|
1; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
$SIGNATURE_FOR{"foo"} = sub { |
186
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my ( %out, %in, %tmp, $tmp, $dtmp, @head ); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
@_ == 2 && (ref($_[1]) eq 'HASH') |
191
|
|
|
|
|
|
|
or @_ % 2 == 1 && @_ == 5 |
192
|
|
|
|
|
|
|
or croak( "Wrong number of parameters in signature for %s: got %d, %s", "foo", scalar( @_ ), "that does not seem right" ); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
197
|
|
|
|
|
|
|
(defined($head[0])) |
198
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_[0]", "Defined" ); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
%in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# Parameter xxx (type: Int) |
203
|
|
|
|
|
|
|
exists( $in{"xxx"} ) |
204
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: xxx' ); |
205
|
|
|
|
|
|
|
(do { my $tmp = $in{"xxx"}; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ }) |
206
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"xxx\"}", "Int" ); |
207
|
|
|
|
|
|
|
$out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} ); |
208
|
|
|
|
|
|
|
delete( $in{"xxx"} ); |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# Parameter yyy (type: Bool) |
211
|
|
|
|
|
|
|
exists( $in{"yyy"} ) |
212
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: yyy' ); |
213
|
|
|
|
|
|
|
$tmp = (do { package Mite::Shim; !ref $in{"yyy"} and (!defined $in{"yyy"} or $in{"yyy"} eq q() or $in{"yyy"} eq '0' or $in{"yyy"} eq '1') }) ? $in{"yyy"} : ((!!1)) ? scalar(do { local $_ = $in{"yyy"}; !!$_ }) : $in{"yyy"}; |
214
|
|
|
|
|
|
|
(!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1')) |
215
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"yyy\"}", "Bool" ); |
216
|
|
|
|
|
|
|
$out{"yyy"} = $tmp; |
217
|
|
|
|
|
|
|
delete( $in{"yyy"} ); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# Unrecognized parameters |
220
|
|
|
|
|
|
|
croak( "Failure in signature for foo: " . sprintf( q{Unrecognized parameter%s: %s}, keys( %in ) > 1 ? q{s} : q{}, join( q{, }, sort keys %in ) ) ) if keys %in; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
do { @_ = ( @head, bless( \%out, "MyTest2::__NAMED_ARGUMENTS__::foo" ) ); goto $__NEXT__ }; |
223
|
|
|
|
|
|
|
}; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
{ |
226
|
|
|
|
|
|
|
package MyTest2::__NAMED_ARGUMENTS__::foo; |
227
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
228
|
1
|
|
|
1
|
|
5
|
no warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
159
|
|
229
|
2
|
|
|
2
|
|
12
|
sub xxx { $_[0]{"xxx"} } |
230
|
2
|
|
|
2
|
|
50
|
sub yyy { $_[0]{"yyy"} } |
231
|
|
|
|
|
|
|
1; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1; |
236
|
|
|
|
|
|
|
} |