Make type constraint messages compatible with Moose's
[gitmo/Mouse.git] / lib / Mouse / Util.pm
index 187aa34..46216ec 100644 (file)
@@ -1,7 +1,21 @@
 package Mouse::Util;
 use Mouse::Exporter; # enables strict and warnings
 
-sub get_linear_isa($;$); # must be here
+# must be here because it will be refered by other modules loaded
+sub get_linear_isa($;$); ## no critic
+
+# must be here because it will called in Mouse::Exporter
+sub install_subroutines {
+    my $into = shift;
+
+    while(my($name, $code) = splice @_, 0, 2){
+        no strict 'refs';
+        no warnings 'once', 'redefine';
+        use warnings FATAL => 'uninitialized';
+        *{$into . '::' . $name} = \&{$code};
+    }
+    return;
+}
 
 BEGIN{
     # This is used in Mouse::PurePerl
@@ -38,7 +52,7 @@ BEGIN{
     # Because Mouse::Util is loaded first in all the Mouse sub-modules,
     # XS loader is placed here, not in Mouse.pm.
 
-    our $VERSION = '0.50_03';
+    our $VERSION = '0.59';
 
     my $xs = !(exists $INC{'Mouse/PurePerl.pm'} || $ENV{MOUSE_PUREPERL});
 
@@ -48,6 +62,7 @@ BEGIN{
 
         (my $hack_mouse_file = __FILE__) =~ s/.Util//; # .../Mouse/Util.pm -> .../Mouse.pm
         $xs = eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . q{
+            local $^W = 0; # work around 'redefine' warning to &install_subroutines
             require XSLoader;
             XSLoader::load('Mouse', $VERSION);
             Mouse::Util->import({ into => 'Mouse::Meta::Method::Constructor::XS' }, ':meta');
@@ -68,8 +83,6 @@ BEGIN{
 use Carp         ();
 use Scalar::Util ();
 
-use constant _MOUSE_VERBOSE => !!$ENV{MOUSE_VERBOSE};
-
 # aliases as public APIs
 # it must be 'require', not 'use', because Mouse::Meta::Module depends on Mouse::Util
 require Mouse::Meta::Module; # for the entities of metaclass cache utilities
@@ -231,7 +244,6 @@ sub load_first_existing_class {
 }
 
 # taken from Class/MOP.pm
-my %is_class_loaded_cache;
 sub _try_load_one_class {
     my $class = shift;
 
@@ -240,7 +252,7 @@ sub _try_load_one_class {
         Carp::confess "Invalid class name ($display)";
     }
 
-    return undef if $is_class_loaded_cache{$class} ||= is_class_loaded($class);
+    return '' if is_class_loaded($class);
 
     $class  =~ s{::}{/}g;
     $class .= '.pm';
@@ -353,7 +365,7 @@ Mouse::Util - Features, with or without their dependencies
 
 =head1 VERSION
 
-This document describes Mouse version 0.50_03
+This document describes Mouse version 0.59
 
 =head1 IMPLEMENTATIONS FOR