Hack for XSLoader
[gitmo/Mouse.git] / lib / Mouse / Util.pm
index a5678b9..949b654 100644 (file)
@@ -11,7 +11,13 @@ BEGIN{
 
     if(!$need_pp && !exists $INC{'Mouse/PurePerl.pm'}){
         local $@;
-        $need_pp = !eval{
+
+        # 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
+        print "$hack_mouse_file\n";
+        $need_pp = !eval sprintf("#line %d %s\n", __LINE__, $hack_mouse_file) . q{
             require XSLoader;
             XSLoader::load('Mouse', $VERSION);
         };