Add prototype behaviour to MOP.xs to silence warnings during XS build time.
[gitmo/Class-MOP.git] / lib / Class / MOP.pm
index 14afdef..9d0c16e 100644 (file)
@@ -13,8 +13,18 @@ use Class::MOP::Method;
 
 use Class::MOP::Immutable;
 
-our $VERSION   = '0.43';
-our $AUTHORITY = 'cpan:STEVAN';
+BEGIN {
+    our $VERSION   = '0.50';
+    our $AUTHORITY = 'cpan:STEVAN';    
+    
+    use XSLoader;
+    XSLoader::load( 'Class::MOP', $VERSION );    
+    
+    unless ($] < 5.009_005) {
+        no warnings 'redefine', 'prototype';
+        *check_package_cache_flag = \&mro::get_pkg_gen;
+    }
+}
 
 {
     # Metaclasses are singletons, so we cache them here.
@@ -405,12 +415,12 @@ Class::MOP::Attribute->meta->add_method('new' => sub {
             if ref $options{builder} || !(defined $options{builder});
         confess("Setting both default and builder is not allowed.")
             if exists $options{default};
+    } else {
+        (Class::MOP::Attribute::is_default_a_coderef(\%options))
+            || confess("References are not allowed as default values, you must ".
+                       "wrap then in a CODE reference (ex: sub { [] } and not [])")
+                if exists $options{default} && ref $options{default};
     }
-    (Class::MOP::Attribute::is_default_a_coderef(\%options))
-        || confess("References are not allowed as default values, you must ".
-                   "wrap then in a CODE reference (ex: sub { [] } and not [])")
-            if exists $options{default} && ref $options{default};
-
     # return the new object
     $class->meta->new_object(name => $name, %options);
 });
@@ -732,6 +742,10 @@ 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 ($pkg)>
+
+=item B<get_code_info ($code)>
+
 =back
 
 =head2 Metaclass cache functions
@@ -881,6 +895,8 @@ Rob (robkinyon) Kinyon
 
 Yuval (nothingmuch) Kogman
 
+Scott (konobi) McWhirter
+
 =head1 COPYRIGHT AND LICENSE
 
 Copyright 2006, 2007 by Infinity Interactive, Inc.