From: Stevan Little Date: Sun, 18 May 2008 16:23:38 +0000 (+0000) Subject: removing ->blessed, blessed is not a method *cough* groditi *cough*,.. and making... X-Git-Tag: 0_64~64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=11b56828515cd0762ef7cbd01a9ea543602ff19e;p=gitmo%2FClass-MOP.git removing ->blessed, blessed is not a method *cough* groditi *cough*,.. and making check_package_cache_flag use the MRO::Compat version --- diff --git a/Changes b/Changes index 9e97d59..7f47eac 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,10 @@ Revision history for Perl extension Class-MOP. 0.56 + * Class::MOP + - we now get the &check_package_cache_flag + function from MRO::Compat + * Class::MOP::Attribute - add has_read_method and has_write_method diff --git a/MOP.xs b/MOP.xs index 6f1e2f6..53724ff 100644 --- a/MOP.xs +++ b/MOP.xs @@ -5,10 +5,6 @@ #include "ppport.h" /* -check_method_cache_flag: - check the PL_sub_generation - ISA/method cache thing - get_code_info: Pass in a coderef, returns: [ $pkg_name, $coderef_name ] ie: @@ -19,14 +15,6 @@ MODULE = Class::MOP PACKAGE = Class::MOP PROTOTYPES: ENABLE -SV* -check_package_cache_flag(pkg) - SV* pkg - CODE: - RETVAL = newSViv(PL_sub_generation); - OUTPUT: - RETVAL - void get_code_info(coderef) SV* coderef diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index db6e3a7..7128954 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -22,15 +22,12 @@ BEGIN { use XSLoader; XSLoader::load( 'Class::MOP', $VERSION ); - unless ($] < 5.009_005) { - require mro; - no warnings 'redefine', 'prototype'; - *check_package_cache_flag = \&mro::get_pkg_gen; - *IS_RUNNING_ON_5_10 = sub () { 1 }; - } - else { - *IS_RUNNING_ON_5_10 = sub () { 0 }; - } + *IS_RUNNING_ON_5_10 = ($] < 5.009_005) + ? sub () { 0 } + : sub () { 1 }; + + # get it from MRO::Compat now ... + *check_package_cache_flag = \&mro::get_pkg_gen; } { diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index 284949a..f767e9a 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -171,7 +171,7 @@ sub make_metaclass_mutable { if ($options{inline_destructor} && $immutable->has_method('DESTROY')) { $immutable->remove_method('DESTROY') - if $immutable->get_method('DESTROY')->blessed eq $options{destructor_class}; + if blessed($immutable->get_method('DESTROY')) eq $options{destructor_class}; } # NOTE: @@ -191,10 +191,10 @@ sub make_metaclass_mutable { # 14:26 <@stevan> the only user of ::Method::Constructor is immutable # 14:27 <@stevan> if someone uses it outside of immutable,.. they are either: mst or groditi # 14:27 <@stevan> so I am not worried - if ($options{inline_constructor}) { + if ($options{inline_constructor} && $immutable->has_method($options{constructor_name})) { my $constructor_class = $options{constructor_class} || 'Class::MOP::Method::Constructor'; $immutable->remove_method( $options{constructor_name} ) - if $immutable->get_method($options{constructor_name})->blessed eq $constructor_class; + if blessed($immutable->get_method($options{constructor_name})) eq $constructor_class; } } diff --git a/t/019_anon_class_keep_alive.t b/t/019_anon_class_keep_alive.t index a1663a9..59422be 100644 --- a/t/019_anon_class_keep_alive.t +++ b/t/019_anon_class_keep_alive.t @@ -24,7 +24,7 @@ my $anon_meta_name; my $anon_class = Class::MOP::Class->create_anon_class(superclasses => [$class]); $anon_class_name = $anon_class->name; - $anon_meta_name = $anon_class->blessed; + $anon_meta_name = Scalar::Util::blessed($anon_class); $anon_class->add_attribute( $_, reader => $_ ) for qw/bar baz/; my $obj = $anon_class->new_object(bar => 'a', baz => 'b'); diff --git a/t/070_immutable_metaclass.t b/t/070_immutable_metaclass.t index f81b0dd..af2781d 100644 --- a/t/070_immutable_metaclass.t +++ b/t/070_immutable_metaclass.t @@ -62,7 +62,7 @@ BEGIN { is_deeply( [ $immutable_metaclass->superclasses ], - [ $meta->blessed ], + [ Scalar::Util::blessed($meta) ], '... immutable_metaclass superclasses are correct' ); ok($immutable_metaclass->has_method('get_mutable_metaclass_name')); diff --git a/t/071_immutable_w_custom_metaclass.t b/t/071_immutable_w_custom_metaclass.t index 4d2eba0..ad7638c 100644 --- a/t/071_immutable_w_custom_metaclass.t +++ b/t/071_immutable_w_custom_metaclass.t @@ -51,8 +51,8 @@ use lib catdir($FindBin::Bin, 'lib'); { my $meta = Baz->meta; ok($meta->is_mutable, '... Baz is mutable'); - is(Foo->meta->blessed, Bar->meta->blessed, 'Foo and Bar immutable metaclasses match'); - is($meta->blessed, 'MyMetaClass', 'Baz->meta blessed as MyMetaClass'); + is(Scalar::Util::blessed(Foo->meta), Scalar::Util::blessed(Bar->meta), 'Foo and Bar immutable metaclasses match'); + is(Scalar::Util::blessed($meta), 'MyMetaClass', 'Baz->meta blessed as MyMetaClass'); ok(Baz->can('mymetaclass_attributes'), '... Baz can do method before immutable'); ok($meta->can('mymetaclass_attributes'), '... meta can do method before immutable'); lives_ok { $meta->make_immutable } "Baz is now immutable"; @@ -60,7 +60,7 @@ use lib catdir($FindBin::Bin, 'lib'); isa_ok($meta, 'MyMetaClass', 'Baz->meta'); ok(Baz->can('mymetaclass_attributes'), '... Baz can do method after imutable'); ok($meta->can('mymetaclass_attributes'), '... meta can do method after immutable'); - isnt(Baz->meta->blessed, Bar->meta->blessed, 'Baz and Bar immutable metaclasses are different'); + isnt(Scalar::Util::blessed(Baz->meta), Scalar::Util::blessed(Bar->meta), 'Baz and Bar immutable metaclasses are different'); lives_ok { $meta->make_mutable } "Baz is now mutable"; ok($meta->is_mutable, '... Baz is mutable again'); }