Merge 'trunk' into 'method_generation_cleanup'
Matt S Trout [Fri, 12 Dec 2008 00:49:50 +0000 (00:49 +0000)]
r26263@agaton (orig r6884):  marcus | 2008-12-05 13:11:32 +0000
Bump dependency for MoreUtils
r26266@agaton (orig r6887):  marcus | 2008-12-05 14:53:43 +0000
Revert unwanted MMM::Accessor change
r26267@agaton (orig r6888):  autarch | 2008-12-05 14:59:04 +0000
update MANIFEST for test changes
r26268@agaton (orig r6889):  autarch | 2008-12-05 15:01:31 +0000
Don't call get_all_package_symbols in list context

r26269@agaton (orig r6890):  autarch | 2008-12-05 16:48:07 +0000
Spell coerce like a proper Merkan

r26272@agaton (orig r6893):  autarch | 2008-12-05 16:57:18 +0000
Handle defaults with quote-breaking values correctly by using
quotemeta. Added tests for this.
r26278@agaton (orig r6899):  autarch | 2008-12-05 19:21:54 +0000
bump version and update Changes
r26281@agaton (orig r6902):  autarch | 2008-12-05 19:30:39 +0000
require latest CMOP
r26288@agaton (orig r6909):  jnapiorkowski | 2008-12-05 21:49:20 +0000
changes to the way Moose::Meta::TypeConstraint passed arguments to the compiled type constraint coderef so that I can support MooseX::Types::Structured::Optional
r26289@agaton (orig r6910):  thepler | 2008-12-05 22:36:27 +0000
more tests for metaclass traits with required attributes
r26535@agaton (orig r6926):  sartak | 2008-12-07 01:29:56 +0000
 r76625@onn:  sartak | 2008-12-06 20:26:31 -0500
 Failing test for passing parameters to role->create (fix will go in Class::MOP)

r26557@agaton (orig r6948):  autarch | 2008-12-07 18:45:18 +0000
Remove an unneeded "the"

r26559@agaton (orig r6950):  autarch | 2008-12-07 18:50:19 +0000
Fix some unintended bugs in the "standard" P5 code.

r26560@agaton (orig r6951):  autarch | 2008-12-07 18:53:41 +0000
Small tweaks to some of the text.

r26586@agaton (orig r6977):  autarch | 2008-12-08 17:09:21 +0000
Add changes for 0.63

r26589@agaton (orig r6980):  autarch | 2008-12-08 17:11:18 +0000
update manifest
r26590@agaton (orig r6981):  autarch | 2008-12-08 17:12:33 +0000
No point in keeping this todo test for parameterized roles in the
Moose distro now that we have an MX module for it.
r26591@agaton (orig r6982):  autarch | 2008-12-08 17:14:17 +0000
bump version to 0.63
r26599@agaton (orig r6990):  autarch | 2008-12-08 22:21:44 +0000
I was channeling stevan and misspeled declaratively

r26600@agaton (orig r6991):  perigrin | 2008-12-08 22:25:12 +0000
zero or more Roles
r26628@agaton (orig r7019):  sartak | 2008-12-09 06:39:26 +0000
 r76787@onn:  sartak | 2008-12-09 01:39:11 -0500
 Always inline predicate and clearer methods

r26693@agaton (orig r7050):  autarch | 2008-12-11 06:23:32 +0000
Doh, we really need CMOP 0.72

lib/Moose/Meta/Method/Accessor.pm
lib/Moose/Meta/Method/Constructor.pm
lib/Moose/Meta/Method/Destructor.pm

index 9fab4d7..3d40db8 100644 (file)
@@ -21,19 +21,21 @@ sub _eval_code {
 
     # NOTE:
     # set up the environment
+    my $environment = q{
     my $attr        = $self->associated_attribute;
     my $attr_name   = $attr->name;
-    my $meta        = $self,
+    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
                                    ? $type_constraint_obj->_compiled_type_constraint
                                    : 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 $@;
+    my $sub = $self->_eval_closure($environment, $code);
+    $self->throw_error("Could not create writer for '${\$self->associated_attribute->name}' because $@ \n code: $code", error => $@, data => $code ) if $@;
     return $sub;
 
 }
@@ -228,7 +230,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 {
index d0a345b..e420b5a 100644 (file)
@@ -150,7 +150,7 @@ sub initialize_body {
     warn $source if $self->options->{debug};
 
     my $code;
-    {
+    my $environment = q{
         my $meta = $self; # FIXME for _inline_throw_error...
 
         # NOTE:
@@ -174,10 +174,9 @@ sub initialize_body {
         my @type_constraint_bodies = map {
             defined $_ ? $_->_compiled_type_constraint : undef;
         } @type_constraints;
-
-        $code = eval $source;
-        $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source ) if $@;
-    }
+    };
+    $code = $self->_eval_closure($environment, $source);
+    $self->throw_error("Could not eval the constructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source ) if $@;
     $self->{'body'} = $code;
 }
 
@@ -223,8 +222,6 @@ sub _generate_triggers {
                                  '$instance',
                                  ("'" . $attr->name . "'")
                              ) 
-                             . ', '
-                    .        '$attrs->[' . $i . ']'
                     .   ');'
                     ."\n}"
                 );
index 6ad6fe6..e8687f2 100644 (file)
@@ -88,11 +88,8 @@ sub initialize_body {
     $source .= ";\n" . '}'; 
     warn $source if $self->options->{debug};    
     
-    my $code;
-    {
-        $code = eval $source;
-        $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source) if $@;
-    }
+    my $code = $self->_eval_closure(q{}, $source);
+    $self->throw_error("Could not eval the destructor :\n\n$source\n\nbecause :\n\n$@", error => $@, data => $source) if $@;
     $self->{'body'} = $code;
 }