revert XS related things. this is no advantage orz
[gitmo/Mouse.git] / lib / Mouse.pm
index 708b0a5..22d07eb 100644 (file)
@@ -6,7 +6,6 @@ use 5.006;
 use base 'Exporter';
 
 our $VERSION;
-our $PurePerl;
 
 BEGIN {
     $VERSION  = '0.12';
@@ -16,18 +15,6 @@ BEGIN {
     } else {
         *DEBUG = sub (){ 0 };
     }
-
-    if (! defined $PurePerl && $ENV{MOUSE_PUREPERL} && $ENV{MOUSE_PUREPERL} =~ /^(.+)$/) {
-        $PurePerl = $1;
-    }
-
-    if (! $PurePerl) {
-        local $@;
-        local $^W = 0;
-        require XSLoader;
-        $PurePerl = ! eval{ XSLoader::load(__PACKAGE__, $VERSION); 1 };
-        warn "Failed to load XS mode: $@" if $@; #  && Mouse::DEBUG();
-    }
 }
 
 use Carp 'confess';
@@ -89,18 +76,12 @@ sub around {
 }
 
 sub with {
-    my $meta = Mouse::Meta::Class->initialize(caller);
-
-    my $role  = shift;
-    my $args  = shift || {};
-
-    confess "Mouse::Role only supports 'with' on individual roles at a time" if @_ || !ref $args;
-
-    Mouse::load_class($role);
-    $role->meta->apply($meta, %$args);
+    Mouse::Util::apply_all_roles((caller)[0], @_);
 }
 
 sub import {
+    my $class = shift;
+
     strict->import;
     warnings->import;
 
@@ -114,7 +95,15 @@ sub import {
     no warnings 'redefine';
     *{$caller.'::meta'} = sub { $meta };
 
-    __PACKAGE__->export_to_level( 1, @_);
+    if (@_) {
+        __PACKAGE__->export_to_level( 1, $class, @_);
+    } else {
+        # shortcut for the common case of no type character
+        no strict 'refs';
+        for my $keyword (@EXPORT) {
+            *{ $caller . '::' . $keyword } = *{__PACKAGE__ . '::' . $keyword};
+        }
+    }
 }
 
 sub unimport {