X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FAccessor.pm;h=9dcbf7029553bb68ae3cc554bdc45ca696b9893d;hb=4da72c45030b36f43e7b9bfb15c38276f14db3a6;hp=02086430e2fd74745fe3bffc9a3cdfd1550e8102;hpb=18748ad69a205a0ae4acea224d69f10f3db53834;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Accessor.pm b/lib/Moose/Meta/Method/Accessor.pm index 0208643..9dcbf70 100644 --- a/lib/Moose/Meta/Method/Accessor.pm +++ b/lib/Moose/Meta/Method/Accessor.pm @@ -4,7 +4,7 @@ package Moose::Meta::Method::Accessor; use strict; use warnings; -our $VERSION = '0.57'; +our $VERSION = '0.68'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -21,21 +21,22 @@ sub _eval_code { # NOTE: # set up the environment - my $attr = $self->associated_attribute; - my $attr_name = $attr->name; - my $meta = $self, - - my $type_constraint_obj = $attr->type_constraint; - my $type_constraint_name = $type_constraint_obj && $type_constraint_obj->name; - my $type_constraint = $type_constraint_obj + my $attr = $self->associated_attribute; + my $type_constraint_obj = $attr->type_constraint; + my $environment = { + '$attr' => \$attr, + '$attr_name' => \$attr->name, + '$meta' => \$self, + '$type_constraint_obj' => \$type_constraint_obj, + '$type_constraint_name' => \($type_constraint_obj && $type_constraint_obj->name), + '$type_constraint' => \($type_constraint_obj ? $type_constraint_obj->_compiled_type_constraint - : undef; + : undef), + }; #warn "code for $attr_name =>\n" . $code . "\n"; - my $sub = eval $code; - $self->throw_error("Could not create writer for '$attr_name' because $@ \n code: $code", error => $@, data => $code ) if $@; - return $sub; - + $self->_compile_code( environment => $environment, code => $code ) + or $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code ); } sub generate_accessor_method_inline { @@ -111,6 +112,8 @@ sub _value_needs_copy { sub generate_reader_method { shift->generate_reader_method_inline(@_) } sub generate_writer_method { shift->generate_writer_method_inline(@_) } sub generate_accessor_method { shift->generate_accessor_method_inline(@_) } +sub generate_predicate_method { shift->generate_predicate_method_inline(@_) } +sub generate_clearer_method { shift->generate_clearer_method_inline(@_) } sub _inline_pre_body { '' } sub _inline_post_body { '' } @@ -226,7 +229,7 @@ sub _inline_trigger { my ($self, $instance, $value) = @_; my $attr = $self->associated_attribute; return '' unless $attr->has_trigger; - return sprintf('$attr->trigger->(%s, %s, $attr);', $instance, $value); + return sprintf('$attr->trigger->(%s, %s);', $instance, $value); } sub _inline_get { @@ -311,6 +314,10 @@ role in the optimization strategy we are currently following. =item B +=item B + +=item B + =item B =item B @@ -333,7 +340,7 @@ Yuval Kogman Enothingmuch@woobling.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2008 by Infinity Interactive, Inc. +Copyright 2006-2009 by Infinity Interactive, Inc. L