In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/da4061d33235769184e98cc28663a2dd54302fa8?hp=4f65bc30ea83f40e28f0ea56d45f48f300db8fcc>
- Log ----------------------------------------------------------------- commit da4061d33235769184e98cc28663a2dd54302fa8 Author: Nicholas Clark <[email protected]> Date: Thu Oct 14 21:44:08 2010 +0100 Convert modules in ext/ to pass minimal arguments to XSLoader::load(). M ext/B/B.pm M ext/Devel-Peek/Peek.pm M ext/Fcntl/Fcntl.pm M ext/File-Glob/Glob.pm M ext/GDBM_File/GDBM_File.pm M ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm M ext/NDBM_File/NDBM_File.pm M ext/ODBM_File/ODBM_File.pm M ext/Opcode/Opcode.pm M ext/POSIX/lib/POSIX.pm M ext/PerlIO-encoding/encoding.pm M ext/PerlIO-scalar/scalar.pm M ext/PerlIO-via/via.pm M ext/SDBM_File/SDBM_File.pm M ext/Socket/Socket.pm M ext/Sys-Hostname/Hostname.pm M ext/Tie-Hash-NamedCapture/NamedCapture.pm M ext/attributes/attributes.pm M ext/mro/mro.pm M ext/re/re.pm commit 1d2b7ec55763d41a18a61d1b44aedd531d305ad3 Author: Nicholas Clark <[email protected]> Date: Thu Oct 14 21:30:16 2010 +0100 XSLoader::load() with no arguments can use caller to find a default package. In the case of dynamic linking, it's already using caller to get a filename, so this isn't usually any extra work. M dist/XSLoader/XSLoader_pm.PL M dist/XSLoader/t/XSLoader.t ----------------------------------------------------------------------- Summary of changes: dist/XSLoader/XSLoader_pm.PL | 30 +++++++++++-------- dist/XSLoader/t/XSLoader.t | 28 ++++++++++-------- ext/B/B.pm | 6 ++-- ext/Devel-Peek/Peek.pm | 6 ++-- ext/Fcntl/Fcntl.pm | 6 ++-- ext/File-Glob/Glob.pm | 6 ++-- ext/GDBM_File/GDBM_File.pm | 4 +- ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm | 4 +- ext/NDBM_File/NDBM_File.pm | 6 ++-- ext/ODBM_File/ODBM_File.pm | 6 ++-- ext/Opcode/Opcode.pm | 6 ++-- ext/POSIX/lib/POSIX.pm | 6 ++-- ext/PerlIO-encoding/encoding.pm | 6 ++-- ext/PerlIO-scalar/scalar.pm | 6 ++-- ext/PerlIO-via/via.pm | 6 ++-- ext/SDBM_File/SDBM_File.pm | 6 ++-- ext/Socket/Socket.pm | 6 ++-- ext/Sys-Hostname/Hostname.pm | 4 +- ext/Tie-Hash-NamedCapture/NamedCapture.pm | 2 +- ext/attributes/attributes.pm | 4 +- ext/mro/mro.pm | 4 +- ext/re/re.pm | 4 +- 22 files changed, 84 insertions(+), 78 deletions(-) diff --git a/dist/XSLoader/XSLoader_pm.PL b/dist/XSLoader/XSLoader_pm.PL index 66afa8e..0738fa5 100644 --- a/dist/XSLoader/XSLoader_pm.PL +++ b/dist/XSLoader/XSLoader_pm.PL @@ -8,7 +8,7 @@ print OUT <<'EOT'; package XSLoader; -$VERSION = "0.12"; +$VERSION = "0.13"; #use strict; @@ -26,9 +26,13 @@ package XSLoader; sub load { package DynaLoader; - die q{XSLoader::load('Your::Module', $Your::Module::VERSION)} unless @_; + my ($module, $modlibname) = caller(); - my($module) = $_[0]; + if (@_) { + $module = $_[0]; + } else { + $_[0] = $module; + } # work with static linking too my $boots = "$module\::bootstrap"; @@ -58,7 +62,6 @@ EOT print OUT <<'EOT'; my $modpname = join('/',@modparts); - my $modlibname = (caller())[1]; my $c = @modparts; $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename EOT @@ -178,14 +181,14 @@ XSLoader - Dynamically load C libraries into Perl code =head1 VERSION -Version 0.10 +Version 0.13 =head1 SYNOPSIS package YourPackage; - use XSLoader; + require XSLoader; - XSLoader::load 'YourPackage', $YourPackage::VERSION; + XSLoader::load(); =head1 DESCRIPTION @@ -234,6 +237,13 @@ If no C<$VERSION> was specified on the C<bootstrap> line, the last line becomes XSLoader::load 'YourPackage'; +If the call to C<load> is from the YourPackage, then that can be further +simplified to + + XSLoader::load(); + +as C<load> will use C<caller> to determine the package. + =head2 Backward compatible boilerplate If you want to have your cake and eat it too, you need a more complicated @@ -367,14 +377,8 @@ B<(W)> As the message says, some symbols stay undefined although the extension module was correctly loaded and initialised. The list of undefined symbols follows. -=item C<XSLoader::load('Your::Module', $Your::Module::VERSION)> - -B<(F)> You tried to invoke C<load()> without any argument. You must supply -a module name, and optionally its version. - =back - =head1 LIMITATIONS To reduce the overhead as much as possible, only one possible location diff --git a/dist/XSLoader/t/XSLoader.t b/dist/XSLoader/t/XSLoader.t index 211c4d8..0cac1f2 100644 --- a/dist/XSLoader/t/XSLoader.t +++ b/dist/XSLoader/t/XSLoader.t @@ -30,7 +30,7 @@ my %modules = ( 'Time::HiRes'=> q| ::can_ok( 'Time::HiRes' => 'usleep' ) |, # 5.7.3 ); -plan tests => keys(%modules) * 3 + 5; +plan tests => keys(%modules) * 3 + 7; # Try to load the module use_ok( 'XSLoader' ); @@ -40,18 +40,20 @@ can_ok( 'XSLoader' => 'load' ); can_ok( 'XSLoader' => 'bootstrap_inherit' ); # Check error messages -eval { XSLoader::load() }; -like( $@, '/^XSLoader::load\(\'Your::Module\', \$Your::Module::VERSION\)/', - "calling XSLoader::load() with no argument" ); - -eval q{ package Thwack; XSLoader::load('Thwack'); }; -if ($Config{usedl}) { - like( $@, q{/^Can't locate loadable object for module Thwack in @INC/}, - "calling XSLoader::load() under a package with no XS part" ); -} -else { - like( $@, q{/^Can't load module Thwack, dynamic loading not available in this perl./}, - "calling XSLoader::load() under a package with no XS part" ); +foreach (['Thwack', 'package Thwack; XSLoader::load(); 1'], + ['Zlott', 'package Thwack; XSLoader::load("Zlott"); 1'], + ) { + my ($should_load, $codestr) = @$_; + is(eval $codestr, undef, "eval '$codestr' should die"); + + if ($Config{usedl}) { + like( $@, qr/^Can't locate loadable object for module $should_load in \...@inc/, + "calling XSLoader::load() under a package with no XS part" ); + } + else { + like( $@, qr/^Can't load module $should_load, dynamic loading not available in this perl./, + "calling XSLoader::load() under a package with no XS part" ); + } } # Now try to load well known XS modules diff --git a/ext/B/B.pm b/ext/B/B.pm index f7d22f1..3d254b5 100644 --- a/ext/B/B.pm +++ b/ext/B/B.pm @@ -7,9 +7,9 @@ # package B; -our $VERSION = '1.23'; +our $VERSION = '1.24'; -use XSLoader (); +require XSLoader; require Exporter; @ISA = qw(Exporter); @@ -315,7 +315,7 @@ sub walksymtable { } } -XSLoader::load 'B'; +XSLoader::load(); 1; diff --git a/ext/Devel-Peek/Peek.pm b/ext/Devel-Peek/Peek.pm index 2fced31..e6efe03 100644 --- a/ext/Devel-Peek/Peek.pm +++ b/ext/Devel-Peek/Peek.pm @@ -3,12 +3,12 @@ package Devel::Peek; -$VERSION = '1.04'; +$VERSION = '1.05'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; require Exporter; -use XSLoader (); +require XSLoader; @ISA = qw(Exporter); @EXPORT = qw(Dump mstat DeadCode DumpArray DumpWithOP DumpProg @@ -16,7 +16,7 @@ use XSLoader (); @EXPORT_OK = qw(SvREFCNT SvREFCNT_inc SvREFCNT_dec CvGV); %EXPORT_TAGS = ('ALL' => [...@export, @EXPORT_OK]); -XSLoader::load 'Devel::Peek'; +XSLoader::load(); sub import { my $c = shift; diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 83edeb6..e173c34 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -59,10 +59,9 @@ use strict; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $AUTOLOAD); require Exporter; -use XSLoader (); @ISA = qw(Exporter); BEGIN { - $VERSION = "1.06"; + $VERSION = "1.07"; } # Items to export into callers namespace by default @@ -212,7 +211,8 @@ BEGIN { # Force the constants to become inlined BEGIN { - XSLoader::load 'Fcntl', $VERSION; + require XSLoader; + XSLoader::load(); } sub S_IFMT { @_ ? ( $_[0] & _S_IFMT() ) : _S_IFMT() } diff --git a/ext/File-Glob/Glob.pm b/ext/File-Glob/Glob.pm index 240e0a5..dcd9a47 100644 --- a/ext/File-Glob/Glob.pm +++ b/ext/File-Glob/Glob.pm @@ -4,7 +4,7 @@ use strict; our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, $AUTOLOAD, $DEFAULT_FLAGS); -use XSLoader (); +require XSLoader; @ISA = qw(Exporter); @@ -56,7 +56,7 @@ use XSLoader (); ) ], ); -$VERSION = '1.08'; +$VERSION = '1.09'; sub import { require Exporter; @@ -93,7 +93,7 @@ sub AUTOLOAD { goto &$AUTOLOAD; } -XSLoader::load 'File::Glob', $VERSION; +XSLoader::load(); # Preloaded methods go here. diff --git a/ext/GDBM_File/GDBM_File.pm b/ext/GDBM_File/GDBM_File.pm index 0b4182c..5520b3f 100644 --- a/ext/GDBM_File/GDBM_File.pm +++ b/ext/GDBM_File/GDBM_File.pm @@ -48,7 +48,7 @@ our($VERSION, @ISA, @EXPORT, $AUTOLOAD); require Carp; require Tie::Hash; require Exporter; -use XSLoader (); +require XSLoader; @ISA = qw(Tie::Hash Exporter); @EXPORT = qw( GDBM_CACHESIZE @@ -81,6 +81,6 @@ sub AUTOLOAD { goto &{$AUTOLOAD}; } -XSLoader::load 'GDBM_File', $VERSION; +XSLoader::load(); 1; diff --git a/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm b/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm index bca3a6f..a7da25f 100644 --- a/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm +++ b/ext/Hash-Util-FieldHash/lib/Hash/Util/FieldHash.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Scalar::Util qw( reftype); -our $VERSION = '1.04'; +our $VERSION = '1.05'; require Exporter; our @ISA = qw(Exporter); @@ -26,7 +26,7 @@ our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); require XSLoader; my %ob_reg; # private object registry sub _ob_reg { \ %ob_reg } - XSLoader::load('Hash::Util::FieldHash', $VERSION); + XSLoader::load(); } sub fieldhash (\%) { diff --git a/ext/NDBM_File/NDBM_File.pm b/ext/NDBM_File/NDBM_File.pm index 3183395..e6c3fa4 100644 --- a/ext/NDBM_File/NDBM_File.pm +++ b/ext/NDBM_File/NDBM_File.pm @@ -4,12 +4,12 @@ use strict; use warnings; require Tie::Hash; -use XSLoader (); +require XSLoader; our @ISA = qw(Tie::Hash); -our $VERSION = "1.08"; +our $VERSION = "1.09"; -XSLoader::load 'NDBM_File', $VERSION; +XSLoader::load(); 1; diff --git a/ext/ODBM_File/ODBM_File.pm b/ext/ODBM_File/ODBM_File.pm index 044e493..52f9563 100644 --- a/ext/ODBM_File/ODBM_File.pm +++ b/ext/ODBM_File/ODBM_File.pm @@ -4,12 +4,12 @@ use strict; use warnings; require Tie::Hash; -use XSLoader (); +require XSLoader; our @ISA = qw(Tie::Hash); -our $VERSION = "1.07"; +our $VERSION = "1.08"; -XSLoader::load 'ODBM_File', $VERSION; +XSLoader::load(); 1; diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm index 9dbbce0..3776324 100644 --- a/ext/Opcode/Opcode.pm +++ b/ext/Opcode/Opcode.pm @@ -6,11 +6,11 @@ use strict; our($VERSION, @ISA, @EXPORT_OK); -$VERSION = "1.15"; +$VERSION = "1.16"; use Carp; use Exporter (); -use XSLoader (); +use XSLoader; BEGIN { @ISA = qw(Exporter); @@ -28,7 +28,7 @@ sub opset_to_hex ($); sub opdump (;$); use subs @EXPORT_OK; -XSLoader::load 'Opcode', $VERSION; +XSLoader::load(); _init_optags(); diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm index a43b76b..fbbbcd1 100644 --- a/ext/POSIX/lib/POSIX.pm +++ b/ext/POSIX/lib/POSIX.pm @@ -4,11 +4,11 @@ use warnings; our(@ISA, %EXPORT_TAGS, @EXPORT_OK, @EXPORT, $AUTOLOAD, %SIGRT) = (); -our $VERSION = "1.20"; +our $VERSION = "1.21"; use AutoLoader; -use XSLoader (); +require XSLoader; use Fcntl qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK O_ACCMODE O_APPEND @@ -33,7 +33,7 @@ sub croak { require Carp; goto &Carp::croak } # declare usage to assist AutoLoad sub usage; -XSLoader::load 'POSIX', $VERSION; +XSLoader::load(); sub AUTOLOAD { no strict; diff --git a/ext/PerlIO-encoding/encoding.pm b/ext/PerlIO-encoding/encoding.pm index 4b44670..305fa07 100644 --- a/ext/PerlIO-encoding/encoding.pm +++ b/ext/PerlIO-encoding/encoding.pm @@ -1,7 +1,7 @@ package PerlIO::encoding; use strict; -our $VERSION = '0.12'; +our $VERSION = '0.13'; our $DEBUG = 0; $DEBUG and warn __PACKAGE__, " called by ", join(", ", caller), "\n"; @@ -10,8 +10,8 @@ $DEBUG and warn __PACKAGE__, " called by ", join(", ", caller), "\n"; # # use Encode (); -use XSLoader (); -XSLoader::load(__PACKAGE__, $VERSION); +require XSLoader; +XSLoader::load(); our $fallback = Encode::PERLQQ()|Encode::WARN_ON_ERR()|Encode::STOP_AT_PARTIAL(); diff --git a/ext/PerlIO-scalar/scalar.pm b/ext/PerlIO-scalar/scalar.pm index 7fe1f50..66fe66e 100644 --- a/ext/PerlIO-scalar/scalar.pm +++ b/ext/PerlIO-scalar/scalar.pm @@ -1,7 +1,7 @@ package PerlIO::scalar; -our $VERSION = '0.09'; -use XSLoader (); -XSLoader::load 'PerlIO::scalar'; +our $VERSION = '0.10'; +require XSLoader; +XSLoader::load(); 1; __END__ diff --git a/ext/PerlIO-via/via.pm b/ext/PerlIO-via/via.pm index 077f0d1..b5d519d 100644 --- a/ext/PerlIO-via/via.pm +++ b/ext/PerlIO-via/via.pm @@ -1,7 +1,7 @@ package PerlIO::via; -our $VERSION = '0.09'; -use XSLoader (); -XSLoader::load 'PerlIO::via'; +our $VERSION = '0.10'; +require XSLoader; +XSLoader::load(); 1; __END__ diff --git a/ext/SDBM_File/SDBM_File.pm b/ext/SDBM_File/SDBM_File.pm index d1209e0..2df7e68 100644 --- a/ext/SDBM_File/SDBM_File.pm +++ b/ext/SDBM_File/SDBM_File.pm @@ -4,12 +4,12 @@ use strict; use warnings; require Tie::Hash; -use XSLoader (); +require XSLoader; our @ISA = qw(Tie::Hash); -our $VERSION = "1.06"; +our $VERSION = "1.07"; -XSLoader::load 'SDBM_File', $VERSION; +XSLoader::load(); 1; diff --git a/ext/Socket/Socket.pm b/ext/Socket/Socket.pm index 20224e4..1cffe6b 100644 --- a/ext/Socket/Socket.pm +++ b/ext/Socket/Socket.pm @@ -1,7 +1,7 @@ package Socket; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); -$VERSION = "1.89"; +$VERSION = "1.90"; =head1 NAME @@ -198,7 +198,7 @@ use Carp; use warnings::register; require Exporter; -use XSLoader (); +require XSLoader; @ISA = qw(Exporter); @EXPORT = qw( inet_aton inet_ntoa @@ -443,6 +443,6 @@ sub AUTOLOAD { goto &$AUTOLOAD; } -XSLoader::load 'Socket', $VERSION; +XSLoader::load(); 1; diff --git a/ext/Sys-Hostname/Hostname.pm b/ext/Sys-Hostname/Hostname.pm index 415f951..2e2e53b 100644 --- a/ext/Sys-Hostname/Hostname.pm +++ b/ext/Sys-Hostname/Hostname.pm @@ -15,12 +15,12 @@ our $VERSION; our $host; BEGIN { - $VERSION = '1.11'; + $VERSION = '1.13'; { local $SIG{__DIE__}; eval { require XSLoader; - XSLoader::load('Sys::Hostname', $VERSION); + XSLoader::load(); }; warn $@ if $@; } diff --git a/ext/Tie-Hash-NamedCapture/NamedCapture.pm b/ext/Tie-Hash-NamedCapture/NamedCapture.pm index 065d68d..814e90d 100644 --- a/ext/Tie-Hash-NamedCapture/NamedCapture.pm +++ b/ext/Tie-Hash-NamedCapture/NamedCapture.pm @@ -4,7 +4,7 @@ package Tie::Hash::NamedCapture; our $VERSION = "0.07"; require XSLoader; -XSLoader::load(__PACKAGE__); +XSLoader::load(); my ($one, $all) = Tie::Hash::NamedCapture::flags(); diff --git a/ext/attributes/attributes.pm b/ext/attributes/attributes.pm index c117bef..cdb015e 100644 --- a/ext/attributes/attributes.pm +++ b/ext/attributes/attributes.pm @@ -1,6 +1,6 @@ package attributes; -our $VERSION = 0.12; +our $VERSION = 0.13; @EXPORT_OK = qw(get reftype); @EXPORT = (); @@ -98,7 +98,7 @@ sub get ($) { sub require_version { goto &UNIVERSAL::VERSION } require XSLoader; -XSLoader::load('attributes', $VERSION); +XSLoader::load(); 1; __END__ diff --git a/ext/mro/mro.pm b/ext/mro/mro.pm index 870b688..8001b7a 100644 --- a/ext/mro/mro.pm +++ b/ext/mro/mro.pm @@ -12,7 +12,7 @@ use warnings; # mro.pm versions < 1.00 reserved for MRO::Compat # for partial back-compat to 5.[68].x -our $VERSION = '1.03'; +our $VERSION = '1.04'; sub import { mro::set_mro(scalar(caller), $_[1]) if $_[1]; @@ -38,7 +38,7 @@ sub method { } require XSLoader; -XSLoader::load('mro', $VERSION); +XSLoader::load('mro'); 1; diff --git a/ext/re/re.pm b/ext/re/re.pm index 2d6784a..90e31f3 100644 --- a/ext/re/re.pm +++ b/ext/re/re.pm @@ -4,7 +4,7 @@ package re; use strict; use warnings; -our $VERSION = "0.12"; +our $VERSION = "0.13"; our @ISA = qw(Exporter); our @EXPORT_OK = ('regmust', qw(is_regexp regexp_pattern @@ -66,7 +66,7 @@ $flags{TRIE} = $flags{DUMP} | $flags{EXECUTE} | $flags{TRIEC}; if (defined &DynaLoader::boot_DynaLoader) { require XSLoader; - XSLoader::load( __PACKAGE__, $VERSION); + XSLoader::load(); } # else we're miniperl # We need to work for miniperl, because the XS toolchain uses Text::Wrap, which -- Perl5 Master Repository
