X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FUtil.pm;h=8d4eadb5cb761cff404b41f557ab2130320a705f;hp=5f3df61f50c9486bc60d0fd00cb3c54514522bc4;hb=db5e440949ed1cdf6c788ea7653a488bc8f1b92e;hpb=460eb22dd849bdfdd8dd73c22799ca37bfbf2ec8 diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 5f3df61..8d4eadb 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -7,25 +7,27 @@ BEGIN{ our $VERSION = '0.40_04'; - my $need_pp = !!$ENV{MOUSE_PUREPERL}; + my $xs = !(exists $INC{'Mouse/PurePerl.pm'} || $ENV{MOUSE_PUREPERL}); - if(!$need_pp && !exists $INC{'Mouse/PurePerl.pm'}){ + if($xs){ local $@; # XXX: XSLoader tries to get the object path from caller's file name # $hack_mouse_file fools its mechanism (my $hack_mouse_file = __FILE__) =~ s/.Util//; # .../Mouse/Util.pm -> .../Mouse.pm - $need_pp = !eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . q{ + $xs = eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . q{ require XSLoader; XSLoader::load('Mouse', $VERSION); }; #warn $@ if $@; } - if($need_pp){ + if(!$xs){ require 'Mouse/PurePerl.pm'; # we don't want to create its namespace } + + *_MOUSE_XS = sub(){ $xs }; }