cpan: Upgrade AutoLoader to 5.73
authorSteffen Mueller <smueller@cpan.org>
Tue, 16 Oct 2012 15:27:47 +0000 (17:27 +0200)
committerSteffen Mueller <smueller@cpan.org>
Tue, 16 Oct 2012 15:27:47 +0000 (17:27 +0200)
Just syncing to CPAN release.

Porting/Maintainers.pl
cpan/AutoLoader/lib/AutoLoader.pm
cpan/AutoLoader/t/01AutoLoader.t

index 3ddf597..83623c9 100755 (executable)
@@ -255,7 +255,7 @@ use File::Glob qw(:case);
 
     'AutoLoader' => {
         'MAINTAINER'   => 'smueller',
-        'DISTRIBUTION' => 'SMUELLER/AutoLoader-5.72.tar.gz',
+        'DISTRIBUTION' => 'SMUELLER/AutoLoader-5.73.tar.gz',
         'FILES'        => q[cpan/AutoLoader],
         'EXCLUDED'     => ['t/00pod.t'],
         'UPSTREAM'     => 'cpan',
index 8dab836..955f852 100644 (file)
@@ -15,11 +15,18 @@ BEGIN {
     $is_epoc = $^O eq 'epoc';
     $is_vms = $^O eq 'VMS';
     $is_macos = $^O eq 'MacOS';
-    $VERSION = '5.72';
+    $VERSION = '5.73';
 }
 
 AUTOLOAD {
     my $sub = $AUTOLOAD;
+    autoload_sub($sub);
+    goto &$sub;
+}
+
+sub autoload_sub {
+    my $sub = shift;
+
     my $filename = AutoLoader::find_filename( $sub );
 
     my $save = $@;
@@ -48,7 +55,8 @@ AUTOLOAD {
        }
     }
     $@ = $save;
-    goto &$sub;
+
+    return 1;
 }
 
 sub find_filename {
@@ -335,6 +343,21 @@ create the individual files.  L<ExtUtils::MakeMaker> will invoke
 B<AutoSplit> automatically if B<AutoLoader> is used in a module source
 file.
 
+=head2 Forcing AutoLoader to Load a Function
+
+Sometimes, it can be necessary or useful to make sure that a certain
+function is fully loaded by AutoLoader. This is the case, for example,
+when you need to wrap a function to inject debugging code. It is also
+helpful to force early loading of code before forking to make use of
+copy-on-write as much as possible.
+
+Starting with AutoLoader 5.73, you can call the
+C<AutoLoader::autoload_sub> function with the fully-qualified name of
+the function to load from its F<.al> file. The behaviour is exactly
+the same as if you called the function, triggering the regular
+C<AUTOLOAD> mechanism, but it does not actually execute the
+autoloaded function.
+
 =head1 CAVEATS
 
 AutoLoaders prior to Perl 5.002 had a slightly different interface.  Any
@@ -376,7 +399,8 @@ can benefit from bug fixes.
 This package has the same copyright and license as the perl core:
 
              Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-        2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
+        2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+       2011, 2012
         by Larry Wall and others
     
                            All rights reserved.
index dcee5c5..aa52904 100644 (file)
@@ -18,7 +18,7 @@ BEGIN
     unshift @INC, $dir;
 }
 
-use Test::More tests => 18;
+use Test::More tests => 21;
 
 sub write_file {
     my ($file, $text) = @_;
@@ -53,6 +53,12 @@ write_file( File::Spec->catfile( $fulldir, 'blechanawilla.al' ), $blechanawilla_
 # to find the above file so we duplicate it where they should find it.
 write_file( File::Spec->catfile( $fulldir, 'blechanawil.al' ), $blechanawilla_text );
 
+write_file( File::Spec->catfile( $fulldir, 'notreached.al' ), <<'EOT' );
+package Foo;
+sub notreached { die "Should not be reached!" }
+1;
+EOT
+
 # Let's define the package
 package Foo;
 require AutoLoader;
@@ -61,6 +67,7 @@ AutoLoader->import( 'AUTOLOAD' );
 sub new { bless {}, shift };
 sub foo;
 sub bazmarkhianish; 
+sub notreached;
 
 package main;
 
@@ -118,6 +125,16 @@ EOT
 
 Foo::a();
 
+# Test whether autoload_sub works without actually executing the function
+ok(!defined(&Foo::notreached), "Foo::notreached unknown to boot");
+AutoLoader::autoload_sub("Foo::notreached");
+ok(defined(&Foo::notreached), "Foo::notreached loaded by autoload_sub");
+
+# Make sure that repeatedly calling autoload_sub is not a problem:
+AutoLoader::autoload_sub("Foo::notreached");
+eval {Foo::notreached;};
+ok($@ && $@ =~ /Should not/, "Foo::notreached works as expected");
+
 package Bar;
 AutoLoader->import();
 ::ok( ! defined &AUTOLOAD, 'AutoLoader should not export AUTOLOAD by default' );