line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
package MyTest3; |
3
|
2
|
|
|
2
|
|
16
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
10
|
no warnings qw( once void ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
412
|
|
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
|
2
|
|
|
2
|
|
10
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest3" ); |
13
|
2
|
|
|
|
|
2
|
( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do { |
14
|
|
|
|
|
|
|
package Mite::Shim; |
15
|
2
|
|
|
2
|
|
24
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
482
|
|
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
|
|
|
|
|
10
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
25
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
26
|
2
|
|
|
|
|
430
|
); |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Mite imports |
31
|
|
|
|
|
|
|
BEGIN { |
32
|
2
|
|
|
2
|
|
14
|
require Scalar::Util; |
33
|
2
|
|
|
|
|
6
|
*STRICT = \&Mite::Shim::STRICT; |
34
|
2
|
|
|
|
|
6
|
*bare = \&Mite::Shim::bare; |
35
|
2
|
|
|
|
|
4
|
*blessed = \&Scalar::Util::blessed; |
36
|
2
|
|
|
|
|
4
|
*carp = \&Mite::Shim::carp; |
37
|
2
|
|
|
|
|
4
|
*confess = \&Mite::Shim::confess; |
38
|
2
|
|
|
|
|
2
|
*croak = \&Mite::Shim::croak; |
39
|
2
|
|
|
|
|
4
|
*false = \&Mite::Shim::false; |
40
|
2
|
|
|
|
|
4
|
*guard = \&Mite::Shim::guard; |
41
|
2
|
|
|
|
|
4
|
*lazy = \&Mite::Shim::lazy; |
42
|
2
|
|
|
|
|
4
|
*lock = \&Mite::Shim::lock; |
43
|
2
|
|
|
|
|
6
|
*ro = \&Mite::Shim::ro; |
44
|
2
|
|
|
|
|
4
|
*rw = \&Mite::Shim::rw; |
45
|
2
|
|
|
|
|
2
|
*rwp = \&Mite::Shim::rwp; |
46
|
2
|
|
|
|
|
4
|
*true = \&Mite::Shim::true; |
47
|
2
|
|
|
|
|
86
|
*unlock = \&Mite::Shim::unlock; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Gather metadata for constructor and destructor |
51
|
|
|
|
|
|
|
sub __META__ { |
52
|
2
|
|
|
2
|
|
12
|
no strict 'refs'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1380
|
|
53
|
2
|
|
33
|
2
|
|
4
|
my $class = shift; $class = ref($class) || $class; |
|
2
|
|
|
|
|
28
|
|
54
|
2
|
|
|
|
|
12
|
my $linear_isa = mro::get_linear_isa( $class ); |
55
|
|
|
|
|
|
|
return { |
56
|
|
|
|
|
|
|
BUILD => [ |
57
|
4
|
50
|
|
|
|
4
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
4
|
|
|
|
|
20
|
|
|
0
|
|
|
|
|
0
|
|
58
|
4
|
|
|
|
|
14
|
map { "$_\::BUILD" } reverse @$linear_isa |
59
|
|
|
|
|
|
|
], |
60
|
|
|
|
|
|
|
DEMOLISH => [ |
61
|
4
|
50
|
|
|
|
6
|
map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () } |
|
4
|
|
|
|
|
54
|
|
|
0
|
|
|
|
|
0
|
|
62
|
2
|
|
|
|
|
4
|
map { "$_\::DEMOLISH" } @$linear_isa |
|
4
|
|
|
|
|
10
|
|
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
|
2
|
50
|
|
2
|
|
5564
|
my $class = ref($_[0]) ? ref(shift) : shift; |
73
|
2
|
|
33
|
|
|
18
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
74
|
2
|
|
|
|
|
6
|
my $self = bless {}, $class; |
75
|
2
|
50
|
|
|
|
10
|
my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
76
|
2
|
|
|
|
|
4
|
my $no_build = delete $args->{__no_BUILD__}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Call BUILD methods |
81
|
2
|
50
|
33
|
|
|
24
|
$self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } ); |
|
2
|
50
|
|
|
|
12
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Unrecognized parameters |
84
|
2
|
0
|
|
|
|
2
|
my @unknown = grep not( do { package MyTest3::__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
|
50
|
|
|
|
0
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
6
|
|
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
62
|
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
|
2
|
|
|
2
|
|
178
|
my $self = shift; |
99
|
2
|
|
33
|
|
|
8
|
my $class = ref( $self ) || $self; |
100
|
2
|
|
33
|
|
|
8
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
101
|
2
|
50
|
|
|
|
12
|
my $in_global_destruction = defined ${^GLOBAL_PHASE} |
102
|
|
|
|
|
|
|
? ${^GLOBAL_PHASE} eq 'DESTRUCT' |
103
|
|
|
|
|
|
|
: Devel::GlobalDestruction::in_global_destruction(); |
104
|
2
|
50
|
|
|
|
4
|
for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { |
|
2
|
|
|
|
|
26
|
|
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
|
2
|
|
|
2
|
|
52
|
no warnings 'misc'; # avoid (in cleanup) warnings |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1680
|
|
111
|
0
|
0
|
|
|
|
0
|
die $e if $e; # rethrow |
112
|
|
|
|
|
|
|
} |
113
|
2
|
|
|
|
|
10
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# See UNIVERSAL |
118
|
|
|
|
|
|
|
sub DOES { |
119
|
96
|
|
|
96
|
|
138
|
my ( $self, $role ) = @_; |
120
|
96
|
|
|
|
|
102
|
our %DOES; |
121
|
96
|
50
|
|
|
|
142
|
return $DOES{$role} if exists $DOES{$role}; |
122
|
96
|
50
|
|
|
|
136
|
return 1 if $role eq __PACKAGE__; |
123
|
96
|
50
|
0
|
|
|
144
|
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
|
96
|
|
|
|
|
400
|
return $self->SUPER::DOES( $role ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
130
|
|
|
|
|
|
|
sub does { |
131
|
48
|
|
|
48
|
|
5076
|
shift->DOES( @_ ); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Method signatures |
135
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$SIGNATURE_FOR{"foo"} = 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", "foo", 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 foo: %s should be %s", "\$_[0]", "Defined" ); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
%in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Parameter xxx (type: Int) |
155
|
|
|
|
|
|
|
exists( $in{"xxx"} ) |
156
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: xxx' ); |
157
|
|
|
|
|
|
|
(do { my $tmp = $in{"xxx"}; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ }) |
158
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"xxx\"}", "Int" ); |
159
|
|
|
|
|
|
|
$out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} ); |
160
|
|
|
|
|
|
|
delete( $in{"xxx"} ); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# Parameter yyy (type: Bool) |
163
|
|
|
|
|
|
|
exists( $in{"yyy"} ) |
164
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: yyy' ); |
165
|
|
|
|
|
|
|
$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"}; |
166
|
|
|
|
|
|
|
(!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1')) |
167
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"yyy\"}", "Bool" ); |
168
|
|
|
|
|
|
|
$out{"yyy"} = $tmp; |
169
|
|
|
|
|
|
|
delete( $in{"yyy"} ); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# Unrecognized parameters |
172
|
|
|
|
|
|
|
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; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
do { @_ = ( @head, bless( \%out, "MyTest3::__NAMED_ARGUMENTS__::foo" ) ); goto $__NEXT__ }; |
175
|
|
|
|
|
|
|
}; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
{ |
178
|
|
|
|
|
|
|
package MyTest3::__NAMED_ARGUMENTS__::foo; |
179
|
2
|
|
|
2
|
|
18
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
180
|
2
|
|
|
2
|
|
10
|
no warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
248
|
|
181
|
0
|
|
|
0
|
|
0
|
sub xxx { $_[0]{"xxx"} } |
182
|
0
|
|
|
0
|
|
0
|
sub yyy { $_[0]{"yyy"} } |
183
|
|
|
|
|
|
|
1; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
}{ |
189
|
|
|
|
|
|
|
package MyTest4; |
190
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
191
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
192
|
2
|
|
|
2
|
|
12
|
no warnings qw( once void ); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
256
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
195
|
|
|
|
|
|
|
our $MITE_SHIM = "Mite::Shim"; |
196
|
|
|
|
|
|
|
our $MITE_VERSION = "0.012000"; |
197
|
|
|
|
|
|
|
# Mite keywords |
198
|
|
|
|
|
|
|
BEGIN { |
199
|
2
|
|
|
2
|
|
8
|
my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest4" ); |
200
|
2
|
|
|
|
|
4
|
( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do { |
201
|
|
|
|
|
|
|
package Mite::Shim; |
202
|
2
|
|
|
2
|
|
12
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
460
|
|
203
|
|
|
|
|
|
|
( |
204
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
205
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
206
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
207
|
|
|
|
|
|
|
sub {}, |
208
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
209
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
210
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
211
|
2
|
|
|
|
|
10
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
212
|
0
|
|
|
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
213
|
2
|
|
|
|
|
376
|
); |
214
|
|
|
|
|
|
|
}; |
215
|
|
|
|
|
|
|
}; |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# Mite imports |
218
|
|
|
|
|
|
|
BEGIN { |
219
|
2
|
|
|
2
|
|
14
|
require Scalar::Util; |
220
|
2
|
|
|
|
|
6
|
*STRICT = \&Mite::Shim::STRICT; |
221
|
2
|
|
|
|
|
4
|
*bare = \&Mite::Shim::bare; |
222
|
2
|
|
|
|
|
4
|
*blessed = \&Scalar::Util::blessed; |
223
|
2
|
|
|
|
|
4
|
*carp = \&Mite::Shim::carp; |
224
|
2
|
|
|
|
|
2
|
*confess = \&Mite::Shim::confess; |
225
|
2
|
|
|
|
|
4
|
*croak = \&Mite::Shim::croak; |
226
|
2
|
|
|
|
|
4
|
*false = \&Mite::Shim::false; |
227
|
2
|
|
|
|
|
20
|
*guard = \&Mite::Shim::guard; |
228
|
2
|
|
|
|
|
4
|
*lazy = \&Mite::Shim::lazy; |
229
|
2
|
|
|
|
|
18
|
*lock = \&Mite::Shim::lock; |
230
|
2
|
|
|
|
|
4
|
*ro = \&Mite::Shim::ro; |
231
|
2
|
|
|
|
|
8
|
*rw = \&Mite::Shim::rw; |
232
|
2
|
|
|
|
|
2
|
*rwp = \&Mite::Shim::rwp; |
233
|
2
|
|
|
|
|
8
|
*true = \&Mite::Shim::true; |
234
|
2
|
|
|
|
|
58
|
*unlock = \&Mite::Shim::unlock; |
235
|
|
|
|
|
|
|
}; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
BEGIN { |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
2
|
|
|
2
|
|
12
|
use mro 'c3'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
38
|
|
242
|
2
|
|
|
2
|
|
100
|
our @ISA; |
243
|
2
|
|
|
|
|
1538
|
push @ISA, "MyTest3"; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
# See UNIVERSAL |
248
|
|
|
|
|
|
|
sub DOES { |
249
|
48
|
|
|
48
|
|
72
|
my ( $self, $role ) = @_; |
250
|
48
|
|
|
|
|
42
|
our %DOES; |
251
|
48
|
50
|
|
|
|
70
|
return $DOES{$role} if exists $DOES{$role}; |
252
|
48
|
50
|
|
|
|
70
|
return 1 if $role eq __PACKAGE__; |
253
|
48
|
50
|
0
|
|
|
76
|
if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) { |
|
|
|
33
|
|
|
|
|
254
|
0
|
0
|
0
|
|
|
0
|
$meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1; |
255
|
|
|
|
|
|
|
} |
256
|
48
|
|
|
|
|
68
|
return $self->SUPER::DOES( $role ); |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
260
|
|
|
|
|
|
|
sub does { |
261
|
48
|
|
|
48
|
|
3262
|
shift->DOES( @_ ); |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# Method signatures |
265
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
$SIGNATURE_FOR{"foo"} = sub { |
268
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
my ( %out, %in, %tmp, $tmp, $dtmp, @head ); |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
@_ == 2 && (ref($_[1]) eq 'HASH') |
273
|
|
|
|
|
|
|
or @_ % 2 == 1 && @_ == 7 |
274
|
|
|
|
|
|
|
or croak( "Wrong number of parameters in signature for %s: got %d, %s", "foo", scalar( @_ ), "that does not seem right" ); |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# Parameter $head[0] (type: Str) |
279
|
|
|
|
|
|
|
do { package Mite::Shim; defined($head[0]) and do { ref(\$head[0]) eq 'SCALAR' or ref(\(my $val = $head[0])) eq 'SCALAR' } } |
280
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_[0]", "Str" ); |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
%in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# Parameter xxx (type: Int) |
285
|
|
|
|
|
|
|
exists( $in{"xxx"} ) |
286
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: xxx' ); |
287
|
|
|
|
|
|
|
(do { my $tmp = $in{"xxx"}; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ }) |
288
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"xxx\"}", "Int" ); |
289
|
|
|
|
|
|
|
$out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} ); |
290
|
|
|
|
|
|
|
delete( $in{"xxx"} ); |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# Parameter yyy (type: Bool) |
293
|
|
|
|
|
|
|
exists( $in{"yyy"} ) |
294
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: yyy' ); |
295
|
|
|
|
|
|
|
$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"}; |
296
|
|
|
|
|
|
|
(!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1')) |
297
|
|
|
|
|
|
|
or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"yyy\"}", "Bool" ); |
298
|
|
|
|
|
|
|
$out{"yyy"} = $tmp; |
299
|
|
|
|
|
|
|
delete( $in{"yyy"} ); |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
# Parameter zzz (type: Any) |
302
|
|
|
|
|
|
|
exists( $in{"zzz"} ) |
303
|
|
|
|
|
|
|
or croak( "Failure in signature for foo: " . 'Missing required parameter: zzz' ); |
304
|
|
|
|
|
|
|
1; # ... nothing to do |
305
|
|
|
|
|
|
|
$out{"zzz"} = $in{"zzz"} if exists( $in{"zzz"} ); |
306
|
|
|
|
|
|
|
delete( $in{"zzz"} ); |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# Unrecognized parameters |
309
|
|
|
|
|
|
|
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; |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
do { @_ = ( @head, bless( \%out, "MyTest4::__NAMED_ARGUMENTS__::foo" ) ); goto $__NEXT__ }; |
312
|
|
|
|
|
|
|
}; |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
{ |
315
|
|
|
|
|
|
|
package MyTest4::__NAMED_ARGUMENTS__::foo; |
316
|
2
|
|
|
2
|
|
18
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
317
|
2
|
|
|
2
|
|
10
|
no warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
272
|
|
318
|
2
|
|
|
2
|
|
14
|
sub xxx { $_[0]{"xxx"} } |
319
|
2
|
|
|
2
|
|
4
|
sub yyy { $_[0]{"yyy"} } |
320
|
2
|
|
|
2
|
|
44
|
sub zzz { $_[0]{"zzz"} } |
321
|
|
|
|
|
|
|
1; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
1; |
326
|
|
|
|
|
|
|
} |