Object-Import-1.006/0000755000175000017500000000000013460663343013552 5ustar corioncorionObject-Import-1.006/GPL0000644000175000017500000010451313460663151014120 0ustar corioncorion GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS 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 the public, 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 state 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) 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 3 of the License, 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . Object-Import-1.006/MANIFEST.SKIP0000644000175000017500000000040513460663151015444 0ustar corioncorion^\.git\/ maint ^tags$ .last_cover_stats .travis.yml .appveyor.yml ^\.github Makefile$ ^blib ^pm_to_blib ^.*.bak ^.*.old ^t.*sessions ^t/.*\.disabled$ ^cover_db ^.*\.log ^.*\.swp$ ^jar/ ^cpan/ ^MYMETA ^.releaserc ^.*.cmd ^Object-Import-.* Object-Import-1.006/Makefile.PL0000644000175000017500000000120313460663151015515 0ustar corioncorionuse ExtUtils::MakeMaker; WriteMakefile( NAME => "Object::Import", ABSTRACT => "import methods of an object as functions to a package", VERSION_FROM => "lib/Object/Import.pm", PREREQ_PM => { "MRO::Compat" => 0, # alternately mro 0 is okay "Scalar::Util" => 0, "warnings" => 0, "IO::Handle" => 0, "strict" => 0, }, MIN_PERL_VERSION => 5.00800, # /\pL/ BUILD_REQUIRES => { "MRO::Compat" => 0, # alternately mro 0 is okay "Scalar::Util" => 0, "warnings" => 0, "IO::Handle" => 0, "strict" => 0, "Test::More" => 0.47, # used in tests "Math::BigInt" => 1.59, # used in tests "File::Temp" => 0, # used in tests }, ); Object-Import-1.006/t/0000755000175000017500000000000013460663343014015 5ustar corioncorionObject-Import-1.006/t/05_nometh.t0000644000175000017500000000324113460663151015775 0ustar corioncorionuse warnings; use strict; use Test::More tests => 21; use Object::Import; BEGIN { $::W1 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ /\Awarning: Object::Import cannot find methods of /) { $::W1++; } else { warn $t; } }; } sub greet { "sorry" }; { no strict "refs"; *{"=k::greet"} = sub { "hello" }; } { { no strict "refs"; *{"|m::crazy"} = sub { $::crazy_pkg_allowed++; }; } $::crazy_ok = eval { "|m"->crazy(); 1 }; $::crazy_err = $@; is(!!$::crazy_ok, !!$::crazy_pkg_allowed, "punctuation package method ran iff call not died"); is(!!$::crazy_ok, !$::crazy_err, "punctuation package method ran iff no exception"); SKIP: { $::crazy_ok and skip "punctuation package method call allowed", 2; like($::crazy_err, qr/\ACan't call method "crazy" without a package or object reference /, "punctuation package method correct error message"); cmp_ok($], "<", 5.0170059, "punctuation package allowed on new enough perl"); } SKIP: { !$::crazy_ok and skip "punctuation package method call not allowed", 1; cmp_ok(5.0160015, "<", $], "punctuation package name allowed only on new perl"); } } is($::W1, 0, "no warn 0"); { package G0; use Test::More; for my $testrec ( [["hello"], "unblessed ref"], ["hello", "nonexistant package"], ["!", "invalid string"], ["", "empty string"], ["=k", "package with wrong name", $::crazy_ok], ) { my($obj, $desc, $expect) = @$testrec; my %n; import Object::Import $obj, savenames => \%n; is_deeply(\%n, $expect ? {"greet" => 1} : {}, ($expect ? "one" : "no") . " import from $desc"); is(exists(&greet), !!$expect, "G0.1 !exi&greet from $desc"); is($::W1, 0+!$expect, "warnt $desc"); $::W1 = 0; } } __END__ Object-Import-1.006/t/03_bigint.t0000644000175000017500000000041313460663151015753 0ustar corioncorionuse warnings; use strict; use Test::More tests => 4; BEGIN { require_ok("Math::BigInt"); } use Object::Import Math::BigInt::; is(new("0x100"), "256"); use Object::Import Math::BigInt->new("100"), prefix => "h"; is(hbmul(2), "200"); is(has_hex(), "0xc8"); __END__ Object-Import-1.006/t/13_meta.t0000644000175000017500000000300413460663151015425 0ustar corioncorionuse warnings; use strict; use Test::More tests => 14; use Object::Import (); { package X; sub greet { my($o, $a) = @_; "hello $a from $o"; } } { package G1; use Test::More; our %nm; import Object::Import "Object::Import", list => ["import"], prefix => "object_"; ok(defined(&object_import), "object_import exported G1"); object_import("X", savenames => \%nm, target => "G1"); ok(defined(&greet), "def greet G1"); is_deeply(\%nm, {greet => 1}, "no other names exported G1"); is(greet("world"), "hello world from X", "&greet G1"); } { package G2; use Test::More; our %nm; import Object::Import "Object::Import", list => ["import"], prefix => "subject_"; ok(defined(&subject_import), "subject_import exported G2"); subject_import("Object::Import", list => ["import"], prefix => "object_", target => "G2"); ok(defined(&object_import), "object_import exported G2"); object_import("X", savenames => \%nm, target => "G2"); ok(defined(&greet), "def greet G2"); is_deeply(\%nm, {greet => 1}, "no other names exported G2"); is(greet("world"), "hello world from X", "&greet G2"); } eval q{ { package G3; use Test::More; our %nm; use Object::Import "Object::Import", list => ["import"], prefix => "object_"; ok(defined(&object_import), "object_import exported G3"); object_import "X", savenames => \%nm, target => "G3"; ok(defined(&greet), "def greet G3"); is_deeply(\%nm, {greet => 1}, "no other names exported G3"); is(greet("world"), "hello world from X", "&greet Gb"); } }; my $eval_err = $@; is($eval_err, "", "eval ran fine"); __END__ Object-Import-1.006/t/01_basic.t0000644000175000017500000000502613460663151015563 0ustar corioncorionuse warnings; no warnings qw"uninitialized reserved prototype"; use strict; use Test::More tests => 34; BEGIN { $::W1 = $::W2 = $::W3 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ m"\ASubroutine G1::greet redefined at .*\bObject/Import\.pm ") { $::W1++; } elsif ($t =~ /\Awarning: Object::Import cannot find methods of /) { $::W2++; } elsif ($t =~ m"\ASubroutine .* redefined at .*\bObject/Import\.pm ") { $::W3++; } else { warn $t; } }; } is($::W1, 0, "no warn redefined 0"); is($::W2, 0, "no warn nometh 0"); is($::W3, 0, "no warn redefined other 0"); $::W1 = $::W2 = $::W3 = 0; { package X; sub greet { my($o, $i) = @_; (ref($o) ? $$o[0] : $o) . ", " . $i; } } { package Hi; BEGIN { @Hi::ISA = X::; } } { package G0; use Test::More; ok(defined(\&greet), "G0 def&greet"); is(greet("world"), "hello, world", "G0 &greet"); use Object::Import bless(["hello"], X::), list => ["greet"]; is($::W1, 0, "no warn redefined G0"); is($::W2, 0, "no warn nometh G0"); is($::W3, 0, "no warn redefined other G0"); $::W1 = $::W2 = $::W3 = 0; } { package G1; use Test::More; ok(!exists(&greet), "G1 !exi&greet"); my $v = eval q'no strict; greet'; is($@, "", "G1 greet bare err"); is($v, "greet", "G1 greet bare"); ok(defined(&thank), "G1 def&thank"); import Object::Import bless(["hey"], X::), list => ["greet"]; ok(defined(&greet), "G1.1 def&greet"); is(greet("world"), "hey, world", "G1.1 &greet"); $v = eval q'no strict; greet'; is($@, "", "G1.1 greet err"); is($v, "hey, ", "G1.1 greet"); $v = eval q'no strict; greet world'; is($@, "", "G1.1 greet w err"); is($v, "hey, world", "G1.1 greet w"); is($::W1, 0, "no warn redefined G1.1"); is($::W2, 0, "no warn nometh G1.1"); is($::W3, 0, "no warn redefined other G1.1"); $::W1 = $::W2 = $::W3 = 0; import Object::Import Hi::, list => ["greet"], nowarn_redefine => 1; ok(defined(&greet), "G1.2 def&greet"); is(greet("perl"), "Hi, perl", "G1.2 &greet"); is($::W1, 0, "no warn redefined G1.2"); is($::W2, 0, "no warn nometh G1.2"); is($::W3, 0, "no warn redefined other G1.2"); $::W1 = $::W2 = $::W3 = 0; import Object::Import bless(["welcome"], Hi::), list => ["greet"]; ok(defined(&greet), "G1.3 def&greet"); is(greet("perl"), "welcome, perl", "G1.3 &greet"); is($::W1, 1, "warn redefined G1.3"); is($::W2, 0, "no warn nometh G1.3"); is($::W3, 0, "no warn redefined other G1.3"); $::W1 = $::W2 = $::W3 = 0; use Object::Import bless(["hullo"], X::), list => ["thank"]; } is($::W1, 0, "no warn redefined \$"); is($::W2, 0, "no warn nometh \$"); is($::W3, 0, "no warn redefined other \$"); __END__ Object-Import-1.006/t/09_parm.t0000644000175000017500000000214413460663151015447 0ustar corioncorionuse warnings; use strict; use Test::More tests => 12; # some basic tests on whether arguments and returns are passed correctly BEGIN { $::W4 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ m"\Awarning: Object::Import cannot find methods of " || $t =~ m"\ASubroutine .* redefined at .*\bObject/Import\.pm ") { $::W4++; } warn $t; }; } use Object::Import (); { package X; sub con { if (!defined(wantarray)) { $_[1] = "void"; } elsif (wantarray) { return "two", "elements"; } else { return "grich"; } } sub cnt { 0 + @_; } sub bsl { \$_[1]; } } { package G; use Test::More; import Object::Import X::; is("" . con((my $c_s = "scalar")), "grich", "scalar con"); is($c_s, "scalar", "scalar con arg"); is(join(":", con((my $c_l = "list"))), "two:elements", "list con"); is($c_l, "list", "list con arg"); con((my $c_v = "unknown")); is($c_v, "void", "void con arg"); is(cnt(), 1, "cnt 1"); is(cnt(4, 9), 3, "cnt 3"); is(cnt("boo", "zrk", undef, undef), 5, "cnt 5"); is(cnt([]), 2, "cnt 2"); my $t; is(ref(bsl($t)), "SCALAR", "bsl"); is(bsl($t), \$t, "bsl"); } is($::W4, 0, "no warn"); __END__ Object-Import-1.006/t/11_exporter.t0000644000175000017500000000065213460663151016353 0ustar corioncorionuse warnings; use strict; use Test::More tests => 3; use Object::Import (); { package X; use Exporter; our @ISA = "Exporter"; sub greet { my($o, $a) = @_; "hello $a from $o"; } } { package G; use Test::More; our %nm; import Object::Import "X", savenames => \%nm; ok(defined(&greet), "def greet"); is_deeply(\%nm, {greet => 1}, "no other names exported"); is(greet("world"), "hello world from X", "&greet"); } __END__ Object-Import-1.006/t/02_auto.t0000644000175000017500000000542213460663151015453 0ustar corioncorionuse warnings; no warnings qw"prototype"; use strict; use Test::More tests => 41; BEGIN { $::W4 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ m"\Awarning: Object::Import cannot find methods of " || $t =~ m"\ASubroutine .* redefined at .*\bObject/Import\.pm ") { $::W4++; } warn $t; }; } use Object::Import (); is($::W4, 0, "no warn 0"); { package X0; sub greet { my($o, $i) = @_; (ref($o) ? $$o[0] : $o) . ", " . $i; } } { package G0; use Test::More; import Object::Import bless(["hello"], X0::); ok(defined(\&greet), "G0 def&greet"); is(greet("world"), "hello, world", "G0 &greet"); import Object::Import bless(["hai"], X0::); # shall not redefine greet is(greet("world"), "hello, world", "G0.1 &greet"); import Object::Import bless(["welcome"], X0::), list => ["greet"], nowarn_redefine => 1; is(greet("world"), "welcome, world", "G0.2 &greet"); } is($::W4, 0, "no warn G0"); { package X1; sub greet { "hello " . ${$_[0]}[0] } sub cos { "dust " . ${$_[0]}[0] } sub getprotobynumb { "tcp " . ${$_[0]}[0] } sub _frobnicate { die } DESTROY { } } { package X1B; BEGIN { @X1B::ISA = X1::; } } { package G1; use Test::More; ok(defined(&{$_}), "G1 def\&$_") for qw"greet cos getprotobynumb greeter coser getprotobynumber _frobnicate"; is(greet(), "hello bunny", "G1 &greet"); is(greeter(), "hello package", "G1 &greeter"); is(cos(0), 1, "G1 COREcos"); is(getprotobynumber(1), "icmp", "G1 COREgetprotobynumber"); use Object::Import bless(["bunny"], X1B::), list => [qw"greet cos getprotobynumb _frobnicate"]; is(cos(0), "dust bunny", "G1.1 &cos"); is(getprotobynumber(1), "icmp", "G1.1 COREgetprotobynumber"); use Object::Import bless(["package"], X1B::), list => [qw"greet cos getprotobynumb"], suffix => "er"; is(cos(0), "dust bunny", "G1.2 &cos"); is(getprotobynumber(1), "tcp package", "G1.2 &getprotobynumber"); } { package G2; use Test::More; our %nm2; use Object::Import bless(["bunny"], X1B::); use Object::Import bless(["package"], X1B::), suffix => "er", savenames => \%nm2, debug => 0; use Object::Import bless(["package"], X1B::), prefix => "mal"; use Object::Import bless(["package"], X1B::), prefix => "well_"; use Object::Import bless(["package"], X1B::), prefix => "bis", underscore => 1; ok(defined(&{$_}), "G2 def\&$_") for qw"greet getprotobynumb greeter coser bis_frobnicate"; ok(!exists(&{$_}), "G2 !exi\&$_") for qw"cos getprotobynumber DESTROY DESTROYer _frobnicate _frobnicateer mal_frobnicate"; is_deeply(\%nm2, {greeter => 1, coser => 1}, "G2 savenames"); is(greet(), "hello bunny", "G2 &greet"); is(greeter(), "hello package", "G2 &greeter"); is(well_greet(), "hello package", "G2 &greeter"); is(malgreet(), "hello package", "G2 &greeter"); is(cos(0), 1, "G2 COREcos"); is(getprotobynumber(1), "icmp", "G2 COREgetprotobynumber"); } is($::W4, 0, "no warn"); __END__ Object-Import-1.006/t/00_require.t0000644000175000017500000000022513460663151016151 0ustar corioncorionuse Test::More tests => 2; require_ok("Object::Import"); cmp_ok(1.001, "<=", $Object::Import::VERSION, "Object::Import::VERSION defined"); __END__ Object-Import-1.006/t/07_mary.t0000644000175000017500000000353513460663151015463 0ustar corioncorionuse warnings; use strict; use Test::More tests => 32; { package X; sub little { small(@_) } use constant { had => -52, lamb => 4, snow => "ho ho ho", }; use constant a => (1, 9); sub its; sub fleece; sub as; sub white { q() . $_[1] . q() }; use subs qw" and everywhere that Mary went that lamb was _sure _to go "; AUTOLOAD { $X::AUTOLOAD =~ /\A.*::(.*)\z/s or die; "<" . $1 . ">" . $_[1] . ""; } } is(X->p("foo"), "

foo

", "direct AUTOLOADED method call"); { package G; use Test::More; my %name; use_ok("Object::Import", "X", savenames => \%name, exclude_methods => {was => 1}, exclude_imports => {go => 1}); my %name_expect; $name_expect{$_} = 1 for qw" Mary had a little lamb its fleece as white as snow and everywhere that Mary went "; ok(!exists(&$_), "!exi\&$_") for qw"small was sure to go _was _sure _to _go"; is_deeply(\%name, \%name_expect, "savenames"); is(white(fleece(little(lamb()))), q(4), "&white"); is(Mary("go"), "go", "&Mary"); is(join(":", a()), "1:9", "&a"); ok(!exists(&small), "!exi&small"); } { package G1; use Test::More; my %name; use_ok("Object::Import", "X", savenames => \%name, prefix => "_", exclude_methods => {was => 1, _fleece => 1}, exclude_imports => {_go => 1, white => 1}); my %name_expect; $name_expect{$_} = 1 for qw" _Mary _had _a _little _lamb _its _fleece _as _white _as _snow _and _everywhere _that _Mary _went "; ok(!exists(&$_), "!exi\&$_") for qw"_small _was _sure _to _go __was __sure __to __go had"; is_deeply(\%name, \%name_expect, "savenames"); is(_white(_fleece(_little(_lamb()))), q(4), "&white"); is(_Mary("go"), "go", "&Mary"); is(join(":", _a()), "1:9", "&a"); ok(!exists(&_small), "!exi&small"); } __END__ Object-Import-1.006/t/08_target.t0000644000175000017500000000434313460663151016000 0ustar corioncorionuse warnings; no warnings qw"uninitialized reserved prototype"; use strict; use Test::More tests => 9; use Scalar::Util; BEGIN { $::W4 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ m"\Awarning: Object::Import cannot find methods of " || $t =~ m"\ASubroutine .* redefined at .*\bObject/Import\.pm ") { $::W4++; } warn $t; }; } is($::W4, 0, "no warn 0"); { package X; sub greet { my($o, $i) = @_; (ref($o) ? $$o[0] : $o) . ", " . $i; } } { package Hi; BEGIN { @Hi::ISA = X::; } } { package Hi::DSL; use Object::Import; use Carp qw(croak); sub import { my ($class, %options); if (@_ == 2) { ($class, $options{ name }) = @_; } else { ($class, %options) = @_; }; my $target = delete $options{ target } || caller; my $name = delete $options{ name } || '$obj'; my $obj = bless(["hello"], Hi::); $name =~ s/^[\$]// or croak 'Variable name must start with $'; { no strict 'refs'; *{"$target\::$name"} = \$obj; # Now install in $target:: import Object::Import \${"$target\::$name"}, deref => 1, target => $target; } } } { package X::DSL; use Object::Import; use Carp qw(croak); sub import { my ($class, %options); if (@_ == 2) { ($class, $options{ name }) = @_; } else { ($class, %options) = @_; }; my $target = delete $options{ target } || caller; my $name = delete $options{ name } || '$obj'; my $obj = bless(["hello"], X::); $name =~ s/^[\$]// or croak 'Variable name must start with $'; { no strict 'refs'; *{"$target\::$name"} = \$obj; # Now install in $target:: import Object::Import \${"$target\::$name"}, deref => 1, target => $target; } } } { package G0; use Test::More; # use Hi::DSL; BEGIN{ Hi::DSL->import() }; ok(defined(\&greet), "G0 def&greet"); is(Scalar::Util::blessed($G0::obj), "Hi", "exported \$obj"); is(greet("world"), "hello, world", "G0 &greet"); $$G0::obj[0] = "bye"; is(greet("world"), "bye, world", "G0.1 &greet"); is($::W4, 0, "no warn G0"); } { package G1; use Test::More; # use Hi::DSL; BEGIN{ X::DSL->import() }; ok(defined(\&greet), "G1 def&greet"); is(greet("world"), "hello, world", "G1 &greet"); is($::W4, 0, "no warn G0"); } __END__ Object-Import-1.006/t/10_alias.t0000644000175000017500000000647113460663151015600 0ustar corioncorionuse warnings; use strict; use Test::More tests => 55; # test that the module keeps the reference to the object correctly BEGIN { $::W4 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ m"\Awarning: Object::Import cannot find methods of " || $t =~ m"\ASubroutine .* redefined at .*\bObject/Import\.pm ") { $::W4++; } warn $t; }; } use Object::Import (); { package X; sub bself { \$_[0]; } $::DC = 0; DESTROY { $::DC++; } } { package G; use Test::More; use Scalar::Util "reftype"; my $o0 = bless [], X::; import Object::Import $o0, "prefix", "o0_"; my $o0b = o0_bself(); is(reftype($o0b), "REF", "o0 ref bself"); isnt(\$o0, $o0b, "o0 id bself"); is(reftype($$o0b), "ARRAY", "o0 ref self"); is($$o0b, $o0, "o0 id self"); my $o1 = bless [], X::; import Object::Import \$o1, "deref", 1, "prefix", "o1_"; my $o1b = o1_bself(); is(reftype($o1b), "REF", "o1 ref bself"); is(\$o1, $o1b, "o1 id bself"); is(reftype($$o1b), "ARRAY", "o1 ref self"); is($$o1b, $o1, "o1 id self"); is($::DC, 0, "dcb 0"); $o1 = bless {}, X::; is($::DC, 1, "dc 1"); is(reftype(o1_bself()), "REF", "o1 ref new bself"); is(o1_bself(), $o1b, "o1 id new bself"); is(reftype($$o1b), "HASH", "o1 ref new self"); is($$o1b, $o1, "o1 id new self"); my $k0; eval { ${o0_bself()} = bless \$k0, X::; }; my $err0 = $@; is($@, "", "o0 sneaky eval"); is(reftype(o0_bself()), "REF", "o0 ref sneaky bself"); is(o0_bself(), $o0b, "o0 id sneaky bself"); is(reftype($$o0b), "SCALAR", "o0 ref sneaky self"); isnt($$o0b, $o0, "o0 id sneaky self not"); is($$o0b, \$k0, "o0 id sneaky self"); is(reftype($o0), "ARRAY", "o0 ref sneaky var"); is($::DC, 1, "dcb 1"); $o0 = (); is($::DC, 2, "dc 2"); is(${o0_bself()}, \$k0, "o0 id still sneaky self"); is($::DC, 2, "dcb 2"); my $k1; eval { ${o1_bself()} = bless \$k1, X::; }; my $err1 = $@; is($::DC, 3, "dc 3"); is($@, "", "o1 sneaky eval"); is(reftype(o1_bself()), "REF", "o1 ref sneaky bself"); is(o1_bself(), $o1b, "o1 id sneaky bself"); is(reftype($$o1b), "SCALAR", "o1 ref sneaky self"); is($$o1b, $o1, "o1 id sneaky self same"); is($$o1b, \$k1, "o1 id sneaky self"); is(reftype($o1), "SCALAR", "o1 ref sneaky var"); is($o1, \$k1, "o1 id sneaky var"); } { package G; no warnings qw"redefine prototype"; is($::DC, 3, "dcb 3"); *o0_bself = sub { -1 }; is($::DC, 4, "dc 4 del sub"); *o1_bself = sub { -1 }; is($::DC, 5, "dc 5 del sub"); } { package G1; use Test::More; use Scalar::Util "reftype"; my $c0 = X::; import Object::Import $c0, "prefix", "c0_"; my $c0b = c0_bself(); is(reftype($c0b), "SCALAR", "c0 ref bself"); isnt(\$c0, $c0b, "c0 id bself"); is(reftype($$c0b), undef, "c0 ref self"); is($$c0b, $c0, "c0 val self"); my $c1 = X::; import Object::Import \$c1, "deref", 1, "prefix", "c1_"; my $c1b = c1_bself(); is(reftype($c1b), "SCALAR", "c1 ref bself"); is(\$c1, $c1b, "c1 id bself"); is(reftype($$c1b), undef, "c1 ref self"); is($$c1b, $c1, "c1 val self"); my @k0; eval { ${c0_bself()} = bless \@k0, X::; }; my $err0 = $@; is($@, "", "c0 sneaky eval"); is(reftype(c0_bself()), "REF", "c0 ref sneaky bself"); is(c0_bself(), $c0b, "c0 id sneaky bself"); is(reftype($$c0b), "ARRAY", "c0 ref sneaky self"); isnt($$c0b, $c0, "c0 id sneaky self not"); is($$c0b, \@k0, "c0 id sneaky self"); is(reftype($c0), undef, "o0 ref sneaky var"); is($c0, X::, "o0 val sneaky var"); } is($::DC, 5, "dcf very end 5"); is($::W4, 0, "no warn"); __END__ Object-Import-1.006/t/04_handle.t0000644000175000017500000000361213460663151015737 0ustar corioncorionuse warnings; use strict; use Test::More tests => 56; BEGIN { require_ok("IO::File"); use_ok("File::Temp", "tempfile"); require_ok("Object::Import"); } my($TT, $tn) = tempfile(UNLINK => 1); ok($tn, "timefile name"); ok(binmode($TT)); SKIP: { ok(open(TI, "+>", $tn), "open ti") or skip("could not open ti ($tn): $!", 25); ok(binmode(TI), "binmode ti"); bless(*TI{IO}, IO::File::); import Object::Import *TI, prefix => "ti"; ok(defined(&$_), "def\&$_") for qw"tiprint tiseek titell tigetline ticlose"; ok(tiprint("hello\nworld\n"), "&tiprint"); is(titell(), 12, "&titell"); ok(tiseek(0, 0), "&tiseek"); is(tigetline(), "hello\n", "&tigetline"); import Object::Import \*TI, prefix => "tj"; ok(defined(&$_), "def\&$_") for qw"tjprint tjseek tjtell tjgetline tjclose"; ok(tjseek(0, 0), "&tjseek"); is(tjgetline(), "hello\n", "&tjgetline"); import Object::Import *TI{IO}, prefix => "th"; ok(defined(&$_), "def\&$_") for qw"thprint thseek thtell thgetline thclose"; ok(thseek(0, 0), "&thseek"); is(thgetline(), "hello\n", "&thgetline"); ok(ticlose(), "&ticlose"); } SKIP: { ok(open(my $TL, "+>", $tn), "open tl") or skip("could not open tl ($tn): $!", 10); ok(binmode($TL), "binmode tl"); bless(*$TL{IO}, IO::File::); import Object::Import $TL, prefix => "tl"; ok(defined(&$_), "def\&$_") for qw"tlprint tlseek tltell tlgetline tlclose"; ok(tlprint("ahoi\nworld\n"), "&tlprint"); is(tltell(), 11, "&tltell"); ok(tlseek(0, 0), "&tlseek"); is(tlgetline(), "ahoi\n", "&tlgetline"); import Object::Import *$TL{IO}, prefix => "tv"; ok(defined(&$_), "def\&$_") for qw"tvprint tvseek tvtell tvgetline tvclose"; ok(tvseek(0, 0), "&tvseek"); is(tvgetline(), "ahoi\n", "&tvgetline"); ok(tlclose(), "&tlclose"); } import Object::Import $TT, prefix => "tt"; ok(defined(&$_), "def\&$_") for qw"ttprint ttgetline ttclose"; ok(seek($TT, 0, 0), "seek"); is(ttgetline(), "ahoi\n", "&ttgetline"); ok(ttclose(), "&ttclose"); __END__ Object-Import-1.006/t/06_deref.t0000644000175000017500000000410613460663151015572 0ustar corioncorionuse warnings; use strict; use Test::More tests => 33; BEGIN { $::W4 = 0; $SIG{__WARN__} = sub { my($t) = @_; if ($t =~ m"\Awarning: Object::Import cannot find methods of " || $t =~ m"\ASubroutine .* redefined at .*\bObject/Import\.pm ") { $::W4++; } warn $t; }; } is($::W4, 0, "no warn 0"); BEGIN { require_ok("Math::BigInt"); } { my $bi = Math::BigInt->new("90"); use_ok("Object::Import", \$bi, deref => 1, prefix => "bi_"); is(bi_bmul(2), "180"); $bi = Math::BigInt->new("100"); is(bi_as_hex(), "0x64"); } { package X0; BEGIN { $::C0 = 0; } sub new { $::C0++; bless {}, $_[0] } sub greet { "hello" } DESTROY { $::C0--; } } { package G0; use Test::More; use_ok("Object::Import", \my $ex, deref => 1, list => ["greet"]); is($::C0, 0, "G0.0 C"); eval { greet() }; like($@, qr/\ACan't call method "greet" on an undefined value/, "G0.0 &greet dies"); $ex = X0->new; is($::C0, 1, "G0.1 C"); is(greet(), "hello", "G0.1 &greet"); $ex = undef; is($::C0, 0, "G0.2 C"); eval { greet() }; like($@, qr/\ACan't call method "greet" on an undefined value/, "G0.2 &greet dies"); } { package X1; BEGIN { $::C1 = 0; } sub new { $::C1++; bless {}, $_[0] } sub greet { "hello" } DESTROY { $::C1--; } } { package G1; use Test::More; my $ex; BEGIN { use_ok("Object::Import", \($ex = X1->new), deref => 1, list => ["greet"]); } is($::C1, 1, "G1.1 C"); is(greet(), "hello", "G1.1 &greet"); $ex = undef; is($::C1, 0, "G1.2 C"); eval { greet() }; like($@, qr/\ACan't call method "greet" on an undefined value/, "G1.2 &greet dies"); } { package X2; sub greet { ${$_[0]}[0] } } { package G2; use Test::More; our $ex = X1->new; use_ok("Object::Import", \$ex, deref => 1, prefix => "hr"); use_ok("Object::Import", "G2::ex", deref => 1, prefix => "gr"); use_ok("Object::Import", *ex, deref => 1, prefix => "sr"); for (qw"hrgreet grgreet srgreet") { no strict "refs"; ok(defined(&$_), "G2 def\&$_"); is(&$_(), "hello", "&hrgreet"); } $ex = bless ["bye"], X2::; for (qw"hrgreet grgreet srgreet") { no strict "refs"; ok(defined(&$_), "G2 def\&$_"); is(&$_(), "bye", "&hrgreet"); } } is($::W4, 0, "no warn"); __END__ Object-Import-1.006/t/12_taint.t0000644000175000017500000000070413460663151015621 0ustar corioncorion#!perl -T use warnings; use strict; use Test::More tests => 4; use 5.008; # ${^TAINT} ok(${^TAINT}, "taint mode"); use Object::Import (); { package X; sub greet { my($o, $a) = @_; "hello $a from $o"; } } { package G; use Test::More; our %nm; import Object::Import "X", savenames => \%nm; ok(defined(&greet), "def greet"); is_deeply(\%nm, {greet => 1}, "no other names exported"); is(greet("world"), "hello world from X", "&greet"); } __END__ Object-Import-1.006/.gitignore0000644000175000017500000000020613460663151015535 0ustar corioncorionMakefile Makefile.old *.tar.gz *.bak *.swp pm_to_blib blib/ Object-Import-* Object-Import-*/ .releaserc cover_db MYMETA.* Object-Import-1.006/META.yml0000644000175000017500000000137613460663343015032 0ustar corioncorion--- abstract: 'import methods of an object as functions to a package' author: - unknown build_requires: File::Temp: '0' IO::Handle: '0' MRO::Compat: '0' Math::BigInt: '1.59' Scalar::Util: '0' Test::More: '0.47' strict: '0' warnings: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150005' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Object-Import no_index: directory: - t - inc requires: IO::Handle: '0' MRO::Compat: '0' Scalar::Util: '0' perl: '5.008' strict: '0' warnings: '0' version: '1.006' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Object-Import-1.006/lib/0000755000175000017500000000000013460663343014320 5ustar corioncorionObject-Import-1.006/lib/Object/0000755000175000017500000000000013460663343015526 5ustar corioncorionObject-Import-1.006/lib/Object/Import.pm0000644000175000017500000006366113460663340017347 0ustar corioncorionpackage Object::Import; use warnings; our $VERSION = 1.006; =head1 NAME Object::Import - import methods of an object as functions to a package =head1 SYNOPSIS use Object::Import $object; foo(@bar); # now means $object->foo(@bar); =head1 DESCRIPTION This module lets you call methods of a certain object more easily by exporting them as functions to a package. The exported functions are not called as methods and do not receive an object argument, but instead the object is fixed at the time you import them with this module. You use the module with the following syntax: use Object::Import $object, %options; Here, C<$object> is the object from which you want to import the methods. This can be a perl object (blessed reference), or the name of a package that has class methods. As usual, a C statement is executed in compile time, so you should take care not to use values that you compute only in run-time, eg. my $object = Foo::Bar->new(); use Object::Import $object; # WRONG: $object is not yet initialized Instead, you have to create the object before you import, such as use Object::Import Foo::Bar->new(); You can also call import in run-time, eg. use Object::Import (); my $object = Foo::Bar->new(); import Object::Import $object; but in that case, you can't call the imported functions without parenthesis. If you don't give an explicit list of methods to export, Object::Import tries to find out what callable methods the object has and import all of them. Some methods are excluded from exporting in this case, namely any methods where exporting would overwrite a function existing in the target package or would override a builtin function, also any methods with names that are special to perl, such as C, and any methods whose name starts with an underscore. This automatic search for methods is quite fragile because of the way perl OO works, so it can find subroutines that shouldn't actually be called as methods, or not find methods that can actually be called. In particular, even if you import an object from a purely object oriented module, it can find non-method subs imported from other (non-OO) modules. If you do give a list of methods to export, Object::Import trusts you know what you mean, so it exports all those subs even if it has to replace existing subs or break something else. =head1 OPTIONS The following import options can be passed to the module. =over =item C<< list => >> I<$arrayref> Sets the list of methods to export, instead of the module deciding automatically. I<$arrayref> must be a reference to an array containing method names. Eg. use Object::Import LWP::UserAgent->new, list => [qw"get post head mirror request simple_request"]; =item C<< target => >> I<$package_name> Export the sub names to the given namespace. Default is the package from where you call import. =item C<< deref => 1 >> Signals that the first import argument, instead of being the object itself, is a reference to a scalar that contains the object. The content of this scalar may later be changed, and the imported functions will be called on the new contents. (The scalar may even be filled with undef, as long as you don't call the functions at that time.) If you don't pass the list of methods explicitly, the content of the scalar at the time of the import is used for determining the methods as a template to determine the methods. If, however, you give the list of methods, the content of the scalar is not examined at the time of the import. =item C<< prefix => >> I<$string> Prepends a string to the names of functions imported. This is useful if some of the method names are the same as existing subs or builtins. Eg. use Object::Import $object, prefix => "foo_"; foo_bar(); # calls $object->bar(); =item C<< suffix => >> I<$string> Like the prefix option, only the string is appended. =item C<< underscore => 1 >> Consider a method for automatic inclusion even if its name starts with an underscore. Such methods are normally excluded, because they are usually used as private subs. =item C<< exclude_methods => >> I<$hashref> Sets a list of additional methods that are not automatically imported. The argument must be a reference to a hash whose keys are potential method names. Ignored if you use the C option. =item C<< exclude_imports => >> I<$hashref> Sets a list of additional sub names which the module must never use as names of imported subs. These names are thus compared not with the original method names, but the names possibly transformed by adding prefixes and suffixes. This applies even if you give an explicit C of methods to import. =item C<< savenames => >> I<$hashref> Save the (unqualified) names of the functions exported by adding them as a key to a hash (the value is incremented with the ++ operator). This could be useful if you wanted to reexport them with Exporter. I<$arrayref> must be a real reference to a hash, not an undef. =item C<< nowarn_redefine => 1 >> Do not warn when an existing sub is redefined. That is currently only possible if you give the list of methods to be exported explicitly with the C option, because if the module chooses automatically then it will not redefine subs. =item C<< nowarn_nomethod => 1 >> Suppress the warning when you try to import methods from an object you might have passed in by mistake. Namely the object could be the name of a nonexistent package, a string that is not a valid package name, an unblessed object, or undef. Such values either don't currently have any methods, or calling methods on them is impossible. That warning often indicates that you passed the wrong value to Object::Import or forgot to require a package. =item C<< debug => 1 >> Print debugging messages about what the module exports. =back =head1 NOTES =head2 Importing from IO handles It is possible to use an IO handle as the object to export methods from. If you do this, you should require IO::Handle first so that the handle actually has methods. You should probably also use the prefix or suffix option in such a case, because many methods of handles have the same name as a builtin function. The handle must not be a symbolic reference, whether qualified or unqualified, eg. open FOO, "<", "somefile" or die; use Object::Import "FOO"; # WRONG You can pass a handle as a glob, reference to glob, or an IO::Handle object, so any of these would work as the object after the above open statement: C<*FOO>, C<\*FOO>, C<*FOO{IO}>. Another way to pass an IO::Handle object would be like this: use IO::File; use Object::Import IO::File->new("somefile", "<"); =head2 Changing the object The C<< deref >> option deserves special mention. This option adds a level of indirection to the imported functions: instead of them calling methods on an object passed to import, the methods are called on the object currently contained by a scalar to which a reference is passed in to import. This can be useful for various reasons: operating on multiple objects throughout the course of the program, being able to import the functions at compile time before you create the object, or being able to destroy the object. The first of this use is straightforward, but you may need to know the following for the other two uses. The list of methods imported is decided at the time you call import, and will not be changed later, no matter how the object is changed or methods the object supports are changed. You thus have to do extra loops if you want to call import before the object is available. The simplest solution is to pass the list of methods you want explicitly using the I<< list >> option. If for some reason you don't want to do this, you need to fill the scalar with a suitable prototype object that has all the methods of the actual object you want to use. In many cases, the package name the object will be blessed to is a suitable prototype, but note that if you do not control the module implementing the object, then that module may not guarantee what package the object will actually be blessed to: the package may depend on some run-time parameters and the details about this could change in future versions of the module. This is, of course, not specific to the deref option, but true to a lesser extent to any case when you're using Object::Import without an explicit list of methods: a future version of the module could create the methods of the class in runtime or AUTOLOAD them without declaring them, or it could add new private methods that will clash with function names you're using. Nevertheless, using the classname as a prototype can be a useful trick in quick and dirty programs, or if you are in control of the implementation of the object. Now let's hear about destroying an object that may hold resources you want to free. Object::Import guarantees that if you use the I<< deref >> option, it does not hold references to the object other than through the one scalar, so if undef the contents of that scalar, the object will be freed unless there are references from somewhere else. Finally, there's one thing you don't want to know but I must document it for completeness: if a method called through Object::Import changes its invocant (zeroth argument), that will also change the object the imported functions refer to, whether you use the deref option or not, and will change the contents of the scalar if you use the deref option. =head1 EXAMPLES Our examples assume the following declarations: use feature "say"; =head2 Basic usage First a simple example of importing class methods. use Math::BigInt; use Object::Import Math::BigInt::; say new("0x100"); This prints 256, because Math::BigInt->new("0x100") creates a big integer equal to 256. Now let's see a simple example of importing object methods. use Math::BigInt; use Object::Import Math::BigInt->new("100"); say bmul(2); say as_hex(); This prints 200 (2 multiplied by 100), then 0xc8 (100 as hexadecimal). =head2 Multiple imports Now let's see a more complicated example. This prints the leading news from the English Wikinews website. use warnings; use strict; use LWP::UserAgent; use XML::Twig; use Object::Import LWP::UserAgent->new; my $response = get "http://en.wikinews.org/wiki/Special:Export?". "pages=Template:Lead_article_1&limit=1"; import Object::Import $response; if (is_success()) { use Object::Import XML::Twig->new; parse content(); for my $parmname (qw"title summary") { first_elt("text")->text =~ /\|\s*$parmname\s*=([^\|\}]+)/ or die; print $1; } } else { die message(); } For example, as I am writing this (2010-09-05), this outputs =over Magnitude 7.0 earthquake hits New Zealand An earthquake with magnitude 7.0 occurred near South Island, New Zealand at Saturday 04:35:44 AM local time (16:35:44 UTC). The earthquake occurred at a depth of 16.1 kilometers (10.0 miles). The earthquake was reported to have caused widespread damage and power outages. Several aftershocks were also reported. =back In this, C refers to the useragent object; C, C and C refers to the response object (and these must be called with a parenthesis); while C and C refer to the twig object. This is not a good example to follow: it's quite fragile, and not only because of the simple regex used to parse out the right parts, but because if a new sub is added to a future version of the L or L classes, they might suddenly get imported and would shadow the methods we're supposed to import later. =head2 Suffix Now let's see an example of using a suffix. use File::Temp; use Object::Import scalar(File::Temp->new()), suffix => "temp"; printtemp "hello, world\nhidden"; seektemp 0, 0; print getlinetemp; say filenametemp; Here we need the suffix because print and seek are names of builtin functions. =head2 Creating the object later Let's see how we can import methods before we create an object. use Math::BigInt; our $number; use Object::Import \$number, deref => 1, list => ["bmul"]; sub double { bmul 2 } $number = Math::BigInt->new("100"); say double; This will output 200. Notice how here we're using the bmul function without parenthesis, so we must import it compile time for the code to parse correctly, but the object is not created till later. =head2 Prototype object This code is the same as above, except that instead of supplying a list of methods, we use a prototype object, namely the Math::BigInt package. At least one of the two is needed, for otherwise Object::Import would have no way to know what methods to import. use Math::BigInt; our $number; use Object::Import \($number = Math::BigInt::), deref => 1; sub double { bmul 2 } $number = Math::BigInt->new("100"); say double; =head2 Exporting to other package This example shows how to export to a different namespace. This is useful if you want to write your own sugar module that provides a procedural syntax: package My::Object::DSL; use Object::Import; use My::Object; sub import { my ($class, %options); if (@_ == 2) { ($class, $options{ name }) = @_; } else { ($class, %options) = @_; }; my $target = delete $options{ target } || caller; my $name = delete $options{ name } || '$obj'; my $obj = My::Object->new(%options); $name =~ s/^[\$]// or croak 'Variable name must start with $'; { no strict 'refs'; *{"$target\::$name"} = \$obj; # Now install in $target:: import Object::Import \${"$target\::$name"}, deref => 1, target => $target; } } You can use the module C<< My::Object::DSL >> as follows: use My::Object::DSL '$obj'; If you want to pass more options, you can use use My::Object::DSL name => '$obj', foo => 'bar'; Implementing a small C<::DSL> module instead of using C directly has the advantage that you can add defaults in C. =head1 SEE ALSO L, L, L, L =head1 BUGS Please report bugs using the CPAN bug tracker (under the distribution name Object-Import), or, failing that, to C. =head1 CREDITS The primary author and maintainer of this module is Zsban Ambrus C. Some of the code was written by Max Maischein, who also gave the motivation to turn a prototype to the full module you see. Thanks to exussum0 for the original inspiration. The module is maintained by Max Maischein since 2018. =head1 COPYING Copyright (C) Zsban Ambrus 2010 This program is free software: you can redistribute it and/or modify it under the terms of either the GNU General Public License version 3, as published by the Free Software Foundation; or the "Artistic License" which comes with perl. 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. A copy of the GNU General Public License can be found in the source tree of this module under the name "GPL", or else see "http://www.gnu.org/licenses/". A copy of the Artistic License can be found in the source tree under the name "ARTISTIC", or else see "http://search.cpan.org/~rjbs/perl-5.16.1/pod/perlartistic.pod". =cut use strict; use 5.007; use Scalar::Util qw"blessed reftype"; eval " use MRO::Compat; "; if (my $use_mro_compat_error = $@) { eval " use mro; "; my $use_mro_error = $@; $use_mro_error and die "$use_mro_compat_error\n$use_mro_error\nerror: could not use either of modules MRO::Compat or mro"; } # Methods must not be exported automatically if their original name is in %special_source # or if the name of the exported sub is in %special_target. our %special_source; our %special_target; # Any name starting with a character other than a letter or underscore are forced to # package main. Such names in other packages may only be accessed with an explicit # package name. Most of these are special or reserved to be special by the core, though # none of their function slots are used. We do not export these because the user could # not call them easily unless exported to main. Note that names starting with unicode # non-letter characters or names that start with invalid utf-8 also seem to be forced # to main (these may only be accessed through symbolic references). # The following names are also forced to main like above. $special_source{$_}++, $special_target{$_}++ for qw"ENV INC ARGV ARGVOUT SIG STDIN STDOUT STDERR _"; # The following names are called by the core on some occasions. $special_source{$_}++, $special_target{$_}++ for qw" AUTOLOAD BINMODE CLEAR CLEARERR CLONE CLONE_SKIP CLOSE DELETE DESTROY EOF ERROR EXISTS EXTEND FDOPEN FETCH FETCHSIZE FILENO FILL FIRSTKEY FLUSH GETC NEXTKEY OPEN POP POPPED PRINT PRINTF PUSH PUSHED READ READLINE SCALAR SEEK SETLINEBUF SHIFT SPLICE STORE STORESIZE SYSOPEN TELL TIEARRAY TIEHANDLE TIEHASH TIESCALAR UNREAD UNSHIFT UNTIE UTF8 WRITE"; # Names starting with "(" are used by the overload mechanism, even as functions in some # cases. We do not touch such subs. # Names starting with "_<" are used for something related to source files, # but the sub slot is not used, so we don't care. # The following names are called by use/no, so they definitely should not be exported. $special_source{$_}++, $special_target{$_}++ for qw"import unimport"; # The following should not occur as subs, but we exclude them for good measure. $special_source{$_}++, $special_target{$_}++ for qw"BEGIN UNITCHECK CHECK INIT END"; # The following names could override a builtin function if exported to a module $special_target{$_}++ for qw" abs accept alarm atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot close closedir connect continue cos crypt dbmclose dbmopen default defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd my next no not oct open opendir ord our pack package pipe pop pos print printf prototype push quotemeta rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write fc evalbytes __SUB__ __FILE__ __LINE__ __PACKAGE__ "; # The following four are UNIVERSAL functions. $special_source{$_}++, $special_target{$_}++ for qw"can isa DOES VERSION"; # The following keywords cannot be overriden this way, so are safe to export, # though you may have to use tricky syntax to call some of them: 0 for qw "and cmp eq ge gt le lt m ne or q qq qr qw qx s tr x xor y"; # The old aliases LT etc are removed from core at perl 5.8 and do not count # as special anymore. # Some of the above long list might also not be overridable, eg. "if". # The following are special, but are not functions and not forced to main. 0 for qw"a b DATA OVERLOAD"; # The following names are English aliases for special variables so they could # be aliased to special names, eg. if the module imports English # then &ARG and &::_ are the same. The function slot of none of these is special. # Exporting to such names would be a bad idea because they could overwrite # a function in main. $special_source{$_}++, $special_target{$_}++ for qw" ACCUMULATOR ARG ARRAY_BASE BASETIME CHILD_ERROR COMPILING DEBUGGING EFFECTIVE_GROUP_ID EFFECTIVE_USER_ID EGID ERRNO EUID EVAL_ERROR EXCEPTIONS_BEING_CAUGHT EXECUTABLE_NAME EXTENDED_OS_ERROR FORMAT_FORMFEED FORMAT_LINES_LEFT FORMAT_LINES_PER_PAGE FORMAT_LINE_BREAK_CHARACTERS FORMAT_NAME FORMAT_PAGE_NUMBER FORMAT_TOP_NAME GID INPLACE_EDIT INPUT_LINE_NUMBER INPUT_RECORD_SEPARATOR LAST_MATCH_END LAST_MATCH_START LAST_PAREN_MATCH LAST_REGEXP_CODE_RESULT LAST_SUBMATCH_RESULT LIST_SEPARATOR MATCH NR OFMT OFS OLD_PERL_VERSION ORS OSNAME OS_ERROR OUTPUT_AUTOFLUSH OUTPUT_FIELD_SEPARATOR OUTPUT_RECORD_SEPARATOR PERLDB PERL_VERSION PID POSTMATCH PREMATCH PROCESS_ID PROGRAM_NAME REAL_GROUP_ID REAL_USER_ID RS SUBSCRIPT_SEPARATOR SUBSEP SYSTEM_FD_MAX UID WARNING"; # The following are names used by Exporter, but not as functions. 0 for qw"EXPORT EXPORT_OK EXPORT_FAIL EXPORT_TAGS"; # The following are subs used by Exporter, some internal. $special_source{$_}++, $special_target{$_}++ for qw" _push_tags _rebuild_cache as_heavy export export_fail export_fail_in export_ok_tags export_tags export_to_level heavy_export heavy_export_ok_tags heavy_export_tags heavy_export_to_level heavy_require_version require_version"; # (Ideally we should have a mechanism to exclude everything that's defined in Exporter # or Exporter::Heavy) # The following are depreciated aliases to the standard filehandles, but as these aren't # forced to main we shan't exclude them. 0 for qw"stdin stdout stderr"; # Yeah, these lists got out of hand, but I want a place to collect all special names. # TODO: See also the B::Keywords module, and submit patches for it. # If the user gives an list of names, we assume they know what they are doing. sub special_source { my($n) = @_; utf8::decode($n); exists($special_source{$n}) || $n !~ /\A[_\pL]/; } sub special_target { my($n) = @_; utf8::decode($n); exists($special_target{$n}) || $n !~ /\A[_\pL]/; } # this returns a list to the methods we want to export automatically sub list_method { my($obj, $expkg, $debug, $nowarn_nomethod, $underscore, $exclude) = @_; my $oobj = $obj; my %exclude; if ($exclude) { %exclude = %$exclude; } my $complain = sub { my($k) = @_; $nowarn_nomethod and return; no warnings "uninitialized"; warn "warning: Object::Import cannot find methods of " . $k . ": " . $oobj; }; if (reftype($obj) ? !defined(blessed($obj)) && "GLOB" eq reftype($obj) : "GLOB" eq reftype(\$obj)) { $obj = *$obj{IO}; # this magically converts any filehandle (glob, ref-to-glob, symref, true handle object) to a handle object. we need this to find the methods. # note that we don't enter here if we have a blessed globref: magical overloaded objects such as File::Temp or Coro::Handle objs can take care of themselves, and we'd lose methods if we dereferenced them to their underlying handles. if (!defined($obj)) { &$complain("globref with no IO handle"); return; } } eval { $obj->can("import") }; my $can_methods = !$@; # false if $obj is an unblessed ref or a string that does not look like a package name, so perl refuses to call any methods if (!$can_methods) { &$complain( reftype($obj) ? (defined(blessed($obj)) ? "strange object" : "unblessed reference") : !defined($obj) ? "undefined value" : !length($obj) ? "empty string value" : !$obj ? "false value" : "string value that is an invalid package name"); return; } if (!reftype($obj) && do { no strict "refs"; !%{$obj . "::"} }) { &$complain("nonexistent package"); } my %r; my $class = blessed($obj) || $obj; my @class = @{mro::get_linear_isa($class)}; $debug and warn "debug: Object::Import object $oobj, class $class, search path: @class"; for my $pkgn (@class) { my $pkg = do { no strict "refs"; \%{$pkgn . "::"}}; for my $m (sort keys %$pkg) { if ( !$exclude{$m} && !$r{$m} && $obj->can($m) && # was exists(&{$$pkg{$m}}) !special_source($m) && ($underscore || $m !~ /\A_/) ) { $r{$m}++; } } } keys(%r); } sub dor ($$) { my($x, $y) = @_; defined($x) ? $x : $y; } sub import { my($_u, $arg1, @opt) = @_; if (@_ <= 1) { return; # required for later imports } 0 == @opt % 2 or die q"error: odd number of import options to Object::Import; usage: use Object::Import $obj, %opts"; my %opt = @opt; my($deref, $methl, $debug, $nowarn_redefine, $nowarn_nomethod, $underscore, $exclude_method, $exclude_import, $savename, $funprefix, $funsuffix, $expkgn) = delete(@opt{(qw"deref list debug nowarn_redefine nowarn_nomethod underscore exclude_methods exclude_imports savenames prefix suffix target")}); %opt and die "error: unused import options to Object::Import: " . join(" ", keys(%opt)); $expkgn = dor($expkgn, scalar caller); my $objr = $deref ? $arg1 : \$arg1; $_ = dor($_, "") for $funprefix, $funsuffix; # one could use the suffix "0" afterall my %exclude_import; $exclude_import and %exclude_import = %$exclude_import; my $expkgns = $expkgn . "::"; my $expkg = do {no strict 'refs'; \%{$expkgns} }; if ($debug) { warn "debug: Object::Import starting to export methods to package $expkgns"; } my @meth; if ($methl) { @meth = @$methl; } else { @meth = list_method do { no strict "refs"; $$objr }, $expkg, $debug, $nowarn_nomethod, $underscore, $exclude_method; } my @funn; for my $methn (@meth) { my $funn = $funprefix . $methn . $funsuffix; if (!$exclude_import{$funn} && ($methl || (!special_target($funn) && !exists(&{$expkgns . $funn}))) # was (!$$expkg{$funn} || !exists(&{$$expkg{$funn}})) # that's wrong because of some shortcut symbol table entries for constants or predeclared subs ) { my $p = sub (@) { no strict "refs"; $$objr->${\$methn}(@_) }; { no strict 'refs'; if ($nowarn_redefine) { no warnings "redefine"; *{$expkgns . $funn} = $p; } else { *{$expkgns . $funn} = $p; } } push @funn, $funn; } } if ($debug) { warn "debug: Object::Import exported the following functions: ", join(" ", sort(@funn)); } if ($savename) { $$savename{$_}++ for @funn; } } 1; __END__ Object-Import-1.006/META.json0000644000175000017500000000244113460663343015174 0ustar corioncorion{ "abstract" : "import methods of an object as functions to a package", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150005", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Object-Import", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "File::Temp" : "0", "IO::Handle" : "0", "MRO::Compat" : "0", "Math::BigInt" : "1.59", "Scalar::Util" : "0", "Test::More" : "0.47", "strict" : "0", "warnings" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "IO::Handle" : "0", "MRO::Compat" : "0", "Scalar::Util" : "0", "perl" : "5.008", "strict" : "0", "warnings" : "0" } } }, "release_status" : "stable", "version" : "1.006", "x_serialization_backend" : "JSON::PP version 2.27203" } Object-Import-1.006/ARTISTIC0000644000175000017500000001373713460663151014727 0ustar corioncorion 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 as specified below. "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 uunet.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) give non-standard executables non-standard names, and clearly document 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. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 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 whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Object-Import-1.006/TODO0000644000175000017500000000175413460663151014246 0ustar corioncorionTODO for Object::Import perl module = bugs = = features = - options to exclude subs inherited from some packages, and maybe some defaults (like Exporter) - options to exclude subs imported from some packages (like Carp, Scalar::Util, etc) and maybe some defaults (popular non-OO modules) - maybe even an option to skip all functions compiled to other packages (and imported)? - weak referencing the object: this can be done in two ways (deref on in both cases): either with an option to make the functions keep only a weak reference to the scalar, or by the scalar being a weak object itself. - maybe make it so that methods with names conflicting with builtins are exported ucfirsted (this may not be a good idea) = documentation = - perl can dispatch methods to filehandles -- how does this come up in code and docs? = distribution = = external = - examine how Symbol::Qualify doesn't work for non-ascii names, possibly patch and report - write patches to B::Keywords Object-Import-1.006/CHANGES0000644000175000017500000000373113460663151014546 0ustar corioncorion2019-04.26 v1.006 release to CPAN - documentation fix for "prefix" option - the prefix and suffix do not automatically provide an underscore 2018-10-29 v1.005 release to CPAN - fix syntax error with newer Perl versions ( RT106769, fix by Slaven Rezic ) - New Maintainer Max Maischein 2012-10-17 v1.004 release to CPAN - fix test t/05_nometh.t to not fail on some perl-bleads between 5.17.4 and 5.17.5 - have test t/13_nometh.t give clearer error message for some failure 2012-10-14 v1.003 release to CPAN - explicitly require perl 5.008 in metafile and module -- module never actually worked on older perls - fix a bug in test t/05_nometh.t (where I passed an array instead of hash to the savenames option) - fix test t/05_nometh.t to work with perl 5.17.5 and higher which allows to call class methods on packages with punctuation name -- used to explicitly test such methods being forbidden - add new keywords we do not export to by default: fc evalbytes __FILE__ __LINE__ __PACKAGE__ __SUB__ - in testsuite, test for specific warnings only, not for arbitrary warnings - added some new tests, including a test for module working under taint mode 2011-01-26 v1.002 release to CPAN - properly document deref option - method called through Object::Import changing its invocant didn't use to have any effect, now it changes the imported object - a few new tests (t/09_parm.t, t/10_alias.t) - fix test failures on Windows where I forgot to binmode a handle - fixed some misplaced text in the docs 2010-11-07 v1.001 release to cpan - target package option - distribution stuff: Makefile.PL, README, TODO - some tests - support for IO handles - save list of names exported to hash - add prefix/suffix to names - exclude some special method names, also underscored names - importing with explicit list of method names - documentation with examples - converting to real module 2010-06-13 v1.000 - toy prototype at http://www.perlmonks.com/?node_id=849373 Object-Import-1.006/README0000644000175000017500000000521313460663151014430 0ustar corioncorionNAME Object::Import - a perl module that lets you import methods of a perl object or class to a package as plain functions. USAGE use Object::Import $object; foo(@bar); # now means $object->foo(@bar); See the pod documentation in the Object::Import module for more details on how to use this module. DEPENDENCIES Perl version 5.8 or later is required to use this module. If you have perl version 5.10.0 or later, you shouldn't need any more prerequisites to use this module. Otherwise, you may need to install the following modules. mro OR MRO::Compat Scalar::Util Test::More * File::Temp * Math::BigInt * (The modules marked with a star are needed only for testing.) This is a pure perl module, so you won't need a C compiler to build it. INSTALLING First, you should get the latest release of the module from CPAN, under the distribution name Object-Import. After that, you can install the module like any other perl module that uses ExtUtils::MakeMaker. For example, use these commands. tar xzf Object-Import-1.VVV.tar.gz cd Object-Import-1.VVV perl Makefile.PL make make test make install Where 1.VVV is the version number of the module you've got. If you're not familiar with the procedure of installing a perl module, you may want to read "http://search.cpan.org/~rjbs/perl-5.16.1/pod/perlmodinstall.pod" SEE ALSO Class::Exporter, Scope::With, Sub::Exporter, Acme::Nooo BUGS Please report bugs using the CPAN bug tracker (under the distribution name Object-Import), or, failing that, to C. CREDITS The primary author and maintainer of this module is Zsban Ambrus C. Some of the code was written by Max Maischein, who also gave the motivation to turn a prototype to the full module you see. Thanks to exussum0 for the original inspiration. COPYING Copyright (C) Zsban Ambrus 2010 This program is free software: you can redistribute it and/or modify it under the terms of either the GNU General Public License version 3, as published by the Free Software Foundation; or the "Artistic License" which comes with perl. 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. A copy of the GNU General Public License can be found in the source tree of this module under the name "GPL", or else see "http://www.gnu.org/licenses/". A copy of the Artistic License can be found in the source tree under the name "ARTISTIC", or else see "http://search.cpan.org/~rjbs/perl-5.16.1/pod/perlartistic.pod". Object-Import-1.006/MANIFEST0000644000175000017500000000053713365643616014715 0ustar corioncorion.gitignore ARTISTIC CHANGES GPL lib/Object/Import.pm Makefile.PL MANIFEST MANIFEST.SKIP META.json Module JSON meta-data (added by MakeMaker) META.yml README t/00_require.t t/01_basic.t t/02_auto.t t/03_bigint.t t/04_handle.t t/05_nometh.t t/06_deref.t t/07_mary.t t/08_target.t t/09_parm.t t/10_alias.t t/11_exporter.t t/12_taint.t t/13_meta.t TODO