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=46b1358f4151b83d1373f5647445a355569f0d4f;p=gitmo%2FClass-MOP.git Fix unified generation --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 40bcf28..7f00c5a 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -356,15 +356,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); @@ -382,11 +386,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 395fd59..8a9ee8c 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