possible bleadperl fix
Stevan Little [Thu, 13 Dec 2007 01:05:50 +0000 (01:05 +0000)]
MOP.xs
lib/Class/MOP.pm
lib/Class/MOP/Class.pm

diff --git a/MOP.xs b/MOP.xs
index 9f2476b..4995b02 100644 (file)
--- 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:
index 4c18e4c..f9d74aa 100644 (file)
@@ -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<check_package_cache_flag>
+=item B<check_package_cache_flag ($pkg)>
 
 =item B<get_code_info ($code)>
 
index ad63d44..0f39343 100644 (file)
@@ -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'};
     }