MRO-Compat-0.15/000755 000000 000000 00000000000 14165604406 013422 5ustar00rootwheel000000 000000 MRO-Compat-0.15/README000644 000000 000000 00000012720 14165604406 014304 0ustar00rootwheel000000 000000 NAME MRO::Compat - mro::* interface compatibility for Perls < 5.9.5 SYNOPSIS package PPP; use base qw/Exporter/; package X; use base qw/PPP/; package Y; use base qw/PPP/; package Z; use base qw/PPP/; package FooClass; use base qw/X Y Z/; package main; use MRO::Compat; my $linear = mro::get_linear_isa('FooClass'); print join(q{, }, @$linear); # Prints: FooClass, X, PPP, Exporter, Y, Z DESCRIPTION The "mro" namespace provides several utilities for dealing with method resolution order and method caching in general in Perl 5.9.5 and higher. This module provides those interfaces for earlier versions of Perl (back to 5.6.0 anyways). It is a harmless no-op to use this module on 5.9.5+. That is to say, code which properly uses MRO::Compat will work unmodified on both older Perls and 5.9.5+. If you're writing a piece of software that would like to use the parts of 5.9.5+'s mro:: interfaces that are supported here, and you want compatibility with older Perls, this is the module for you. Some parts of this code will work better and/or faster with Class::C3::XS installed (which is an optional prereq of Class::C3, which is in turn a prereq of this package), but it's not a requirement. This module never exports any functions. All calls must be fully qualified with the "mro::" prefix. The interface documentation here serves only as a quick reference of what the function basically does, and what differences between MRO::Compat and 5.9.5+ one should look out for. The main docs in 5.9.5's mro are the real interface docs, and contain a lot of other useful information. Functions mro::get_linear_isa($classname[, $type]) Returns an arrayref which is the linearized "ISA" of the given class. Uses whichever MRO is currently in effect for that class by default, or the given MRO (either "c3" or "dfs" if specified as $type). The linearized ISA of a class is a single ordered list of all of the classes that would be visited in the process of resolving a method on the given class, starting with itself. It does not include any duplicate entries. Note that "UNIVERSAL" (and any members of "UNIVERSAL"'s MRO) are not part of the MRO of a class, even though all classes implicitly inherit methods from "UNIVERSAL" and its parents. mro::import This allows the "use mro 'dfs'" and "use mro 'c3'" syntaxes, providing you "use MRO::Compat" first. Please see the "USING C3" section for additional details. mro::set_mro($classname, $type) Sets the mro of $classname to one of the types "dfs" or "c3". Please see the "USING C3" section for additional details. mro::get_mro($classname) Returns the MRO of the given class (either "c3" or "dfs"). It considers any Class::C3-using class to have C3 MRO even before Class::C3::initialize() is called. mro::get_isarev($classname) Returns an arrayref of classes who are subclasses of the given classname. In other words, classes in whose @ISA hierarchy we appear, no matter how indirectly. This is much slower on pre-5.9.5 Perls with MRO::Compat than it is on 5.9.5+, as it has to search the entire package namespace. mro::is_universal($classname) Returns a boolean status indicating whether or not the given classname is either "UNIVERSAL" itself, or one of "UNIVERSAL"'s parents by @ISA inheritance. Any class for which this function returns true is "universal" in the sense that all classes potentially inherit methods from it. mro::invalidate_all_method_caches Increments "PL_sub_generation", which invalidates method caching in all packages. Please note that this is rarely necessary, unless you are dealing with a situation which is known to confuse Perl's method caching. mro::method_changed_in($classname) Invalidates the method cache of any classes dependent on the given class. In MRO::Compat on pre-5.9.5 Perls, this is an alias for "mro::invalidate_all_method_caches" above, as pre-5.9.5 Perls have no other way to do this. It will still enforce the requirement that you pass it a classname, for compatibility. Please note that this is rarely necessary, unless you are dealing with a situation which is known to confuse Perl's method caching. mro::get_pkg_gen($classname) Returns an integer which is incremented every time a local method of or the @ISA of the given package changes on Perl 5.9.5+. On earlier Perls with this MRO::Compat module, it will probably increment a lot more often than necessary. USING C3 While this module makes the 5.9.5+ syntaxes "use mro 'c3'" and "mro::set_mro("Foo", 'c3')" available on older Perls, it does so merely by passing off the work to Class::C3. It does not remove the need for you to call "Class::C3::initialize()", "Class::C3::reinitialize()", and/or "Class::C3::uninitialize()" at the appropriate times as documented in the Class::C3 docs. These three functions are always provided by MRO::Compat, either via Class::C3 itself on older Perls, or directly as no-ops on 5.9.5+. SEE ALSO Class::C3 mro AUTHOR Brandon L. Black, COPYRIGHT AND LICENSE Copyright 2007-2008 Brandon L. Black This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. MRO-Compat-0.15/Changes000644 000000 000000 00000004046 14165604356 014725 0ustar00rootwheel000000 000000 Revision history for Perl extension MRO::Compat. 0.15 - 2022-01-06 - fix function prototypes to match core functions 0.14_01 - 2020-11-16 - optimize pure perl DFS inheritance calculation on perl 5.8 - pod formatting fix 0.13 - 2017-03-28 - don't run pod tests on user installs - stop using Module::Install to fix installation when @INC doesn't have the current directory (RT#119016) - repository migrated to the github moose organization 0.12 - 2012-12-04 - Bump Class::C3 dependency on 5.8 which in turn will automatically install Class::C3::XS if possible - Fix nonfunctional SYNOPSIS (RT#78325) 0.11 - 2009-05-27 - Fix misspelled docs for get_isarev. Closes RT#46401. - Bump optional prereq on Class::C3 to 0.20. 0.10 - 2009-03-25 - Remove the fake Build.PL. Module::Install doesn't support that anymore. (Florian Ragwitz) - Remove auto_install from Makefile.PL. Its use is strongly discouraged. (Closes RT#44542) (Simon Betrang) 0.09 - 2008-06-05 - No change from 0.08_01 0.08_01 - 2008-06-02 - Add fixup (and new tests) for RT#36256 0.07 - 2008-05-20 - Add explicit dependency on perl 5.6.0 or higher in Makefile.PL + META.yml 0.06_01 - 2008-05-19 - Fix for false classnames in mro::get_isarev, I guess I missed an instance during the 0.04 fixes. (reported by Daniel Austin) 0.05 - 2007-09-09 - Fix for RT#28661 (ill-formated %INC filenames aren't nice) 0.04 - 2007-07-18 - Removed doc warning now that 5.9.5 is out - Stopped the code from assuming valid classnames are true in boolean context - Misc small tweaks 0.03 - 2007-06-04 - Bumped C3 requirements - Loads mro.pm on 5.9.5+ 0.02 - 2007-05-12 - Added mro::get_pkg_gen (which optionally works even faster with Class::C3::XS 0.04) in anticipation of it being added to 5.9.5 - Changed mro::get_isarev to return arrayref in anticipation of that change in 5.9.5 - Bumped requirements, added more docs 0.01_01 - 2007-05-11 - Initial dev release MRO-Compat-0.15/MANIFEST000644 000000 000000 00000000725 14165604406 014557 0ustar00rootwheel000000 000000 Changes lib/MRO/Compat.pm maint/Makefile.PL.include Makefile.PL MANIFEST This list of files t/10basic.t t/15pkg_gen.t t/20mros.t xt/pod.t xt/pod_coverage.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) LICENSE LICENSE file (added by Distar) MRO-Compat-0.15/LICENSE000644 000000 000000 00000043432 14165604406 014435 0ustar00rootwheel000000 000000 Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2022 by Brandon L. Black . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2022 by Brandon L. Black . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End MRO-Compat-0.15/t/000755 000000 000000 00000000000 14165604404 013663 5ustar00rootwheel000000 000000 MRO-Compat-0.15/xt/000755 000000 000000 00000000000 14165604404 014053 5ustar00rootwheel000000 000000 MRO-Compat-0.15/META.yml000644 000000 000000 00000001440 14165604404 014670 0ustar00rootwheel000000 000000 --- abstract: 'mro::* interface compatibility for Perls < 5.9.5' author: - 'Brandon L. Black ' build_requires: Test::More: '0.47' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MRO-Compat no_index: directory: - t - xt requires: perl: '5.006' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=MRO-Compat homepage: https://metacpan.org/release/MRO-Compat license: http://dev.perl.org/licenses/ repository: git://github.com/moose/MRO-Compat.git version: '0.15' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' MRO-Compat-0.15/META.json000644 000000 000000 00000003067 14165604405 015050 0ustar00rootwheel000000 000000 { "abstract" : "mro::* interface compatibility for Perls < 5.9.5", "author" : [ "Brandon L. Black " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "MRO-Compat", "no_index" : { "directory" : [ "t", "xt" ] }, "prereqs" : { "build" : {}, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::Pod" : "1.14", "Test::Pod::Coverage" : "1.04" } }, "runtime" : { "requires" : { "perl" : "5.006" } }, "test" : { "requires" : { "Test::More" : "0.47" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-MRO-Compat@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=MRO-Compat" }, "homepage" : "https://metacpan.org/release/MRO-Compat", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "git://github.com/moose/MRO-Compat.git", "web" : "https://github.com/moose/MRO-Compat" } }, "version" : "0.15", "x_serialization_backend" : "JSON::PP version 4.06" } MRO-Compat-0.15/lib/000755 000000 000000 00000000000 14165604404 014166 5ustar00rootwheel000000 000000 MRO-Compat-0.15/maint/000755 000000 000000 00000000000 14165604404 014530 5ustar00rootwheel000000 000000 MRO-Compat-0.15/Makefile.PL000644 000000 000000 00000005430 13751000504 015363 0ustar00rootwheel000000 000000 use strict; use warnings FATAL => 'all'; use 5.006; my %META = ( name => 'MRO-Compat', license => 'perl_5', prereqs => { configure => { requires => { 'ExtUtils::MakeMaker' => 0, } }, test => { requires => { 'Test::More' => '0.47', }, }, runtime => { requires => { 'perl' => '5.006', }, }, develop => { requires => { 'Test::Pod' => '1.14', 'Test::Pod::Coverage' => '1.04', }, }, }, resources => { repository => { url => 'git://github.com/moose/MRO-Compat.git', web => 'https://github.com/moose/MRO-Compat', type => 'git', }, bugtracker => { web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=MRO-Compat', mailto => 'bug-MRO-Compat@rt.cpan.org', }, homepage => 'https://metacpan.org/release/MRO-Compat', license => [ 'http://dev.perl.org/licenses/' ], }, no_index => { directory => [ 't', 'xt' ] }, ); my %MM_ARGS = ( PREREQ_PM => { ($] < 5.009_005 ? ('Class::C3' => '0.24') : ()), }, ); ## BOILERPLATE ############################################################### require ExtUtils::MakeMaker; (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; # have to do this since old EUMM dev releases miss the eval $VERSION line my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; my $mymeta = $eumm_version >= 6.57_02; my $mymeta_broken = $mymeta && $eumm_version < 6.57_07; ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g; ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g; $META{license} = [ $META{license} ] if $META{license} && !ref $META{license}; $MM_ARGS{LICENSE} = $META{license}[0] if $META{license} && $eumm_version >= 6.30; $MM_ARGS{NO_MYMETA} = 1 if $mymeta_broken; $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META } unless -f 'META.yml'; $MM_ARGS{PL_FILES} ||= {}; $MM_ARGS{NORECURS} = 1 if not exists $MM_ARGS{NORECURS}; for (qw(configure build test runtime)) { my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; my $r = $MM_ARGS{$key} = { %{$META{prereqs}{$_}{requires} || {}}, %{delete $MM_ARGS{$key} || {}}, }; defined $r->{$_} or delete $r->{$_} for keys %$r; } $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0; delete $MM_ARGS{MIN_PERL_VERSION} if $eumm_version < 6.47_01; $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}} if $eumm_version < 6.63_03; $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}} if $eumm_version < 6.55_01; delete $MM_ARGS{CONFIGURE_REQUIRES} if $eumm_version < 6.51_03; ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS); ## END BOILERPLATE ########################################################### MRO-Compat-0.15/maint/Makefile.PL.include000644 000000 000000 00000000325 14002076472 020122 0ustar00rootwheel000000 000000 BEGIN { -e 'Distar' or system qw(git clone https://github.com/p5sagit/Distar.git) } use lib 'Distar/lib'; use Distar 0.001; use ExtUtils::MakeMaker 6.57_10 (); author 'Brandon L. Black '; 1; MRO-Compat-0.15/lib/MRO/000755 000000 000000 00000000000 14165604404 014623 5ustar00rootwheel000000 000000 MRO-Compat-0.15/lib/MRO/Compat.pm000644 000000 000000 00000025225 14165604323 016412 0ustar00rootwheel000000 000000 package MRO::Compat; use strict; use warnings; require 5.006_000; # Keep this < 1.00, so people can tell the fake # mro.pm from the real one our $VERSION = '0.15'; BEGIN { # Alias our private functions over to # the mro:: namespace and load # Class::C3 if Perl < 5.9.5 if($] < 5.009_005) { $mro::VERSION # to fool Module::Install when generating META.yml = $VERSION; $INC{'mro.pm'} = __FILE__; *mro::import = \&__import; *mro::get_linear_isa = \&__get_linear_isa; *mro::set_mro = \&__set_mro; *mro::get_mro = \&__get_mro; *mro::get_isarev = \&__get_isarev; *mro::is_universal = \&__is_universal; *mro::method_changed_in = \&__method_changed_in; *mro::invalidate_all_method_caches = \&__invalidate_all_method_caches; require Class::C3; if($Class::C3::XS::VERSION && $Class::C3::XS::VERSION > 0.03) { *mro::get_pkg_gen = \&__get_pkg_gen_c3xs; } else { *mro::get_pkg_gen = \&__get_pkg_gen_pp; } } # Load mro.pm and provide no-op Class::C3::.*initialize() funcs for 5.9.5+ else { require mro; no warnings 'redefine'; *Class::C3::initialize = sub { 1 }; *Class::C3::reinitialize = sub { 1 }; *Class::C3::uninitialize = sub { 1 }; } } =head1 NAME MRO::Compat - mro::* interface compatibility for Perls < 5.9.5 =head1 SYNOPSIS package PPP; use base qw/Exporter/; package X; use base qw/PPP/; package Y; use base qw/PPP/; package Z; use base qw/PPP/; package FooClass; use base qw/X Y Z/; package main; use MRO::Compat; my $linear = mro::get_linear_isa('FooClass'); print join(q{, }, @$linear); # Prints: FooClass, X, PPP, Exporter, Y, Z =head1 DESCRIPTION The "mro" namespace provides several utilities for dealing with method resolution order and method caching in general in Perl 5.9.5 and higher. This module provides those interfaces for earlier versions of Perl (back to 5.6.0 anyways). It is a harmless no-op to use this module on 5.9.5+. That is to say, code which properly uses L will work unmodified on both older Perls and 5.9.5+. If you're writing a piece of software that would like to use the parts of 5.9.5+'s mro:: interfaces that are supported here, and you want compatibility with older Perls, this is the module for you. Some parts of this code will work better and/or faster with L installed (which is an optional prereq of L, which is in turn a prereq of this package), but it's not a requirement. This module never exports any functions. All calls must be fully qualified with the C prefix. The interface documentation here serves only as a quick reference of what the function basically does, and what differences between L and 5.9.5+ one should look out for. The main docs in 5.9.5's L are the real interface docs, and contain a lot of other useful information. =head1 Functions =head2 mro::get_linear_isa($classname[, $type]) Returns an arrayref which is the linearized "ISA" of the given class. Uses whichever MRO is currently in effect for that class by default, or the given MRO (either C or C if specified as C<$type>). The linearized ISA of a class is a single ordered list of all of the classes that would be visited in the process of resolving a method on the given class, starting with itself. It does not include any duplicate entries. Note that C (and any members of C's MRO) are not part of the MRO of a class, even though all classes implicitly inherit methods from C and its parents. =cut sub __get_linear_isa_dfs { my @check = shift; my @lin; my %found; while (defined(my $check = shift @check)) { push @lin, $check; no strict 'refs'; unshift @check, grep !$found{$_}++, @{"$check\::ISA"}; } return \@lin; } sub __get_linear_isa ($;$) { my ($classname, $type) = @_; die "mro::get_mro requires a classname" if !defined $classname; $type ||= __get_mro($classname); if($type eq 'dfs') { return __get_linear_isa_dfs($classname); } elsif($type eq 'c3') { return [Class::C3::calculateMRO($classname)]; } die "type argument must be 'dfs' or 'c3'"; } =head2 mro::import This allows the C and C syntaxes, providing you C first. Please see the L section for additional details. =cut sub __import { if($_[1]) { goto &Class::C3::import if $_[1] eq 'c3'; __set_mro(scalar(caller), $_[1]); } } =head2 mro::set_mro($classname, $type) Sets the mro of C<$classname> to one of the types C or C. Please see the L section for additional details. =cut sub __set_mro ($$) { my ($classname, $type) = @_; if(!defined $classname || !$type) { die q{Usage: mro::set_mro($classname, $type)}; } if($type eq 'c3') { eval "package $classname; use Class::C3"; die $@ if $@; } elsif($type eq 'dfs') { # In the dfs case, check whether we need to undo C3 if(defined $Class::C3::MRO{$classname}) { Class::C3::_remove_method_dispatch_table($classname); } delete $Class::C3::MRO{$classname}; } else { die qq{Invalid mro type "$type"}; } return; } =head2 mro::get_mro($classname) Returns the MRO of the given class (either C or C). It considers any Class::C3-using class to have C3 MRO even before L is called. =cut sub __get_mro ($) { my $classname = shift; die "mro::get_mro requires a classname" if !defined $classname; return 'c3' if exists $Class::C3::MRO{$classname}; return 'dfs'; } =head2 mro::get_isarev($classname) Returns an arrayref of classes who are subclasses of the given classname. In other words, classes in whose @ISA hierarchy we appear, no matter how indirectly. This is much slower on pre-5.9.5 Perls with MRO::Compat than it is on 5.9.5+, as it has to search the entire package namespace. =cut sub __get_all_pkgs_with_isas { no strict 'refs'; no warnings 'recursion'; my @retval; my $search = shift; my $pfx; my $isa; if(defined $search) { $isa = \@{"$search\::ISA"}; $pfx = "$search\::"; } else { $search = 'main'; $isa = \@main::ISA; $pfx = ''; } push(@retval, $search) if scalar(@$isa); foreach my $cand (keys %{"$search\::"}) { if($cand =~ s/::$//) { next if $cand eq $search; # skip self-reference (main?) push(@retval, @{__get_all_pkgs_with_isas($pfx . $cand)}); } } return \@retval; } sub __get_isarev_recurse { no strict 'refs'; my ($class, $all_isas, $level) = @_; die "Recursive inheritance detected" if $level > 100; my %retval; foreach my $cand (@$all_isas) { my $found_me; foreach (@{"$cand\::ISA"}) { if($_ eq $class) { $found_me = 1; last; } } if($found_me) { $retval{$cand} = 1; map { $retval{$_} = 1 } @{__get_isarev_recurse($cand, $all_isas, $level+1)}; } } return [keys %retval]; } sub __get_isarev ($) { my $classname = shift; die "mro::get_isarev requires a classname" if !defined $classname; __get_isarev_recurse($classname, __get_all_pkgs_with_isas(), 0); } =head2 mro::is_universal($classname) Returns a boolean status indicating whether or not the given classname is either C itself, or one of C's parents by C<@ISA> inheritance. Any class for which this function returns true is "universal" in the sense that all classes potentially inherit methods from it. =cut sub __is_universal ($) { my $classname = shift; die "mro::is_universal requires a classname" if !defined $classname; my $lin = __get_linear_isa('UNIVERSAL'); foreach (@$lin) { return 1 if $classname eq $_; } return 0; } =head2 mro::invalidate_all_method_caches Increments C, which invalidates method caching in all packages. Please note that this is rarely necessary, unless you are dealing with a situation which is known to confuse Perl's method caching. =cut sub __invalidate_all_method_caches () { # Super secret mystery code :) @f845a9c1ac41be33::ISA = @f845a9c1ac41be33::ISA; return; } =head2 mro::method_changed_in($classname) Invalidates the method cache of any classes dependent on the given class. In L on pre-5.9.5 Perls, this is an alias for C above, as pre-5.9.5 Perls have no other way to do this. It will still enforce the requirement that you pass it a classname, for compatibility. Please note that this is rarely necessary, unless you are dealing with a situation which is known to confuse Perl's method caching. =cut sub __method_changed_in ($) { my $classname = shift; die "mro::method_changed_in requires a classname" if !defined $classname; __invalidate_all_method_caches(); } =head2 mro::get_pkg_gen($classname) Returns an integer which is incremented every time a local method of or the C<@ISA> of the given package changes on Perl 5.9.5+. On earlier Perls with this L module, it will probably increment a lot more often than necessary. =cut { my $__pkg_gen = 2; sub __get_pkg_gen_pp ($) { my $classname = shift; die "mro::get_pkg_gen requires a classname" if !defined $classname; return $__pkg_gen++; } } sub __get_pkg_gen_c3xs ($) { my $classname = shift; die "mro::get_pkg_gen requires a classname" if !defined $classname; return Class::C3::XS::_plsubgen(); } =head1 USING C3 While this module makes the 5.9.5+ syntaxes C and C available on older Perls, it does so merely by passing off the work to L. It does not remove the need for you to call C, C, and/or C at the appropriate times as documented in the L docs. These three functions are always provided by L, either via L itself on older Perls, or directly as no-ops on 5.9.5+. =head1 SEE ALSO L L =head1 AUTHOR Brandon L. Black, Eblblack@gmail.comE =head1 COPYRIGHT AND LICENSE Copyright 2007-2008 Brandon L. Black Eblblack@gmail.comE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; MRO-Compat-0.15/xt/pod.t000644 000000 000000 00000000124 13274563740 015026 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More; use Test::Pod 1.14; all_pod_files_ok(); MRO-Compat-0.15/xt/pod_coverage.t000644 000000 000000 00000000141 13274563740 016700 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More; use Test::Pod::Coverage 1.04; all_pod_coverage_ok(); MRO-Compat-0.15/t/20mros.t000644 000000 000000 00000004343 13274563740 015205 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More tests => 13; use MRO::Compat; { package AAA; our @ISA = qw//; use mro 'dfs'; package BBB; our @ISA = qw/AAA/; use mro 'dfs'; package CCC; our @ISA = qw/AAA/; use mro 'dfs'; package DDD; our @ISA = qw/AAA/; use mro 'dfs'; package EEE; our @ISA = qw/BBB CCC DDD/; use mro 'dfs'; package FFF; our @ISA = qw/EEE DDD/; use mro 'dfs'; package GGG; our @ISA = qw/FFF/; use mro 'dfs'; package AAA3; our @ISA = qw//; sub testsub { return $_[0] . '_first_in_dfs' } package BBB3; our @ISA = qw/AAA3/; package CCC3; our @ISA = qw/AAA3/; sub testsub { return $_[0] . '_first_in_c3' } package DDD3; our @ISA = qw/AAA3/; package EEE3; our @ISA = qw/BBB3 CCC3 DDD3/; package FFF3; our @ISA = qw/EEE3 DDD3/; use mro 'c3'; package GGG3; our @ISA = qw/FFF3/; use mro 'c3'; } is(mro::get_mro('FFF3'), 'c3'); is_deeply( mro::get_linear_isa('GGG'), [ 'GGG', 'FFF', 'EEE', 'BBB', 'AAA', 'CCC', 'DDD' ], "get_linear_isa for GGG", ); is_deeply( mro::get_linear_isa('GGG3'), [ 'GGG3', 'FFF3', 'EEE3', 'BBB3', 'CCC3', 'DDD3', 'AAA3' ], "get_linear_isa for GGG3", ); SKIP: { skip "Does not work like this on 5.9.5+", 1 if $] > 5.009_004; is(FFF3->testsub(), 'FFF3_first_in_dfs', 'dfs resolution pre-init'); } Class::C3::initialize(); is(FFF3->testsub(), 'FFF3_first_in_c3', 'c3 resolution post-init'); mro::set_mro('FFF3', 'dfs'); is(mro::get_mro('FFF3'), 'dfs'); is_deeply( mro::get_linear_isa('FFF3'), [ 'FFF3', 'EEE3', 'BBB3', 'AAA3', 'CCC3', 'DDD3' ], "get_linear_isa for FFF3 (dfs)", ); is(FFF3->testsub(), 'FFF3_first_in_dfs', 'dfs resolution post- set_mro dfs'); is_deeply( mro::get_linear_isa('GGG3'), [ 'GGG3', 'FFF3', 'EEE3', 'BBB3', 'CCC3', 'DDD3', 'AAA3' ], "get_linear_isa for GGG3 (still c3)", ); mro::set_mro('FFF3', 'c3'); is(mro::get_mro('FFF3'), 'c3'); is_deeply( mro::get_linear_isa('FFF3'), [ 'FFF3', 'EEE3', 'BBB3', 'CCC3', 'DDD3', 'AAA3' ], "get_linear_isa for FFF3 (reset to c3 via set_mro)", ); eval "package FFF3; use mro 'dfs'"; is(mro::get_mro('FFF3'), 'dfs'); is_deeply( mro::get_linear_isa('FFF3'), [ 'FFF3', 'EEE3', 'BBB3', 'AAA3', 'CCC3', 'DDD3' ], "get_linear_isa for FFF3 (reset to dfs via 'use mro')", ); MRO-Compat-0.15/t/10basic.t000644 000000 000000 00000002241 13274563740 015300 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More tests => 10; use MRO::Compat; { package AAA; our @ISA = qw//; package BBB; our @ISA = qw/AAA/; package CCC; our @ISA = qw/AAA/; package DDD; our @ISA = qw/AAA/; package EEE; our @ISA = qw/BBB CCC DDD/; package FFF; our @ISA = qw/EEE DDD/; package GGG; our @ISA = qw/FFF/; package UNIVERSAL; our @ISA = qw/DDD/; } is_deeply( mro::get_linear_isa('GGG'), [ 'GGG', 'FFF', 'EEE', 'BBB', 'AAA', 'CCC', 'DDD' ], "get_linear_isa for GGG", ); is_deeply( [sort @{mro::get_isarev('GGG')}], [], "get_isarev for GGG", ); is_deeply( [sort @{mro::get_isarev('DDD')}], [ 'EEE', 'FFF', 'GGG', 'UNIVERSAL' ], "get_isarev for DDD", ); is_deeply( [sort @{mro::get_isarev('AAA')}], [ 'BBB', 'CCC', 'DDD', 'EEE', 'FFF', 'GGG', 'UNIVERSAL' ], "get_isarev for AAA", ); ok(mro::is_universal('UNIVERSAL'), "UNIVERSAL is_universal"); ok(mro::is_universal('DDD'), "DDD is_universal"); ok(mro::is_universal('AAA'), "AAA is_universal"); ok(!mro::is_universal('MRO::Compat'), "MRO::Compat !is_universal"); ok(!mro::is_universal('BBB'), "BBB !is_universal"); ok(!mro::is_universal('FFF'), "FFF !is_universal"); MRO-Compat-0.15/t/15pkg_gen.t000644 000000 000000 00000000745 13274563740 015645 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More tests => 3; use MRO::Compat; { package Foo; our @ISA = qw//; } my $f_gen = mro::get_pkg_gen('Foo'); ok($f_gen > 0, 'Foo pkg_gen > 0'); { no warnings 'once'; *Foo::foo_func = sub { 123 }; } my $new_f_gen = mro::get_pkg_gen('Foo'); ok($new_f_gen > $f_gen, 'Foo pkg_gen incs for methods'); $f_gen = $new_f_gen; @Foo::ISA = qw/Bar/; $new_f_gen = mro::get_pkg_gen('Foo'); ok($new_f_gen > $f_gen, 'Foo pkg_gen incs for @ISA');