diff options
author | robot-piglet <[email protected]> | 2025-08-28 14:27:58 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-08-28 14:57:06 +0300 |
commit | 81d828c32c8d5477cb2f0ce5da06a1a8d9392ca3 (patch) | |
tree | 3081d566f0d5158d76e9093261344f6406fd09f7 /contrib/tools/swig/Lib/go | |
parent | 77ea11423f959e51795cc3ef36a48d808b4ffb98 (diff) |
Intermediate changes
commit_hash:d5b1af16dbe9030537a04c27eb410c88c2f496cd
Diffstat (limited to 'contrib/tools/swig/Lib/go')
22 files changed, 2975 insertions, 0 deletions
diff --git a/contrib/tools/swig/Lib/go/.yandex_meta/licenses.list.txt b/contrib/tools/swig/Lib/go/.yandex_meta/licenses.list.txt new file mode 100644 index 00000000000..8aad0f87d67 --- /dev/null +++ b/contrib/tools/swig/Lib/go/.yandex_meta/licenses.list.txt @@ -0,0 +1,916 @@ +====================File: COPYRIGHT==================== +SWIG Copyright and Authors +-------------------------- + +Copyright (c) 1995-2023 The SWIG Developers +Copyright (c) 2005-2006 Arizona Board of Regents (University of Arizona). +Copyright (c) 1998-2005 University of Chicago. +Copyright (c) 1995-1998 The University of Utah and the Regents of the University of California + +Portions also copyrighted by: + Network Applied Communication Laboratory, Inc + Information-technology Promotion Agency, Japan + +Active SWIG Developers: + William Fulton ([email protected]) (SWIG core, Java, C#, Windows, Cygwin) + Olly Betts ([email protected]) (PHP) + Joseph Wang ([email protected]) (R) + Momtchil Momtchev ([email protected]) (Javascript Node-API) + Simon Marchetto ([email protected]) (Scilab) + Zackery Spytz ([email protected]) (OCaml, SWIG core) + +Past SWIG developers and major contributors include: + Dave Beazley ([email protected]) (SWIG core, Python, Tcl, Perl) + Henning Thielemann ([email protected]) (Modula3) + Matthias Köppe ([email protected]) (Guile, MzScheme) + Luigi Ballabio ([email protected]) (STL wrapping) + Mikel Bancroft ([email protected]) (Allegro CL) + Surendra Singhi ([email protected]) (CLISP, CFFI) + Marcelo Matus ([email protected]) (SWIG core, Python, UTL[python,perl,tcl,ruby]) + Art Yerkes ([email protected]) (OCaml) + Lyle Johnson ([email protected]) (Ruby) + Charlie Savage ([email protected]) (Ruby) + Thien-Thi Nguyen ([email protected]) (build/test/misc) + Richard Palmer ([email protected]) (PHP) + Sam Liddicott - Ananova Ltd ([email protected]) (PHP) + Tim Hockin - Sun Microsystems ([email protected]) (PHP) + Kevin Ruland (PHP) + Shibukawa Yoshiki (Japanese Translation) + Jason Stewart ([email protected]) (Perl5) + Loic Dachary (Perl5) + David Fletcher (Perl5) + Gary Holt (Perl5) + Masaki Fukushima (Ruby) + Scott Michel ([email protected]) (Java directors) + Tiger Feng ([email protected]) (SWIG core) + Mark Rose ([email protected]) (Directors) + Jonah Beckford ([email protected]) (CHICKEN) + Ahmon Dancy ([email protected]) (Allegro CL) + Dirk Gerrits (Allegro CL) + Neil Cawse (C#) + Harco de Hilster (Java) + Alexey Dyachenko ([email protected]) (Tcl) + Bob Techentin (Tcl) + Martin Froehlich <[email protected]> (Guile) + Marcio Luis Teixeira <[email protected]> (Guile) + Duncan Temple Lang (R) + Miklos Vajna <[email protected]> (PHP directors) + Mark Gossage ([email protected]) (Lua) + Raman Gopalan ([email protected]) (eLua) + Gonzalo Garramuno ([email protected]) (Ruby, Ruby's UTL) + John Lenz (Guile, MzScheme updates, Chicken module, runtime system) + Baozeng Ding <[email protected]> (Scilab) + Ian Lance Taylor (Go) + Dmitry Kabak ([email protected]) (Doxygen) + Vadim Zeitlin (PCRE, Python, Doxygen) + Stefan Zager ([email protected]) (Python) + Vincent Couvert (Scilab) + Sylvestre Ledru (Scilab) + Wolfgang Frisch (Scilab) + Oliver Buchtala ([email protected]) (Javascript) + Neha Narang ([email protected]) (Javascript) + Xavier Delacour ([email protected]) (Octave) + David Nadlinger ([email protected]) (D) + Leif Middelschulte ([email protected]) (C) + +Past contributors include: + James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran + Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn, + Edward Zimmermann, David Ascher, Dominique Dumont, Pier Giorgio Esposito, Hasan Baran Kovuk, + Klaus Wiederänders, Richard Beare, Hans Oesterholt. + (See CHANGES and CHANGES.current and the bug tracker for a more complete list). + +Past students: + Songyan Feng (Chicago). + Xinghua Shi (Chicago). + Jing Cao (Chicago). + Aquinas Hobor (Chicago). + +Historically, the following people contributed to early versions of SWIG. +Peter Lomdahl, Brad Holian, Shujia Zhou, Niels Jensen, and Tim Germann +at Los Alamos National Laboratory were the first users. Patrick +Tullmann at the University of Utah suggested the idea of automatic +documentation generation. John Schmidt and Kurtis Bleeker at the +University of Utah tested out the early versions. Chris Johnson +supported SWIG's developed at the University of Utah. John Buckman, +Larry Virden, and Tom Schwaller provided valuable input on the first +releases and improving the portability of SWIG. David Fletcher and +Gary Holt have provided a great deal of input on improving SWIG's +Perl5 implementation. Kevin Butler contributed the first Windows NT +port. + +Early bug reports and patches: +Adam Hupp, Arthur Smyles, Brad Clements, Brett Williams, Buck Hodges, +Burkhard Kloss, Chia-Liang Kao, Craig Files, Dennis Marsa, Dieter Baron, +Drake Diedrich, Fleur Diana Dragan, Gary Pennington, Geoffrey Hort, Gerald Williams, +Greg Anderson, Greg Kochanski, Greg Troxel, Henry Rowley, Irina Kotlova, +Israel Taller, James Bailey, Jim Fulton, Joel Reed, Jon Travis, +Junio Hamano, Justin Heyes-Jones, Karl Forner, Keith Davidson, +Krzysztof Kozminski, Larry Virden, Luke J Crook, Magnus Ljung, Marc Zonzon, +Mark Howson, Micahel Scharf, Michel Sanner, Mike Romberg, Mike Simons, +Mike Weiblen, Paul Brannan, Ram Bhamidipaty, Reinhard Fobbe, Rich Wales, +Richard Salz, Roy Lecates, Rudy Albachten, Scott Drummonds +Scott Michel, Shaun Lowry, Steve Galser, Tarn Weisner Burton, +Thomas Weidner, Tony Seward, Uwe Steinmann, Vadim Chugunov, Wyss Clemens, +Zhong Ren. + + + +====================File: LICENSE-GPL==================== + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. + + +====================File: LICENSE-UNIVERSITIES==================== +SWIG is distributed under the following terms: + +I. + +Copyright (c) 1995-1998 +The University of Utah and the Regents of the University of California +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following two paragraphs +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE +UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY +PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH +SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND +THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, +SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + + +II. + +This software includes contributions that are Copyright (c) 1998-2005 +University of Chicago. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. Redistributions +in binary form must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. Neither the name of +the University of Chicago nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +III. + +This software includes contributions that are Copyright (c) 2005-2006 +Arizona Board of Regents (University of Arizona). +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following paragraph +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +====================LicenseRef-scancode-swig==================== +SWIG is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. See the LICENSE-GPL file for +the full terms of the GNU General Public license version 3. + +Portions of SWIG are also licensed under the terms of the licenses +in the file LICENSE-UNIVERSITIES. You must observe the terms of +these licenses, as well as the terms of the GNU General Public License, +when you distribute SWIG. + +The SWIG library and examples, under the Lib and Examples top level +directories, are distributed under the following terms: + + You may copy, modify, distribute, and make derivative works based on + this software, in source code or object code form, without + restriction. If you distribute the software to others, you may do + so according to the terms of your choice. This software is offered as + is, without warranty of any kind. + +See the COPYRIGHT file for a list of contributors to SWIG and their +copyright notices.
\ No newline at end of file diff --git a/contrib/tools/swig/Lib/go/argcargv.i b/contrib/tools/swig/Lib/go/argcargv.i new file mode 100644 index 00000000000..f2dee2be955 --- /dev/null +++ b/contrib/tools/swig/Lib/go/argcargv.i @@ -0,0 +1,62 @@ +/* ------------------------------------------------------------- + * SWIG library containing argc and argv multi-argument typemaps + * ------------------------------------------------------------- */ + +%typemap(gotype) (int ARGC, char **ARGV) "[]string" + +%insert(go_wrapper) %{ +//export cgo_swig_get_string_slice_idx +func cgo_swig_get_string_slice_idx(s []string, i C.swig_intgo) string { + return s[i] +} +%} + +%{ +extern +#ifdef __cplusplus + "C" +#endif +_gostring_ cgo_swig_get_string_slice_idx(_goslice_ s, intgo i); +%} + +%typemap(in) (int ARGC, char **ARGV) { + $1_ltype len = ($1_ltype)$input.len; + size_t aralloc = (size_t)((len + 1) * sizeof(char *)); + if (len < 0) { + _swig_gopanic("negative array length"); + } + $2 = ($2_ltype) Swig_malloc((int)aralloc); + if ($2 == NULL) { + _swig_gopanic("fail allocating memory for array"); + } + memset($2, 0, aralloc); + $1 = len; + { + $1_ltype i; + for (i = 0; i < len; i++) { + char *p; + _gostring_ st = cgo_swig_get_string_slice_idx($input, (intgo)i); + if (st.n < 0) { + _swig_gopanic("string length negative"); + } + p = (char *) Swig_malloc((int)(st.n + 1)); + if (p == NULL) { + _swig_gopanic("fail allocating memory for a string"); + } + memcpy(p, st.p, st.n); + p[st.n] = 0; + $2[i] = p; + } + $2[i] = NULL; + } +} + +%typemap(freearg) (int ARGC, char **ARGV) { + if ($2 != NULL) { + $1_ltype i; + for (i = 0; i < $1; i++) { + Swig_free((void *)$2[i]); + } + Swig_free((void *)$2); + } +} diff --git a/contrib/tools/swig/Lib/go/cdata.i b/contrib/tools/swig/Lib/go/cdata.i new file mode 100644 index 00000000000..77b08ec7a62 --- /dev/null +++ b/contrib/tools/swig/Lib/go/cdata.i @@ -0,0 +1,57 @@ +/* ----------------------------------------------------------------------------- + * cdata.i + * + * SWIG library file containing macros for manipulating raw C data. + * ----------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------ + * Typemap for passing bytes with length + * ------------------------------------------------------------ */ + +%typemap(gotype) (const void *BYTES, size_t LENGTH) "[]byte" +%typemap(in) (const void *BYTES, size_t LENGTH) %{ + $1 = ($1_ltype)$input.array; + $2 = ($2_ltype)$input.len; +%} +%apply (const void *BYTES, size_t LENGTH) { (void *BYTES, size_t LENGTH) } + +%include <typemaps/cdata_begin.swg> + +%fragment("cdata", "header") %{ +struct swigcdata { + uintgo size; + void *data; +}; +%} + +%typemap(gotype) SWIGCDATA "[]byte" +%typemap(imtype) SWIGCDATA "uint64" + +%typemap(out, fragment="cdata") SWIGCDATA(struct swigcdata *swig_out) %{ + swig_out = (struct swigcdata *)malloc(sizeof(*swig_out)); + if (swig_out) { + swig_out->size = $1.len; + swig_out->data = malloc(swig_out->size); + if (swig_out->data) { + memcpy(swig_out->data, $1.data, swig_out->size); + } + } + $result = *(long long *)(void **)&swig_out; +%} + +%typemap(goout) SWIGCDATA { + type swigcdata struct { size int; data uintptr } + p := (*swigcdata)(unsafe.Pointer(uintptr($1))) + if p == nil || p.data == 0 { + $result = nil + } else { + b := make([]byte, p.size) + a := (*[0x7fffffff]byte)(unsafe.Pointer(p.data))[:p.size] + copy(b, a) + Swig_free(p.data) + Swig_free(uintptr(unsafe.Pointer(p))) + $result = b + } +} + +%include <typemaps/cdata_end.swg> diff --git a/contrib/tools/swig/Lib/go/director.swg b/contrib/tools/swig/Lib/go/director.swg new file mode 100644 index 00000000000..103ba22a34e --- /dev/null +++ b/contrib/tools/swig/Lib/go/director.swg @@ -0,0 +1,80 @@ +/* ----------------------------------------------------------------------------- + * director.swg + * + * This file contains support for director classes so that Go proxy + * methods can be called from C++. + * ----------------------------------------------------------------------------- */ + +#include <exception> +#include <map> + +namespace Swig { + + class DirectorException : public std::exception { + }; +} + +/* Handle memory management for directors. */ + +namespace { + struct GCItem { + virtual ~GCItem() {} + }; + + 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->() { + return _item; + } + + private: + GCItem *_item; + }; + + template <typename Type> + struct GCItem_T : GCItem { + GCItem_T(Type *ptr) : _ptr(ptr) { + } + + virtual ~GCItem_T() { + delete _ptr; + } + + private: + Type *_ptr; + }; +} + +class Swig_memory { +public: + template <typename Type> + void swig_acquire_pointer(Type* vptr) { + if (vptr) { + swig_owner[vptr] = new GCItem_T<Type>(vptr); + } + } +private: + typedef std::map<void *, GCItem_var> swig_ownership_map; + swig_ownership_map swig_owner; +}; + +template <typename Type> +static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) { + if (!pmem) { + *pmem = new Swig_memory; + } + (*pmem)->swig_acquire_pointer(ptr); +} diff --git a/contrib/tools/swig/Lib/go/exception.i b/contrib/tools/swig/Lib/go/exception.i new file mode 100644 index 00000000000..5abd306a4ed --- /dev/null +++ b/contrib/tools/swig/Lib/go/exception.i @@ -0,0 +1,7 @@ +%typemap(throws,noblock=1) (...) { + SWIG_exception(SWIG_RuntimeError,"unknown exception"); +} + +%insert("runtime") %{ +#define SWIG_exception(code, msg) _swig_gopanic(msg) +%} diff --git a/contrib/tools/swig/Lib/go/go.swg b/contrib/tools/swig/Lib/go/go.swg new file mode 100644 index 00000000000..8f5bb4fcdcb --- /dev/null +++ b/contrib/tools/swig/Lib/go/go.swg @@ -0,0 +1,747 @@ +/* ------------------------------------------------------------ + * go.swg + * + * Go configuration module. + * ------------------------------------------------------------ */ + +%include <gostring.swg> + +/* Code insertion directives */ +#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%} + +/* Basic types */ + +%typemap(gotype) bool, const bool & "bool" +%typemap(gotype) char, const char & "byte" +%typemap(gotype) signed char, const signed char & "int8" +%typemap(gotype) unsigned char, const unsigned char & "byte" +%typemap(gotype) short, const short & "int16" +%typemap(gotype) unsigned short, const unsigned short & "uint16" +%typemap(gotype) int, const int & "int" +%typemap(gotype) unsigned int, const unsigned int & "uint" +%typemap(gotype) long, const long & "int64" +%typemap(gotype) unsigned long, const unsigned long & "uint64" +%typemap(gotype) long long, const long long & "int64" +%typemap(gotype) unsigned long long, const unsigned long long & "uint64" +%typemap(gotype) float, const float & "float32" +%typemap(gotype) double, const double & "float64" + +%typemap(in) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $1 = ($1_ltype)$input; %} + +%typemap(in) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ $1 = ($1_ltype)&$input; %} + +%typemap(in) const long & ($*1_ltype temp), + const unsigned long & ($*1_ltype temp) +%{ temp = ($*1_ltype)$input; + $1 = ($1_ltype)&temp; %} + +%typemap(out) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $result = $1; %} + +%typemap(goout) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +"" + +%typemap(out) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ $result = ($*1_ltype)*$1; %} + +%typemap(goout) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +"" + +%typemap(out) void "" + +%typemap(goout) void "" + +%typemap(directorin) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $input = ($1_ltype)$1; %} + +%typemap(godirectorin) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +"" + +%typemap(directorin) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ $input = ($*1_ltype)$1; %} + +%typemap(godirectorin) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +"" + +%typemap(directorout) bool, + char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $result = ($1_ltype)$input; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const bool &, + const char &, + const signed char &, + const unsigned char &, + const short &, + const unsigned short &, + const int &, + const unsigned int &, + const long &, + const unsigned long &, + const long long &, + const unsigned long long &, + const float &, + const double & +%{ + $result = new $*1_ltype($input); + swig_acquire_pointer(&swig_mem, $result); +%} + +/* The size_t type. */ + +%typemap(gotype) size_t, const size_t & %{int64%} + +%typemap(in) size_t +%{ $1 = (size_t)$input; %} + +%typemap(in) const size_t & +%{ $1 = ($1_ltype)&$input; %} + +%typemap(out) size_t +%{ $result = $1; %} + +%typemap(goout) size_t "" + +%typemap(out) const size_t & +%{ $result = ($*1_ltype)*$1; %} + +%typemap(goout) const size_t & "" + +%typemap(directorin) size_t +%{ $input = (size_t)$1; %} + +%typemap(godirectorin) size_t "" + +%typemap(directorin) const size_t & +%{ $input = ($*1_ltype)$1; %} + +%typemap(godirectorin) const size_t & "" + +%typemap(directorout) size_t +%{ $result = ($1_ltype)$input; %} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t & +%{ + $result = new $*1_ltype($input); + swig_acquire_pointer(&swig_mem, $result); +%} + +/* Member pointers. */ + +%typemap(gotype) SWIGTYPE (CLASS::*) +%{$gotypename%} + +%typemap(in) SWIGTYPE (CLASS::*) +%{ $1 = *($&1_ltype)$input; %} + +%typemap(out) SWIGTYPE (CLASS::*) +%{ + struct swig_out_type { intgo size; void* val; } *swig_out; + swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out)); + if (swig_out) { + swig_out->size = sizeof($1_ltype); + swig_out->val = malloc(swig_out->size); + if (swig_out->val) { + *($&1_ltype)(swig_out->val) = $1; + } + } + $result = swig_out; +%} + +%typemap(goout) SWIGTYPE (CLASS::*) +%{ + { + type swig_out_type struct { size int; val uintptr } + p := (*swig_out_type)(unsafe.Pointer($1)) + if p == nil || p.val == 0 { + $result = nil + } else { + m := make([]byte, p.size) + a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size] + copy(m, a) + Swig_free(p.val) + Swig_free(uintptr(unsafe.Pointer(p))) + $result = &m[0] + } + } +%} + +%typemap(directorin) SWIGTYPE (CLASS::*) +%{ $input = *($&1_ltype)$1; %} + +%typemap(godirectorin) SWIGTYPE (CLASS::*) "" + +%typemap(directorout) SWIGTYPE (CLASS::*) +%{ + $result = new $1_ltype($input); + swig_acquire_pointer(&swig_mem, $result); +%} + +/* Pointers. */ + +/* We can't translate pointers using a typemap, so that is handled in + the C++ code. */ +%typemap(gotype) SWIGTYPE * +%{$gotypename%} + +%typemap(in) SWIGTYPE * +%{ $1 = *($&1_ltype)&$input; %} + +%typemap(out) SWIGTYPE * +%{ *($&1_ltype)&$result = ($1_ltype)$1; %} + +%typemap(goout) SWIGTYPE * "" + +%typemap(directorin) SWIGTYPE * +%{ *($&1_ltype)&$input = ($1_ltype)$1; %} + +%typemap(godirectorin) SWIGTYPE * "" + +%typemap(directorout) SWIGTYPE * +%{ $result = *($&1_ltype)&$input; %} + +/* Pointer references. */ + +%typemap(gotype) SWIGTYPE *const& +%{$gotypename%} + +%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0) +%{ + temp = *($1_ltype)&$input; + $1 = ($1_ltype)&temp; +%} + +%typemap(out) SWIGTYPE *const& +%{ *($1_ltype)&$result = *$1; %} + +%typemap(goout) SWIGTYPE *const& "" + +/* References. */ + +/* Converting a C++ reference to Go has to be handled in the C++ + code. */ +%typemap(gotype) SWIGTYPE & +%{$gotypename%} + +%typemap(in) SWIGTYPE & +%{ $1 = *($&1_ltype)&$input; %} + +%typemap(out) SWIGTYPE & +%{ *($&1_ltype)&$result = $1; %} + +%typemap(goout) SWIGTYPE & "" + +%typemap(directorin) SWIGTYPE & +%{ $input = ($1_ltype)&$1; %} + +%typemap(godirectorin) SWIGTYPE & "" + +%typemap(directorout) SWIGTYPE & +%{ *($&1_ltype)&$result = $input; %} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const& +%{ static $*1_ltype swig_temp; + swig_temp = *($1_ltype)&$input; + $result = &swig_temp; %} + +%typemap(gotype) SWIGTYPE && +%{$gotypename%} + +%typemap(in, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) +%{ $1 = *($&1_ltype)&$input; +rvrdeleter.reset($1); %} + +%typemap(out) SWIGTYPE && +%{ *($&1_ltype)&$result = $1; %} + +%typemap(goout) SWIGTYPE && "" + +%typemap(directorin) SWIGTYPE && +%{ $input = ($1_ltype)&$1_name; %} + +%typemap(godirectorin) SWIGTYPE && "" + +%typemap(directorout) SWIGTYPE && +%{ *($&1_ltype)&$result = $input; %} + +/* C arrays turn into Go pointers. If we know the length we can use a + slice. */ + +%typemap(gotype) SWIGTYPE [] +%{$gotypename%} + +%typemap(in) SWIGTYPE [] +%{ $1 = *($&1_ltype)&$input; %} + +%typemap(out) SWIGTYPE [] +%{ *($&1_ltype)&$result = $1; %} + +%typemap(goout) SWIGTYPE [] "" + +%typemap(directorin) SWIGTYPE [] +%{ $input = *($1_ltype)&$1; %} + +%typemap(godirectorin) SWIGTYPE [] "" + +%typemap(directorout) SWIGTYPE [] +%{ *($&1_ltype)&$result = $input; %} + +/* Strings. */ + +%typemap(gotype) + char *, char *&, char[ANY], char[] "string" + +/* Needed to avoid confusion with the way the go module handles + references. */ +%typemap(gotype) char&, unsigned char& "*byte" +%typemap(gotype) signed char& "*int8" + +%typemap(in) + char *, char[ANY], char[] +%{ + $1 = ($1_ltype)malloc($input.n + 1); + memcpy($1, $input.p, $input.n); + $1[$input.n] = '\0'; +%} + +%typemap(in) char *& (char *temp) +%{ + temp = (char *)malloc($input.n + 1); + memcpy(temp, $input.p, $input.n); + temp[$input.n] = '\0'; + $1 = ($1_ltype)&temp; +%} + +%typemap(freearg) + char *, char[ANY], char[] +%{ free($1); %} + +%typemap(freearg) char *& +%{ free(temp$argnum); %} + +%typemap(out,fragment="AllocateString") + char *, char *&, char[ANY], char[] +%{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %} + +%typemap(goout,fragment="CopyString") + char *, char *&, char[ANY], char[] +%{ $result = swigCopyString($1) %} + +%typemap(directorin,fragment="AllocateString") + char *, char *&, char[ANY], char[] +%{ + $input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); +%} + +%typemap(godirectorin,fragment="CopyString") + char *, char *&, char[ANY], char[] +%{ + $result = swigCopyString($input) +%} + +%typemap(godirectorout) + char *, char *&, char[ANY], char[] +%{ + { + p := Swig_malloc(len($input) + 1) + s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input) + 1] + copy(s, $input) + s[len($input)] = 0 + $result = *(*string)(unsafe.Pointer(&s)) + } +%} + +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) + char *, char *&, char[ANY], char[] +%{ $result = ($1_ltype)$input.p; %} + +/* String & length */ + +%typemap(gotype) (const char *STRING, size_t LENGTH) "string" + +%typemap(in) (const char *STRING, size_t LENGTH) +%{ + $1 = ($1_ltype)$input.p; + $2 = ($2_ltype)$input.n; +%} + +%typemap(out,fragment="AllocateString") (const char *STRING, size_t LENGTH) +%{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %} + +%typemap(goout,fragment="CopyString") (const char *STRING, size_t LENGTH) +%{ $result = swigCopyString($1) %} + +%typemap(directorin,fragment="AllocateString") (const char *STRING, size_t LENGTH) +%{ $input = Swig_AllocateString((char*)$1, $2); %} + +%typemap(godirectorin,fragment="CopyString") (const char *STRING, size_t LENGTH) +%{ $result = swigCopyString($input) %} + +%typemap(directorout) (const char *STRING, size_t LENGTH) +%{ + $1 = ($1_ltype)$input.p; + $2 = ($2_ltype)$input.n; +%} +%apply (const char *STRING, size_t LENGTH) { (const char *STRING, int LENGTH) } +%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) } +%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } + +/* The int & type needs to convert to intgo. */ + +%typemap(gotype) int & "*int" + +%typemap(in) int & (int e) +%{ + e = (int)*$input; + $1 = &e; +%} + +%typemap(out) int & +%{ $result = new intgo(*$1); %} + +%typemap(argout) int & +%{ *$input = (intgo)e$argnum; %} + +%typemap(goout) int & "" + +%typemap(directorin) int & (intgo e) +%{ + e = (intgo)$1; + $input = &e; +%} + +%typemap(godirectorin) int & "" + +%typemap(directorout) int & +%{ + $*1_ltype f = ($*1_ltype)*$input; + $result = ($1_ltype)&f; +%} + +%typemap(directorargout) int & +%{ $1 = (int)*$input; %} + +%typemap(argout) const int & "" +%typemap(directorargout) const int & "" + +/* Enums. We can't do the right thing for enums in typemap(gotype) so + we deliberately don't define them. The right thing would be to + capitalize the name. This is instead done in go.cxx. */ + +%typemap(gotype) enum SWIGTYPE +%{$gotypename%} + +%typemap(in) enum SWIGTYPE +%{ $1 = ($1_ltype)$input; %} + +%typemap(out) enum SWIGTYPE +%{ $result = (intgo)$1; %} + +%typemap(goout) enum SWIGTYPE "" + +%typemap(directorin) enum SWIGTYPE +%{ $input = (intgo)$1; %} + +%typemap(godirectorin) enum SWIGTYPE "" + +%typemap(directorout) enum SWIGTYPE +%{ $result = ($1_ltype)$input; %} + +%typemap(directorin) enum SWIGTYPE & (intgo e) +%{ + e = (intgo)$1; + $input = ($1_ltype)&e; +%} + +%typemap(godirectorin) enum SWIGTYPE & "" + +%typemap(directorout) enum SWIGTYPE & +%{ $result = $input; %} + +/* Arbitrary type. This is a type passed by value in the C/C++ code. + We convert it to a pointer for the Go code. Note that all basic + types are explicitly handled above. */ + +%typemap(gotype) SWIGTYPE +%{$gotypename%} + +%typemap(in) SWIGTYPE ($&1_type argp) +%{ + argp = ($&1_ltype)$input; + if (argp == NULL) { + _swig_gopanic("Attempt to dereference null $1_type"); + } + $1 = ($1_ltype)*argp; +%} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +%{ *($&1_ltype*)&$result = new $1_ltype($1); %} +#else +{ + $&1_ltype $1ptr = ($&1_ltype)malloc(sizeof($1_ltype)); + memmove($1ptr, &$1, sizeof($1_type)); + *($&1_ltype*)&$result = $1ptr; +} +#endif + +%typemap(goout) SWIGTYPE "" + +%typemap(directorin) SWIGTYPE +%{ $input = new $1_ltype(SWIG_STD_MOVE($1)); %} + +%typemap(godirectorin) SWIGTYPE "" + +%typemap(directorout) SWIGTYPE +%{ $result = *($&1_ltype)$input; %} + +/* Exception handling */ + +%typemap(throws) char * +%{ _swig_gopanic($1); %} + +%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] +%{ + (void)$1; + _swig_gopanic("C++ $1_type exception thrown"); +%} + +/* Typecheck typemaps. The purpose of these is merely to issue a + warning for overloaded C++ functions that cannot be overloaded in + Go as more than one C++ type maps to a single Go type. */ + +%typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */ + bool, + const bool & + "" + +%typecheck(SWIG_TYPECHECK_CHAR) /* Go byte */ + char, + const char &, + unsigned char, + const unsigned char & + "" + +%typecheck(SWIG_TYPECHECK_INT8) /* Go int8 */ + signed char, + const signed char & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Go int16 */ + short, + const short & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Go uint16 */ + unsigned short, + const unsigned short & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Go int */ + int, + const int & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Go uint */ + unsigned int, + const unsigned int & + "" + +%typecheck(SWIG_TYPECHECK_INT64) /* Go int64 */ + long, + const long &, + long long, + const long long & + "" + +%typecheck(SWIG_TYPECHECK_INT64) /* Go uint64 */ + unsigned long, + const unsigned long &, + unsigned long long, + const unsigned long long & + "" + +%typecheck(SWIG_TYPECHECK_FLOAT) /* Go float32 */ + float, + const float & + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE) /* Go float64 */ + double, + const double & + "" + +%typecheck(SWIG_TYPECHECK_STRING) /* Go string */ + char *, + char *&, + char[ANY], + char [], + signed char *, + signed char *&, + signed char[ANY], + signed char [], + unsigned char *, + unsigned char *&, + unsigned char[ANY], + unsigned char [] + "" + +%typecheck(SWIG_TYPECHECK_POINTER) + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE &&, + SWIGTYPE *const&, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" + +%apply SWIGTYPE * { SWIGTYPE *const } +%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) } +%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) } + +/* Go keywords. */ +%include <gokw.swg> + +%include <goruntime.swg> diff --git a/contrib/tools/swig/Lib/go/gokw.swg b/contrib/tools/swig/Lib/go/gokw.swg new file mode 100644 index 00000000000..35428300246 --- /dev/null +++ b/contrib/tools/swig/Lib/go/gokw.swg @@ -0,0 +1,33 @@ +/* Rename keywords. */ + +#define GOKW(x) %keywordwarn("'" `x` "' is a Go keyword",rename="X%s") `x` +#define GOBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in Go") "::"`x` + +GOKW(break); +GOKW(case); +GOKW(chan); +GOKW(const); +GOKW(continue); +GOKW(default); +GOKW(defer); +GOKW(else); +GOKW(fallthrough); +GOKW(for); +GOKW(func); +GOKW(go); +GOKW(goto); +GOKW(if); +GOKW(import); +GOKW(interface); +GOKW(package); +GOKW(range); +GOKW(return); +GOKW(select); +GOKW(struct); +GOKW(switch); +GOKW(type); +GOKW(var); + +GOBN(map); + +#undef GOKW diff --git a/contrib/tools/swig/Lib/go/goruntime.swg b/contrib/tools/swig/Lib/go/goruntime.swg new file mode 100644 index 00000000000..7bf083bd3da --- /dev/null +++ b/contrib/tools/swig/Lib/go/goruntime.swg @@ -0,0 +1,217 @@ +/* ------------------------------------------------------------ + * goruntime.swg + * + * Go runtime code for the various generated files. + * ------------------------------------------------------------ */ + +%inline %{ +static void Swig_free(void* p) { + free(p); +} + +static void* Swig_malloc(int c) { + return malloc(c); +} +%} + +%insert(runtime) %{ +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> + +%} + +%insert(cgo_comment_typedefs) %{ +#include <stddef.h> +#include <stdint.h> +%} + +#if SWIGGO_INTGO_SIZE == 32 +%insert(runtime) %{ +typedef int intgo; +typedef unsigned int uintgo; +%} +%insert(cgo_comment_typedefs) %{ +typedef int intgo; +typedef unsigned int uintgo; +%} +#elif SWIGGO_INTGO_SIZE == 64 +%insert(runtime) %{ +typedef long long intgo; +typedef unsigned long long uintgo; +%} +%insert(cgo_comment_typedefs) %{ +typedef long long intgo; +typedef unsigned long long uintgo; +%} +#else +%insert(runtime) %{ +typedef ptrdiff_t intgo; +typedef size_t uintgo; +%} +%insert(cgo_comment_typedefs) %{ +typedef ptrdiff_t intgo; +typedef size_t uintgo; +%} +#endif + +#ifndef SWIGGO_GCCGO +// Set the host compiler struct attribute that will be +// used to match gc's struct layout. For example, on 386 Windows, +// gcc wants to 8-align int64s, but gc does not. +// Use __gcc_struct__ to work around http://gcc.gnu.org/PR52991 on x86, +// and https://golang.org/issue/5603. +// See: https://github.com/golang/go/blob/fcbf04f9b93b4cd8addd05c2ed784118eb50a46c/src/cmd/cgo/out.go#L663 +%insert(runtime) %{ +# if !defined(__clang__) && (defined(__i386__) || defined(__x86_64__)) +# define SWIGSTRUCTPACKED __attribute__((__packed__, __gcc_struct__)) +# else +# define SWIGSTRUCTPACKED __attribute__((__packed__)) +# endif +%} +#else +# define SWIGSTRUCTPACKED +#endif + +%insert(runtime) %{ + +typedef struct { char *p; intgo n; } _gostring_; +typedef struct { void* array; intgo len; intgo cap; } _goslice_; + +%} + +%insert(cgo_comment_typedefs) %{ + +typedef struct { char *p; intgo n; } _gostring_; +typedef struct { void* array; intgo len; intgo cap; } _goslice_; + +%} + +#ifdef SWIGGO_GCCGO + +/* Boilerplate for C/C++ code when using gccgo. */ +%insert(runtime) %{ +#define SWIGGO_GCCGO + +#ifdef __cplusplus +extern "C" { +#endif +extern void *_cgo_allocate(size_t); +extern void _cgo_panic(const char *); +#ifdef __cplusplus +} +#endif + +#define _swig_goallocate _cgo_allocate +#define _swig_gopanic _cgo_panic +%} + +#endif + +#ifndef SWIGGO_GCCGO + +%go_import("unsafe", _ "runtime/cgo") + +#else + +%go_import("syscall", "unsafe") + +%insert(go_header) %{ + +type _ syscall.Sockaddr + +%} + +#endif + +%insert(go_header) %{ + +type _ unsafe.Pointer + +%} + +/* Swig_always_false is used to conditionally assign parameters to + Swig_escape_val so that the compiler thinks that they escape. We + only assign them if Swig_always_false is true, which it never is. + We export the variable so that the compiler doesn't realize that it + is never set. */ +%insert(go_header) %{ +var Swig_escape_always_false bool +var Swig_escape_val interface{} +%} + +/* Function pointers are translated by the code in go.cxx into + _swig_fnptr. Member pointers are translated to _swig_memberptr. */ + +%insert(go_header) %{ +type _swig_fnptr *byte +type _swig_memberptr *byte +%} + +/* Convert a Go interface value into a C++ pointer. */ + +%insert(go_header) %{ +func getSwigcptr(v interface { Swigcptr() uintptr }) uintptr { + if v == nil { + return 0 + } + return v.Swigcptr() +} +%} + +/* For directors we need C++ to track a Go pointer. Since we can't + pass a Go pointer into C++, we use a map to track the pointers on + the Go side. */ + +%go_import("sync") + +%insert(go_header) %{ +type _ sync.Mutex +%} + +%insert(go_director) %{ + +var swigDirectorTrack struct { + sync.Mutex + m map[int]interface{} + c int +} + +func swigDirectorAdd(v interface{}) int { + swigDirectorTrack.Lock() + defer swigDirectorTrack.Unlock() + if swigDirectorTrack.m == nil { + swigDirectorTrack.m = make(map[int]interface{}) + } + swigDirectorTrack.c++ + ret := swigDirectorTrack.c + swigDirectorTrack.m[ret] = v + return ret +} + +func swigDirectorLookup(c int) interface{} { + swigDirectorTrack.Lock() + defer swigDirectorTrack.Unlock() + ret := swigDirectorTrack.m[c] + if ret == nil { + panic("C++ director pointer not found (possible use-after-free)") + } + return ret +} + +func swigDirectorDelete(c int) { + swigDirectorTrack.Lock() + defer swigDirectorTrack.Unlock() + if swigDirectorTrack.m[c] == nil { + if c > swigDirectorTrack.c { + panic("C++ director pointer invalid (possible memory corruption") + } else { + panic("C++ director pointer not found (possible use-after-free)") + } + } + delete(swigDirectorTrack.m, c) +} + +%} diff --git a/contrib/tools/swig/Lib/go/gostring.swg b/contrib/tools/swig/Lib/go/gostring.swg new file mode 100644 index 00000000000..d9c47d28583 --- /dev/null +++ b/contrib/tools/swig/Lib/go/gostring.swg @@ -0,0 +1,29 @@ +/* ------------------------------------------------------------ + * gostring.swg + * + * Support for returning strings from C to Go. + * ------------------------------------------------------------ */ + +// C/C++ code to convert a memory buffer into a Go string allocated in +// C/C++ memory. +%fragment("AllocateString", "runtime") %{ +static _gostring_ Swig_AllocateString(const char *p, size_t l) { + _gostring_ ret; + ret.p = (char*)malloc(l); + memcpy(ret.p, p, l); + ret.n = l; + return ret; +} +%} + +// Go code to convert a string allocated in C++ memory to one +// allocated in Go memory. +%fragment("CopyString", "go_runtime") %{ +type swig_gostring struct { p unsafe.Pointer; n int } +func swigCopyString(s string) string { + p := *(*swig_gostring)(unsafe.Pointer(&s)) + r := string((*[0x7fffffff]byte)(p.p)[:p.n]) + Swig_free(uintptr(p.p)) + return r +} +%} diff --git a/contrib/tools/swig/Lib/go/std_array.i b/contrib/tools/swig/Lib/go/std_array.i new file mode 100644 index 00000000000..36c790e3c1b --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_array.i @@ -0,0 +1,43 @@ +/* ----------------------------------------------------------------------------- + * std_array.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +namespace std { + + template<class T, size_t N> class array { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + array(); + array(const array& other); + + size_type size() const; + %rename(isEmpty) empty; + bool empty() const; + void fill(const T& u); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("array index out of range"); + } + void set(int i, const value_type& val) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = val; + else + throw std::out_of_range("array index out of range"); + } + } + }; +} diff --git a/contrib/tools/swig/Lib/go/std_common.i b/contrib/tools/swig/Lib/go/std_common.i new file mode 100644 index 00000000000..c010facacd1 --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_common.i @@ -0,0 +1,4 @@ +%include <std_except.i> + +%apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; diff --git a/contrib/tools/swig/Lib/go/std_deque.i b/contrib/tools/swig/Lib/go/std_deque.i new file mode 100644 index 00000000000..cb98f6c2fb3 --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/contrib/tools/swig/Lib/go/std_except.i b/contrib/tools/swig/Lib/go/std_except.i new file mode 100644 index 00000000000..4f021a1264a --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_except.i @@ -0,0 +1,31 @@ +/* ----------------------------------------------------------------------------- + * std_except.i + * + * Typemaps used by the STL wrappers that throw exceptions. + * These typemaps are used when methods are declared with an STL exception specification, such as + * size_t at() const throw (std::out_of_range); + * ----------------------------------------------------------------------------- */ + +%{ +#include <typeinfo> +#include <stdexcept> +%} + +namespace std +{ + %ignore exception; + struct exception {}; +} + +%typemap(throws) std::bad_cast %{_swig_gopanic($1.what());%} +%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%} +%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::exception %{_swig_gopanic($1.what());%} +%typemap(throws) std::invalid_argument %{_swig_gopanic($1.what());%} +%typemap(throws) std::length_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::logic_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::out_of_range %{_swig_gopanic($1.what());%} +%typemap(throws) std::overflow_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::range_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::runtime_error %{_swig_gopanic($1.what());%} +%typemap(throws) std::underflow_error %{_swig_gopanic($1.what());%} diff --git a/contrib/tools/swig/Lib/go/std_list.i b/contrib/tools/swig/Lib/go/std_list.i new file mode 100644 index 00000000000..ff6f700130f --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_list.i @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------------- + * std_list.i + * ----------------------------------------------------------------------------- */ + +%{ +#include <list> +#include <stdexcept> +%} + +namespace std { + + template<class T> + class list { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + list(); + list(const list& other); + + size_type size() const; + bool empty() const; + %rename(isEmpty) empty; + void clear(); + void push_front(const value_type& x); + void pop_front(); + void push_back(const value_type& x); + void pop_back(); + void remove(value_type x); + void reverse(); + void unique(); + void sort(); + void merge(list& x); + }; + +} diff --git a/contrib/tools/swig/Lib/go/std_map.i b/contrib/tools/swig/Lib/go/std_map.i new file mode 100644 index 00000000000..19281ad7d50 --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_map.i @@ -0,0 +1,70 @@ +/* ----------------------------------------------------------------------------- + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T, class C = std::less<K> > class map { + // add typemaps here + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + map(); + map(const map& other); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map< K, T, C >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { +%#ifdef __cpp_lib_map_try_emplace + (*self).insert_or_assign(key, x); +%#else + (*self)[key] = x; +%#endif + } + void del(const K& key) throw (std::out_of_range) { + std::map< K, T, C >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map< K, T, C >::iterator i = self->find(key); + return i != self->end(); + } + } + }; +} diff --git a/contrib/tools/swig/Lib/go/std_pair.i b/contrib/tools/swig/Lib/go/std_pair.i new file mode 100644 index 00000000000..732347db583 --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_pair.i @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + typedef T first_type; + typedef U second_type; + + pair(); + pair(T first, U second); + pair(const pair& other); + + template <class U1, class U2> pair(const pair<U1, U2> &other); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/contrib/tools/swig/Lib/go/std_string.i b/contrib/tools/swig/Lib/go/std_string.i new file mode 100644 index 00000000000..35b4a5e46b1 --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_string.i @@ -0,0 +1,162 @@ +/* ----------------------------------------------------------------------------- + * std_string.i + * + * Typemaps for std::string and const std::string& + * These are mapped to a Go string and are passed around by value. + * + * To use non-const std::string references use the following %apply. Note + * that they are passed by value. + * %apply const std::string & {std::string &}; + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + +%naturalvar string; + +class string; + +%typemap(gotype) string, const string & "string" + +%typemap(in) string +%{ $1.assign($input.p, $input.n); %} + +%typemap(godirectorout) string +%{ + { + p := Swig_malloc(len($input)) + s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)] + copy(s, $input) + $result = *(*string)(unsafe.Pointer(&s)) + } +%} + +%typemap(directorout) string +%{ + $result.assign($input.p, $input.n); + free($input.p); +%} + +%typemap(out,fragment="AllocateString") string +%{ $result = Swig_AllocateString($1.data(), $1.length()); %} + +%typemap(goout,fragment="CopyString") string +%{ $result = swigCopyString($1) %} + +%typemap(directorin,fragment="AllocateString") string +%{ $input = Swig_AllocateString($1.data(), $1.length()); %} + +%typemap(godirectorin,fragment="CopyString") string +%{ $result = swigCopyString($input) %} + +%typemap(throws) string +%{ _swig_gopanic($1.c_str()); %} + +%typemap(in) const string & +%{ + $*1_ltype $1_str($input.p, $input.n); + $1 = &$1_str; +%} + +%typemap(godirectorout) const string & +%{ + { + p := Swig_malloc(len($input)) + s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)] + copy(s, $input) + $result = *(*string)(unsafe.Pointer(&s)) + } +%} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & +%{ + static $*1_ltype $1_str; + $1_str.assign($input.p, $input.n); + free($input.p); + $result = &$1_str; +%} + +%typemap(out,fragment="AllocateString") const string & +%{ $result = Swig_AllocateString((*$1).data(), (*$1).length()); %} + +%typemap(goout,fragment="CopyString") const string & +%{ $result = swigCopyString($1) %} + +%typemap(directorin,fragment="AllocateString") const string & +%{ $input = Swig_AllocateString($1.data(), $1.length()); %} + +%typemap(godirectorin,fragment="CopyString") const string & +%{ $result = swigCopyString($input) %} + +%typemap(throws) const string & +%{ _swig_gopanic($1.c_str()); %} + + +%typemap(gotype) string * "*string" + +%typemap(in) string * (string temp) +%{ + if ($input) { + temp.assign($input->p, $input->n); + $1 = &temp; + } else + $1 = 0; +%} + +%typemap(godirectorout) string * +%{ + if $input != nil { + p := Swig_malloc(len(*$input)) + s := (*[1<<30]byte)(unsafe.Pointer(p))[:len(*$input)] + copy(s, *$input) + $result = (*string)(unsafe.Pointer(&s)) + } else { + $result = nil + } +%} + +%typemap(directorout) string * (string temp) +%{ + temp.assign($input->p, $input->n); + $result = &temp; + free($input.p); +%} + +%typemap(out,fragment="AllocateString") string * (_gostring_ temp) +%{ + temp = Swig_AllocateString($1->data(), $1->length()); + $result = &temp; +%} + +%typemap(goout,fragment="CopyString") string * +%{ *$result = swigCopyString(*$1) %} + +%typemap(directorin,fragment="AllocateString") string * (_gostring_ temp) +%{ + if ($1) { + temp = Swig_AllocateString($1->data(), $1->length()); + $input = &temp; + } else + $input = 0; +%} + +%typemap(godirectorin,fragment="CopyString") string * +%{ *$result = swigCopyString(*$input); %} + +%typemap(argout,fragment="AllocateString") string * +%{ + if ($1) + *$input = Swig_AllocateString($1->data(), $1->length()); +%} + +%typemap(goargout,fragment="CopyString") string * +%{ + if $input != nil { + *$1 = swigCopyString(*$input) + } +%} + +} diff --git a/contrib/tools/swig/Lib/go/std_vector.i b/contrib/tools/swig/Lib/go/std_vector.i new file mode 100644 index 00000000000..679c707596e --- /dev/null +++ b/contrib/tools/swig/Lib/go/std_vector.i @@ -0,0 +1,92 @@ +/* ----------------------------------------------------------------------------- + * std_vector.i + * ----------------------------------------------------------------------------- */ + +%{ +#include <vector> +#include <stdexcept> +%} + +namespace std { + + template<class T> class vector { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + vector(); + vector(size_type n); + vector(const vector& other); + + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const value_type& val) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = val; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + // bool specialization + template<> class vector<bool> { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef bool value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef bool const_reference; + + vector(); + vector(size_type n); + vector(const vector& other); + + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %rename(add) push_back; + void push_back(const value_type& x); + %extend { + bool get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const value_type& val) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = val; + else + throw std::out_of_range("vector index out of range"); + } + } + }; +} diff --git a/contrib/tools/swig/Lib/go/stl.i b/contrib/tools/swig/Lib/go/stl.i new file mode 100644 index 00000000000..04f86014f2c --- /dev/null +++ b/contrib/tools/swig/Lib/go/stl.i @@ -0,0 +1,10 @@ +/* ----------------------------------------------------------------------------- + * stl.i + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/contrib/tools/swig/Lib/go/swigmove.i b/contrib/tools/swig/Lib/go/swigmove.i new file mode 100644 index 00000000000..e1984b6ea26 --- /dev/null +++ b/contrib/tools/swig/Lib/go/swigmove.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * swigmove.i + * + * Input typemaps library for implementing full move semantics when passing + * parameters by value. + * ----------------------------------------------------------------------------- */ + +%typemap(in) SWIGTYPE MOVE ($&1_type argp) +%{ + argp = ($&1_ltype)$input; + if (argp == NULL) { + _swig_gopanic("Attempt to dereference null $1_type"); + } + SwigValueWrapper< $1_ltype >::reset($1, argp); +%} diff --git a/contrib/tools/swig/Lib/go/typemaps.i b/contrib/tools/swig/Lib/go/typemaps.i new file mode 100644 index 00000000000..d2e60d37c8b --- /dev/null +++ b/contrib/tools/swig/Lib/go/typemaps.i @@ -0,0 +1,298 @@ +/* ----------------------------------------------------------------------------- + * typemaps.i + * + * Pointer and reference handling typemap library + * + * These mappings provide support for input/output arguments and common + * uses for C/C++ pointers and C++ references. + * ----------------------------------------------------------------------------- */ + +/* +INPUT typemaps +-------------- + +These typemaps remap a C pointer or C++ reference to be an "INPUT" value which is +passed by value instead of reference. + +The following typemaps can be applied to turn a pointer or reference into a simple +input value. That is, instead of passing a pointer or reference to an object, +you would use a real value instead. + + bool *INPUT, bool &INPUT + signed char *INPUT, signed char &INPUT + unsigned char *INPUT, unsigned char &INPUT + short *INPUT, short &INPUT + unsigned short *INPUT, unsigned short &INPUT + int *INPUT, int &INPUT + unsigned int *INPUT, unsigned int &INPUT + long *INPUT, long &INPUT + unsigned long *INPUT, unsigned long &INPUT + long long *INPUT, long long &INPUT + unsigned long long *INPUT, unsigned long long &INPUT + float *INPUT, float &INPUT + double *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); + +In Go you could then use it like this: + answer := modulename.Fadd(10.0, 20.0) + +There are no char *INPUT typemaps, however you can apply the signed +char * typemaps instead: + %include <typemaps.i> + %apply signed char *INPUT {char *input}; + void f(char *input); +*/ + +%define INPUT_TYPEMAP(TYPE, GOTYPE) +%typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE" + + %typemap(in) TYPE *INPUT, TYPE &INPUT +%{ $1 = ($1_ltype)&$input; %} + +%typemap(out) TYPE *INPUT, TYPE &INPUT "" + +%typemap(goout) TYPE *INPUT, TYPE &INPUT "" + +%typemap(freearg) TYPE *INPUT, TYPE &INPUT "" + +%typemap(argout) TYPE *INPUT, TYPE &INPUT "" + +// %typemap(typecheck) TYPE *INPUT = TYPE; +// %typemap(typecheck) TYPE &INPUT = TYPE; +%enddef + +INPUT_TYPEMAP(bool, bool); +INPUT_TYPEMAP(signed char, int8); +INPUT_TYPEMAP(char, byte); +INPUT_TYPEMAP(unsigned char, byte); +INPUT_TYPEMAP(short, int16); +INPUT_TYPEMAP(unsigned short, uint16); +INPUT_TYPEMAP(int, int); +INPUT_TYPEMAP(unsigned int, uint); +INPUT_TYPEMAP(long, int64); +INPUT_TYPEMAP(unsigned long, uint64); +INPUT_TYPEMAP(long long, int64); +INPUT_TYPEMAP(unsigned long long, uint64); +INPUT_TYPEMAP(float, float32); +INPUT_TYPEMAP(double, float64); + +#undef INPUT_TYPEMAP + +// OUTPUT typemaps. These typemaps are used for parameters that +// are output only. An array replaces the c pointer or reference parameter. +// The output value is returned in this array passed in. + +/* +OUTPUT typemaps +--------------- + +The following typemaps can be applied to turn a pointer or reference +into an "output" value. When calling a function, no input value would +be given for a parameter, but an output value would be returned. This +works by a Go slice being passed as a parameter where a c pointer or +reference is required. As with any Go function, the array is passed +by reference so that any modifications to the array will be picked up +in the calling function. Note that the array passed in MUST have at +least one element, but as the c function does not require any input, +the value can be set to anything. + + bool *OUTPUT, bool &OUTPUT + signed char *OUTPUT, signed char &OUTPUT + unsigned char *OUTPUT, unsigned char &OUTPUT + short *OUTPUT, short &OUTPUT + unsigned short *OUTPUT, unsigned short &OUTPUT + int *OUTPUT, int &OUTPUT + unsigned int *OUTPUT, unsigned int &OUTPUT + long *OUTPUT, long &OUTPUT + unsigned long *OUTPUT, unsigned long &OUTPUT + long long *OUTPUT, long long &OUTPUT + unsigned long long *OUTPUT, unsigned long long &OUTPUT + float *OUTPUT, float &OUTPUT + double *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 Go output of the function would be the function return value and the +value in the single element array. In Go you would use it like this: + + ptr := []float64{0.0} + fraction := modulename.Modf(5.0,ptr) + +There are no char *OUTPUT typemaps, however you can apply the signed +char * typemaps instead: + %include <typemaps.i> + %apply signed char *OUTPUT {char *output}; + void f(char *output); +*/ + +%define OUTPUT_TYPEMAP(TYPE, GOTYPE) +%typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%} + +%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) +{ + if ($input.len == 0) { + _swig_gopanic("array must contain at least 1 element"); + } + $1 = &temp; +} + +%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT "" + +%typemap(goout) TYPE *INPUT, TYPE &INPUT "" + +%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" + +%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT +{ + TYPE* a = (TYPE *) $input.array; + a[0] = temp$argnum; +} + +%enddef + +OUTPUT_TYPEMAP(bool, bool); +OUTPUT_TYPEMAP(signed char, int8); +OUTPUT_TYPEMAP(char, byte); +OUTPUT_TYPEMAP(unsigned char, byte); +OUTPUT_TYPEMAP(short, int16); +OUTPUT_TYPEMAP(unsigned short, uint16); +OUTPUT_TYPEMAP(int, int); +OUTPUT_TYPEMAP(unsigned int, uint); +OUTPUT_TYPEMAP(long, int64); +OUTPUT_TYPEMAP(unsigned long, uint64); +OUTPUT_TYPEMAP(long long, int64); +OUTPUT_TYPEMAP(unsigned long long, uint64); +OUTPUT_TYPEMAP(float, float32); +OUTPUT_TYPEMAP(double, float64); + +#undef OUTPUT_TYPEMAP + +/* +INOUT typemaps +-------------- + +Mappings for a parameter that is both an input and an output parameter + +The following typemaps can be applied to make a function parameter both +an input and output value. This combines the behavior of both the +"INPUT" and "OUTPUT" typemaps described earlier. Output values are +returned as an element in a Go slice. + + bool *INOUT, bool &INOUT + signed char *INOUT, signed char &INOUT + unsigned char *INOUT, unsigned char &INOUT + short *INOUT, short &INOUT + unsigned short *INOUT, unsigned short &INOUT + int *INOUT, int &INOUT + unsigned int *INOUT, unsigned int &INOUT + long *INOUT, long &INOUT + unsigned long *INOUT, unsigned long &INOUT + long long *INOUT, long long &INOUT + unsigned long long *INOUT, unsigned long long &INOUT + float *INOUT, float &INOUT + double *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); + +This works similarly to C in that the mapping directly modifies the +input value - the input must be an array with a minimum of one element. +The element in the array is the input and the output is the element in +the array. + + x := []float64{5.0} + Neg(x); + +The implementation of the OUTPUT and INOUT typemaps is different to +other languages in that other languages will return the output value +as part of the function return value. This difference is due to Go +being a typed language. + +There are no char *INOUT typemaps, however you can apply the signed +char * typemaps instead: + %include <typemaps.i> + %apply signed char *INOUT {char *inout}; + void f(char *inout); +*/ + +%define INOUT_TYPEMAP(TYPE, GOTYPE) +%typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%} + +%typemap(in) TYPE *INOUT, TYPE &INOUT { + if ($input.len == 0) { + _swig_gopanic("array must contain at least 1 element"); + } + $1 = ($1_ltype) $input.array; +} + +%typemap(out) TYPE *INOUT, TYPE &INOUT "" + +%typemap(goout) TYPE *INOUT, TYPE &INOUT "" + +%typemap(freearg) TYPE *INOUT, TYPE &INOUT "" + +%typemap(argout) TYPE *INOUT, TYPE &INOUT "" + +%enddef + +INOUT_TYPEMAP(bool, bool); +INOUT_TYPEMAP(signed char, int8); +INOUT_TYPEMAP(char, byte); +INOUT_TYPEMAP(unsigned char, byte); +INOUT_TYPEMAP(short, int16); +INOUT_TYPEMAP(unsigned short, uint16); +INOUT_TYPEMAP(int, int); +INOUT_TYPEMAP(unsigned int, uint); +INOUT_TYPEMAP(long, int64); +INOUT_TYPEMAP(unsigned long, uint64); +INOUT_TYPEMAP(long long, int64); +INOUT_TYPEMAP(unsigned long long, uint64); +INOUT_TYPEMAP(float, float32); +INOUT_TYPEMAP(double, float64); + +#undef INOUT_TYPEMAP diff --git a/contrib/tools/swig/Lib/go/ya.make b/contrib/tools/swig/Lib/go/ya.make new file mode 100644 index 00000000000..21a9b3ed30a --- /dev/null +++ b/contrib/tools/swig/Lib/go/ya.make @@ -0,0 +1,24 @@ +# Generated by devtools/yamaker. + +LIBRARY() + +LICENSE(LicenseRef-scancode-swig) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +SUBSCRIBER(g:cpp-contrib) + +VERSION(4.3.1) + +ORIGINAL_SOURCE(https://github.com/swig/swig/archive/v4.3.1.tar.gz) + +ADDINCL( + GLOBAL FOR + swig + contrib/tools/swig/Lib/go + GLOBAL FOR + swig + contrib/tools/swig/Lib +) + +END() |