diff options
author | robot-piglet <[email protected]> | 2025-08-28 14:27:58 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-08-28 14:57:06 +0300 |
commit | 81d828c32c8d5477cb2f0ce5da06a1a8d9392ca3 (patch) | |
tree | 3081d566f0d5158d76e9093261344f6406fd09f7 /contrib/tools/swig/Lib/perl5 | |
parent | 77ea11423f959e51795cc3ef36a48d808b4ffb98 (diff) |
Intermediate changes
commit_hash:d5b1af16dbe9030537a04c27eb410c88c2f496cd
Diffstat (limited to 'contrib/tools/swig/Lib/perl5')
44 files changed, 4983 insertions, 0 deletions
diff --git a/contrib/tools/swig/Lib/perl5/.yandex_meta/licenses.list.txt b/contrib/tools/swig/Lib/perl5/.yandex_meta/licenses.list.txt new file mode 100644 index 00000000000..8aad0f87d67 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/.yandex_meta/licenses.list.txt @@ -0,0 +1,916 @@ +====================File: COPYRIGHT==================== +SWIG Copyright and Authors +-------------------------- + +Copyright (c) 1995-2023 The SWIG Developers +Copyright (c) 2005-2006 Arizona Board of Regents (University of Arizona). +Copyright (c) 1998-2005 University of Chicago. +Copyright (c) 1995-1998 The University of Utah and the Regents of the University of California + +Portions also copyrighted by: + Network Applied Communication Laboratory, Inc + Information-technology Promotion Agency, Japan + +Active SWIG Developers: + William Fulton ([email protected]) (SWIG core, Java, C#, Windows, Cygwin) + Olly Betts ([email protected]) (PHP) + Joseph Wang ([email protected]) (R) + Momtchil Momtchev ([email protected]) (Javascript Node-API) + Simon Marchetto ([email protected]) (Scilab) + Zackery Spytz ([email protected]) (OCaml, SWIG core) + +Past SWIG developers and major contributors include: + Dave Beazley ([email protected]) (SWIG core, Python, Tcl, Perl) + Henning Thielemann ([email protected]) (Modula3) + Matthias Köppe ([email protected]) (Guile, MzScheme) + Luigi Ballabio ([email protected]) (STL wrapping) + Mikel Bancroft ([email protected]) (Allegro CL) + Surendra Singhi ([email protected]) (CLISP, CFFI) + Marcelo Matus ([email protected]) (SWIG core, Python, UTL[python,perl,tcl,ruby]) + Art Yerkes ([email protected]) (OCaml) + Lyle Johnson ([email protected]) (Ruby) + Charlie Savage ([email protected]) (Ruby) + Thien-Thi Nguyen ([email protected]) (build/test/misc) + Richard Palmer ([email protected]) (PHP) + Sam Liddicott - Ananova Ltd ([email protected]) (PHP) + Tim Hockin - Sun Microsystems ([email protected]) (PHP) + Kevin Ruland (PHP) + Shibukawa Yoshiki (Japanese Translation) + Jason Stewart ([email protected]) (Perl5) + Loic Dachary (Perl5) + David Fletcher (Perl5) + Gary Holt (Perl5) + Masaki Fukushima (Ruby) + Scott Michel ([email protected]) (Java directors) + Tiger Feng ([email protected]) (SWIG core) + Mark Rose ([email protected]) (Directors) + Jonah Beckford ([email protected]) (CHICKEN) + Ahmon Dancy ([email protected]) (Allegro CL) + Dirk Gerrits (Allegro CL) + Neil Cawse (C#) + Harco de Hilster (Java) + Alexey Dyachenko ([email protected]) (Tcl) + Bob Techentin (Tcl) + Martin Froehlich <[email protected]> (Guile) + Marcio Luis Teixeira <[email protected]> (Guile) + Duncan Temple Lang (R) + Miklos Vajna <[email protected]> (PHP directors) + Mark Gossage ([email protected]) (Lua) + Raman Gopalan ([email protected]) (eLua) + Gonzalo Garramuno ([email protected]) (Ruby, Ruby's UTL) + John Lenz (Guile, MzScheme updates, Chicken module, runtime system) + Baozeng Ding <[email protected]> (Scilab) + Ian Lance Taylor (Go) + Dmitry Kabak ([email protected]) (Doxygen) + Vadim Zeitlin (PCRE, Python, Doxygen) + Stefan Zager ([email protected]) (Python) + Vincent Couvert (Scilab) + Sylvestre Ledru (Scilab) + Wolfgang Frisch (Scilab) + Oliver Buchtala ([email protected]) (Javascript) + Neha Narang ([email protected]) (Javascript) + Xavier Delacour ([email protected]) (Octave) + David Nadlinger ([email protected]) (D) + Leif Middelschulte ([email protected]) (C) + +Past contributors include: + James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran + Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn, + Edward Zimmermann, David Ascher, Dominique Dumont, Pier Giorgio Esposito, Hasan Baran Kovuk, + Klaus Wiederänders, Richard Beare, Hans Oesterholt. + (See CHANGES and CHANGES.current and the bug tracker for a more complete list). + +Past students: + Songyan Feng (Chicago). + Xinghua Shi (Chicago). + Jing Cao (Chicago). + Aquinas Hobor (Chicago). + +Historically, the following people contributed to early versions of SWIG. +Peter Lomdahl, Brad Holian, Shujia Zhou, Niels Jensen, and Tim Germann +at Los Alamos National Laboratory were the first users. Patrick +Tullmann at the University of Utah suggested the idea of automatic +documentation generation. John Schmidt and Kurtis Bleeker at the +University of Utah tested out the early versions. Chris Johnson +supported SWIG's developed at the University of Utah. John Buckman, +Larry Virden, and Tom Schwaller provided valuable input on the first +releases and improving the portability of SWIG. David Fletcher and +Gary Holt have provided a great deal of input on improving SWIG's +Perl5 implementation. Kevin Butler contributed the first Windows NT +port. + +Early bug reports and patches: +Adam Hupp, Arthur Smyles, Brad Clements, Brett Williams, Buck Hodges, +Burkhard Kloss, Chia-Liang Kao, Craig Files, Dennis Marsa, Dieter Baron, +Drake Diedrich, Fleur Diana Dragan, Gary Pennington, Geoffrey Hort, Gerald Williams, +Greg Anderson, Greg Kochanski, Greg Troxel, Henry Rowley, Irina Kotlova, +Israel Taller, James Bailey, Jim Fulton, Joel Reed, Jon Travis, +Junio Hamano, Justin Heyes-Jones, Karl Forner, Keith Davidson, +Krzysztof Kozminski, Larry Virden, Luke J Crook, Magnus Ljung, Marc Zonzon, +Mark Howson, Micahel Scharf, Michel Sanner, Mike Romberg, Mike Simons, +Mike Weiblen, Paul Brannan, Ram Bhamidipaty, Reinhard Fobbe, Rich Wales, +Richard Salz, Roy Lecates, Rudy Albachten, Scott Drummonds +Scott Michel, Shaun Lowry, Steve Galser, Tarn Weisner Burton, +Thomas Weidner, Tony Seward, Uwe Steinmann, Vadim Chugunov, Wyss Clemens, +Zhong Ren. + + + +====================File: LICENSE-GPL==================== + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + 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. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 <http://www.gnu.org/licenses/>. + +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: + + <program> Copyright (C) <year> <name of author> + 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 +<http://www.gnu.org/licenses/>. + + 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 +<http://www.gnu.org/philosophy/why-not-lgpl.html>. + + +====================File: LICENSE-UNIVERSITIES==================== +SWIG is distributed under the following terms: + +I. + +Copyright (c) 1995-1998 +The University of Utah and the Regents of the University of California +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following two paragraphs +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE +UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY +PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH +SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND +THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, +SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + + +II. + +This software includes contributions that are Copyright (c) 1998-2005 +University of Chicago. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. Redistributions +in binary form must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. Neither the name of +the University of Chicago nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +III. + +This software includes contributions that are Copyright (c) 2005-2006 +Arizona Board of Regents (University of Arizona). +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following paragraph +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +====================LicenseRef-scancode-swig==================== +SWIG 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. See the LICENSE-GPL file for +the full terms of the GNU General Public license version 3. + +Portions of SWIG are also licensed under the terms of the licenses +in the file LICENSE-UNIVERSITIES. You must observe the terms of +these licenses, as well as the terms of the GNU General Public License, +when you distribute SWIG. + +The SWIG library and examples, under the Lib and Examples top level +directories, are distributed under the following terms: + + You may copy, modify, distribute, and make derivative works based on + this software, in source code or object code form, without + restriction. If you distribute the software to others, you may do + so according to the terms of your choice. This software is offered as + is, without warranty of any kind. + +See the COPYRIGHT file for a list of contributors to SWIG and their +copyright notices.
\ No newline at end of file diff --git a/contrib/tools/swig/Lib/perl5/Makefile.pl b/contrib/tools/swig/Lib/perl5/Makefile.pl new file mode 100644 index 00000000000..cffdc8e79f8 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/Makefile.pl @@ -0,0 +1,19 @@ +# File : Makefile.pl +# MakeMaker file for a SWIG module. Use this file if you are +# producing a module for general use or distribution. +# +# 1. Modify the file as appropriate. Replace $module with the +# real name of your module and wrapper file. +# 2. Run perl as 'perl Makefile.pl' +# 3. Type 'make' to build your module +# 4. Type 'make install' to install your module. +# +# See "Programming Perl", 2nd. Ed, for more gory details than +# you ever wanted to know. + +use ExtUtils::MakeMaker; +WriteMakefile( + 'NAME' => '$module', # Name of your module + 'LIBS' => [''], # Custom libraries (if any) + 'OBJECT' => '$module_wrap.o' # Object files +); diff --git a/contrib/tools/swig/Lib/perl5/argcargv.i b/contrib/tools/swig/Lib/perl5/argcargv.i new file mode 100644 index 00000000000..ee238130b5a --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/argcargv.i @@ -0,0 +1,30 @@ +/* ------------------------------------------------------------- + * SWIG library containing argc and argv multi-argument typemaps + * ------------------------------------------------------------- */ + +%typemap(in) (int ARGC, char **ARGV) { + int i; + SSize_t len; + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) { + SWIG_croak("in method '$symname', Expecting reference to argv array"); + goto fail; + } + len = av_len(av) + 1; + $1 = ($1_ltype) len; + $2 = (char **) malloc((len+1)*sizeof(char *)); + for (i = 0; i < len; i++) { + SV **tv = av_fetch(av, i, 0); + $2[i] = SvPV_nolen(*tv); + } + $2[i] = NULL; +} + +%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { + AV *av = (AV *)SvRV($input); + $1 = SvTYPE(av) == SVt_PVAV; +} + +%typemap(freearg) (int ARGC, char **ARGV) { + free((void *)$2); +} diff --git a/contrib/tools/swig/Lib/perl5/attribute.i b/contrib/tools/swig/Lib/perl5/attribute.i new file mode 100644 index 00000000000..779716cd2ea --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/attribute.i @@ -0,0 +1 @@ +%include <typemaps/attribute.swg> diff --git a/contrib/tools/swig/Lib/perl5/carrays.i b/contrib/tools/swig/Lib/perl5/carrays.i new file mode 100644 index 00000000000..c1e6db3f0b4 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/carrays.i @@ -0,0 +1 @@ +%include <typemaps/carrays.swg> diff --git a/contrib/tools/swig/Lib/perl5/cmalloc.i b/contrib/tools/swig/Lib/perl5/cmalloc.i new file mode 100644 index 00000000000..248f06b961b --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/cmalloc.i @@ -0,0 +1 @@ +%include <typemaps/cmalloc.swg> diff --git a/contrib/tools/swig/Lib/perl5/cpointer.i b/contrib/tools/swig/Lib/perl5/cpointer.i new file mode 100644 index 00000000000..d824792fa7a --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/cpointer.i @@ -0,0 +1 @@ +%include <typemaps/cpointer.swg> diff --git a/contrib/tools/swig/Lib/perl5/cstring.i b/contrib/tools/swig/Lib/perl5/cstring.i new file mode 100644 index 00000000000..ede9c596aef --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/cstring.i @@ -0,0 +1 @@ +%include <typemaps/cstring.swg> diff --git a/contrib/tools/swig/Lib/perl5/director.swg b/contrib/tools/swig/Lib/perl5/director.swg new file mode 100644 index 00000000000..f0a6614fc5c --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/director.swg @@ -0,0 +1,317 @@ +/* ----------------------------------------------------------------------------- + * director.swg + * + * This file contains support for director classes so that Perl proxy + * methods can be called from C++. + * ----------------------------------------------------------------------------- */ + +#ifndef SWIG_DIRECTOR_PERL_HEADER_ +#define SWIG_DIRECTOR_PERL_HEADER_ + +#include <string> +#include <iostream> +#include <exception> +#include <vector> +#include <map> + + +/* + Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the + native C++ RTTI and dynamic_cast<>. But be aware that directors + could stop working when using this option. +*/ +#ifdef SWIG_DIRECTOR_NORTTI +/* + When we don't use the native C++ RTTI, we implement a minimal one + only for Directors. +*/ +# ifndef SWIG_DIRECTOR_RTDIR +# define SWIG_DIRECTOR_RTDIR + +namespace Swig { + class Director; + SWIGINTERN std::map<void *, Director *>& get_rtdir_map() { + static std::map<void *, Director *> rtdir_map; + return rtdir_map; + } + + SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) { + get_rtdir_map()[vptr] = rtdir; + } + + SWIGINTERNINLINE Director *get_rtdir(void *vptr) { + std::map<void *, Director *>::const_iterator pos = get_rtdir_map().find(vptr); + Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0; + return rtdir; + } +} +# endif /* SWIG_DIRECTOR_RTDIR */ + +# define SWIG_DIRECTOR_CAST(ARG) Swig::get_rtdir(static_cast<void *>(ARG)) +# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) Swig::set_rtdir(static_cast<void *>(ARG1), ARG2) + +#else + +# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG) +# define SWIG_DIRECTOR_RGTR(ARG1, ARG2) + +#endif /* SWIG_DIRECTOR_NORTTI */ + +extern "C" { + struct swig_type_info; +} + +namespace Swig { + + /* memory handler */ + struct GCItem { + virtual ~GCItem() {} + + virtual int get_own() const { + return 0; + } + }; + + struct GCItem_var { + GCItem_var(GCItem *item = 0) : _item(item) { + } + + GCItem_var& operator=(GCItem *item) { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() { + delete _item; + } + + GCItem *operator->() const { + return _item; + } + + private: + GCItem *_item; + }; + + struct GCItem_Object : GCItem { + GCItem_Object(int own) : _own(own) { + } + + virtual ~GCItem_Object() { + } + + int get_own() const { + return _own; + } + + private: + int _own; + }; + + template <typename Type> + struct GCItem_T : GCItem { + GCItem_T(Type *ptr) : _ptr(ptr) { + } + + virtual ~GCItem_T() { + delete _ptr; + } + + private: + Type *_ptr; + }; + + template <typename Type> + struct GCArray_T : GCItem { + GCArray_T(Type *ptr) : _ptr(ptr) { + } + + virtual ~GCArray_T() { + delete[] _ptr; + } + + private: + Type *_ptr; + }; + + /* base class for director exceptions */ + class DirectorException : public std::exception { + public: + virtual SV *getNative() const = 0; + }; + + /* exceptions emitted by Perl */ + class DirectorMethodException : public DirectorException { + protected: + SV *err; + public: + DirectorMethodException(SV *sv = sv_mortalcopy(ERRSV)) : err(sv) { + SvREFCNT_inc(err); + } + + const char *what() const throw() { + return SvPV_nolen(err); + } + + SV *getNative() const { + return sv_2mortal(newSVsv(err)); + } + + static void raise(SV *sv) { + throw DirectorMethodException(sv); + } + }; + + /* exceptions emitted by wrap code */ + class DirectorWrapException : public DirectorException { + protected: + std::string msg; + DirectorWrapException(const char *str) : msg(str) { + } + + public: + virtual ~DirectorWrapException() throw() { + } + + const char *what() const throw() { + return msg.c_str(); + } + + virtual SV *getNative() const { + return sv_2mortal(newSVpvn(msg.data(), msg.size())); + } + }; + + class DirectorTypeMismatchException : public DirectorWrapException { + public: + DirectorTypeMismatchException(const char *str) : DirectorWrapException(str) { + } + + static void raise(const char *type, const char *msg) { + std::string err = std::string(type); + err += ": "; + err += msg; + throw DirectorTypeMismatchException(err.c_str()); + } + }; + + class DirectorPureVirtualException : public DirectorWrapException { + public: + DirectorPureVirtualException(const char *name) + : DirectorWrapException("SWIG director pure virtual method called: ") { + msg += name; + } + + static void raise(const char *name) { + throw DirectorPureVirtualException(name); + } + }; + + /* director base class */ + class Director { + private: + /* pointer to the wrapped perl object */ + SV *swig_self; + /* class of wrapped perl object */ + std::string swig_class; + /* flag indicating whether the object is owned by perl or c++ */ + mutable bool swig_disown_flag; + + /* decrement the reference count of the wrapped perl object */ + void swig_decref() const { + if (swig_disown_flag) { + SvREFCNT_dec(swig_self); + } + } + + public: + /* wrap a Perl object. */ + Director(SV *pkg) : swig_disown_flag(false) { + STRLEN len; + char *str = SvPV(pkg, len); + swig_class = std::string(str, len); + swig_self = newRV_inc((SV *)newHV()); + } + + /* discard our reference at destruction */ + virtual ~Director() { + swig_decref(); + } + + /* return a pointer to the wrapped Perl object */ + SV *swig_get_self() const { + return swig_self; + } + + const char *swig_get_class() const { + return swig_class.c_str(); + } + + /* acquire ownership of the wrapped Perl object (the sense of "disown" is from perl) */ + void swig_disown() const { + if (!swig_disown_flag) { + swig_disown_flag=true; + swig_incref(); + } + } + + /* increase the reference count of the wrapped Perl object */ + void swig_incref() const { + if (swig_disown_flag) { + SvREFCNT_inc(swig_self); + } + } + + /* methods to implement pseudo protected director members */ + virtual bool swig_get_inner(const char * /* swig_protected_method_name */) const { + return true; + } + + virtual void swig_set_inner(const char * /* swig_protected_method_name */, bool /* swig_val */) const { + } + + /* ownership management */ + private: + typedef std::map<void *, GCItem_var> swig_ownership_map; + mutable swig_ownership_map swig_owner; + + public: + template <typename Type> + void swig_acquire_ownership_array(Type *vptr) const { + if (vptr) { + swig_owner[vptr] = new GCArray_T<Type>(vptr); + } + } + + template <typename Type> + void swig_acquire_ownership(Type *vptr) const { + if (vptr) { + swig_owner[vptr] = new GCItem_T<Type>(vptr); + } + } + + void swig_acquire_ownership_obj(void *vptr, int own) const { + if (vptr && own) { + swig_owner[vptr] = new GCItem_Object(own); + } + } + + int swig_release_ownership(void *vptr) const { + int own = 0; + if (vptr) { + swig_ownership_map::iterator iter = swig_owner.find(vptr); + if (iter != swig_owner.end()) { + own = iter->second->get_own(); + swig_owner.erase(iter); + } + } + return own; + } + }; + +} + +#endif + diff --git a/contrib/tools/swig/Lib/perl5/exception.i b/contrib/tools/swig/Lib/perl5/exception.i new file mode 100644 index 00000000000..b786f25e299 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/exception.i @@ -0,0 +1,5 @@ +%include <typemaps/exception.swg> + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) +} diff --git a/contrib/tools/swig/Lib/perl5/extra-install.list b/contrib/tools/swig/Lib/perl5/extra-install.list new file mode 100644 index 00000000000..db93830aabf --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/extra-install.list @@ -0,0 +1,2 @@ +# see top-level Makefile.in +Makefile.pl noembed.h diff --git a/contrib/tools/swig/Lib/perl5/factory.i b/contrib/tools/swig/Lib/perl5/factory.i new file mode 100644 index 00000000000..46a0a8733e7 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/factory.i @@ -0,0 +1 @@ +%include <typemaps/factory.swg> diff --git a/contrib/tools/swig/Lib/perl5/noembed.h b/contrib/tools/swig/Lib/perl5/noembed.h new file mode 100644 index 00000000000..4e30f1117c8 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/noembed.h @@ -0,0 +1,116 @@ +/* Workaround perl5 global namespace pollution. Note that undefining library + * functions like fopen will not solve the problem on all platforms as fopen + * might be a macro on Windows but not necessarily on other operating systems. */ +#ifdef do_open + #undef do_open +#endif +#ifdef do_close + #undef do_close +#endif +#ifdef do_exec + #undef do_exec +#endif +#ifdef scalar + #undef scalar +#endif +#ifdef list + #undef list +#endif +#ifdef apply + #undef apply +#endif +#ifdef convert + #undef convert +#endif +#ifdef Error + #undef Error +#endif +#ifdef form + #undef form +#endif +#ifdef vform + #undef vform +#endif +#ifdef LABEL + #undef LABEL +#endif +#ifdef METHOD + #undef METHOD +#endif +#ifdef Move + #undef Move +#endif +#ifdef yylex + #undef yylex +#endif +#ifdef yyparse + #undef yyparse +#endif +#ifdef yyerror + #undef yyerror +#endif +#ifdef invert + #undef invert +#endif +#ifdef ref + #undef ref +#endif +#ifdef read + #undef read +#endif +#ifdef write + #undef write +#endif +#ifdef eof + #undef eof +#endif +#ifdef close + #undef close +#endif +#ifdef rewind + #undef rewind +#endif +#ifdef free + #undef free +#endif +#ifdef malloc + #undef malloc +#endif +#ifdef calloc + #undef calloc +#endif +#ifdef Stat + #undef Stat +#endif +#ifdef check + #undef check +#endif +#ifdef seekdir + #undef seekdir +#endif +#ifdef open + #undef open +#endif +#ifdef readdir + #undef readdir +#endif +#ifdef bind + #undef bind +#endif +#ifdef access + #undef access +#endif +#ifdef stat + #undef stat +#endif +#ifdef seed + #undef seed +#endif + +#ifdef bool + /* Leave if macro is from C99 stdbool.h */ + #ifndef __bool_true_false_are_defined + #undef bool + #endif +#endif + diff --git a/contrib/tools/swig/Lib/perl5/perl5.swg b/contrib/tools/swig/Lib/perl5/perl5.swg new file mode 100644 index 00000000000..693c2b9457c --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perl5.swg @@ -0,0 +1,42 @@ +/* ------------------------------------------------------------ + * perl.swg + * + * Perl configuration module. + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Inner macros + * ------------------------------------------------------------ */ +%include <perlmacros.swg> + +/* ------------------------------------------------------------ + * The runtime part + * ------------------------------------------------------------ */ +%include <perlruntime.swg> + +/* ------------------------------------------------------------ + * Special user directives + * ------------------------------------------------------------ */ +%include <perluserdir.swg> + +/* ------------------------------------------------------------ + * Typemap specializations + * ------------------------------------------------------------ */ +%include <perltypemaps.swg> + +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ +%include <perlopers.swg> + +/* ------------------------------------------------------------ + * Warnings for Perl keywords + * ------------------------------------------------------------ */ +%include <perlkw.swg> + +/* ------------------------------------------------------------ + * The Perl initialization function + * ------------------------------------------------------------ */ +%include <perlinit.swg> + + diff --git a/contrib/tools/swig/Lib/perl5/perlerrors.swg b/contrib/tools/swig/Lib/perl5/perlerrors.swg new file mode 100644 index 00000000000..0e563b62df1 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlerrors.swg @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGINTERN const char* +SWIG_Perl_ErrorType(int code) { + switch(code) { + case SWIG_MemoryError: + return "MemoryError"; + case SWIG_IOError: + return "IOError"; + case SWIG_RuntimeError: + return "RuntimeError"; + case SWIG_IndexError: + return "IndexError"; + case SWIG_TypeError: + return "TypeError"; + case SWIG_DivisionByZero: + return "ZeroDivisionError"; + case SWIG_OverflowError: + return "OverflowError"; + case SWIG_SyntaxError: + return "SyntaxError"; + case SWIG_ValueError: + return "ValueError"; + case SWIG_SystemError: + return "SystemError"; + case SWIG_AttributeError: + return "AttributeError"; + case SWIG_NullReferenceError: + return "NullReferenceError"; + default: + return "RuntimeError"; + } +} + diff --git a/contrib/tools/swig/Lib/perl5/perlfragments.swg b/contrib/tools/swig/Lib/perl5/perlfragments.swg new file mode 100644 index 00000000000..45d25d1f6c3 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlfragments.swg @@ -0,0 +1,23 @@ +/* + + Create a file with this name, 'perlfragments.swg', in your working + directory and add all the %fragments you want to take precedence + over the ones defined by default by swig. + + For example, if you add: + + %fragment(SWIG_AsVal_frag(int),"header") { + SWIGINTERNINLINE int + SWIG_AsVal(int)(PyObject *obj, int *val) + { + <your code here>; + } + } + + this will replace the code used to retrieve an integer value for all + the typemaps that need it, including: + + int, std::vector<int>, std::list<std::pair<int,int> >, etc. + + +*/ diff --git a/contrib/tools/swig/Lib/perl5/perlhead.swg b/contrib/tools/swig/Lib/perl5/perlhead.swg new file mode 100644 index 00000000000..11ea50a9edf --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlhead.swg @@ -0,0 +1,94 @@ +#ifdef __cplusplus +/* Needed on some windows machines---since MS plays funny games with the header files under C++ */ +#include <math.h> +#include <stdlib.h> +extern "C" { +#endif + +#if __GNUC__ >= 10 +#if defined(__cplusplus) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvolatile" +#endif +#endif + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#if __GNUC__ >= 10 +#if defined(__cplusplus) +#pragma GCC diagnostic pop +#endif +#endif + +/* PERL_REVISION was added in Perl 5.6. */ +#if !defined PERL_REVISION || (PERL_REVISION-0 == 5 && PERL_VERSION-0 < 8) +# error SWIG requires Perl >= 5.8.0 +#endif + +#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE) +#define PerlIO_exportFILE(fh,fl) (FILE*)(fh) +#endif + +#ifndef SvIOK_UV +# define SvIOK_UV(sv) (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv))) +#endif + +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + +#ifndef IVSIZE +# ifdef LONGSIZE +# define IVSIZE LONGSIZE +# else +# define IVSIZE 4 /* A bold guess, but the best we can make. */ +# endif +#endif + +#ifndef INT2PTR +# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) +# define PTRV UV +# define INT2PTR(any,d) (any)(d) +# else +# if PTRSIZE == LONGSIZE +# define PTRV unsigned long +# else +# define PTRV unsigned +# endif +# define INT2PTR(any,d) (any)(PTRV)(d) +# endif + +# define NUM2PTR(any,d) (any)(PTRV)(d) +# define PTR2IV(p) INT2PTR(IV,p) +# define PTR2UV(p) INT2PTR(UV,p) +# define PTR2NV(p) NUM2PTR(NV,p) + +# if PTRSIZE == LONGSIZE +# define PTR2ul(p) (unsigned long)(p) +# else +# define PTR2ul(p) INT2PTR(unsigned long,p) +# endif +#endif /* !INT2PTR */ + +#ifndef SvPV_nolen +# define SvPV_nolen(x) SvPV(x,PL_na) +#endif + +#ifndef get_sv +# define get_sv perl_get_sv +#endif + +#ifndef ERRSV +# define ERRSV get_sv("@",FALSE) +#endif + +#ifndef pTHX_ +#define pTHX_ +#endif + +#include <string.h> +#ifdef __cplusplus +} +#endif diff --git a/contrib/tools/swig/Lib/perl5/perlinit.swg b/contrib/tools/swig/Lib/perl5/perlinit.swg new file mode 100644 index 00000000000..c26b93fadb9 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlinit.swg @@ -0,0 +1,78 @@ + +/* Export the SWIG initialization function */ +%header %{ +#ifdef __cplusplus +extern "C" +#endif +#ifndef MULTIPLICITY +SWIGEXPORT void SWIG_init (CV* cv); +#else +SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); +#endif +%} + +/* Module initialization function */ + +%insert(init) "swiginit.swg" + +%init %{ + +#if defined(__cplusplus) && ! defined(XSPROTO) +extern "C" +#endif + +XS(SWIG_init) { + dXSARGS; + int i; + (void)items; + + SWIG_InitializeModule(0); + + /* Install commands */ + for (i = 0; swig_commands[i].name; i++) { + /* Casts only needed for Perl < 5.10. */ +#ifdef __cplusplus + newXS(const_cast<char*>(swig_commands[i].name), swig_commands[i].wrapper, const_cast<char*>(__FILE__)); +#else + newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__); +#endif + } + + /* Install variables */ + for (i = 0; swig_variables[i].name; i++) { + SV *sv; + sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); + if (swig_variables[i].type) { + SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); + } else { + sv_setiv(sv,(IV) 0); + } + swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + } + + /* Install constant */ + for (i = 0; swig_constants[i].type; i++) { + SV *sv; + sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); + switch(swig_constants[i].type) { + case SWIG_INT: + sv_setiv(sv, (IV) swig_constants[i].lvalue); + break; + case SWIG_FLOAT: + sv_setnv(sv, (double) swig_constants[i].dvalue); + break; + case SWIG_STRING: + sv_setpv(sv, (const char *) swig_constants[i].pvalue); + break; + case SWIG_POINTER: + SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); + break; + case SWIG_BINARY: + SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); + break; + default: + break; + } + SvREADONLY_on(sv); + } +%} diff --git a/contrib/tools/swig/Lib/perl5/perlkw.swg b/contrib/tools/swig/Lib/perl5/perlkw.swg new file mode 100644 index 00000000000..00648e0bf38 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlkw.swg @@ -0,0 +1,251 @@ +/* Warnings for Perl keywords */ +#define PERLKW(x) %keywordwarn("'" `x` "' is a perl keyword") `x` +#define PERLBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in perl") "::" `x` + + +/* + + From http://www.rocketaware.com/perl/perlfunc/ + +*/ + +/* Functions for SCALARs or strings*/ +PERLBN(chomp); +PERLBN(chop); +PERLBN(chr); +PERLBN(crypt); +PERLBN(hex); +PERLBN(index); +PERLBN(lc); +PERLBN(lcfirst); +PERLBN(length); +PERLBN(oct); +PERLBN(ord); +PERLBN(pack); +PERLBN(reverse); +PERLBN(rindex); +PERLBN(sprintf); +PERLBN(substr); +PERLBN(uc); +PERLBN(ucfirst); + +/* Regular expressions and pattern matching */ +PERLBN(m); +PERLBN(pos); +PERLBN(quotemeta); +PERLBN(split); +PERLBN(study); + +/* Numeric functions */ +PERLBN(abs); +PERLBN(atan2); +PERLBN(cos); +PERLBN(exp); +PERLBN(hex); +PERLBN(int); +PERLBN(log); +PERLBN(oct); +PERLBN(rand); +PERLBN(sin); +PERLBN(sqrt); +PERLBN(srand); + + +/* Functions for real @ARRAYs*/ +PERLBN(pop); +PERLBN(push); +PERLBN(shift); +PERLBN(splice); +PERLBN(unshift); + +/* Functions for list data*/ +PERLBN(grep); +PERLBN(join); +PERLBN(map); +PERLBN(qw); +PERLBN(reverse); +PERLBN(sort); +PERLBN(unpack); + + +/* Functions for real %HASHes*/ +PERLBN(delete); +PERLBN(each); +PERLBN(exists); +PERLBN(keys); +PERLBN(values); + + +/* Input and output functions*/ + +PERLBN(binmode); +PERLBN(close); +PERLBN(closedir); +PERLBN(dbmclose); +PERLBN(dbmopen); +PERLBN(die); +PERLBN(eof); +PERLBN(fileno); +PERLBN(flock); +PERLBN(format); +PERLBN(getc); +PERLBN(print); +PERLBN(printf); +PERLBN(read); +PERLBN(readdir); +PERLBN(rewinddir); +PERLBN(seek); +PERLBN(seekdir); +PERLBN(select); +PERLBN(syscall); +PERLBN(sysread); +PERLBN(sysseek); +PERLBN(syswrite); +PERLBN(tell); +PERLBN(telldir); +PERLBN(truncate); +PERLBN(warn); +PERLBN(write); + + +/* Functions for fixed length data or records*/ +PERLBN(pack); +PERLBN(read); +PERLBN(syscall); +PERLBN(sysread); +PERLBN(syswrite); +PERLBN(unpack); +PERLBN(vec); + + +/* Functions for filehandles, files, or directories */ +PERLBN(chdir); +PERLBN(chmod); +PERLBN(chown); +PERLBN(chroot); +PERLBN(fcntl); +PERLBN(glob); +PERLBN(ioctl); +PERLBN(link); +PERLBN(lstat); +PERLBN(mkdir); +PERLBN(open); +PERLBN(opendir); +PERLBN(readlink); +PERLBN(rename); +PERLBN(rmdir); +PERLBN(stat); +PERLBN(symlink); +PERLBN(umask); +PERLBN(unlink); +PERLBN(utime); + + +/* Keywords related to the control flow of your perl program */ +PERLKW(caller); +PERLKW(continue); +PERLKW(die); +PERLKW(do); +PERLKW(dump); +PERLKW(eval); +PERLKW(exit); +PERLKW(goto); +PERLKW(last); +PERLKW(next); +PERLKW(redo); +PERLKW(return); +PERLKW(sub); +PERLKW(wantarray); + + +/* Keywords related to scoping */ +PERLKW(caller); +PERLKW(import); +PERLKW(local); +PERLKW(my); +PERLKW(package); +PERLKW(use); + + +/* Miscellaneous functions */ +PERLBN("defined"); +PERLBN(dump); +PERLBN(eval); +PERLBN(formline); +PERLBN(local); +PERLBN(my); +PERLBN(reset); +PERLBN(scalar); +PERLBN(undef); +PERLBN(wantarray); + + +/* Functions for processes and process groups */ +PERLBN(alarm); +PERLBN(exec); +PERLBN(fork); +PERLBN(getpgrp); +PERLBN(getppid); +PERLBN(getpriority); +PERLBN(kill); +PERLBN(pipe); +PERLBN(setpgrp); +PERLBN(setpriority); +PERLBN(sleep); +PERLBN(system); +PERLBN(times); +PERLBN(wait); +PERLBN(waitpid); + + +/* Keywords related to perl modules */ +PERLKW(do); +PERLKW(import); +PERLKW(no); +PERLKW(package); +PERLKW(require); +PERLKW(use); + + +/* Keywords related to classes and object-orientedness */ +PERLKW(bless); +PERLKW(dbmclose); +PERLKW(dbmopen); +PERLKW(package); +PERLKW(ref); +PERLKW(tie); +PERLKW(tied); +PERLKW(untie); +PERLKW(use); + +/* Functions new in perl5 */ +PERLBN(abs); +PERLBN(bless); +PERLBN(chomp); +PERLBN(chr); +PERLBN(exists); +PERLBN(formline); +PERLBN(glob); +PERLBN(import); +PERLBN(lc); +PERLBN(lcfirst); +PERLBN(map); +PERLBN(my); +PERLBN(no); +PERLBN(prototype); +PERLBN(qx); +PERLBN(qw); +PERLBN(readline); +PERLBN(readpipe); +PERLBN(ref); +PERLBN(sub); +PERLBN(sysopen); +PERLBN(tie); +PERLBN(tied); +PERLBN(uc); +PERLBN(ucfirst); +PERLBN(untie); +PERLBN(use); + +#undef PERLKW +#undef PERLBN diff --git a/contrib/tools/swig/Lib/perl5/perlmacros.swg b/contrib/tools/swig/Lib/perl5/perlmacros.swg new file mode 100644 index 00000000000..4917f6efc59 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlmacros.swg @@ -0,0 +1,2 @@ +%include <typemaps/swigmacros.swg> + diff --git a/contrib/tools/swig/Lib/perl5/perlmain.i b/contrib/tools/swig/Lib/perl5/perlmain.i new file mode 100644 index 00000000000..14f1cf2191a --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlmain.i @@ -0,0 +1,77 @@ +/* ----------------------------------------------------------------------------- + * perlmain.i + * + * Code to statically rebuild perl5. + * ----------------------------------------------------------------------------- */ + +// This module provides support for building a new version of the +// Perl executable. This will be necessary on systems that do +// not support shared libraries and may be necessary with C++ +// extensions. +// +// This module may only build a stripped down version of the +// Perl executable. Thus, it may be necessary (or desirable) +// to hand-edit this file for your particular application. To +// do this, simply copy this file from swig_lib/perl5/perlmain.i +// to your working directory and make the appropriate modifications. +// +// This library file works with Perl 5.003. It may work with earlier +// versions, but it hasn't been tested. As far as I know, this +// library is C++ safe. + +%{ + +static void xs_init _((pTHX)); +static PerlInterpreter *my_perl; + +int perl_eval(char *string) { + char *argv[2]; + argv[0] = string; + argv[1] = (char *) 0; + return perl_call_argv("eval",0,argv); +} + +int +main(int argc, char **argv, char **env) +{ + int exitstatus; + + my_perl = perl_alloc(); + if (!my_perl) + exit(1); + perl_construct( my_perl ); + + exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL ); + if (exitstatus) + exit( exitstatus ); + + /* Initialize all of the module variables */ + + exitstatus = perl_run( my_perl ); + + perl_destruct( my_perl ); + perl_free( my_perl ); + + exit( exitstatus ); +} + +/* Register any extra external extensions */ + +/* Do not delete this line--writemain depends on it */ +/* EXTERN_C void boot_DynaLoader _((CV* cv)); */ + +static void +xs_init(pTHX) +{ +/* dXSUB_SYS; */ + char *file = __FILE__; + { + /* newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */ + newXS(SWIG_name, SWIG_init, file); +#ifdef SWIGMODINIT + SWIGMODINIT +#endif + } +} + +%} diff --git a/contrib/tools/swig/Lib/perl5/perlopers.swg b/contrib/tools/swig/Lib/perl5/perlopers.swg new file mode 100644 index 00000000000..e7d13b678ad --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlopers.swg @@ -0,0 +1,54 @@ +/* ------------------------------------------------------------ + * Overloaded operator support + * ------------------------------------------------------------ */ + +#ifdef __cplusplus + +// These are auto-supported by the Perl-module +%rename(__plusplus__) *::operator++; +%rename(__minmin__) *::operator--; +%rename(__add__) *::operator+; +%rename(__sub__) *::operator-; +%rename(__neg__) *::operator-(); +%rename(__neg__) *::operator-() const; +%rename(__mul__) *::operator*; +%rename(__div__) *::operator/; +%rename(__eq__) *::operator==; +%rename(__ne__) *::operator!=; +%rename(__mod__) *::operator%; +%rename(__gt__) *::operator>; +%rename(__lt__) *::operator<; +%rename(__not__) *::operator!; +%rename(__le__) *::operator<=; +%rename(__ge__) *::operator>=; +%rename(__and__) *::operator&; +%rename(__or__) *::operator|; +%rename(__iadd__) *::operator+=; +%rename(__isub__) *::operator-=; + +// These are renamed, but no test exists in operator_overload_runme.pl +%ignoreoperator(EQ) operator=; + +// These are renamed, but no 'use overload...' is added +%rename(__lshift__) *::operator<<; +%rename(__rshift__) *::operator>>; +%rename(__xor__) *::operator^; +%rename(__invert__) *::operator~; +%rename(__call__) *::operator(); + +/* Ignored operators */ +%ignoreoperator(LAND) operator&&; +%ignoreoperator(LOR) operator||; +%ignoreoperator(MULEQ) operator*=; +%ignoreoperator(DIVEQ) operator/=; +%ignoreoperator(MODEQ) operator%=; +%ignoreoperator(LSHIFTEQ) operator<<=; +%ignoreoperator(RSHIFTEQ) operator>>=; +%ignoreoperator(ANDEQ) operator&=; +%ignoreoperator(OREQ) operator|=; +%ignoreoperator(XOREQ) operator^=; +%ignoreoperator(ARROWSTAR) operator->*; +%ignoreoperator(INDEX) operator[]; + + +#endif /* __cplusplus */ diff --git a/contrib/tools/swig/Lib/perl5/perlprimtypes.swg b/contrib/tools/swig/Lib/perl5/perlprimtypes.swg new file mode 100644 index 00000000000..57f390a2549 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlprimtypes.swg @@ -0,0 +1,364 @@ +/* ------------------------------------------------------------ + * Primitive Types + * ------------------------------------------------------------ */ + +/* bool */ + +%fragment(SWIG_From_frag(bool),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(bool)(bool value) +{ + return boolSV(value); +} +} + +%fragment(SWIG_AsVal_frag(bool),"header") { +SWIGINTERN int +SWIG_AsVal_dec(bool)(SV *obj, bool* val) +{ + if (obj == &PL_sv_yes) { + if (val) *val = true; + return SWIG_OK; + } else if (obj == &PL_sv_no) { + if (val) *val = false; + return SWIG_OK; + } else { + if (val) *val = SvTRUE(obj) ? true : false; + return SWIG_AddCast(SWIG_OK); + } +} +} + + +/* long */ + +%fragment(SWIG_From_frag(long),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(long)(long value) +{ + SV *sv; + if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX)) + sv = newSViv(value); + else + sv = newSVpvf("%ld", value); + return sv_2mortal(sv); +} +} + +%fragment(SWIG_AsVal_frag(long),"header", + fragment="<limits.h>", + fragment="<stdlib.h>", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(long)(SV *obj, long* val) +{ + if (SvUOK(obj)) { + UV v = SvUV(obj); + if (UVSIZE < sizeof(*val) || v <= LONG_MAX) { + if (val) *val = v; + return SWIG_OK; + } + return SWIG_OverflowError; + } else if (SvIOK(obj)) { + IV v = SvIV(obj); + if (IVSIZE <= sizeof(*val) || (v >= LONG_MIN && v <= LONG_MAX)) { + if(val) *val = v; + return SWIG_OK; + } + return SWIG_OverflowError; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + long v; + errno = 0; + v = strtol(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +} + +/* unsigned long */ + +%fragment(SWIG_From_frag(unsigned long),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(unsigned long)(unsigned long value) +{ + SV *sv; + if (UVSIZE >= sizeof(value) || value <= UV_MAX) + sv = newSVuv(value); + else + sv = newSVpvf("%lu", value); + return sv_2mortal(sv); +} +} + +%fragment(SWIG_AsVal_frag(unsigned long),"header", + fragment="<limits.h>", + fragment="<stdlib.h>", + fragment="SWIG_CanCastAsInteger") { +SWIGINTERN int +SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) +{ + if (SvUOK(obj)) { + UV v = SvUV(obj); + if (UVSIZE <= sizeof(*val) || v <= ULONG_MAX) { + if (val) *val = v; + return SWIG_OK; + } + return SWIG_OverflowError; + } else if (SvIOK(obj)) { + IV v = SvIV(obj); + if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULONG_MAX)) { + if (val) *val = v; + return SWIG_OK; + } + return SWIG_OverflowError; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + unsigned long v; + errno = 0; + v = strtoul(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +} + +/* long long */ + +%fragment(SWIG_From_frag(long long),"header", + fragment="SWIG_LongLongAvailable", + fragment="<stdio.h>") { +%#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE SV * +SWIG_From_dec(long long)(long long value) +{ + SV *sv; + if (IVSIZE >= sizeof(value) || (value >= IV_MIN && value <= IV_MAX)) + sv = newSViv((IV)(value)); + else { + //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl + char temp[256]; + SWIG_snprintf(temp, sizeof(temp), "%lld", value); + sv = newSVpv(temp, 0); + } + return sv_2mortal(sv); +} +%#endif +} + +%fragment(SWIG_AsVal_frag(long long),"header", + fragment="SWIG_LongLongAvailable", + fragment="<stdlib.h>", + fragment="SWIG_CanCastAsInteger") { +%#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_dec(long long)(SV *obj, long long *val) +{ + if (SvUOK(obj)) { + UV v = SvUV(obj); + /* pretty sure this could allow v == LLONG MAX */ + if (UVSIZE < sizeof(*val) || v < LLONG_MAX) { + if (val) *val = v; + return SWIG_OK; + } + return SWIG_OverflowError; + } else if (SvIOK(obj)) { + IV v = SvIV(obj); + if (IVSIZE <= sizeof(*val) || (v >= LLONG_MIN && v <= LLONG_MAX)) { + if (val) *val = v; + return SWIG_OK; + } + return SWIG_OverflowError; + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + long long v; + errno = 0; + v = strtoll(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + const double mant_max = 1LL << DBL_MANT_DIG; + const double mant_min = -mant_max; + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { + if (val) *val = (long long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +%#endif +} + +/* unsigned long long */ + +%fragment(SWIG_From_frag(unsigned long long),"header", + fragment="SWIG_LongLongAvailable", + fragment="<stdio.h>") { +%#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERNINLINE SV * +SWIG_From_dec(unsigned long long)(unsigned long long value) +{ + SV *sv; + if (UVSIZE >= sizeof(value) || value <= UV_MAX) + sv = newSVuv((UV)(value)); + else { + //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl + char temp[256]; + SWIG_snprintf(temp, sizeof(temp), "%llu", value); + sv = newSVpv(temp, 0); + } + return sv_2mortal(sv); +} +%#endif +} + +%fragment(SWIG_AsVal_frag(unsigned long long),"header", + fragment="SWIG_LongLongAvailable", + fragment="<stdlib.h>", + fragment="SWIG_CanCastAsInteger") { +%#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val) +{ + if (SvUOK(obj)) { + /* pretty sure this should be conditional on + * (UVSIZE <= sizeof(*val) || v <= ULLONG_MAX) */ + if (val) *val = SvUV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + IV v = SvIV(obj); + if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULLONG_MAX)) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + unsigned long long v; + errno = 0; + v = strtoull(nptr, &endptr,0); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + if (!dispatch) { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return res; + } + } + } + return SWIG_TypeError; +} +%#endif +} + +/* double */ + +%fragment(SWIG_From_frag(double),"header") { +SWIGINTERNINLINE SV * +SWIG_From_dec(double)(double value) +{ + return sv_2mortal(newSVnv(value)); +} +} + +%fragment(SWIG_AsVal_frag(double),"header") { +SWIGINTERN int +SWIG_AsVal_dec(double)(SV *obj, double *val) +{ + if (SvNIOK(obj)) { + if (val) *val = SvNV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { + if (val) *val = (double) SvIV(obj); + return SWIG_AddCast(SWIG_OK); + } else { + const char *nptr = SvPV_nolen(obj); + if (nptr) { + char *endptr; + double v; + errno = 0; + v = strtod(nptr, &endptr); + if (errno == ERANGE) { + errno = 0; + return SWIG_OverflowError; + } else { + if (*endptr == '\0') { + if (val) *val = v; + return SWIG_Str2NumCast(SWIG_OK); + } + } + } + } + return SWIG_TypeError; +} +} diff --git a/contrib/tools/swig/Lib/perl5/perlrun.swg b/contrib/tools/swig/Lib/perl5/perlrun.swg new file mode 100644 index 00000000000..dfb2c8ee2d8 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlrun.swg @@ -0,0 +1,493 @@ +/* ----------------------------------------------------------------------------- + * perlrun.swg + * + * This file contains the runtime support for Perl modules + * and includes code for managing global variables and pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +#define SWIG_PERL_OBJECT_DECL +#define SWIG_PERL_OBJECT_CALL + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own) +#define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) +#define SWIG_AcquirePtr(ptr, src) SWIG_Perl_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) +#define SWIG_NewPackedObj(p, s, type) SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) + + +/* Error manipulation */ + +#define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) +#define SWIG_Error(code, msg) sv_setpvf(get_sv("@", GV_ADD), "%s %s", SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + +/* Perl-specific SWIG API */ + +#define SWIG_MakePtr(sv, ptr, type, flags) SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags) +#define SWIG_MakePackedObj(sv, p, s, type) SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type) +#define SWIG_SetError(str) SWIG_Error(SWIG_RuntimeError, str) + + +#define SWIG_PERL_DECL_ARGS_1(arg1) (SWIG_PERL_OBJECT_DECL arg1) +#define SWIG_PERL_CALL_ARGS_1(arg1) (SWIG_PERL_OBJECT_CALL arg1) +#define SWIG_PERL_DECL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_DECL arg1, arg2) +#define SWIG_PERL_CALL_ARGS_2(arg1, arg2) (SWIG_PERL_OBJECT_CALL arg1, arg2) + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +/* For backward compatibility only */ +#define SWIG_POINTER_EXCEPTION 0 + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWIG_OWNER SWIG_POINTER_OWN +#define SWIG_SHADOW SWIG_OWNER << 1 + +#define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL + +/* SWIG Perl macros */ + +/* Macro to declare an XS function */ +#ifndef XSPROTO +# define XSPROTO(name) void name(pTHX_ CV* cv) +#endif + +/* Macro to call an XS function */ +#ifndef MULTIPLICITY +# define SWIG_CALLXS(_name) _name(cv) +#else +# define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) +#endif + +#define MAGIC_PPERL +#define SWIGCLASS_STATIC static SWIGUNUSED + +#ifndef MULTIPLICITY +#define SWIG_MAGIC(a,b) (SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#else /* MULTIPLICITY */ + +#define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b) + +#ifdef __cplusplus +extern "C" { +#endif +typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); +#ifdef __cplusplus +} +#endif + +#endif /* MULTIPLICITY */ + +static void SWIGUNUSED SWIG_croak_null() +{ + SV *err = get_sv("@", GV_ADD); + if (sv_isobject(err)) + croak(0); + else + croak("%s", SvPV_nolen(err)); +} + + +/* + Define how strict is the cast between strings and integers/doubles + when overloading between these types occurs. + + The default is making it as strict as possible by using SWIG_AddCast + when needed. + + You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to + disable the SWIG_AddCast, making the casting between string and + numbers less strict. + + In the end, we try to solve the overloading between strings and + numerical types in the more natural way, but if you can avoid it, + well, avoid it using %rename, for example. +*/ +#ifndef SWIG_PERL_NO_STRICT_STR2NUM +# ifndef SWIG_PERL_STRICT_STR2NUM +# define SWIG_PERL_STRICT_STR2NUM +# endif +#endif +#ifdef SWIG_PERL_STRICT_STR2NUM +/* string takes precedence */ +#define SWIG_Str2NumCast(x) SWIG_AddCast(x) +#else +/* number takes precedence */ +#define SWIG_Str2NumCast(x) x +#endif + + + +#include <stdlib.h> + +SWIGRUNTIME const char * +SWIG_Perl_TypeProxyName(const swig_type_info *type) { + if (!type) return NULL; + if (type->clientdata != NULL) { + return (const char*) type->clientdata; + } + else { + return type->name; + } +} + +/* Identical to SWIG_TypeCheck, except for strcmp comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(SWIG_Perl_TypeProxyName(iter->type), c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_AcquirePtr(SWIG_MAYBE_PERL_OBJECT SV *SWIGUNUSEDPARM(sv), int SWIGUNUSEDPARM(own)) { + /* TODO */ + return 0; +} + +/* Function for getting a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) { + swig_cast_info *tc; + void *voidptr = (void *)0; + SV *tsv = 0; + int check_owned_pointer_release = (flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE; + + if (own) + *own = 0; + + /* If magical, apply more magic */ + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + IV tmp = 0; + tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + sv = mg->mg_obj; + if (sv_isobject(sv)) { + tsv = (SV*)SvRV(sv); + tmp = SvIV(tsv); + } + } + } else { + return SWIG_ERROR; + } + } else { + tmp = SvIV(tsv); + } + voidptr = INT2PTR(void *,tmp); + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + if (!SvROK(sv)) { + /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value. */ + if (SvIOK(sv)) { + return SWIG_ERROR; + } else { + /* NULL pointer (reference to undef). */ + *(ptr) = (void *) 0; + return SWIG_OK; + } + } else { + return SWIG_ERROR; + } + } else { /* Don't know what it is */ + return SWIG_ERROR; + } + if (_t) { + /* Now see if the types match */ + char *_c = HvNAME(SvSTASH(SvRV(sv))); + tc = SWIG_TypeProxyCheck(_c,_t); +#ifdef SWIG_DIRECTORS + if (!tc && !sv_derived_from(sv,SWIG_Perl_TypeProxyName(_t))) { +#else + if (!tc) { +#endif + return SWIG_ERROR; + } + { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + } else { + *ptr = voidptr; + } + + /* + * DISOWN implementation: we need a perl guru to check this one. + */ + if (tsv && ((flags & SWIG_POINTER_DISOWN) || check_owned_pointer_release)) { + /* + * almost copy paste code from below SWIG_POINTER_OWN setting + */ + SV *obj = sv; + HV *stash = SvSTASH(SvRV(obj)); + GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + int owned = 0; + if (isGV(gv)) { + HV *hv = GvHVn(gv); + /* + * To set ownership (see below), a newSViv(1) entry is added. + * Hence, to remove ownership, we delete the entry. + */ + if (hv_exists_ent(hv, obj, 0)) { + owned = 1; + if (flags & SWIG_POINTER_DISOWN) { + hv_delete_ent(hv, obj, 0, 0); + } + } + } + if (check_owned_pointer_release && !owned) { + return SWIG_ERROR_RELEASE_NOT_OWNED; + } + } + + if (tsv && (flags & SWIG_POINTER_CLEAR)) { + SvIV_set(tsv, 0); + } + + return SWIG_OK; +} + +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0); +} + +SWIGRUNTIME void +SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { + if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) { + SV *self; + SV *obj=newSV(0); + HV *hash=newHV(); + HV *stash; + sv_setref_pv(obj, SWIG_Perl_TypeProxyName(t), ptr); + stash=SvSTASH(SvRV(obj)); + if (flags & SWIG_POINTER_OWN) { + HV *hv; + GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + if (!isGV(gv)) + gv_init(gv, stash, "OWNER", 5, FALSE); + hv=GvHVn(gv); + hv_store_ent(hv, obj, newSViv(1), 0); + } + sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0); + SvREFCNT_dec(obj); + self=newRV_noinc((SV *)hash); + sv_setsv(sv, self); + SvREFCNT_dec((SV *)self); + sv_bless(sv, stash); + } + else { + sv_setref_pv(sv, SWIG_Perl_TypeProxyName(t), ptr); + } +} + +SWIGRUNTIMEINLINE SV * +SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) { + SV *result = sv_newmortal(); + SWIG_MakePtr(result, ptr, t, flags); + return result; +} + +SWIGRUNTIME void +SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) { + char result[1024]; + char *r = result; + if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + strcpy(r,SWIG_Perl_TypeProxyName(type)); + sv_setpv(sv, result); +} + +SWIGRUNTIME SV * +SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) { + SV *result = sv_newmortal(); + SWIG_Perl_MakePackedObj(result, ptr, sz, type); + return result; +} + +/* Convert a packed pointer value */ +SWIGRUNTIME int +SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { + swig_cast_info *tc; + const char *c = 0; + + if ((!obj) || (!SvOK(obj))) return SWIG_ERROR; + c = SvPV_nolen(obj); + /* Pointer values must start with leading underscore */ + if (*c != '_') return SWIG_ERROR; + c++; + c = SWIG_UnpackData(c,ptr,sz); + if (ty) { + tc = SWIG_TypeCheck(c,ty); + if (!tc) return SWIG_ERROR; + } + return SWIG_OK; +} + + +/* Macros for low-level exception handling */ +#define SWIG_croak(x) { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; } + + +typedef XSPROTO(SwigPerlWrapper); +typedef SwigPerlWrapper *SwigPerlWrapperPtr; + +/* Structure for command table */ +typedef struct { + const char *name; + SwigPerlWrapperPtr wrapper; +} swig_command_info; + +/* Information for constant table */ + +#define SWIG_INT 1 +#define SWIG_FLOAT 2 +#define SWIG_STRING 3 +#define SWIG_POINTER 4 +#define SWIG_BINARY 5 + +/* Constant information structure */ +typedef struct swig_constant_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_constant_info; + + +/* Structure for variable table */ +typedef struct { + const char *name; + SwigMagicFunc set; + SwigMagicFunc get; + swig_type_info **type; +} swig_variable_info; + +/* Magic variable code */ +#ifdef __cplusplus +# define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast<char*>(a),b,c) +#else +# define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c) +#endif +#ifndef MULTIPLICITY +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) +#else +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) +#endif +{ + MAGIC *mg; + sv_magic(sv,sv,'U',name,(I32)strlen(name)); + mg = mg_find(sv,'U'); + mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); + mg->mg_virtual->svt_get = (SwigMagicFunc) get; + mg->mg_virtual->svt_set = (SwigMagicFunc) set; + mg->mg_virtual->svt_len = 0; + mg->mg_virtual->svt_clear = 0; + mg->mg_virtual->svt_free = 0; +} + + +SWIGRUNTIME swig_module_info * +SWIG_Perl_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + SV *pointer; + + /* first check if pointer already created */ + if (!type_pointer) { + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI); + if (pointer && SvOK(pointer)) { + type_pointer = INT2PTR(swig_type_info **, SvIV(pointer)); + } + } + + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Perl_SetModule(swig_module_info *module) { + SV *pointer; + + /* create a new pointer */ + pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI); + sv_setiv(pointer, PTR2IV(module)); +} + +#ifdef __cplusplus +} +#endif diff --git a/contrib/tools/swig/Lib/perl5/perlruntime.swg b/contrib/tools/swig/Lib/perl5/perlruntime.swg new file mode 100644 index 00000000000..f948023de7a --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlruntime.swg @@ -0,0 +1,8 @@ + +%runtime "swigrun.swg" // Common C API type-checking code +%runtime "swigerrors.swg" // SWIG errors +%runtime "perlhead.swg" // Perl includes and fixes +%runtime "perlerrors.swg" // Perl errors +%runtime "perlrun.swg" // Perl runtime functions +%runtime "noembed.h" // undefine Perl5 macros + diff --git a/contrib/tools/swig/Lib/perl5/perlstrings.swg b/contrib/tools/swig/Lib/perl5/perlstrings.swg new file mode 100644 index 00000000000..d21b75afbb2 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perlstrings.swg @@ -0,0 +1,59 @@ +/* ------------------------------------------------------------ + * utility methods for char strings + * ------------------------------------------------------------ */ + +%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { +SWIGINTERN int +SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +{ + if (SvMAGICAL(obj)) { + SV *tmp = sv_newmortal(); + SvSetSV(tmp, obj); + obj = tmp; + } + if (SvPOK(obj)) { + STRLEN len = 0; + char *cstr = SvPV(obj, len); + size_t size = len + 1; + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = %new_copy_array(cstr, size, char); + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } + } + if (psize) *psize = size; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + char* vptr = 0; + if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = vptr; + if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} +} + +%fragment("SWIG_FromCharPtrAndSize","header") { +SWIGINTERNINLINE SV * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + SV *obj = sv_newmortal(); + if (carray) { + sv_setpvn(obj, carray, size); + } else { + sv_setsv(obj, &PL_sv_undef); + } + return obj; +} +} + diff --git a/contrib/tools/swig/Lib/perl5/perltypemaps.swg b/contrib/tools/swig/Lib/perl5/perltypemaps.swg new file mode 100644 index 00000000000..42f8887befd --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perltypemaps.swg @@ -0,0 +1,104 @@ +/* ------------------------------------------------------------ + * Typemap specializations for Perl + * ------------------------------------------------------------ */ + +/* ------------------------------------------------------------ + * Fragment section + * ------------------------------------------------------------ */ + +/* + in Perl we need to pass the CPerlObj value, sometimes, so, we define + the decl/call macros as needed. +*/ + +#define SWIG_AS_DECL_ARGS SWIG_PERL_DECL_ARGS_2 +#define SWIG_AS_CALL_ARGS SWIG_PERL_CALL_ARGS_2 + +#define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1 +#define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1 + + +/* Include fundamental fragment definitions */ +%include <typemaps/fragments.swg> + +/* Look for user fragments file. */ +%include <perlfragments.swg> + +/* Perl fragments for primitive types */ +%include <perlprimtypes.swg> + +/* Perl fragments for char* strings */ +%include <perlstrings.swg> + + +/* ------------------------------------------------------------ + * Unified typemap section + * ------------------------------------------------------------ */ + +/* director support in Perl is experimental */ +#ifndef SWIG_DIRECTOR_TYPEMAPS +#define SWIG_DIRECTOR_TYPEMAPS +#endif + + +/* Perl types */ +#define SWIG_Object SV * +#define VOID_Object &PL_sv_undef + +/* Perl $shadow flag */ +#define %newpointer_flags $shadow +#define %newinstance_flags $shadow + + +/* Complete overload of the output/constant/exception macros */ + +/* output */ +%define %set_output(obj) $result = obj; argvi++ %enddef + +/* append output */ +%define %append_output(obj) +if (argvi >= items) EXTEND(sp, argvi+1); +%set_output(obj) %enddef + +/* variable output */ +%define %set_varoutput(obj) sv_setsv($result,obj) %enddef + +/* constant */ +%define %set_constant(name, obj) %begin_block + SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2 | GV_ADDMULTI); + sv_setsv(sv, obj); + SvREADONLY_on(sv); +%end_block %enddef + +/* raise exception */ +%define %raise(obj, type, desc) sv_setsv(get_sv("@", GV_ADD), obj); SWIG_fail %enddef + +/* For directors to raise/throw the original exception */ +%typemap(throws) Swig::DirectorException +%{ sv_setsv(ERRSV, $1.getNative()); SWIG_fail; %} + +/* Include the unified typemap library */ +%include <typemaps/swigtypemaps.swg> + +/* ------------------------------------------------------------ + * Perl extra typemaps / typemap overrides + * ------------------------------------------------------------ */ + +%typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE [] + "sv_setiv(SvRV($result),PTR2IV($1));"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE & + "sv_setiv(SvRV($result),PTR2IV(&$1));"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE && + "sv_setiv(SvRV($result),PTR2IV(&$1));"; + +%typemap(varout,type="$&1_descriptor") SWIGTYPE + "sv_setiv(SvRV($result), PTR2IV(&$1));"; + +%typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) { + SWIG_MakePackedObj($result, (void *) &$1, sizeof($1), $1_descriptor); +} + +%typemap(varout) SWIGTYPE *const = SWIGTYPE *; + diff --git a/contrib/tools/swig/Lib/perl5/perluserdir.swg b/contrib/tools/swig/Lib/perl5/perluserdir.swg new file mode 100644 index 00000000000..718440e8372 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/perluserdir.swg @@ -0,0 +1,2 @@ +#define %perlcode %insert("perl") + diff --git a/contrib/tools/swig/Lib/perl5/reference.i b/contrib/tools/swig/Lib/perl5/reference.i new file mode 100644 index 00000000000..b424c533b1b --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/reference.i @@ -0,0 +1,261 @@ +/* ----------------------------------------------------------------------------- + * reference.i + * + * Accept Perl references as pointers + * ----------------------------------------------------------------------------- */ + +/* +The following methods make Perl references work like simple C +pointers. References can only be used for simple input/output +values, not C arrays however. It should also be noted that +REFERENCES are specific to Perl and not supported in other +scripting languages at this time. + + int *REFERENCE + short *REFERENCE + long *REFERENCE + unsigned int *REFERENCE + unsigned short *REFERENCE + unsigned long *REFERENCE + unsigned char *REFERENCE + float *REFERENCE + double *REFERENCE + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include reference.i + void neg(double *REFERENCE); + +or you can use the %apply directive : + + %include reference.i + %apply double *REFERENCE { double *x }; + void neg(double *x); + +Unlike the INOUT mapping described in typemaps.i, this approach directly +modifies the value of a Perl reference. Thus, you could use it +as follows : + + $x = 3; + neg(\$x); + print "$x\n"; # Should print out -3. + +*/ + +%typemap(in) double *REFERENCE (double dvalue), double &REFERENCE(double dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { + printf("Received %d\n", SvTYPE(tempsv)); + SWIG_croak("Expected a double reference."); + } + dvalue = SvNV(tempsv); + $1 = &dvalue; +} + +%typemap(in) float *REFERENCE (float dvalue), float &REFERENCE(float dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { + SWIG_croak("expected a double reference"); + } + dvalue = (float) SvNV(tempsv); + $1 = &dvalue; +} + +%typemap(in) int *REFERENCE (int dvalue), int &REFERENCE (int dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = SvIV(tempsv); + $1 = &dvalue; +} + +%typemap(in) short *REFERENCE (short dvalue), short &REFERENCE(short dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (short) SvIV(tempsv); + $1 = &dvalue; +} +%typemap(in) long *REFERENCE (long dvalue), long &REFERENCE(long dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (long) SvIV(tempsv); + $1 = &dvalue; +} +%typemap(in) unsigned int *REFERENCE (unsigned int dvalue), unsigned int &REFERENCE(unsigned int dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (unsigned int) SvUV(tempsv); + $1 = &dvalue; +} +%typemap(in) unsigned short *REFERENCE (unsigned short dvalue), unsigned short &REFERENCE(unsigned short dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (unsigned short) SvUV(tempsv); + $1 = &dvalue; +} +%typemap(in) unsigned long *REFERENCE (unsigned long dvalue), unsigned long &REFERENCE(unsigned long dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (unsigned long) SvUV(tempsv); + $1 = &dvalue; +} + +%typemap(in) unsigned char *REFERENCE (unsigned char dvalue), unsigned char &REFERENCE(unsigned char dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (unsigned char) SvUV(tempsv); + $1 = &dvalue; +} + +%typemap(in) signed char *REFERENCE (signed char dvalue), signed char &REFERENCE(signed char dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = (signed char) SvIV(tempsv); + $1 = &dvalue; +} + +%typemap(in) bool *REFERENCE (bool dvalue), bool &REFERENCE(bool dvalue) +{ + SV *tempsv; + if (!SvROK($input)) { + SWIG_croak("expected a reference"); + } + tempsv = SvRV($input); + if (!SvIOK(tempsv)) { + SWIG_croak("expected an integer reference"); + } + dvalue = SvIV(tempsv) ? true : false; + $1 = &dvalue; +} + +%typemap(typecheck) int *REFERENCE, int &REFERENCE, + short *REFERENCE, short &REFERENCE, + long *REFERENCE, long &REFERENCE, + signed char *REFERENCE, signed char &REFERENCE, + bool *REFERENCE, bool &REFERENCE +{ + $1 = SvROK($input) && SvIOK(SvRV($input)); +} +%typemap(typecheck) double *REFERENCE, double &REFERENCE, + float *REFERENCE, float &REFERENCE +{ + $1 = SvROK($input); + if($1) { + SV *tmpsv = SvRV($input); + $1 = SvNOK(tmpsv) || SvIOK(tmpsv); + } +} +%typemap(typecheck) unsigned int *REFERENCE, unsigned int &REFERENCE, + unsigned short *REFERENCE, unsigned short &REFERENCE, + unsigned long *REFERENCE, unsigned long &REFERENCE, + unsigned char *REFERENCE, unsigned char &REFERENCE +{ + $1 = SvROK($input); + if($1) { + SV *tmpsv = SvRV($input); + $1 = SvUOK(tmpsv) || SvIOK(tmpsv); + } +} + +%typemap(argout) double *REFERENCE, double &REFERENCE, + float *REFERENCE, float &REFERENCE +{ + SV *tempsv; + tempsv = SvRV($arg); + if (!$1) SWIG_croak("expected a reference"); + sv_setnv(tempsv, (double) *$1); +} + +%typemap(argout) int *REFERENCE, int &REFERENCE, + short *REFERENCE, short &REFERENCE, + long *REFERENCE, long &REFERENCE, + signed char *REFERENCE, signed char &REFERENCE, + bool *REFERENCE, bool &REFERENCE +{ + SV *tempsv; + tempsv = SvRV($input); + if (!$1) SWIG_croak("expected a reference"); + sv_setiv(tempsv, (IV) *$1); +} + +%typemap(argout) unsigned int *REFERENCE, unsigned int &REFERENCE, + unsigned short *REFERENCE, unsigned short &REFERENCE, + unsigned long *REFERENCE, unsigned long &REFERENCE, + unsigned char *REFERENCE, unsigned char &REFERENCE +{ + SV *tempsv; + tempsv = SvRV($input); + if (!$1) SWIG_croak("expected a reference"); + sv_setuv(tempsv, (UV) *$1); +} diff --git a/contrib/tools/swig/Lib/perl5/std_auto_ptr.i b/contrib/tools/swig/Lib/perl5/std_auto_ptr.i new file mode 100644 index 00000000000..3d7ae8ba16e --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_auto_ptr.i @@ -0,0 +1,39 @@ +/* ----------------------------------------------------------------------------- + * std_auto_ptr.i + * + * SWIG library file for handling std::auto_ptr. + * Memory ownership is passed from the std::auto_ptr C++ layer to the proxy + * class when returning a std::auto_ptr from a function. + * Memory ownership is passed from the proxy class to the std::auto_ptr in the + * C++ layer when passed as a parameter to a wrapped function. + * ----------------------------------------------------------------------------- */ + +%define %auto_ptr(TYPE) +%typemap(in, noblock=1) std::auto_ptr< TYPE > (void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags); + if (!SWIG_IsOK(res)) { + if (res == SWIG_ERROR_RELEASE_NOT_OWNED) { + %releasenotowned_fail(res, "TYPE *", $symname, $argnum); + } else { + %argument_fail(res, "TYPE *", $symname, $argnum); + } + } + $1.reset((TYPE *)argp); +} + +%typemap (out) std::auto_ptr< TYPE > %{ + %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags)); +%} + +%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::auto_ptr< TYPE > { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0); + $1 = SWIG_CheckState(res); +} + +%template() std::auto_ptr< TYPE >; +%enddef + +namespace std { + template <class T> class auto_ptr {}; +} diff --git a/contrib/tools/swig/Lib/perl5/std_common.i b/contrib/tools/swig/Lib/perl5/std_common.i new file mode 100644 index 00000000000..7c1ff232899 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_common.i @@ -0,0 +1,28 @@ +/* ----------------------------------------------------------------------------- + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +%fragment("<string>"); +%{ +SWIGINTERN +double SwigSvToNumber(SV* sv) { + return SvIOK(sv) ? double(SvIVX(sv)) : SvNVX(sv); +} +SWIGINTERN +std::string SwigSvToString(SV* sv) { + STRLEN len; + char *ptr = SvPV(sv, len); + return std::string(ptr, len); +} +SWIGINTERN +void SwigSvFromString(SV* sv, const std::string& s) { + sv_setpvn(sv,s.data(),s.size()); +} +%} + diff --git a/contrib/tools/swig/Lib/perl5/std_deque.i b/contrib/tools/swig/Lib/perl5/std_deque.i new file mode 100644 index 00000000000..cb98f6c2fb3 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/contrib/tools/swig/Lib/perl5/std_except.i b/contrib/tools/swig/Lib/perl5/std_except.i new file mode 100644 index 00000000000..af98428f65d --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_except.i @@ -0,0 +1 @@ +%include <typemaps/std_except.swg> diff --git a/contrib/tools/swig/Lib/perl5/std_list.i b/contrib/tools/swig/Lib/perl5/std_list.i new file mode 100644 index 00000000000..76f789b96ea --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_list.i @@ -0,0 +1,377 @@ +/* ----------------------------------------------------------------------------- + * std_list.i + * + * SWIG typemaps for std::list types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// containers + + +// ------------------------------------------------------------------------ +// std::list +// +// The aim of all that follows would be to integrate std::list with +// Perl as much as possible, namely, to allow the user to pass and +// be returned Perl arrays. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::list<T>), f(const std::list<T>&), f(const std::list<T>*): +// the parameter being read-only, either a Perl sequence or a +// previously wrapped std::list<T> can be passed. +// -- f(std::list<T>&), f(std::list<T>*): +// the parameter must be modified; therefore, only a wrapped std::list +// can be passed. +// -- std::list<T> f(): +// the list is returned by copy; therefore, a Perl sequence of T:s +// is returned which is most easily used in other Perl functions +// -- std::list<T>& f(), std::list<T>* f(), const std::list<T>& f(), +// const std::list<T>* f(): +// the list is returned by reference; therefore, a wrapped std::list +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <list> +%} +%fragment("<algorithm>"); +%fragment("<stdexcept>"); + +// exported class + +namespace std { + + template<class T> class list { + %typemap(in) list<T> (std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1) { + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + $1.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const list<T>& (std::list<T> temp, + std::list<T>* v), + const list<T>* (std::list<T> temp, + std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + temp.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) list<T> { + std::list< T >::const_iterator i; + unsigned int j; + int len = $1.size(); + SV **svs = new SV*[len]; + for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { + T* ptr = new T(*i); + svs[j] = sv_newmortal(); + SWIG_MakePtr(svs[j], (void*) ptr, + $descriptor(T *), $shadow|$owner); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_LIST) list<T> { + { + /* wrapped list? */ + std::list< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_&descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_LIST) const list<T>&, + const list<T>* { + { + /* wrapped list? */ + std::list< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + list(); + list(const list& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(const T& x); + }; + + + // specializations for built-ins + + %define specialize_std_list(T,CHECK_T,TO_T,FROM_T) + template<> class list<T> { + %typemap(in) list<T> (std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1){ + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + $1.push_back(TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const list<T>& (std::list<T> temp, + std::list<T>* v), + const list<T>* (std::list<T> temp, + std::list<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + temp.push_back(TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) list<T> { + std::list< T >::const_iterator i; + unsigned int j; + int len = $1.size(); + SV **svs = new SV*[len]; + for (i=$1.begin(), j=0; i!=$1.end(); i++, j++) { + svs[j] = sv_newmortal(); + FROM_T(svs[j], *i); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_LIST) list<T> { + { + /* wrapped list? */ + std::list< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_&descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_LIST) const list<T>&, + const list<T>* { + { + /* wrapped list? */ + std::list< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SV **tv; + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + typedef size_t size_type; + typedef T value_type; + typedef const value_type& const_reference; + + list(); + list(const list& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T x); + }; + %enddef + + specialize_std_list(bool,SvIOK,SvIVX,sv_setiv); + specialize_std_list(char,SvIOK,SvIVX,sv_setiv); + specialize_std_list(int,SvIOK,SvIVX,sv_setiv); + specialize_std_list(short,SvIOK,SvIVX,sv_setiv); + specialize_std_list(long,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned char,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned int,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned short,SvIOK,SvIVX,sv_setiv); + specialize_std_list(unsigned long,SvIOK,SvIVX,sv_setiv); + specialize_std_list(float,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_list(double,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_list(std::string,SvPOK,SvPVX,SwigSvFromString); + +} + diff --git a/contrib/tools/swig/Lib/perl5/std_map.i b/contrib/tools/swig/Lib/perl5/std_map.i new file mode 100644 index 00000000000..7d8103c0c47 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_map.i @@ -0,0 +1,71 @@ +/* ----------------------------------------------------------------------------- + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +%} +%fragment("<algorithm>"); +%fragment("<stdexcept>"); + +// exported class + +namespace std { + + template<class K, class T, class C = std::less<K> > class map { + // add typemaps here + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + map(); + map(const map& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map< K, T, C >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { +%#ifdef __cpp_lib_map_try_emplace + (*self).insert_or_assign(key, x); +%#else + (*self)[key] = x; +%#endif + } + void del(const K& key) throw (std::out_of_range) { + std::map< K, T, C >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map< K, T, C >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + +} diff --git a/contrib/tools/swig/Lib/perl5/std_pair.i b/contrib/tools/swig/Lib/perl5/std_pair.i new file mode 100644 index 00000000000..732347db583 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_pair.i @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + typedef T first_type; + typedef U second_type; + + pair(); + pair(T first, U second); + pair(const pair& other); + + template <class U1, class U2> pair(const pair<U1, U2> &other); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/contrib/tools/swig/Lib/perl5/std_string.i b/contrib/tools/swig/Lib/perl5/std_string.i new file mode 100644 index 00000000000..6f34f18475f --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_string.i @@ -0,0 +1,2 @@ +%include <perlstrings.swg> +%include <typemaps/std_string.swg> diff --git a/contrib/tools/swig/Lib/perl5/std_string_view.i b/contrib/tools/swig/Lib/perl5/std_string_view.i new file mode 100644 index 00000000000..b1afffcc034 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_string_view.i @@ -0,0 +1,2 @@ +%include <perlstrings.swg> +%include <typemaps/std_string_view.swg> diff --git a/contrib/tools/swig/Lib/perl5/std_unique_ptr.i b/contrib/tools/swig/Lib/perl5/std_unique_ptr.i new file mode 100644 index 00000000000..e3669bb4a5a --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_unique_ptr.i @@ -0,0 +1,69 @@ +/* ----------------------------------------------------------------------------- + * std_unique_ptr.i + * + * SWIG library file for handling std::unique_ptr. + * + * Returning a std::unique_ptr from a wrapped function: + * Memory ownership is passed (moved) from the std::unique_ptr in the C++ layer + * to the proxy class when returning a std::unique_ptr by value from a function. + * Memory ownership is not moved when returning by any sort of reference. + * + * Passing a std::unique_ptr as a parameter to a wrapped function: + * Memory ownership is passed from the proxy class to the std::unique_ptr in the + * C++ layer when passed as a parameter by value, rvalue reference or non-const + * lvalue reference. Memory ownership is not transferred when passing by const + * lvalue reference. + * ----------------------------------------------------------------------------- */ + +%include <unique_ptr.swg> + +%define %unique_ptr(TYPE) +%typemap(in, noblock=1) std::unique_ptr< TYPE > (void *argp = 0, int res = 0) { + res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags); + if (!SWIG_IsOK(res)) { + if (res == SWIG_ERROR_RELEASE_NOT_OWNED) { + %releasenotowned_fail(res, "TYPE *", $symname, $argnum); + } else { + %argument_fail(res, "TYPE *", $symname, $argnum); + } + } + $1.reset((TYPE *)argp); +} + +%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) { + res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags); + if (!SWIG_IsOK(res)) { + if (res == SWIG_ERROR_RELEASE_NOT_OWNED) { + %releasenotowned_fail(res, "TYPE *", $symname, $argnum); + } else { + %argument_fail(res, "TYPE *", $symname, $argnum); + } + } + uptr.reset((TYPE *)argp); + $1 = &uptr; +} + +%typemap(in, noblock=1, fragment="SwigNoDeleteUniquePtr") const std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, swig::NoDeleteUniquePtr< TYPE > ndup) { + res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), 0); + if (!SWIG_IsOK(res)) { + %argument_fail(res, "TYPE *", $symname, $argnum); + } + ndup.uptr.reset((TYPE *)argp); + $1 = &ndup.uptr; +} + +%typemap (out) std::unique_ptr< TYPE > %{ + %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags)); +%} +%typemap (out) std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && %{ + %set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags)); +%} + +%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && { + void *vptr = 0; + int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0); + $1 = SWIG_CheckState(res); +} + +%template() std::unique_ptr< TYPE >; +%enddef diff --git a/contrib/tools/swig/Lib/perl5/std_vector.i b/contrib/tools/swig/Lib/perl5/std_vector.i new file mode 100644 index 00000000000..06bc6f38347 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/std_vector.i @@ -0,0 +1,592 @@ +/* ----------------------------------------------------------------------------- + * std_vector.i + * + * SWIG typemaps for std::vector types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Perl as much as possible, namely, to allow the user to pass and +// be returned Perl arrays. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Perl sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Perl sequence of T:s +// is returned which is most easily used in other Perl functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +%} +%fragment("<algorithm>"); +%fragment("<stdexcept>"); + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> (std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1) { + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + $1.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp, + std::vector<T>* v), + const vector<T>* (std::vector<T> temp, + std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + T* obj; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) { + temp.push_back(*obj); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) vector<T> { + size_t len = $1.size(); + SV **svs = new SV*[len]; + for (size_t i=0; i<len; i++) { + T* ptr = new T($1[i]); + svs[i] = sv_newmortal(); + SWIG_MakePtr(svs[i], (void*) ptr, + $descriptor(T *), $shadow|$owner); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + { + /* wrapped vector? */ + std::vector< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + SV **tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + { + /* wrapped vector? */ + std::vector< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* obj; + SV **tv = av_fetch(av, 0, 0); + if (SWIG_ConvertPtr(*tv, (void **)&obj, + $descriptor(T *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + // specializations for pointers + template<class T> class vector<T*> { + %typemap(in) vector<T*> (std::vector<T*>* v) { + int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); + if (SWIG_IsOK(res)){ + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SSize_t len = av_len(av) + 1; + for (int i=0; i<len; i++) { + void *v; + SV **tv = av_fetch(av, i, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) { + $1.push_back(%static_cast(v, T *)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const vector<T *>& (std::vector<T *> temp,std::vector<T *>* v), + const vector<T *>* (std::vector<T *> temp,std::vector<T *>* v) { + int res = SWIG_ConvertPtr($input,(void **) &v, $1_descriptor,0); + if (SWIG_IsOK(res)) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SSize_t len = av_len(av) + 1; + for (int i=0; i<len; i++) { + void *v; + SV **tv = av_fetch(av, i, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) { + temp.push_back(%static_cast(v, T *)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) vector<T *> { + size_t len = $1.size(); + SV **svs = new SV*[len]; + for (size_t i=0; i<len; i++) { + T *x = (($1_type &)$1)[i]; + svs[i] = sv_newmortal(); + sv_setsv(svs[i], SWIG_NewPointerObj(x, $descriptor(T *), 0)); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T *> { + { + /* wrapped vector? */ + std::vector< T *>* v; + int res = SWIG_ConvertPtr($input,(void **) &v, $&1_descriptor,0); + if (SWIG_IsOK(res)) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + void *v; + SV **tv = av_fetch(av, 0, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T *>&,const vector<T *>* { + { + /* wrapped vector? */ + std::vector< T *> *v; + int res = SWIG_ConvertPtr($input,%as_voidptrptr(&v), $1_descriptor,0); + if (SWIG_IsOK(res)) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + void *v; + SV **tv = av_fetch(av, 0, 0); + int res = SWIG_ConvertPtr(*tv, &v, $descriptor(T *),0); + if (SWIG_IsOK(res)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T* value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + vector(unsigned int size = 0); + vector(unsigned int size, T *value); + vector(const vector& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T *x); + %extend { + T *pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T *x = self->back(); + self->pop_back(); + return x; + } + T *get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T *x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_vector(T,CHECK_T,TO_T,FROM_T) + template<> class vector<T> { + %typemap(in) vector<T> (std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,1) != -1){ + $1 = *v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + $1.push_back((T)TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(in) const vector<T>& (std::vector<T> temp, + std::vector<T>* v), + const vector<T>* (std::vector<T> temp, + std::vector<T>* v) { + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,1) != -1) { + $1 = v; + } else if (SvROK($input)) { + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) != SVt_PVAV) + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + SV **tv; + SSize_t len = av_len(av) + 1; + for (int i=0; i<len; i++) { + tv = av_fetch(av, i, 0); + if (CHECK_T(*tv)) { + temp.push_back((T)TO_T(*tv)); + } else { + SWIG_croak("Type error in argument $argnum of " + "$symname. " + "Expected an array of " #T); + } + } + $1 = &temp; + } else { + SWIG_croak("Type error in argument $argnum of $symname. " + "Expected an array of " #T); + } + } + %typemap(out) vector<T> { + size_t len = $1.size(); + SV **svs = new SV*[len]; + for (size_t i=0; i<len; i++) { + svs[i] = sv_newmortal(); + FROM_T(svs[i], $1[i]); + } + AV *myav = av_make(len, svs); + delete[] svs; + $result = newRV_noinc((SV*) myav); + sv_2mortal($result); + argvi++; + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + { + /* wrapped vector? */ + std::vector< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SV **tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&, + const vector<T>* { + { + /* wrapped vector? */ + std::vector< T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor,0) != -1) { + $1 = 1; + } else if (SvROK($input)) { + /* native sequence? */ + AV *av = (AV *)SvRV($input); + if (SvTYPE(av) == SVt_PVAV) { + SSize_t len = av_len(av) + 1; + if (len == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SV **tv = av_fetch(av, 0, 0); + if (CHECK_T(*tv)) + $1 = 1; + else + $1 = 0; + } + } + } else { + $1 = 0; + } + } + } + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + vector(unsigned int size = 0); + vector(unsigned int size, T value); + vector(const vector& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %rename(push) push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %enddef + + specialize_std_vector(bool,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(char,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(int,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(short,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(long,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned char,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned int,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned short,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(unsigned long,SvIOK,SvIVX,sv_setiv); + specialize_std_vector(float,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_vector(double,SvNIOK,SwigSvToNumber,sv_setnv); + specialize_std_vector(std::string,SvPOK,SwigSvToString,SwigSvFromString); +} + diff --git a/contrib/tools/swig/Lib/perl5/stl.i b/contrib/tools/swig/Lib/perl5/stl.i new file mode 100644 index 00000000000..04f86014f2c --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/stl.i @@ -0,0 +1,10 @@ +/* ----------------------------------------------------------------------------- + * stl.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/contrib/tools/swig/Lib/perl5/swigmove.i b/contrib/tools/swig/Lib/perl5/swigmove.i new file mode 100644 index 00000000000..62ecca76823 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/swigmove.i @@ -0,0 +1 @@ +%include <typemaps/swigmove.swg> diff --git a/contrib/tools/swig/Lib/perl5/typemaps.i b/contrib/tools/swig/Lib/perl5/typemaps.i new file mode 100644 index 00000000000..078f24ce891 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/typemaps.i @@ -0,0 +1,371 @@ +/* ----------------------------------------------------------------------------- + * typemaps.i + * + * The SWIG typemap library provides a language independent mechanism for + * supporting output arguments, input values, and other C function + * calling mechanisms. The primary use of the library is to provide a + * better interface to certain C function--especially those involving + * pointers. + * ----------------------------------------------------------------------------- */ + +#if !defined(SWIG_USE_OLD_TYPEMAPS) +%include <typemaps/typemaps.swg> +#else + + +// INPUT typemaps. +// These remap a C pointer to be an "INPUT" value which is passed by value +// instead of reference. + + +/* +The following methods can be applied to turn a pointer into a simple +"input" value. That is, instead of passing a pointer to an object, +you would use a real value instead. + + int *INPUT + short *INPUT + long *INPUT + long long *INPUT + unsigned int *INPUT + unsigned short *INPUT + unsigned long *INPUT + unsigned long long *INPUT + unsigned char *INPUT + bool *INPUT + float *INPUT + double *INPUT + +To use these, suppose you had a C function like this : + + double fadd(double *a, double *b) { + return *a+*b; + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + double fadd(double *INPUT, double *INPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INPUT { double *a, double *b }; + double fadd(double *a, double *b); + +*/ + +%define INPUT_TYPEMAP(type, converter) +%typemap(in) type *INPUT(type temp), type &INPUT(type temp) { + temp = (type) converter($input); + $1 = &temp; +} +%typemap(typecheck) type *INPUT = type; +%typemap(typecheck) type &INPUT = type; +%enddef + +INPUT_TYPEMAP(float, SvNV); +INPUT_TYPEMAP(double, SvNV); +INPUT_TYPEMAP(int, SvIV); +INPUT_TYPEMAP(long, SvIV); +INPUT_TYPEMAP(short, SvIV); +INPUT_TYPEMAP(signed char, SvIV); +INPUT_TYPEMAP(unsigned int, SvUV); +INPUT_TYPEMAP(unsigned long, SvUV); +INPUT_TYPEMAP(unsigned short, SvUV); +INPUT_TYPEMAP(unsigned char, SvUV); + +%typemap(in) bool *INPUT(bool temp), bool &INPUT(bool temp) { + temp = SvIV($input) ? true : false; + $1 = &temp; +} +%typemap(typecheck) bool *INPUT = bool; +%typemap(typecheck) bool &INPUT = bool; + +%typemap(in) long long *INPUT($*1_ltype temp), long long &INPUT($*1_ltype temp) { + temp = strtoll(SvPV_nolen($input), 0, 0); + $1 = &temp; +} +%typemap(typecheck) long long *INPUT = long long; +%typemap(typecheck) long long &INPUT = long long; + +%typemap(in) unsigned long long *INPUT($*1_ltype temp), unsigned long long &INPUT($*1_ltype temp) { + temp = strtoull(SvPV_nolen($input), 0, 0); + $1 = &temp; +} +%typemap(typecheck) unsigned long long *INPUT = unsigned long long; +%typemap(typecheck) unsigned long long &INPUT = unsigned long long; + + +#undef INPUT_TYPEMAP + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. The output value is appended to the result as +// a list element. + +/* +The following methods can be applied to turn a pointer into an "output" +value. When calling a function, no input value would be given for +a parameter, but an output value would be returned. In the case of +multiple output values, functions will return a Perl array. + + int *OUTPUT + short *OUTPUT + long *OUTPUT + long long *OUTPUT + unsigned int *OUTPUT + unsigned short *OUTPUT + unsigned long *OUTPUT + unsigned long long *OUTPUT + unsigned char *OUTPUT + bool *OUTPUT + float *OUTPUT + double *OUTPUT + +For example, suppose you were trying to wrap the modf() function in the +C math library which splits x into integral and fractional parts (and +returns the integer part in one of its parameters).: + + double modf(double x, double *ip); + +You could wrap it with SWIG as follows : + + %include typemaps.i + double modf(double x, double *OUTPUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *OUTPUT { double *ip }; + double modf(double x, double *ip); + +The Perl output of the function would be an array containing both +output values. + +*/ + +// Force the argument to be ignored. + +%typemap(in,numinputs=0) int *OUTPUT(int temp), int &OUTPUT(int temp), + short *OUTPUT(short temp), short &OUTPUT(short temp), + long *OUTPUT(long temp), long &OUTPUT(long temp), + unsigned int *OUTPUT(unsigned int temp), unsigned int &OUTPUT(unsigned int temp), + unsigned short *OUTPUT(unsigned short temp), unsigned short &OUTPUT(unsigned short temp), + unsigned long *OUTPUT(unsigned long temp), unsigned long &OUTPUT(unsigned long temp), + unsigned char *OUTPUT(unsigned char temp), unsigned char &OUTPUT(unsigned char temp), + signed char *OUTPUT(signed char temp), signed char &OUTPUT(signed char temp), + bool *OUTPUT(bool temp), bool &OUTPUT(bool temp), + float *OUTPUT(float temp), float &OUTPUT(float temp), + double *OUTPUT(double temp), double &OUTPUT(double temp), + long long *OUTPUT($*1_ltype temp), long long &OUTPUT($*1_ltype temp), + unsigned long long *OUTPUT($*1_ltype temp), unsigned long long &OUTPUT($*1_ltype temp) +"$1 = &temp;"; + +%typemap(argout) int *OUTPUT, int &OUTPUT, + short *OUTPUT, short &OUTPUT, + long *OUTPUT, long &OUTPUT, + signed char *OUTPUT, signed char &OUTPUT, + bool *OUTPUT, bool &OUTPUT +{ + if (argvi >= items) { + EXTEND(sp, argvi+1); + } + $result = sv_newmortal(); + sv_setiv($result,(IV) *($1)); + argvi++; +} + +%typemap(argout) unsigned int *OUTPUT, unsigned int &OUTPUT, + unsigned short *OUTPUT, unsigned short &OUTPUT, + unsigned long *OUTPUT, unsigned long &OUTPUT, + unsigned char *OUTPUT, unsigned char &OUTPUT +{ + if (argvi >= items) { + EXTEND(sp, argvi+1); + } + $result = sv_newmortal(); + sv_setuv($result,(UV) *($1)); + argvi++; +} + + + +%typemap(argout) float *OUTPUT, float &OUTPUT, + double *OUTPUT, double &OUTPUT +{ + if (argvi >= items) { + EXTEND(sp, argvi+1); + } + $result = sv_newmortal(); + sv_setnv($result,(double) *($1)); + argvi++; +} + +%typemap(argout) long long *OUTPUT, long long &OUTPUT { + char temp[256]; + if (argvi >= items) { + EXTEND(sp, argvi+1); + } + SWIG_snprintf(temp, sizeof(temp),"%lld", (long long)*($1)); + $result = sv_newmortal(); + sv_setpv($result,temp); + argvi++; +} + +%typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { + char temp[256]; + if (argvi >= items) { + EXTEND(sp, argvi+1); + } + SWIG_snprintf(temp, sizeof(temp),"%llu", (unsigned long long)*($1)); + $result = sv_newmortal(); + sv_setpv($result,temp); + argvi++; +} + +// INOUT +// Mappings for an argument that is both an input and output +// parameter + +/* +The following methods can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" methods described earlier. Output values are +returned in the form of a Perl array. + + int *INOUT + short *INOUT + long *INOUT + long long *INOUT + unsigned int *INOUT + unsigned short *INOUT + unsigned long *INOUT + unsigned long long *INOUT + unsigned char *INOUT + bool *INOUT + float *INOUT + double *INOUT + +For example, suppose you were trying to wrap the following function : + + void neg(double *x) { + *x = -(*x); + } + +You could wrap it with SWIG as follows : + + %include typemaps.i + void neg(double *INOUT); + +or you can use the %apply directive : + + %include typemaps.i + %apply double *INOUT { double *x }; + void neg(double *x); + +Unlike C, this mapping does not directly modify the input value. +Rather, the modified input value shows up as the return value of the +function. Thus, to apply this function to a Perl variable you might +do this : + + $x = neg($x); + +*/ + +%typemap(in) int *INOUT = int *INPUT; +%typemap(in) short *INOUT = short *INPUT; +%typemap(in) long *INOUT = long *INPUT; +%typemap(in) unsigned *INOUT = unsigned *INPUT; +%typemap(in) unsigned short *INOUT = unsigned short *INPUT; +%typemap(in) unsigned long *INOUT = unsigned long *INPUT; +%typemap(in) unsigned char *INOUT = unsigned char *INPUT; +%typemap(in) signed char *INOUT = signed char *INPUT; +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(in) float *INOUT = float *INPUT; +%typemap(in) double *INOUT = double *INPUT; +%typemap(in) long long *INOUT = long long *INPUT; +%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; + +%typemap(in) int &INOUT = int &INPUT; +%typemap(in) short &INOUT = short &INPUT; +%typemap(in) long &INOUT = long &INPUT; +%typemap(in) unsigned &INOUT = unsigned &INPUT; +%typemap(in) unsigned short &INOUT = unsigned short &INPUT; +%typemap(in) unsigned long &INOUT = unsigned long &INPUT; +%typemap(in) unsigned char &INOUT = unsigned char &INPUT; +%typemap(in) signed char &INOUT = signed char &INPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(in) float &INOUT = float &INPUT; +%typemap(in) double &INOUT = double &INPUT; +%typemap(in) long long &INOUT = long long &INPUT; +%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT; + + +%typemap(argout) int *INOUT = int *OUTPUT; +%typemap(argout) short *INOUT = short *OUTPUT; +%typemap(argout) long *INOUT = long *OUTPUT; +%typemap(argout) unsigned *INOUT = unsigned *OUTPUT; +%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT; +%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; +%typemap(argout) signed char *INOUT = signed char *OUTPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(argout) float *INOUT = float *OUTPUT; +%typemap(argout) double *INOUT = double *OUTPUT; +%typemap(argout) long long *INOUT = long long *OUTPUT; +%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; + + +%typemap(argout) int &INOUT = int &OUTPUT; +%typemap(argout) short &INOUT = short &OUTPUT; +%typemap(argout) long &INOUT = long &OUTPUT; +%typemap(argout) unsigned &INOUT = unsigned &OUTPUT; +%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT; +%typemap(argout) signed char &INOUT = signed char &OUTPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; +%typemap(argout) float &INOUT = float &OUTPUT; +%typemap(argout) double &INOUT = double &OUTPUT; +%typemap(argout) long long &INOUT = long long &OUTPUT; +%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT; + + +/* Overloading information */ + +%typemap(typecheck) double *INOUT = double; +%typemap(typecheck) bool *INOUT = bool; +%typemap(typecheck) signed char *INOUT = signed char; +%typemap(typecheck) unsigned char *INOUT = unsigned char; +%typemap(typecheck) unsigned long *INOUT = unsigned long; +%typemap(typecheck) unsigned short *INOUT = unsigned short; +%typemap(typecheck) unsigned int *INOUT = unsigned int; +%typemap(typecheck) long *INOUT = long; +%typemap(typecheck) short *INOUT = short; +%typemap(typecheck) int *INOUT = int; +%typemap(typecheck) float *INOUT = float; +%typemap(typecheck) long long *INOUT = long long; +%typemap(typecheck) unsigned long long *INOUT = unsigned long long; + +%typemap(typecheck) double &INOUT = double; +%typemap(typecheck) bool &INOUT = bool; +%typemap(typecheck) signed char &INOUT = signed char; +%typemap(typecheck) unsigned char &INOUT = unsigned char; +%typemap(typecheck) unsigned long &INOUT = unsigned long; +%typemap(typecheck) unsigned short &INOUT = unsigned short; +%typemap(typecheck) unsigned int &INOUT = unsigned int; +%typemap(typecheck) long &INOUT = long; +%typemap(typecheck) short &INOUT = short; +%typemap(typecheck) int &INOUT = int; +%typemap(typecheck) float &INOUT = float; +%typemap(typecheck) long long &INOUT = long long; +%typemap(typecheck) unsigned long long &INOUT = unsigned long long; + +#endif + +// -------------------------------------------------------------------- +// Special types +// -------------------------------------------------------------------- + + +%include <reference.i> diff --git a/contrib/tools/swig/Lib/perl5/ya.make b/contrib/tools/swig/Lib/perl5/ya.make new file mode 100644 index 00000000000..e81e36377f8 --- /dev/null +++ b/contrib/tools/swig/Lib/perl5/ya.make @@ -0,0 +1,24 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(LicenseRef-scancode-swig) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +SUBSCRIBER(g:cpp-contrib) + +VERSION(4.3.1) + +ORIGINAL_SOURCE(https://github.com/swig/swig/archive/v4.3.1.tar.gz) + +ADDINCL( + GLOBAL FOR + swig + contrib/tools/swig/Lib/perl5 + GLOBAL FOR + swig + contrib/tools/swig/Lib +) + +END() |