| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::Meta::Signature::Combined::Compiled; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
5428
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use HTML::Template::Pro; |
|
6
|
|
|
|
|
|
|
use MooseX::Meta::Signature::Named::Compiled; |
|
7
|
|
|
|
|
|
|
use MooseX::Meta::Signature::Positional::Compiled; |
|
8
|
|
|
|
|
|
|
use MooseX::Method::Constant; |
|
9
|
|
|
|
|
|
|
use MooseX::Method::Exception; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends qw/MooseX::Meta::Signature::Combined/; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with qw/MooseX::Meta::Signature::Compiled/; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:BERLE'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $compile_template = HTML::Template::Pro->new (scalarref => \<< 'EOF'); |
|
20
|
|
|
|
|
|
|
sub { |
|
21
|
|
|
|
|
|
|
my @values = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
<TMPL_VAR NAME="body"> |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return @values; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
EOF |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $as_perl_template = HTML::Template::Pro->new (scalarref => \<< 'EOF'); |
|
30
|
|
|
|
|
|
|
my @pos_values = (scalar @values <= <TMPL_VAR NAME="size"> ? @values : @values[0..(<TMPL_VAR NAME="size_min">)]); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @named_values = @values[<TMPL_VAR NAME="size">..$#values]; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
@values = @pos_values; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
<TMPL_VAR NAME="pos_body"> |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
@pos_values = @values; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
@values = @named_values; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
<TMPL_VAR NAME="named_body"> |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
@named_values = @values; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
@values = (@pos_values,@named_values); |
|
47
|
|
|
|
|
|
|
EOF |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _positional_metaclass { 'MooseX::Meta::Signature::Positional::Compiled' } |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _named_metaclass { 'MooseX::Meta::Signature::Named::Compiled' } |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
override new => sub { |
|
54
|
|
|
|
|
|
|
my $self = super; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$self->{params} = $self->_setup_params; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
return $self; |
|
59
|
|
|
|
|
|
|
}; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub validate { |
|
62
|
|
|
|
|
|
|
my $self = shift; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$self->{compiled_validator} ||= $self->compile; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return $self->{compiled_validator}->(@_); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub compile { |
|
70
|
|
|
|
|
|
|
my ($self) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$compile_template->param (body => $self->as_perl); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $coderef = eval $compile_template->output; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
MooseX::Method::Exception->throw ("Compilation error: $@") |
|
77
|
|
|
|
|
|
|
if $@; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
return $coderef; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub as_perl { |
|
83
|
|
|
|
|
|
|
my ($self) = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$as_perl_template->param ($self->{params}); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return $as_perl_template->output; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _setup_params { |
|
91
|
|
|
|
|
|
|
my ($self) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $params = { |
|
94
|
|
|
|
|
|
|
size => $self->{positional_signature_size}, |
|
95
|
|
|
|
|
|
|
size_min => $self->{positional_signature_size} - 1, |
|
96
|
|
|
|
|
|
|
pos_body => $self->{positional_signature}->as_perl, |
|
97
|
|
|
|
|
|
|
named_body => $self->{named_signature}->as_perl, |
|
98
|
|
|
|
|
|
|
}; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return $params; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(inline_constructor => 0); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 NAME |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
MooseX::Meta::Signature::Combined::Compiled - Compiled combined signature |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 WARNING |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This API is unstable, it may change at any time. This should not |
|
118
|
|
|
|
|
|
|
affect ordinary L<MooseX::Method> usage. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
use MooseX::Meta::Signature::Combined::Compiled; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $validator = MooseX::Meta::Signature::Combined::Compiled->new ({ isa => 'Int' })->compile; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
eval { |
|
127
|
|
|
|
|
|
|
$validator->(42); |
|
128
|
|
|
|
|
|
|
}; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 METHODS |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=over 4 |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item validate |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Overriden from the superclass. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item compile |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Produces a validator coderef. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item as_perl |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Spits out most of the perl code used to produce the coderef above. |
|
145
|
|
|
|
|
|
|
This is primarily used internally for inlining. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 BUGS |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Most software has bugs. This module probably isn't an exception. |
|
152
|
|
|
|
|
|
|
If you find a bug please either email me, or add the bug to cpan-RT. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Anders Nor Berle E<lt>debolaz@gmail.comE<gt> |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Copyright 2007 by Anders Nor Berle. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
163
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|