From: Stevan Little Date: Thu, 13 Dec 2007 01:05:50 +0000 (+0000) Subject: possible bleadperl fix X-Git-Tag: 0_49~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b1f5f41db4b04ea59f1c2f16aab65d7ce3bc4b21;p=gitmo%2FClass-MOP.git possible bleadperl fix --- diff --git a/MOP.xs b/MOP.xs index 9f2476b..4995b02 100644 --- a/MOP.xs +++ b/MOP.xs @@ -18,7 +18,8 @@ get_code_info: MODULE = Class::MOP PACKAGE = Class::MOP SV* -check_package_cache_flag() +check_package_cache_flag(pkg) + SV* pkg CODE: RETVAL = newSViv(PL_sub_generation); OUTPUT: diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 4c18e4c..f9d74aa 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -13,11 +13,18 @@ use Class::MOP::Method; use Class::MOP::Immutable; -our $VERSION = '0.49'; -our $AUTHORITY = 'cpan:STEVAN'; - -use XSLoader; -XSLoader::load( 'Class::MOP', $VERSION ); +BEGIN { + our $VERSION = '0.49'; + our $AUTHORITY = 'cpan:STEVAN'; + + use XSLoader; + XSLoader::load( 'Class::MOP', $VERSION ); + + unless ($] < 5.009_005) { + no warnings 'redefine'; + *check_package_cache_flag = \&mro::get_pkg_gen; + } +} { # Metaclasses are singletons, so we cache them here. @@ -735,7 +742,7 @@ NOTE: This does a basic check of the symbol table to try and determine as best it can if the C<$class_name> is loaded, it is probably correct about 99% of the time. -=item B +=item B =item B diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index ad63d44..0f39343 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -136,13 +136,14 @@ sub construct_class_instance { sub reset_package_cache_flag { (shift)->{'$!_package_cache_flag'} = undef } sub update_package_cache_flag { + my $self = shift; # NOTE: # we can manually update the cache number # since we are actually adding the method # to our cache as well. This avoids us # having to regenerate the method_map. # - SL - (shift)->{'$!_package_cache_flag'} = Class::MOP::check_package_cache_flag(); + $self->{'$!_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); } sub check_metaclass_compatability { @@ -295,7 +296,7 @@ sub get_method_map { my $self = shift; if (defined $self->{'$!_package_cache_flag'} && - $self->{'$!_package_cache_flag'} == Class::MOP::check_package_cache_flag()) { + $self->{'$!_package_cache_flag'} == Class::MOP::check_package_cache_flag($self->name)) { return $self->{'%!methods'}; }