From: gfx Date: Sat, 15 Aug 2009 11:04:06 +0000 (+0900) Subject: Fix unified generation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ace00b189b8348a63a9497bd4becc37359dce82e;p=gitmo%2FClass-MOP.git Fix unified generation --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index e97084c..b8a5357 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -350,15 +350,19 @@ sub _process_accessors { $method_ctx = { %$ctx }; } + my $metaclass = $self->associated_class; + if (ref($accessor)) { (ref($accessor) eq 'HASH') || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref"; my ($name, $method) = %{$accessor}; + $method = $self->accessor_metaclass->wrap( - $method, - package_name => $self->associated_class->name, - name => $name, - definition_context => $method_ctx, + body => $method, + associated_metaclass => $metaclass, + package_name => $metaclass->name, + name => $name, + definition_context => $method_ctx, ); $self->associate_method($method); return ($name, $method); @@ -376,11 +380,12 @@ sub _process_accessors { } $method = $self->accessor_metaclass->new( - attribute => $self, - accessor_type => $type, - package_name => $self->associated_class->name, - name => $accessor, - definition_context => $method_ctx, + attribute => $self, + accessor_type => $type, + associated_metaclass => $metaclass, + package_name => $metaclass->name, + name => $accessor, + definition_context => $method_ctx, ); }; confess "Could not create the '$type' method for " . $self->name . " because : $@" if $@; diff --git a/lib/Class/MOP/Method/Accessor.pm b/lib/Class/MOP/Method/Accessor.pm index 45cab21..6353314 100644 --- a/lib/Class/MOP/Method/Accessor.pm +++ b/lib/Class/MOP/Method/Accessor.pm @@ -35,6 +35,7 @@ sub new { # a cycle in the code, if not # needed weaken($self->{'attribute'}); + weaken($self->{'associated_metaclass'}); $self->_initialize_body; @@ -58,8 +59,7 @@ sub _new { original_method => $params->{original_method}, # inherit from Class::MOP::Generated - is_inline => ($params->{associated_metaclass} - && $params->{associated_metaclass}->instance_metaclass->is_inlinable), + is_inline => $params->{associated_metaclass}->instance_metaclass->is_inlinable, definition_context => $params->{definition_context}, # defined in this class