Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role/Application/ToClass.pm |
Statements | Executed 288 statements in 2.11ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
4 | 1 | 1 | 473µs | 5.80ms | apply_methods | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 181µs | 15.3ms | apply | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 130µs | 6.56ms | apply_attributes | Moose::Meta::Role::Application::ToClass::
12 | 3 | 1 | 98µs | 250µs | apply_method_modifiers | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 85µs | 1.42ms | check_role_exclusions | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 72µs | 530µs | check_required_methods | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 38µs | 102µs | apply_override_method_modifiers | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 10µs | 10µs | BEGIN@2 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 10µs | 53µs | BEGIN@13 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 9µs | 14µs | BEGIN@9 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 9µs | 220µs | BEGIN@14 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 9µs | 25µs | BEGIN@10 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 9µs | 84µs | BEGIN@17 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 577µs | BEGIN@11 | Moose::Meta::Role::Application::ToClass::
1 | 1 | 1 | 8µs | 37µs | BEGIN@15 | Moose::Meta::Role::Application::ToClass::
4 | 1 | 1 | 7µs | 7µs | check_required_attributes | Moose::Meta::Role::Application::ToClass::
0 | 0 | 0 | 0s | 0s | __ANON__[:127] | Moose::Meta::Role::Application::ToClass::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Role::Application::ToClass; | ||||
2 | # spent 10µs within Moose::Meta::Role::Application::ToClass::BEGIN@2 which was called:
# once (10µs+0s) by Moose::BEGIN@40 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::Role::Application::ToClass::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 27µs | 1 | 10µs | } # spent 10µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@2 |
5 | { | ||||
6 | 2 | 2µs | $Moose::Meta::Role::Application::ToClass::VERSION = '2.0602'; | ||
7 | } | ||||
8 | |||||
9 | 3 | 19µs | 2 | 19µs | # spent 14µs (9+5) within Moose::Meta::Role::Application::ToClass::BEGIN@9 which was called:
# once (9µs+5µs) by Moose::BEGIN@40 at line 9 # spent 14µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@9
# spent 5µs making 1 call to strict::import |
10 | 3 | 19µs | 2 | 41µs | # spent 25µs (9+16) within Moose::Meta::Role::Application::ToClass::BEGIN@10 which was called:
# once (9µs+16µs) by Moose::BEGIN@40 at line 10 # spent 25µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@10
# spent 16µs making 1 call to warnings::import |
11 | 3 | 28µs | 2 | 1.15ms | # spent 577µs (8+569) within Moose::Meta::Role::Application::ToClass::BEGIN@11 which was called:
# once (8µs+569µs) by Moose::BEGIN@40 at line 11 # spent 577µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@11
# spent 568µs making 1 call to metaclass::import |
12 | |||||
13 | 3 | 23µs | 2 | 96µs | # spent 53µs (10+43) within Moose::Meta::Role::Application::ToClass::BEGIN@13 which was called:
# once (10µs+43µs) by Moose::BEGIN@40 at line 13 # spent 53µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@13
# spent 43µs making 1 call to Exporter::import |
14 | 3 | 27µs | 2 | 432µs | # spent 220µs (9+211) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called:
# once (9µs+211µs) by Moose::BEGIN@40 at line 14 # spent 220µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14
# spent 211µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756] |
15 | 3 | 27µs | 2 | 67µs | # spent 37µs (8+30) within Moose::Meta::Role::Application::ToClass::BEGIN@15 which was called:
# once (8µs+30µs) by Moose::BEGIN@40 at line 15 # spent 37µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@15
# spent 30µs making 1 call to Exporter::import |
16 | |||||
17 | 3 | 825µs | 2 | 159µs | # spent 84µs (9+75) within Moose::Meta::Role::Application::ToClass::BEGIN@17 which was called:
# once (9µs+75µs) by Moose::BEGIN@40 at line 17 # spent 84µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@17
# spent 75µs making 1 call to base::import |
18 | |||||
19 | 1 | 7µs | 3 | 508µs | __PACKAGE__->meta->add_attribute('role' => ( # spent 473µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 25µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 10µs making 1 call to Class::MOP::_definition_context |
20 | reader => 'role', | ||||
21 | Class::MOP::_definition_context(), | ||||
22 | )); | ||||
23 | |||||
24 | 1 | 4µs | 3 | 300µs | __PACKAGE__->meta->add_attribute('class' => ( # spent 283µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 12µs making 1 call to Moose::Meta::Role::Application::ToClass::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
25 | accessor => 'class', | ||||
26 | Class::MOP::_definition_context(), | ||||
27 | )); | ||||
28 | |||||
29 | # spent 15.3ms (181µs+15.1) within Moose::Meta::Role::Application::ToClass::apply which was called 4 times, avg 3.82ms/call:
# 4 times (181µs+15.1ms) by Moose::Meta::Role::apply at line 470 of Moose/Meta/Role.pm, avg 3.82ms/call | ||||
30 | 24 | 186µs | my ($self, $role, $class) = @_; | ||
31 | |||||
32 | # We need weak_ref in CMOP :( | ||||
33 | 4 | 8µs | weaken($self->{role} = $role); # spent 8µs making 4 calls to Scalar::Util::weaken, avg 2µs/call | ||
34 | 4 | 7µs | weaken($self->{class} = $class); # spent 7µs making 4 calls to Scalar::Util::weaken, avg 2µs/call | ||
35 | |||||
36 | 4 | 14.9ms | $self->SUPER::apply($role, $class); # spent 14.9ms making 4 calls to Moose::Meta::Role::Application::apply, avg 3.73ms/call | ||
37 | |||||
38 | 4 | 84µs | $class->add_role($role); # spent 84µs making 4 calls to Moose::Meta::Class::add_role, avg 21µs/call | ||
39 | 4 | 85µs | $class->add_role_application($self); # spent 85µs making 4 calls to Moose::Meta::Class::add_role_application, avg 21µs/call | ||
40 | } | ||||
41 | |||||
42 | # spent 1.42ms (85µs+1.34) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 4 times, avg 355µs/call:
# 4 times (85µs+1.34ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 355µs/call | ||||
43 | 12 | 135µs | my ($self, $role, $class) = @_; | ||
44 | 8 | 1.29ms | if ($class->excludes_role($role->name)) { # spent 1.28ms making 4 calls to Moose::Meta::Class::excludes_role, avg 320µs/call
# spent 10µs making 4 calls to Class::MOP::Package::name, avg 2µs/call | ||
45 | $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'"); | ||||
46 | } | ||||
47 | 4 | 47µs | foreach my $excluded_role_name ($role->get_excluded_roles_list) { # spent 47µs making 4 calls to Moose::Meta::Role::get_excluded_roles_list, avg 12µs/call | ||
48 | if ($class->does_role($excluded_role_name)) { | ||||
49 | $class->throw_error("The class " . $class->name . " does the excluded role '$excluded_role_name'"); | ||||
50 | } | ||||
51 | } | ||||
52 | } | ||||
53 | |||||
54 | # spent 530µs (72+457) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 4 times, avg 132µs/call:
# 4 times (72µs+457µs) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 132µs/call | ||||
55 | 20 | 42µs | my ($self, $role, $class) = @_; | ||
56 | |||||
57 | my @missing; | ||||
58 | my @is_attr; | ||||
59 | |||||
60 | # NOTE: | ||||
61 | # we might need to move this down below the | ||||
62 | # the attributes so that we can require any | ||||
63 | # attribute accessors. However I am thinking | ||||
64 | # that maybe those are somehow exempt from | ||||
65 | # the require methods stuff. | ||||
66 | 4 | 51µs | foreach my $required_method ($role->get_required_method_list) { # spent 51µs making 4 calls to Moose::Meta::Role::get_required_method_list, avg 13µs/call | ||
67 | 8 | 19µs | 4 | 9µs | my $required_method_name = $required_method->name; # spent 9µs making 4 calls to Moose::Meta::Role::Method::Required::name, avg 2µs/call |
68 | |||||
69 | 4 | 398µs | if (!$class->find_method_by_name($required_method_name)) { # spent 398µs making 4 calls to Class::MOP::Class::find_method_by_name, avg 99µs/call | ||
70 | |||||
71 | next if $self->is_aliased_method($required_method_name); | ||||
72 | |||||
73 | push @missing, $required_method; | ||||
74 | } | ||||
75 | } | ||||
76 | |||||
77 | return unless @missing; | ||||
78 | |||||
79 | my $error = ''; | ||||
80 | |||||
81 | @missing = sort { $a->name cmp $b->name } @missing; | ||||
82 | my @conflicts = grep { $_->isa('Moose::Meta::Role::Method::Conflicting') } @missing; | ||||
83 | |||||
84 | if (@conflicts) { | ||||
85 | my $conflict = $conflicts[0]; | ||||
86 | my $roles = $conflict->roles_as_english_list; | ||||
87 | |||||
88 | my @same_role_conflicts = grep { $_->roles_as_english_list eq $roles } @conflicts; | ||||
89 | |||||
90 | if (@same_role_conflicts == 1) { | ||||
91 | $error | ||||
92 | .= "Due to a method name conflict in roles " | ||||
93 | . $roles | ||||
94 | . ", the method '" | ||||
95 | . $conflict->name | ||||
96 | . "' must be implemented or excluded by '" | ||||
97 | . $class->name | ||||
98 | . q{'}; | ||||
99 | } | ||||
100 | else { | ||||
101 | my $methods | ||||
102 | = Moose::Util::english_list( map { q{'} . $_->name . q{'} } @same_role_conflicts ); | ||||
103 | |||||
104 | $error | ||||
105 | .= "Due to method name conflicts in roles " | ||||
106 | . $roles | ||||
107 | . ", the methods " | ||||
108 | . $methods | ||||
109 | . " must be implemented or excluded by '" | ||||
110 | . $class->name | ||||
111 | . q{'}; | ||||
112 | } | ||||
113 | } | ||||
114 | elsif (@missing) { | ||||
115 | my $noun = @missing == 1 ? 'method' : 'methods'; | ||||
116 | |||||
117 | my $list | ||||
118 | = Moose::Util::english_list( map { q{'} . $_ . q{'} } @missing ); | ||||
119 | |||||
120 | $error | ||||
121 | .= q{'} | ||||
122 | . $role->name | ||||
123 | . "' requires the $noun $list " | ||||
124 | . "to be implemented by '" | ||||
125 | . $class->name . q{'}; | ||||
126 | |||||
127 | if (my $meth = firstval { $class->name->can($_) } @missing) { | ||||
128 | $error .= ". If you imported functions intending to use them as " | ||||
129 | . "methods, you need to explicitly mark them as such, via " | ||||
130 | . $class->name . "->meta->add_method($meth => \\\&$meth)"; | ||||
131 | } | ||||
132 | } | ||||
133 | |||||
134 | $class->throw_error($error); | ||||
135 | } | ||||
136 | |||||
137 | 4 | 13µs | # spent 7µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 4 times, avg 2µs/call:
# 4 times (7µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 2µs/call | ||
138 | |||||
139 | } | ||||
140 | |||||
141 | # spent 6.56ms (130µs+6.43) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 4 times, avg 1.64ms/call:
# 4 times (130µs+6.43ms) by Moose::Meta::Role::Application::apply at line 58 of Moose/Meta/Role/Application.pm, avg 1.64ms/call | ||||
142 | 8 | 52µs | my ($self, $role, $class) = @_; | ||
143 | |||||
144 | 4 | 37µs | foreach my $attribute_name ($role->get_attribute_list) { # spent 37µs making 4 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 9µs/call | ||
145 | # it if it has one already | ||||
146 | 4 | 60µs | 2 | 24µs | if ($class->has_attribute($attribute_name) && # spent 24µs making 2 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 12µs/call |
147 | # make sure we haven't seen this one already too | ||||
148 | $class->get_attribute($attribute_name) != $role->get_attribute($attribute_name)) { | ||||
149 | next; | ||||
150 | } | ||||
151 | else { | ||||
152 | 6 | 6.37ms | $class->add_attribute( # spent 3.63ms making 2 calls to Moose::Meta::Class::add_attribute, avg 1.81ms/call
# spent 2.72ms making 2 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 1.36ms/call
# spent 21µs making 2 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 11µs/call | ||
153 | $role->get_attribute($attribute_name)->attribute_for_class | ||||
154 | ); | ||||
155 | } | ||||
156 | } | ||||
157 | } | ||||
158 | |||||
159 | # spent 5.80ms (473µs+5.32) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 4 times, avg 1.45ms/call:
# 4 times (473µs+5.32ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 1.45ms/call | ||||
160 | 12 | 94µs | my ( $self, $role, $class ) = @_; | ||
161 | |||||
162 | 4 | 2.99ms | foreach my $method ( $role->_get_local_methods ) { # spent 2.99ms making 4 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 748µs/call | ||
163 | 68 | 295µs | 19 | 18µs | my $method_name = $method->name; # spent 18µs making 19 calls to Class::MOP::Method::name, avg 942ns/call |
164 | |||||
165 | 19 | 40µs | next if $method->isa('Class::MOP::Method::Meta'); # spent 40µs making 19 calls to UNIVERSAL::isa, avg 2µs/call | ||
166 | |||||
167 | 45 | 60µs | 15 | 140µs | unless ( $self->is_method_excluded($method_name) ) { # spent 140µs making 15 calls to Moose::Meta::Role::Application::is_method_excluded, avg 9µs/call |
168 | |||||
169 | 15 | 491µs | my $class_method = $class->get_method($method_name); # spent 491µs making 15 calls to Class::MOP::Mixin::HasMethods::get_method, avg 33µs/call | ||
170 | |||||
171 | next if $class_method && $class_method->body != $method->body; | ||||
172 | |||||
173 | 15 | 1.51ms | $class->add_method( # spent 1.51ms making 15 calls to Class::MOP::Mixin::HasMethods::add_method, avg 100µs/call | ||
174 | $method_name, | ||||
175 | $method, | ||||
176 | ); | ||||
177 | } | ||||
178 | |||||
179 | 15 | 125µs | next unless $self->is_method_aliased($method_name); # spent 125µs making 15 calls to Moose::Meta::Role::Application::is_method_aliased, avg 8µs/call | ||
180 | |||||
181 | my $aliased_method_name = $self->get_method_aliases->{$method_name}; | ||||
182 | |||||
183 | my $class_method = $class->get_method($aliased_method_name); | ||||
184 | |||||
185 | if ( $class_method && $class_method->body != $method->body ) { | ||||
186 | $class->throw_error( | ||||
187 | "Cannot create a method alias if a local method of the same name exists" | ||||
188 | ); | ||||
189 | } | ||||
190 | |||||
191 | $class->add_method( | ||||
192 | $aliased_method_name, | ||||
193 | $method, | ||||
194 | ); | ||||
195 | } | ||||
196 | |||||
197 | # we must reset the cache here since | ||||
198 | # we are just aliasing methods, otherwise | ||||
199 | # the modifiers go wonky. | ||||
200 | 4 | 11µs | $class->reset_package_cache_flag; # spent 11µs making 4 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 3µs/call | ||
201 | } | ||||
202 | |||||
203 | # spent 102µs (38+64) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 4 times, avg 26µs/call:
# 4 times (38µs+64µs) by Moose::Meta::Role::Application::apply at line 61 of Moose/Meta/Role/Application.pm, avg 26µs/call | ||||
204 | 8 | 36µs | my ($self, $role, $class) = @_; | ||
205 | 4 | 64µs | foreach my $method_name ($role->get_method_modifier_list('override')) { # spent 64µs making 4 calls to Moose::Meta::Role::get_method_modifier_list, avg 16µs/call | ||
206 | # it if it has one already then ... | ||||
207 | if ($class->has_method($method_name)) { | ||||
208 | next; | ||||
209 | } | ||||
210 | else { | ||||
211 | # if this is not a role, then we need to | ||||
212 | # find the original package of the method | ||||
213 | # so that we can tell the class were to | ||||
214 | # find the right super() method | ||||
215 | my $method = $role->get_override_method_modifier($method_name); | ||||
216 | my ($package) = Class::MOP::get_code_info($method); | ||||
217 | # if it is a class, we just add it | ||||
218 | $class->add_override_method_modifier($method_name, $method, $package); | ||||
219 | } | ||||
220 | } | ||||
221 | } | ||||
222 | |||||
223 | # spent 250µs (98+152) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 12 times, avg 21µs/call:
# 4 times (44µs+65µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 77 of Moose/Meta/Role/Application.pm, avg 27µs/call
# 4 times (27µs+43µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 18µs/call
# 4 times (27µs+44µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 18µs/call | ||||
224 | 48 | 100µs | my ($self, $modifier_type, $role, $class) = @_; | ||
225 | my $add = "add_${modifier_type}_method_modifier"; | ||||
226 | my $get = "get_${modifier_type}_method_modifiers"; | ||||
227 | 12 | 152µs | foreach my $method_name ($role->get_method_modifier_list($modifier_type)) { # spent 152µs making 12 calls to Moose::Meta::Role::get_method_modifier_list, avg 13µs/call | ||
228 | $class->$add( | ||||
229 | $method_name, | ||||
230 | $_ | ||||
231 | ) foreach $role->$get($method_name); | ||||
232 | } | ||||
233 | } | ||||
234 | |||||
235 | 1 | 9µs | 1; | ||
236 | |||||
237 | # ABSTRACT: Compose a role into a class | ||||
238 | |||||
- - | |||||
241 | =pod | ||||
242 | |||||
243 | =head1 NAME | ||||
244 | |||||
245 | Moose::Meta::Role::Application::ToClass - Compose a role into a class | ||||
246 | |||||
247 | =head1 VERSION | ||||
248 | |||||
249 | version 2.0602 | ||||
250 | |||||
251 | =head1 DESCRIPTION | ||||
252 | |||||
253 | =head2 METHODS | ||||
254 | |||||
255 | =over 4 | ||||
256 | |||||
257 | =item B<new> | ||||
258 | |||||
259 | =item B<meta> | ||||
260 | |||||
261 | =item B<apply> | ||||
262 | |||||
263 | =item B<check_role_exclusions> | ||||
264 | |||||
265 | =item B<check_required_methods> | ||||
266 | |||||
267 | =item B<check_required_attributes> | ||||
268 | |||||
269 | =item B<apply_attributes> | ||||
270 | |||||
271 | =item B<apply_methods> | ||||
272 | |||||
273 | =item B<apply_method_modifiers> | ||||
274 | |||||
275 | =item B<apply_override_method_modifiers> | ||||
276 | |||||
277 | =back | ||||
278 | |||||
279 | =head1 BUGS | ||||
280 | |||||
281 | See L<Moose/BUGS> for details on reporting bugs. | ||||
282 | |||||
283 | =head1 AUTHOR | ||||
284 | |||||
285 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
286 | |||||
287 | =head1 COPYRIGHT AND LICENSE | ||||
288 | |||||
289 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
290 | |||||
291 | This is free software; you can redistribute it and/or modify it under | ||||
292 | the same terms as the Perl 5 programming language system itself. | ||||
293 | |||||
294 | =cut | ||||
295 | |||||
296 | |||||
297 | __END__ |