| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
1290822
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
75
|
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
244
|
|
|
3
|
|
|
|
|
|
|
package MooseX::Types::Meta; # git description: v0.02-11-g05b102e |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Moose types to check against Moose's meta objects |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
|
|
17
|
use MooseX::Types -declare => [qw( |
|
9
|
|
|
|
|
|
|
TypeConstraint |
|
10
|
|
|
|
|
|
|
TypeCoercion |
|
11
|
|
|
|
|
|
|
Attribute |
|
12
|
|
|
|
|
|
|
RoleAttribute |
|
13
|
|
|
|
|
|
|
Method |
|
14
|
|
|
|
|
|
|
Class |
|
15
|
|
|
|
|
|
|
Role |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
TypeEquals |
|
18
|
|
|
|
|
|
|
TypeOf |
|
19
|
|
|
|
|
|
|
SubtypeOf |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
StructuredTypeConstraint |
|
22
|
|
|
|
|
|
|
StructuredTypeCoercion |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
ParameterizableRole |
|
25
|
|
|
|
|
|
|
ParameterizedRole |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
711
|
)]; |
|
|
2
|
|
|
|
|
276704
|
|
|
28
|
2
|
|
|
2
|
|
22165
|
use Carp qw(confess); |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
193
|
|
|
29
|
2
|
|
|
2
|
|
12
|
use if MooseX::Types->VERSION >= 0.42, 'namespace::autoclean'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
105
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#pod =for :prelude |
|
32
|
|
|
|
|
|
|
#pod =for stopwords |
|
33
|
|
|
|
|
|
|
#pod ParameterizableRole |
|
34
|
|
|
|
|
|
|
#pod ParameterizedRole |
|
35
|
|
|
|
|
|
|
#pod RoleAttribute |
|
36
|
|
|
|
|
|
|
#pod StructuredTypeCoercion |
|
37
|
|
|
|
|
|
|
#pod StructuredTypeConstraint |
|
38
|
|
|
|
|
|
|
#pod TypeCoercion |
|
39
|
|
|
|
|
|
|
#pod TypeConstraint |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod =cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# TODO: ParameterizedType{Constraint,Coercion} ? |
|
44
|
|
|
|
|
|
|
# {Duck,Class,Enum,Parameterizable,Parameterized,Role,Union}TypeConstraint? |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#pod =type TypeConstraint |
|
47
|
|
|
|
|
|
|
#pod |
|
48
|
|
|
|
|
|
|
#pod A L<Moose::Meta::TypeConstraint>. |
|
49
|
|
|
|
|
|
|
#pod |
|
50
|
|
|
|
|
|
|
#pod =cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
class_type TypeConstraint, { class => 'Moose::Meta::TypeConstraint' }; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#pod =type TypeCoercion |
|
55
|
|
|
|
|
|
|
#pod |
|
56
|
|
|
|
|
|
|
#pod A L<Moose::Meta::TypeCoercion>. |
|
57
|
|
|
|
|
|
|
#pod |
|
58
|
|
|
|
|
|
|
#pod =cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
class_type TypeCoercion, { class => 'Moose::Meta::TypeCoercion' }; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#pod =type Attribute |
|
63
|
|
|
|
|
|
|
#pod |
|
64
|
|
|
|
|
|
|
#pod A L<Class::MOP::Attribute>. |
|
65
|
|
|
|
|
|
|
#pod |
|
66
|
|
|
|
|
|
|
#pod =cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
class_type Attribute, { class => 'Class::MOP::Attribute' }; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#pod =type RoleAttribute |
|
71
|
|
|
|
|
|
|
#pod |
|
72
|
|
|
|
|
|
|
#pod A L<Moose::Meta::Role::Attribute>. |
|
73
|
|
|
|
|
|
|
#pod |
|
74
|
|
|
|
|
|
|
#pod =cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
class_type RoleAttribute, { class => 'Moose::Meta::Role::Attribute' }; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#pod =type Method |
|
79
|
|
|
|
|
|
|
#pod |
|
80
|
|
|
|
|
|
|
#pod A L<Class::MOP::Method>. |
|
81
|
|
|
|
|
|
|
#pod |
|
82
|
|
|
|
|
|
|
#pod =cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
class_type Method, { class => 'Class::MOP::Method' }; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#pod =type Class |
|
87
|
|
|
|
|
|
|
#pod |
|
88
|
|
|
|
|
|
|
#pod A L<Class::MOP::Class>. |
|
89
|
|
|
|
|
|
|
#pod |
|
90
|
|
|
|
|
|
|
#pod =cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
class_type Class, { class => 'Class::MOP::Class' }; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#pod =type Role |
|
95
|
|
|
|
|
|
|
#pod |
|
96
|
|
|
|
|
|
|
#pod A L<Moose::Meta::Role>. |
|
97
|
|
|
|
|
|
|
#pod |
|
98
|
|
|
|
|
|
|
#pod =cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
class_type Role, { class => 'Moose::Meta::Role' }; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#pod =type StructuredTypeConstraint |
|
103
|
|
|
|
|
|
|
#pod |
|
104
|
|
|
|
|
|
|
#pod A L<MooseX::Meta::TypeConstraint::Structured>. |
|
105
|
|
|
|
|
|
|
#pod |
|
106
|
|
|
|
|
|
|
#pod =cut |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
class_type StructuredTypeConstraint, { |
|
109
|
|
|
|
|
|
|
class => 'MooseX::Meta::TypeConstraint::Structured', |
|
110
|
|
|
|
|
|
|
}; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#pod =type StructuredTypeCoercion |
|
113
|
|
|
|
|
|
|
#pod |
|
114
|
|
|
|
|
|
|
#pod A L<MooseX::Meta::TypeCoercion::Structured>. |
|
115
|
|
|
|
|
|
|
#pod |
|
116
|
|
|
|
|
|
|
#pod =cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
class_type StructuredTypeCoercion, { |
|
119
|
|
|
|
|
|
|
class => 'MooseX::Meta::TypeCoercion::Structured', |
|
120
|
|
|
|
|
|
|
}; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#pod =type ParameterizableRole |
|
123
|
|
|
|
|
|
|
#pod |
|
124
|
|
|
|
|
|
|
#pod A L<MooseX::Role::Parameterized::Meta::Role::Parameterizable>. |
|
125
|
|
|
|
|
|
|
#pod |
|
126
|
|
|
|
|
|
|
#pod =cut |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
if (eval { require MooseX::Role::Parameterized; MooseX::Role::Parameterized->VERSION('1.03') }) { |
|
129
|
|
|
|
|
|
|
role_type ParameterizableRole, { |
|
130
|
|
|
|
|
|
|
role => 'MooseX::Role::Parameterized::Meta::Trait::Parameterizable', |
|
131
|
|
|
|
|
|
|
}; |
|
132
|
|
|
|
|
|
|
} else { |
|
133
|
|
|
|
|
|
|
class_type ParameterizableRole, { |
|
134
|
|
|
|
|
|
|
class => 'MooseX::Role::Parameterized::Meta::Role::Parameterizable', |
|
135
|
|
|
|
|
|
|
}; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#pod =type ParameterizedRole |
|
139
|
|
|
|
|
|
|
#pod |
|
140
|
|
|
|
|
|
|
#pod A L<MooseX::Role::Parameterized::Meta::Role::Parameterized>. |
|
141
|
|
|
|
|
|
|
#pod |
|
142
|
|
|
|
|
|
|
#pod =cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
class_type ParameterizedRole, { |
|
145
|
|
|
|
|
|
|
class => 'MooseX::Role::Parameterized::Meta::Role::Parameterized', |
|
146
|
|
|
|
|
|
|
}; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
#pod =type TypeEquals[`x] |
|
149
|
|
|
|
|
|
|
#pod |
|
150
|
|
|
|
|
|
|
#pod A L<Moose::Meta::TypeConstraint>, that's equal to the type constraint |
|
151
|
|
|
|
|
|
|
#pod C<x>. |
|
152
|
|
|
|
|
|
|
#pod |
|
153
|
|
|
|
|
|
|
#pod =type TypeOf[`x] |
|
154
|
|
|
|
|
|
|
#pod |
|
155
|
|
|
|
|
|
|
#pod A L<Moose::Meta::TypeConstraint>, that's either equal to or a subtype |
|
156
|
|
|
|
|
|
|
#pod of the type constraint C<x>. |
|
157
|
|
|
|
|
|
|
#pod |
|
158
|
|
|
|
|
|
|
#pod =type SubtypeOf[`x] |
|
159
|
|
|
|
|
|
|
#pod |
|
160
|
|
|
|
|
|
|
#pod A L<Moose::Meta::TypeConstraint>, that's a subtype of the type |
|
161
|
|
|
|
|
|
|
#pod constraint C<x>. |
|
162
|
|
|
|
|
|
|
#pod |
|
163
|
|
|
|
|
|
|
#pod =cut |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
for my $t ( |
|
166
|
|
|
|
|
|
|
[ 'TypeEquals', 'equals' ], |
|
167
|
|
|
|
|
|
|
[ 'TypeOf', 'is_a_type_of' ], |
|
168
|
|
|
|
|
|
|
[ 'SubtypeOf', 'is_subtype_of' ], |
|
169
|
|
|
|
|
|
|
) { |
|
170
|
|
|
|
|
|
|
my ($name, $method) = @{ $t }; |
|
171
|
|
|
|
|
|
|
my $tc = Moose::Meta::TypeConstraint::Parameterizable->new( |
|
172
|
|
|
|
|
|
|
name => join(q{::} => __PACKAGE__, $name), |
|
173
|
|
|
|
|
|
|
package_defined_in => __PACKAGE__, |
|
174
|
|
|
|
|
|
|
parent => TypeConstraint, |
|
175
|
|
|
|
|
|
|
constraint_generator => sub { |
|
176
|
|
|
|
|
|
|
my ($type_parameter) = @_; |
|
177
|
|
|
|
|
|
|
confess "type parameter $type_parameter for $name is not a type constraint" |
|
178
|
|
|
|
|
|
|
unless TypeConstraint->check($type_parameter); |
|
179
|
|
|
|
|
|
|
return sub { |
|
180
|
|
|
|
|
|
|
my ($val) = @_; |
|
181
|
|
|
|
|
|
|
return $val->$method($type_parameter); |
|
182
|
|
|
|
|
|
|
}; |
|
183
|
|
|
|
|
|
|
}, |
|
184
|
|
|
|
|
|
|
); |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::register_type_constraint($tc); |
|
187
|
|
|
|
|
|
|
Moose::Util::TypeConstraints::add_parameterizable_type($tc); |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
__END__ |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=pod |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=encoding UTF-8 |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 NAME |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
MooseX::Types::Meta - Moose types to check against Moose's meta objects |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 VERSION |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
version 0.03 |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=for stopwords |
|
207
|
|
|
|
|
|
|
ParameterizableRole |
|
208
|
|
|
|
|
|
|
ParameterizedRole |
|
209
|
|
|
|
|
|
|
RoleAttribute |
|
210
|
|
|
|
|
|
|
StructuredTypeCoercion |
|
211
|
|
|
|
|
|
|
StructuredTypeConstraint |
|
212
|
|
|
|
|
|
|
TypeCoercion |
|
213
|
|
|
|
|
|
|
TypeConstraint |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 TYPES |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 TypeConstraint |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
A L<Moose::Meta::TypeConstraint>. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 TypeCoercion |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
A L<Moose::Meta::TypeCoercion>. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 Attribute |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
A L<Class::MOP::Attribute>. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 RoleAttribute |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
A L<Moose::Meta::Role::Attribute>. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 Method |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
A L<Class::MOP::Method>. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 Class |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
A L<Class::MOP::Class>. |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head2 Role |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
A L<Moose::Meta::Role>. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head2 StructuredTypeConstraint |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
A L<MooseX::Meta::TypeConstraint::Structured>. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 StructuredTypeCoercion |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
A L<MooseX::Meta::TypeCoercion::Structured>. |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head2 ParameterizableRole |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
A L<MooseX::Role::Parameterized::Meta::Role::Parameterizable>. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head2 ParameterizedRole |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
A L<MooseX::Role::Parameterized::Meta::Role::Parameterized>. |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 TypeEquals[`x] |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
A L<Moose::Meta::TypeConstraint>, that's equal to the type constraint |
|
264
|
|
|
|
|
|
|
C<x>. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head2 TypeOf[`x] |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
A L<Moose::Meta::TypeConstraint>, that's either equal to or a subtype |
|
269
|
|
|
|
|
|
|
of the type constraint C<x>. |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head2 SubtypeOf[`x] |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
A L<Moose::Meta::TypeConstraint>, that's a subtype of the type |
|
274
|
|
|
|
|
|
|
constraint C<x>. |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 SUPPORT |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Meta> |
|
279
|
|
|
|
|
|
|
(or L<bug-MooseX-Types-Meta@rt.cpan.org|mailto:bug-MooseX-Types-Meta@rt.cpan.org>). |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
|
282
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
|
285
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head1 AUTHOR |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=for stopwords Karen Etheridge |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Florian Ragwitz. |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
302
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |