From: Stevan Little Date: Wed, 23 Jan 2008 01:49:25 +0000 (+0000) Subject: 0.52 stuff X-Git-Tag: 0_53~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a2b84587843665ec0c541f4635455f490480595;p=gitmo%2FClass-MOP.git 0.52 stuff --- diff --git a/Changes b/Changes index 63fe78a..ccde218 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,14 @@ Revision history for Perl extension Class-MOP. +0.52 + * Class::MOP::Class + - fixed bug in rebless_instance + (discovered by ash) + + * Class::MOP::Method::Constructor + - removed assumptions about the existence of + a &meta method + 0.51 Mon. Jan. 14, 2008 ~~~ some misc. doc. fixes ~~~ ~~ updated copyright dates ~~ diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 8ca431d..720a9b5 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -14,7 +14,7 @@ use Class::MOP::Method; use Class::MOP::Immutable; BEGIN { - our $VERSION = '0.51'; + our $VERSION = '0.52'; our $AUTHORITY = 'cpan:STEVAN'; use XSLoader; diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 7d47e17..67baec4 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -12,7 +12,7 @@ use Carp 'confess'; use Scalar::Util 'blessed', 'reftype', 'weaken'; use Sub::Name 'subname'; -our $VERSION = '0.26'; +our $VERSION = '0.27'; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Module'; @@ -395,7 +395,17 @@ sub clone_instance { sub rebless_instance { my ($self, $instance) = @_; - my $old_metaclass = $instance->meta(); + + my $old_metaclass; + if ($instance->can('meta')) { + ($instance->meta->isa('Class::MOP::Class')) + || confess 'Cannot rebless instance if ->meta is not an instance of Class::MOP::Class'; + $old_metaclass = $instance->meta; + } + else { + $old_metaclass = $self->initialize(blessed($instance)); + } + my $meta_instance = $self->get_meta_instance(); $self->name->isa($old_metaclass->name) diff --git a/lib/Class/MOP/Method/Constructor.pm b/lib/Class/MOP/Method/Constructor.pm index a05ebac..fb3a316 100644 --- a/lib/Class/MOP/Method/Constructor.pm +++ b/lib/Class/MOP/Method/Constructor.pm @@ -7,7 +7,7 @@ use warnings; use Carp 'confess'; use Scalar::Util 'blessed', 'weaken', 'looks_like_number'; -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Method::Generated'; @@ -68,7 +68,7 @@ sub initialize_body { } sub generate_constructor_method { - return sub { (shift)->meta->new_object(@_) } + return sub { Class::MOP::Class->initialize(shift)->new_object(@_) } } sub generate_constructor_method_inline { @@ -77,7 +77,7 @@ sub generate_constructor_method_inline { my $source = 'sub {'; $source .= "\n" . 'my ($class, %params) = @_;'; - $source .= "\n" . 'return $class->meta->new_object(%params)'; + $source .= "\n" . 'return Class::MOP::Class->initialize($class)->new_object(%params)'; $source .= "\n" . ' if $class ne \'' . $self->associated_metaclass->name . '\';'; $source .= "\n" . 'my $instance = ' . $self->meta_instance->inline_create_instance('$class');