File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Method/Accessor.pm |
Statements Executed | 4276 |
Statement Execution Time | 9.93ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
172 | 1 | 1 | 2.82ms | 18.3ms | new | Class::MOP::Method::Accessor::
223 | 2 | 2 | 2.13ms | 2.13ms | _new | Class::MOP::Method::Accessor::
172 | 1 | 1 | 1.54ms | 12.2ms | _initialize_body | Class::MOP::Method::Accessor::
52 | 1 | 1 | 958µs | 4.53ms | _generate_reader_method_inline | Class::MOP::Method::Accessor::
15 | 1 | 1 | 317µs | 1.45ms | _generate_accessor_method_inline | Class::MOP::Method::Accessor::
52 | 1 | 1 | 299µs | 348µs | _generate_reader_method | Class::MOP::Method::Accessor::
13 | 1 | 1 | 247µs | 987µs | _generate_predicate_method_inline | Class::MOP::Method::Accessor::
196 | 13 | 2 | 186µs | 186µs | associated_attribute | Class::MOP::Method::Accessor::
172 | 1 | 1 | 179µs | 179µs | accessor_type | Class::MOP::Method::Accessor::
15 | 1 | 1 | 89µs | 102µs | _generate_accessor_method | Class::MOP::Method::Accessor::
3 | 1 | 1 | 84µs | 259µs | _generate_writer_method_inline | Class::MOP::Method::Accessor::
13 | 1 | 1 | 73µs | 84µs | _generate_predicate_method | Class::MOP::Method::Accessor::
3 | 1 | 1 | 26µs | 29µs | _generate_writer_method | Class::MOP::Method::Accessor::
1 | 1 | 1 | 22µs | 27µs | BEGIN@4 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 15µs | 64µs | BEGIN@8 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 11µs | 27µs | BEGIN@5 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 10µs | 2.64ms | BEGIN@14 | Class::MOP::Method::Accessor::
1 | 1 | 1 | 10µs | 55µs | BEGIN@7 | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:105] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:113] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:120] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:127] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | __ANON__[:97] | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_clearer_method | Class::MOP::Method::Accessor::
0 | 0 | 0 | 0s | 0s | _generate_clearer_method_inline | Class::MOP::Method::Accessor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Method::Accessor; | ||||
3 | |||||
4 | 3 | 34µs | 2 | 33µs | # spent 27µs (22+5) within Class::MOP::Method::Accessor::BEGIN@4 which was called
# once (22µs+5µs) by Class::MOP::Class::BEGIN@9 at line 4 # spent 27µs making 1 call to Class::MOP::Method::Accessor::BEGIN@4
# spent 5µs making 1 call to strict::import |
5 | 3 | 35µs | 2 | 43µs | # spent 27µs (11+16) within Class::MOP::Method::Accessor::BEGIN@5 which was called
# once (11µs+16µs) by Class::MOP::Class::BEGIN@9 at line 5 # spent 27µs making 1 call to Class::MOP::Method::Accessor::BEGIN@5
# spent 16µs making 1 call to warnings::import |
6 | |||||
7 | 3 | 38µs | 2 | 99µs | # spent 55µs (10+45) within Class::MOP::Method::Accessor::BEGIN@7 which was called
# once (10µs+45µs) by Class::MOP::Class::BEGIN@9 at line 7 # spent 55µs making 1 call to Class::MOP::Method::Accessor::BEGIN@7
# spent 45µs making 1 call to Exporter::import |
8 | 3 | 76µs | 2 | 114µs | # spent 64µs (15+49) within Class::MOP::Method::Accessor::BEGIN@8 which was called
# once (15µs+49µs) by Class::MOP::Class::BEGIN@9 at line 8 # spent 64µs making 1 call to Class::MOP::Method::Accessor::BEGIN@8
# spent 49µs making 1 call to Exporter::import |
9 | |||||
10 | 1 | 900ns | our $VERSION = '0.98'; | ||
11 | 1 | 24µs | $VERSION = eval $VERSION; | ||
12 | 1 | 500ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
13 | |||||
14 | 3 | 1.05ms | 2 | 5.27ms | # spent 2.64ms (10µs+2.63) within Class::MOP::Method::Accessor::BEGIN@14 which was called
# once (10µs+2.63ms) by Class::MOP::Class::BEGIN@9 at line 14 # spent 2.64ms making 1 call to Class::MOP::Method::Accessor::BEGIN@14
# spent 2.63ms making 1 call to base::import |
15 | |||||
16 | # spent 18.3ms (2.82+15.5) within Class::MOP::Method::Accessor::new which was called 172 times, avg 106µs/call:
# 172 times (2.82ms+15.5ms) by Class::MOP::Attribute::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Attribute.pm:340] at line 332 of Class/MOP/Attribute.pm, avg 106µs/call | ||||
17 | 172 | 55µs | my $class = shift; | ||
18 | 172 | 392µs | my %options = @_; | ||
19 | |||||
20 | 172 | 57µs | (exists $options{attribute}) | ||
21 | || confess "You must supply an attribute to construct with"; | ||||
22 | |||||
23 | 172 | 38µs | (exists $options{accessor_type}) | ||
24 | || confess "You must supply an accessor_type to construct with"; | ||||
25 | |||||
26 | 172 | 913µs | 344 | 270µs | (blessed($options{attribute}) && $options{attribute}->isa('Class::MOP::Attribute')) # spent 140µs making 172 calls to UNIVERSAL::isa, avg 816ns/call
# spent 130µs making 172 calls to Scalar::Util::blessed, avg 756ns/call |
27 | || confess "You must supply an attribute which is a 'Class::MOP::Attribute' instance"; | ||||
28 | |||||
29 | 172 | 62µs | ($options{package_name} && $options{name}) | ||
30 | || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"; | ||||
31 | |||||
32 | 172 | 271µs | 172 | 2.80ms | my $self = $class->_new(\%options); # spent 1.50ms making 166 calls to Class::MOP::Method::Accessor::_new, avg 9µs/call
# spent 1.04ms making 2 calls to Class::MOP::Method::_new, avg 521µs/call
# spent 260µs making 4 calls to Moose::Meta::Method::Accessor::_new, avg 65µs/call |
33 | |||||
34 | # we don't want this creating | ||||
35 | # a cycle in the code, if not | ||||
36 | # needed | ||||
37 | 172 | 543µs | 172 | 220µs | weaken($self->{'attribute'}); # spent 220µs making 172 calls to Scalar::Util::weaken, avg 1µs/call |
38 | |||||
39 | 172 | 189µs | 172 | 12.2ms | $self->_initialize_body; # spent 12.2ms making 172 calls to Class::MOP::Method::Accessor::_initialize_body, avg 71µs/call |
40 | |||||
41 | 172 | 471µs | return $self; | ||
42 | } | ||||
43 | |||||
44 | # spent 2.13ms within Class::MOP::Method::Accessor::_new which was called 223 times, avg 10µs/call:
# 166 times (1.50ms+0s) by Class::MOP::Method::Accessor::new at line 32, avg 9µs/call
# 57 times (628µs+0s) by Class::MOP::Method::wrap at line 44 of Class/MOP/Method.pm, avg 11µs/call | ||||
45 | 223 | 54µs | my $class = shift; | ||
46 | |||||
47 | 223 | 50µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
48 | if $class ne __PACKAGE__; | ||||
49 | |||||
50 | 223 | 90µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
51 | |||||
52 | 223 | 2.04ms | return bless { | ||
53 | # inherited from Class::MOP::Method | ||||
54 | body => $params->{body}, | ||||
55 | associated_metaclass => $params->{associated_metaclass}, | ||||
56 | package_name => $params->{package_name}, | ||||
57 | name => $params->{name}, | ||||
58 | original_method => $params->{original_method}, | ||||
59 | |||||
60 | # inherit from Class::MOP::Generated | ||||
61 | is_inline => $params->{is_inline} || 0, | ||||
62 | definition_context => $params->{definition_context}, | ||||
63 | |||||
64 | # defined in this class | ||||
65 | attribute => $params->{attribute}, | ||||
66 | accessor_type => $params->{accessor_type}, | ||||
67 | } => $class; | ||||
68 | } | ||||
69 | |||||
70 | ## accessors | ||||
71 | |||||
72 | 196 | 410µs | # spent 186µs within Class::MOP::Method::Accessor::associated_attribute which was called 196 times, avg 947ns/call:
# 52 times (52µs+0s) by Class::MOP::Method::Accessor::_generate_reader_method_inline at line 153, avg 998ns/call
# 52 times (49µs+0s) by Class::MOP::Method::Accessor::_generate_reader_method at line 101, avg 942ns/call
# 15 times (14µs+0s) by Class::MOP::Method::Accessor::_generate_accessor_method_inline at line 134, avg 927ns/call
# 15 times (13µs+0s) by Class::MOP::Method::Accessor::_generate_accessor_method at line 93, avg 867ns/call
# 13 times (12µs+0s) by Class::MOP::Method::Accessor::_generate_predicate_method_inline at line 188, avg 892ns/call
# 13 times (11µs+0s) by Class::MOP::Method::Accessor::_generate_predicate_method at line 117, avg 815ns/call
# 6 times (8µs+0s) by Moose::Meta::Method::Accessor::_inline_check_lazy at line 158 of Moose/Meta/Method/Accessor.pm, avg 1µs/call
# 6 times (7µs+0s) by Moose::Meta::Method::Accessor::_generate_reader_method_inline at line 91 of Moose/Meta/Method/Accessor.pm, avg 1µs/call
# 6 times (6µs+0s) by Moose::Meta::Method::Accessor::_inline_auto_deref at line 277 of Moose/Meta/Method/Accessor.pm, avg 1µs/call
# 6 times (6µs+0s) by Moose::Meta::Method::Accessor::_eval_code at line 24 of Moose/Meta/Method/Accessor.pm, avg 917ns/call
# 6 times (4µs+0s) by Moose::Meta::Method::Accessor::_inline_get at line 250 of Moose/Meta/Method/Accessor.pm, avg 733ns/call
# 3 times (3µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method_inline at line 171, avg 900ns/call
# 3 times (2µs+0s) by Class::MOP::Method::Accessor::_generate_writer_method at line 110, avg 800ns/call | ||
73 | 172 | 333µs | # spent 179µs within Class::MOP::Method::Accessor::accessor_type which was called 172 times, avg 1µs/call:
# 172 times (179µs+0s) by Class::MOP::Method::Accessor::_initialize_body at line 80, avg 1µs/call | ||
74 | |||||
75 | ## factory | ||||
76 | |||||
77 | # spent 12.2ms (1.54+10.6) within Class::MOP::Method::Accessor::_initialize_body which was called 172 times, avg 71µs/call:
# 172 times (1.54ms+10.6ms) by Class::MOP::Method::Accessor::new at line 39, avg 71µs/call | ||||
78 | 172 | 29µs | my $self = shift; | ||
79 | |||||
80 | 172 | 453µs | 344 | 372µs | my $method_name = join "_" => ( # spent 193µs making 172 calls to Class::MOP::Method::Generated::is_inline, avg 1µs/call
# spent 179µs making 172 calls to Class::MOP::Method::Accessor::accessor_type, avg 1µs/call |
81 | '_generate', | ||||
82 | $self->accessor_type, | ||||
83 | 'method', | ||||
84 | ($self->is_inline ? 'inline' : ()) | ||||
85 | ); | ||||
86 | |||||
87 | 172 | 640µs | 172 | 10.3ms | $self->{'body'} = $self->$method_name(); # spent 4.53ms making 52 calls to Class::MOP::Method::Accessor::_generate_reader_method_inline, avg 87µs/call
# spent 2.06ms making 5 calls to Moose::Meta::Method::Accessor::_generate_reader_method, avg 412µs/call
# spent 1.45ms making 15 calls to Class::MOP::Method::Accessor::_generate_accessor_method_inline, avg 97µs/call
# spent 987µs making 13 calls to Class::MOP::Method::Accessor::_generate_predicate_method_inline, avg 76µs/call
# spent 424µs making 1 call to Moose::Meta::Method::Accessor::_generate_reader_method_inline
# spent 348µs making 52 calls to Class::MOP::Method::Accessor::_generate_reader_method, avg 7µs/call
# spent 259µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method_inline, avg 86µs/call
# spent 102µs making 15 calls to Class::MOP::Method::Accessor::_generate_accessor_method, avg 7µs/call
# spent 84µs making 13 calls to Class::MOP::Method::Accessor::_generate_predicate_method, avg 6µs/call
# spent 29µs making 3 calls to Class::MOP::Method::Accessor::_generate_writer_method, avg 10µs/call |
88 | } | ||||
89 | |||||
90 | ## generators | ||||
91 | |||||
92 | # spent 102µs (89+13) within Class::MOP::Method::Accessor::_generate_accessor_method which was called 15 times, avg 7µs/call:
# 15 times (89µs+13µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call | ||||
93 | 15 | 17µs | 15 | 13µs | my $attr = (shift)->associated_attribute; # spent 13µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 867ns/call |
94 | return sub { | ||||
95 | $attr->set_value($_[0], $_[1]) if scalar(@_) == 2; | ||||
96 | $attr->get_value($_[0]); | ||||
97 | 15 | 68µs | }; | ||
98 | } | ||||
99 | |||||
100 | # spent 348µs (299+49) within Class::MOP::Method::Accessor::_generate_reader_method which was called 52 times, avg 7µs/call:
# 52 times (299µs+49µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 7µs/call | ||||
101 | 52 | 66µs | 52 | 49µs | my $attr = (shift)->associated_attribute; # spent 49µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 942ns/call |
102 | return sub { | ||||
103 | 6 | 4µs | confess "Cannot assign a value to a read-only accessor" if @_ > 1; | ||
104 | 6 | 21µs | 6 | 155µs | $attr->get_value($_[0]); # spent 155µs making 6 calls to Class::MOP::Attribute::get_value, avg 26µs/call |
105 | 52 | 212µs | }; | ||
106 | } | ||||
107 | |||||
108 | |||||
109 | # spent 29µs (26+2) within Class::MOP::Method::Accessor::_generate_writer_method which was called 3 times, avg 10µs/call:
# 3 times (26µs+2µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 10µs/call | ||||
110 | 3 | 5µs | 3 | 2µs | my $attr = (shift)->associated_attribute; # spent 2µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 800ns/call |
111 | return sub { | ||||
112 | $attr->set_value($_[0], $_[1]); | ||||
113 | 3 | 19µs | }; | ||
114 | } | ||||
115 | |||||
116 | # spent 84µs (73+11) within Class::MOP::Method::Accessor::_generate_predicate_method which was called 13 times, avg 6µs/call:
# 13 times (73µs+11µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 6µs/call | ||||
117 | 13 | 15µs | 13 | 11µs | my $attr = (shift)->associated_attribute; # spent 11µs making 13 calls to Class::MOP::Method::Accessor::associated_attribute, avg 815ns/call |
118 | return sub { | ||||
119 | 2 | 9µs | 2 | 57µs | $attr->has_value($_[0]) # spent 57µs making 2 calls to Class::MOP::Attribute::has_value, avg 28µs/call |
120 | 13 | 50µs | }; | ||
121 | } | ||||
122 | |||||
123 | sub _generate_clearer_method { | ||||
124 | my $attr = (shift)->associated_attribute; | ||||
125 | return sub { | ||||
126 | $attr->clear_value($_[0]) | ||||
127 | }; | ||||
128 | } | ||||
129 | |||||
130 | ## Inline methods | ||||
131 | |||||
132 | # spent 1.45ms (317µs+1.14) within Class::MOP::Method::Accessor::_generate_accessor_method_inline which was called 15 times, avg 97µs/call:
# 15 times (317µs+1.14ms) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 97µs/call | ||||
133 | 15 | 3µs | my $self = shift; | ||
134 | 15 | 16µs | 15 | 14µs | my $attr = $self->associated_attribute; # spent 14µs making 15 calls to Class::MOP::Method::Accessor::associated_attribute, avg 927ns/call |
135 | 15 | 42µs | 15 | 9µs | my $attr_name = $attr->name; # spent 9µs making 15 calls to Class::MOP::Mixin::AttributeCore::name, avg 627ns/call |
136 | 15 | 28µs | 30 | 28µs | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 15µs making 15 calls to Class::MOP::Class::instance_metaclass, avg 987ns/call
# spent 14µs making 15 calls to Class::MOP::Attribute::associated_class, avg 907ns/call |
137 | |||||
138 | 15 | 85µs | 45 | 1.09ms | my ( $code, $e ) = $self->_eval_closure( # spent 902µs making 15 calls to Class::MOP::Method::Generated::_eval_closure, avg 60µs/call
# spent 104µs making 15 calls to Class::MOP::Instance::inline_set_slot_value, avg 7µs/call
# spent 80µs making 15 calls to Class::MOP::Instance::inline_get_slot_value, avg 5µs/call |
139 | {}, | ||||
140 | 'sub {' | ||||
141 | . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]') | ||||
142 | . ' if scalar(@_) == 2; ' | ||||
143 | . $meta_instance->inline_get_slot_value('$_[0]', $attr_name) | ||||
144 | . '}' | ||||
145 | ); | ||||
146 | 15 | 2µs | confess "Could not generate inline accessor because : $e" if $e; | ||
147 | |||||
148 | 15 | 35µs | return $code; | ||
149 | } | ||||
150 | |||||
151 | # spent 4.53ms (958µs+3.57) within Class::MOP::Method::Accessor::_generate_reader_method_inline which was called 52 times, avg 87µs/call:
# 52 times (958µs+3.57ms) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 87µs/call | ||||
152 | 52 | 12µs | my $self = shift; | ||
153 | 52 | 56µs | 52 | 52µs | my $attr = $self->associated_attribute; # spent 52µs making 52 calls to Class::MOP::Method::Accessor::associated_attribute, avg 998ns/call |
154 | 52 | 154µs | 52 | 36µs | my $attr_name = $attr->name; # spent 36µs making 52 calls to Class::MOP::Mixin::AttributeCore::name, avg 687ns/call |
155 | 52 | 98µs | 104 | 107µs | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 58µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call
# spent 49µs making 52 calls to Class::MOP::Attribute::associated_class, avg 940ns/call |
156 | |||||
157 | 52 | 213µs | 104 | 3.38ms | my ( $code, $e ) = $self->_eval_closure( # spent 3.06ms making 52 calls to Class::MOP::Method::Generated::_eval_closure, avg 59µs/call
# spent 313µs making 52 calls to Class::MOP::Instance::inline_get_slot_value, avg 6µs/call |
158 | {}, | ||||
159 | 'sub {' | ||||
160 | . 'confess "Cannot assign a value to a read-only accessor" if @_ > 1;' | ||||
161 | . $meta_instance->inline_get_slot_value('$_[0]', $attr_name) | ||||
162 | . '}' | ||||
163 | ); | ||||
164 | 52 | 7µs | confess "Could not generate inline reader because : $e" if $e; | ||
165 | |||||
166 | 52 | 119µs | return $code; | ||
167 | } | ||||
168 | |||||
169 | # spent 259µs (84+175) within Class::MOP::Method::Accessor::_generate_writer_method_inline which was called 3 times, avg 86µs/call:
# 3 times (84µs+175µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 86µs/call | ||||
170 | 3 | 1µs | my $self = shift; | ||
171 | 3 | 4µs | 3 | 3µs | my $attr = $self->associated_attribute; # spent 3µs making 3 calls to Class::MOP::Method::Accessor::associated_attribute, avg 900ns/call |
172 | 3 | 10µs | 3 | 2µs | my $attr_name = $attr->name; # spent 2µs making 3 calls to Class::MOP::Mixin::AttributeCore::name, avg 633ns/call |
173 | 3 | 8µs | 6 | 6µs | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 3µs making 3 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call
# spent 3µs making 3 calls to Class::MOP::Attribute::associated_class, avg 933ns/call |
174 | |||||
175 | 3 | 17µs | 6 | 164µs | my ( $code, $e ) = $self->_eval_closure( # spent 144µs making 3 calls to Class::MOP::Method::Generated::_eval_closure, avg 48µs/call
# spent 20µs making 3 calls to Class::MOP::Instance::inline_set_slot_value, avg 7µs/call |
176 | {}, | ||||
177 | 'sub {' | ||||
178 | . $meta_instance->inline_set_slot_value('$_[0]', $attr_name, '$_[1]') | ||||
179 | . '}' | ||||
180 | ); | ||||
181 | 3 | 900ns | confess "Could not generate inline writer because : $e" if $e; | ||
182 | |||||
183 | 3 | 10µs | return $code; | ||
184 | } | ||||
185 | |||||
186 | # spent 987µs (247+740) within Class::MOP::Method::Accessor::_generate_predicate_method_inline which was called 13 times, avg 76µs/call:
# 13 times (247µs+740µs) by Class::MOP::Method::Accessor::_initialize_body at line 87, avg 76µs/call | ||||
187 | 13 | 4µs | my $self = shift; | ||
188 | 13 | 14µs | 13 | 12µs | my $attr = $self->associated_attribute; # spent 12µs making 13 calls to Class::MOP::Method::Accessor::associated_attribute, avg 892ns/call |
189 | 13 | 35µs | 13 | 8µs | my $attr_name = $attr->name; # spent 8µs making 13 calls to Class::MOP::Mixin::AttributeCore::name, avg 631ns/call |
190 | 13 | 25µs | 26 | 25µs | my $meta_instance = $attr->associated_class->instance_metaclass; # spent 13µs making 13 calls to Class::MOP::Class::instance_metaclass, avg 1µs/call
# spent 11µs making 13 calls to Class::MOP::Attribute::associated_class, avg 877ns/call |
191 | |||||
192 | 13 | 57µs | 26 | 696µs | my ( $code, $e ) = $self->_eval_closure( # spent 599µs making 13 calls to Class::MOP::Method::Generated::_eval_closure, avg 46µs/call
# spent 96µs making 13 calls to Class::MOP::Instance::inline_is_slot_initialized, avg 7µs/call |
193 | {}, | ||||
194 | 'sub {' | ||||
195 | . $meta_instance->inline_is_slot_initialized('$_[0]', $attr_name) | ||||
196 | . '}' | ||||
197 | ); | ||||
198 | 13 | 2µs | confess "Could not generate inline predicate because : $e" if $e; | ||
199 | |||||
200 | 13 | 32µs | return $code; | ||
201 | } | ||||
202 | |||||
203 | sub _generate_clearer_method_inline { | ||||
204 | my $self = shift; | ||||
205 | my $attr = $self->associated_attribute; | ||||
206 | my $attr_name = $attr->name; | ||||
207 | my $meta_instance = $attr->associated_class->instance_metaclass; | ||||
208 | |||||
209 | my ( $code, $e ) = $self->_eval_closure( | ||||
210 | {}, | ||||
211 | 'sub {' | ||||
212 | . $meta_instance->inline_deinitialize_slot('$_[0]', $attr_name) | ||||
213 | . '}' | ||||
214 | ); | ||||
215 | confess "Could not generate inline clearer because : $e" if $e; | ||||
216 | |||||
217 | return $code; | ||||
218 | } | ||||
219 | |||||
220 | 1 | 6µs | 1; | ||
221 | |||||
222 | __END__ | ||||
223 | |||||
224 | =pod | ||||
225 | |||||
226 | =head1 NAME | ||||
227 | |||||
228 | Class::MOP::Method::Accessor - Method Meta Object for accessors | ||||
229 | |||||
230 | =head1 SYNOPSIS | ||||
231 | |||||
232 | use Class::MOP::Method::Accessor; | ||||
233 | |||||
234 | my $reader = Class::MOP::Method::Accessor->new( | ||||
235 | attribute => $attribute, | ||||
236 | is_inline => 1, | ||||
237 | accessor_type => 'reader', | ||||
238 | ); | ||||
239 | |||||
240 | $reader->body->execute($instance); # call the reader method | ||||
241 | |||||
242 | =head1 DESCRIPTION | ||||
243 | |||||
244 | This is a subclass of <Class::MOP::Method> which is used by | ||||
245 | C<Class::MOP::Attribute> to generate accessor code. It handles | ||||
246 | generation of readers, writers, predicates and clearers. For each type | ||||
247 | of method, it can either create a subroutine reference, or actually | ||||
248 | inline code by generating a string and C<eval>'ing it. | ||||
249 | |||||
250 | =head1 METHODS | ||||
251 | |||||
252 | =over 4 | ||||
253 | |||||
254 | =item B<< Class::MOP::Method::Accessor->new(%options) >> | ||||
255 | |||||
256 | This returns a new C<Class::MOP::Method::Accessor> based on the | ||||
257 | C<%options> provided. | ||||
258 | |||||
259 | =over 4 | ||||
260 | |||||
261 | =item * attribute | ||||
262 | |||||
263 | This is the C<Class::MOP::Attribute> for which accessors are being | ||||
264 | generated. This option is required. | ||||
265 | |||||
266 | =item * accessor_type | ||||
267 | |||||
268 | This is a string which should be one of "reader", "writer", | ||||
269 | "accessor", "predicate", or "clearer". This is the type of method | ||||
270 | being generated. This option is required. | ||||
271 | |||||
272 | =item * is_inline | ||||
273 | |||||
274 | This indicates whether or not the accessor should be inlined. This | ||||
275 | defaults to false. | ||||
276 | |||||
277 | =item * name | ||||
278 | |||||
279 | The method name (without a package name). This is required. | ||||
280 | |||||
281 | =item * package_name | ||||
282 | |||||
283 | The package name for the method. This is required. | ||||
284 | |||||
285 | =back | ||||
286 | |||||
287 | =item B<< $metamethod->accessor_type >> | ||||
288 | |||||
289 | Returns the accessor type which was passed to C<new>. | ||||
290 | |||||
291 | =item B<< $metamethod->is_inline >> | ||||
292 | |||||
293 | Returns a boolean indicating whether or not the accessor is inlined. | ||||
294 | |||||
295 | =item B<< $metamethod->associated_attribute >> | ||||
296 | |||||
297 | This returns the L<Class::MOP::Attribute> object which was passed to | ||||
298 | C<new>. | ||||
299 | |||||
300 | =item B<< $metamethod->body >> | ||||
301 | |||||
302 | The method itself is I<generated> when the accessor object is | ||||
303 | constructed. | ||||
304 | |||||
305 | =back | ||||
306 | |||||
307 | =head1 AUTHORS | ||||
308 | |||||
309 | Stevan Little E<lt>stevan@iinteractive.comE<gt> | ||||
310 | |||||
311 | =head1 COPYRIGHT AND LICENSE | ||||
312 | |||||
313 | Copyright 2006-2010 by Infinity Interactive, Inc. | ||||
314 | |||||
315 | L<http://www.iinteractive.com> | ||||
316 | |||||
317 | This library is free software; you can redistribute it and/or modify | ||||
318 | it under the same terms as Perl itself. | ||||
319 | |||||
320 | =cut | ||||
321 |