diff options
author | alevitskii <[email protected]> | 2025-09-02 06:57:05 +0300 |
---|---|---|
committer | alevitskii <[email protected]> | 2025-09-02 07:19:27 +0300 |
commit | 7e399723cf6d967e20c8f9d2ee975426636242c5 (patch) | |
tree | abd5283daba11c07afc8fc16f02aec2c19e2272a /contrib/tools/swig/Lib/python | |
parent | 14e9c865541d5abe545cb496c0143e4905b00c78 (diff) |
Drop LINTER param from styling macroses and cleanup deps
Drop LINTER param from styling macroses
commit_hash:00dd2e2ee103e509cff38f520d4779974abe39a7
Diffstat (limited to 'contrib/tools/swig/Lib/python')
88 files changed, 0 insertions, 11517 deletions
diff --git a/contrib/tools/swig/Lib/python/.yandex_meta/licenses.list.txt b/contrib/tools/swig/Lib/python/.yandex_meta/licenses.list.txt deleted file mode 100644 index 8aad0f87d67..00000000000 --- a/contrib/tools/swig/Lib/python/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,916 +0,0 @@ -====================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/python/README b/contrib/tools/swig/Lib/python/README deleted file mode 100644 index 70968e7dd58..00000000000 --- a/contrib/tools/swig/Lib/python/README +++ /dev/null @@ -1,103 +0,0 @@ -/* ----------------------------------------------------------------------------- - * - * User interfaces: include these ones as needed - * - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * Special types and user helpers - * ----------------------------------------------------------------------------- */ - -argcargv.i Handler for (int argc, char **argv) -attribute.i Convert a pair of set/get methods into a "native" python attribute -ccomplex.i C99 complex type -complex.i C99 or C++ complex type -cstring.i Various forms of C character string handling -cwstring.i Various forms of C wchar_t string handling -embed.i embedding the Python interpreter in something else -file.i FILE C type -implicit.i Allow the use of implicit C++ constructors -wchar.i wchar_t C type - -/* ----------------------------------------------------------------------------- - * C++ STD + STL - * ----------------------------------------------------------------------------- */ - -std_alloc.i allocator -std_basic_string.i basic string -std_char_traits.i char traits -std_complex.i complex -std_deque.i deque -std_except.i exceptions -std_ios.i ios -std_iostream.i istream/ostream -std_list.i list -std_map.i map -std_multimap.i multimap -std_multiset.i multiset -std_pair.i pair -std_set.i set -std_sstream.i string stream -std_streambuf.i streambuf -std_string.i string -std_vector.i vector -std_wios.i wios -std_wiostream.i wistream/wostream -std_wsstream.i wstring stream -std_wstreambuf.i wstreambuf -std_wstring.i wstring - - - -/* ----------------------------------------------------------------------------- -/* - * Implementation files: don't look at them unless you are really drunk - * - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * Basic files - * ----------------------------------------------------------------------------- */ - -python.swg Main language file, it just includes what is needed. -pyuserdir.swg User visible directives (%pythonnondynamic, etc) -pymacros.swg Internal macros used for typemaps -pyfragments.swg Allow the user to overload the default fragments -pyopers.swg Python operations (+=, *=, etc) -pythonkw.swg Python keywords and special names -pyinit.swg Python Init method - -/* ----------------------------------------------------------------------------- - * The runtime part - * ----------------------------------------------------------------------------- */ - -pyruntime.swg Main runtime file definition -pyapi.swg SWIG/Python API declarations -pyrun.swg Python run-time code - -/* ----------------------------------------------------------------------------- - * Internal typemap specializations - * ----------------------------------------------------------------------------- */ - -pyswigtype.swg SWIGTYPE -pystrings.swg Char strings (char *) -pywstrings.swg Wchar Strings (wchar_t *) -pyprimtypes.swg Primitive types (shot,int,double,etc) -pycomplex.swg PyComplex and helper for C/C++ complex types -pydocs.swg Typemaps documentation - -/* ----------------------------------------------------------------------------- - * C++ STD + STL - * ----------------------------------------------------------------------------- */ - -pycontainer.swg python container iterators -std_common.i general common code for the STD/STL implementation -std_container.i general common code for the STD/STL containers - - -/*----------------------------------------------------------------------------- - * Backward compatibility and deprecated - * ----------------------------------------------------------------------------- */ - -std_vectora.i vector + allocator (allocators are now supported in STD/STL) -typemaps.i old in/out typemaps (doesn't need to be included) diff --git a/contrib/tools/swig/Lib/python/argcargv.i b/contrib/tools/swig/Lib/python/argcargv.i deleted file mode 100644 index af71840f58c..00000000000 --- a/contrib/tools/swig/Lib/python/argcargv.i +++ /dev/null @@ -1,89 +0,0 @@ -/* ------------------------------------------------------------- - * SWIG library containing argc and argv multi-argument typemaps - * ------------------------------------------------------------- */ - -%fragment("SWIG_AsArgcArgv","header",fragment="SWIG_AsCharPtrAndSize") { -SWIGINTERN int -SWIG_AsArgcArgv(PyObject *input, swig_type_info *ppchar_info, size_t *argc, char ***argv, int *owner) { - void *vptr; - int res = SWIG_ConvertPtr(input, &vptr, ppchar_info, 0); - if (!SWIG_IsOK(res)) { - int list = 0; - PyErr_Clear(); - list = PyList_Check(input); - if (list || PyTuple_Check(input)) { - size_t i = 0; - size_t size = list ? PyList_Size(input) : PyTuple_Size(input); - if (argc) *argc = size; - if (argv) { - *argv = %new_array(size + 1, char*); - for (; i < size; ++i) { - PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); - char *cptr = 0; size_t sz = 0; int alloc = 0; - res = SWIG_AsCharPtrAndSize(obj, &cptr, &sz, &alloc); - if (SWIG_IsOK(res)) { - if (cptr && sz) { - (*argv)[i] = (alloc == SWIG_NEWOBJ) ? cptr : %new_copy_array(cptr, sz, char); - } else { - (*argv)[i] = 0; - } - } else { - return SWIG_TypeError; - } - } - (*argv)[i] = 0; - if (owner) *owner = 1; - } else { - for (; i < size; ++i) { - PyObject *obj = list ? PyList_GetItem(input,i) : PyTuple_GetItem(input,i); - res = SWIG_AsCharPtrAndSize(obj, 0, 0, 0); - if (!SWIG_IsOK(res)) return SWIG_TypeError; - } - if (owner) *owner = 0; - } - return SWIG_OK; - } else { - return SWIG_TypeError; - } - } else { - /* seems dangerous, but the user asked for it... */ - size_t i = 0; - if (argv) { while (*argv[i] != 0) ++i;} - if (argc) *argc = i; - if (owner) *owner = 0; - return SWIG_OK; - } -} -} - -/* - This typemap works with either a char **, a python list or a python - tuple - */ - -%typemap(in,noblock=0,fragment="SWIG_AsArgcArgv") (int ARGC, char **ARGV) (int res,char **argv = 0, size_t argc = 0, int owner= 0) { - res = SWIG_AsArgcArgv($input, $descriptor(char**), &argc, &argv, &owner); - if (!SWIG_IsOK(res)) { - $1 = 0; $2 = 0; - %argument_fail(SWIG_TypeError, "int ARGC, char **ARGV", $symname, $argnum); - } else { - $1 = %static_cast(argc,$1_ltype); - $2 = %static_cast(argv, $2_ltype); - } -} - -%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) { - int res = SWIG_AsArgcArgv($input, $descriptor(char**), 0, 0, 0); - $1 = SWIG_IsOK(res); -} - -%typemap(freearg,noblock=1) (int ARGC, char **ARGV) { - if (owner$argnum) { - size_t i = argc$argnum; - while (i) { - %delete_array(argv$argnum[--i]); - } - %delete_array(argv$argnum); - } -} - diff --git a/contrib/tools/swig/Lib/python/attribute.i b/contrib/tools/swig/Lib/python/attribute.i deleted file mode 100644 index 779716cd2ea..00000000000 --- a/contrib/tools/swig/Lib/python/attribute.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/attribute.swg> diff --git a/contrib/tools/swig/Lib/python/boost_shared_ptr.i b/contrib/tools/swig/Lib/python/boost_shared_ptr.i deleted file mode 100644 index bfd8787c08a..00000000000 --- a/contrib/tools/swig/Lib/python/boost_shared_ptr.i +++ /dev/null @@ -1,411 +0,0 @@ -%include <shared_ptr.i> - -// Set SHARED_PTR_DISOWN to $disown if required, for example -// #define SHARED_PTR_DISOWN $disown -#if !defined(SHARED_PTR_DISOWN) -#define SHARED_PTR_DISOWN 0 -#endif - -%fragment("SWIG_null_deleter_python", "header", fragment="SWIG_null_deleter") { -%#define SWIG_NO_NULL_DELETER_SWIG_BUILTIN_INIT -} - -// Language specific macro implementing all the customisations for handling the smart pointer -%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) - -// %naturalvar is as documented for member variables -%naturalvar TYPE; -%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; - -// destructor wrapper customisation -%feature("unref") TYPE -//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" - "(void)arg1; delete smartarg1;" - -// Typemap customisations... - -// plain value -%typemap(in) CONST TYPE (void *argp, int res = 0) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (!argp) { - %argument_nullref("$type", $symname, $argnum); - } else { - $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - } -} -%typemap(out) CONST TYPE { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1)); - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(varin) CONST TYPE { - void *argp = 0; - int newmem = 0; - int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %variable_fail(res, "$type", "$name"); - } - if (!argp) { - %variable_nullref("$type", "$name"); - } else { - $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - } -} -%typemap(varout) CONST TYPE { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1)); - %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(directorin,noblock=1) CONST TYPE (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(SWIG_STD_MOVE($1))); - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) CONST TYPE (void *swig_argp, int swig_res = 0) { - int newmem = 0; - swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(swig_res)) { - %dirout_fail(swig_res, "$type"); - } - if (!swig_argp) { - %dirout_nullref("$type"); - } else { - $result = *(%reinterpret_cast(swig_argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(swig_argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - } -} - -// plain pointer -// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance -%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (newmem & SWIG_CAST_NEW_MEMORY) { - tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - $1 = %const_cast(tempshared.get(), $1_ltype); - } else { - smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); - } -} - -%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); -} - -%typemap(varin) CONST TYPE * { - void *argp = 0; - int newmem = 0; - int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %variable_fail(res, "$type", "$name"); - } - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0; - if (newmem & SWIG_CAST_NEW_MEMORY) { - tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - $1 = %const_cast(tempshared.get(), $1_ltype); - } else { - smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); - } -} -%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; - %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(directorin,noblock=1, fragment="SWIG_null_deleter_python") CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) CONST TYPE * %{ -#error "directorout typemap for plain pointer not implemented" -%} - -// plain reference -%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (!argp) { %argument_nullref("$type", $symname, $argnum); } - if (newmem & SWIG_CAST_NEW_MEMORY) { - tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - $1 = %const_cast(tempshared.get(), $1_ltype); - } else { - $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); - } -} -%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(varin) CONST TYPE & { - void *argp = 0; - int newmem = 0; - int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %variable_fail(res, "$type", "$name"); - } - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared; - if (!argp) { - %variable_nullref("$type", "$name"); - } - if (newmem & SWIG_CAST_NEW_MEMORY) { - tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - $1 = *%const_cast(tempshared.get(), $1_ltype); - } else { - $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype); - } -} -%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); - %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(directorin,noblock=1, fragment="SWIG_null_deleter_python") CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0); - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) CONST TYPE & %{ -#error "directorout typemap for plain reference not implemented" -%} - -// plain pointer by reference -// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance -%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (newmem & SWIG_CAST_NEW_MEMORY) { - tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); - temp = %const_cast(tempshared.get(), $*1_ltype); - } else { - temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype); - } - $1 = &temp; -} -%typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner) : 0; - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(varin) TYPE *CONST& %{ -#error "varin typemap not implemented" -%} -%typemap(varout) TYPE *CONST& %{ -#error "varout typemap not implemented" -%} - -%typemap(directorin,noblock=1, fragment="SWIG_null_deleter_python") TYPE *CONST& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) TYPE *CONST& %{ -#error "directorout typemap for plain pointer by reference not implemented" -%} - -// shared_ptr by value -%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); -} -%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { - int newmem = 0; - void *argp = 0; - int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %variable_fail(res, "$type", "$name"); - } - $1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >(); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); -} -%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; - %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *swig_argp, int swig_res = 0) { - int newmem = 0; - swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(swig_res)) { - %dirout_fail(swig_res, "$type"); - } - if (swig_argp) { - $result = *(%reinterpret_cast(swig_argp, $<ype)); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(swig_argp, $<ype); - } -} - -// shared_ptr by reference -%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (newmem & SWIG_CAST_NEW_MEMORY) { - if (argp) tempshared = *%reinterpret_cast(argp, $ltype); - delete %reinterpret_cast(argp, $ltype); - $1 = &tempshared; - } else { - $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; - } -} -%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ -#error "varin typemap not implemented" -%} -%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ -#error "varout typemap not implemented" -%} - -%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0; - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{ -#error "directorout typemap for shared_ptr ref not implemented" -%} - -// shared_ptr by pointer -%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (newmem & SWIG_CAST_NEW_MEMORY) { - if (argp) tempshared = *%reinterpret_cast(argp, $ltype); - delete %reinterpret_cast(argp, $ltype); - $1 = &tempshared; - } else { - $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared; - } -} -%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); - if ($owner) delete $1; -} - -%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ -#error "varin typemap not implemented" -%} -%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ -#error "varout typemap not implemented" -%} - -%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{ -#error "directorout typemap for pointer to shared_ptr not implemented" -%} - -// shared_ptr by pointer reference -%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { - int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); - if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); - temp = &tempshared; - $1 = &temp; -} -%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; - %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); -} - -%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ -#error "varin typemap not implemented" -%} -%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ -#error "varout typemap not implemented" -%} - -%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = ($1 && *$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0; - $input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); -%} -%typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{ -#error "directorout typemap for pointer ref to shared_ptr not implemented" -%} - -// Typecheck typemaps -// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting -// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. -%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) - TYPE CONST, - TYPE CONST &, - TYPE CONST *, - TYPE *CONST&, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& { - int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0); - $1 = SWIG_CheckState(res); -} - - -// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug -%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ -#error "typemaps for $1_type not available" -%} -%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ -#error "typemaps for $1_type not available" -%} - -%typemap(doctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& - %{TYPE%} - - -%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; - - -%enddef diff --git a/contrib/tools/swig/Lib/python/builtin.swg b/contrib/tools/swig/Lib/python/builtin.swg deleted file mode 100644 index e2e7f120f29..00000000000 --- a/contrib/tools/swig/Lib/python/builtin.swg +++ /dev/null @@ -1,778 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -SWIGINTERN Py_hash_t -SwigPyObject_hash(PyObject *obj) { - SwigPyObject *sobj = (SwigPyObject *)obj; - void *ptr = sobj->ptr; -#if PY_VERSION_HEX < 0x03020000 - return (Py_hash_t)(Py_ssize_t)ptr; -#else - return (Py_hash_t)ptr; -#endif -} - -SWIGINTERN Py_hash_t -SWIG_PyNumber_AsPyHash(PyObject *obj) { - Py_hash_t result = -1; -#if PY_VERSION_HEX < 0x03020000 - if (PyInt_Check(obj)) - result = PyInt_AsLong(obj); - else if (PyLong_Check(obj)) - result = PyLong_AsLong(obj); -#else - if (PyNumber_Check(obj)) - result = PyNumber_AsSsize_t(obj, NULL); -#endif - else - PyErr_Format(PyExc_TypeError, "Wrong type for hash function"); - return PyErr_Occurred() ? -1 : result; -} - -SWIGINTERN int -SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) { - PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name); - return -1; -} - -SWIGINTERN void -SwigPyBuiltin_BadDealloc(PyObject *obj) { - SwigPyObject *sobj = (SwigPyObject *)obj; - if (sobj->own) { - PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name); - } -} - -typedef struct { - PyCFunction get; - PyCFunction set; -} SwigPyGetSet; - -SWIGINTERN PyObject * -SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) { - SwigPyGetSet *getset; - PyObject *tuple, *result; - if (!closure) - return SWIG_Py_Void(); - getset = (SwigPyGetSet *)closure; - if (!getset->get) - return SWIG_Py_Void(); - tuple = PyTuple_New(0); - assert(tuple); - result = (*getset->get)(obj, tuple); - SWIG_Py_DECREF(tuple); - return result; -} - -SWIGINTERN PyObject * -SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) { - SwigPyGetSet *getset; - PyObject *result; - if (!closure) - return SWIG_Py_Void(); - getset = (SwigPyGetSet *)closure; - if (!getset->get) - return SWIG_Py_Void(); - result = (*getset->get)(obj, NULL); - return result; -} - -SWIGINTERN int -SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { - SwigPyGetSet *getset; - PyObject *tuple, *result; - if (!closure) { - PyErr_Format(PyExc_TypeError, "Missing getset closure"); - return -1; - } - getset = (SwigPyGetSet *)closure; - if (!getset->set) { - PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); - return -1; - } - tuple = PyTuple_New(1); - assert(tuple); - SWIG_Py_INCREF(val); - PyTuple_SET_ITEM(tuple, 0, val); - result = (*getset->set)(obj, tuple); - SWIG_Py_DECREF(tuple); - SWIG_Py_XDECREF(result); - return result ? 0 : -1; -} - -SWIGINTERN int -SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) { - SwigPyGetSet *getset; - PyObject *result; - if (!closure) { - PyErr_Format(PyExc_TypeError, "Missing getset closure"); - return -1; - } - getset = (SwigPyGetSet *)closure; - if (!getset->set) { - PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); - return -1; - } - result = (*getset->set)(obj, val); - SWIG_Py_XDECREF(result); - return result ? 0 : -1; -} - -SWIGINTERN void -SwigPyStaticVar_dealloc(PyDescrObject *descr) { - PyObject_GC_UnTrack(descr); - SWIG_Py_XDECREF((PyObject *)PyDescr_TYPE(descr)); - SWIG_Py_XDECREF((PyObject *)PyDescr_NAME(descr)); - PyObject_GC_Del(descr); -} - -SWIGINTERN PyObject * -SwigPyStaticVar_repr(PyGetSetDescrObject *descr) { -#if PY_VERSION_HEX >= 0x03000000 - - return PyUnicode_FromFormat("<class attribute '%S' of type '%s'>", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); -#else - return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); -#endif -} - -SWIGINTERN int -SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) { - PyDescrObject *descr; - descr = (PyDescrObject *)self; - Py_VISIT((PyObject*) PyDescr_TYPE(descr)); - return 0; -} - -SWIGINTERN PyObject * -SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) { - if (descr->d_getset->get != NULL) - return descr->d_getset->get(obj, descr->d_getset->closure); -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); -#else - PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); -#endif - return NULL; -} - -SWIGINTERN int -SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) { - if (descr->d_getset->set != NULL) - return descr->d_getset->set(obj, value, descr->d_getset->closure); -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); -#else - PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); -#endif - return -1; -} - -SWIGINTERN int -SwigPyObjectType_setattro(PyObject *typeobject, PyObject *name, PyObject *value) { - PyObject *attribute; - PyTypeObject *type; - descrsetfunc local_set; - - assert(PyType_Check(typeobject)); - type = (PyTypeObject *)typeobject; - attribute = _PyType_Lookup(type, name); - if (attribute != NULL) { - /* Implement descriptor functionality, if any */ - local_set = attribute->ob_type->tp_descr_set; - if (local_set != NULL) - return local_set(attribute, (PyObject *)type, value); -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name); -#else - PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name)); -#endif - } else { -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name); -#else - PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name)); -#endif - } - - return -1; -} - -SWIGINTERN PyTypeObject* -SwigPyStaticVar_Type(void) { - static PyTypeObject staticvar_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ -#endif - "swig_static_var_getset_descriptor", /* tp_name */ - sizeof(PyGetSetDescrObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /* tp_print */ -#else - (Py_ssize_t)0, /* tp_vectorcall_offset */ -#endif - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)SwigPyStaticVar_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ - 0, /* tp_doc */ - SwigPyStaticVar_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */ - (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#if PY_VERSION_HEX >= 0x030c0000 - 0, /* tp_watched */ -#endif -#if PY_VERSION_HEX >= 0x030d00a4 - 0, /* tp_versions_used */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - staticvar_type = tmp; - type_init = 1; - if (PyType_Ready(&staticvar_type) < 0) - return NULL; - } - return &staticvar_type; -} - -SWIGINTERN PyTypeObject* -SwigPyObjectType(void) { - static char swigpyobjecttype_doc[] = "Metaclass for SWIG wrapped types"; - static PyTypeObject swigpyobjecttype_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ -#endif - "SwigPyObjectType", /* tp_name */ - PyType_Type.tp_basicsize, /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /* tp_print */ -#else - (Py_ssize_t)0, /* tp_vectorcall_offset */ -#endif - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - SwigPyObjectType_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ - swigpyobjecttype_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#if PY_VERSION_HEX >= 0x030c0000 - 0, /* tp_watched */ -#endif -#if PY_VERSION_HEX >= 0x030d00a4 - 0, /* tp_versions_used */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - swigpyobjecttype_type = tmp; - type_init = 1; - swigpyobjecttype_type.tp_base = &PyType_Type; - if (PyType_Ready(&swigpyobjecttype_type) < 0) - return NULL; - } - return &swigpyobjecttype_type; -} - -SWIGINTERN PyGetSetDescrObject * -SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { - - PyGetSetDescrObject *descr; - descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0); - assert(descr); - SWIG_Py_XINCREF((PyObject *)type); - PyDescr_TYPE(descr) = type; - PyDescr_NAME(descr) = PyString_InternFromString(getset->name); - descr->d_getset = getset; - if (PyDescr_NAME(descr) == NULL) { - SWIG_Py_DECREF((PyObject *)descr); - descr = NULL; - } - return descr; -} - -SWIGINTERN PyObject * -SwigPyBuiltin_InitBases(PyTypeObject **bases) { - Py_ssize_t base_count = 0; - PyTypeObject **b; - PyObject *tuple; - Py_ssize_t i; - - if (!bases[0]) { - bases[0] = SwigPyObject_type(); - bases[1] = NULL; - } - for (b = bases; *b != NULL; ++b) - ++base_count; - tuple = PyTuple_New(base_count); - for (i = 0; i < base_count; ++i) { - SWIG_Py_INCREF((PyObject *)bases[i]); - PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); - } - return tuple; -} - -SWIGINTERN PyObject * -SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { - PyObject *result; - result = (PyObject *)SWIG_Python_GetSwigThis(self); - SWIG_Py_XINCREF(result); - return result; -} - -SWIGINTERN void -SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) -{ -#if PY_VERSION_HEX >= 0x030900a4 - Py_SET_TYPE(type, metatype); -#else - Py_TYPE(type) = metatype; -#endif -} - - -/* Start of callback function macros for use in PyTypeObject */ - -typedef PyObject *(*SwigPyWrapperFunction)(PyObject *, PyObject *); - -#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_unaryfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_unaryfunc_closure(wrapper, a); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_unaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ -SWIGINTERN void \ -wrapper##_destructor_closure(PyObject *a) { \ - SwigPyBuiltin_destructor_closure(wrapper, #wrapper, a); \ -} -SWIGINTERN void -SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrappername, PyObject *a) { - SwigPyObject *sobj; - sobj = (SwigPyObject *)a; - SWIG_Py_XDECREF(sobj->dict); - if (sobj->own) { - PyObject *o; - PyObject *type = 0, *value = 0, *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - o = wrapper(a, NULL); - if (!o) { - PyObject *deallocname = PyString_FromString(wrappername); - PyErr_WriteUnraisable(deallocname); - SWIG_Py_DECREF(deallocname); - } - PyErr_Restore(type, value, traceback); - SWIG_Py_XDECREF(o); - } - if (PyType_IS_GC(a->ob_type)) { - PyObject_GC_Del(a); - } else { - PyObject_Free(a); - } -} - -#define SWIGPY_INQUIRY_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_inquiry_closure(PyObject *a) { \ - return SwigPyBuiltin_inquiry_closure(wrapper, a); \ -} -SWIGINTERN int -SwigPyBuiltin_inquiry_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - PyObject *pyresult; - int result; - pyresult = wrapper(a, NULL); - result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; - SWIG_Py_XDECREF(pyresult); - return result; -} - -#define SWIGPY_GETITERFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_getiterfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_getiterfunc_closure(wrapper, a); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_getiterfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_binaryfunc_closure(PyObject *a, PyObject *b) { \ - return SwigPyBuiltin_binaryfunc_closure(wrapper, a, b); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { - PyObject *tuple, *result; - tuple = PyTuple_New(1); - assert(tuple); - SWIG_Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - result = wrapper(a, tuple); - SWIG_Py_DECREF(tuple); - return result; -} - -typedef ternaryfunc ternarycallfunc; - -#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ternaryfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \ - return SwigPyBuiltin_ternaryfunc_closure(wrapper, a, b, c); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { - PyObject *tuple, *result; - tuple = PyTuple_New(2); - assert(tuple); - SWIG_Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - if (c) { - SWIG_Py_INCREF(c); - PyTuple_SET_ITEM(tuple, 1, c); - } - result = wrapper(a, tuple); - SWIG_Py_DECREF(tuple); - return result; -} - -#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ternarycallfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \ - return SwigPyBuiltin_ternarycallfunc_closure(wrapper, a, b, c); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ternarycallfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { - (void) c; - return wrapper(a, b); -} - -#define SWIGPY_LENFUNC_CLOSURE(wrapper) \ -SWIGINTERN Py_ssize_t \ -wrapper##_lenfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_lenfunc_closure(wrapper, a); \ -} -SWIGINTERN Py_ssize_t -SwigPyBuiltin_lenfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - PyObject *resultobj; - Py_ssize_t result; - resultobj = wrapper(a, NULL); - result = PyNumber_AsSsize_t(resultobj, NULL); - SWIG_Py_DECREF(resultobj); - return result; -} - -#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ssizessizeargfunc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \ - return SwigPyBuiltin_ssizessizeargfunc_closure(wrapper, a, b, c); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ssizessizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c) { - PyObject *tuple, *result; - tuple = PyTuple_New(2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); - result = wrapper(a, tuple); - SWIG_Py_DECREF(tuple); - return result; -} - -#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_ssizessizeobjargproc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \ - return SwigPyBuiltin_ssizessizeobjargproc_closure(wrapper, a, b, c, d); \ -} -SWIGINTERN int -SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { - PyObject *tuple, *resultobj; - int result; - tuple = PyTuple_New(d ? 3 : 2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); - if (d) { - SWIG_Py_INCREF(d); - PyTuple_SET_ITEM(tuple, 2, d); - } - resultobj = wrapper(a, tuple); - result = resultobj ? 0 : -1; - SWIG_Py_DECREF(tuple); - SWIG_Py_XDECREF(resultobj); - return result; -} - -#define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \ - return SwigPyBuiltin_funpack_ssizeargfunc_closure(wrapper, a, b); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_funpack_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) { - PyObject *tuple, *result; - tuple = PyTuple_New(1); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - result = wrapper(a, tuple); - SWIG_Py_DECREF(tuple); - return result; -} - -#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \ - return SwigPyBuiltin_ssizeargfunc_closure(wrapper, a, b); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) { - PyObject *arg, *result; - arg = _PyLong_FromSsize_t(b); - result = wrapper(a, arg); - SWIG_Py_DECREF(arg); - return result; -} - -#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_ssizeobjargproc_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \ - return SwigPyBuiltin_ssizeobjargproc_closure(wrapper, a, b, c); \ -} -SWIGINTERN int -SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, PyObject *c) { - PyObject *tuple, *resultobj; - int result; - tuple = PyTuple_New(2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - if (c) { - SWIG_Py_INCREF(c); - PyTuple_SET_ITEM(tuple, 1, c); - } - resultobj = wrapper(a, tuple); - result = resultobj ? 0 : -1; - SWIG_Py_XDECREF(resultobj); - SWIG_Py_DECREF(tuple); - return result; -} - -#define SWIGPY_OBJOBJPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ - return SwigPyBuiltin_objobjproc_closure(wrapper, a, b); \ -} -SWIGINTERN int -SwigPyBuiltin_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { - int result; - PyObject *pyresult; - PyObject *tuple; - tuple = PyTuple_New(1); - assert(tuple); - SWIG_Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - pyresult = wrapper(a, tuple); - result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; - SWIG_Py_XDECREF(pyresult); - SWIG_Py_DECREF(tuple); - return result; -} - -#define SWIGPY_FUNPACK_OBJOBJPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ - return SwigPyBuiltin_funpack_objobjproc_closure(wrapper, a, b); \ -} -SWIGINTERN int -SwigPyBuiltin_funpack_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { - int result; - PyObject *pyresult; - pyresult = wrapper(a, b); - result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; - SWIG_Py_XDECREF(pyresult); - return result; -} - -#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \ - return SwigPyBuiltin_objobjargproc_closure(wrapper, a, b, c); \ -} -SWIGINTERN int -SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { - PyObject *tuple, *resultobj; - int result; - tuple = PyTuple_New(c ? 2 : 1); - assert(tuple); - SWIG_Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - if (c) { - SWIG_Py_INCREF(c); - PyTuple_SET_ITEM(tuple, 1, c); - } - resultobj = wrapper(a, tuple); - result = resultobj ? 0 : -1; - SWIG_Py_XDECREF(resultobj); - SWIG_Py_DECREF(tuple); - return result; -} - -#define SWIGPY_REPRFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_reprfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_reprfunc_closure(wrapper, a); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_reprfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ -SWIGINTERN Py_hash_t \ -wrapper##_hashfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_hashfunc_closure(wrapper, a); \ -} -SWIGINTERN Py_hash_t -SwigPyBuiltin_hashfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - PyObject *pyresult; - Py_hash_t result; - pyresult = wrapper(a, NULL); - if (!pyresult) - return -1; - result = SWIG_PyNumber_AsPyHash(pyresult); - SWIG_Py_DECREF(pyresult); - return result; -} - -#define SWIGPY_ITERNEXTFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_iternextfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_iternextfunc_closure(wrapper, a);\ -} -SWIGINTERN PyObject * -SwigPyBuiltin_iternextfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -/* End of callback function macros for use in PyTypeObject */ - -#ifdef __cplusplus -} -#endif - diff --git a/contrib/tools/swig/Lib/python/carrays.i b/contrib/tools/swig/Lib/python/carrays.i deleted file mode 100644 index a7b6120d38e..00000000000 --- a/contrib/tools/swig/Lib/python/carrays.i +++ /dev/null @@ -1,9 +0,0 @@ -%define %array_class(TYPE,NAME) -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "sq_item", functype="ssizeargfunc") NAME::__getitem__; - %feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") NAME::__setitem__; -#endif -%array_class_wrap(TYPE,NAME,__getitem__,__setitem__) -%enddef - -%include <typemaps/carrays.swg> diff --git a/contrib/tools/swig/Lib/python/ccomplex.i b/contrib/tools/swig/Lib/python/ccomplex.i deleted file mode 100644 index b99f96a4890..00000000000 --- a/contrib/tools/swig/Lib/python/ccomplex.i +++ /dev/null @@ -1,27 +0,0 @@ -/* ----------------------------------------------------------------------------- - * ccomplex.i - * - * C complex typemaps - * ISO C99: 7.3 Complex arithmetic <complex.h> - * ----------------------------------------------------------------------------- */ - - -%include <pycomplex.swg> - -%{ -#include <complex.h> -%} - -#define complex _Complex - -/* C complex constructor */ -#define CCplxConst(r, i) ((r) + I*(i)) - -%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag); - -/* declaring the typemaps */ -%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex); diff --git a/contrib/tools/swig/Lib/python/cmalloc.i b/contrib/tools/swig/Lib/python/cmalloc.i deleted file mode 100644 index 248f06b961b..00000000000 --- a/contrib/tools/swig/Lib/python/cmalloc.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/cmalloc.swg> diff --git a/contrib/tools/swig/Lib/python/complex.i b/contrib/tools/swig/Lib/python/complex.i deleted file mode 100644 index 4c3b3c5e2b1..00000000000 --- a/contrib/tools/swig/Lib/python/complex.i +++ /dev/null @@ -1,6 +0,0 @@ -#ifdef __cplusplus -%include <std_complex.i> -#else -%include <ccomplex.i> -#endif - diff --git a/contrib/tools/swig/Lib/python/cpointer.i b/contrib/tools/swig/Lib/python/cpointer.i deleted file mode 100644 index d824792fa7a..00000000000 --- a/contrib/tools/swig/Lib/python/cpointer.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/cpointer.swg> diff --git a/contrib/tools/swig/Lib/python/cstring.i b/contrib/tools/swig/Lib/python/cstring.i deleted file mode 100644 index ede9c596aef..00000000000 --- a/contrib/tools/swig/Lib/python/cstring.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/cstring.swg> diff --git a/contrib/tools/swig/Lib/python/cwstring.i b/contrib/tools/swig/Lib/python/cwstring.i deleted file mode 100644 index 2824d9c7b0f..00000000000 --- a/contrib/tools/swig/Lib/python/cwstring.i +++ /dev/null @@ -1,3 +0,0 @@ -%include <pywstrings.swg> -%include <typemaps/cwstring.swg> - diff --git a/contrib/tools/swig/Lib/python/director.swg b/contrib/tools/swig/Lib/python/director.swg deleted file mode 100644 index c5935695ea2..00000000000 --- a/contrib/tools/swig/Lib/python/director.swg +++ /dev/null @@ -1,359 +0,0 @@ -/* ----------------------------------------------------------------------------- - * director.swg - * - * This file contains support for director classes so that Python proxy - * methods can be called from C++. - * ----------------------------------------------------------------------------- */ - -#ifndef SWIG_DIRECTOR_PYTHON_HEADER_ -#define SWIG_DIRECTOR_PYTHON_HEADER_ - -#include <string> -#include <iostream> -#include <exception> -#include <vector> -#include <map> - -/* - Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual - table', and avoid multiple GetAttr calls to retrieve the python - methods. -*/ - -#ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE -#ifndef SWIG_PYTHON_DIRECTOR_VTABLE -#define SWIG_PYTHON_DIRECTOR_VTABLE -#endif -#endif - - - -/* - Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the - Undefined Exception Handler provided by swig. -*/ -#ifndef SWIG_DIRECTOR_NO_UEH -#ifndef SWIG_DIRECTOR_UEH -#define SWIG_DIRECTOR_UEH -#endif -#endif - - -/* - 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 { - protected: - std::string swig_msg; - public: - DirectorException(PyObject *error, const char *hdr ="", const char *msg ="") : swig_msg(hdr) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (msg[0]) { - swig_msg += " "; - swig_msg += msg; - } - if (!PyErr_Occurred()) { - PyErr_SetString(error, swig_msg.c_str()); - } - SWIG_PYTHON_THREAD_END_BLOCK; - } - - virtual ~DirectorException() throw() { - } - - /* Deprecated, use what() instead */ - const char *getMessage() const { - return what(); - } - - const char *what() const throw() { - return swig_msg.c_str(); - } - - static void raise(PyObject *error, const char *msg) { - throw DirectorException(error, msg); - } - - static void raise(const char *msg) { - raise(PyExc_RuntimeError, msg); - } - }; - - /* type mismatch in the return value from a python method call */ - class DirectorTypeMismatchException : public DirectorException { - public: - DirectorTypeMismatchException(PyObject *error, const char *msg="") - : DirectorException(error, "SWIG director type mismatch", msg) { - } - - DirectorTypeMismatchException(const char *msg="") - : DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) { - } - - static void raise(PyObject *error, const char *msg) { - throw DirectorTypeMismatchException(error, msg); - } - - static void raise(const char *msg) { - throw DirectorTypeMismatchException(msg); - } - }; - - /* any python exception that occurs during a director method call */ - class DirectorMethodException : public DirectorException { - public: - DirectorMethodException(const char *msg = "") - : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) { - } - - static void raise(const char *msg) { - throw DirectorMethodException(msg); - } - }; - - /* attempt to call a pure virtual method via a director method */ - class DirectorPureVirtualException : public DirectorException { - public: - DirectorPureVirtualException(const char *msg = "") - : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) { - } - - static void raise(const char *msg) { - throw DirectorPureVirtualException(msg); - } - }; - - - - /* director base class */ - class Director { - private: - /* pointer to the wrapped python object */ - PyObject *swig_self; - /* flag indicating whether the object is owned by python or c++ */ - mutable bool swig_disown_flag; - - /* decrement the reference count of the wrapped python object */ - void swig_decref() const { - if (swig_disown_flag) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - SWIG_Py_DECREF(swig_self); - SWIG_PYTHON_THREAD_END_BLOCK; - } - } - - public: - /* wrap a python object. */ - Director(PyObject *self) : swig_self(self), swig_disown_flag(false) { - } - - /* discard our reference at destruction */ - virtual ~Director() { - swig_decref(); - } - - /* return a pointer to the wrapped python object */ - PyObject *swig_get_self() const { - return swig_self; - } - - /* acquire ownership of the wrapped python object (the sense of "disown" is from python) */ - void swig_disown() const { - if (!swig_disown_flag) { - swig_disown_flag=true; - swig_incref(); - } - } - - /* increase the reference count of the wrapped python object */ - void swig_incref() const { - if (swig_disown_flag) { - SWIG_Py_INCREF(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; - SWIG_GUARD_DECLARATION(swig_mutex_own); - - public: - template <typename Type> - void swig_acquire_ownership_array(Type *vptr) const { - if (vptr) { - SWIG_GUARD(swig_mutex_own); - swig_owner[vptr] = new GCArray_T<Type>(vptr); - } - } - - template <typename Type> - void swig_acquire_ownership(Type *vptr) const { - if (vptr) { - SWIG_GUARD(swig_mutex_own); - swig_owner[vptr] = new GCItem_T<Type>(vptr); - } - } - - void swig_acquire_ownership_obj(void *vptr, int own) const { - if (vptr && own) { - SWIG_GUARD(swig_mutex_own); - swig_owner[vptr] = new GCItem_Object(own); - } - } - - int swig_release_ownership(void *vptr) const { - int own = 0; - if (vptr) { - SWIG_GUARD(swig_mutex_own); - 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; - } - - template <typename Type> - static PyObject *swig_pyobj_disown(PyObject *pyobj, PyObject *SWIGUNUSEDPARM(args)) { - SwigPyObject *sobj = (SwigPyObject *)pyobj; - sobj->own = 0; - Director *d = SWIG_DIRECTOR_CAST(reinterpret_cast<Type *>(sobj->ptr)); - if (d) - d->swig_disown(); - return PyWeakref_NewProxy(pyobj, NULL); - } - }; - - SWIG_GUARD_DEFINITION(Director, swig_mutex_own); -} - -#endif diff --git a/contrib/tools/swig/Lib/python/director_py_mutex.swg b/contrib/tools/swig/Lib/python/director_py_mutex.swg deleted file mode 100644 index 5bb0f83f26b..00000000000 --- a/contrib/tools/swig/Lib/python/director_py_mutex.swg +++ /dev/null @@ -1,24 +0,0 @@ -/* ----------------------------------------------------------------------------- - * director_py_mutex.swg - * - * contains python mutex for threads - * ----------------------------------------------------------------------------- */ - -#if defined(SWIG_PYTHON_THREADS) && !defined(SWIG_THREADS) -#define SWIG_THREADS 1 -#endif -#if defined(SWIG_THREADS) && !defined(Py_LIMITED_API) -#include "pythread.h" -#define SWIG_HAVE_MUTEX -namespace Swig { - class Mutex - { - PyThread_type_lock mutex_; - public: - Mutex() : mutex_(PyThread_allocate_lock()) {} - ~Mutex() { PyThread_free_lock(mutex_); } - void lock() { PyThread_acquire_lock(mutex_, WAIT_LOCK); } - void unlock() { PyThread_release_lock(mutex_); } - }; -} -#endif diff --git a/contrib/tools/swig/Lib/python/embed.i b/contrib/tools/swig/Lib/python/embed.i deleted file mode 100644 index e5ee601d92f..00000000000 --- a/contrib/tools/swig/Lib/python/embed.i +++ /dev/null @@ -1,113 +0,0 @@ -// -// embed.i -// SWIG file embedding the Python interpreter in something else. -// This file is deprecated and no longer actively maintained, but it still -// seems to work with Python 2.7. It doesn't work with Python 3. -// -// This file makes it possible to extend Python and all of its -// built-in functions without having to hack its setup script. -// -// This module provides support for building a new version of the -// Python executable. This will be necessary on systems that do -// not support shared libraries and may be necessary with C++ -// extensions. This file contains everything you need to build -// a new version of Python from include files and libraries normally -// installed with the Python language. -// -// This module will automatically grab all of the Python modules -// present in your current Python executable (including any special -// purpose modules you have enabled such as Tkinter). Thus, you -// may need to provide additional link libraries when compiling. -// -// As far as I know, this module is C++ safe. - -%wrapper %{ -#if !defined(PY_SSIZE_T_CLEAN) && !defined(SWIG_NO_PY_SSIZE_T_CLEAN) -#define PY_SSIZE_T_CLEAN -#endif - -#if __GNUC__ >= 7 -#pragma GCC diagnostic push -#if defined(__cplusplus) && __cplusplus >=201703L -#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */ -#endif -#endif - -#include <Python.h> - -#if __GNUC__ >= 7 -#pragma GCC diagnostic pop -#endif - -#ifdef __cplusplus -extern "C" -#endif -void SWIG_init(); /* Forward reference */ - -#define _PyImport_Inittab swig_inittab - -/* Grab Python's inittab[] structure */ - -#ifdef __cplusplus -extern "C" { -#endif -#include <config.c> - -#undef _PyImport_Inittab - -/* Now define our own version of it. - Hopefully someone does not have more than 1000 built-in modules */ - -struct _inittab SWIG_Import_Inittab[1000]; - -static int swig_num_modules = 0; - -/* Function for adding modules to Python */ - -static void swig_add_module(char *name, void (*initfunc)()) { - SWIG_Import_Inittab[swig_num_modules].name = name; - SWIG_Import_Inittab[swig_num_modules].initfunc = initfunc; - swig_num_modules++; - SWIG_Import_Inittab[swig_num_modules].name = (char *) 0; - SWIG_Import_Inittab[swig_num_modules].initfunc = 0; -} - -/* Function to add all of Python's built-in modules to our interpreter */ - -static void swig_add_builtin() { - int i = 0; - while (swig_inittab[i].name) { - swig_add_module(swig_inittab[i].name, swig_inittab[i].initfunc); - i++; - } -#ifdef SWIGMODINIT - SWIGMODINIT -#endif - /* Add SWIG builtin function */ - swig_add_module(SWIG_name, SWIG_init); -} - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -extern int Py_Main(int, char **); - -#ifdef __cplusplus -} -#endif - -extern struct _inittab *PyImport_Inittab; - -int -main(int argc, char **argv) { - swig_add_builtin(); - PyImport_Inittab = SWIG_Import_Inittab; - return Py_Main(argc,argv); -} - -%} diff --git a/contrib/tools/swig/Lib/python/exception.i b/contrib/tools/swig/Lib/python/exception.i deleted file mode 100644 index bb0b15c9dde..00000000000 --- a/contrib/tools/swig/Lib/python/exception.i +++ /dev/null @@ -1,6 +0,0 @@ -%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/python/factory.i b/contrib/tools/swig/Lib/python/factory.i deleted file mode 100644 index 46a0a8733e7..00000000000 --- a/contrib/tools/swig/Lib/python/factory.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/factory.swg> diff --git a/contrib/tools/swig/Lib/python/file.i b/contrib/tools/swig/Lib/python/file.i deleted file mode 100644 index 359c34d2c50..00000000000 --- a/contrib/tools/swig/Lib/python/file.i +++ /dev/null @@ -1,41 +0,0 @@ -/* ----------------------------------------------------------------------------- - * file.i - * - * Typemaps for FILE* - * ----------------------------------------------------------------------------- */ - -%types(FILE *); - -/* defining basic methods */ -%fragment("SWIG_AsValFilePtr","header") { -SWIGINTERN int -SWIG_AsValFilePtr(PyObject *obj, FILE **val) { - static swig_type_info* desc = 0; - void *vptr = 0; - if (!desc) desc = SWIG_TypeQuery("FILE *"); - if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { - if (val) *val = (FILE *)vptr; - return SWIG_OK; - } -%#if PY_VERSION_HEX < 0x03000000 - if (PyFile_Check(obj)) { - if (val) *val = PyFile_AsFile(obj); - return SWIG_OK; - } -%#endif - return SWIG_TypeError; -} -} - - -%fragment("SWIG_AsFilePtr","header",fragment="SWIG_AsValFilePtr") { -SWIGINTERNINLINE FILE* -SWIG_AsFilePtr(PyObject *obj) { - FILE *val = 0; - SWIG_AsValFilePtr(obj, &val); - return val; -} -} - -/* defining the typemaps */ -%typemaps_asval(%checkcode(POINTER), SWIG_AsValFilePtr, "SWIG_AsValFilePtr", FILE*); diff --git a/contrib/tools/swig/Lib/python/implicit.i b/contrib/tools/swig/Lib/python/implicit.i deleted file mode 100644 index 152c2b0566b..00000000000 --- a/contrib/tools/swig/Lib/python/implicit.i +++ /dev/null @@ -1,7 +0,0 @@ -%include <std_common.i> -%include <typemaps/implicit.swg> - -#warning "This file provides the %implicit directive, which is an old and fragile" -#warning "way to implement the C++ implicit conversion mechanism." -#warning "Try using the more robust '%implicitconv Type;' directive instead." - diff --git a/contrib/tools/swig/Lib/python/pyabc.i b/contrib/tools/swig/Lib/python/pyabc.i deleted file mode 100644 index cae1e7032ff..00000000000 --- a/contrib/tools/swig/Lib/python/pyabc.i +++ /dev/null @@ -1,14 +0,0 @@ -%define %pythonabc(Type, Abc) - %feature("python:abc", Abc) Type; -%enddef -%pythoncode %{if _swig_python_version_info[0:2] >= (3, 3): - import collections.abc -else: - import collections -%} -%pythonabc(std::vector, "collections.abc.MutableSequence if _swig_python_version_info >= (3, 3) else collections.MutableSequence"); -%pythonabc(std::list, "collections.abc.MutableSequence if _swig_python_version_info >= (3, 3) else collections.MutableSequence"); -%pythonabc(std::map, "collections.abc.MutableMapping if _swig_python_version_info >= (3, 3) else collections.MutableMapping"); -%pythonabc(std::multimap, "collections.abc.MutableMapping if _swig_python_version_info >= (3, 3) else collections.MutableMapping"); -%pythonabc(std::set, "collections.abc.MutableSet if _swig_python_version_info >= (3, 3) else collections.MutableSet"); -%pythonabc(std::multiset, "collections.abc.MutableSet if _swig_python_version_info >= (3, 3) else collections.MutableSet"); diff --git a/contrib/tools/swig/Lib/python/pyapi.swg b/contrib/tools/swig/Lib/python/pyapi.swg deleted file mode 100644 index 19e6979b56d..00000000000 --- a/contrib/tools/swig/Lib/python/pyapi.swg +++ /dev/null @@ -1,30 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - const char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - -#ifdef __cplusplus -} -#endif - diff --git a/contrib/tools/swig/Lib/python/pybackward.swg b/contrib/tools/swig/Lib/python/pybackward.swg deleted file mode 100644 index 8305fc78b7c..00000000000 --- a/contrib/tools/swig/Lib/python/pybackward.swg +++ /dev/null @@ -1,45 +0,0 @@ -/* - adding backward compatibility macros -*/ - -#define SWIG_arg(x...) %arg(x) -#define SWIG_Mangle(x...) %mangle(x) - -#define SWIG_As_frag(Type...) %fragment_name(As, Type) -#define SWIG_As_name(Type...) %symbol_name(As, Type) -#define SWIG_As(Type...) SWIG_As_name(Type) SWIG_AS_CALL_ARGS - -#define SWIG_Check_frag(Type...) %fragment_name(Check, Type) -#define SWIG_Check_name(Type...) %symbol_name(Check, Type) -#define SWIG_Check(Type...) SWIG_Check_name(Type) SWIG_AS_CALL_ARGS - -%define %ascheck_methods(Code, Type...) -%fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) { -SWIGINTERNINLINE Type -SWIG_As(Type)(PyObject* obj) -{ - Type v; - int res = SWIG_AsVal(Type)(obj, &v); - if (!SWIG_IsOK(res)) { - /* - this is needed to make valgrind/purify happier. - */ - memset((void*)&v, 0, sizeof(Type)); - SWIG_Error(res, ""); - } - return v; -} -} - -%fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) { -SWIGINTERNINLINE int -SWIG_Check(Type)(PyObject* obj) -{ - int res = SWIG_AsVal(Type)(obj, (Type*)0); - return SWIG_IsOK(res); -} -} -%enddef - -%apply_checkctypes(%ascheck_methods) - diff --git a/contrib/tools/swig/Lib/python/pybuffer.i b/contrib/tools/swig/Lib/python/pybuffer.i deleted file mode 100644 index 9ebc36a8c4e..00000000000 --- a/contrib/tools/swig/Lib/python/pybuffer.i +++ /dev/null @@ -1,203 +0,0 @@ -/* Implementing buffer protocol typemaps */ - -/* %pybuffer_mutable_binary(TYPEMAP, SIZE) - * - * Macro for functions accept mutable buffer pointer with a size. - * This can be used for both input and output. For example: - * - * %pybuffer_mutable_binary(char *buff, int size); - * void foo(char *buff, int size) { - * for(int i=0; i<size; ++i) - * buff[i]++; - * } - */ - -/* Note that in Py_LIMITED_API case we have no choice, but to use deprecated - * functions, as they provides the only way to access buffer data with limited - * API, which doesn't include Py_buffer definition. We also disable the - * warnings about doing this because they're not useful in our case. - */ - -%define %pybuffer_mutable_binary(TYPEMAP, SIZE) -%typemap(in) (TYPEMAP, SIZE) { - int res; Py_ssize_t size = 0; void *buf = 0; -%#ifndef Py_LIMITED_API - Py_buffer view; - res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); -%#else - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic push - %#pragma GCC diagnostic ignored "-Wdeprecated" - %#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - %#elif defined(_MSC_VER) - %#pragma warning(push) - %#pragma warning(disable: 4996) - %#endif - res = PyObject_AsWriteBuffer($input, &buf, &size); - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic pop - %#elif defined(_MSC_VER) - %#pragma warning(pop) - %#endif -%#endif - if (res < 0) { - PyErr_Clear(); - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); - } -%#ifndef Py_LIMITED_API - size = view.len; - buf = view.buf; - PyBuffer_Release(&view); -%#endif - $1 = ($1_ltype) buf; - $2 = ($2_ltype) (size/sizeof($*1_type)); -} -%enddef - -/* %pybuffer_mutable_string(TYPEMAP) - * - * Macro for functions accept mutable zero terminated string pointer. - * This can be used for both input and output. For example: - * - * %pybuffer_mutable_string(char *str); - * void foo(char *str) { - * while(*str) { - * *str = toupper(*str); - * str++; - * } - */ - -%define %pybuffer_mutable_string(TYPEMAP) -%typemap(in) (TYPEMAP) { - int res; void *buf = 0; -%#ifndef Py_LIMITED_API - Py_buffer view; - res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); -%#else - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic push - %#pragma GCC diagnostic ignored "-Wdeprecated" - %#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - %#elif defined(_MSC_VER) - %#pragma warning(push) - %#pragma warning(disable: 4996) - %#endif - Py_ssize_t size; - res = PyObject_AsWriteBuffer($input, &buf, &size); - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic pop - %#elif defined(_MSC_VER) - %#pragma warning(pop) - %#endif -%#endif - if (res < 0) { - PyErr_Clear(); - %argument_fail(res, "(TYPEMAP)", $symname, $argnum); - } -%#ifndef Py_LIMITED_API - buf = view.buf; - PyBuffer_Release(&view); -%#endif - $1 = ($1_ltype) buf; -} -%enddef - -/* pybuffer_binary(TYPEMAP, SIZE) - * - * Macro for functions accept read only buffer pointer with a size. - * This must be used for input. For example: - * - * %pybuffer_binary(char *buff, int size); - * int foo(char *buff, int size) { - * int count = 0; - * for(int i=0; i<size; ++i) - * if (0==buff[i]) count++; - * return count; - * } - */ - -%define %pybuffer_binary(TYPEMAP, SIZE) -%typemap(in) (TYPEMAP, SIZE) { - int res; Py_ssize_t size = 0; const void *buf = 0; -%#ifndef Py_LIMITED_API - Py_buffer view; - res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); -%#else - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic push - %#pragma GCC diagnostic ignored "-Wdeprecated" - %#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - %#elif defined(_MSC_VER) - %#pragma warning(push) - %#pragma warning(disable: 4996) - %#endif - res = PyObject_AsReadBuffer($input, &buf, &size); - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic pop - %#elif defined(_MSC_VER) - %#pragma warning(pop) - %#endif -%#endif - if (res < 0) { - PyErr_Clear(); - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); - } -%#ifndef Py_LIMITED_API - size = view.len; - buf = view.buf; - PyBuffer_Release(&view); -%#endif - $1 = ($1_ltype) buf; - $2 = ($2_ltype) (size / sizeof($*1_type)); -} -%enddef - -/* %pybuffer_string(TYPEMAP) - * - * Macro for functions accept read only zero terminated string pointer. - * This can be used for input. For example: - * - * %pybuffer_string(char *str); - * int foo(char *str) { - * int count = 0; - * while(*str) { - * if (isalnum(*str)) - * count++; - * str++; - * } - */ - -%define %pybuffer_string(TYPEMAP) -%typemap(in) (TYPEMAP) { - int res; const void *buf = 0; -%#ifndef Py_LIMITED_API - Py_buffer view; - res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); -%#else - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic push - %#pragma GCC diagnostic ignored "-Wdeprecated" - %#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - %#elif defined(_MSC_VER) - %#pragma warning(push) - %#pragma warning(disable: 4996) - %#endif - Py_ssize_t size; - res = PyObject_AsReadBuffer($input, &buf, &size); - %#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - %#pragma GCC diagnostic pop - %#elif defined(_MSC_VER) - %#pragma warning(pop) - %#endif -%#endif - if (res < 0) { - PyErr_Clear(); - %argument_fail(res, "(TYPEMAP)", $symname, $argnum); - } -%#ifndef Py_LIMITED_API - buf = view.buf; - PyBuffer_Release(&view); -%#endif - $1 = ($1_ltype) buf; -} -%enddef diff --git a/contrib/tools/swig/Lib/python/pyclasses.swg b/contrib/tools/swig/Lib/python/pyclasses.swg deleted file mode 100644 index 7a9d093657c..00000000000 --- a/contrib/tools/swig/Lib/python/pyclasses.swg +++ /dev/null @@ -1,157 +0,0 @@ -#ifdef __cplusplus - -/* - SwigPtr_PyObject is used as a replacement of PyObject *, where - the INCREF/DECREF are applied as needed. - - You can use SwigPtr_PyObject in a container, such as - - std::vector<SwigPtr_PyObject>; - - or as a member variable: - - struct A { - SwigPtr_PyObject _obj; - A(PyObject *o) : _obj(o) { - } - }; - - or as a input/output value - - SwigPtr_PyObject func(SwigPtr_PyObject obj) { - SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); - SWIG_Py_DECREF(out); - return out; - } - - just remember to pair the object creation with the proper DECREF, - the same as with plain PyObject *ptr, since SwigPtr_PyObject always add - one reference at construction. - - SwigPtr_PyObject is 'visible' at the wrapped side, so you can do: - - - %template(pyvector) std::vector<swig::SwigPtr_PyObject>; - - and all the proper typemaps will be used. - -*/ - -namespace swig { - %ignore SwigPtr_PyObject; - struct SwigPtr_PyObject {}; - %apply PyObject * {SwigPtr_PyObject}; - %apply PyObject * const& {SwigPtr_PyObject const&}; - - %typemap(typecheck,precedence=SWIG_TYPECHECK_SWIGOBJECT,noblock=1) SwigPtr_PyObject const& "$1 = ($input != 0);" - - - /* For output */ - %typemap(out,noblock=1) SwigPtr_PyObject { - $result = (PyObject *)$1; - SWIG_Py_INCREF($result); - } - - %typemap(out,noblock=1) SwigPtr_PyObject const & { - $result = (PyObject *)*$1; - SWIG_Py_INCREF($result); - } - -} - -%{ -namespace swig { - class SwigPtr_PyObject { - protected: - PyObject *_obj; - - public: - SwigPtr_PyObject() :_obj(0) - { - } - - SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - SWIG_Py_XINCREF(_obj); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) - { - if (initial_ref) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - SWIG_Py_XINCREF(_obj); - SWIG_PYTHON_THREAD_END_BLOCK; - } - } - - SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - SWIG_Py_XINCREF(item._obj); - SWIG_Py_XDECREF(_obj); - _obj = item._obj; - SWIG_PYTHON_THREAD_END_BLOCK; - return *this; - } - - ~SwigPtr_PyObject() - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - SWIG_Py_XDECREF(_obj); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - operator PyObject *() const - { - return _obj; - } - - PyObject *operator->() const - { - return _obj; - } - }; -} -%} - -/* - SwigVar_PyObject is used to manage 'in the scope' PyObject * variables, - as in - - int func () { - SwigVar_PyObject obj = PyString_FromString("hello"); - } - - ie, 'obj' is created and destructed in the same scope from - a python object that carries at least one reference value. - - SwigVar_PyObject just take care of applying the proper Py_DECREF. - - Hence, this class is purely internal and not visible at the wrapped side. - */ -namespace swig { - %ignore SwigVar_PyObject; - struct SwigVar_PyObject {}; - %apply PyObject * {SwigVar_PyObject}; - %apply PyObject * const& {SwigVar_PyObject const&}; -} - -%{ -namespace swig { - struct SwigVar_PyObject : SwigPtr_PyObject { - SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } - - SwigVar_PyObject & operator = (PyObject* obj) - { - SWIG_Py_XDECREF(_obj); - _obj = obj; - return *this; - } - }; -} -%} - - -#endif diff --git a/contrib/tools/swig/Lib/python/pycomplex.swg b/contrib/tools/swig/Lib/python/pycomplex.swg deleted file mode 100644 index eeb9af7be07..00000000000 --- a/contrib/tools/swig/Lib/python/pycomplex.swg +++ /dev/null @@ -1,90 +0,0 @@ -/* - Defines the As/From converters for double/float complex, you need to - provide complex Type, the Name you want to use in the converters, - the complex Constructor method, and the Real and Imag complex - accessor methods. - - See the std_complex.i and ccomplex.i for concrete examples. -*/ - -/* the common from converter */ -%define %swig_fromcplx_conv(Type, Real, Imag) -%fragment(SWIG_From_frag(Type),"header") -{ -SWIGINTERNINLINE PyObject* -#if defined(__cplusplus) -SWIG_From_dec(Type)(const Type& c) -#else -SWIG_From_dec(Type)(Type c) -#endif -{ - return PyComplex_FromDoubles(Real(c), Imag(c)); -} -} -%enddef - -/* the double case */ -%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag) -%fragment(SWIG_AsVal_frag(Type),"header", - fragment=SWIG_AsVal_frag(double)) -{ -SWIGINTERN int -SWIG_AsVal(Type) (PyObject *o, Type* val) -{ - if (PyComplex_Check(o)) { - if (val) *val = Constructor(PyComplex_RealAsDouble(o), PyComplex_ImagAsDouble(o)); - return SWIG_OK; - } else { - double d; - int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d)); - if (SWIG_IsOK(res)) { - if (val) *val = Constructor(d, 0.0); - return res; - } - } - return SWIG_TypeError; -} -} -%swig_fromcplx_conv(Type, Real, Imag); -%enddef - -/* the float case */ -%define %swig_cplxflt_conv(Type, Constructor, Real, Imag) -%fragment(SWIG_AsVal_frag(Type),"header", - fragment=SWIG_AsVal_frag(float)) { -SWIGINTERN int -SWIG_AsVal(Type)(PyObject *o, Type *val) -{ - if (PyComplex_Check(o)) { - double re = PyComplex_RealAsDouble(o); - double im = PyComplex_ImagAsDouble(o); - if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) { - if (val) *val = Constructor(%numeric_cast(re, float), - %numeric_cast(im, float)); - return SWIG_OK; - } else { - return SWIG_OverflowError; - } - } else { - float re; - int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re)); - if (SWIG_IsOK(res)) { - if (val) *val = Constructor(re, 0.0f); - return res; - } - } - return SWIG_TypeError; -} -} - -%swig_fromcplx_conv(Type, Real, Imag); -%enddef - -#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \ -%swig_cplxflt_conv(Type, Constructor, Real, Imag) - - -#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \ -%swig_cplxdbl_conv(Type, Constructor, Real, Imag) - - diff --git a/contrib/tools/swig/Lib/python/pycontainer.swg b/contrib/tools/swig/Lib/python/pycontainer.swg deleted file mode 100644 index 12a45bfc89d..00000000000 --- a/contrib/tools/swig/Lib/python/pycontainer.swg +++ /dev/null @@ -1,871 +0,0 @@ -/* ----------------------------------------------------------------------------- - * pycontainer.swg - * - * Python sequence <-> C++ container wrapper - * - * This wrapper, and its iterator, allows a general use (and reuse) of - * the mapping between C++ and Python, thanks to the C++ templates. - * - * Of course, it needs the C++ compiler to support templates, but - * since we will use this wrapper with the STL containers, that should - * be the case. - * ----------------------------------------------------------------------------- */ - -%{ -#include <iostream> - -#if PY_VERSION_HEX >= 0x03020000 -# define SWIGPY_SLICEOBJECT PyObject -#else -# define SWIGPY_SLICEOBJECT PySliceObject -#endif -%} - - -#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) -# if !defined(SWIG_EXPORT_ITERATOR_METHODS) -# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS -# endif -#endif - -%include <pyiterators.swg> - -/**** The PySequence C++ Wrap ***/ - -%fragment("<stdexcept>"); - -%include <std_except.i> - -%fragment("container_owner_attribute_init", "init") { - // thread safe initialization - swig::container_owner_attribute(); -} - -%fragment("reference_container_owner", "header", fragment="container_owner_attribute_init") { -namespace swig { - static PyObject* container_owner_attribute() { - static PyObject* attr = SWIG_Python_str_FromChar("__swig_container"); - return attr; - } - - template <typename T> - struct container_owner { - // By default, do not add the back-reference (for value types) - // Specialization below will check the reference for pointer types. - static bool back_reference(PyObject* /*child*/, PyObject* /*owner*/) { - return false; - } - }; - - template <> - struct container_owner<swig::pointer_category> { - /* - * Call to add a back-reference to the owning object when returning a - * reference from a container. Will only set the reference if child - * is a SWIG wrapper object that does not own the pointer. - * - * returns whether the reference was set or not - */ - static bool back_reference(PyObject* child, PyObject* owner) { - SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); - if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { - return PyObject_SetAttr(child, container_owner_attribute(), owner) != -1; - } - return false; - } - }; -} -} - -%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { -namespace swig { - template <> struct traits<SwigPtr_PyObject > { - typedef value_category category; - static const char* type_name() { return "SwigPtr_PyObject"; } - }; - - template <> struct traits_from<SwigPtr_PyObject> { - typedef SwigPtr_PyObject value_type; - static PyObject *from(const value_type& val) { - PyObject *obj = static_cast<PyObject *>(val); - SWIG_Py_XINCREF(obj); - return obj; - } - }; - - template <> - struct traits_check<SwigPtr_PyObject, value_category> { - static bool check(SwigPtr_PyObject) { - return true; - } - }; - - template <> struct traits_asval<SwigPtr_PyObject > { - typedef SwigPtr_PyObject value_type; - static int asval(PyObject *obj, value_type *val) { - if (val) *val = obj; - return SWIG_OK; - } - }; -} -} - -%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") { -namespace swig { - template <> struct traits<SwigVar_PyObject > { - typedef value_category category; - static const char* type_name() { return "SwigVar_PyObject"; } - }; - - template <> struct traits_from<SwigVar_PyObject> { - typedef SwigVar_PyObject value_type; - static PyObject *from(const value_type& val) { - PyObject *obj = static_cast<PyObject *>(val); - SWIG_Py_XINCREF(obj); - return obj; - } - }; - - template <> - struct traits_check<SwigVar_PyObject, value_category> { - static bool check(SwigVar_PyObject) { - return true; - } - }; - - template <> struct traits_asval<SwigVar_PyObject > { - typedef SwigVar_PyObject value_type; - static int asval(PyObject *obj, value_type *val) { - if (val) *val = obj; - return SWIG_OK; - } - }; -} -} - -%fragment("SwigPySequence_Base","header",fragment="<stddef.h>",fragment="StdTraits") -{ -%#include <functional> - -namespace std { - template <> - struct less <PyObject *> - { - bool - operator()(PyObject * v, PyObject *w) const - { - bool res; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false; - /* This may fall into a case of inconsistent - eg. ObjA > ObjX > ObjB - but ObjA < ObjB - */ - if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) - { - /* Objects can't be compared, this mostly occurred in Python 3.0 */ - /* Compare their ptr directly for a workaround */ - res = (v < w); - PyErr_Clear(); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return res; - } - }; - - template <> - struct less <swig::SwigPtr_PyObject> - { - bool - operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const - { - return std::less<PyObject *>()(v, w); - } - }; - - template <> - struct less <swig::SwigVar_PyObject> - { - bool - operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const - { - return std::less<PyObject *>()(v, w); - } - }; - -} - -namespace swig { - template <> struct traits<PyObject *> { - typedef value_category category; - static const char* type_name() { return "PyObject *"; } - }; - - template <> struct traits_asval<PyObject * > { - typedef PyObject * value_type; - static int asval(PyObject *obj, value_type *val) { - if (val) *val = obj; - return SWIG_OK; - } - }; - - template <> - struct traits_check<PyObject *, value_category> { - static bool check(PyObject *) { - return true; - } - }; - - template <> struct traits_from<PyObject *> { - typedef PyObject * value_type; - static PyObject *from(const value_type& val) { - SWIG_Py_XINCREF(val); - return val; - } - }; - -} - -namespace swig { - template <class Difference> - inline size_t - check_index(Difference i, size_t size, bool insert = false) { - if ( i < 0 ) { - if ((size_t) (-i) <= size) - return (size_t) (i + size); - } else if ( (size_t) i < size ) { - return (size_t) i; - } else if (insert && ((size_t) i == size)) { - return size; - } - throw std::out_of_range("index out of range"); - } - - template <class Difference> - void - slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) { - if (step == 0) { - throw std::invalid_argument("slice step cannot be zero"); - } else if (step > 0) { - // Required range: 0 <= i < size, 0 <= j < size, i <= j - if (i < 0) { - ii = 0; - } else if (i < (Difference)size) { - ii = i; - } else if (insert && (i >= (Difference)size)) { - ii = (Difference)size; - } - if (j < 0) { - jj = 0; - } else { - jj = (j < (Difference)size) ? j : (Difference)size; - } - if (jj < ii) - jj = ii; - } else { - // Required range: -1 <= i < size-1, -1 <= j < size-1, i >= j - if (i < -1) { - ii = -1; - } else if (i < (Difference) size) { - ii = i; - } else if (i >= (Difference)(size-1)) { - ii = (Difference)(size-1); - } - if (j < -1) { - jj = -1; - } else { - jj = (j < (Difference)size ) ? j : (Difference)(size-1); - } - if (ii < jj) - ii = jj; - } - } - - template <class Sequence, class Difference> - inline typename Sequence::iterator - getpos(Sequence* self, Difference i) { - typename Sequence::iterator pos = self->begin(); - std::advance(pos, check_index(i,self->size())); - return pos; - } - - template <class Sequence, class Difference> - inline typename Sequence::const_iterator - cgetpos(const Sequence* self, Difference i) { - typename Sequence::const_iterator pos = self->begin(); - std::advance(pos, check_index(i,self->size())); - return pos; - } - - template <class Sequence> - inline void - erase(Sequence* seq, const typename Sequence::iterator& position) { - seq->erase(position); - } - - template <class Sequence> - struct traits_reserve { - static void reserve(Sequence & /*seq*/, typename Sequence::size_type /*n*/) { - // This should be specialized for types that support reserve - } - }; - - template <class Sequence, class Difference> - inline Sequence* - getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) { - typename Sequence::size_type size = self->size(); - Difference ii = 0; - Difference jj = 0; - swig::slice_adjust(i, j, step, size, ii, jj); - - if (step > 0) { - typename Sequence::const_iterator sb = self->begin(); - typename Sequence::const_iterator se = self->begin(); - std::advance(sb,ii); - std::advance(se,jj); - if (step == 1) { - return new Sequence(sb, se); - } else { - Sequence *sequence = new Sequence(); - swig::traits_reserve<Sequence>::reserve(*sequence, (jj - ii + step - 1) / step); - typename Sequence::const_iterator it = sb; - while (it!=se) { - sequence->push_back(*it); - for (Py_ssize_t c=0; c<step && it!=se; ++c) - it++; - } - return sequence; - } - } else { - Sequence *sequence = new Sequence(); - swig::traits_reserve<Sequence>::reserve(*sequence, (ii - jj - step - 1) / -step); - typename Sequence::const_reverse_iterator sb = self->rbegin(); - typename Sequence::const_reverse_iterator se = self->rbegin(); - std::advance(sb,size-ii-1); - std::advance(se,size-jj-1); - typename Sequence::const_reverse_iterator it = sb; - while (it!=se) { - sequence->push_back(*it); - for (Py_ssize_t c=0; c<-step && it!=se; ++c) - it++; - } - return sequence; - } - } - - template <class Sequence, class Difference, class InputSeq> - inline void - setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { - typename Sequence::size_type size = self->size(); - Difference ii = 0; - Difference jj = 0; - swig::slice_adjust(i, j, step, size, ii, jj, true); - if (step > 0) { - if (step == 1) { - size_t ssize = jj - ii; - if (ssize <= is.size()) { - // expanding/staying the same size - swig::traits_reserve<Sequence>::reserve(*self, self->size() - ssize + is.size()); - typename Sequence::iterator sb = self->begin(); - typename InputSeq::const_iterator isit = is.begin(); - std::advance(sb,ii); - std::advance(isit, jj - ii); - self->insert(std::copy(is.begin(), isit, sb), isit, is.end()); - } else { - // shrinking - typename Sequence::iterator sb = self->begin(); - typename Sequence::iterator se = self->begin(); - std::advance(sb,ii); - std::advance(se,jj); - self->erase(sb,se); - sb = self->begin(); - std::advance(sb,ii); - self->insert(sb, is.begin(), is.end()); - } - } else { - size_t replacecount = (jj - ii + step - 1) / step; - if (is.size() != replacecount) { - char msg[1024]; - PyOS_snprintf(msg, sizeof(msg), "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); - throw std::invalid_argument(msg); - } - typename Sequence::const_iterator isit = is.begin(); - typename Sequence::iterator it = self->begin(); - std::advance(it,ii); - for (size_t rc=0; rc<replacecount && it != self->end(); ++rc) { - *it++ = *isit++; - for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) - it++; - } - } - } else { - size_t replacecount = (ii - jj - step - 1) / -step; - if (is.size() != replacecount) { - char msg[1024]; - PyOS_snprintf(msg, sizeof(msg), "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); - throw std::invalid_argument(msg); - } - typename Sequence::const_iterator isit = is.begin(); - typename Sequence::reverse_iterator it = self->rbegin(); - std::advance(it,size-ii-1); - for (size_t rc=0; rc<replacecount && it != self->rend(); ++rc) { - *it++ = *isit++; - for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) - it++; - } - } - } - - template <class Sequence, class Difference> - inline void - delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) { - typename Sequence::size_type size = self->size(); - Difference ii = 0; - Difference jj = 0; - swig::slice_adjust(i, j, step, size, ii, jj, true); - if (step > 0) { - typename Sequence::iterator sb = self->begin(); - std::advance(sb,ii); - if (step == 1) { - typename Sequence::iterator se = self->begin(); - std::advance(se,jj); - self->erase(sb,se); - } else { - typename Sequence::iterator it = sb; - size_t delcount = (jj - ii + step - 1) / step; - while (delcount) { - it = self->erase(it); - for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) - it++; - delcount--; - } - } - } else { - typename Sequence::reverse_iterator sb = self->rbegin(); - std::advance(sb,size-ii-1); - typename Sequence::reverse_iterator it = sb; - size_t delcount = (ii - jj - step - 1) / -step; - while (delcount) { - it = typename Sequence::reverse_iterator(self->erase((++it).base())); - for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) - it++; - delcount--; - } - } - } -} -} - -%define %swig_sequence_iterator(Sequence...) - %swig_sequence_iterator_with_making_function(swig::make_output_iterator,Sequence...) -%enddef - -%define %swig_sequence_forward_iterator(Sequence...) - %swig_sequence_iterator_with_making_function(swig::make_output_forward_iterator,Sequence...) -%enddef - -%define %swig_sequence_iterator_with_making_function(Make_output_iterator,Sequence...) -#if defined(SWIG_EXPORT_ITERATOR_METHODS) - class iterator; - class reverse_iterator; - class const_iterator; - class const_reverse_iterator; - - %typemap(out,noblock=1,fragment="SwigPyIterator_T") - iterator, reverse_iterator, const_iterator, const_reverse_iterator { - $result = SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &)), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); - } - %typemap(out,noblock=1,fragment="SwigPyIterator_T") - std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> { - $result = PyTuple_New(2); - PyTuple_SetItem($result,0,SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &).first), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); - PyTuple_SetItem($result,1,SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &).second), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); - } - - %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPyIterator_T") {} - - %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator") - std::pair<iterator, bool>, std::pair<const_iterator, bool> { - $result = PyTuple_New(2); - PyTuple_SetItem($result,0,SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &).first), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); - PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); - } - - %typemap(in,noblock=1,fragment="SwigPyIterator_T") - iterator(swig::SwigPyIterator *iter = 0, int res), - reverse_iterator(swig::SwigPyIterator *iter = 0, int res), - const_iterator(swig::SwigPyIterator *iter = 0, int res), - const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) { - res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); - if (!SWIG_IsOK(res) || !iter) { - %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); - } else { - swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter); - if (iter_t) { - $1 = iter_t->get_current(); - } else { - %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); - } - } - } - - %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPyIterator_T") - iterator, reverse_iterator, const_iterator, const_reverse_iterator { - swig::SwigPyIterator *iter = 0; - int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); - $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter) != 0)); - } - - %fragment("SwigPyIterator_T"); - - %newobject iterator(PyObject **PYTHON_SELF); - %extend { - swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) { - return Make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "tp_iter", functype="getiterfunc") iterator; -#else - %pythoncode %{def __iter__(self): - return self.iterator()%} -#endif - } - -#endif //SWIG_EXPORT_ITERATOR_METHODS -%enddef - - -/**** The python container methods ****/ - -%define %swig_container_methods(Container...) - -/* deprecated in Python 2 */ -#if 1 - %newobject __getslice__; -#endif - %newobject __getitem__(SWIGPY_SLICEOBJECT *slice); - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "nb_nonzero", functype="inquiry") __nonzero__; - %feature("python:slot", "sq_length", functype="lenfunc") __len__; -#endif // SWIGPYTHON_BUILTIN - - %extend { - bool __nonzero__() const { - return !(self->empty()); - } - - /* Alias for Python 3 compatibility */ - bool __bool__() const { - return !(self->empty()); - } - - size_type __len__() const { - return self->size(); - } - - // Although __getitem__, front, back actually use a const value_type& return type, the typemaps below - // use non-const so that they can be easily overridden by users if necessary. - %typemap(ret, fragment="reference_container_owner", noblock=1) value_type& __getitem__, value_type& front, value_type& back { - (void)swig::container_owner<swig::traits<$*1_ltype>::category>::back_reference($result, $self); - } - } -%enddef - - - -%define %swig_sequence_methods_common(Sequence...) - %swig_sequence_iterator(%arg(Sequence)) - %swig_container_methods(%arg(Sequence)) - - %fragment("SwigPySequence_Base"); - -#if defined(SWIGPYTHON_BUILTIN) - //%feature("python:slot", "sq_item", functype="ssizeargfunc") __getitem__; - //%feature("python:slot", "sq_slice", functype="ssizessizeargfunc") __getslice__; - //%feature("python:slot", "sq_ass_item", functype="ssizeobjargproc") __setitem__; - //%feature("python:slot", "sq_ass_slice", functype="ssizessizeobjargproc") __setslice__; - %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; - %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; -#endif // SWIGPYTHON_BUILTIN - - %extend { - /* typemap for slice object support */ - %typemap(in) SWIGPY_SLICEOBJECT* { - if (!PySlice_Check($input)) { - %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); - } - $1 = (SWIGPY_SLICEOBJECT *) $input; - } - %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) SWIGPY_SLICEOBJECT* { - $1 = PySlice_Check($input); - } - -/* deprecated in Python 2 */ -#if 1 - Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { - return swig::getslice(self, i, j, 1); - } - - void __setslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { - swig::setslice(self, i, j, 1, Sequence()); - } - - void __setslice__(difference_type i, difference_type j, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { - swig::setslice(self, i, j, 1, v); - } - - void __delslice__(difference_type i, difference_type j) throw (std::out_of_range, std::invalid_argument) { - swig::delslice(self, i, j, 1); - } -#endif - - void __delitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { - swig::erase(self, swig::getpos(self, i)); - } - - /* Overloaded methods for Python 3 compatibility - * (Also useful in Python 2.x) - */ - Sequence* __getitem__(SWIGPY_SLICEOBJECT *slice) throw (std::out_of_range, std::invalid_argument) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return NULL; - } - PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); - Sequence::difference_type id = i; - Sequence::difference_type jd = j; - return swig::getslice(self, id, jd, step); - } - - void __setitem__(SWIGPY_SLICEOBJECT *slice, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return; - } - PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); - Sequence::difference_type id = i; - Sequence::difference_type jd = j; - swig::setslice(self, id, jd, step, v); - } - - void __setitem__(SWIGPY_SLICEOBJECT *slice) throw (std::out_of_range, std::invalid_argument) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return; - } - PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); - Sequence::difference_type id = i; - Sequence::difference_type jd = j; - swig::delslice(self, id, jd, step); - } - - void __delitem__(SWIGPY_SLICEOBJECT *slice) throw (std::out_of_range, std::invalid_argument) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return; - } - PySlice_GetIndices(slice, (Py_ssize_t)self->size(), &i, &j, &step); - Sequence::difference_type id = i; - Sequence::difference_type jd = j; - swig::delslice(self, id, jd, step); - } - - } -%enddef - -%define %swig_sequence_methods_non_resizable(Sequence...) - %swig_sequence_methods_common(%arg(Sequence)) - %extend { - const value_type& __getitem__(difference_type i) const throw (std::out_of_range) { - return *(swig::cgetpos(self, i)); - } - - void __setitem__(difference_type i, const value_type& x) throw (std::out_of_range) { - *(swig::getpos(self,i)) = x; - } - -#if defined(SWIGPYTHON_BUILTIN) - // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { - swig::erase(self, swig::getpos(self, i)); - } -#endif - - } -%enddef - -%define %swig_sequence_methods(Sequence...) - %swig_sequence_methods_non_resizable(%arg(Sequence)) - %extend { - value_type pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty container"); - Sequence::value_type x = self->back(); - self->pop_back(); - return x; - } - - void append(const value_type& x) { - self->push_back(x); - } - } -%enddef - -%define %swig_sequence_methods_non_resizable_val(Sequence...) - %swig_sequence_methods_common(%arg(Sequence)) - %extend { - value_type __getitem__(difference_type i) throw (std::out_of_range) { - return *(swig::cgetpos(self, i)); - } - - void __setitem__(difference_type i, value_type x) throw (std::out_of_range) { - *(swig::getpos(self,i)) = x; - } - -#if defined(SWIGPYTHON_BUILTIN) - // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(difference_type i) throw (std::out_of_range, std::invalid_argument) { - swig::erase(self, swig::getpos(self, i)); - } -#endif - } -%enddef - -%define %swig_sequence_methods_val(Sequence...) - %swig_sequence_methods_non_resizable_val(%arg(Sequence)) - %extend { - value_type pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty container"); - Sequence::value_type x = self->back(); - self->pop_back(); - return x; - } - - void append(value_type x) { - self->push_back(x); - } - } -%enddef - - - -// -// Common fragments -// - -%fragment("StdSequenceTraits","header", - fragment="StdTraits", - fragment="SwigPySequence_Base") -{ -namespace swig { - template <class Seq, class T = typename Seq::value_type > - struct IteratorProtocol { - static void assign(PyObject *obj, Seq *seq) { - SwigVar_PyObject iter = PyObject_GetIter(obj); - if (iter) { - SwigVar_PyObject item = PyIter_Next(iter); - while (item) { - seq->insert(seq->end(), swig::as<T>(item)); - item = PyIter_Next(iter); - } - } - } - - static bool check(PyObject *obj) { - bool ret = false; - SwigVar_PyObject iter = PyObject_GetIter(obj); - if (iter) { - SwigVar_PyObject item = PyIter_Next(iter); - ret = true; - while (item) { - ret = swig::check<T>(item); - item = ret ? PyIter_Next(iter) : 0; - } - } - return ret; - } - }; - - template <class Seq, class T = typename Seq::value_type > - struct traits_asptr_stdseq { - typedef Seq sequence; - typedef T value_type; - - static bool is_iterable(PyObject *obj) { - SwigVar_PyObject iter = PyObject_GetIter(obj); - PyErr_Clear(); - return iter != 0; - } - - static int asptr(PyObject *obj, sequence **seq) { - int ret = SWIG_ERROR; - if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) { - sequence *p; - swig_type_info *descriptor = swig::type_info<sequence>(); - if (descriptor && SWIG_IsOK(::SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) { - if (seq) *seq = p; - return SWIG_OLDOBJ; - } - } else if (is_iterable(obj)) { - try { - if (seq) { - *seq = new sequence(); - IteratorProtocol<Seq, T>::assign(obj, *seq); - if (!PyErr_Occurred()) - return SWIG_NEWOBJ; - } else { - return IteratorProtocol<Seq, T>::check(obj) ? SWIG_OK : SWIG_ERROR; - } - } catch (std::exception& e) { - if (seq && !PyErr_Occurred()) - PyErr_SetString(PyExc_TypeError, e.what()); - } - if (seq) - delete *seq; - return SWIG_ERROR; - } - return ret; - } - }; - - template <class Seq, class T = typename Seq::value_type > - struct traits_from_stdseq { - typedef Seq sequence; - typedef T value_type; - typedef typename Seq::size_type size_type; - typedef typename sequence::const_iterator const_iterator; - - static PyObject *from(const sequence& seq) { -%#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS - swig_type_info *desc = swig::type_info<sequence>(); - if (desc && desc->clientdata) { - return SWIG_InternalNewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); - } -%#endif - size_type size = seq.size(); - if (size <= (size_type)INT_MAX) { - PyObject *obj = PyTuple_New((Py_ssize_t)size); - Py_ssize_t i = 0; - for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { - PyTuple_SetItem(obj,i,swig::from<value_type>(*it)); - } - return obj; - } else { - PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python"); - return NULL; - } - } - }; -} -} diff --git a/contrib/tools/swig/Lib/python/pydocs.swg b/contrib/tools/swig/Lib/python/pydocs.swg deleted file mode 100644 index 5a25423d4ca..00000000000 --- a/contrib/tools/swig/Lib/python/pydocs.swg +++ /dev/null @@ -1,45 +0,0 @@ - -// Documentation for use with the autodoc feature. - -#ifdef SWIG_DOC_DOXYGEN_STYLE -%typemap(doc) SWIGTYPE "@param $1_name $1_type" -%typemap(doc) SWIGTYPE * "@param $1_name $1_type" -%typemap(doc) const SWIGTYPE & "@param $1_name $1_type" -%typemap(doc) const SWIGTYPE && "@param $1_name $1_type" -%typemap(doc) enum SWIGTYPE "@param $1_name enum $1_type" - -%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "@param $1_name $1_type (input/output)" -%typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "@param $1_name $1_type (input)" -%typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "@param $1_name $1_type (output)" -#else -%typemap(doc) SWIGTYPE "$1_name: $1_type" -%typemap(doc) SWIGTYPE * "$1_name: $1_type" -%typemap(doc) const SWIGTYPE & "$1_name: $1_type" -%typemap(doc) const SWIGTYPE && "$1_name: $1_type" -%typemap(doc) enum SWIGTYPE "$1_name: enum $1_type" - -%typemap(doc) SWIGTYPE *INOUT, SWIGTYPE &INOUT "$1_name: $1_type (input/output)" -%typemap(doc) SWIGTYPE *INPUT, SWIGTYPE &INPUT "$1_name: $1_type (input)" -%typemap(doc) SWIGTYPE *OUTPUT, SWIGTYPE &OUTPUT "$1_name: $1_type (output)" -#endif - - -// Types to use in Python documentation for the parameters of the given C++ type. -%typemap(doctype) bool "boolean" - -%define int_doctype_for_cppint_type(cppint_type) - %typemap(doctype) cppint_type, unsigned cppint_type "int" -%enddef -%formacro(int_doctype_for_cppint_type, short, int, long, long long) - -%typemap(doctype) size_t "int" - -%typemap(doctype) enum SWIGTYPE "int" - -%typemap(doctype) float, double, long double "float" - -%typemap(doctype) char*, std::string "string" - -%typemap(doctype) SWIGTYPE "$1_basetype" -%typemap(doctype) SWIGTYPE * "$typemap(doctype, $*1_ltype)" -%typemap(doctype) SWIGTYPE & "$typemap(doctype, $*1_ltype)" diff --git a/contrib/tools/swig/Lib/python/pyerrors.swg b/contrib/tools/swig/Lib/python/pyerrors.swg deleted file mode 100644 index e7fe688d193..00000000000 --- a/contrib/tools/swig/Lib/python/pyerrors.swg +++ /dev/null @@ -1,112 +0,0 @@ -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - case SWIG_NullReferenceError: - type = PyExc_TypeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyObject *bytes = NULL; - const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes); - PyErr_Clear(); - SWIG_Py_XINCREF(type); - if (tmp) - PyErr_Format(type, "%s %s", tmp, mesg); - else - PyErr_Format(type, "%s", mesg); - SWIG_Py_XDECREF(bytes); - SWIG_Py_DECREF(old_str); - SWIG_Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} - -SWIGRUNTIME int -SWIG_Python_TypeErrorOccurred(PyObject *obj) -{ - PyObject *error; - if (obj) - return 0; - error = PyErr_Occurred(); - return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); -} - -SWIGRUNTIME void -SWIG_Python_RaiseOrModifyTypeError(const char *message) -{ - if (SWIG_Python_TypeErrorOccurred(NULL)) { - /* Use existing TypeError to preserve stacktrace and enhance with given message */ - PyObject *newvalue; - PyObject *type = NULL, *value = NULL, *traceback = NULL; - PyErr_Fetch(&type, &value, &traceback); -#if PY_VERSION_HEX >= 0x03000000 - newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); -#else - newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); -#endif - if (newvalue) { - SWIG_Py_XDECREF(value); - PyErr_Restore(type, newvalue, traceback); - } else { - PyErr_Restore(type, value, traceback); - } - } else { - /* Raise TypeError using given message */ - PyErr_SetString(PyExc_TypeError, message); - } -} diff --git a/contrib/tools/swig/Lib/python/pyfragments.swg b/contrib/tools/swig/Lib/python/pyfragments.swg deleted file mode 100644 index 535a45bdf2d..00000000000 --- a/contrib/tools/swig/Lib/python/pyfragments.swg +++ /dev/null @@ -1,23 +0,0 @@ -/* - - Create a file with this name, 'pyfragments.swg', in your working - directory and add all the %fragments you want to take precedence - over the default ones defined 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/python/pyhead.swg b/contrib/tools/swig/Lib/python/pyhead.swg deleted file mode 100644 index 938224123f0..00000000000 --- a/contrib/tools/swig/Lib/python/pyhead.swg +++ /dev/null @@ -1,105 +0,0 @@ -/* Compatibility macros for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) -#define PyString_Check(name) PyBytes_Check(name) -#define PyString_FromString(x) PyUnicode_FromString(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) -#define PyString_AsString(str) PyBytes_AsString(str) -#define PyString_Size(str) PyBytes_Size(str) -#define PyString_InternFromString(key) PyUnicode_InternFromString(key) -#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) - -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - - -/* Wrapper around PyUnicode_AsUTF8AndSize - call Py_XDECREF on the returned pbytes when finished with the returned string */ -SWIGINTERN const char * -SWIG_PyUnicode_AsUTF8AndSize(PyObject *str, Py_ssize_t *psize, PyObject **pbytes) -{ -#if PY_VERSION_HEX >= 0x03030000 -# if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 - *pbytes = NULL; - return PyUnicode_AsUTF8AndSize(str, psize); -# else - const char *chars; - *pbytes = PyUnicode_AsUTF8String(str); - chars = *pbytes ? PyBytes_AsString(*pbytes) : NULL; - if (chars && psize) - *psize = PyBytes_Size(*pbytes); - return chars; -# endif -#else - char *chars = NULL; - *pbytes = NULL; - PyString_AsStringAndSize(str, &chars, psize); - return chars; -#endif -} - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} - -#define SWIG_RUNTIME_MODULE "swig_runtime_data" SWIG_RUNTIME_VERSION - -/* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */ -# define SWIGPY_USE_CAPSULE -#ifdef SWIGPYTHON_BUILTIN -# define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule_builtin" SWIG_TYPE_TABLE_NAME -#else -# define SWIGPY_CAPSULE_ATTR_NAME "type_pointer_capsule" SWIG_TYPE_TABLE_NAME -#endif -#define SWIGPY_CAPSULE_NAME SWIG_RUNTIME_MODULE "." SWIGPY_CAPSULE_ATTR_NAME - -#if PY_VERSION_HEX < 0x03020000 -#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) -#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) -#define Py_hash_t long -#endif - -#ifdef Py_LIMITED_API -# define PyTuple_GET_ITEM PyTuple_GetItem -/* Note that PyTuple_SetItem() has different semantics from PyTuple_SET_ITEM as it decref's the original tuple item, so in general they cannot be used - interchangeably. However in SWIG-generated code PyTuple_SET_ITEM is only used with newly initialized tuples without any items and for them this does work. */ -# define PyTuple_SET_ITEM PyTuple_SetItem -# define PyTuple_GET_SIZE PyTuple_Size -# define PyCFunction_GET_FLAGS PyCFunction_GetFlags -# define PyCFunction_GET_FUNCTION PyCFunction_GetFunction -# define PyCFunction_GET_SELF PyCFunction_GetSelf -# define PyList_GET_ITEM PyList_GetItem -# define PyList_SET_ITEM PyList_SetItem -# define PySliceObject PyObject -#endif - -/* Increment and Decrement wrappers - for portability when using the stable abi and for performance otherwise */ -#ifdef Py_LIMITED_API -# define SWIG_Py_INCREF Py_IncRef -# define SWIG_Py_XINCREF Py_IncRef -# define SWIG_Py_DECREF Py_DecRef -# define SWIG_Py_XDECREF Py_DecRef -#else -# define SWIG_Py_INCREF Py_INCREF -# define SWIG_Py_XINCREF Py_XINCREF -# define SWIG_Py_DECREF Py_DECREF -# define SWIG_Py_XDECREF Py_XDECREF -#endif diff --git a/contrib/tools/swig/Lib/python/pyinit.swg b/contrib/tools/swig/Lib/python/pyinit.swg deleted file mode 100644 index 5070762ebd0..00000000000 --- a/contrib/tools/swig/Lib/python/pyinit.swg +++ /dev/null @@ -1,326 +0,0 @@ -/* ------------------------------------------------------------ - * The start of the Python initialization function - * ------------------------------------------------------------ */ - -%insert(init) "swiginit.swg" - -#if defined(SWIGPYTHON_BUILTIN) -%fragment("<stddef.h>"); // For offsetof -#endif - -#if defined SWIGPYTHON_FASTPROXY && !defined SWIGPYTHON_BUILTIN - -%insert(runtime) %{ -#ifdef __cplusplus -extern "C" { -#endif - -/* Method creation and docstring support functions */ - -SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); -SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); -SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); - -#ifdef __cplusplus -} -#endif -%} - -#endif - -%init %{ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * constants/methods manipulation - * ----------------------------------------------------------------------------- */ - -/* Install Constants */ -SWIGINTERN void -SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { - PyObject *obj = 0; - size_t i; - for (i = 0; constants[i].type; ++i) { - switch(constants[i].type) { - case SWIG_PY_POINTER: - obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); - break; - case SWIG_PY_BINARY: - obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); - break; - default: - obj = 0; - break; - } - if (obj) { - PyDict_SetItemString(d, constants[i].name, obj); - SWIG_Py_DECREF(obj); - } - } -} - -/* ----------------------------------------------------------------------------- - * Patch %callback methods' docstrings to hold the callback ptrs - * -----------------------------------------------------------------------------*/ - -SWIGINTERN void -SWIG_Python_FixMethods(PyMethodDef *methods, const swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { - size_t i; - for (i = 0; methods[i].ml_name; ++i) { - const char *c = methods[i].ml_doc; - if (!c) continue; - c = strstr(c, "swig_ptr: "); - if (c) { - int j; - const swig_const_info *ci = 0; - const char *name = c + 10; - for (j = 0; const_table[j].type; ++j) { - if (strncmp(const_table[j].name, name, - strlen(const_table[j].name)) == 0) { - ci = &(const_table[j]); - break; - } - } - if (ci) { - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; - char *ndoc = (char*)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - memcpy(buff, methods[i].ml_doc, ldoc); - buff += ldoc; - memcpy(buff, "swig_ptr: ", 10); - buff += 10; - SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); - methods[i].ml_doc = ndoc; - } - } - } - } - } -} - -#ifdef __cplusplus -} -#endif - -%} - -#if defined SWIGPYTHON_FASTPROXY && !defined SWIGPYTHON_BUILTIN - -%init %{ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * Method creation and docstring support functions - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * Function to find the method definition with the correct docstring for the - * proxy module as opposed to the low-level API - * ----------------------------------------------------------------------------- */ - -SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { - /* Find the function in the modified method table */ - size_t offset = 0; - int found = 0; - while (SwigMethods_proxydocs[offset].ml_meth != NULL) { - if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { - found = 1; - break; - } - offset++; - } - /* Use the copy with the modified docstring if available */ - return found ? &SwigMethods_proxydocs[offset] : NULL; -} - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ - -SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - return PyMethod_New(func, NULL, NULL); -#endif -} - -/* ----------------------------------------------------------------------------- - * Wrapper of PyStaticMethod_New() - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ - -SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } - return PyStaticMethod_New(func); -} - -#ifdef __cplusplus -} -#endif - -%} - -#endif - -%init %{ - -/* -----------------------------------------------------------------------------* - * Partial Init method - * -----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" -#endif - -SWIGEXPORT -#if PY_VERSION_HEX >= 0x03000000 - PyObject* -#else - void -#endif -SWIG_init(void) { - PyObject *m, *d, *md, *globals; - -#if PY_VERSION_HEX >= 0x03000000 - static struct PyModuleDef SWIG_module = { - PyModuleDef_HEAD_INIT, - SWIG_name, - NULL, - -1, - SwigMethods, - NULL, - NULL, - NULL, - NULL - }; -#endif - -#if defined(SWIGPYTHON_BUILTIN) - static SwigPyClientData SwigPyObject_clientdata = {0, 0, 0, 0, 0, 0, 0}; - static PyGetSetDef this_getset_def = { - (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL - }; - static SwigPyGetSet thisown_getset_closure = { - SwigPyObject_own, - SwigPyObject_own - }; - static PyGetSetDef thisown_getset_def = { - (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure - }; - PyTypeObject *builtin_pytype; - int builtin_base_count; - swig_type_info *builtin_basetype; - PyObject *tuple; - PyGetSetDescrObject *static_getset; - PyTypeObject *metatype; - PyTypeObject *swigpyobject; - SwigPyClientData *cd; - PyObject *public_interface, *public_symbol; - PyObject *this_descr; - PyObject *thisown_descr; - PyObject *self = 0; - int i; - - (void)builtin_pytype; - (void)builtin_base_count; - (void)builtin_basetype; - (void)tuple; - (void)static_getset; - (void)self; - - /* Metaclass is used to implement static member variables */ - metatype = SwigPyObjectType(); - assert(metatype); -#endif - - (void)globals; - - /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ - SWIG_runtime_data_module(); - SWIG_This(); - SWIG_Python_TypeCache(); - SwigPyPacked_type(); -#ifndef SWIGPYTHON_BUILTIN - SwigPyObject_type(); -#endif - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - -#if PY_VERSION_HEX >= 0x03000000 - m = PyModule_Create(&SWIG_module); -#else - m = Py_InitModule(SWIG_name, SwigMethods); -#endif - - md = d = PyModule_GetDict(m); - (void)md; - - SWIG_InitializeModule(0); - -#ifdef SWIGPYTHON_BUILTIN - swigpyobject = SwigPyObject_TypeOnce(); - - SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); - assert(SwigPyObject_stype); - cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; - if (!cd) { - SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; - SwigPyObject_clientdata.pytype = swigpyobject; - } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { - PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); -# if PY_VERSION_HEX >= 0x03000000 - return NULL; -# else - return; -# endif - } - - /* All objects have a 'this' attribute */ - this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); - (void)this_descr; - - /* All objects have a 'thisown' attribute */ - thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); - (void)thisown_descr; - - public_interface = PyList_New(0); - public_symbol = 0; - (void)public_symbol; - - PyDict_SetItemString(md, "__all__", public_interface); - SWIG_Py_DECREF(public_interface); - for (i = 0; SwigMethods[i].ml_name != NULL; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); - for (i = 0; swig_const_table[i].name != 0; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); -#endif - - SWIG_InstallConstants(d,swig_const_table); -%} - diff --git a/contrib/tools/swig/Lib/python/pyiterators.swg b/contrib/tools/swig/Lib/python/pyiterators.swg deleted file mode 100644 index 53f22b9fe03..00000000000 --- a/contrib/tools/swig/Lib/python/pyiterators.swg +++ /dev/null @@ -1,453 +0,0 @@ -/* ----------------------------------------------------------------------------- - * pyiterators.swg - * - * Implement a python 'output' iterator for Python 2.2 or higher. - * - * Users can derive form the SwigPyIterator to implement their - * own iterators. As an example (real one since we use it for STL/STD - * containers), the template SwigPyIterator_T does the - * implementation for generic C++ iterators. - * ----------------------------------------------------------------------------- */ - -%include <std_common.i> - -%fragment("SwigPyIterator","header",fragment="<stddef.h>") { -namespace swig { - struct stop_iteration { - }; - - struct SwigPyIterator { - private: - SwigPtr_PyObject _seq; - - protected: - SwigPyIterator(PyObject *seq) : _seq(seq) - { - } - - public: - virtual ~SwigPyIterator() {} - - // Access iterator method, required by Python - virtual PyObject *value() const = 0; - - // Forward iterator method, required by Python - virtual SwigPyIterator *incr(size_t n = 1) = 0; - - // Backward iterator method, very common in C++, but not required in Python - virtual SwigPyIterator *decr(size_t /*n*/ = 1) - { - throw stop_iteration(); - } - - // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const - { - throw std::invalid_argument("operation not supported"); - } - - virtual bool equal (const SwigPyIterator &/*x*/) const - { - throw std::invalid_argument("operation not supported"); - } - - // C++ common/needed methods - virtual SwigPyIterator *copy() const = 0; - - PyObject *next() - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads - PyObject *obj = value(); - incr(); - SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads - return obj; - } - - /* Make an alias for Python 3.x */ - PyObject *__next__() - { - return next(); - } - - PyObject *previous() - { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads - decr(); - PyObject *obj = value(); - SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads - return obj; - } - - SwigPyIterator *advance(ptrdiff_t n) - { - return (n > 0) ? incr(n) : decr(-n); - } - - bool operator == (const SwigPyIterator& x) const - { - return equal(x); - } - - bool operator != (const SwigPyIterator& x) const - { - return ! operator==(x); - } - - SwigPyIterator& operator += (ptrdiff_t n) - { - return *advance(n); - } - - SwigPyIterator& operator -= (ptrdiff_t n) - { - return *advance(-n); - } - - SwigPyIterator* operator + (ptrdiff_t n) const - { - return copy()->advance(n); - } - - SwigPyIterator* operator - (ptrdiff_t n) const - { - return copy()->advance(-n); - } - - ptrdiff_t operator - (const SwigPyIterator& x) const - { - return x.distance(*this); - } - - static swig_type_info* descriptor() { - static swig_type_info* desc = SWIG_TypeQuery("swig::SwigPyIterator *"); - return desc; - } - }; - -%#if defined(SWIGPYTHON_BUILTIN) - inline PyObject* make_output_iterator_builtin (PyObject *pyself) - { - SWIG_Py_INCREF(pyself); - return pyself; - } -%#endif -} -} - -%fragment("SwigPyIterator_T","header",fragment="<stddef.h>",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") { -namespace swig { - template<typename OutIterator> - class SwigPyIterator_T : public SwigPyIterator - { - public: - typedef OutIterator out_iterator; - typedef typename std::iterator_traits<out_iterator>::value_type value_type; - typedef SwigPyIterator_T<out_iterator> self_type; - - SwigPyIterator_T(out_iterator curr, PyObject *seq) - : SwigPyIterator(seq), current(curr) - { - } - - const out_iterator& get_current() const - { - return current; - } - - - bool equal (const SwigPyIterator &iter) const - { - const self_type *iters = dynamic_cast<const self_type *>(&iter); - if (iters) { - return (current == iters->get_current()); - } else { - throw std::invalid_argument("bad iterator type"); - } - } - - ptrdiff_t distance(const SwigPyIterator &iter) const - { - const self_type *iters = dynamic_cast<const self_type *>(&iter); - if (iters) { - return std::distance(current, iters->get_current()); - } else { - throw std::invalid_argument("bad iterator type"); - } - } - - protected: - out_iterator current; - }; - - template <class ValueType> - struct from_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v); - } - }; - - template<typename OutIterator, - typename ValueType = typename std::iterator_traits<OutIterator>::value_type, - typename FromOper = from_oper<ValueType> > - class SwigPyForwardIteratorOpen_T : public SwigPyIterator_T<OutIterator> - { - public: - FromOper from; - typedef OutIterator out_iterator; - typedef ValueType value_type; - typedef SwigPyIterator_T<out_iterator> base; - typedef SwigPyForwardIteratorOpen_T<OutIterator, ValueType, FromOper> self_type; - - SwigPyForwardIteratorOpen_T(out_iterator curr, PyObject *seq) - : SwigPyIterator_T<OutIterator>(curr, seq) - { - } - - PyObject *value() const { - return from(static_cast<const value_type&>(*(base::current))); - } - - SwigPyIterator *copy() const - { - return new self_type(*this); - } - - SwigPyIterator *incr(size_t n = 1) - { - while (n--) { - ++base::current; - } - return this; - } - - }; - - template<typename OutIterator, - typename ValueType = typename std::iterator_traits<OutIterator>::value_type, - typename FromOper = from_oper<ValueType> > - class SwigPyIteratorOpen_T : public SwigPyForwardIteratorOpen_T<OutIterator, ValueType, FromOper> - { - public: - FromOper from; - typedef OutIterator out_iterator; - typedef ValueType value_type; - typedef SwigPyIterator_T<out_iterator> base; - typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type; - - SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq) - : SwigPyForwardIteratorOpen_T<OutIterator>(curr, seq) - { - } - - SwigPyIterator *decr(size_t n = 1) - { - while (n--) { - --base::current; - } - return this; - } - }; - - template<typename OutIterator, - typename ValueType = typename std::iterator_traits<OutIterator>::value_type, - typename FromOper = from_oper<ValueType> > - class SwigPyForwardIteratorClosed_T : public SwigPyIterator_T<OutIterator> - { - public: - FromOper from; - typedef OutIterator out_iterator; - typedef ValueType value_type; - typedef SwigPyIterator_T<out_iterator> base; - typedef SwigPyForwardIteratorClosed_T<OutIterator, ValueType, FromOper> self_type; - - SwigPyForwardIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) - : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last) - { - } - - PyObject *value() const { - if (base::current == end) { - throw stop_iteration(); - } else { - return from(static_cast<const value_type&>(*(base::current))); - } - } - - SwigPyIterator *copy() const - { - return new self_type(*this); - } - - SwigPyIterator *incr(size_t n = 1) - { - while (n--) { - if (base::current == end) { - throw stop_iteration(); - } else { - ++base::current; - } - } - return this; - } - - protected: - out_iterator begin; - out_iterator end; - }; - - template<typename OutIterator, - typename ValueType = typename std::iterator_traits<OutIterator>::value_type, - typename FromOper = from_oper<ValueType> > - class SwigPyIteratorClosed_T : public SwigPyForwardIteratorClosed_T<OutIterator,ValueType,FromOper> - { - public: - FromOper from; - typedef OutIterator out_iterator; - typedef ValueType value_type; - typedef SwigPyIterator_T<out_iterator> base; - typedef SwigPyForwardIteratorClosed_T<OutIterator, ValueType, FromOper> base0; - typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type; - - SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) - : SwigPyForwardIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq) - { - } - - SwigPyIterator *decr(size_t n = 1) - { - while (n--) { - if (base::current == base0::begin) { - throw stop_iteration(); - } else { - --base::current; - } - } - return this; - } - }; - - - template<typename OutIter> - inline SwigPyIterator* - make_output_forward_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) - { - return new SwigPyForwardIteratorClosed_T<OutIter>(current, begin, end, seq); - } - - template<typename OutIter> - inline SwigPyIterator* - make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) - { - return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq); - } - - template<typename OutIter> - inline SwigPyIterator* - make_output_forward_iterator(const OutIter& current, PyObject *seq = 0) - { - return new SwigPyForwardIteratorOpen_T<OutIter>(current, seq); - } - - template<typename OutIter> - inline SwigPyIterator* - make_output_iterator(const OutIter& current, PyObject *seq = 0) - { - return new SwigPyIteratorOpen_T<OutIter>(current, seq); - } - -} -} - - -%fragment("SwigPyIterator"); -namespace swig -{ - /* - Throw a StopIteration exception - */ - %ignore stop_iteration; - struct stop_iteration {}; - - %typemap(throws) stop_iteration { - (void)$1; - SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void()); - SWIG_fail; - } - - /* - Mark methods that return new objects - */ - %newobject SwigPyIterator::copy; - %newobject SwigPyIterator::operator + (ptrdiff_t n) const; - %newobject SwigPyIterator::operator - (ptrdiff_t n) const; - - %nodirector SwigPyIterator; - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:tp_iter") SwigPyIterator "&swig::make_output_iterator_builtin"; - %feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__; -#else - %extend SwigPyIterator { - %pythoncode %{def __iter__(self): - return self%} - } -#endif - - %catches(swig::stop_iteration) SwigPyIterator::value() const; - %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1); - %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1); - %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const; - %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const; - %catches(swig::stop_iteration) SwigPyIterator::__next__(); - %catches(swig::stop_iteration) SwigPyIterator::next(); - %catches(swig::stop_iteration) SwigPyIterator::previous(); - %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n); - %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n); - %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n); - %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const; - %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const; - - struct SwigPyIterator - { - protected: - SwigPyIterator(PyObject *seq); - - public: - virtual ~SwigPyIterator(); - - // Access iterator method, required by Python - virtual PyObject *value() const = 0; - - // Forward iterator method, required by Python - virtual SwigPyIterator *incr(size_t n = 1) = 0; - - // Backward iterator method, very common in C++, but not required in Python - virtual SwigPyIterator *decr(size_t n = 1); - - // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const SwigPyIterator &x) const; - - virtual bool equal (const SwigPyIterator &x) const; - - // C++ common/needed methods - virtual SwigPyIterator *copy() const = 0; - - PyObject *next(); - PyObject *__next__(); - PyObject *previous(); - SwigPyIterator *advance(ptrdiff_t n); - - bool operator == (const SwigPyIterator& x) const; - bool operator != (const SwigPyIterator& x) const; - SwigPyIterator& operator += (ptrdiff_t n); - SwigPyIterator& operator -= (ptrdiff_t n); - SwigPyIterator* operator + (ptrdiff_t n) const; - SwigPyIterator* operator - (ptrdiff_t n) const; - ptrdiff_t operator - (const SwigPyIterator& x) const; - }; -} - diff --git a/contrib/tools/swig/Lib/python/pymacros.swg b/contrib/tools/swig/Lib/python/pymacros.swg deleted file mode 100644 index ab7bace5bac..00000000000 --- a/contrib/tools/swig/Lib/python/pymacros.swg +++ /dev/null @@ -1,4 +0,0 @@ -%include <typemaps/swigmacros.swg> - - - diff --git a/contrib/tools/swig/Lib/python/pyname_compat.i b/contrib/tools/swig/Lib/python/pyname_compat.i deleted file mode 100644 index 789b2844351..00000000000 --- a/contrib/tools/swig/Lib/python/pyname_compat.i +++ /dev/null @@ -1,78 +0,0 @@ -/* -* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, -* since they are inappropriate and discouraged in Python documentation -* (from http://www.python.org/doc/2.5.2/api/includes.html): -* -* "All user visible names defined by Python.h (except those defined by the included -* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with -* "_Py" are for internal use by the Python implementation and should not be used -* by extension writers. Structure member names do not have a reserved prefix. -* -* Important: user code should never define names that begin with "Py" or "_Py". -* This confuses the reader, and jeopardizes the portability of the user code to -* future Python versions, which may define additional names beginning with one -* of these prefixes." -* -* This file defined macros to provide backward compatibility for these deprecated -* symbols. In the case you have these symbols in your interface file, you can simply -* include this file at beginning of it. -* -* However, this file may be removed in future release of SWIG, so using this file to -* keep these inappropriate names in your SWIG interface file is also not recommended. -* Instead, we provide a simple tool for converting your interface files to -* the new naming convention. You can get the tool from the SWIG distribution: -* Tools/pyname_patch.py -*/ - -%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {} -%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} -%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {} -%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {} -%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} - -%inline %{ -#define PyMapIterator_T SwigPyMapIterator_T -#define PyMapKeyIterator_T SwigPyMapKeyIterator_T -#define PyMapValueIterator_T SwigPyMapValueIterator_T -#define PyObject_ptr SwigPtr_PyObject -#define PyObject_var SwigVar_PyObject -#define PyOper SwigPyOper -#define PySwigClientData SwigPyClientData -#define PySwigClientData_Del SwigPyClientData_Del -#define PySwigClientData_New SwigPyClientData_New -#define PySwigIterator SwigPyIterator -#define PySwigIteratorClosed_T SwigPyIteratorClosed_T -#define PySwigIteratorOpen_T SwigPyIteratorOpen_T -#define PySwigIterator_T SwigPyIterator_T -#define PySwigObject SwigPyObject -#define PySwigObject_Check SwigPyObject_Check -#define PySwigObject_GetDesc SwigPyObject_GetDesc -#define PySwigObject_New SwigPyObject_New -#define PySwigObject_acquire SwigPyObject_acquire -#define PySwigObject_append SwigPyObject_append -#define PySwigObject_as_number SwigPyObject_as_number -#define PySwigObject_compare SwigPyObject_compare -#define PySwigObject_dealloc SwigPyObject_dealloc -#define PySwigObject_disown SwigPyObject_disown -#define PySwigObject_format SwigPyObject_format -#define PySwigObject_getattr SwigPyObject_getattr -#define PySwigObject_hex SwigPyObject_hex -#define PySwigObject_long SwigPyObject_long -#define PySwigObject_next SwigPyObject_next -#define PySwigObject_oct SwigPyObject_oct -#define PySwigObject_own SwigPyObject_own -#define PySwigObject_repr SwigPyObject_repr -#define PySwigObject_richcompare SwigPyObject_richcompare -#define PySwigObject_type SwigPyObject_type -#define PySwigPacked SwigPyPacked -#define PySwigPacked_Check SwigPyPacked_Check -#define PySwigPacked_New SwigPyPacked_New -#define PySwigPacked_UnpackData SwigPyPacked_UnpackData -#define PySwigPacked_compare SwigPyPacked_compare -#define PySwigPacked_dealloc SwigPyPacked_dealloc -#define PySwigPacked_repr SwigPyPacked_repr -#define PySwigPacked_str SwigPyPacked_str -#define PySwigPacked_type SwigPyPacked_type -#define pyswigobject_type swigpyobject_type -#define pyswigpacked_type swigpypacked_type -%} diff --git a/contrib/tools/swig/Lib/python/pyopers.swg b/contrib/tools/swig/Lib/python/pyopers.swg deleted file mode 100644 index fd2fcc58120..00000000000 --- a/contrib/tools/swig/Lib/python/pyopers.swg +++ /dev/null @@ -1,264 +0,0 @@ -/* ------------------------------------------------------------ - * Overloaded operator support - - The directives in this file apply whether or not you use the - -builtin option to SWIG, but operator overloads are particularly - attractive when using -builtin, because they are much faster - than named methods. - - If you're using the -builtin option to SWIG, and you want to define - python operator overloads beyond the defaults defined in this file, - here's what you need to know: - - There are two ways to define a python slot function: dispatch to a - statically defined function; or dispatch to a method defined on the - operand. - - To dispatch to a statically defined function, use %feature("python:<slot>"), - where <slot> is the name of a field in a PyTypeObject, PyNumberMethods, - PyMappingMethods, PySequenceMethods, or PyBufferProcs. For example: - - %feature("python:tp_hash") MyClass "myHashFunc"; - - class MyClass { - public: - ... - }; - - %{ - // Note: Py_hash_t was introduced in Python 3.2 - static Py_hash_t myHashFunc(PyObject *pyobj) { - MyClass *cobj; - // Convert pyobj to cobj - return (cobj->field1 * (cobj->field2 << 7)); - } - %} - - NOTE: It is the responsibility of the programmer (that's you) to ensure - that a statically defined slot function has the correct signature. - - If, instead, you want to dispatch to an instance method, you can - use %feature("python:slot"). For example: - - %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc; - - class MyClass { - public: - Py_hash_t myHashFunc () const; - ... - }; - - NOTE: Some python slots use a method signature which does not - match the signature of SWIG-wrapped methods. For those slots, - SWIG will automatically generate a "closure" function to re-marshall - the arguments before dispatching to the wrapped method. Setting - the "functype" attribute of the feature enables SWIG to generate - a correct closure function. - - -------------------------------------------------------------- - - The tp_richcompare slot is a special case: SWIG automatically generates - a rich compare function for all wrapped types. If a type defines C++ - operator overloads for comparison (operator==, operator<, etc.), they - will be called from the generated rich compare function. If you - want to explicitly choose a method to handle a certain comparison - operation, you may use a different feature, %feature("python:compare") - like this: - - %feature("python:compare", "Py_LT") MyClass::lessThan; - - class MyClass { - public: - bool lessThan(const MyClass& other) const; - ... - }; - - ... where "Py_LT" is one of the rich comparison opcodes defined in the - python header file object.h. - - If there's no method defined to handle a particular comparison operation, - the default behavior is to compare pointer values of the wrapped - C++ objects. - - -------------------------------------------------------------- - - - For more information about python slots, including their names and - signatures, you may refer to the python documentation : - - http://docs.python.org/c-api/typeobj.html - - * ------------------------------------------------------------ */ - - -#ifdef __cplusplus - -#if defined(SWIGPYTHON_BUILTIN) -#define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:slot", #slt, functype=#functp) oper; %feature("python:slot", #slt, functype=#functp) pyname; -#define %pycompare(pyname,oper,comptype) %rename(pyname) oper; %pythonmaybecall oper; %feature("python:compare", #comptype) oper; %feature("python:compare", #comptype) pyname; -#else -#define %pybinoperator(pyname,oper,functp,slt) %rename(pyname) oper; %pythonmaybecall oper -#define %pycompare(pyname,oper,comptype) %pybinoperator(pyname,oper,,comptype) -#endif - -%pybinoperator(__add__, *::operator+, binaryfunc, nb_add); -%pybinoperator(__pos__, *::operator+(), unaryfunc, nb_positive); -%pybinoperator(__pos__, *::operator+() const, unaryfunc, nb_positive); -%pybinoperator(__sub__, *::operator-, binaryfunc, nb_subtract); -%pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative); -%pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative); -%pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply); -%pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder); -%pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift); -%pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift); -%pybinoperator(__and__, *::operator&, binaryfunc, nb_and); -%pybinoperator(__or__, *::operator|, binaryfunc, nb_or); -%pybinoperator(__xor__, *::operator^, binaryfunc, nb_xor); -%pycompare(__lt__, *::operator<, Py_LT); -%pycompare(__le__, *::operator<=, Py_LE); -%pycompare(__gt__, *::operator>, Py_GT); -%pycompare(__ge__, *::operator>=, Py_GE); -%pycompare(__eq__, *::operator==, Py_EQ); -%pycompare(__ne__, *::operator!=, Py_NE); - -/* Special cases */ -%rename(__invert__) *::operator~; -%feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~; -%rename(__call__) *::operator(); -%feature("python:slot", "tp_call", functype="ternarycallfunc") *::operator(); - -#if defined(SWIGPYTHON_BUILTIN) -%pybinoperator(__nonzero__, *::operator bool, inquiry, nb_nonzero); -%pybinoperator(__truediv__, *::operator/ , binaryfunc, nb_divide); -#else -%feature("shadow") *::operator bool %{ -def __nonzero__(self): - return $action(self) -__bool__ = __nonzero__ -%}; -%rename(__nonzero__) *::operator bool; -%feature("shadow") *::operator/ %{ -def __truediv__(self, *args): - return $action(self, *args) -__div__ = __truediv__ -%}; -%rename(__truediv__) *::operator/; -%pythonmaybecall *::operator/; -#endif - -/* Ignored operators */ -%ignoreoperator(LNOT) operator!; -%ignoreoperator(LAND) operator&&; -%ignoreoperator(LOR) operator||; -%ignoreoperator(EQ) *::operator=; -%ignoreoperator(PLUSPLUS) *::operator++; -%ignoreoperator(MINUSMINUS) *::operator--; -%ignoreoperator(ARROWSTAR) *::operator->*; -%ignoreoperator(INDEX) *::operator[]; - -/* - Inplace operator declarations. - - They translate the inplace C++ operators (+=, -=, ...) into the - corresponding python equivalents(__iadd__,__isub__), etc, - disabling the ownership of the input 'this' pointer, and assigning - it to the returning object: - - %feature("del") *::Operator; // disables ownership by generating SWIG_POINTER_DISOWN - %feature("new") *::Operator; // claims ownership by generating SWIG_POINTER_OWN - - This makes the most common case safe, ie: - - A& A::operator+=(int i) { ...; return *this; } - ^^^^ ^^^^^^ - - will work fine, even when the resulting python object shares the - 'this' pointer with the input one. The input object is usually - deleted after the operation, including the shared 'this' pointer, - producing 'strange' seg faults, as reported by Lucriz - ([email protected]). - - If you have an interface that already takes care of that, ie, you - already are using inplace operators and you are not getting - seg. faults, with the new scheme you could end with 'free' elements - that never get deleted (maybe, not sure, it depends). But if that is - the case, you could recover the old behaviour using - - %feature("del","0") A::operator+=; - %feature("new","0") A::operator+=; - - which recovers the old behaviour for the class 'A', or if you are - 100% sure your entire system works fine in the old way, use: - - %feature("del","") *::operator+=; - %feature("new","") *::operator+=; - - The default behaviour assumes that the 'this' pointer's memory is - already owned by the SWIG object; it relinquishes ownership then - takes it back. This may not be the case though as the SWIG object - might be owned by memory managed elsewhere, eg after calling a - function that returns a C++ reference. In such case you will need - to use the features above to recover the old behaviour too. -*/ - -#if defined(SWIGPYTHON_BUILTIN) -#define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %feature("python:slot", #slt, functype=#functp) Oper; %rename(SwigPyOper) Oper -#else -#define %pyinplaceoper(SwigPyOper, Oper, functp, slt) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper -#endif - -%pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add); -%pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract); -%pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply); -%pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder); -%pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and); -%pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or); -%pyinplaceoper(__ixor__ , *::operator ^=, binaryfunc, nb_inplace_xor); -%pyinplaceoper(__ilshift__, *::operator <<=, binaryfunc, nb_inplace_lshift); -%pyinplaceoper(__irshift__, *::operator >>=, binaryfunc, nb_inplace_rshift); - -/* Special cases */ -#if defined(SWIGPYTHON_BUILTIN) -%pyinplaceoper(__itruediv__ , *::operator /=, binaryfunc, nb_inplace_divide); -#else -%delobject *::operator /=; -%newobject *::operator /=; -%feature("shadow") *::operator /= %{ -def __itruediv__(self, *args): - return $action(self, *args) -__idiv__ = __itruediv__ -%}; -%rename(__itruediv__) *::operator /=; -#endif - -/* Finally, in python we need to mark the binary operations to fail as - 'maybecall' methods */ - -#define %pybinopermaybecall(oper) %pythonmaybecall __ ## oper ## __; %pythonmaybecall __r ## oper ## __ - -%pybinopermaybecall(add); -%pybinopermaybecall(pos); -%pybinopermaybecall(pos); -%pybinopermaybecall(sub); -%pybinopermaybecall(neg); -%pybinopermaybecall(neg); -%pybinopermaybecall(mul); -%pybinopermaybecall(div); -%pybinopermaybecall(truediv); -%pybinopermaybecall(mod); -%pybinopermaybecall(lshift); -%pybinopermaybecall(rshift); -%pybinopermaybecall(and); -%pybinopermaybecall(or); -%pybinopermaybecall(xor); -%pybinopermaybecall(lt); -%pybinopermaybecall(le); -%pybinopermaybecall(gt); -%pybinopermaybecall(ge); -%pybinopermaybecall(eq); -%pybinopermaybecall(ne); - -#endif - - - diff --git a/contrib/tools/swig/Lib/python/pyprimtypes.swg b/contrib/tools/swig/Lib/python/pyprimtypes.swg deleted file mode 100644 index 7f372753fb3..00000000000 --- a/contrib/tools/swig/Lib/python/pyprimtypes.swg +++ /dev/null @@ -1,362 +0,0 @@ -/* ------------------------------------------------------------ - * Primitive Types - * ------------------------------------------------------------ */ - -/* boolean */ - -%fragment(SWIG_From_frag(bool),"header") { -SWIGINTERNINLINE PyObject* - SWIG_From_dec(bool)(bool value) -{ - return PyBool_FromLong(value ? 1 : 0); -} -} - -#ifdef SWIG_PYTHON_LEGACY_BOOL -// Default prior to SWIG 3.0.0 -%fragment(SWIG_AsVal_frag(bool),"header", - fragment=SWIG_AsVal_frag(long)) { -SWIGINTERN int -SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) -{ - int r = PyObject_IsTrue(obj); - if (r == -1) - return SWIG_ERROR; - if (val) *val = r ? true : false; - return SWIG_OK; -} -} -#else -%fragment(SWIG_AsVal_frag(bool),"header", - fragment=SWIG_AsVal_frag(long)) { -SWIGINTERN int -SWIG_AsVal_dec(bool)(PyObject *obj, bool *val) -{ - int r; - if (!PyBool_Check(obj)) - return SWIG_ERROR; - r = PyObject_IsTrue(obj); - if (r == -1) - return SWIG_ERROR; - if (val) *val = r ? true : false; - return SWIG_OK; -} -} -#endif - -/* int */ - -%fragment(SWIG_From_frag(int),"header") { -SWIGINTERNINLINE PyObject* - SWIG_From_dec(int)(int value) -{ - return PyInt_FromLong((long) value); -} -} - -/* unsigned int */ - -%fragment(SWIG_From_frag(unsigned int),"header") { -SWIGINTERNINLINE PyObject* - SWIG_From_dec(unsigned int)(unsigned int value) -{ - return PyInt_FromSize_t((size_t) value); -} -} - -/* long */ - -%fragment(SWIG_From_frag(long),"header") { - %define_as(SWIG_From_dec(long), PyInt_FromLong) -} - -%fragment(SWIG_AsVal_frag(long),"header", - fragment="SWIG_CanCastAsInteger") { -SWIGINTERN int -SWIG_AsVal_dec(long)(PyObject *obj, long* val) -{ -%#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else -%#endif - if (PyLong_Check(obj)) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } -%#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - long v = PyInt_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); - // Largest double not larger than LONG_MAX (not portably calculated easily) - // Note that double(LONG_MAX) is stored in a double rounded up by one (for 64-bit long) - // 0x7ffffffffffffc00LL == (int64_t)std::nextafter(double(__uint128_t(LONG_MAX)+1), double(0)) - const double long_max = sizeof(long) == 8 ? 0x7ffffffffffffc00LL : LONG_MAX; - // No equivalent needed for 64-bit double(LONG_MIN) is exactly LONG_MIN - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, long_max)) { - if (val) *val = (long)(d); - return res; - } - } - } -%#endif - return SWIG_TypeError; -} -} - -/* unsigned long */ - -%fragment(SWIG_From_frag(unsigned long),"header", - fragment=SWIG_From_frag(long)) { -SWIGINTERNINLINE PyObject* -SWIG_From_dec(unsigned long)(unsigned long value) -{ - return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyInt_FromLong(%numeric_cast(value,long)); -} -} - -%fragment(SWIG_AsVal_frag(unsigned long),"header", - fragment="SWIG_CanCastAsInteger") { -SWIGINTERN int -SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) -{ -%#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { - if (val) *val = v; - return SWIG_OK; - } else { - return SWIG_OverflowError; - } - } else -%#endif - if (PyLong_Check(obj)) { - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } -%#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal(double)(obj,&d)); - // Largest double not larger than ULONG_MAX (not portably calculated easily) - // Note that double(ULONG_MAX) is stored in a double rounded up by one (for 64-bit unsigned long) - // 0xfffffffffffff800ULL == (uint64_t)std::nextafter(double(__uint128_t(ULONG_MAX)+1), double(0)) - const double ulong_max = sizeof(unsigned long) == 8 ? 0xfffffffffffff800ULL : ULONG_MAX; - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ulong_max)) { - if (val) *val = (unsigned long)(d); - return res; - } - } - } -%#endif - return SWIG_TypeError; -} -} - -/* long long */ - -%fragment(SWIG_From_frag(long long),"header", - fragment="SWIG_LongLongAvailable") { -%#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERNINLINE PyObject* -SWIG_From_dec(long long)(long long value) -{ - return ((value < LONG_MIN) || (value > LONG_MAX)) ? - PyLong_FromLongLong(value) : PyInt_FromLong(%numeric_cast(value,long)); -} -%#endif -} - -%fragment(SWIG_AsVal_frag(long long),"header", - fragment=SWIG_AsVal_frag(long), - fragment="SWIG_CanCastAsInteger", - fragment="SWIG_LongLongAvailable") { -%#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERN int -SWIG_AsVal_dec(long long)(PyObject *obj, long long *val) -{ - int res = SWIG_TypeError; - if (PyLong_Check(obj)) { - long long v = PyLong_AsLongLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - res = SWIG_OverflowError; - } - } else { - long v; - res = SWIG_AsVal(long)(obj,&v); - if (SWIG_IsOK(res)) { - if (val) *val = v; - return res; - } - } -%#ifdef SWIG_PYTHON_CAST_MODE - { - const double mant_max = 1LL << DBL_MANT_DIG; - const double mant_min = -mant_max; - double d; - res = SWIG_AsVal(double)(obj,&d); - if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max)) - return SWIG_OverflowError; - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) { - if (val) *val = (long long)(d); - return SWIG_AddCast(res); - } - res = SWIG_TypeError; - } -%#endif - return res; -} -%#endif -} - -/* unsigned long long */ - -%fragment(SWIG_From_frag(unsigned long long),"header", - fragment="SWIG_LongLongAvailable") { -%#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERNINLINE PyObject* -SWIG_From_dec(unsigned long long)(unsigned long long value) -{ - return (value > LONG_MAX) ? - PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(%numeric_cast(value,long)); -} -%#endif -} - -%fragment(SWIG_AsVal_frag(unsigned long long),"header", - fragment=SWIG_AsVal_frag(unsigned long), - fragment="SWIG_CanCastAsInteger", - fragment="SWIG_LongLongAvailable") { -%#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERN int -SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val) -{ - int res = SWIG_TypeError; - if (PyLong_Check(obj)) { - unsigned long long v = PyLong_AsUnsignedLongLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - res = SWIG_OverflowError; - } - } else { - unsigned long v; - res = SWIG_AsVal(unsigned long)(obj,&v); - if (SWIG_IsOK(res)) { - if (val) *val = v; - return res; - } - } -%#ifdef SWIG_PYTHON_CAST_MODE - { - const double mant_max = 1LL << DBL_MANT_DIG; - double d; - res = SWIG_AsVal(double)(obj,&d); - if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) - return SWIG_OverflowError; - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { - if (val) *val = (unsigned long long)(d); - return SWIG_AddCast(res); - } - res = SWIG_TypeError; - } -%#endif - return res; -} -%#endif -} - -/* double */ - -%fragment(SWIG_From_frag(double),"header") { - %define_as(SWIG_From_dec(double), PyFloat_FromDouble) -} - -%fragment(SWIG_AsVal_frag(double),"header") { -SWIGINTERN int -SWIG_AsVal_dec(double)(PyObject *obj, double *val) -{ - int res = SWIG_TypeError; - if (PyFloat_Check(obj)) { - if (val) *val = PyFloat_AsDouble(obj); - return SWIG_OK; -%#if PY_VERSION_HEX < 0x03000000 - } else if (PyInt_Check(obj)) { - if (val) *val = (double) PyInt_AsLong(obj); - return SWIG_OK; -%#endif - } else if (PyLong_Check(obj)) { - double v = PyLong_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -%#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - double d = PyFloat_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = d; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); - } else { - PyErr_Clear(); - } - } - } -%#endif - return res; -} -} - - - diff --git a/contrib/tools/swig/Lib/python/pyrun.swg b/contrib/tools/swig/Lib/python/pyrun.swg deleted file mode 100644 index e7164725dbf..00000000000 --- a/contrib/tools/swig/Lib/python/pyrun.swg +++ /dev/null @@ -1,2108 +0,0 @@ -/* ----------------------------------------------------------------------------- - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ -# error "This version of SWIG only supports Python >= 2.7" -#endif - -#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03030000 -# error "This version of SWIG only supports Python 3 >= 3.3" -#endif - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) - -#ifdef SWIGPYTHON_BUILTIN -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) -#else -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) -#endif - -#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) - -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, 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_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - SWIG_Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -#if defined(SWIGPYTHON_BUILTIN) - -SWIGINTERN void -SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { - PyObject *s = PyString_InternFromString(key); - PyList_Append(seq, s); - SWIG_Py_DECREF(s); -} - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { - PyDict_SetItemString(d, name, obj); - SWIG_Py_DECREF(obj); - if (public_interface) - SwigPyBuiltin_AddPublicSymbol(public_interface, name); -} - -#else - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, name, obj); - SWIG_Py_DECREF(obj); -} - -#endif - -/* SWIG runtime data Python module */ -static PyObject *Swig_runtime_data_module_global = NULL; - -/* Create/obtain the single swig_runtime_data module which is used across different SWIG generated modules */ -SWIGINTERN PyObject * -SWIG_runtime_data_module() { - if (!Swig_runtime_data_module_global) { -#if PY_VERSION_HEX >= 0x03000000 - Swig_runtime_data_module_global = PyImport_AddModule(SWIG_RUNTIME_MODULE); -#else - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - Swig_runtime_data_module_global = Py_InitModule(SWIG_RUNTIME_MODULE, swig_empty_runtime_method_table); -#endif - SWIG_Py_XINCREF(Swig_runtime_data_module_global); - } - return Swig_runtime_data_module_global; -} - -/* Append a value to the result obj */ -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj, int is_void) { - if (!result) { - result = obj; - } else if (result == Py_None && is_void) { - SWIG_Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - if (result) { - PyList_SET_ITEM(result, 0, o2); - } else { - SWIG_Py_DECREF(obj); - return o2; - } - } - PyList_Append(result,obj); - SWIG_Py_DECREF(obj); - } - return result; -} - -/* Unpack the argument tuple */ - -SWIGINTERN Py_ssize_t -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - if (min <= 1 && max >= 1) { - Py_ssize_t i; - objs[0] = args; - for (i = 1; i < max; ++i) { - objs[i] = 0; - } - return 2; - } - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - Py_ssize_t i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -SWIGINTERN int -SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { - int no_kwargs = 1; - if (kwargs) { - assert(PyDict_Check(kwargs)); - if (PyDict_Size(kwargs) > 0) { - PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); - no_kwargs = 0; - } - } - return no_kwargs; -} - -/* A functor is a function object with one single object argument */ -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Python-specific SWIG API */ -#define SWIG_newvarlink() SWIG_Python_newvarlink() -#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) -#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) - -/* ----------------------------------------------------------------------------- - * global variable support code. - * ----------------------------------------------------------------------------- */ - -typedef struct swig_globalvar { - char *name; /* Name of global variable */ - PyObject *(*get_attr)(void); /* Return the current value */ - int (*set_attr)(PyObject *); /* Set the value */ - struct swig_globalvar *next; -} swig_globalvar; - -typedef struct swig_varlinkobject { - PyObject_HEAD - swig_globalvar *vars; -} swig_varlinkobject; - -SWIGINTERN PyObject * -SwigVarLink_repr(PyObject *SWIGUNUSEDPARM(v)) { -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString("<Swig global variables>"); -#else - return PyString_FromString("<Swig global variables>"); -#endif -} - -SWIGINTERN PyObject * -SwigVarLink_str(PyObject *o) { - swig_varlinkobject *v = (swig_varlinkobject *) o; -#if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); - PyObject *tail; - PyObject *joined; - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - tail = PyUnicode_FromString(var->name); - joined = PyUnicode_Concat(str, tail); - SWIG_Py_DECREF(str); - SWIG_Py_DECREF(tail); - str = joined; - if (var->next) { - tail = PyUnicode_InternFromString(", "); - joined = PyUnicode_Concat(str, tail); - SWIG_Py_DECREF(str); - SWIG_Py_DECREF(tail); - str = joined; - } - } - tail = PyUnicode_InternFromString(")"); - joined = PyUnicode_Concat(str, tail); - SWIG_Py_DECREF(str); - SWIG_Py_DECREF(tail); - str = joined; -#else - PyObject *str = PyString_FromString("("); - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - PyString_ConcatAndDel(&str,PyString_FromString(var->name)); - if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); - } - PyString_ConcatAndDel(&str,PyString_FromString(")")); -#endif - return str; -} - -SWIGINTERN void -SwigVarLink_dealloc(PyObject *o) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - swig_globalvar *var = v->vars; - while (var) { - swig_globalvar *n = var->next; - free(var->name); - free(var); - var = n; - } -} - -SWIGINTERN PyObject * -SwigVarLink_getattr(PyObject *o, char *n) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - PyObject *res = NULL; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->get_attr)(); - break; - } - var = var->next; - } - if (res == NULL && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; -} - -SWIGINTERN int -SwigVarLink_setattr(PyObject *o, char *n, PyObject *p) { - swig_varlinkobject *v = (swig_varlinkobject *) o; - int res = 1; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->set_attr)(p); - break; - } - var = var->next; - } - if (res == 1 && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; -} - -#if !defined(SWIGPYTHON_BUILTIN) && PY_VERSION_HEX >= 0x03030000 -#define SWIG_HEAPTYPES -#endif - -SWIGINTERN PyTypeObject* -swig_varlink_type(void) { - static char SwigVarLink_doc[] = "Swig variable link object"; -#ifndef SWIG_HEAPTYPES - static PyTypeObject varlink_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - SWIG_RUNTIME_MODULE ".SwigVarLink", /* tp_name */ - sizeof(swig_varlinkobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) SwigVarLink_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /* tp_print */ -#else - (Py_ssize_t)0, /* tp_vectorcall_offset */ -#endif - (getattrfunc) SwigVarLink_getattr, /* tp_getattr */ - (setattrfunc) SwigVarLink_setattr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc) SwigVarLink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) SwigVarLink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - SwigVarLink_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#if PY_VERSION_HEX >= 0x030c0000 - 0, /* tp_watched */ -#endif -#if PY_VERSION_HEX >= 0x030d00a4 - 0, /* tp_versions_used */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - PyObject *runtime_data_module = SWIG_runtime_data_module(); - varlink_type = tmp; - type_init = 1; - if (PyType_Ready(&varlink_type) < 0) - return NULL; - if (PyModule_AddObject(runtime_data_module, "SwigVarLink", (PyObject *)&varlink_type) == 0) - SWIG_Py_INCREF((PyObject *)&varlink_type); - } - return &varlink_type; -#else - PyType_Slot slots[] = { - { Py_tp_dealloc, (void *)SwigVarLink_dealloc }, - { Py_tp_repr, (void *)SwigVarLink_repr }, - { Py_tp_getattr, (void *)SwigVarLink_getattr }, - { Py_tp_setattr, (void *)SwigVarLink_setattr }, - { Py_tp_str, (void *)SwigVarLink_str }, - { Py_tp_doc, (void *)SwigVarLink_doc }, - { 0, NULL } - }; - PyType_Spec spec = { - SWIG_RUNTIME_MODULE ".SwigVarLink", - sizeof(swig_varlinkobject), - 0, - Py_TPFLAGS_DEFAULT, - slots - }; - PyObject *pytype = PyType_FromSpec(&spec); - PyObject *runtime_data_module = SWIG_runtime_data_module(); - if (pytype && PyModule_AddObject(runtime_data_module, "SwigVarLink", pytype) == 0) - SWIG_Py_INCREF(pytype); - return (PyTypeObject *)pytype; -#endif -} - -/* Create a variable linking object for use later */ -SWIGINTERN PyObject * -SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = PyObject_New(swig_varlinkobject, swig_varlink_type()); - if (result) { - result->vars = 0; - } - return ((PyObject*) result); -} - -SWIGINTERN void -SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v = (swig_varlinkobject *) p; - swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - if (gv) { - size_t size = strlen(name)+1; - gv->name = (char *)malloc(size); - if (gv->name) { - memcpy(gv->name, name, size); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; - } - } - v->vars = gv; -} - - -static PyObject *Swig_Globals_global = NULL; - -SWIGINTERN PyObject * -SWIG_globals(void) { - if (Swig_Globals_global == NULL) { - Swig_Globals_global = SWIG_newvarlink(); - } - return Swig_Globals_global; -} - -#ifdef __cplusplus -} -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) -#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) - -#ifdef __cplusplus -extern "C" { -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - SWIG_Py_INCREF(none); - return none; -} - -/* SwigPyClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; - PyTypeObject *pytype; -} SwigPyClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - int fail = data ? data->implicitconv : 0; - if (fail) - PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); - return fail; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - SWIG_Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - SWIG_Py_INCREF(obj); - data->newargs = obj; - } else { - data->newraw = PyObject_GetAttrString(data->klass, "__new__"); - if (data->newraw) { - data->newargs = PyTuple_New(1); - if (data->newargs) { - SWIG_Py_INCREF(obj); - PyTuple_SET_ITEM(data->newargs, 0, obj); - } else { - SWIG_Py_DECREF(data->newraw); - SWIG_Py_DECREF(data->klass); - free(data); - return 0; - } - } else { - SWIG_Py_INCREF(obj); - data->newargs = obj; - } - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - data->delargs = !(PyCFunction_GET_FLAGS(data->destroy) & METH_O); - } else { - data->delargs = 0; - } - data->implicitconv = 0; - data->pytype = 0; - return data; - } -} - -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData *data) -{ - SWIG_Py_XDECREF(data->klass); - SWIG_Py_XDECREF(data->newraw); - SWIG_Py_XDECREF(data->newargs); - SWIG_Py_XDECREF(data->destroy); - free(data); -} - -/* =============== SwigPyObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -#ifdef SWIGPYTHON_BUILTIN - PyObject *dict; -#endif -} SwigPyObject; - - -#ifdef SWIGPYTHON_BUILTIN - -SWIGRUNTIME PyObject * -SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - - if (!sobj->dict) - sobj->dict = PyDict_New(); - - SWIG_Py_XINCREF(sobj->dict); - return sobj->dict; -} - -#endif - -SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - PyObject *val = SwigPyObject_long(v); - if (val) { - PyObject *ofmt; - PyTuple_SET_ITEM(args, 0, val); - ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else - res = PyString_Format(ofmt,args); -#endif - SWIG_Py_DECREF(ofmt); - } - } - SWIG_Py_DECREF(args); - } - return res; -} - -SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) -{ - return SwigPyObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) -{ - return SwigPyObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_repr(SwigPyObject *v) -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); - if (repr && v->next) { - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); - if (nrep) { -# if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - SWIG_Py_DECREF(repr); - SWIG_Py_DECREF(nrep); - repr = joined; -# else - PyString_ConcatAndDel(&repr,nrep); -# endif - } else { - SWIG_Py_DECREF(repr); - repr = NULL; - } - } - return repr; -} - -/* We need a version taking two PyObject* parameters so it's a valid - * PyCFunction to use in SwigPyObject_methods[]. */ -SWIGRUNTIME PyObject * -SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) -{ - return SwigPyObject_repr((SwigPyObject*)v); -} - -SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -/* Added for Python 3.x, would it also be useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res = NULL; - if (!PyErr_Occurred()) { - if (op != Py_EQ && op != Py_NE) { - SWIG_Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); - } - return res; -} - - -SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); - -#ifdef SWIGPYTHON_BUILTIN -static swig_type_info *SwigPyObject_stype = 0; -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - SwigPyClientData *cd; - assert(SwigPyObject_stype); - cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; - assert(cd); - assert(cd->pytype); - return cd->pytype; -} -#else -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); - return type; -} -#endif - -SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { - PyTypeObject *target_tp = SwigPyObject_type(); - PyTypeObject *op_type = Py_TYPE(op); -#ifdef SWIGPYTHON_BUILTIN - if (PyType_IsSubtype(op_type, target_tp)) - return 1; - return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyObject") == 0); -#else -# ifdef Py_LIMITED_API - int cmp; - PyObject *tp_name; -#endif - if (op_type == target_tp) - return 1; -# ifdef Py_LIMITED_API - tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); - if (!tp_name) - return 0; - cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyObject"); - SWIG_Py_DECREF(tp_name); - return cmp == 0; -# else - return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyObject") == 0); -# endif -#endif -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); - -static PyObject* Swig_Capsule_global = NULL; - -SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - - /* PyObject_CallFunction() has the potential to silently drop - the active exception. In cases of unnamed temporary - variable or where we just finished iterating over a generator - StopIteration will be active right now, and this needs to - remain true upon return from SwigPyObject_dealloc. So save - and restore. */ - - PyObject *type = NULL, *value = NULL, *traceback = NULL; - PyErr_Fetch(&type, &value, &traceback); - - if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - if (tmp) { - res = SWIG_Python_CallFunctor(destroy, tmp); - } else { - res = 0; - } - SWIG_Py_XDECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - if (!res) - PyErr_WriteUnraisable(destroy); - - PyErr_Restore(type, value, traceback); - - SWIG_Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - SWIG_Py_XDECREF(Swig_Capsule_global); - } - SWIG_Py_XDECREF(next); -#ifdef SWIGPYTHON_BUILTIN - SWIG_Py_XDECREF(sobj->dict); -#endif - PyObject_Free(v); -} - -SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (!SwigPyObject_Check(next)) { - PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); - return NULL; - } - ((SwigPyObject *)next)->next = sobj->next; - sobj->next = next; - SWIG_Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - SWIG_Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; - if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { - return NULL; - } else { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { - if (PyObject_IsTrue(val)) { - SWIG_Py_DECREF(SwigPyObject_acquire(v,args)); - } else { - SWIG_Py_DECREF(SwigPyObject_disown(v,args)); - } - } - return obj; - } -} - -static PyMethodDef -SwigPyObject_methods[] = { - {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, - {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, - {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, - {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, - {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, - {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, - {0, 0, 0, 0} -}; - -SWIGRUNTIME PyTypeObject* -SwigPyObject_TypeOnce(void) { - static char SwigPyObject_doc[] = "Swig object holding a C/C++ pointer"; -#ifndef SWIG_HEAPTYPES - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ -#else - 0, /*nb_reserved*/ -#endif - (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ -#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#else - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#endif - }; - - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - SWIG_RUNTIME_MODULE ".SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /* tp_print */ -#else - (Py_ssize_t)0, /* tp_vectorcall_offset */ -#endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ -#else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - SwigPyObject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - SwigPyObject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#if PY_VERSION_HEX >= 0x030c0000 - 0, /* tp_watched */ -#endif -#if PY_VERSION_HEX >= 0x030d00a4 - 0, /* tp_versions_used */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - PyObject *runtime_data_module = SWIG_runtime_data_module(); - swigpyobject_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpyobject_type) != 0) - return NULL; - if (PyModule_AddObject(runtime_data_module, "SwigPyObject", (PyObject *)&swigpyobject_type) == 0) - SWIG_Py_INCREF((PyObject *)&swigpyobject_type); - } - return &swigpyobject_type; -#else - PyType_Slot slots[] = { - { Py_tp_dealloc, (void *)SwigPyObject_dealloc }, - { Py_tp_repr, (void *)SwigPyObject_repr }, - { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, - { Py_tp_doc, (void *)SwigPyObject_doc }, - { Py_tp_richcompare, (void *)SwigPyObject_richcompare }, - { Py_tp_methods, (void *)SwigPyObject_methods }, - { Py_nb_int, (void *)SwigPyObject_long }, - { 0, NULL } - }; - PyType_Spec spec = { - SWIG_RUNTIME_MODULE ".SwigPyObject", - sizeof(SwigPyObject), - 0, - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, - slots - }; - PyObject *pytype = PyType_FromSpec(&spec); - PyObject *runtime_data_module = SWIG_runtime_data_module(); - if (pytype && PyModule_AddObject(runtime_data_module, "SwigPyObject", pytype) == 0) - SWIG_Py_INCREF(pytype); - return (PyTypeObject *)pytype; -#endif -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) -{ - SwigPyObject *sobj = PyObject_New(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; -#ifdef SWIGPYTHON_BUILTIN - sobj->dict = 0; -#endif - if (own == SWIG_POINTER_OWN) { - /* Obtain a reference to the Python capsule wrapping the module information, so that the - * module information is correctly destroyed after all SWIG python objects have been freed - * by the GC (and corresponding destructors invoked) */ - SWIG_Py_XINCREF(Swig_Capsule_global); - } - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} SwigPyPacked; - -SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } -} - -SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { -#ifdef Py_LIMITED_API - int cmp; - PyObject *tp_name; -#endif - PyTypeObject* op_type = Py_TYPE(op); - if (op_type == SwigPyPacked_type()) - return 1; -#ifdef Py_LIMITED_API - tp_name = PyObject_GetAttrString((PyObject *)op_type, "__name__"); - if (!tp_name) - return 0; - cmp = PyUnicode_CompareWithASCIIString(tp_name, "SwigPyPacked"); - SWIG_Py_DECREF(tp_name); - return cmp == 0; -#else - return (strcmp(op_type->tp_name, SWIG_RUNTIME_MODULE ".SwigPyPacked") == 0); -#endif -} - -SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) -{ - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_Free(v); -} - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_TypeOnce(void) { - static char SwigPyPacked_doc[] = "Swig object holding a C/C++ function pointer"; -#ifndef SWIG_HEAPTYPES - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - SWIG_RUNTIME_MODULE ".SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x030800b4 - (printfunc)0, /* tp_print */ -#else - (Py_ssize_t)0, /* tp_vectorcall_offset */ -#endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - SwigPyPacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#if PY_VERSION_HEX >= 0x030c0000 - 0, /* tp_watched */ -#endif -#if PY_VERSION_HEX >= 0x030d00a4 - 0, /* tp_versions_used */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - PyObject *runtime_data_module = SWIG_runtime_data_module(); - swigpypacked_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpypacked_type) != 0) - return NULL; - if (PyModule_AddObject(runtime_data_module, "SwigPyPacked", (PyObject *)&swigpypacked_type) == 0) - SWIG_Py_INCREF((PyObject *)&swigpypacked_type); - } - return &swigpypacked_type; -#else - PyType_Slot slots[] = { - { Py_tp_dealloc, (void *)SwigPyPacked_dealloc }, - { Py_tp_repr, (void *)SwigPyPacked_repr }, - { Py_tp_str, (void *)SwigPyPacked_str }, - { Py_tp_getattro, (void *)PyObject_GenericGetAttr }, - { Py_tp_doc, (void *)SwigPyPacked_doc }, - { 0, NULL } - }; - PyType_Spec spec = { - SWIG_RUNTIME_MODULE ".SwigPyPacked", - sizeof(SwigPyPacked), - 0, - Py_TPFLAGS_DEFAULT, - slots - }; - PyObject *pytype = PyType_FromSpec(&spec); - PyObject *runtime_data_module = SWIG_runtime_data_module(); - if (pytype && PyModule_AddObject(runtime_data_module, "SwigPyPacked", pytype) == 0) - SWIG_Py_INCREF(pytype); - return (PyTypeObject *)pytype; -#endif -} - -SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - SwigPyPacked *sobj = PyObject_New(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_Free((PyObject *)sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -static PyObject *Swig_This_global = NULL; - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - if (Swig_This_global == NULL) - Swig_This_global = SWIG_Python_str_FromChar("this"); - return Swig_This_global; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - PyObject *obj; - - if (SwigPyObject_Check(pyobj)) - return (SwigPyObject *) pyobj; - -#ifdef SWIGPYTHON_BUILTIN - (void)obj; -# ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { -#if PY_VERSION_HEX >= 0x030d0000 - PyWeakref_GetRef(pyobj, &pyobj); - Py_DECREF(pyobj); -#else - pyobj = PyWeakref_GET_OBJECT(pyobj); -#endif - if (pyobj && SwigPyObject_Check(pyobj)) - return (SwigPyObject*) pyobj; - } -# endif - return NULL; -#else - - obj = 0; - -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - SWIG_Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - SWIG_Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; -#endif -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - int res; - SwigPyObject *sobj; - int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; - - if (!obj) - return SWIG_ERROR; - if (obj == Py_None && !implicit_conv) { - if (ptr) - *ptr = 0; - return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; - } - - res = SWIG_ERROR; - - sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&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; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !sobj->own) { - res = SWIG_ERROR_RELEASE_NOT_OWNED; - } else { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - if (flags & SWIG_POINTER_CLEAR) { - sobj->ptr = 0; - } - res = SWIG_OK; - } - } else { - if (implicit_conv) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - SWIG_Py_DECREF(impconv); - } - } - } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; - } - } - } - return res; -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - swig_cast_info *tc; - - /* here we get the method pointer for callbacks */ -#ifndef Py_LIMITED_API - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); -#else - PyObject* pystr_doc = PyObject_GetAttrString(obj, "__doc__"); - PyObject *bytes = NULL; - const char *doc = pystr_doc ? SWIG_PyUnicode_AsUTF8AndSize(pystr_doc, NULL, &bytes) : 0; -#endif - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; -#ifdef Py_LIMITED_API - SWIG_Py_XDECREF(bytes); - SWIG_Py_XDECREF(pystr_doc); -#endif - if (!desc) - return SWIG_ERROR; - tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - return SWIG_OK; - } -} - -/* Convert a packed pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, without calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) -{ - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - } else{ - SWIG_Py_DECREF(inst); - inst = 0; - } - } -#else - if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { - SWIG_Py_DECREF(inst); - inst = 0; - } -#endif - } - } else { -#if PY_VERSION_HEX >= 0x03000000 - PyObject *empty_args = PyTuple_New(0); - if (empty_args) { - PyObject *empty_kwargs = PyDict_New(); - if (empty_kwargs) { -#ifndef Py_LIMITED_API - newfunc newfn = ((PyTypeObject *)data->newargs)->tp_new; -#else - newfunc newfn = (newfunc)PyType_GetSlot((PyTypeObject *)data->newargs, Py_tp_new); -#endif - inst = newfn((PyTypeObject *)data->newargs, empty_args, empty_kwargs); - SWIG_Py_DECREF(empty_kwargs); - if (inst) { - if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { - SWIG_Py_DECREF(inst); - inst = 0; - } else { - PyType_Modified(Py_TYPE(inst)); - } - } - } - SWIG_Py_DECREF(empty_args); - } -#else - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - SWIG_Py_DECREF(dict); - } -#endif - } - return inst; -} - -SWIGRUNTIME int -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - if (dict) { - return PyDict_SetItem(dict, SWIG_This(), swig_this); - } else{ - return -1; - } - } -#endif - return PyObject_SetAttr(inst, SWIG_This(), swig_this); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { - return NULL; - } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - SWIG_Py_DECREF(SwigPyObject_append((PyObject*) sthis, obj[1])); - } else { - if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) - return NULL; - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { - SwigPyClientData *clientdata; - PyObject * robj; - int own; - - if (!ptr) - return SWIG_Py_Void(); - - clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - if (clientdata && clientdata->pytype) { - SwigPyObject *newobj; - if (flags & SWIG_BUILTIN_TP_INIT) { - newobj = (SwigPyObject*) self; - if (newobj->ptr) { -#ifndef Py_LIMITED_API - allocfunc alloc = clientdata->pytype->tp_alloc; -#else - allocfunc alloc = (allocfunc)PyType_GetSlot(clientdata->pytype, Py_tp_alloc); -#endif - PyObject *next_self = alloc(clientdata->pytype, 0); - while (newobj->next) - newobj = (SwigPyObject *) newobj->next; - newobj->next = next_self; - newobj = (SwigPyObject *)next_self; -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif - } - } else { - newobj = PyObject_New(SwigPyObject, clientdata->pytype); -#ifdef SWIGPYTHON_BUILTIN - if (newobj) { - newobj->dict = 0; - } -#endif - } - if (newobj) { - newobj->ptr = ptr; - newobj->ty = type; - newobj->own = own; - newobj->next = 0; - return (PyObject*) newobj; - } - return SWIG_Py_Void(); - } - - assert(!(flags & SWIG_BUILTIN_TP_INIT)); - - robj = SwigPyObject_New(ptr, type, own); - if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - SWIG_Py_DECREF(robj); - robj = inst; - } - return robj; -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -static PyObject *Swig_TypeCache_global = NULL; - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - if (Swig_TypeCache_global == NULL) { - Swig_TypeCache_global = PyDict_New(); - } - return Swig_TypeCache_global; -} - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { -#ifdef SWIG_LINK_RUNTIME - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); - } -#else - void *type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - return (swig_module_info *) type_pointer; -} - - -#if defined(SWIG_REFCNT_DEBUG) -#define SWIG_PYOBJ_REFCNT(OBJ) fprintf(stdout, "" #OBJ " count %ld\n", (OBJ ? Py_REFCNT(OBJ) : 0)) -#else -#define SWIG_PYOBJ_REFCNT(OBJ) -#endif - -static int interpreter_counter = 0; /* how many (sub-)interpreters are using swig_module's types */ - -SWIGRUNTIME void -SWIG_Python_DestroyModule(PyObject *obj) -{ - swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); - swig_type_info **types = swig_module->types; - size_t i; - if (--interpreter_counter != 0) /* another sub-interpreter may still be using the swig_module's types */ - return; - for (i = 0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - ty->clientdata = 0; - if (data) SwigPyClientData_Del(data); - } - } - SWIG_Py_XDECREF(Swig_This_global); - SWIG_PYOBJ_REFCNT(Swig_This_global); - Swig_This_global = NULL; - - SWIG_Py_XDECREF(Swig_Globals_global); - SWIG_PYOBJ_REFCNT(Swig_Globals_global); - Swig_Globals_global = NULL; - - SWIG_Py_XDECREF(Swig_TypeCache_global); - SWIG_PYOBJ_REFCNT(Swig_TypeCache_global); - Swig_TypeCache_global = NULL; - - SWIG_PYOBJ_REFCNT(Swig_Capsule_global); - Swig_Capsule_global = NULL; - - SWIG_Py_XDECREF(Swig_runtime_data_module_global); - SWIG_PYOBJ_REFCNT(Swig_runtime_data_module_global); - Swig_runtime_data_module_global = NULL; -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - PyObject *runtime_data_module = SWIG_runtime_data_module(); - PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); - if (pointer && runtime_data_module) { - if (PyModule_AddObject(runtime_data_module, SWIGPY_CAPSULE_ATTR_NAME, pointer) == 0) { - ++interpreter_counter; - Swig_Capsule_global = pointer; - } else { - SWIG_Py_DECREF(pointer); - } - } else { - SWIG_Py_XDECREF(pointer); - } -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); - } else { - swig_module_info *swig_module = SWIG_GetModule(0); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCapsule_New((void*) descriptor, NULL, NULL); - if (obj) { - PyDict_SetItem(cache, key, obj); - SWIG_Py_DECREF(obj); - } - } - } - SWIG_Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyObject *bytes = NULL; - const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes); - const char *errmesg = tmp ? tmp : "Invalid error message"; - SWIG_Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, errmesg); - } else { - PyErr_Format(type, "%s %s", errmesg, mesg); - } - SWIG_Py_XDECREF(bytes); - SWIG_Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) -{ - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : ""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - (void) obj; - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { -#ifndef Py_LIMITED_API - /* tp_name is not accessible */ - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - PyObject *bytes = NULL; - const char *cstr = str ? SWIG_PyUnicode_AsUTF8AndSize(str, NULL, &bytes) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - SWIG_Py_XDECREF(bytes); - SWIG_Py_XDECREF(str); - return; - } -#endif - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - } - return result; -} - -#ifdef SWIGPYTHON_BUILTIN -SWIGRUNTIME int -SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { - PyTypeObject *tp = obj->ob_type; - PyObject *descr; - PyObject *encoded_name; - descrsetfunc f; - int res = -1; - -# ifdef Py_USING_UNICODE - if (PyString_Check(name)) { - name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); - if (!name) - return -1; - } else if (!PyUnicode_Check(name)) -# else - if (!PyString_Check(name)) -# endif - { - PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); - return -1; - } else { - SWIG_Py_INCREF(name); - } - - if (!tp->tp_dict) { - if (PyType_Ready(tp) != 0) - goto done; - } - - descr = _PyType_Lookup(tp, name); - f = NULL; - if (descr != NULL) - f = descr->ob_type->tp_descr_set; - if (!f) { - if (PyString_Check(name)) { - encoded_name = name; - SWIG_Py_INCREF(name); - } else { - encoded_name = PyUnicode_AsUTF8String(name); - if (!encoded_name) - goto done; - } - PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); - SWIG_Py_DECREF(encoded_name); - } else { - res = f(descr, obj, value); - } - - done: - SWIG_Py_DECREF(name); - return res; -} -#endif - - -#ifdef __cplusplus -} -#endif diff --git a/contrib/tools/swig/Lib/python/pyruntime.swg b/contrib/tools/swig/Lib/python/pyruntime.swg deleted file mode 100644 index b9210a84b59..00000000000 --- a/contrib/tools/swig/Lib/python/pyruntime.swg +++ /dev/null @@ -1,61 +0,0 @@ -%insert(runtime) %{ -#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) -/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ -# include <math.h> -#endif - -#if !defined(PY_SSIZE_T_CLEAN) && !defined(SWIG_NO_PY_SSIZE_T_CLEAN) -#define PY_SSIZE_T_CLEAN -#endif - -#if __GNUC__ >= 7 -#pragma GCC diagnostic push -#if defined(__cplusplus) && __cplusplus >=201703L -#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */ -#endif -#endif - -#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) -/* Use debug wrappers with the Python release dll */ - -#if defined(_MSC_VER) && _MSC_VER >= 1929 -/* Workaround compilation errors when redefining _DEBUG in MSVC 2019 version 16.10 and later - * See https://github.com/swig/swig/issues/2090 */ -# include <corecrt.h> -#endif - -# undef _DEBUG -# include <Python.h> -# define _DEBUG 1 -#else -# include <Python.h> -#endif - -#if defined(SWIGPYTHON_BUILTIN) && defined(SWIG_HEAPTYPES) -/* SWIG_HEAPTYPES is not ready for use with SWIGPYTHON_BUILTIN, but if turned on manually requires the following */ -#if PY_VERSION_HEX >= 0x03030000 && PY_VERSION_HEX < 0x030c0000 -#error #include <structmember.h> -#define Py_READONLY READONLY -#define Py_T_PYSSIZET T_PYSSIZET -#endif -#endif - -#if __GNUC__ >= 7 -#pragma GCC diagnostic pop -#endif - -#include <stdio.h> -#include <stdlib.h> -%} - -%insert(runtime) "swigrun.swg"; /* SWIG API */ -%insert(runtime) "swigerrors.swg"; /* SWIG errors */ -%insert(runtime) "pyhead.swg"; /* Python includes and fixes */ -%insert(runtime) "pyerrors.swg"; /* Python errors */ -%insert(runtime) "pythreads.swg"; /* Python thread code */ -%insert(runtime) "pyapi.swg"; /* Python API */ -%insert(runtime) "pyrun.swg"; /* Python run-time code */ - -#if defined(SWIGPYTHON_BUILTIN) -%insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */ -#endif diff --git a/contrib/tools/swig/Lib/python/pystdcommon.swg b/contrib/tools/swig/Lib/python/pystdcommon.swg deleted file mode 100644 index afa71350a91..00000000000 --- a/contrib/tools/swig/Lib/python/pystdcommon.swg +++ /dev/null @@ -1,265 +0,0 @@ -%fragment("StdTraits","header",fragment="StdTraitsCommon") -{ -namespace swig { - /* - Traits that provides the from method - */ - template <class Type> struct traits_from_ptr { - static PyObject *from(Type *val, int owner = 0) { - return SWIG_InternalNewPointerObj(val, type_info<Type>(), owner); - } - }; - - template <class Type> struct traits_from { - static PyObject *from(const Type& val) { - return traits_from_ptr<Type>::from(new Type(val), 1); - } - }; - - template <class Type> struct traits_from<Type *> { - static PyObject *from(Type* val) { - return traits_from_ptr<Type>::from(val, 0); - } - }; - - template <class Type> struct traits_from<const Type *> { - static PyObject *from(const Type* val) { - return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0); - } - }; - - - template <class Type> - inline PyObject *from(const Type& val) { - return traits_from<Type>::from(val); - } - - template <class Type> - inline PyObject *from_ptr(Type* val, int owner) { - return traits_from_ptr<Type>::from(val, owner); - } - - /* - Traits that provides the asval/as/check method - */ - template <class Type> - struct traits_asptr { - static int asptr(PyObject *obj, Type **val) { - int res = SWIG_ERROR; - swig_type_info *descriptor = type_info<Type>(); - if (val) { - Type *p = 0; - int newmem = 0; - res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR; - if (SWIG_IsOK(res)) { - if (newmem & SWIG_CAST_NEW_MEMORY) { - res |= SWIG_NEWOBJMASK; - } - *val = p; - } - } else { - res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR; - } - return res; - } - }; - - template <class Type> - inline int asptr(PyObject *obj, Type **vptr) { - return traits_asptr<Type>::asptr(obj, vptr); - } - - template <class Type> - struct traits_asval { - static int asval(PyObject *obj, Type *val) { - if (val) { - Type *p = 0; - int res = traits_asptr<Type>::asptr(obj, &p); - if (!SWIG_IsOK(res)) return res; - if (p) { - typedef typename noconst_traits<Type>::noconst_type noconst_type; - *(const_cast<noconst_type*>(val)) = *p; - if (SWIG_IsNewObj(res)){ - %delete(p); - res = SWIG_DelNewMask(res); - } - return res; - } else { - return SWIG_ERROR; - } - } else { - return traits_asptr<Type>::asptr(obj, (Type **)(0)); - } - } - }; - - template <class Type> struct traits_asval<Type*> { - static int asval(PyObject *obj, Type **val) { - if (val) { - typedef typename noconst_traits<Type>::noconst_type noconst_type; - noconst_type *p = 0; - int res = traits_asptr<noconst_type>::asptr(obj, &p); - if (SWIG_IsOK(res)) { - *(const_cast<noconst_type**>(val)) = p; - } - return res; - } else { - return traits_asptr<Type>::asptr(obj, (Type **)(0)); - } - } - }; - - template <class Type> - inline int asval(PyObject *obj, Type *val) { - return traits_asval<Type>::asval(obj, val); - } - - template <class Type> - struct traits_as<Type, value_category> { - static Type as(PyObject *obj) { - Type v; - int res = asval(obj, &v); - if (!obj || !SWIG_IsOK(res)) { - if (!PyErr_Occurred()) { - ::%type_error(swig::type_name<Type>()); - } - throw std::invalid_argument("bad type"); - } - return v; - } - }; - - template <class Type> - struct traits_as<Type, pointer_category> { - static Type as(PyObject *obj) { - Type *v = 0; - int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); - if (SWIG_IsOK(res) && v) { - if (SWIG_IsNewObj(res)) { - Type r(*v); - %delete(v); - return r; - } else { - return *v; - } - } else { - if (!PyErr_Occurred()) { - %type_error(swig::type_name<Type>()); - } - throw std::invalid_argument("bad type"); - } - } - }; - - template <class Type> - struct traits_as<Type*, pointer_category> { - static Type* as(PyObject *obj) { - Type *v = 0; - int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR); - if (SWIG_IsOK(res)) { - return v; - } else { - if (!PyErr_Occurred()) { - %type_error(swig::type_name<Type>()); - } - throw std::invalid_argument("bad type"); - } - } - }; - - template <class Type> - inline Type as(PyObject *obj) { - return traits_as<Type, typename traits<Type>::category>::as(obj); - } - - template <class Type> - struct traits_check<Type, value_category> { - static bool check(PyObject *obj) { - int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; - return SWIG_IsOK(res) ? true : false; - } - }; - - template <class Type> - struct traits_check<Type, pointer_category> { - static bool check(PyObject *obj) { - int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; - return SWIG_IsOK(res) ? true : false; - } - }; - - template <class Type> - inline bool check(PyObject *obj) { - return traits_check<Type, typename traits<Type>::category>::check(obj); - } -} -} - -// -// Backward compatibility -// - -#ifdef SWIG_PYTHON_BACKWARD_COMP -%fragment("<string>"); -%{ -PyObject* SwigInt_FromBool(bool b) { - return PyInt_FromLong(b ? 1L : 0L); -} -double SwigNumber_Check(PyObject* o) { - return PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o); -} -double SwigNumber_AsDouble(PyObject* o) { - return PyFloat_Check(o) ? PyFloat_AsDouble(o) - : (PyInt_Check(o) ? double(PyInt_AsLong(o)) - : double(PyLong_AsLong(o))); -} -PyObject* SwigString_FromString(const std::string& s) { - return PyString_FromStringAndSize(s.data(),s.size()); -} -std::string SwigString_AsString(PyObject* o) { - return std::string(PyString_AsString(o)); -} -%} - -#endif - - -%define %specialize_std_container(Type,Check,As,From) -%{ -namespace swig { - template <> struct traits_asval<Type > { - typedef Type value_type; - static int asval(PyObject *obj, value_type *val) { - if (Check(obj)) { - if (val) *val = As(obj); - return SWIG_OK; - } - return SWIG_ERROR; - } - }; - template <> struct traits_from<Type > { - typedef Type value_type; - static PyObject *from(const value_type& val) { - return From(val); - } - }; - - template <> - struct traits_check<Type, value_category> { - static int check(PyObject *obj) { - int res = Check(obj); - return obj && res ? res : 0; - } - }; -} -%} -%enddef - - -#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) -#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) -#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) -#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) -#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) -#define specialize_std_unordered_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) -#define specialize_std_unordered_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From) diff --git a/contrib/tools/swig/Lib/python/pystrings.swg b/contrib/tools/swig/Lib/python/pystrings.swg deleted file mode 100644 index 9797d1f75e8..00000000000 --- a/contrib/tools/swig/Lib/python/pystrings.swg +++ /dev/null @@ -1,117 +0,0 @@ -/* ------------------------------------------------------------ - * utility methods for char strings - * ------------------------------------------------------------ */ -%fragment("SWIG_AsCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { -/* Return string from Python obj. NOTE: obj must remain in scope in order - to use the returned cptr (but only when alloc is set to SWIG_OLDOBJ) */ -SWIGINTERN int -SWIG_AsCharPtrAndSize(PyObject *obj, char **cptr, size_t *psize, int *alloc) -{ -%#if PY_VERSION_HEX>=0x03000000 -%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_Check(obj)) -%#else - if (PyUnicode_Check(obj)) -%#endif -%#else - if (PyString_Check(obj)) -%#endif - { - char *cstr; Py_ssize_t len; - PyObject *bytes = NULL; - int ret = SWIG_OK; - if (alloc) - *alloc = SWIG_OLDOBJ; -%#if PY_VERSION_HEX>=0x03000000 && defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) - return SWIG_TypeError; -%#else - cstr = (char *)SWIG_PyUnicode_AsUTF8AndSize(obj, &len, &bytes); - if (!cstr) - return SWIG_TypeError; - /* The returned string is only duplicated if the char * returned is not owned and memory managed by obj */ - if (bytes && cptr) { - if (alloc) { - cstr = %new_copy_array(cstr, len + 1, char); - *alloc = SWIG_NEWOBJ; - } else { - /* alloc must be set in order to clean up allocated memory */ - return SWIG_RuntimeError; - } - } -%#endif - if (cptr) *cptr = cstr; - if (psize) *psize = len + 1; - SWIG_Py_XDECREF(bytes); - return ret; - } else { -%#if defined(SWIG_PYTHON_2_UNICODE) -%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) -%#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" -%#endif -%#if PY_VERSION_HEX<0x03000000 - if (PyUnicode_Check(obj)) { - char *cstr; Py_ssize_t len; - if (!alloc && cptr) { - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - if (!obj) - return SWIG_TypeError; - if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { - if (cptr) { - if (alloc) *alloc = SWIG_NEWOBJ; - *cptr = %new_copy_array(cstr, len + 1, char); - } - if (psize) *psize = len + 1; - - SWIG_Py_XDECREF(obj); - return SWIG_OK; - } else { - SWIG_Py_XDECREF(obj); - } - } -%#endif -%#endif - - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void* vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} -} - -%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char* carray, size_t size) -{ - if (carray) { - if (size > INT_MAX) { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { -%#if PY_VERSION_HEX >= 0x03000000 -%#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - return PyBytes_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); -%#else - return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape"); -%#endif -%#else - return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); -%#endif - } - } else { - return SWIG_Py_Void(); - } -} -} - diff --git a/contrib/tools/swig/Lib/python/python.swg b/contrib/tools/swig/Lib/python/python.swg deleted file mode 100644 index 769d9e104a0..00000000000 --- a/contrib/tools/swig/Lib/python/python.swg +++ /dev/null @@ -1,59 +0,0 @@ -/* ------------------------------------------------------------ - * python.swg - * - * Python configuration module. - * ------------------------------------------------------------ */ - -/* ------------------------------------------------------------ - * Inner macros - * ------------------------------------------------------------ */ -%include <pymacros.swg> - - -/* ------------------------------------------------------------ - * The runtime part - * ------------------------------------------------------------ */ -%include <pyruntime.swg> - -/* ------------------------------------------------------------ - * Special user directives - * ------------------------------------------------------------ */ -%include <pyuserdir.swg> - -/* ------------------------------------------------------------ - * Typemap specializations - * ------------------------------------------------------------ */ -%include <pytypemaps.swg> - -/* ------------------------------------------------------------ - * Overloaded operator support - * ------------------------------------------------------------ */ -%include <pyopers.swg> - -/* ------------------------------------------------------------ - * Warnings for Python keywords - * ------------------------------------------------------------ */ -%include <pythonkw.swg> - -/* ------------------------------------------------------------ - * The Python autodoc support - * ------------------------------------------------------------ */ -%include <pydocs.swg> - -/* ------------------------------------------------------------ - * The Python classes, for C++ - * ------------------------------------------------------------ */ -%include <pyclasses.swg> - -/* ------------------------------------------------------------ - * The Python initialization function - * ------------------------------------------------------------ */ -%include <pyinit.swg> - - -/* ------------------------------------------------------------ - * For backward compatibility - * ------------------------------------------------------------ */ -%include <pybackward.swg> - - diff --git a/contrib/tools/swig/Lib/python/pythonkw.swg b/contrib/tools/swig/Lib/python/pythonkw.swg deleted file mode 100644 index a21034524fd..00000000000 --- a/contrib/tools/swig/Lib/python/pythonkw.swg +++ /dev/null @@ -1,140 +0,0 @@ -/* - Warnings for Python keywords, built-in names and bad names. -*/ - -#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword", rename="_%s") `x` -#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") `x` - - -/* - Warnings for Python keywords - https://docs.python.org/2/reference/lexical_analysis.html#keywords -*/ - -PYTHONKW(and); -PYTHONKW(as); -PYTHONKW(assert); -PYTHONKW(async); -PYTHONKW(await); -PYTHONKW(break); -PYTHONKW(class); -PYTHONKW(continue); -PYTHONKW(def); -PYTHONKW(del); -PYTHONKW(elif); -PYTHONKW(else); -PYTHONKW(except); -PYTHONKW(exec); -PYTHONKW(finally); -PYTHONKW(for); -PYTHONKW(from); -PYTHONKW(global); -PYTHONKW(if); -PYTHONKW(import); -PYTHONKW(in); -PYTHONKW(is); -PYTHONKW(lambda); -PYTHONKW(not); -PYTHONKW(or); -PYTHONKW(pass); -PYTHONKW(print); -PYTHONKW(raise); -PYTHONKW(return); -PYTHONKW(try); -PYTHONKW(while); -PYTHONKW(with); -PYTHONKW(yield); - -/* - built-in functions - https://docs.python.org/2/library/functions.html - */ - -PYTHONBN(abs); -PYTHONBN(apply); -PYTHONBN(bool); -PYTHONBN(buffer); -PYTHONBN(callable); -PYTHONBN(chr); -PYTHONBN(classmethod); -PYTHONBN(cmp); -PYTHONBN(coerce); -PYTHONBN(compile); -PYTHONBN(complex); -PYTHONBN(delattr); -PYTHONBN(dict); -PYTHONBN(dir); -PYTHONBN(divmod); -PYTHONBN(enumerate); -PYTHONBN(eval); -PYTHONBN(execfile); -PYTHONBN(file); -PYTHONBN(filter); -PYTHONBN(float); -PYTHONBN(frozenset); -PYTHONBN(getattr); -PYTHONBN(globals); -PYTHONBN(hasattr); -PYTHONBN(hash); -PYTHONBN(hex); -PYTHONBN(id); -PYTHONBN(input); -PYTHONBN(int); -PYTHONBN(intern); -PYTHONBN(isinstance); -PYTHONBN(issubclass); -PYTHONBN(iter); -PYTHONBN(len); -PYTHONBN(list); -PYTHONBN(locals); -PYTHONBN(long); -PYTHONBN(map); -PYTHONBN(max); -PYTHONBN(min); -PYTHONBN(object); -PYTHONBN(oct); -PYTHONBN(open); -PYTHONBN(ord); -PYTHONBN(pow); -PYTHONBN(property); -PYTHONBN(range); -PYTHONBN(raw_input); -PYTHONBN(reduce); -PYTHONBN(reload); -PYTHONBN(repr); -PYTHONBN(reversed); -PYTHONBN(round); -PYTHONBN(set); -PYTHONBN(setattr); -PYTHONBN(slice); -PYTHONBN(sorted); -PYTHONBN(staticmethod); -PYTHONBN(str); -PYTHONBN(sum); -PYTHONBN(super); -PYTHONBN(tuple); -PYTHONBN(type); -PYTHONBN(unichr); -PYTHONBN(unicode); -PYTHONBN(vars); -PYTHONBN(xrange); -PYTHONBN(zip); - - -/* - built-in names - boolean type and None -*/ -PYTHONBN(True); -PYTHONBN(False); - -PYTHONKW(None); - - -/* - 'self' is also a bad Name -*/ -PYTHONKW(self); - -#undef PYTHONBN -#undef PYTHONKW diff --git a/contrib/tools/swig/Lib/python/pythreads.swg b/contrib/tools/swig/Lib/python/pythreads.swg deleted file mode 100644 index 96a64710c38..00000000000 --- a/contrib/tools/swig/Lib/python/pythreads.swg +++ /dev/null @@ -1,68 +0,0 @@ -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# define SWIG_PYTHON_USE_GIL -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# if PY_VERSION_HEX < 0x03070000 -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# else -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { status = false; PyEval_RestoreThread(save); }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif diff --git a/contrib/tools/swig/Lib/python/pytypemaps.swg b/contrib/tools/swig/Lib/python/pytypemaps.swg deleted file mode 100644 index f4a6e457705..00000000000 --- a/contrib/tools/swig/Lib/python/pytypemaps.swg +++ /dev/null @@ -1,103 +0,0 @@ -/* ------------------------------------------------------------ - * Typemap specializations for Python - * ------------------------------------------------------------ */ - -/* ------------------------------------------------------------ - * Fragment section - * ------------------------------------------------------------ */ -#ifdef SWIG_PYTHON_LEGACY_BOOL -// Default prior to SWIG 3.0.0 -#undef SWIG_TYPECHECK_BOOL -%define SWIG_TYPECHECK_BOOL 10000 %enddef -#endif - -/* Include fundamental fragment definitions */ -%include <typemaps/fragments.swg> - -/* Look for user fragments file. */ -%include <pyfragments.swg> - -/* Python fragments for fundamental types */ -%include <pyprimtypes.swg> - -/* Python fragments for char* strings */ -%include <pystrings.swg> - - -/* ------------------------------------------------------------ - * Unified typemap section - * ------------------------------------------------------------ */ - -/* directors are supported in Python */ -#ifndef SWIG_DIRECTOR_TYPEMAPS -#define SWIG_DIRECTOR_TYPEMAPS -#endif - - -/* Python types */ -#define SWIG_Object PyObject * -#define VOID_Object SWIG_Py_Void() - -/* Python allows implicit conversion */ -#define %implicitconv_flag $implicitconv - - -/* Overload of the output/constant/exception/dirout handling */ - -/* append output */ -#define SWIG_AppendOutput(result, obj) SWIG_Python_AppendOutput(result, obj, $isvoid) - -/* set constant */ -#if defined(SWIGPYTHON_BUILTIN) -#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, name,obj) -#else -#define SWIG_SetConstant(name, obj) SWIG_Python_SetConstant(d, name,obj) -#endif - -/* raise */ -#define SWIG_Raise(obj, type, desc) SWIG_Python_Raise(obj, type, desc) - -/* clear errors */ -#define %error_clear PyErr_Clear() - -/* Include the unified typemap library */ -%include <typemaps/swigtypemaps.swg> - - -/* ------------------------------------------------------------ - * Python extra typemaps / typemap overrides - * ------------------------------------------------------------ */ - -/* Get the address of the 'python self' object */ - -%typemap(in,numinputs=0,noblock=1) PyObject **PYTHON_SELF { - $1 = &$self; -} - - -/* Consttab, needed for callbacks, it should be removed later */ - -%typemap(consttab) SWIGTYPE ((*)(ANY)) -{ SWIG_PY_POINTER, "$symname", 0, 0, (void *)($value), &$descriptor } -%typemap(consttab) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY)); - -%typemap(constcode) SWIGTYPE ((*)(ANY)) "" -%typemap(constcode) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY)); - - -/* Smart Pointers */ -%typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER { - $result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags); -} - -%typemap(ret,noblock=1) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER { - if ($result) { - PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); - if (robj && !PyErr_Occurred()) { - SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), - (PyObject *) SWIG_Python_GetSwigThis(robj)); - SWIG_Py_DECREF(robj); - } - } -} - diff --git a/contrib/tools/swig/Lib/python/pyuserdir.swg b/contrib/tools/swig/Lib/python/pyuserdir.swg deleted file mode 100644 index 3110760793e..00000000000 --- a/contrib/tools/swig/Lib/python/pyuserdir.swg +++ /dev/null @@ -1,242 +0,0 @@ -/* ------------------------------------------------------------------------- - * Special user directives - * ------------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------------- */ - -/* shadow code */ -#define %shadow %insert("shadow") -#define %pythoncode %insert("python") -#define %pythonbegin %insert("pythonbegin") - - -/* ------------------------------------------------------------------------- */ -/* -Use the "nondynamic" feature to make a wrapped class behave as a "nondynamic" -one, ie, a python class that doesn't dynamically add new attributes. - -For example, for the class - -%pythonnondynamic A; -struct A -{ - int a; - int b; -}; - -you will get: - - aa = A() - aa.a = 1 # Ok - aa.b = 1 # Ok - aa.c = 3 # error - -Since nondynamic is a feature, if you use it like - - %pythonnondynamic; - -it will make all the wrapped classes nondynamic ones. - -The implementation is based on this recipe: - - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 - -*/ - -#define %pythonnondynamic %feature("python:nondynamic", "1") -#define %nopythonnondynamic %feature("python:nondynamic", "0") -#define %clearpythonnondynamic %feature("python:nondynamic", "") -#define %pythondynamic %nopythonnondynamic - - -/* ------------------------------------------------------------------------- */ -/* - -Use %pythonmaybecall to flag a method like __add__ or __radd__. These -don't produce an error when called, they just return NotImplemented. - -These methods "may be called" if needed. - -*/ - -#define %pythonmaybecall %feature("python:maybecall", "1") -#define %nopythonmaybecall %feature("python:maybecall", "0") -#define %clearpythonmaybecall %feature("python:maybecall", "") - -/* ------------------------------------------------------------------------- */ -/* - The %pythoncallback feature produce a more natural callback wrapper - than the %callback mechanism, ie, it uses the original name for - the callback and callable objects. - - Just use it as - - %pythoncallback(1) foo; - int foo(int a); - - %pythoncallback(1) A::foo; - struct A { - static int foo(int a); - }; - - int bar(int, int (*pf)(int)); - - then, you can use it as: - - a = foo(1) - b = bar(2, foo) - - c = A.foo(3) - d = bar(4, A.foo) - - - If you use it with a member method - %pythoncallback(1) A::foom; - struct A { - int foom(int a); - }; - - then you can use it as - - r = a.foom(3) # eval the method - mptr = A.foom_cb_ptr # returns the callback pointer - - where the '_cb_ptr' suffix is added for the callback pointer. - -*/ - -#define %pythoncallback %feature("python:callback") -#define %nopythoncallback %feature("python:callback","0") -#define %clearpythoncallback %feature("python:callback","") - -/* ------------------------------------------------------------------------- */ -/* - Support for the old %callback directive name -*/ -#ifdef %callback -#undef %callback -#endif - -#ifdef %nocallback -#undef %nocallback -#endif - -#ifdef %clearcallback -#undef %clearcallback -#endif - -#define %callback(x) %feature("python:callback",`x`) -#define %nocallback %nopythoncallback -#define %clearcallback %clearpythoncallback - -/* ------------------------------------------------------------------------- */ -/* - Thread support - Advance control - -*/ - -#define %nothread %feature("nothread") -#define %thread %feature("nothread","0") -#define %clearnothread %feature("nothread","") - -#define %nothreadblock %feature("nothreadblock") -#define %threadblock %feature("nothreadblock","0") -#define %clearnothreadblock %feature("nothreadblock","") - -#define %nothreadallow %feature("nothreadallow") -#define %threadallow %feature("nothreadallow","0") -#define %clearnothreadallow %feature("nothreadallow","") - - -/* ------------------------------------------------------------------------- */ -/* - Implicit Conversion using the C++ constructor mechanism -*/ - -#define %implicitconv %feature("implicitconv") -#define %noimplicitconv %feature("implicitconv", "0") -#define %clearimplicitconv %feature("implicitconv", "") - - -/* ------------------------------------------------------------------------- */ -/* - Enable keywords parameters -*/ - -#define %kwargs %feature("kwargs") -#define %nokwargs %feature("kwargs", "0") -#define %clearkwargs %feature("kwargs", "") - -/* ------------------------------------------------------------------------- */ -/* - Add python code to the proxy/shadow code - - %pythonprepend - Add code before the C++ function is called - %pythonappend - Add code after the C++ function is called -*/ - -#define %pythonprepend %feature("pythonprepend") -#define %clearpythonprepend %feature("pythonprepend","") - -#define %pythonappend %feature("pythonappend") -#define %clearpythonappend %feature("pythonappend","") - - -/* ------------------------------------------------------------------------- */ -/* - %extend_smart_pointer extend the smart pointer support. - - For example, if you have a smart pointer as: - - template <class Type> class RCPtr { - public: - ... - RCPtr(Type *p); - Type * operator->() const; - ... - }; - - you use the %extend_smart_pointer directive as: - - %extend_smart_pointer(RCPtr<A>); - %template(RCPtr_A) RCPtr<A>; - - then, if you have something like: - - RCPtr<A> make_ptr(); - int foo(A *); - - you can do the following: - - a = make_ptr(); - b = foo(a); - - ie, swig will accept a RCPtr<A> object where a 'A *' is - expected. - - Also, when using vectors - - %extend_smart_pointer(RCPtr<A>); - %template(RCPtr_A) RCPtr<A>; - %template(vector_A) std::vector<RCPtr<A> >; - - you can type - - a = A(); - v = vector_A(2) - v[0] = a - - ie, an 'A *' object is accepted, via implicit conversion, - where a RCPtr<A> object is expected. Additionally - - x = v[0] - - returns (and sets 'x' as) a copy of v[0], making reference - counting possible and consistent. -*/ - -%define %extend_smart_pointer(Type...) -%implicitconv Type; -%apply const SWIGTYPE& SMARTPOINTER { const Type& }; -%apply SWIGTYPE SMARTPOINTER { Type }; -%enddef diff --git a/contrib/tools/swig/Lib/python/pywstrings.swg b/contrib/tools/swig/Lib/python/pywstrings.swg deleted file mode 100644 index 903885abb58..00000000000 --- a/contrib/tools/swig/Lib/python/pywstrings.swg +++ /dev/null @@ -1,89 +0,0 @@ -/* ------------------------------------------------------------ - * utility methods for wchar_t strings - * ------------------------------------------------------------ */ - -%{ -#if PY_VERSION_HEX >= 0x03020000 -# define SWIGPY_UNICODE_ARG(obj) ((PyObject*) (obj)) -#else -# define SWIGPY_UNICODE_ARG(obj) ((PyUnicodeObject*) (obj)) -#endif -%} - -%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { -SWIGINTERN int -SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) -{ - PyObject *tmp = 0; - int isunicode = PyUnicode_Check(obj); -%#if PY_VERSION_HEX < 0x03000000 && !defined(SWIG_PYTHON_STRICT_UNICODE_WCHAR) - if (!isunicode && PyString_Check(obj)) { - tmp = PyUnicode_FromObject(obj); - if (tmp) { - isunicode = 1; - obj = tmp; - } else { - PyErr_Clear(); - return SWIG_TypeError; - } - } -%#endif - if (isunicode) { -%#if PY_VERSION_HEX >= 0x03030000 -%# if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 - Py_ssize_t len = PyUnicode_GetLength(obj); -%# else - Py_ssize_t len = PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), NULL, 0) - 1; -%# endif -%#else - Py_ssize_t len = PyUnicode_GetSize(obj); -%#endif - if (cptr) { - Py_ssize_t length; - *cptr = %new_array(len + 1, wchar_t); - length = PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len); - if (length == -1) { - PyErr_Clear(); - SWIG_Py_XDECREF(tmp); - return SWIG_TypeError; - } - (*cptr)[length] = 0; - } - if (psize) *psize = (size_t) len + 1; - if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; - SWIG_Py_XDECREF(tmp); - return SWIG_OK; - } else { - swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); - if (pwchar_descriptor) { - void * vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (wchar_t *)vptr; - if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} -} - -%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") { -SWIGINTERNINLINE PyObject * -SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size) -{ - if (carray) { - if (size > INT_MAX) { - swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor(); - return pwchar_descriptor ? - SWIG_InternalNewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void(); - } else { - return PyUnicode_FromWideChar(carray, %numeric_cast(size, Py_ssize_t)); - } - } else { - return SWIG_Py_Void(); - } -} -} - - diff --git a/contrib/tools/swig/Lib/python/std_alloc.i b/contrib/tools/swig/Lib/python/std_alloc.i deleted file mode 100644 index 35dc051beab..00000000000 --- a/contrib/tools/swig/Lib/python/std_alloc.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_alloc.i> diff --git a/contrib/tools/swig/Lib/python/std_array.i b/contrib/tools/swig/Lib/python/std_array.i deleted file mode 100644 index 707b354750b..00000000000 --- a/contrib/tools/swig/Lib/python/std_array.i +++ /dev/null @@ -1,119 +0,0 @@ -/* - std::array -*/ - -%fragment("StdArrayTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T, size_t N> - struct traits_asptr<std::array<T, N> > { - static int asptr(PyObject *obj, std::array<T, N> **vec) { - return traits_asptr_stdseq<std::array<T, N> >::asptr(obj, vec); - } - }; - - template <class T, size_t N> - struct traits_from<std::array<T, N> > { - static PyObject *from(const std::array<T, N>& vec) { - return traits_from_stdseq<std::array<T, N> >::from(vec); - } - }; - - template <class T, size_t N> - struct IteratorProtocol<std::array<T, N>, T> { - - static void assign(PyObject *obj, std::array<T, N> *seq) { - SwigVar_PyObject iter = PyObject_GetIter(obj); - if (iter) { - SwigVar_PyObject item = PyIter_Next(iter); - size_t count = 0; - typename std::array<T, N>::iterator array_iter = seq->begin(); - while (item && (count < N)) { - ++count; - *array_iter++ = swig::as<T>(item); - item = PyIter_Next(iter); - } - if (count != N || item) - throw std::invalid_argument("std::array size does not match source container size"); - } - } - - static bool check(PyObject *obj) { - bool ret = false; - SwigVar_PyObject iter = PyObject_GetIter(obj); - if (iter) { - SwigVar_PyObject item = PyIter_Next(iter); - size_t count = 0; - ret = true; - while (item && (count < N)) { - ++count; - ret = swig::check<T>(item); - item = ret ? PyIter_Next(iter) : 0; - } - if (count != N || item) - ret = false; - } - return ret; - } - }; - - template <class T, size_t N> - inline void - erase(std::array<T, N>* SWIGUNUSEDPARM(seq), const typename std::array<T, N>::iterator& SWIGUNUSEDPARM(position)) { - throw std::invalid_argument("std::array object does not support item deletion"); - } - - // Only limited slicing is supported as std::array is fixed in size - template <class T, size_t N, class Difference> - inline std::array<T, N>* - getslice(const std::array<T, N>* self, Difference i, Difference j, Py_ssize_t step) { - typedef std::array<T, N> Sequence; - typename Sequence::size_type size = self->size(); - Difference ii = 0; - Difference jj = 0; - swig::slice_adjust(i, j, step, size, ii, jj); - - if (step == 1 && ii == 0 && static_cast<typename Sequence::size_type>(jj) == size) { - Sequence *sequence = new Sequence(); - std::copy(self->begin(), self->end(), sequence->begin()); - return sequence; - } else if (step == -1 && static_cast<typename Sequence::size_type>(ii) == (size - 1) && jj == -1) { - Sequence *sequence = new Sequence(); - std::copy(self->rbegin(), self->rend(), sequence->begin()); - return sequence; - } else { - throw std::invalid_argument("std::array object only supports getting a slice that is the size of the array"); - } - } - - template <class T, size_t N, class Difference, class InputSeq> - inline void - setslice(std::array<T, N>* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) { - typedef std::array<T, N> Sequence; - typename Sequence::size_type size = self->size(); - Difference ii = 0; - Difference jj = 0; - swig::slice_adjust(i, j, step, size, ii, jj, true); - - if (step == 1 && ii == 0 && static_cast<typename Sequence::size_type>(jj) == size) { - std::copy(is.begin(), is.end(), self->begin()); - } else if (step == -1 && static_cast<typename Sequence::size_type>(ii) == (size - 1) && jj == -1) { - std::copy(is.rbegin(), is.rend(), self->begin()); - } else { - throw std::invalid_argument("std::array object only supports setting a slice that is the size of the array"); - } - } - - template <class T, size_t N, class Difference> - inline void - delslice(std::array<T, N>* SWIGUNUSEDPARM(self), Difference SWIGUNUSEDPARM(i), Difference SWIGUNUSEDPARM(j), Py_ssize_t SWIGUNUSEDPARM(step)) { - throw std::invalid_argument("std::array object does not support item deletion"); - } - } -%} - -#define %swig_array_methods(Type...) %swig_sequence_methods_non_resizable(Type) -#define %swig_array_methods_val(Type...) %swig_sequence_methods_non_resizable_val(Type); - -%include <std/std_array.i> - diff --git a/contrib/tools/swig/Lib/python/std_auto_ptr.i b/contrib/tools/swig/Lib/python/std_auto_ptr.i deleted file mode 100644 index 3d7ae8ba16e..00000000000 --- a/contrib/tools/swig/Lib/python/std_auto_ptr.i +++ /dev/null @@ -1,39 +0,0 @@ -/* ----------------------------------------------------------------------------- - * 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/python/std_basic_string.i b/contrib/tools/swig/Lib/python/std_basic_string.i deleted file mode 100644 index e3f524dbdad..00000000000 --- a/contrib/tools/swig/Lib/python/std_basic_string.i +++ /dev/null @@ -1,89 +0,0 @@ -#if !defined(SWIG_STD_STRING) -#define SWIG_STD_BASIC_STRING - -%include <pycontainer.swg> - -#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type) - - -%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header", - fragment="SWIG_AsCharPtrAndSize") { -SWIGINTERN int -SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val) { - static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string<char> *"); - std::string *vptr; - if (SWIG_IsOK(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0))) { - if (val) *val = vptr; - return SWIG_OLDOBJ; - } else { - PyErr_Clear(); - char* buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_IsOK(SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc))) { - if (buf) { - if (val) *val = new std::string(buf, size - 1); - if (alloc == SWIG_NEWOBJ) %delete_array(buf); - return SWIG_NEWOBJ; - } else { - if (val) *val = 0; - return SWIG_OLDOBJ; - } - } - return SWIG_ERROR; - } -} -} - -%fragment(SWIG_From_frag(std::basic_string<char>),"header", - fragment="SWIG_FromCharPtrAndSize") { -SWIGINTERNINLINE PyObject* - SWIG_From(std::basic_string<char>)(const std::string& s) { - return SWIG_FromCharPtrAndSize(s.data(), s.size()); - } -} - -%include <std/std_basic_string.i> -%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>); - -#endif - - -#if !defined(SWIG_STD_WSTRING) - -%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header", - fragment="SWIG_AsWCharPtrAndSize") { -SWIGINTERN int -SWIG_AsPtr(std::basic_string<wchar_t>)(PyObject* obj, std::wstring **val) { - static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string<wchar_t> *"); - std::wstring *vptr; - if (SWIG_IsOK(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0))) { - if (val) *val = vptr; - return SWIG_OLDOBJ; - } else { - PyErr_Clear(); - wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_IsOK(SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc))) { - if (buf) { - if (val) *val = new std::wstring(buf, size - 1); - if (alloc == SWIG_NEWOBJ) %delete_array(buf); - return SWIG_NEWOBJ; - } else { - if (val) *val = 0; - return SWIG_OLDOBJ; - } - } - return SWIG_ERROR; - } -} -} - -%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header", - fragment="SWIG_FromWCharPtrAndSize") { -SWIGINTERNINLINE PyObject* - SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s) { - return SWIG_FromWCharPtrAndSize(s.data(), s.size()); - } -} - -%typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>); - -#endif diff --git a/contrib/tools/swig/Lib/python/std_char_traits.i b/contrib/tools/swig/Lib/python/std_char_traits.i deleted file mode 100644 index bf4e6c47dd4..00000000000 --- a/contrib/tools/swig/Lib/python/std_char_traits.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_char_traits.i> diff --git a/contrib/tools/swig/Lib/python/std_common.i b/contrib/tools/swig/Lib/python/std_common.i deleted file mode 100644 index 605766238bb..00000000000 --- a/contrib/tools/swig/Lib/python/std_common.i +++ /dev/null @@ -1,74 +0,0 @@ -%include <std/std_except.i> -%include <pystdcommon.swg> - - -/* - Generate the traits for a 'primitive' type, such as 'double', - for which the SWIG_AsVal and SWIG_From methods are already defined. -*/ - -%define %traits_ptypen(Type...) - %fragment(SWIG_Traits_frag(Type),"header", - fragment=SWIG_AsVal_frag(Type), - fragment=SWIG_From_frag(Type), - fragment="StdTraits") { -namespace swig { - template <> struct traits< Type > { - typedef value_category category; - static const char* type_name() { return #Type; } - }; - template <> struct traits_asval< Type > { - typedef Type value_type; - static int asval(PyObject *obj, value_type *val) { - return SWIG_AsVal(Type)(obj, val); - } - }; - template <> struct traits_from< Type > { - typedef Type value_type; - static PyObject *from(const value_type& val) { - return SWIG_From(Type)(val); - } - }; -} -} -%enddef - -/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums - is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit - instantiations required using %template). The STL containers define the 'front' method and the typemap - below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the - standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from - required in the generated code for enums. */ - -%define %traits_enum(Type...) - %fragment("SWIG_Traits_enum_"{Type},"header", - fragment=SWIG_AsVal_frag(int), - fragment=SWIG_From_frag(int), - fragment="StdTraits") { -namespace swig { - template <> struct traits_asval< Type > { - typedef Type value_type; - static int asval(PyObject *obj, value_type *val) { - return SWIG_AsVal(int)(obj, (int *)val); - } - }; - template <> struct traits_from< Type > { - typedef Type value_type; - static PyObject *from(const value_type& val) { - return SWIG_From(int)((int)val); - } - }; -} -} -%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} -%enddef - - -%include <std/std_common.i> - -// -// Generates the traits for all the known primitive -// C++ types (int, double, ...) -// -%apply_cpptypes(%traits_ptypen); - diff --git a/contrib/tools/swig/Lib/python/std_complex.i b/contrib/tools/swig/Lib/python/std_complex.i deleted file mode 100644 index c9c46c4c3bb..00000000000 --- a/contrib/tools/swig/Lib/python/std_complex.i +++ /dev/null @@ -1,27 +0,0 @@ -/* - * STD C++ complex typemaps - */ - -%include <pycomplex.swg> - -%{ -#include <complex> -%} - -namespace std { - %naturalvar complex; - template<typename T> class complex; - %template() complex<double>; - %template() complex<float>; -} - -/* defining the complex as/from converters */ - -%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag) -%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag) - -/* defining the typemaps */ - -%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>); -%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>); - diff --git a/contrib/tools/swig/Lib/python/std_container.i b/contrib/tools/swig/Lib/python/std_container.i deleted file mode 100644 index d24c1570f1d..00000000000 --- a/contrib/tools/swig/Lib/python/std_container.i +++ /dev/null @@ -1,2 +0,0 @@ -%include <pycontainer.swg> -%include <std/std_container.i> diff --git a/contrib/tools/swig/Lib/python/std_deque.i b/contrib/tools/swig/Lib/python/std_deque.i deleted file mode 100644 index d9a174706b3..00000000000 --- a/contrib/tools/swig/Lib/python/std_deque.i +++ /dev/null @@ -1,27 +0,0 @@ -/* - Deques -*/ - -%fragment("StdDequeTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T> - struct traits_asptr<std::deque<T> > { - static int asptr(PyObject *obj, std::deque<T> **vec) { - return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec); - } - }; - - template <class T> - struct traits_from<std::deque<T> > { - static PyObject *from(const std::deque<T>& vec) { - return traits_from_stdseq<std::deque<T> >::from(vec); - } - }; - } -%} - -#define %swig_deque_methods(Type...) %swig_sequence_methods(Type) -#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type); - -%include <std/std_deque.i> diff --git a/contrib/tools/swig/Lib/python/std_except.i b/contrib/tools/swig/Lib/python/std_except.i deleted file mode 100644 index af98428f65d..00000000000 --- a/contrib/tools/swig/Lib/python/std_except.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/std_except.swg> diff --git a/contrib/tools/swig/Lib/python/std_filesystem.i b/contrib/tools/swig/Lib/python/std_filesystem.i deleted file mode 100644 index 4fd1161424a..00000000000 --- a/contrib/tools/swig/Lib/python/std_filesystem.i +++ /dev/null @@ -1,127 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_filesystem.i - * - * SWIG typemaps for std::filesystem::path - * ----------------------------------------------------------------------------- */ - -%{ -#include <filesystem> -%} - -namespace std { - namespace filesystem { - class path; - } -} - -%fragment("SWIG_std_filesystem", "header") { -SWIGINTERN PyObject *SWIG_std_filesystem_importPathClass() { - PyObject *module = PyImport_ImportModule("pathlib"); - PyObject *cls = PyObject_GetAttrString(module, "Path"); - SWIG_Py_DECREF(module); - return cls; -} - -SWIGINTERN bool SWIG_std_filesystem_isPathInstance(PyObject *obj) { - PyObject *cls = SWIG_std_filesystem_importPathClass(); - bool is_instance = PyObject_IsInstance(obj, cls); - SWIG_Py_DECREF(cls); - return is_instance; -} -} - -%typemap(in, fragment="SWIG_std_filesystem", fragment="<type_traits>") std::filesystem::path { - if (PyUnicode_Check($input)) { - PyObject *bytes = NULL; - const char *s = SWIG_PyUnicode_AsUTF8AndSize($input, NULL, &bytes); - $1 = std::filesystem::path(s); - SWIG_Py_XDECREF(bytes); - } else if (SWIG_std_filesystem_isPathInstance($input)) { - PyObject *str_obj = PyObject_Str($input); - if constexpr (std::is_same_v<typename std::filesystem::path::value_type, wchar_t>) { - Py_ssize_t size = 0; - wchar_t *ws = PyUnicode_AsWideCharString(str_obj, &size); - if (!ws) SWIG_fail; - $1 = std::filesystem::path(std::wstring(ws, static_cast<size_t>(size))); - PyMem_Free(ws); - } else { - PyObject *bytes = NULL; - const char *s = SWIG_PyUnicode_AsUTF8AndSize(str_obj, NULL, &bytes); - $1 = std::filesystem::path(s); - SWIG_Py_XDECREF(bytes); - } - SWIG_Py_DECREF(str_obj); - } else { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, $descriptor(std::filesystem::path *), $disown | 0); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - std::filesystem::path *temp = %reinterpret_cast(argp, $1_ltype*); - $1 = *temp; - } -} - -%typemap(in, fragment="SWIG_std_filesystem", fragment="<type_traits>") const std::filesystem::path &(std::filesystem::path temp_path) { - if (PyUnicode_Check($input)) { - PyObject *bytes = NULL; - const char *s = SWIG_PyUnicode_AsUTF8AndSize($input, NULL, &bytes); - temp_path = std::filesystem::path(s); - $1 = &temp_path; - SWIG_Py_XDECREF(bytes); - } else if (SWIG_std_filesystem_isPathInstance($input)) { - PyObject *str_obj = PyObject_Str($input); - if constexpr (std::is_same_v<typename std::filesystem::path::value_type, wchar_t>) { - Py_ssize_t size = 0; - wchar_t *ws = PyUnicode_AsWideCharString(str_obj, &size); - if (!ws) SWIG_fail; - temp_path = std::filesystem::path(std::wstring(ws, static_cast<size_t>(size))); - $1 = &temp_path; - PyMem_Free(ws); - } else { - PyObject *bytes = NULL; - const char *s = SWIG_PyUnicode_AsUTF8AndSize(str_obj, NULL, &bytes); - temp_path = std::filesystem::path(s); - $1 = &temp_path; - SWIG_Py_XDECREF(bytes); - } - SWIG_Py_DECREF(str_obj); - } else { - void *argp = 0; - int res = SWIG_ConvertPtr($input, &argp, $descriptor, $disown | 0); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); - } - $1 = %reinterpret_cast(argp, $1_ltype); - } -} - -%typemap(out, fragment="SWIG_std_filesystem", fragment="<type_traits>") std::filesystem::path { - PyObject *args; - if constexpr (std::is_same_v<typename std::filesystem::path::value_type, wchar_t>) { - std::wstring s = $1.generic_wstring(); - args = Py_BuildValue("(u)", s.data()); - } else { - std::string s = $1.generic_string(); - args = Py_BuildValue("(s)", s.data()); - } - PyObject *cls = SWIG_std_filesystem_importPathClass(); - $result = PyObject_CallObject(cls, args); - SWIG_Py_DECREF(cls); - SWIG_Py_DECREF(args); -} - -%typemap(out, fragment="SWIG_std_filesystem", fragment="<type_traits>") const std::filesystem::path & { - PyObject *args; - if constexpr (std::is_same_v<typename std::filesystem::path::value_type, wchar_t>) { - std::wstring s = $1->generic_wstring(); - args = Py_BuildValue("(u)", s.data()); - } else { - std::string s = $1->generic_string(); - args = Py_BuildValue("(s)", s.data()); - } - PyObject *cls = SWIG_std_filesystem_importPathClass(); - $result = PyObject_CallObject(cls, args); - SWIG_Py_DECREF(cls); - SWIG_Py_DECREF(args); -} diff --git a/contrib/tools/swig/Lib/python/std_ios.i b/contrib/tools/swig/Lib/python/std_ios.i deleted file mode 100644 index aa6f0994d76..00000000000 --- a/contrib/tools/swig/Lib/python/std_ios.i +++ /dev/null @@ -1,3 +0,0 @@ -%rename(ios_base_in) std::ios_base::in; - -%include <std/std_ios.i> diff --git a/contrib/tools/swig/Lib/python/std_iostream.i b/contrib/tools/swig/Lib/python/std_iostream.i deleted file mode 100644 index 43d6b0c24be..00000000000 --- a/contrib/tools/swig/Lib/python/std_iostream.i +++ /dev/null @@ -1,8 +0,0 @@ -namespace std -{ -%callback(1) endl; -%callback(1) ends; -%callback(1) flush; -} - -%include <std/std_iostream.i> diff --git a/contrib/tools/swig/Lib/python/std_list.i b/contrib/tools/swig/Lib/python/std_list.i deleted file mode 100644 index 24d274b423f..00000000000 --- a/contrib/tools/swig/Lib/python/std_list.i +++ /dev/null @@ -1,28 +0,0 @@ -/* - Lists -*/ - -%fragment("StdListTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T > - struct traits_asptr<std::list<T> > { - static int asptr(PyObject *obj, std::list<T> **lis) { - return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis); - } - }; - - template <class T> - struct traits_from<std::list<T> > { - static PyObject *from(const std::list<T>& vec) { - return traits_from_stdseq<std::list<T> >::from(vec); - } - }; - } -%} - -#define %swig_list_methods(Type...) %swig_sequence_methods(Type) -#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type); - -%include <std/std_list.i> - diff --git a/contrib/tools/swig/Lib/python/std_map.i b/contrib/tools/swig/Lib/python/std_map.i deleted file mode 100644 index 954e7eb2d9a..00000000000 --- a/contrib/tools/swig/Lib/python/std_map.i +++ /dev/null @@ -1,304 +0,0 @@ -/* - Maps -*/ - -%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits",fragment="SwigPyIterator_T") -{ - namespace swig { - template <class ValueType> - struct from_key_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v.first); - } - }; - - template <class ValueType> - struct from_value_oper - { - typedef const ValueType& argument_type; - typedef PyObject *result_type; - result_type operator()(argument_type v) const - { - return swig::from(v.second); - } - }; - - template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type> - struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> - { - SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq) - { - } - }; - - - template<class OutIterator, - class FromOper = from_key_oper<typename OutIterator::value_type> > - struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper> - { - SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq) - { - } - }; - - template<typename OutIter> - inline SwigPyIterator* - make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq); - } - - template<class OutIterator, - class FromOper = from_value_oper<typename OutIterator::value_type> > - struct SwigPyMapValueIterator_T : SwigPyMapIterator_T<OutIterator, FromOper> - { - SwigPyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq) - { - } - }; - - - template<typename OutIter> - inline SwigPyIterator* - make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapValueIterator_T<OutIter>(current, begin, end, seq); - } - } -} - -%fragment("StdMapTraits","header",fragment="StdMapCommonTraits") -{ - namespace swig { - template <class K, class T, class Compare, class Alloc> - struct traits_asptr<std::map<K,T,Compare,Alloc > > { - typedef std::map<K,T,Compare,Alloc > map_type; - static int asptr(PyObject *obj, map_type **val) { - int res = SWIG_ERROR; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); -%#if PY_VERSION_HEX >= 0x03000000 - /* In Python 3.x the ".items()" method returns a dict_items object */ - items = PySequence_Fast(items, ".items() didn't return a sequence!"); -%#endif - res = traits_asptr_stdseq<map_type, std::pair<K, T> >::asptr(items, val); - } else { - map_type *p = 0; - swig_type_info *descriptor = swig::type_info<map_type>(); - res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res) && val) *val = p; - } - SWIG_PYTHON_THREAD_END_BLOCK; - return res; - } - }; - - template <class K, class T, class Compare, class Alloc > - struct traits_from<std::map<K,T,Compare,Alloc > > { - typedef std::map<K,T,Compare,Alloc > map_type; - typedef typename map_type::const_iterator const_iterator; - typedef typename map_type::size_type size_type; - - static PyObject *asdict(const map_type& map) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - size_type size = map.size(); - Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return obj; - } - - static PyObject *from(const map_type& map) { - swig_type_info *desc = swig::type_info<map_type>(); - if (desc && desc->clientdata) { - return SWIG_InternalNewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); - } else { - return asdict(map); - } - } - }; - } -} - -%define %swig_map_common(Map...) - %swig_sequence_iterator(Map); - %swig_container_methods(Map) - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_length", functype="lenfunc") __len__; - %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; - %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; - %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; - - %extend { - %newobject iterkeys(PyObject **PYTHON_SELF); - swig::SwigPyIterator* iterkeys(PyObject **PYTHON_SELF) { - return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - - %newobject itervalues(PyObject **PYTHON_SELF); - swig::SwigPyIterator* itervalues(PyObject **PYTHON_SELF) { - return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - - %newobject iteritems(PyObject **PYTHON_SELF); - swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) { - return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - } - -#else - %extend { - %pythoncode %{def __iter__(self): - return self.key_iterator()%} - %pythoncode %{def iterkeys(self): - return self.key_iterator()%} - %pythoncode %{def itervalues(self): - return self.value_iterator()%} - %pythoncode %{def iteritems(self): - return self.iterator()%} - } -#endif - - %extend { - mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) { - Map::const_iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - - void __delitem__(const key_type& key) throw (std::out_of_range) { - Map::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 key_type& key) const { - Map::const_iterator i = self->find(key); - return i != self->end(); - } - - PyObject* keys() { - Map::size_type size = self->size(); - Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject* keyList = PyList_New(pysize); - Map::const_iterator i = self->begin(); - for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { - PyList_SET_ITEM(keyList, j, swig::from(i->first)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return keyList; - } - - PyObject* values() { - Map::size_type size = self->size(); - Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject* valList = PyList_New(pysize); - Map::const_iterator i = self->begin(); - for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { - PyList_SET_ITEM(valList, j, swig::from(i->second)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return valList; - } - - PyObject* items() { - Map::size_type size = self->size(); - Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject* itemList = PyList_New(pysize); - Map::const_iterator i = self->begin(); - for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { - PyList_SET_ITEM(itemList, j, swig::from(*i)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return itemList; - } - - bool __contains__(const key_type& key) { - return self->find(key) != self->end(); - } - - %newobject key_iterator(PyObject **PYTHON_SELF); - swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { - return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - - %newobject value_iterator(PyObject **PYTHON_SELF); - swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { - return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - } - -%enddef - -%define %swig_map_methods(Map...) - %swig_map_common(Map) - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; -#endif - - %extend { - // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(const key_type& key) { - self->erase(key); - } - - void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { -%#ifdef __cpp_lib_map_try_emplace - (*self).insert_or_assign(key, x); -%#else - (*self)[key] = x; -%#endif - } - - PyObject* asdict() { - return swig::traits_from< Map >::asdict(*self); - } - } - - -%enddef - - -%include <std/std_map.i> diff --git a/contrib/tools/swig/Lib/python/std_multimap.i b/contrib/tools/swig/Lib/python/std_multimap.i deleted file mode 100644 index 75b4d7fcfac..00000000000 --- a/contrib/tools/swig/Lib/python/std_multimap.i +++ /dev/null @@ -1,83 +0,0 @@ -/* - Multimaps -*/ -%include <std_map.i> - -%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits") -{ - namespace swig { - template <class K, class T> - struct traits_asptr<std::multimap<K,T> > { - typedef std::multimap<K,T> multimap_type; - static int asptr(PyObject *obj, std::multimap<K,T> **val) { - int res = SWIG_ERROR; - if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); -%#if PY_VERSION_HEX >= 0x03000000 - /* In Python 3.x the ".items()" method returns a dict_items object */ - items = PySequence_Fast(items, ".items() didn't return a sequence!"); -%#endif - res = traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val); - } else { - multimap_type *p = 0; - swig_type_info *descriptor = swig::type_info<multimap_type>(); - res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - } - }; - - template <class K, class T > - struct traits_from<std::multimap<K,T> > { - typedef std::multimap<K,T> multimap_type; - typedef typename multimap_type::const_iterator const_iterator; - typedef typename multimap_type::size_type size_type; - - static PyObject *from(const multimap_type& multimap) { - swig_type_info *desc = swig::type_info<multimap_type>(); - if (desc && desc->clientdata) { - return SWIG_InternalNewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN); - } else { - size_type size = multimap.size(); - Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; - if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, "multimap size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - return obj; - } - } - }; - } -} - -%define %swig_multimap_methods(Type...) - %swig_map_common(Type); - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; -#endif - - %extend { - // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(const key_type& key) { - self->erase(key); - } - - void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { - self->insert(Type::value_type(key,x)); - } - } -%enddef - -%include <std/std_multimap.i> - diff --git a/contrib/tools/swig/Lib/python/std_multiset.i b/contrib/tools/swig/Lib/python/std_multiset.i deleted file mode 100644 index b79f64e5a31..00000000000 --- a/contrib/tools/swig/Lib/python/std_multiset.i +++ /dev/null @@ -1,30 +0,0 @@ -/* - Multisets -*/ - -%include <std_set.i> - -%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T> - struct traits_asptr<std::multiset<T> > { - static int asptr(PyObject *obj, std::multiset<T> **m) { - return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, m); - } - }; - - template <class T> - struct traits_from<std::multiset<T> > { - static PyObject *from(const std::multiset<T>& vec) { - return traits_from_stdseq<std::multiset<T> >::from(vec); - } - }; - } -%} - -#define %swig_multiset_methods(Set...) %swig_set_methods(Set) - - - -%include <std/std_multiset.i> diff --git a/contrib/tools/swig/Lib/python/std_pair.i b/contrib/tools/swig/Lib/python/std_pair.i deleted file mode 100644 index 0dcd0bb7ef2..00000000000 --- a/contrib/tools/swig/Lib/python/std_pair.i +++ /dev/null @@ -1,206 +0,0 @@ -/* - Pairs -*/ -%include <pystdcommon.swg> - -//#define SWIG_STD_PAIR_ASVAL - -%fragment("StdPairTraits","header",fragment="StdTraits") { - namespace swig { -#ifdef SWIG_STD_PAIR_ASVAL - template <class T, class U > - struct traits_asval<std::pair<T,U> > { - typedef std::pair<T,U> value_type; - - static int get_pair(PyObject* first, PyObject* second, - std::pair<T,U> *val) - { - if (val) { - T *pfirst = &(val->first); - int res1 = swig::asval((PyObject*)first, pfirst); - if (!SWIG_IsOK(res1)) return res1; - U *psecond = &(val->second); - int res2 = swig::asval((PyObject*)second, psecond); - if (!SWIG_IsOK(res2)) return res2; - return res1 > res2 ? res1 : res2; - } else { - T *pfirst = 0; - int res1 = swig::asval((PyObject*)first, 0); - if (!SWIG_IsOK(res1)) return res1; - U *psecond = 0; - int res2 = swig::asval((PyObject*)second, psecond); - if (!SWIG_IsOK(res2)) return res2; - return res1 > res2 ? res1 : res2; - } - } - - static int asval(PyObject *obj, std::pair<T,U> *val) { - int res = SWIG_ERROR; - if (PyTuple_Check(obj)) { - if (PyTuple_GET_SIZE(obj) == 2) { - res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); - } - } else if (PySequence_Check(obj)) { - if (PySequence_Size(obj) == 2) { - swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); - swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); - res = get_pair(first, second, val); - } - } else { - value_type *p = 0; - swig_type_info *descriptor = swig::type_info<value_type>(); - res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res) && val) *val = *p; - } - return res; - } - }; - -#else - template <class T, class U > - struct traits_asptr<std::pair<T,U> > { - typedef std::pair<T,U> value_type; - - static int get_pair(PyObject* first, PyObject* second, - std::pair<T,U> **val) - { - if (val) { - value_type *vp = %new_instance(std::pair<T,U>); - T *pfirst = &(vp->first); - int res1 = swig::asval((PyObject*)first, pfirst); - if (!SWIG_IsOK(res1)) { - %delete(vp); - return res1; - } - U *psecond = &(vp->second); - int res2 = swig::asval((PyObject*)second, psecond); - if (!SWIG_IsOK(res2)) { - %delete(vp); - return res2; - } - *val = vp; - return SWIG_AddNewMask(res1 > res2 ? res1 : res2); - } else { - T *pfirst = 0; - int res1 = swig::asval((PyObject*)first, pfirst); - if (!SWIG_IsOK(res1)) return res1; - U *psecond = 0; - int res2 = swig::asval((PyObject*)second, psecond); - if (!SWIG_IsOK(res2)) return res2; - return res1 > res2 ? res1 : res2; - } - } - - static int asptr(PyObject *obj, std::pair<T,U> **val) { - int res = SWIG_ERROR; - if (PyTuple_Check(obj)) { - if (PyTuple_GET_SIZE(obj) == 2) { - res = get_pair(PyTuple_GET_ITEM(obj,0),PyTuple_GET_ITEM(obj,1), val); - } - } else if (PySequence_Check(obj)) { - if (PySequence_Size(obj) == 2) { - swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); - swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); - res = get_pair(first, second, val); - } - } else { - value_type *p = 0; - swig_type_info *descriptor = swig::type_info<value_type>(); - res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - } - }; - -#endif - template <class T, class U > - struct traits_from<std::pair<T,U> > { - static PyObject *from(const std::pair<T,U>& val) { - PyObject* obj = PyTuple_New(2); - PyTuple_SetItem(obj,0,swig::from(val.first)); - PyTuple_SetItem(obj,1,swig::from(val.second)); - return obj; - } - }; - } - -#if defined(SWIGPYTHON_BUILTIN) -SWIGINTERN Py_ssize_t -SwigPython_std_pair_len (PyObject *a) -{ - return 2; -} - -SWIGINTERN PyObject* -SwigPython_std_pair_repr (PyObject *o) -{ - PyObject *tuple = PyTuple_New(2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, PyObject_GetAttrString(o, (char*) "first")); - PyTuple_SET_ITEM(tuple, 1, PyObject_GetAttrString(o, (char*) "second")); - PyObject *result = PyObject_Repr(tuple); - SWIG_Py_DECREF(tuple); - return result; -} - -SWIGINTERN PyObject* -SwigPython_std_pair_getitem (PyObject *a, Py_ssize_t b) -{ - PyObject *result = PyObject_GetAttrString(a, b % 2 ? (char*) "second" : (char*) "first"); - return result; -} - -SWIGINTERN int -SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c) -{ - int result = PyObject_SetAttrString(a, b % 2 ? (char*) "second" : (char*) "first", c); - return result; -} -#endif - -} - -%feature("python:sq_length") std::pair "SwigPython_std_pair_len"; -%feature("python:sq_length") std::pair<T*,U> "SwigPython_std_pair_len"; -%feature("python:sq_length") std::pair<T,U*> "SwigPython_std_pair_len"; -%feature("python:sq_length") std::pair<T*,U*> "SwigPython_std_pair_len"; - -%feature("python:tp_repr") std::pair "SwigPython_std_pair_repr"; -%feature("python:tp_repr") std::pair<T*,U> "SwigPython_std_pair_repr"; -%feature("python:tp_repr") std::pair<T,U*> "SwigPython_std_pair_repr"; -%feature("python:tp_repr") std::pair<T*,U*> "SwigPython_std_pair_repr"; - -%feature("python:sq_item") std::pair "SwigPython_std_pair_getitem"; -%feature("python:sq_item") std::pair<T*,U> "SwigPython_std_pair_getitem"; -%feature("python:sq_item") std::pair<T,U*> "SwigPython_std_pair_getitem"; -%feature("python:sq_item") std::pair<T*,U*> "SwigPython_std_pair_getitem"; - -%feature("python:sq_ass_item") std::pair "SwigPython_std_pair_setitem"; -%feature("python:sq_ass_item") std::pair<T*,U> "SwigPython_std_pair_setitem"; -%feature("python:sq_ass_item") std::pair<T,U*> "SwigPython_std_pair_setitem"; -%feature("python:sq_ass_item") std::pair<T*,U*> "SwigPython_std_pair_setitem"; - -%define %swig_pair_methods(pair...) -#if !defined(SWIGPYTHON_BUILTIN) -%extend { -%pythoncode %{def __len__(self): - return 2 -def __repr__(self): - return str((self.first, self.second)) -def __getitem__(self, index): - if not (index % 2): - return self.first - else: - return self.second -def __setitem__(self, index, val): - if not (index % 2): - self.first = val - else: - self.second = val%} -} -#endif -%enddef - -%include <std/std_pair.i> - diff --git a/contrib/tools/swig/Lib/python/std_set.i b/contrib/tools/swig/Lib/python/std_set.i deleted file mode 100644 index 3f80daff686..00000000000 --- a/contrib/tools/swig/Lib/python/std_set.i +++ /dev/null @@ -1,56 +0,0 @@ -/* - Sets -*/ - -%fragment("StdSetTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T> - struct traits_asptr<std::set<T> > { - static int asptr(PyObject *obj, std::set<T> **s) { - return traits_asptr_stdseq<std::set<T> >::asptr(obj, s); - } - }; - - template <class T> - struct traits_from<std::set<T> > { - static PyObject *from(const std::set<T>& vec) { - return traits_from_stdseq<std::set<T> >::from(vec); - } - }; - } -%} - -%define %swig_set_methods(set...) - %swig_sequence_iterator(set); - %swig_container_methods(set); - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; - %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; -#endif - - %extend { - void append(value_type x) { - self->insert(x); - } - - bool __contains__(value_type x) { - return self->find(x) != self->end(); - } - - value_type __getitem__(difference_type i) const throw (std::out_of_range) { - return *(swig::cgetpos(self, i)); - } - - void add(value_type x) { - self->insert(x); - } - - void discard(value_type x) { - self->erase(x); - } - } -%enddef - -%include <std/std_set.i> diff --git a/contrib/tools/swig/Lib/python/std_shared_ptr.i b/contrib/tools/swig/Lib/python/std_shared_ptr.i deleted file mode 100644 index df873679c62..00000000000 --- a/contrib/tools/swig/Lib/python/std_shared_ptr.i +++ /dev/null @@ -1,2 +0,0 @@ -#define SWIG_SHARED_PTR_NAMESPACE std -%include <boost_shared_ptr.i> diff --git a/contrib/tools/swig/Lib/python/std_sstream.i b/contrib/tools/swig/Lib/python/std_sstream.i deleted file mode 100644 index 6647df8cd4f..00000000000 --- a/contrib/tools/swig/Lib/python/std_sstream.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_sstream.i> diff --git a/contrib/tools/swig/Lib/python/std_streambuf.i b/contrib/tools/swig/Lib/python/std_streambuf.i deleted file mode 100644 index 44b9bb4d788..00000000000 --- a/contrib/tools/swig/Lib/python/std_streambuf.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_streambuf.i> diff --git a/contrib/tools/swig/Lib/python/std_string.i b/contrib/tools/swig/Lib/python/std_string.i deleted file mode 100644 index dc1378ae6de..00000000000 --- a/contrib/tools/swig/Lib/python/std_string.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/std_string.swg> diff --git a/contrib/tools/swig/Lib/python/std_string_view.i b/contrib/tools/swig/Lib/python/std_string_view.i deleted file mode 100644 index 702dd9b49ef..00000000000 --- a/contrib/tools/swig/Lib/python/std_string_view.i +++ /dev/null @@ -1,135 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_string_view.i - * - * SWIG typemaps for std::string_view types - * ----------------------------------------------------------------------------- */ - -%include <exception.i> - -%{ -#include <string_view> - -#if PY_VERSION_HEX < 0x03000000 -# error std_string_view.i not supported for Python 2 -#endif -%} - -namespace std { - - %naturalvar string_view; - - class string_view; - - %typemap(typecheck,precedence=SWIG_TYPECHECK_STRINGVIEW) string_view, const string_view & %{ -#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - $1 = PyBytes_Check($input); -#else - $1 = PyUnicode_Check($input) || PyBytes_Check($input); -#endif - %} - - %typemap(in) string_view (PyObject *bytes = NULL) { - Py_ssize_t len; -%#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - const char *p = PyBytes_AsString($input); - if (!p) SWIG_fail; - len = PyBytes_Size($input); -%#else - const char *p; - if (PyUnicode_Check($input)) { - p = SWIG_PyUnicode_AsUTF8AndSize($input, &len, &bytes); - if (!p) SWIG_fail; - } else { - p = PyBytes_AsString($input); - if (!p) SWIG_fail; - len = PyBytes_Size($input); - } -%#endif - $1 = std::string_view(p, len); - } - - %typemap(freearg) string_view %{ - SWIG_Py_XDECREF(bytes$argnum); - %} - - %typemap(in) const string_view & ($*1_ltype temp, PyObject *bytes = NULL) { - Py_ssize_t len; -%#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - const char *p = PyBytes_AsString($input); - if (!p) SWIG_fail; - len = PyBytes_Size($input); -%#else - const char *p; - if (PyUnicode_Check($input)) { - p = SWIG_PyUnicode_AsUTF8AndSize($input, &len, &bytes); - if (!p) SWIG_fail; - } else { - p = PyBytes_AsString($input); - if (!p) SWIG_fail; - len = PyBytes_Size($input); - } -%#endif - temp = std::string_view(p, len); - $1 = &temp; - } - - %typemap(freearg) const string_view & %{ - SWIG_Py_XDECREF(bytes$argnum); - %} - - %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) string_view { - Py_ssize_t len; -%#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - const char *p = PyBytes_AsString($input); - if (p) len = PyBytes_Size($input); -%#else - const char *p; - PyObject *bytes = NULL; - if (PyUnicode_Check($input)) { - p = SWIG_PyUnicode_AsUTF8AndSize($input, &len, &bytes); - // Avoid undefined behaviour (p will be pointing to a temporary - // if bytes is not NULL which happens when Py_LIMITED_API is defined - // and < 0x030A0000) and just leak by not calling Py_XDECREF. - // Py_XDECREF(bytes); - } else { - p = PyBytes_AsString($input); - if (p) len = PyBytes_Size($input); - } -%#endif - if (p) $result = std::string_view(p, len); - } - - - %typemap(out) string_view %{ -#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - $result = PyBytes_FromStringAndSize($1.data(), $1.size()); -#else - $result = PyUnicode_FromStringAndSize($1.data(), $1.size()); -#endif - %} - - %typemap(varout) string_view %{ -#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - $result = PyBytes_FromStringAndSize($1.data(), $1.size()); -#else - $result = PyUnicode_FromStringAndSize($1.data(), $1.size()); -#endif - %} - - %typemap(directorin) string_view, const string_view & %{ -#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - $input = PyBytes_FromStringAndSize($1.data(), $1.size()); -#else - $input = PyUnicode_FromStringAndSize($1.data(), $1.size()); -#endif - %} - - %typemap(out) const string_view & %{ -#ifdef SWIG_PYTHON_STRICT_BYTE_CHAR - $result = PyBytes_FromStringAndSize($1->data(), $1->size()); -#else - $result = PyUnicode_FromStringAndSize($1->data(), $1->size()); -#endif - %} - -} diff --git a/contrib/tools/swig/Lib/python/std_unique_ptr.i b/contrib/tools/swig/Lib/python/std_unique_ptr.i deleted file mode 100644 index e3669bb4a5a..00000000000 --- a/contrib/tools/swig/Lib/python/std_unique_ptr.i +++ /dev/null @@ -1,69 +0,0 @@ -/* ----------------------------------------------------------------------------- - * 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/python/std_unordered_map.i b/contrib/tools/swig/Lib/python/std_unordered_map.i deleted file mode 100644 index 4321735561e..00000000000 --- a/contrib/tools/swig/Lib/python/std_unordered_map.i +++ /dev/null @@ -1,290 +0,0 @@ -/* - Unordered Maps -*/ -%include <std_map.i> - -%fragment("StdUnorderedMapForwardIteratorTraits","header") -{ - namespace swig { - template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type> - struct SwigPyMapForwardIterator_T : SwigPyForwardIteratorClosed_T<OutIterator, ValueType, FromOper> - { - SwigPyMapForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyForwardIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq) - { - } - }; - - - template<class OutIterator, - class FromOper = from_key_oper<typename OutIterator::value_type> > - struct SwigPyMapKeyForwardIterator_T : SwigPyMapForwardIterator_T<OutIterator, FromOper> - { - SwigPyMapKeyForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapForwardIterator_T<OutIterator, FromOper>(curr, first, last, seq) - { - } - }; - - template<typename OutIter> - inline SwigPyIterator* - make_output_key_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapKeyForwardIterator_T<OutIter>(current, begin, end, seq); - } - - template<class OutIterator, - class FromOper = from_value_oper<typename OutIterator::value_type> > - struct SwigPyMapValueForwardIterator_T : SwigPyMapForwardIterator_T<OutIterator, FromOper> - { - SwigPyMapValueForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapForwardIterator_T<OutIterator, FromOper>(curr, first, last, seq) - { - } - }; - - - template<typename OutIter> - inline SwigPyIterator* - make_output_value_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapValueForwardIterator_T<OutIter>(current, begin, end, seq); - } - } -} - -%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") -{ - namespace swig { - template <class K, class T, class Hash, class Compare, class Alloc> - struct traits_reserve<std::unordered_map<K,T,Hash,Compare,Alloc> > { - static void reserve(std::unordered_map<K,T,Hash,Compare,Alloc> &seq, typename std::unordered_map<K,T,Hash,Compare,Alloc>::size_type n) { - seq.reserve(n); - } - }; - - template <class K, class T, class Hash, class Compare, class Alloc> - struct traits_asptr<std::unordered_map<K,T,Hash,Compare,Alloc> > { - typedef std::unordered_map<K,T,Hash,Compare,Alloc> unordered_map_type; - static int asptr(PyObject *obj, unordered_map_type **val) { - int res = SWIG_ERROR; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); -%#if PY_VERSION_HEX >= 0x03000000 - /* In Python 3.x the ".items()" method returns a dict_items object */ - items = PySequence_Fast(items, ".items() didn't return a sequence!"); -%#endif - res = traits_asptr_stdseq<std::unordered_map<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val); - } else { - unordered_map_type *p = 0; - swig_type_info *descriptor = swig::type_info<unordered_map_type>(); - res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res) && val) *val = p; - } - SWIG_PYTHON_THREAD_END_BLOCK; - return res; - } - }; - - template <class K, class T, class Hash, class Compare, class Alloc> - struct traits_from<std::unordered_map<K,T,Hash,Compare,Alloc> > { - typedef std::unordered_map<K,T,Hash,Compare,Alloc> unordered_map_type; - typedef typename unordered_map_type::const_iterator const_iterator; - typedef typename unordered_map_type::size_type size_type; - - static PyObject *asdict(const unordered_map_type& map) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - size_type size = map.size(); - Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return obj; - } - - static PyObject *from(const unordered_map_type& map) { - swig_type_info *desc = swig::type_info<unordered_map_type>(); - if (desc && desc->clientdata) { - return SWIG_InternalNewPointerObj(new unordered_map_type(map), desc, SWIG_POINTER_OWN); - } else { - return asdict(map); - } - } - }; - } -} - -%define %swig_unordered_map_common(Map...) - %swig_sequence_forward_iterator(Map); - %swig_container_methods(Map) - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_length", functype="lenfunc") __len__; - %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; - %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; - %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; - - %extend { - %newobject iterkeys(PyObject **PYTHON_SELF); - swig::SwigPyIterator* iterkeys(PyObject **PYTHON_SELF) { - return swig::make_output_key_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - - %newobject itervalues(PyObject **PYTHON_SELF); - swig::SwigPyIterator* itervalues(PyObject **PYTHON_SELF) { - return swig::make_output_value_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - - %newobject iteritems(PyObject **PYTHON_SELF); - swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) { - return swig::make_output_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - } - -#else - %extend { - %pythoncode %{def __iter__(self): - return self.key_iterator()%} - %pythoncode %{def iterkeys(self): - return self.key_iterator()%} - %pythoncode %{def itervalues(self): - return self.value_iterator()%} - %pythoncode %{def iteritems(self): - return self.iterator()%} - } -#endif - - %extend { - mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) { - Map::const_iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - - void __delitem__(const key_type& key) throw (std::out_of_range) { - Map::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 key_type& key) const { - Map::const_iterator i = self->find(key); - return i != self->end(); - } - - PyObject* keys() { - Map::size_type size = self->size(); - Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject* keyList = PyList_New(pysize); - Map::const_iterator i = self->begin(); - for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { - PyList_SET_ITEM(keyList, j, swig::from(i->first)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return keyList; - } - - PyObject* values() { - Map::size_type size = self->size(); - Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject* valList = PyList_New(pysize); - Map::const_iterator i = self->begin(); - for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { - PyList_SET_ITEM(valList, j, swig::from(i->second)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return valList; - } - - PyObject* items() { - Map::size_type size = self->size(); - Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - if (pysize < 0) { - PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject* itemList = PyList_New(pysize); - Map::const_iterator i = self->begin(); - for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { - PyList_SET_ITEM(itemList, j, swig::from(*i)); - } - SWIG_PYTHON_THREAD_END_BLOCK; - return itemList; - } - - bool __contains__(const key_type& key) { - return self->find(key) != self->end(); - } - - %newobject key_iterator(PyObject **PYTHON_SELF); - swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { - return swig::make_output_key_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - - %newobject value_iterator(PyObject **PYTHON_SELF); - swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { - return swig::make_output_value_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); - } - } - -%enddef - -%define %swig_unordered_map_methods(Map...) - %swig_unordered_map_common(Map) - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; -#endif - - %extend { - // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(const key_type& key) { - self->erase(key); - } - - void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { -%#ifdef __cpp_lib_unordered_map_try_emplace - (*self).insert_or_assign(key, x); -%#else - (*self)[key] = x; -%#endif - } - - PyObject* asdict() { - return swig::traits_from< Map >::asdict(*self); - } - } - - -%enddef - - -%include <std/std_unordered_map.i> diff --git a/contrib/tools/swig/Lib/python/std_unordered_multimap.i b/contrib/tools/swig/Lib/python/std_unordered_multimap.i deleted file mode 100644 index 816ec0933a8..00000000000 --- a/contrib/tools/swig/Lib/python/std_unordered_multimap.i +++ /dev/null @@ -1,90 +0,0 @@ -/* - Unordered Multimaps -*/ -%include <std_unordered_map.i> - -%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") -{ - namespace swig { - template <class K, class T, class Hash, class Compare, class Alloc> - struct traits_reserve<std::unordered_multimap<K,T,Hash,Compare,Alloc> > { - static void reserve(std::unordered_multimap<K,T,Hash,Compare,Alloc> &seq, typename std::unordered_multimap<K,T,Hash,Compare,Alloc>::size_type n) { - seq.reserve(n); - } - }; - - template <class K, class T, class Hash, class Compare, class Alloc> - struct traits_asptr<std::unordered_multimap<K,T,Hash,Compare,Alloc> > { - typedef std::unordered_multimap<K,T,Hash,Compare,Alloc> unordered_multimap_type; - static int asptr(PyObject *obj, std::unordered_multimap<K,T,Hash,Compare,Alloc> **val) { - int res = SWIG_ERROR; - if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); -%#if PY_VERSION_HEX >= 0x03000000 - /* In Python 3.x the ".items()" method returns a dict_items object */ - items = PySequence_Fast(items, ".items() didn't return a sequence!"); -%#endif - res = traits_asptr_stdseq<std::unordered_multimap<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val); - } else { - unordered_multimap_type *p = 0; - swig_type_info *descriptor = swig::type_info<unordered_multimap_type>(); - res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res) && val) *val = p; - } - return res; - } - }; - - template <class K, class T, class Hash, class Compare, class Alloc> - struct traits_from<std::unordered_multimap<K,T,Hash,Compare,Alloc> > { - typedef std::unordered_multimap<K,T,Hash,Compare,Alloc> unordered_multimap_type; - typedef typename unordered_multimap_type::const_iterator const_iterator; - typedef typename unordered_multimap_type::size_type size_type; - - static PyObject *from(const unordered_multimap_type& unordered_multimap) { - swig_type_info *desc = swig::type_info<unordered_multimap_type>(); - if (desc && desc->clientdata) { - return SWIG_InternalNewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN); - } else { - size_type size = unordered_multimap.size(); - Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; - if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, "unordered_multimap size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= unordered_multimap.begin(); i!= unordered_multimap.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - return obj; - } - } - }; - } -} - -%define %swig_unordered_multimap_methods(Type...) - %swig_unordered_map_common(Type); - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; -#endif - - %extend { - // This will be called through the mp_ass_subscript slot to delete an entry. - void __setitem__(const key_type& key) { - self->erase(key); - } - - void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { - self->insert(Type::value_type(key,x)); - } - } -%enddef - -%include <std/std_unordered_multimap.i> - diff --git a/contrib/tools/swig/Lib/python/std_unordered_multiset.i b/contrib/tools/swig/Lib/python/std_unordered_multiset.i deleted file mode 100644 index 0542247b23a..00000000000 --- a/contrib/tools/swig/Lib/python/std_unordered_multiset.i +++ /dev/null @@ -1,37 +0,0 @@ -/* - Unordered Multisets -*/ - -%include <std_unordered_set.i> - -%fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class Key, class Hash, class Compare, class Alloc> - struct traits_reserve<std::unordered_multiset<Key,Hash,Compare,Alloc> > { - static void reserve(std::unordered_multiset<Key,Hash,Compare,Alloc> &seq, typename std::unordered_multiset<Key,Hash,Compare,Alloc>::size_type n) { - seq.reserve(n); - } - }; - - template <class Key, class Hash, class Compare, class Alloc> - struct traits_asptr<std::unordered_multiset<Key,Hash,Compare,Alloc> > { - static int asptr(PyObject *obj, std::unordered_multiset<Key,Hash,Compare,Alloc> **m) { - return traits_asptr_stdseq<std::unordered_multiset<Key,Hash,Compare,Alloc> >::asptr(obj, m); - } - }; - - template <class Key, class Hash, class Compare, class Alloc> - struct traits_from<std::unordered_multiset<Key,Hash,Compare,Alloc> > { - static PyObject *from(const std::unordered_multiset<Key,Hash,Compare,Alloc>& vec) { - return traits_from_stdseq<std::unordered_multiset<Key,Hash,Compare,Alloc> >::from(vec); - } - }; - } -%} - -#define %swig_unordered_multiset_methods(Set...) %swig_unordered_set_methods(Set) - - - -%include <std/std_unordered_multiset.i> diff --git a/contrib/tools/swig/Lib/python/std_unordered_set.i b/contrib/tools/swig/Lib/python/std_unordered_set.i deleted file mode 100644 index fd866b14aa0..00000000000 --- a/contrib/tools/swig/Lib/python/std_unordered_set.i +++ /dev/null @@ -1,56 +0,0 @@ -/* - Unordered Sets -*/ - -%fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class Key, class Hash, class Compare, class Alloc> - struct traits_reserve<std::unordered_set<Key,Hash,Compare,Alloc> > { - static void reserve(std::unordered_set<Key,Hash,Compare,Alloc> &seq, typename std::unordered_set<Key,Hash,Compare,Alloc>::size_type n) { - seq.reserve(n); - } - }; - - template <class Key, class Hash, class Compare, class Alloc> - struct traits_asptr<std::unordered_set<Key,Hash,Compare,Alloc> > { - static int asptr(PyObject *obj, std::unordered_set<Key,Hash,Compare,Alloc> **s) { - return traits_asptr_stdseq<std::unordered_set<Key,Hash,Compare,Alloc> >::asptr(obj, s); - } - }; - - template <class Key, class Hash, class Compare, class Alloc> - struct traits_from<std::unordered_set<Key,Hash,Compare,Alloc> > { - static PyObject *from(const std::unordered_set<Key,Hash,Compare,Alloc>& vec) { - return traits_from_stdseq<std::unordered_set<Key,Hash,Compare,Alloc> >::from(vec); - } - }; - } -%} - -%define %swig_unordered_set_methods(unordered_set...) - %swig_sequence_forward_iterator(unordered_set); - %swig_container_methods(unordered_set); - -#if defined(SWIGPYTHON_BUILTIN) - %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; - %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; -#endif - - - %extend { - void append(value_type x) { - self->insert(x); - } - - bool __contains__(value_type x) { - return self->find(x) != self->end(); - } - - value_type __getitem__(difference_type i) const throw (std::out_of_range) { - return *(swig::cgetpos(self, i)); - } - } -%enddef - -%include <std/std_unordered_set.i> diff --git a/contrib/tools/swig/Lib/python/std_vector.i b/contrib/tools/swig/Lib/python/std_vector.i deleted file mode 100644 index 2ac41a54d7d..00000000000 --- a/contrib/tools/swig/Lib/python/std_vector.i +++ /dev/null @@ -1,34 +0,0 @@ -/* - Vectors -*/ - -%fragment("StdVectorTraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T> - struct traits_reserve<std::vector<T> > { - static void reserve(std::vector<T> &seq, typename std::vector<T>::size_type n) { - seq.reserve(n); - } - }; - - template <class T> - struct traits_asptr<std::vector<T> > { - static int asptr(PyObject *obj, std::vector<T> **vec) { - return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec); - } - }; - - template <class T> - struct traits_from<std::vector<T> > { - static PyObject *from(const std::vector<T>& vec) { - return traits_from_stdseq<std::vector<T> >::from(vec); - } - }; - } -%} - -#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) -#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); - -%include <std/std_vector.i> diff --git a/contrib/tools/swig/Lib/python/std_vectora.i b/contrib/tools/swig/Lib/python/std_vectora.i deleted file mode 100644 index 3f084bd7de1..00000000000 --- a/contrib/tools/swig/Lib/python/std_vectora.i +++ /dev/null @@ -1,31 +0,0 @@ -/* - Vectors + allocators -*/ - -%fragment("StdVectorATraits","header",fragment="StdSequenceTraits") -%{ - namespace swig { - template <class T, class A> - struct traits_asptr<std::vector<T,A> > { - typedef std::vector<T,A> vector_type; - typedef T value_type; - static int asptr(PyObject *obj, vector_type **vec) { - return traits_asptr_stdseq<vector_type>::asptr(obj, vec); - } - }; - - template <class T, class A> - struct traits_from<std::vector<T,A> > { - typedef std::vector<T,A> vector_type; - static PyObject *from(const vector_type& vec) { - return traits_from_stdseq<vector_type>::from(vec); - } - }; - } -%} - - -#define %swig_vector_methods(Type...) %swig_sequence_methods(Type) -#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type); - -%include <std/std_vectora.i> diff --git a/contrib/tools/swig/Lib/python/std_wios.i b/contrib/tools/swig/Lib/python/std_wios.i deleted file mode 100644 index 930a57dd0de..00000000000 --- a/contrib/tools/swig/Lib/python/std_wios.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_wios.i> diff --git a/contrib/tools/swig/Lib/python/std_wiostream.i b/contrib/tools/swig/Lib/python/std_wiostream.i deleted file mode 100644 index d3a5ee785a2..00000000000 --- a/contrib/tools/swig/Lib/python/std_wiostream.i +++ /dev/null @@ -1,10 +0,0 @@ -namespace std -{ -%callback(1) wendl; -%callback(1) wends; -%callback(1) wflush; -} - -%include <std_basic_string.i> -%include <std_wstring.i> -%include <std/std_wiostream.i> diff --git a/contrib/tools/swig/Lib/python/std_wsstream.i b/contrib/tools/swig/Lib/python/std_wsstream.i deleted file mode 100644 index 8843f56d895..00000000000 --- a/contrib/tools/swig/Lib/python/std_wsstream.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_wsstream.i> diff --git a/contrib/tools/swig/Lib/python/std_wstreambuf.i b/contrib/tools/swig/Lib/python/std_wstreambuf.i deleted file mode 100644 index c0f09201cef..00000000000 --- a/contrib/tools/swig/Lib/python/std_wstreambuf.i +++ /dev/null @@ -1 +0,0 @@ -%include <std/std_wstreambuf.i> diff --git a/contrib/tools/swig/Lib/python/std_wstring.i b/contrib/tools/swig/Lib/python/std_wstring.i deleted file mode 100644 index ef8628137bd..00000000000 --- a/contrib/tools/swig/Lib/python/std_wstring.i +++ /dev/null @@ -1,3 +0,0 @@ -%include <pywstrings.swg> -%include <typemaps/std_wstring.swg> - diff --git a/contrib/tools/swig/Lib/python/stl.i b/contrib/tools/swig/Lib/python/stl.i deleted file mode 100644 index 04f86014f2c..00000000000 --- a/contrib/tools/swig/Lib/python/stl.i +++ /dev/null @@ -1,10 +0,0 @@ -/* ----------------------------------------------------------------------------- - * 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/python/swigmove.i b/contrib/tools/swig/Lib/python/swigmove.i deleted file mode 100644 index 62ecca76823..00000000000 --- a/contrib/tools/swig/Lib/python/swigmove.i +++ /dev/null @@ -1 +0,0 @@ -%include <typemaps/swigmove.swg> diff --git a/contrib/tools/swig/Lib/python/typemaps.i b/contrib/tools/swig/Lib/python/typemaps.i deleted file mode 100644 index 75592036b22..00000000000 --- a/contrib/tools/swig/Lib/python/typemaps.i +++ /dev/null @@ -1,144 +0,0 @@ -/* ----------------------------------------------------------------------------- - * typemaps.i - * - * Pointer handling - * These mappings provide support for input/output arguments and common - * uses for C/C++ pointers. - * ----------------------------------------------------------------------------- */ - -// 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); - -*/ - -// 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, they are returned in the form of a Python tuple. - - 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 Python output of the function would be a tuple containing both -output values. - -*/ - -// 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 Python tuple. - - 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 (since -this makes no sense in Python). Rather, the modified input value shows -up as the return value of the function. Thus, to apply this function -to a Python variable you might do this : - - x = neg(x) - -*/ - -%include <typemaps/typemaps.swg> diff --git a/contrib/tools/swig/Lib/python/wchar.i b/contrib/tools/swig/Lib/python/wchar.i deleted file mode 100644 index 308139a3ab7..00000000000 --- a/contrib/tools/swig/Lib/python/wchar.i +++ /dev/null @@ -1,21 +0,0 @@ -#ifdef __cplusplus - -%{ -#include <cwchar> -%} - -#else - -%{ -#include <wchar.h> -%} - -#endif - -%types(wchar_t *); -%include <pywstrings.swg> - -/* - Enable swig wchar support. -*/ -#define SWIG_WCHAR diff --git a/contrib/tools/swig/Lib/python/ya.make b/contrib/tools/swig/Lib/python/ya.make deleted file mode 100644 index 27d61986dc2..00000000000 --- a/contrib/tools/swig/Lib/python/ya.make +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by devtools/yamaker. - -LIBRARY() - -LICENSE(LicenseRef-scancode-swig) - -LICENSE_TEXTS(.yandex_meta/licenses.list.txt) - -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/python - GLOBAL FOR - swig - contrib/tools/swig/Lib -) - -END() |