diff options
author | Steffen Mueller <smueller@cpan.org> | 2009-09-21 15:58:31 +0200 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2009-09-21 15:58:31 +0200 |
commit | 248f30289f80d02b83f3d80d7ff575cb3e758ced (patch) | |
tree | 2b76ecd398a33a18ed45b214582fe78bd5a7d584 | |
parent | 7e4c21aaad0cc18d004f5e2f89535e35778178a8 (diff) | |
download | perl-248f30289f80d02b83f3d80d7ff575cb3e758ced.tar.gz |
Upgrade to Attribute::Handlers 0.87 (which is just a core sync)
-rw-r--r-- | ext/Attribute-Handlers/Changes | 23 | ||||
-rw-r--r-- | ext/Attribute-Handlers/lib/Attribute/Handlers.pm | 6 | ||||
-rw-r--r-- | ext/XSLoader/XSLoader.pm | 358 | ||||
-rw-r--r-- | ext/lib/lib.pm | 242 |
4 files changed, 625 insertions, 4 deletions
diff --git a/ext/Attribute-Handlers/Changes b/ext/Attribute-Handlers/Changes index 13dd6f5677..f91fa607a8 100644 --- a/ext/Attribute-Handlers/Changes +++ b/ext/Attribute-Handlers/Changes @@ -1,4 +1,4 @@ -Revision history for Perl extension Attribute-Handlers +t Revision history for Perl extension Attribute-Handlers 0.50 Sat Apr 21 16:09:31 2001 - original version; @@ -132,3 +132,24 @@ Revision history for Perl extension Attribute-Handlers 0.86 Sat Aug 8 12:41:00 CET 2009 - Add resources (bugtracker, ...) section to META.yml +0.86_01 Thu Sep 17 10:01:00 CET 2009 + - From perl change 09330df80caf214f375fcf0c04857347e3b17c69 (Zefram): + + Fix [perl #66970] Incorrect coderef in MODIFY_CODE_ATTRIBUTES + + Attribute handlers being applied to a temporary CV has actually been + reported as a bug, #66970. The attached patch fixes the bug, by + changing the order in which things happen: attributes are now applied + after the temporary CV has been merged into the existing CV or has + otherwise been added to the appropriate GV. + + The change breaks part of Attribute::Handlers. Part of A:H searches the + package to find the name of the sub to which a :ATTR attribute is being + applied, and the correct time at which to launch that search depends + crucially on the order in which the CV construction events occur. So + this patch also includes a change to A:H, to make it detect which way + things happen. The resulting A:H works either way, which is essential + for its dual-life nature. + +0.87 Mon Sep 21 15:55:00 CET 2009 + - Promote to stable release diff --git a/ext/Attribute-Handlers/lib/Attribute/Handlers.pm b/ext/Attribute-Handlers/lib/Attribute/Handlers.pm index b8625ae0f4..ea11b8f7ed 100644 --- a/ext/Attribute-Handlers/lib/Attribute/Handlers.pm +++ b/ext/Attribute-Handlers/lib/Attribute/Handlers.pm @@ -4,7 +4,7 @@ use Carp; use warnings; use strict; use vars qw($VERSION $AUTOLOAD); -$VERSION = '0.86'; # remember to update version in POD! +$VERSION = '0.87'; # remember to update version in POD! # $DB::single=1; my %symcache; @@ -257,8 +257,8 @@ Attribute::Handlers - Simpler definition of attribute handlers =head1 VERSION -This document describes version 0.86 of Attribute::Handlers, -released August 8, 2009. +This document describes version 0.87 of Attribute::Handlers, +released September 21, 2009. =head1 SYNOPSIS diff --git a/ext/XSLoader/XSLoader.pm b/ext/XSLoader/XSLoader.pm new file mode 100644 index 0000000000..28130c1af1 --- /dev/null +++ b/ext/XSLoader/XSLoader.pm @@ -0,0 +1,358 @@ +# Generated from XSLoader.pm.PL (resolved %Config::Config value) + +package XSLoader; + +$VERSION = "0.10"; + +#use strict; + +# enable debug/trace messages from DynaLoader perl code +# $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug; + + my $dl_dlext = 'so'; + +package DynaLoader; + +# No prizes for guessing why we don't say 'bootstrap DynaLoader;' here. +# NOTE: All dl_*.xs (including dl_none.xs) define a dl_error() XSUB +boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && + !defined(&dl_error); +package XSLoader; + +sub load { + package DynaLoader; + + die q{XSLoader::load('Your::Module', $Your::Module::VERSION)} unless @_; + + my($module) = $_[0]; + + # work with static linking too + my $boots = "$module\::bootstrap"; + goto &$boots if defined &$boots; + + goto retry unless $module and defined &dl_load_file; + + my @modparts = split(/::/,$module); + my $modfname = $modparts[-1]; + + my $modpname = join('/',@modparts); + my $modlibname = (caller())[1]; + my $c = @modparts; + $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename + my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext"; + +# print STDERR "XSLoader::load for $module ($file)\n" if $dl_debug; + + my $bs = $file; + $bs =~ s/(\.\w+)?(;\d*)?$/\.bs/; # look for .bs 'beside' the library + + if (-s $bs) { # only read file if it's not empty +# print STDERR "BS: $bs ($^O, $dlsrc)\n" if $dl_debug; + eval { do $bs; }; + warn "$bs: $@\n" if $@; + } + + goto retry if not -f $file or -s $bs; + + my $bootname = "boot_$module"; + $bootname =~ s/\W/_/g; + @DynaLoader::dl_require_symbols = ($bootname); + + my $boot_symbol_ref; + + # Many dynamic extension loading problems will appear to come from + # this section of code: XYZ failed at line 123 of DynaLoader.pm. + # Often these errors are actually occurring in the initialisation + # C code of the extension XS file. Perl reports the error as being + # in this perl code simply because this was the last perl code + # it executed. + + my $libref = dl_load_file($file, 0) or do { + require Carp; + Carp::croak("Can't load '$file' for module $module: " . dl_error()); + }; + push(@DynaLoader::dl_librefs,$libref); # record loaded object + + my @unresolved = dl_undef_symbols(); + if (@unresolved) { + require Carp; + Carp::carp("Undefined symbols present after loading $file: @unresolved\n"); + } + + $boot_symbol_ref = dl_find_symbol($libref, $bootname) or do { + require Carp; + Carp::croak("Can't find '$bootname' symbol in $file\n"); + }; + + push(@DynaLoader::dl_modules, $module); # record loaded module + + boot: + my $xs = dl_install_xsub($boots, $boot_symbol_ref, $file); + + # See comment block above + push(@DynaLoader::dl_shared_objects, $file); # record files loaded + return &$xs(@_); + + retry: + my $bootstrap_inherit = DynaLoader->can('bootstrap_inherit') || + XSLoader->can('bootstrap_inherit'); + goto &$bootstrap_inherit; +} + +# Versions of DynaLoader prior to 5.6.0 don't have this function. +sub bootstrap_inherit { + package DynaLoader; + + my $module = $_[0]; + local *DynaLoader::isa = *{"$module\::ISA"}; + local @DynaLoader::isa = (@DynaLoader::isa, 'DynaLoader'); + # Cannot goto due to delocalization. Will report errors on a wrong line? + require DynaLoader; + DynaLoader::bootstrap(@_); +} + +1; + + +__END__ + +=head1 NAME + +XSLoader - Dynamically load C libraries into Perl code + +=head1 VERSION + +Version 0.10 + +=head1 SYNOPSIS + + package YourPackage; + use XSLoader; + + XSLoader::load 'YourPackage', $YourPackage::VERSION; + +=head1 DESCRIPTION + +This module defines a standard I<simplified> interface to the dynamic +linking mechanisms available on many platforms. Its primary purpose is +to implement cheap automatic dynamic loading of Perl modules. + +For a more complicated interface, see L<DynaLoader>. Many (most) +features of C<DynaLoader> are not implemented in C<XSLoader>, like for +example the C<dl_load_flags>, not honored by C<XSLoader>. + +=head2 Migration from C<DynaLoader> + +A typical module using L<DynaLoader|DynaLoader> starts like this: + + package YourPackage; + require DynaLoader; + + our @ISA = qw( OnePackage OtherPackage DynaLoader ); + our $VERSION = '0.01'; + bootstrap YourPackage $VERSION; + +Change this to + + package YourPackage; + use XSLoader; + + our @ISA = qw( OnePackage OtherPackage ); + our $VERSION = '0.01'; + XSLoader::load 'YourPackage', $VERSION; + +In other words: replace C<require DynaLoader> by C<use XSLoader>, remove +C<DynaLoader> from C<@ISA>, change C<bootstrap> by C<XSLoader::load>. Do not +forget to quote the name of your package on the C<XSLoader::load> line, +and add comma (C<,>) before the arguments (C<$VERSION> above). + +Of course, if C<@ISA> contained only C<DynaLoader>, there is no need to have +the C<@ISA> assignment at all; moreover, if instead of C<our> one uses the +more backward-compatible + + use vars qw($VERSION @ISA); + +one can remove this reference to C<@ISA> together with the C<@ISA> assignment. + +If no C<$VERSION> was specified on the C<bootstrap> line, the last line becomes + + XSLoader::load 'YourPackage'; + +=head2 Backward compatible boilerplate + +If you want to have your cake and eat it too, you need a more complicated +boilerplate. + + package YourPackage; + use vars qw($VERSION @ISA); + + @ISA = qw( OnePackage OtherPackage ); + $VERSION = '0.01'; + eval { + require XSLoader; + XSLoader::load('YourPackage', $VERSION); + 1; + } or do { + require DynaLoader; + push @ISA, 'DynaLoader'; + bootstrap YourPackage $VERSION; + }; + +The parentheses about C<XSLoader::load()> arguments are needed since we replaced +C<use XSLoader> by C<require>, so the compiler does not know that a function +C<XSLoader::load()> is present. + +This boilerplate uses the low-overhead C<XSLoader> if present; if used with +an antic Perl which has no C<XSLoader>, it falls back to using C<DynaLoader>. + +=head1 Order of initialization: early load() + +I<Skip this section if the XSUB functions are supposed to be called from other +modules only; read it only if you call your XSUBs from the code in your module, +or have a C<BOOT:> section in your XS file (see L<perlxs/"The BOOT: Keyword">). +What is described here is equally applicable to the L<DynaLoader|DynaLoader> +interface.> + +A sufficiently complicated module using XS would have both Perl code (defined +in F<YourPackage.pm>) and XS code (defined in F<YourPackage.xs>). If this +Perl code makes calls into this XS code, and/or this XS code makes calls to +the Perl code, one should be careful with the order of initialization. + +The call to C<XSLoader::load()> (or C<bootstrap()>) has three side effects: + +=over + +=item * + +if C<$VERSION> was specified, a sanity check is done to ensure that the +versions of the F<.pm> and the (compiled) F<.xs> parts are compatible; + +=item * + +the XSUBs are made accessible from Perl; + +=item * + +if a C<BOOT:> section was present in the F<.xs> file, the code there is called. + +=back + +Consequently, if the code in the F<.pm> file makes calls to these XSUBs, it is +convenient to have XSUBs installed before the Perl code is defined; for +example, this makes prototypes for XSUBs visible to this Perl code. +Alternatively, if the C<BOOT:> section makes calls to Perl functions (or +uses Perl variables) defined in the F<.pm> file, they must be defined prior to +the call to C<XSLoader::load()> (or C<bootstrap()>). + +The first situation being much more frequent, it makes sense to rewrite the +boilerplate as + + package YourPackage; + use XSLoader; + use vars qw($VERSION @ISA); + + BEGIN { + @ISA = qw( OnePackage OtherPackage ); + $VERSION = '0.01'; + + # Put Perl code used in the BOOT: section here + + XSLoader::load 'YourPackage', $VERSION; + } + + # Put Perl code making calls into XSUBs here + +=head2 The most hairy case + +If the interdependence of your C<BOOT:> section and Perl code is +more complicated than this (e.g., the C<BOOT:> section makes calls to Perl +functions which make calls to XSUBs with prototypes), get rid of the C<BOOT:> +section altogether. Replace it with a function C<onBOOT()>, and call it like +this: + + package YourPackage; + use XSLoader; + use vars qw($VERSION @ISA); + + BEGIN { + @ISA = qw( OnePackage OtherPackage ); + $VERSION = '0.01'; + XSLoader::load 'YourPackage', $VERSION; + } + + # Put Perl code used in onBOOT() function here; calls to XSUBs are + # prototype-checked. + + onBOOT; + + # Put Perl initialization code assuming that XS is initialized here + + +=head1 DIAGNOSTICS + +=over + +=item C<Can't find '%s' symbol in %s> + +B<(F)> The bootstrap symbol could not be found in the extension module. + +=item C<Can't load '%s' for module %s: %s> + +B<(F)> The loading or initialisation of the extension module failed. +The detailed error follows. + +=item C<Undefined symbols present after loading %s: %s> + +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 +is checked to find the extension DLL (this location is where C<make install> +would put the DLL). If not found, the search for the DLL is transparently +delegated to C<DynaLoader>, which looks for the DLL along the C<@INC> list. + +In particular, this is applicable to the structure of C<@INC> used for testing +not-yet-installed extensions. This means that running uninstalled extensions +may have much more overhead than running the same extensions after +C<make install>. + + +=head1 BUGS + +Please report any bugs or feature requests via the perlbug(1) utility. + + +=head1 SEE ALSO + +L<DynaLoader> + + +=head1 AUTHORS + +Ilya Zakharevich originally extracted C<XSLoader> from C<DynaLoader>. + +CPAN version is currently maintained by SE<eacute>bastien Aperghis-Tramoni +E<lt>sebastien@aperghis.netE<gt>. + +Previous maintainer was Michael G Schwern <schwern@pobox.com>. + + +=head1 COPYRIGHT & LICENSE + +Copyright (C) 1990-2007 by Larry Wall and others. + +This program is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/ext/lib/lib.pm b/ext/lib/lib.pm new file mode 100644 index 0000000000..471d381bb7 --- /dev/null +++ b/ext/lib/lib.pm @@ -0,0 +1,242 @@ +package lib; + +# THIS FILE IS AUTOMATICALLY GENERATED FROM lib_pm.PL. +# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN BY THE NEXT PERL BUILD. + +use Config; + +use strict; + +my $archname = $Config{archname}; +my $version = $Config{version}; +my @inc_version_list = reverse split / /, $Config{inc_version_list}; + + +our @ORIG_INC = @INC; # take a handy copy of 'original' value +our $VERSION = '0.62'; +my $Is_MacOS = $^O eq 'MacOS'; +my $Mac_FS; +if ($Is_MacOS) { + require File::Spec; + $Mac_FS = eval { require Mac::FileSpec::Unixish }; +} + +sub import { + shift; + + my %names; + foreach (reverse @_) { + my $path = $_; # we'll be modifying it, so break the alias + if ($path eq '') { + require Carp; + Carp::carp("Empty compile time value given to use lib"); + } + + $path = _nativize($path); + + if ($path !~ /\.par$/i && -e $path && ! -d _) { + require Carp; + Carp::carp("Parameter to use lib must be directory, not file"); + } + unshift(@INC, $path); + # Add any previous version directories we found at configure time + foreach my $incver (@inc_version_list) + { + my $dir = $Is_MacOS + ? File::Spec->catdir( $path, $incver ) + : "$path/$incver"; + unshift(@INC, $dir) if -d $dir; + } + # Put a corresponding archlib directory in front of $path if it + # looks like $path has an archlib directory below it. + my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir) + = _get_dirs($path); + unshift(@INC, $arch_dir) if -d $arch_auto_dir; + unshift(@INC, $version_dir) if -d $version_dir; + unshift(@INC, $version_arch_dir) if -d $version_arch_dir; + } + + # remove trailing duplicates + @INC = grep { ++$names{$_} == 1 } @INC; + return; +} + + +sub unimport { + shift; + + my %names; + foreach (@_) { + my $path = _nativize($_); + + my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir) + = _get_dirs($path); + ++$names{$path}; + ++$names{$arch_dir} if -d $arch_auto_dir; + ++$names{$version_dir} if -d $version_dir; + ++$names{$version_arch_dir} if -d $version_arch_dir; + } + + # Remove ALL instances of each named directory. + @INC = grep { !exists $names{$_} } @INC; + return; +} + +sub _get_dirs { + my($dir) = @_; + my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir); + + # we could use this for all platforms in the future, but leave it + # Mac-only for now, until there is more time for testing it. + if ($Is_MacOS) { + $arch_auto_dir = File::Spec->catdir( $dir, $archname, 'auto' ); + $arch_dir = File::Spec->catdir( $dir, $archname, ); + $version_dir = File::Spec->catdir( $dir, $version ); + $version_arch_dir = File::Spec->catdir( $dir, $version, $archname ); + } else { + $arch_auto_dir = "$dir/$archname/auto"; + $arch_dir = "$dir/$archname"; + $version_dir = "$dir/$version"; + $version_arch_dir = "$dir/$version/$archname"; + } + return($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir); +} + +sub _nativize { + my($dir) = @_; + + if ($Is_MacOS && $Mac_FS && ! -d $dir) { + $dir = Mac::FileSpec::Unixish::nativize($dir); + $dir .= ":" unless $dir =~ /:$/; + } + + return $dir; +} + +1; +__END__ + +=head1 NAME + +lib - manipulate @INC at compile time + +=head1 SYNOPSIS + + use lib LIST; + + no lib LIST; + +=head1 DESCRIPTION + +This is a small simple module which simplifies the manipulation of @INC +at compile time. + +It is typically used to add extra directories to perl's search path so +that later C<use> or C<require> statements will find modules which are +not located on perl's default search path. + +=head2 Adding directories to @INC + +The parameters to C<use lib> are added to the start of the perl search +path. Saying + + use lib LIST; + +is I<almost> the same as saying + + BEGIN { unshift(@INC, LIST) } + +For each directory in LIST (called $dir here) the lib module also +checks to see if a directory called $dir/$archname/auto exists. +If so the $dir/$archname directory is assumed to be a corresponding +architecture specific directory and is added to @INC in front of $dir. +lib.pm also checks if directories called $dir/$version and $dir/$version/$archname +exist and adds these directories to @INC. + +The current value of C<$archname> can be found with this command: + + perl -V:archname + +The corresponding command to get the current value of C<$version> is: + + perl -V:version + +To avoid memory leaks, all trailing duplicate entries in @INC are +removed. + +=head2 Deleting directories from @INC + +You should normally only add directories to @INC. If you need to +delete directories from @INC take care to only delete those which you +added yourself or which you are certain are not needed by other modules +in your script. Other modules may have added directories which they +need for correct operation. + +The C<no lib> statement deletes all instances of each named directory +from @INC. + +For each directory in LIST (called $dir here) the lib module also +checks to see if a directory called $dir/$archname/auto exists. +If so the $dir/$archname directory is assumed to be a corresponding +architecture specific directory and is also deleted from @INC. + +=head2 Restoring original @INC + +When the lib module is first loaded it records the current value of @INC +in an array C<@lib::ORIG_INC>. To restore @INC to that value you +can say + + @INC = @lib::ORIG_INC; + +=head1 CAVEATS + +In order to keep lib.pm small and simple, it only works with Unix +filepaths. This doesn't mean it only works on Unix, but non-Unix +users must first translate their file paths to Unix conventions. + + # VMS users wanting to put [.stuff.moo] into + # their @INC would write + use lib 'stuff/moo'; + +=head1 NOTES + +In the future, this module will likely use File::Spec for determining +paths, as it does now for Mac OS (where Unix-style or Mac-style paths +work, and Unix-style paths are converted properly to Mac-style paths +before being added to @INC). + +If you try to add a file to @INC as follows: + + use lib 'this_is_a_file.txt'; + +C<lib> will warn about this. The sole exceptions are files with the +C<.par> extension which are intended to be used as libraries. + +=head1 SEE ALSO + +FindBin - optional module which deals with paths relative to the source file. + +PAR - optional module which can treat C<.par> files as Perl libraries. + +=head1 AUTHOR + +Tim Bunce, 2nd June 1995. + +C<lib> is maintained by the perl5-porters. Please direct +any questions to the canonical mailing list. Anything that +is applicable to the CPAN release can be sent to its maintainer, +though. + +Maintainer: The Perl5-Porters <perl5-porters@perl.org> + +Maintainer of the CPAN release: Steffen Mueller <smueller@cpan.org> + +=head1 COPYRIGHT AND LICENSE + +This package has been part of the perl core since perl 5.001. +It has been released separately to CPAN so older installations +can benefit from bug fixes. + +This package has the same copyright and license as the perl core. + +=cut |