pax_global_header00006660000000000000000000000064122406344470014520gustar00rootroot0000000000000052 comment=a6fcbef57e28d80cdff566124f5808451eaf0924 giws-2.0.2/000077500000000000000000000000001224063444700124725ustar00rootroot00000000000000giws-2.0.2/.gitignore000066400000000000000000000002571224063444700144660ustar00rootroot00000000000000*.pyc *~ # remove examples generated files /examples/*/*.cpp /examples/*/*.hxx /examples/*/*/*.class /examples/*/main # ignore eclipse pydev files /.project /.pydevproject giws-2.0.2/AUTHORS000066400000000000000000000005401224063444700135410ustar00rootroot00000000000000giws has been written for Scilab by: - Sylvestre Ledru - Vincent Couvert - Jean-Baptiste Silvy - Matthieu Walter - Calixte Denizet - Clément David giws-2.0.2/BUGS000066400000000000000000000001671224063444700131610ustar00rootroot00000000000000Plenty I guess... * when we load the XML declaration, we are (wrongly) assuming that the order will always be the samegiws-2.0.2/CHANGELOG000066400000000000000000000334021224063444700137060ustar00rootroot00000000000000giws (2.0.2) [ Calixte Denizet ] * Put jmethoID in a static variable. * Remove some empty lines and spaces at end of the line * Fix a problem when returning a matrix from a Java function. * Fix a typo in the generated code * Add option -s/--enable-return-size-array (default) -- Sylvestre Ledru Sun, 27 Jan 2013 09:53:10 +0100 giws (2.0.1) * Remove the copyright and authors from generated code * Update the setup.py configuration * Use a cache by *buffer type * To compute the size of a bytebuffer from C, use sizeof(byte) * Use the class name of the member * When a method returned a NULL String, it could lead to errors (Closes: #766 -- Sylvestre Ledru Mon, 17 Sep 2012 17:44:10 +0200 giws (2.0.0) * Management of the Java buffer classes: - ByteBuffer - CharBuffer - DoubleBuffer - FloatBuffer - IntBuffer - LongBuffer - ShortBuffer See examples/bytebuffer/ for examples. * Fix a bug when no parameter but was returning an array * Update the byte declaration under Windows (Closes: #639) * Comments contain now the command line used to generated the file * Add a const in the method profile when dealing with pointers (Closes: #675) -- Sylvestre Ledru Sun, 20 Nov 2011 20:40:35 +0100 giws (1.3.1) * Export GIWS symbols also under Linux -- Sylvestre Ledru Sun, 20 Nov 2011 20:40:35 +0100 giws (1.3.0) * New option -g introduced to generate on demand GiwsException.cpp * The option -e no longer generates automatically GiwsException.cpp * Fix a problem with two similar declarations with a different profile (Closes: #517) * Fix a bug when a string is declared but empty. * Add a whatStr() method (returns a C++ String). Deprecate what() (Could lead to side effect: String could be deleted) * JniBadAllocException creator was expecting the VM env while it should not (Closes: #526) * Export GIWS symbols on Windows (Closes: #405) -- Sylvestre Ledru Mon, 05 Sep 2011 17:36:52 +0200 giws (1.2.4) * Two potential memory leaks removed * A check on an allocation added -- Sylvestre Ledru Fri, 25 Mar 2011 08:57:20 +0100 giws (1.2.3) * Forgot to increment the version number of the generated code -- Sylvestre Ledru Fri, 11 Mar 2011 17:33:26 +0100 giws (1.2.2) [ Calixte Denizet ] * Bad path to libjvm on 64 bits OS. * Add the possibility to detach the current thread of the jvm: Example 5 added to show this new feature. -- Sylvestre Ledru Fri, 11 Mar 2011 12:03:26 +0100 giws (1.2.1) * Examples compile out of the box under 64 bit CPU * When an exception occurred, the memory was not cleaned up. -- Sylvestre Ledru Sat, 18 Sep 2010 15:49:13 +0200 giws (1.2.0) * Management of inheritance in GIWS (Closes: #12) See /giws/examples/inherit for a usage example * Avoid to have jobjectArray in the profile. Does not show the actual type. (Closes: #143) * Reject a method with two parameters with the same name (Closes: #144) * Many clean up and various small improvements [ Bruno Jofret ] * Manage Java Arrays returning null. Give NULL back to C++. (Closes: #134) [ Calixte Denizet ] * All the array creations were not checked. -- Sylvestre Ledru Tue, 21 Sep 2010 21:08:13 +0200 giws (1.1.0) * GIWS can now manage array of array. String[][] for example. (Closes: #5) * Example4 added to show this new feature * Using byte datatypes was not providing the appropriate typedef (Closes: #6) * Management of the char datatype (Closes: #7) * Example3 updated: Shows how to retrieve the example text error * By default, when dealing with array, an argument (int*) is added to provide the size of the array. Option -r/--disable-return-size-array to go back to the previous behavior. -- Sylvestre Ledru Wed, 02 Dec 2009 15:50:38 +0100 giws (1.0.6) * When using an array of bool, a static_cast was failing. Rollback to the classic cast. This bug has been introduced in the version 1.0.5 (Closes: #3) * When a java method returns a String[], the length of the array is lost in the generated cpp, then, we set arrayOfString[len]=NULL. (Closes: #4) -- Sylvestre Ledru Wed, 21 Oct 2009 15:02:40 +0200 giws (1.0.5) * Classical cast changed for *_cast * The use of a static method returning an array wasn't calling the right method. It didn't seem to trigger any errors in the past but the latest version of the JDK is now complaining. -- Sylvestre Ledru Wed, 21 Oct 2009 15:02:40 +0200 giws (1.0.4) * Missing exception check on some calls of methods returning an array * Use a const_cast in the examples (to avoid warnings) * Some warnings removed in the examples * Lack of information in the error message when dealing with unknown type -- Sylvestre Ledru Tue, 06 Oct 2009 12:10:12 +0200 giws (1.0.3) * The use of a static method returning an int wasn't calling the right method. It didn't seem to trigger any errors in the past but the latest version of the JDK is now complaining. -- Sylvestre Ledru Sun, 05 Jul 2009 20:49:03 +0200 giws (1.0.2) [ Sylvestre Ledru ] * Typos fixed * synchronize & endSynchronize are also managed by option -e/--throws-exception-on-error [ Matthieu Walter ] * Better management of the argument * Removed old unused code (__dict__...) * show_help wasn't called when a wrong cmdline param was given (uncatched exception was thrown instead) * Description is now mandatory: no -f/--description-file prints help * Fixed opts/args len checking to fit the real usage * Makefiles added to build quickly the examples: cd examples; make -- Sylvestre Ledru Mon, 27 Apr 2009 13:40:15 +0100 giws (1.0.1) * Fixed a bug in the Exception check in a method call In some cases (like a Java method returning a String), the check of Exception was done on the clean of the variable, not on the potential exception raised by the method. -- Sylvestre Ledru Mon, 13 Oct 2008 17:25:33 +0100 giws (1.0) * Fixed a bug in the Exception Class. JNI complained: 'WARNING in native method: JNI call made with exception pending' * Mandatory output about on C++ exception removed * Third example added (Exception management) * Warning about bad class descriptor with the FindClass method removed * Moved to version 1.0 to sync with the release 5.0 of Scilab * Main program renamed giws.py => giws * setup.py added to facilitate the packaging * Update of the README -- Sylvestre Ledru Thu, 11 Sept 2008 16:05:33 +0100 giws (0.9.9.4) * native type for "int" changed to "int" from "long" (see http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/types.html#wp428) -- Simon Lipp Tue, 26 Aug 2008 15:16:03 +0100 giws (0.9.9.3) * A malloc replaced by new * More feedback in the exception -- Sylvestre Ledru Mon, 25 Aug 2008 16:00:52 +0100 giws (0.9.9.2) * C++ Exception can be triggered in case of error instead of an ugly exit(EXIT_FAILURE) Use the options: -e/--throws-exception-on-error * Update of copyright notices * some malloc replaced by new * Memory leaks removed -- Sylvestre Ledru Wed, 13 Aug 2008 16:18:52 +0100 giws (0.9.9.1) [ Vincent Couvert ] * Bug fixed: a static method can now return String[] values [ Sylvestre Ledru ] * Missing author (Matthieu Walter) * Performance improvement (use cache on the methodId) * Warnings removed (cls unused / shadowed variable) * Documentation updated * Memory leaks removed * Redefinition of a variable was causing some warning under Sun Compiler * Print the exception in case of error (Closes: #7) -- Sylvestre Ledru Mon, 25 Feb 2008 14:50:01 +0100 giws (0.9.9) * Basic example added (same as the website) * Split generated files per object by default (-s/--split-per-object replaced by -p/--per-package) and examples updated * Developer documentation -- Sylvestre Ledru Thu, 20 Dec 2007 17:56:15 +0100 giws (0.9.8) * when java.lang.String is loaded, store it as a global variable * Do not try to load the default description file * Produce the help when no option provided -- Sylvestre Ledru Tue, 18 Dec 2007 14:50:02 +0100 giws (0.9.7) * Cast boolean when used (closes #3) * Warnings removed * Examples extended to show boolean management * Compilation error with gcc-4.3 * Search only once for all the class java.lang.String (closes #2) -- Sylvestre Ledru Mon, 17 Dec 2007 11:07:08 +0100 giws (0.9.6) * Bug fix for String[] return value type -- Vincent Couvert Fri, 7 Dec 2008 08:38:50 +0200 giws (0.9.5) [ Vincent Couvert ] * Manages static methods [ Sylvestre Ledru ] * datatypes/charDataGiws.py / datatypes/booleanDataGiws.py / datatypes/byteDataGiws.py have been factorized too * cleaning of the code * bug in getMethodId causes by the static methodes call stuff * BUG list updated -- Sylvestre Ledru Tue, 22 Nov 2007 22:13:50 +0200 giws (0.9.4) * Manages array of String when it is used in input * Example 2 updated to show this change * On Vincent Couvert request, #define added around the namespace/class declaration in order to avoid multiple declarations -- Sylvestre Ledru Tue, 13 Nov 2007 11:22:45 +0100 giws (0.9.3) * Current time removed in the header (force the commit everytime) * Spelling mistake in an error message -- Sylvestre Ledru Mon, 8 Oct 2007 11:35:17 +0200 giws (0.9.2) * License is also added in the header file * In the generated files, information are provided about the generator (version of GIWS and current date/time) -- Sylvestre Ledru Thu, 4 Oct 2007 10:56:17 +0200 giws (0.9.1) * Just a detail with string in order to facilitate the localisation -- Sylvestre Ledru Mon, 1 Oct 2007 18:06:17 +0200 giws (0.9) * License CECILL (GPL compatible) added (thanks to Oliver Mehani for the few advices) * License information added in all files * All the previous versions of GIWS are under the same license (CECILL) * Readme files for the examples -- Sylvestre Ledru Wed, 26 Sep 2007 11:53:22 +0200 giws (0.8) * Factorisation of some code in getCallMethod * Use CallObjectMethod instead of Call(type)Method when dealing with an array of primitive types (J-B Silvy idea) -- Sylvestre Ledru Tue, 25 Sep 2007 10:23:51 +0200 giws (0.7) * Factorisation of some code in getNativeType * Better return of an array of primitive type (one more time, thanks Jean-Baptiste Silvy) * Comestic in example1 -- Sylvestre Ledru Mon, 24 Sep 2007 17:50:51 +0200 giws (0.6) * Manages array of primitive type in return of a method (ex : int[] giveMeMyInts()) * factorisation of some code in getJavaTypeSyntax and getJavaShortType * Use JNI_VERSION_1_4 instead of JNI_VERSION_1_6 in the examples * TODO and README-DEV updated * example2 updated with a return of primitive type -- Sylvestre Ledru Fri, 20 Sep 2007 13:21:55 +0200 giws (0.5) * New constructor from an existing jobject -- Vincent Couvert Tue, 18 Sep 2007 09:40:50 +0200 giws (0.4) * check if exceptions after calling a method * Bug when the input parameter was a String (thanks Jean-Baptiste Silvy) * Update of the example1 * Better management of the Preprocessing * Manages array of string (as parameter and return type) and all other datatypes as parameter (and soon return) -- Sylvestre Ledru Thu, 19 Aug 2007 10:20:15 +0200 giws (0.3) * works on a JavaVM type instead of a JNIEnv * creator with jobject commented (why did I do that ?) * methods with JNIEnv in the profile removed * Caching system for the methodID(s) and the instance * Thread tolerant * Destructor of the object added * Two methods added to synchronize : * synchronize() Enter monitor associated with the object. * endSynchronize() Exit monitor associated with the object. -- Sylvestre Ledru Thu, 1 Aug 2007 11:45:45 +0200 giws (0.2) * Example added (see examples/example1/) * Code rewrote when the method returns a String object * Add the licence into the generated code * Check of files and directories * Change of the default extension (.cxx => .cpp) * New constructor added when we want to load an already existing jobject * Two options added --header-extension-file and --body-extension-file to specify extensions * Add much more tests/feedback when we are loading the object * Exit with an error message when a call of method fails * Manages the case where there is no parameter * Check added when calling the method * Licence file added (CECILL) * Removes french comment in the generated code -- Sylvestre Ledru Thu, 19 Jul 2007 15:45:45 +0200 giws (0.1) * Initial release -- Sylvestre Ledru Wed, 18 Jul 2007 15:45:45 +0200 giws-2.0.2/COPYING000066400000000000000000000511501224063444700135270ustar00rootroot00000000000000CeCILL FREE SOFTWARE LICENSE AGREEMENT Notice This Agreement is a Free Software license agreement that is the result of discussions between its authors in order to ensure compliance with the two main principles guiding its drafting: * firstly, compliance with the principles governing the distribution of Free Software: access to source code, broad rights granted to users, * secondly, the election of a governing law, French law, with which it is conformant, both as regards the law of torts and intellectual property law, and the protection that it offers to both authors and holders of the economic rights over software. The authors of the CeCILL (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) license are: Commissariat à l'Energie Atomique - CEA, a public scientific, technical and industrial research establishment, having its principal place of business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France. Centre National de la Recherche Scientifique - CNRS, a public scientific and technological establishment, having its principal place of business at 3 rue Michel-Ange, 75794 Paris cedex 16, France. Institut National de Recherche en Informatique et en Automatique - INRIA, a public scientific and technological establishment, having its principal place of business at Domaine de Voluceau, Rocquencourt, BP 105, 78153 Le Chesnay cedex, France. Preamble The purpose of this Free Software license agreement is to grant users the right to modify and redistribute the software governed by this license within the framework of an open source distribution model. The exercising of these rights is conditional upon certain obligations for users so as to preserve this status for all subsequent redistributions. In consideration of access to the source code and the rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors only have limited liability. In this respect, the risks associated with loading, using, modifying and/or developing or reproducing the software by the user are brought to the user's attention, given its Free Software status, which may make it complicated to use, with the result that its use is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the suitability of the software as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions of security. This Agreement may be freely reproduced and published, provided it is not altered, and that no provisions are either added or removed herefrom. This Agreement may apply to any or all software for which the holder of the economic rights decides to submit the use thereof to its provisions. Article 1 - DEFINITIONS For the purpose of this Agreement, when the following expressions commence with a capital letter, they shall have the following meaning: Agreement: means this license agreement, and its possible subsequent versions and annexes. Software: means the software in its Object Code and/or Source Code form and, where applicable, its documentation, "as is" when the Licensee accepts the Agreement. Initial Software: means the Software in its Source Code and possibly its Object Code form and, where applicable, its documentation, "as is" when it is first distributed under the terms and conditions of the Agreement. Modified Software: means the Software modified by at least one Contribution. Source Code: means all the Software's instructions and program lines to which access is required so as to modify the Software. Object Code: means the binary files originating from the compilation of the Source Code. Holder: means the holder(s) of the economic rights over the Initial Software. Licensee: means the Software user(s) having accepted the Agreement. Contributor: means a Licensee having made at least one Contribution. Licensor: means the Holder, or any other individual or legal entity, who distributes the Software under the Agreement. Contribution: means any or all modifications, corrections, translations, adaptations and/or new functions integrated into the Software by any or all Contributors, as well as any or all Internal Modules. Module: means a set of sources files including their documentation that enables supplementary functions or services in addition to those offered by the Software. External Module: means any or all Modules, not derived from the Software, so that this Module and the Software run in separate address spaces, with one calling the other when they are run. Internal Module: means any or all Module, connected to the Software so that they both execute in the same address space. GNU GPL: means the GNU General Public License version 2 or any subsequent version, as published by the Free Software Foundation Inc. Parties: mean both the Licensee and the Licensor. These expressions may be used both in singular and plural form. Article 2 - PURPOSE The purpose of the Agreement is the grant by the Licensor to the Licensee of a non-exclusive, transferable and worldwide license for the Software as set forth in Article 5 hereinafter for the whole term of the protection granted by the rights over said Software. Article 3 - ACCEPTANCE 3.1 The Licensee shall be deemed as having accepted the terms and conditions of this Agreement upon the occurrence of the first of the following events: * (i) loading the Software by any or all means, notably, by downloading from a remote server, or by loading from a physical medium; * (ii) the first time the Licensee exercises any of the rights granted hereunder. 3.2 One copy of the Agreement, containing a notice relating to the characteristics of the Software, to the limited warranty, and to the fact that its use is restricted to experienced users has been provided to the Licensee prior to its acceptance as set forth in Article 3.1 hereinabove, and the Licensee hereby acknowledges that it has read and understood it. Article 4 - EFFECTIVE DATE AND TERM 4.1 EFFECTIVE DATE The Agreement shall become effective on the date when it is accepted by the Licensee as set forth in Article 3.1. 4.2 TERM The Agreement shall remain in force for the entire legal term of protection of the economic rights over the Software. Article 5 - SCOPE OF RIGHTS GRANTED The Licensor hereby grants to the Licensee, who accepts, the following rights over the Software for any or all use, and for the term of the Agreement, on the basis of the terms and conditions set forth hereinafter. Besides, if the Licensor owns or comes to own one or more patents protecting all or part of the functions of the Software or of its components, the Licensor undertakes not to enforce the rights granted by these patents against successive Licensees using, exploiting or modifying the Software. If these patents are transferred, the Licensor undertakes to have the transferees subscribe to the obligations set forth in this paragraph. 5.1 RIGHT OF USE The Licensee is authorized to use the Software, without any limitation as to its fields of application, with it being hereinafter specified that this comprises: 1. permanent or temporary reproduction of all or part of the Software by any or all means and in any or all form. 2. loading, displaying, running, or storing the Software on any or all medium. 3. entitlement to observe, study or test its operation so as to determine the ideas and principles behind any or all constituent elements of said Software. This shall apply when the Licensee carries out any or all loading, displaying, running, transmission or storage operation as regards the Software, that it is entitled to carry out hereunder. 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS The right to make Contributions includes the right to translate, adapt, arrange, or make any or all modifications to the Software, and the right to reproduce the resulting software. The Licensee is authorized to make any or all Contributions to the Software provided that it includes an explicit notice that it is the author of said Contribution and indicates the date of the creation thereof. 5.3 RIGHT OF DISTRIBUTION In particular, the right of distribution includes the right to publish, transmit and communicate the Software to the general public on any or all medium, and by any or all means, and the right to market, either in consideration of a fee, or free of charge, one or more copies of the Software by any means. The Licensee is further authorized to distribute copies of the modified or unmodified Software to third parties according to the terms and conditions set forth hereinafter. 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION The Licensee is authorized to distribute true copies of the Software in Source Code or Object Code form, provided that said distribution complies with all the provisions of the Agreement and is accompanied by: 1. a copy of the Agreement, 2. a notice relating to the limitation of both the Licensor's warranty and liability as set forth in Articles 8 and 9, and that, in the event that only the Object Code of the Software is redistributed, the Licensee allows future Licensees unhindered access to the full Source Code of the Software by indicating how to access it, it being understood that the additional cost of acquiring the Source Code shall not exceed the cost of transferring the data. 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE When the Licensee makes a Contribution to the Software, the terms and conditions for the distribution of the resulting Modified Software become subject to all the provisions of this Agreement. The Licensee is authorized to distribute the Modified Software, in source code or object code form, provided that said distribution complies with all the provisions of the Agreement and is accompanied by: 1. a copy of the Agreement, 2. a notice relating to the limitation of both the Licensor's warranty and liability as set forth in Articles 8 and 9, and that, in the event that only the object code of the Modified Software is redistributed, the Licensee allows future Licensees unhindered access to the full source code of the Modified Software by indicating how to access it, it being understood that the additional cost of acquiring the source code shall not exceed the cost of transferring the data. 5.3.3 DISTRIBUTION OF EXTERNAL MODULES When the Licensee has developed an External Module, the terms and conditions of this Agreement do not apply to said External Module, that may be distributed under a separate license agreement. 5.3.4 COMPATIBILITY WITH THE GNU GPL The Licensee can include a code that is subject to the provisions of one of the versions of the GNU GPL in the Modified or unmodified Software, and distribute that entire code under the terms of the same version of the GNU GPL. The Licensee can include the Modified or unmodified Software in a code that is subject to the provisions of one of the versions of the GNU GPL, and distribute that entire code under the terms of the same version of the GNU GPL. Article 6 - INTELLECTUAL PROPERTY 6.1 OVER THE INITIAL SOFTWARE The Holder owns the economic rights over the Initial Software. Any or all use of the Initial Software is subject to compliance with the terms and conditions under which the Holder has elected to distribute its work and no one shall be entitled to modify the terms and conditions for the distribution of said Initial Software. The Holder undertakes that the Initial Software will remain ruled at least by this Agreement, for the duration set forth in Article 4.2. 6.2 OVER THE CONTRIBUTIONS The Licensee who develops a Contribution is the owner of the intellectual property rights over this Contribution as defined by applicable law. 6.3 OVER THE EXTERNAL MODULES The Licensee who develops an External Module is the owner of the intellectual property rights over this External Module as defined by applicable law and is free to choose the type of agreement that shall govern its distribution. 6.4 JOINT PROVISIONS The Licensee expressly undertakes: 1. not to remove, or modify, in any manner, the intellectual property notices attached to the Software; 2. to reproduce said notices, in an identical manner, in the copies of the Software modified or not. The Licensee undertakes not to directly or indirectly infringe the intellectual property rights of the Holder and/or Contributors on the Software and to take, where applicable, vis-à-vis its staff, any and all measures required to ensure respect of said intellectual property rights of the Holder and/or Contributors. Article 7 - RELATED SERVICES 7.1 Under no circumstances shall the Agreement oblige the Licensor to provide technical assistance or maintenance services for the Software. However, the Licensor is entitled to offer this type of services. The terms and conditions of such technical assistance, and/or such maintenance, shall be set forth in a separate instrument. Only the Licensor offering said maintenance and/or technical assistance services shall incur liability therefor. 7.2 Similarly, any Licensor is entitled to offer to its licensees, under its sole responsibility, a warranty, that shall only be binding upon itself, for the redistribution of the Software and/or the Modified Software, under terms and conditions that it is free to decide. Said warranty, and the financial terms and conditions of its application, shall be subject of a separate instrument executed between the Licensor and the Licensee. Article 8 - LIABILITY 8.1 Subject to the provisions of Article 8.2, the Licensee shall be entitled to claim compensation for any direct loss it may have suffered from the Software as a result of a fault on the part of the relevant Licensor, subject to providing evidence thereof. 8.2 The Licensor's liability is limited to the commitments made under this Agreement and shall not be incurred as a result of in particular: (i) loss due the Licensee's total or partial failure to fulfill its obligations, (ii) direct or consequential loss that is suffered by the Licensee due to the use or performance of the Software, and (iii) more generally, any consequential loss. In particular the Parties expressly agree that any or all pecuniary or business loss (i.e. loss of data, loss of profits, operating loss, loss of customers or orders, opportunity cost, any disturbance to business activities) or any or all legal proceedings instituted against the Licensee by a third party, shall constitute consequential loss and shall not provide entitlement to any or all compensation from the Licensor. Article 9 - WARRANTY 9.1 The Licensee acknowledges that the scientific and technical state-of-the-art when the Software was distributed did not enable all possible uses to be tested and verified, nor for the presence of possible defects to be detected. In this respect, the Licensee's attention has been drawn to the risks associated with loading, using, modifying and/or developing and reproducing the Software which are reserved for experienced users. The Licensee shall be responsible for verifying, by any or all means, the suitability of the product for its requirements, its good working order, and for ensuring that it shall not cause damage to either persons or properties. 9.2 The Licensor hereby represents, in good faith, that it is entitled to grant all the rights over the Software (including in particular the rights set forth in Article 5). 9.3 The Licensee acknowledges that the Software is supplied "as is" by the Licensor without any other express or tacit warranty, other than that provided for in Article 9.2 and, in particular, without any warranty as to its commercial value, its secured, safe, innovative or relevant nature. Specifically, the Licensor does not warrant that the Software is free from any error, that it will operate without interruption, that it will be compatible with the Licensee's own equipment and software configuration, nor that it will meet the Licensee's requirements. 9.4 The Licensor does not either expressly or tacitly warrant that the Software does not infringe any third party intellectual property right relating to a patent, software or any other property right. Therefore, the Licensor disclaims any and all liability towards the Licensee arising out of any or all proceedings for infringement that may be instituted in respect of the use, modification and redistribution of the Software. Nevertheless, should such proceedings be instituted against the Licensee, the Licensor shall provide it with technical and legal assistance for its defense. Such technical and legal assistance shall be decided on a case-by-case basis between the relevant Licensor and the Licensee pursuant to a memorandum of understanding. The Licensor disclaims any and all liability as regards the Licensee's use of the name of the Software. No warranty is given as regards the existence of prior rights over the name of the Software or as regards the existence of a trademark. Article 10 - TERMINATION 10.1 In the event of a breach by the Licensee of its obligations hereunder, the Licensor may automatically terminate this Agreement thirty (30) days after notice has been sent to the Licensee and has remained ineffective. 10.2 A Licensee whose Agreement is terminated shall no longer be authorized to use, modify or distribute the Software. However, any licenses that it may have granted prior to termination of the Agreement shall remain valid subject to their having been granted in compliance with the terms and conditions hereof. Article 11 - MISCELLANEOUS 11.1 EXCUSABLE EVENTS Neither Party shall be liable for any or all delay, or failure to perform the Agreement, that may be attributable to an event of force majeure, an act of God or an outside cause, such as defective functioning or interruptions of the electricity or telecommunications networks, network paralysis following a virus attack, intervention by government authorities, natural disasters, water damage, earthquakes, fire, explosions, strikes and labor unrest, war, etc. 11.2 Any failure by either Party, on one or more occasions, to invoke one or more of the provisions hereof, shall under no circumstances be interpreted as being a waiver by the interested Party of its right to invoke said provision(s) subsequently. 11.3 The Agreement cancels and replaces any or all previous agreements, whether written or oral, between the Parties and having the same purpose, and constitutes the entirety of the agreement between said Parties concerning said purpose. No supplement or modification to the terms and conditions hereof shall be effective as between the Parties unless it is made in writing and signed by their duly authorized representatives. 11.4 In the event that one or more of the provisions hereof were to conflict with a current or future applicable act or legislative text, said act or legislative text shall prevail, and the Parties shall make the necessary amendments so as to comply with said act or legislative text. All other provisions shall remain effective. Similarly, invalidity of a provision of the Agreement, for any reason whatsoever, shall not cause the Agreement as a whole to be invalid. 11.5 LANGUAGE The Agreement is drafted in both French and English and both versions are deemed authentic. Article 12 - NEW VERSIONS OF THE AGREEMENT 12.1 Any person is authorized to duplicate and distribute copies of this Agreement. 12.2 So as to ensure coherence, the wording of this Agreement is protected and may only be modified by the authors of the License, who reserve the right to periodically publish updates or new versions of the Agreement, each with a separate number. These subsequent versions may address new issues encountered by Free Software. 12.3 Any Software distributed under a given version of the Agreement may only be subsequently distributed under the same version of the Agreement or a subsequent version, subject to the provisions of Article 5.3.4. Article 13 - GOVERNING LAW AND JURISDICTION 13.1 The Agreement is governed by French law. The Parties agree to endeavor to seek an amicable solution to any disagreements or disputes that may arise during the performance of the Agreement. 13.2 Failing an amicable solution within two (2) months as from their occurrence, and unless emergency proceedings are necessary, the disagreements or disputes shall be referred to the Paris Courts having jurisdiction, by the more diligent Party. Version 2.0 dated 2006-09-05. giws-2.0.2/CXXException.py000066400000000000000000000432651224063444700153770ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING """ Engine to create the C++/JNI exception files """ from licenseWrapper import licenseWrapper from JNIFrameWork import JNIFrameWork from outputWriter import outputWriter class CXXException: package=None def getDescriptionHeader(self, config): return """/* Generated by GIWS (version %s) */ """%(config.getVersion()) # Header of the Exception file def getCXXHeader(self, config, objectName=""): defineHeader=config.getExceptionFileName() return """%s %s %s#include %s namespace %s { """ % (self.getDescriptionHeader(config), licenseWrapper().getLicense(),JNIFrameWork().getHeader(defineHeader),JNIFrameWork().getDLLExportSyntax(),config.getExceptionFileName()) # Build the whole code of the C++ Exception header def generateCXXHeader(self,config): strCommonEnd=""" } #endif """ strHeader=""" /** * Parent class for exceptions which may occure in JNI code. */ class GIWSEXPORT JniException : public std::exception { /** Error message to display */ std::string m_oErrorMessage; /** Java description of the exception*/ std::string m_oJavaMessage; /** Java stackTrace when the exception occurred */ std::string m_oJavaStackTrace; /** Name of the exception (ie class name).*/ std::string m_oJavaExceptionName; /** The exception itself ... we store as a member otherwise JNI complains about 'WARNING in native method: JNI call made with exception pending' */ jthrowable javaException; public: /** * Each subclass of JniExcpetion should call the super constructor * and the setErrorMessage function to set the message. * @param curEnv java environment where the exception occurred. */ JniException(JNIEnv * curEnv) throw() ; JniException() throw() : exception() { }; virtual ~JniException(void) throw(); /** * @return a description of the exception * @deprecated This function could lead to side effect error. Please use whatStr */ virtual const char * what(void) const throw(); /** * @return a description of the exception */ virtual std::string whatStr(void) const throw(); /** * @return Java description of the exception. */ std::string getJavaDescription(void) const throw(); /** * @return Java stack trace where the exception occurred. */ std::string getJavaStackTrace(void) const throw(); /** * Get the name of the exception (ie its class name). */ std::string getJavaExceptionName(void) const throw(); protected: /** * Set the error message that the exception should print. */ void setErrorMessage(const std::string & errorMessage); /** * Get the message that the exception will print. */ std::string getErrorMessage(void) const; private: /** * @return error message of the exception. */ std::string retrieveExceptionMessage(JNIEnv * curEnv); /** * @return full stack trace when the exception occurred. */ std::string retrieveStackTrace(JNIEnv * curEnv); /** * @return string containing the name of the exception (ie its class name). */ std::string retrieveExceptionName(JNIEnv * curEnv); /** * To be called when all the information about the exceptions have been * retrived. * Remove the exception from the environment. */ void closeException(JNIEnv * curEnv); /** * Convert a Java string (jstring) into a C++ string */ std::string convertJavaString(JNIEnv * curEnv, jstring javaString); }; /** * Exception that should be thrown when allocation of Java resources from C++ * code fails (sur as NewDoubleArray or NewStringUTF). */ class GIWSEXPORT JniBadAllocException : public JniException { public: JniBadAllocException(JNIEnv * curEnv) throw(); virtual ~JniBadAllocException(void) throw(); }; /** * Exception that should be thrown when a call to a Java method * using Jni throw an exception. * If possible, user should try to avoid this sitution because of the loss * of information. */ class GIWSEXPORT JniCallMethodException : public JniException { public: /** * @param curEnv java envirnonment where the exception occurred. */ JniCallMethodException(JNIEnv * curEnv) throw(); virtual ~JniCallMethodException(void) throw(); }; /** * Exception that should be thrown when Jni code could not find a Java class */ class GIWSEXPORT JniClassNotFoundException : public JniException { public: /** * @param className name of the class which haven't been found */ JniClassNotFoundException(JNIEnv * curEnv, const std::string & className) throw(); virtual ~JniClassNotFoundException(void) throw(); }; /** * Exception that should be thrown when Jni code could not find a Java method */ class GIWSEXPORT JniMethodNotFoundException : public JniException { public: /** * @param className name of the method which haven't been found */ JniMethodNotFoundException(JNIEnv * curEnv, const std::string & methodName) throw(); virtual ~JniMethodNotFoundException(void) throw(); }; /** * Exception that should be thrown when a call to a Java method * using Jni throw an exception. * If possible, user should try to avoid this sitution because of the loss * of information. */ class GIWSEXPORT JniObjectCreationException : public JniException { public: /** * @param curEnv java envirnonment where the exception occurred. */ JniObjectCreationException(JNIEnv * curEnv, const std::string & className) throw(); virtual ~JniObjectCreationException(void) throw(); }; /** * Exception that should be thrown when a call to the Java monitor * failed */ class GIWSEXPORT JniMonitorException : public JniException { public: /** * @param curEnv java envirnonment where the exception occurred. */ JniMonitorException(JNIEnv * curEnv, const std::string & className) throw(); virtual ~JniMonitorException(void) throw(); }; """ str="""%s %s %s """ % (self.getCXXHeader(config), strHeader, strCommonEnd) fileName=config.getExceptionFileName()+config.getCPPHeaderExtension() outputWriter().writeIntoFile(config.getOutput(),fileName, str) print "%s generated ..."%fileName # Build the whole code of the C++ Exception Body def generateCXXBody(self,config): strCommon="""%s %s %s namespace %s { """%(self.getDescriptionHeader(config), licenseWrapper().getLicense(),"""#include "%s" """%(config.getExceptionFileName()+config.getCPPHeaderExtension()), config.getExceptionFileName()) strCommonEnd=""" } """ strBody=""" /** * Each subclass of JniExcpetion should call the super constructor * and the setErrorMessage function to set the message. * @param curEnv java envirnonment where the exception occurred. */ JniException::JniException(JNIEnv * curEnv) throw() : exception() { // retrieve information about the exception javaException = curEnv->ExceptionOccurred(); /* Clear the Java Exception to avoid calling it again & again */ curEnv->ExceptionClear(); m_oJavaMessage = this->retrieveExceptionMessage(curEnv); m_oJavaStackTrace = this->retrieveStackTrace(curEnv); m_oJavaExceptionName = this->retrieveExceptionName(curEnv); // by default JniExceptions display teh stack trace setErrorMessage(m_oJavaMessage + "\\n" + m_oJavaStackTrace); curEnv->DeleteLocalRef(javaException); closeException(curEnv); } JniException::~JniException(void) throw() { m_oErrorMessage.clear(); } /** * @return a description of the exception * @deprecated This function could lead to side effect error. Please use whatStr */ const char * JniException::what(void) const throw() { return m_oErrorMessage.c_str(); } /** * @return a description of the exception */ std::string JniException::whatStr(void) const throw() { return m_oErrorMessage; } /** * @return Java description of the exception. */ std::string JniException::getJavaDescription(void) const throw() { return m_oJavaMessage; } /** * @return Java stack trace where the exception occurred. */ std::string JniException::getJavaStackTrace(void) const throw() { return m_oJavaStackTrace; } /** * Get the name of the exception (ie its class name). */ std::string JniException::getJavaExceptionName(void) const throw() { return m_oJavaExceptionName; } /** * Set the error message that the exception should print. */ void JniException::setErrorMessage(const std::string & errorMessage) { m_oErrorMessage = errorMessage; } /** * Get the message that the exception will print. */ std::string JniException::getErrorMessage(void) const { return m_oErrorMessage; } /** * @return error message of the exception. */ std::string JniException::retrieveExceptionMessage(JNIEnv * curEnv) { // return the result of the getLocalizedMessage method // retrieve information from the exception. // get method id jmethodID getLocalizedMessageId = curEnv->GetMethodID(curEnv->GetObjectClass(javaException), "getLocalizedMessage", "()Ljava/lang/String;"); // call getLocalizedMessage jstring description = (jstring) curEnv->CallObjectMethod(javaException, getLocalizedMessageId); if (description == NULL) { return ""; } std::string res = convertJavaString(curEnv, description); // release java resources curEnv->DeleteLocalRef(description); return res; } /** * @return full stack trace when the exception occurred. */ std::string JniException::retrieveStackTrace(JNIEnv * curEnv) { // return the result of the getStackTrace method // retrieve information from the exception. // get method id // getStackTrace returns an array of StackTraceElement jmethodID getStackTraceId = curEnv->GetMethodID(curEnv->GetObjectClass(javaException), "getStackTrace", "()[Ljava/lang/StackTraceElement;"); // call getStackTrace jobjectArray stackTrace = (jobjectArray) curEnv->CallObjectMethod(javaException, getStackTraceId); if (stackTrace == NULL) { return ""; } // get length of the array jsize stackTraceLength = curEnv->GetArrayLength(stackTrace); std::string res = ""; // get toString methodId of StackTraceElement class jclass stackTraceElementClass = curEnv->FindClass("java/lang/StackTraceElement"); jmethodID toStringId = curEnv->GetMethodID(stackTraceElementClass, "toString", "()Ljava/lang/String;"); for (jsize i = 0; i < stackTraceLength; i++) { // add the result of toString method of each element in the result jobject curStackTraceElement = curEnv->GetObjectArrayElement(stackTrace, i); // call to string on the object jstring stackElementString = (jstring) curEnv->CallObjectMethod(curStackTraceElement, toStringId); if (stackElementString == NULL) { curEnv->DeleteLocalRef(stackTraceElementClass); curEnv->DeleteLocalRef(stackTrace); curEnv->DeleteLocalRef(curStackTraceElement); return res; } // add a line to res res += " at " + convertJavaString(curEnv, stackElementString) + "\\n"; curEnv->DeleteLocalRef(curStackTraceElement); curEnv->DeleteLocalRef(stackElementString); } // release java resources curEnv->DeleteLocalRef(stackTraceElementClass); curEnv->DeleteLocalRef(stackTrace); return res; } /** * @return string containing the name of the exception (ie its class name). */ std::string JniException::retrieveExceptionName(JNIEnv * curEnv) { // then get its class jclass exceptionClass = curEnv->GetObjectClass(javaException); // get the Class class // we could also use curEnv->FindClass("Class"); jclass classClass = curEnv->GetObjectClass(exceptionClass); // get the getName method jmethodID getNameId = curEnv->GetMethodID(classClass, "getName", "()Ljava/lang/String;"); // call the getName function jstring javaName = (jstring) curEnv->CallObjectMethod(exceptionClass, getNameId); if (javaName == NULL) { return ""; } std::string res = convertJavaString(curEnv, javaName); // release java resources curEnv->DeleteLocalRef(exceptionClass); curEnv->DeleteLocalRef(classClass); curEnv->DeleteLocalRef(javaName); return res; } /** * To be called when all the information about the exceptions have been * retrived. * Remove the exception from the environment. */ void JniException::closeException(JNIEnv * curEnv) { // remove the exception from the environment // Beware, the exception is no longer reachable curEnv->ExceptionClear(); } /** * Convert a Java string (jstring) into a C++ string */ std::string JniException::convertJavaString(JNIEnv * curEnv, jstring javaString) { // get a pointer on a C string const char * tempString = curEnv->GetStringUTFChars(javaString, 0); // convert the C string into a C++ string std::string res(tempString); // release pointer curEnv->ReleaseStringUTFChars(javaString, tempString); return res; } /** * Exception that should be thrown when allocation of Java resources from C++ * code fails (sur as NewDoubleArray or NewStringUTF). */ JniBadAllocException::JniBadAllocException(JNIEnv * curEnv) throw() : JniException() { std::string message = "Error no more memory."; setErrorMessage(message); } JniBadAllocException::~JniBadAllocException(void) throw() {} /** * Exception that should be thrown when a call to a Java method * using Jni throw an exception. * If possible, user should try to avoid this sitution because of the loss * of information. */ /** * @param curEnv java environment where the exception occurred. */ JniCallMethodException::JniCallMethodException(JNIEnv * curEnv) throw() : JniException(curEnv) { std::string errorMessage = "Exception when calling Java method : "; errorMessage += getJavaDescription() + "\\n" + getJavaStackTrace(); errorMessage += what(); setErrorMessage(errorMessage); } JniCallMethodException::~JniCallMethodException(void) throw() {} /** * @param className name of the class which haven't been found */ JniClassNotFoundException::JniClassNotFoundException(JNIEnv * curEnv, const std::string & className) throw() : JniException(curEnv) { std::string errorMessage = "Could not get the Class " + className + "."; setErrorMessage(errorMessage); } JniClassNotFoundException::~JniClassNotFoundException(void) throw() {} /** * @param className name of the method which haven't been found */ JniMethodNotFoundException::JniMethodNotFoundException(JNIEnv * curEnv, const std::string & methodName) throw() : JniException(curEnv) { std::string errorMessage = "Could not access to the method " + methodName + "."; setErrorMessage(errorMessage); } JniMethodNotFoundException::~JniMethodNotFoundException(void) throw() {} /** * @param curEnv java envirnonment where the exception occurred. */ JniObjectCreationException::JniObjectCreationException(JNIEnv * curEnv, const std::string & className) throw() : JniException(curEnv) { std::string errorMessage = "Could not instantiate the object " + className + "."; setErrorMessage(errorMessage); } JniObjectCreationException::~JniObjectCreationException(void) throw() {} /** * @param curEnv java envirnonment where the exception occurred. */ JniMonitorException::JniMonitorException(JNIEnv * curEnv, const std::string & className) throw() : JniException(curEnv) { std::string errorMessage = "Error in the access (Enter or exit) or a Java env monitor of class " + className + "."; setErrorMessage(errorMessage); } JniMonitorException::~JniMonitorException(void) throw() {} """ str="""%s %s %s """ % (strCommon, strBody, strCommonEnd) fileName=config.getExceptionFileName()+config.getCPPBodyExtension() outputWriter().writeIntoFile(config.getOutput(),fileName, str) print "%s generated ..."%fileName giws-2.0.2/CXXFile.py000066400000000000000000000132751224063444700143160ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from classRepresentation.packageGiws import packageGiws from outputWriter import outputWriter from JNIFrameWork import JNIFrameWork from licenseWrapper import licenseWrapper """ Engine to create the C++ files """ class CXXFile: package=None def __init__(self, package): if isinstance(package,packageGiws): self.package=package else: raise Exception("The type must be a packageGiws object") def getDescriptionHeader(self, config): str="""/* Generated by GIWS (version %s) with command: giws %s */"""%(config.getVersion(), " ".join(config.getFullCommandLine())) return str # Check if we are using the inheritance. Don't need the fakeGiwsDataType class def __isUsingInheritanceFeature(self): for object in self.package.getObjects(): if object.getExtendedClass() != None: return True return False def __getFileNameForObjectDeclaration(self, config, typeFile, object): fileName=object.getName() if typeFile=="header": fileName+=config.getCPPHeaderExtension() else: fileName+=config.getCPPBodyExtension() return fileName def __getFileNameForPackageDeclaration(self, config, typeFile): fileName=self.package.getNameForCXX() if typeFile=="header": fileName+=config.getCPPHeaderExtension() else: fileName+=config.getCPPBodyExtension() return fileName def getObjectCXX(self, type="header"): i=1 str="" for object in self.package.getObjects(): if type=="header": str=str+object.generateCXXHeader(self.package.getNameForJNI()) else: str=str+object.generateCXXBody() if len(self.package.getObjects())!=i: str+=""" """ i=i+1 return str def getCXXHeader(self, config, objectName=""): if config.getSplitPerObject()==True: # Split per object ... Then, the define is different for each header defineHeader=self.package.getNameForCXX()+"_"+objectName else: defineHeader=self.package.getNameForCXX() str="""%s %s %s %s""" % (self.getDescriptionHeader(config), licenseWrapper().getLicense(), JNIFrameWork().getHeader(defineHeader), JNIFrameWork().getDLLExportSyntax()) if self.__isUsingInheritanceFeature()==True: str+=JNIFrameWork().getHeaderInheritance() return str+""" namespace %s { """ % (self.package.getNameForCXX()) def generateCXXHeader(self,config): strCommonEnd=""" } #endif """ str="" if config.getSplitPerObject()==True: for object in self.package.getObjects(): fileName=self.__getFileNameForObjectDeclaration(config, "header",object) str=self.getCXXHeader(config,object.getName())+object.generateCXXHeader(self.package.getNameForJNI())+strCommonEnd outputWriter().writeIntoFile(config.getOutput(), fileName, str) print "%s generated ..."%fileName else: fileName=self.__getFileNameForPackageDeclaration(config, "header") str="""%s %s %s """ % (self.getCXXHeader(config), self.getObjectCXX("header"), strCommonEnd) outputWriter().writeIntoFile(config.getOutput(),fileName, str) print "%s generated ..."%fileName def generateCXXBody(self,config): strCommon="""%s %s namespace %s { """%(self.getDescriptionHeader(config),licenseWrapper().getLicense(), self.package.getNameForCXX()) strCommonEnd=""" } """ str="" if config.getSplitPerObject()==True: for object in self.package.getObjects(): strInclude="""#include "%s" """%(self.__getFileNameForObjectDeclaration(config, "header",object)) fileName=self.__getFileNameForObjectDeclaration(config, "body",object) str=strInclude+strCommon+object.generateCXXBody()+strCommonEnd outputWriter().writeIntoFile(config.getOutput(),fileName, str) print "%s generated ..."%fileName else: strInclude="""#include "%s" """%(self.__getFileNameForPackageDeclaration(config, "header")) fileName=self.__getFileNameForPackageDeclaration(config, "body") str="""%s %s %s %s """ % (strInclude, strCommon, self.getObjectCXX("body"), strCommonEnd) outputWriter().writeIntoFile(config.getOutput(),fileName, str) print "%s generated ..."%fileName giws-2.0.2/JNIFrameWork.py000066400000000000000000000231711224063444700153060ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from types import MethodType from configGiws import configGiws class JNIFrameWork: """ This class provides the JNI code """ __JavaVMVariable="jvm" __JavaVMVariableType="JavaVM" def getHeader(self,namespaceName): strHeader=""" #ifndef __%s__ #define __%s__ #include #include #include #include #include """%(namespaceName.upper(), namespaceName.upper()) # add the include for giws exception if configGiws().getThrowsException() and not namespaceName==configGiws().getExceptionFileName(): strHeader+=""" #include "%s" """%(configGiws().getExceptionFileName()+configGiws().getCPPHeaderExtension()) # Byte support strHeader+=""" #if defined(_MSC_VER) /* Defined anyway with Visual */ #include #else typedef signed char byte; #endif """ return strHeader # For the extends (inheritance) support def getHeaderInheritance(self): strHeader=""" #ifndef FAKEGIWSDATATYPE #define FAKEGIWSDATATYPE namespace fakeGiwsDataType { struct fakeGiwsDataType { }; } #endif """ return strHeader def getJavaVMVariable(self): return self.__JavaVMVariable def getJavaVMVariableType(self): return self.__JavaVMVariableType def getMethodGetCurrentEnv(self,objectName): if configGiws().getThrowsException(): error = """throw %s::JniException(getCurrentEnv());"""%(configGiws().getExceptionFileName()) else: error = """std::cerr << "Could not retrieve the current JVM." << std::endl; exit(EXIT_FAILURE); """ return """ JNIEnv * %s::getCurrentEnv() { JNIEnv * curEnv = NULL; jint res=this->jvm->AttachCurrentThread(reinterpret_cast(&curEnv), NULL); if (res != JNI_OK) { %s } return curEnv; }"""%(objectName, error) def getObjectDestuctor(self,objectName,stringClassSet=False): myStr=""" %s::~%s() { JNIEnv * curEnv = NULL; this->jvm->AttachCurrentThread(reinterpret_cast(&curEnv), NULL); curEnv->DeleteGlobalRef(this->instance); curEnv->DeleteGlobalRef(this->instanceClass); """%(objectName, objectName) if stringClassSet==True: myStr += "curEnv->DeleteGlobalRef(this->stringArrayClass);" myStr+="}" return myStr def getSynchronizeMethod(self,objectName): myStr=""" void %s::synchronize() { if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) { """%(objectName) if configGiws().getThrowsException(): myStr += """throw %s::JniMonitorException(getCurrentEnv(), "%s");"""%(configGiws().getExceptionFileName(),objectName) else: myStr += """std::cerr << "Fail to enter monitor." << std::endl; exit(EXIT_FAILURE); """ return myStr + """ } }""" def getEndSynchronizeMethod(self,objectName): myStr=""" void %s::endSynchronize() { if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) { """%(objectName) if configGiws().getThrowsException(): myStr+="""throw %s::JniMonitorException(getCurrentEnv(), "%s");"""%(configGiws().getExceptionFileName(),objectName) else: myStr+= """ std::cerr << "Fail to exit monitor." << std::endl; exit(EXIT_FAILURE);""" return myStr + """ } }""" # For static methods, we can not call getCurrentEnv() because it is not static def getStaticProfile(self): static = """ JNIEnv * curEnv = NULL; jvm_->AttachCurrentThread(reinterpret_cast(&curEnv), NULL); jclass cls = initClass(curEnv); if ( cls == NULL) { """ # Management of the error if configGiws().getThrowsException(): errorMgnt = """throw %s::JniCallMethodException(curEnv);""" % (configGiws().getExceptionFileName()) else: errorMgnt = """std::cerr << "Could not access to the class " << className() << std::endl; exit(EXIT_FAILURE);""" return static + errorMgnt + """ } """ def getDeleteStaticProfile(self): return "" def getObjectInstanceProfile(self): return """ JNIEnv * curEnv = getCurrentEnv(); """ def getExceptionCheckProfile(self, detachThread, methodReturn=""): if configGiws().getThrowsException(): str="""if (curEnv->ExceptionCheck()) { """ if methodReturn != "": str+="""delete[] %s; """%(methodReturn) str+= """%sthrow %s::JniCallMethodException(curEnv); }"""%(detachThread,configGiws().getExceptionFileName()) return str else: return """if (curEnv->ExceptionCheck()) { curEnv->ExceptionDescribe() ; } """ def getMethodIdProfile(self, method): params="" for parameter in method.getParameters(): if parameter.getType().isArray() and not parameter.getType().isByteBufferBased(): # It is an array params+="[" * parameter.getType().getDimensionArray() params+=parameter.getType().getTypeSignature() methodIdName=method.getUniqueNameOfTheMethod() signatureReturn=method.getReturn().getTypeSignature() if method.getReturn().isArray() and not method.getReturn().isByteBufferBased(): # Returns an array ... signatureReturn="["* method.getReturn().getDimensionArray() + signatureReturn if method.getModifier()=="static": getMethod = "GetStaticMethodID" firstParam = "cls" else: getMethod = "GetMethodID" firstParam = "this->instanceClass" if method.getModifier()=="static": methodCall="static jmethodID" else: methodCall="""if (%s==NULL) { /* Use the cache */ """%methodIdName # Management of the error if configGiws().getThrowsException(): errorMgnt="""%sthrow %s::JniMethodNotFoundException(curEnv, "%s");"""%(method.getDetachThread(),configGiws().getExceptionFileName(),method.getName()) else: errorMgnt="""std::cerr << "Could not access to the method " << "%s" << std::endl; curEnv->ExceptionDescribe(); %s exit(EXIT_FAILURE);"""%(method.getName(),method.getDetachThread()) methodIdProfile=""" %s %s = curEnv->%s(%s, "%s", "(%s)%s" ) ; if (%s == NULL) { %s } """%(methodCall, methodIdName, getMethod, firstParam, method.getName(), params,signatureReturn, methodIdName, errorMgnt) if method.getModifier()!="static": methodIdProfile+="}" # Cached methodId return methodIdProfile def getCallObjectMethodProfile(self, method): parametersTypes=method.getParameters() returnType=method.getReturn() i=1 params="" for parameter in parametersTypes: if i==1: params+="," # in order to manage call without param params+=parameter.getName() if parameter.getType().specificPreProcessing(parameter,method.getDetachThread())!=None: params+="_" # There is a pre-processing, then, we add the _ if len(parametersTypes)!=i: params+=", " i=i+1 if returnType.getNativeType()=="void": # Dealing with a void ... returns="" returnsEnd="" else: typeOfReturn=returnType.getJavaTypeSyntax() returns="""%s res = static_cast<%s>("""%(typeOfReturn, typeOfReturn) returnsEnd=")" if method.getModifier()=="static": return """ %s curEnv->%s(cls, %s %s)%s; """ % (returns, returnType.getCallStaticMethod(), method.getUniqueNameOfTheMethod(), params, returnsEnd) else: return """ %s curEnv->%s( this->instance, %s %s)%s; """ % (returns, returnType.getCallMethod(), method.getUniqueNameOfTheMethod(), params, returnsEnd) def getReturnProfile(self, returnType): return returnType.getReturnSyntax() def getDLLExportSyntax(self): return """ #ifndef GIWSEXPORT # if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(STATIC_LINKED) # define GIWSEXPORT # else # define GIWSEXPORT __declspec(dllexport) # endif # else # if __GNUC__ >= 4 # define GIWSEXPORT __attribute__ ((visibility ("default"))) # else # define GIWSEXPORT # endif # endif #endif """ giws-2.0.2/LICENSE000066400000000000000000000032241224063444700135000ustar00rootroot00000000000000Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING giws-2.0.2/Makefile000066400000000000000000000010241224063444700141270ustar00rootroot00000000000000SHELL = /bin/sh # help message by default all: @echo "make: available targets: examples clean deepclean" @echo " - examples: build examples/ folder" @echo " - clean: clean the examples folder and remove .pyc files" # build examples/ .PHONY: examples examples: $(MAKE) -C examples build # clean examples/ folder clean: cleanpyc cleanexamples # clean examples folder cleanexamples: $(MAKE) -C examples clean # clean .pyc cleanpyc: @echo "Cleaning *.pyc files..." @find . -type f -name "*.pyc" | xargs rm -f giws-2.0.2/README000066400000000000000000000024261224063444700133560ustar00rootroot00000000000000 GIWS **** === Description === GIWS is basically the opposite of SWIG. When SWIG generates wrappers to call C/C++ functions/methods from other languages, GIWS creates wrapper for those who wants to call Java methods from C/C++. GIWS is widely used in Scilab (from version 5.0) to drive the rendering and the GUI. === Documentation === The best way to understand how to use GIWS is to read the examples Code using C++ generated files examples/*/main.cpp XML declaration files: examples/*/*.xml === Usage === ./giws -h to see the help Options : -o / --output-dir= : Where files should be generated -f / --description-file= : Specify the declaration file to use -p / --per-package : Creates a file per package instead of a file per object -e / --throws-exception-on-error: Throws a C++ exception instead of an exit(EXIT_FAILURE) --header-extension-file : Specify the extension of the header file generated [Default : .hxx] --body-extension-file : Specify the extension of the body file generated [Default : .cpp] -v / --version : Displays the version and other information -h / --help : Displays the help === Dependencies === Obviously, as GIWS has been written in Python, it needs the Python interpretor to work. For the XML parsing : python-libxml2 giws-2.0.2/README-DEV000066400000000000000000000021001224063444700137570ustar00rootroot00000000000000 = Objects = * classRepresentation/ Python objects matching the Java declarations are stored. * datatypes/ Python objects matching the datatype (provides the different method, type declaration ...) * configGiws.py Specifies default values * giws Manages arguments, help and version info * licenseWrapper.py Provides the license information for the generated code * parseXMLEngine.py Parse the XML * CXXFile.py Contains the intelligence about the C++ generation * JNIFrameWork.py Contains the intelligence about the JNI code * outputWriter.py The file writer = Steps = GIWS is working in a few step. 1. Load/Parse the XML file 2. Build in the memory the "tree" of * Package * Objects * Methods * Parameters * Return types * Datatypes 3. Generate the C++ header file 4. Generate the call of Java methods from C++ using JNI = Design patterns = The design pattern Factory is used to instanciate the different kind of data that we are managing. This object is called : dataFactoryGiws and can be called as : myFactory=dataFactoryGiws() myData=myFactory.create("int") giws-2.0.2/TODO000066400000000000000000000017751224063444700131740ustar00rootroot00000000000000* Manage not empty constructors * Manage objects * Manage enums * When an error occurs (exception or exist), we should, before "leaving", clean up all the variable (we could store all the current variable in the list to be able to retrieve them quickly) * When returning an array of primitive types, we do : jsize len = curEnv->GetArrayLength(res); jboolean isCopy = JNI_TRUE; jint *resultsArray = curEnv->GetIntArrayElements(res, &isCopy); long * myArray=(long *)malloc(sizeof(long *)*len); for (jsize i = 0; i < len; i++){ myArray[i]=resultsArray[i]; } return myArray; There is probably a much better way to do it * Add the management of: * in scinotes.cpp, this should be catched jmethodID voidscinotesjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "scinotes", "(Ljava/lang/String;)V" ) ; giws-2.0.2/classRepresentation/000077500000000000000000000000001224063444700165225ustar00rootroot00000000000000giws-2.0.2/classRepresentation/__init__.py000066400000000000000000000033221224063444700206330ustar00rootroot00000000000000# Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING giws-2.0.2/classRepresentation/methodGiws.py000066400000000000000000000164341224063444700212160ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from parameterGiws import parameterGiws from JNIFrameWork import JNIFrameWork from datatypes.dataGiws import dataGiws from datatypes.stringDataGiws import stringDataGiws from types import MethodType from configGiws import configGiws class methodGiws: __name="" __returns="" __modifier="" __detachThread="" __parameters=[] def __init__(self, name, returns, detachThread, modifier=None): self.__name=name if isinstance(returns,dataGiws) or isinstance(returns,dataBufferGiws): self.__returns=returns else: raise Exception("The type must be a dataGiws object") self.__parameters=[] if detachThread: self.__detachThread="\njvm_->DetachCurrentThread();\n" self.__modifier=modifier def addParameter(self, parameter): if isinstance(parameter,parameterGiws): self.__parameters.append(parameter) def getName(self): return self.__name def getReturn(self): return self.__returns def getModifier(self): return self.__modifier def getParameters(self): return self.__parameters def getDetachThread(self): return self.__detachThread def getParametersCXX(self): """ Returns the parameters with their types """ i=1 if self.getModifier()=="static": str="JavaVM * jvm_" if len(self.__parameters)!=0: str+=", " else: # In the case where there is no input argument # but return an array of int (or an other type) # needed to lenRow if self.getReturn().isArray() and configGiws().getDisableReturnSize()!=True: str+=", " else: str="" for parameter in self.__parameters: str=str+parameter.generateCXXHeader() if len(self.__parameters)!=i: str+=", " i=i+1 return str def __createMethodBody(self): if self.getModifier()=="static": str=JNIFrameWork().getStaticProfile() else: str=JNIFrameWork().getObjectInstanceProfile() str+=JNIFrameWork().getMethodIdProfile(self) arrayOfStringDeclared=False for parameter in self.__parameters: paramType=parameter.getType() # Only declared once this object if type(paramType) is stringDataGiws and paramType.isArray() and not arrayOfStringDeclared: str+=""" jclass stringArrayClass = curEnv->FindClass("java/lang/String");""" arrayOfStringDeclared=True if paramType.specificPreProcessing(parameter,self.getDetachThread())!=None: str+=paramType.specificPreProcessing(parameter,self.getDetachThread()) # Retrieve the call profile to the java object str+=JNIFrameWork().getCallObjectMethodProfile(self) # add specific post processing stuff if hasattr(self.getReturn(), "specificPostProcessing") and type(self.getReturn().specificPostProcessing) is MethodType: # For this datatype, there is some stuff to do AFTER the method call str+=self.getReturn().specificPostProcessing(self.getDetachThread()) # Delete the stringArrayClass object if used before if arrayOfStringDeclared: str+="""curEnv->DeleteLocalRef(stringArrayClass); """ for parameter in self.__parameters: paramType=parameter.getType() if paramType.isArray(): str+=paramType.specificPostDeleteMemory(parameter) else: if isinstance(paramType,stringDataGiws): str+=paramType.specificPostDeleteMemory(parameter) if self.getModifier()=="static": str+=JNIFrameWork().getDeleteStaticProfile() if hasattr(self.getReturn(), "specificPostProcessing") and type(self.getReturn().specificPostProcessing) is MethodType and (self.getReturn().isArray() or isinstance(self.getReturn(),stringDataGiws)): # Check the exception with a delete to avoid memory leak str+=JNIFrameWork().getExceptionCheckProfile(self.getDetachThread(), self.getReturn().temporaryVariableName) else: str+=JNIFrameWork().getExceptionCheckProfile(self.getDetachThread()) str+=self.getDetachThread() str+=JNIFrameWork().getReturnProfile(self.getReturn()) return str def getUniqueNameOfTheMethod(self): paramStr="" for parameter in self.getParameters(): #Creates a unique string of all the profiles paramStr+=parameter.getType().getJavaTypeSyntax() + "_"*parameter.getType().getDimensionArray() paramStr+=parameter.getType().getRealJavaType().replace(".","_") if parameter.getType().isArray(): # Avoid to have jobjectArray in the profile. Does not show the actual type. Fixes bug #143 paramStr+=parameter.getType().getRealJavaType().replace(".","_") str="""%s%s%sID"""%(self.getReturn().getJavaTypeSyntax() + "_" * self.getReturn().getDimensionArray(), self.getName(), paramStr) return str def generateCXXHeader(self): """ Generates the profile of the method ... for the header """ if self.getModifier()=="static": static="static " else: static="" ret="" if self.getReturn().isArray() and configGiws().getDisableReturnSize()!=True: if len(self.__parameters)!=0: ret+=", " if self.getReturn().getDimensionArray() == 1: ret+="int *lenRow" else: ret+="int *lenRow, int *lenCol" str="""%s%s %s(%s%s); """%(static, self.getReturn().getNativeType(), self.getName(), self.getParametersCXX(),ret) return str def generateCXXBody(self, className): """ Generates the content of the method ... for the body """ baseProfile="""%s %s::%s"""%(self.getReturn().getNativeType(),className, self.getName()) ret="" if self.getReturn().isArray() and configGiws().getDisableReturnSize()!=True: if len(self.__parameters)!=0: ret+=", " if self.getReturn().getDimensionArray() == 1: ret+="int *lenRow" else: ret+="int *lenRow, int *lenCol" str=""" %s (%s%s)"""%(baseProfile,self.getParametersCXX(),ret) str+="""{ %s }"""%(self.__createMethodBody()) return str giws-2.0.2/classRepresentation/objectGiws.py000066400000000000000000000416301224063444700212000ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from methodGiws import methodGiws from JNIFrameWork import JNIFrameWork from datatypes.stringDataGiws import stringDataGiws from configGiws import configGiws class objectGiws: __name="" __methods=[] __stringClassSet=False # Which class it extends __extends=None def __init__(self, name): self.__name=name self.__methods=[] def __init__(self, name, extends): self.__name=name self.__methods=[] self.__extends=extends def addMethod(self, method): if isinstance(method,methodGiws): self.__methods.append(method) def getName(self): return self.__name def getMethods(self): return self.__methods def __getDeclarationOfCachingMethodID(self): ### Init the list of the cache of methodID str="" stringClassSet=False for method in self.__methods: str+="""%s=NULL; """%method.getUniqueNameOfTheMethod() for param in method.getParameters(): ### Avoids to load the class String each time we need it if isinstance(param.getType(),stringDataGiws) and param.getType().isArray()==True and stringClassSet!=True and method.getModifier()!="static": str+=""" jclass localStringArrayClass = curEnv->FindClass("java/lang/String"); stringArrayClass = static_cast(curEnv->NewGlobalRef(localStringArrayClass)); curEnv->DeleteLocalRef(localStringArrayClass); """ stringClassSet=True if self.getExtendedClass()!=None: # Get the father object to work on it. str+=self.getExtendedClass().__getDeclarationOfCachingMethodID() return str def __getConstructorWhichInstanciateTheNewObject(self): """ """ # Management of the error when the class cannot be found if configGiws().getThrowsException(): errorMgntClass=""" throw %s::JniClassNotFoundException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntClass="""std::cerr << "Could not get the Class " << this->className() << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" # Management of the error when the global ref could not be created if configGiws().getThrowsException(): errorMgntCreation="""throw %s::JniObjectCreationException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntCreation="""std::cerr << "Could not create a Global Ref of " << this->className() << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" # Management of the error when it is not possible to retrieve the constructor if configGiws().getThrowsException(): errorMgntConstructor="""throw %s::JniObjectCreationException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntConstructor="""std::cerr << "Could not retrieve the constructor of the class " << this->className() << " with the profile : " << construct << param << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" # Management of the error when it is not possible instantiate the obj if configGiws().getThrowsException(): errorMgntInstantiate="""throw %s::JniObjectCreationException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntInstantiate="""std::cerr << "Could not instantiate the object " << this->className() << " with the constructor : " << construct << param << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" # Management of the error when it is not possible create a global ref if configGiws().getThrowsException(): errorMgntRef="""throw %s::JniObjectCreationException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntRef="""std::cerr << "Could not create a new global ref of " << this->className() << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" ### Init the list of the cache of methodID strMethodID=self.__getDeclarationOfCachingMethodID() constructorProfile="""%s::%s"""%(self.getName(), self.__getConstructorProfileWhichInstanciateTheNewObject()) if self.getExtendedClass()!=None: constructorProfile+=""" : %s(fakeGiwsDataType::fakeGiwsDataType())""" % (self.getExtendedClass().getName()) return """%s { jmethodID constructObject = NULL ; jobject localInstance ; jclass localClass ; const std::string construct=""; const std::string param="()V"; jvm=jvm_; JNIEnv * curEnv = getCurrentEnv(); localClass = curEnv->FindClass( this->className().c_str() ) ; if (localClass == NULL) { %s } this->instanceClass = static_cast(curEnv->NewGlobalRef(localClass)); /* localClass is not needed anymore */ curEnv->DeleteLocalRef(localClass); if (this->instanceClass == NULL) { %s } constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ; if(constructObject == NULL){ %s } localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ; if(localInstance == NULL){ %s } this->instance = curEnv->NewGlobalRef(localInstance) ; if(this->instance == NULL){ %s } /* localInstance not needed anymore */ curEnv->DeleteLocalRef(localInstance); /* Methods ID set to NULL */ %s } """%(constructorProfile, errorMgntClass, errorMgntCreation, errorMgntConstructor, errorMgntInstantiate, errorMgntRef, strMethodID) def __getConstructorWhichUsesAnAlreadyExistingJObject(self): ### Init the list of the cache of methodID strMethodID=self.__getDeclarationOfCachingMethodID() # Management of the error when the instance class could not be created a global ref if configGiws().getThrowsException(): errorMgntRef="""throw %s::JniObjectCreationException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntRef=""" std::cerr << "Could not create a Global Ref of " << this->className() << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" # Management of the error when the instance class could not be created a global ref if configGiws().getThrowsException(): errorMgntNewRef="""throw %s::JniObjectCreationException(curEnv, this->className());"""%(configGiws().getExceptionFileName()) else: errorMgntNewRef=""" std::cerr << "Could not create a new global ref of " << this->className() << std::endl; curEnv->ExceptionDescribe(); exit(EXIT_FAILURE);""" constructorProfile="""%s::%s"""%(self.getName(), self.__getConstructorProfileWhichUsesAnAlreadyExistingJObject()) if self.getExtendedClass()!=None: constructorProfile+=""" : %s(fakeGiwsDataType::fakeGiwsDataType()) """ % (self.getExtendedClass().getName()) return """ %s { jvm=jvm_; JNIEnv * curEnv = getCurrentEnv(); jclass localClass = curEnv->GetObjectClass(JObj); this->instanceClass = static_cast(curEnv->NewGlobalRef(localClass)); curEnv->DeleteLocalRef(localClass); if (this->instanceClass == NULL) { %s } this->instance = curEnv->NewGlobalRef(JObj) ; if(this->instance == NULL){ %s } /* Methods ID set to NULL */ %s } """%(constructorProfile, errorMgntRef, errorMgntNewRef, strMethodID) # Returns the class the current one is extending # Returns None if not existing def getExtendedClass(self): return self.__extends def getConstructorBodyCXX(self): str=self.__getConstructorWhichInstanciateTheNewObject() str+=self.__getConstructorWhichUsesAnAlreadyExistingJObject() return str def __getConstructorProfileWhichInstanciateTheNewObject(self): str="""%s(%s * %s_)"""% (self.getName(), JNIFrameWork().getJavaVMVariableType(), JNIFrameWork().getJavaVMVariable()) # if self.__extends!=None: # str+=""": %s(fakeGiwsDataType::fakeGiwsDataType())"""%(self.__extends) return str def __getConstructorProfileWhichUsesAnAlreadyExistingJObject(self): return """%s(%s * %s_, jobject JObj)"""% (self.getName(), JNIFrameWork().getJavaVMVariableType(), JNIFrameWork().getJavaVMVariable()) def getConstructorWhichUsesAnAlreadyExistingJObjectHeaderCXX(self): return """%s;"""%self.__getConstructorProfileWhichUsesAnAlreadyExistingJObject() def getConstructorWhichInstanciateTheNewObjectHeaderCXX(self): return """%s;"""%self.__getConstructorProfileWhichInstanciateTheNewObject() def __getFakeConstructorForExtendedClasses(self): str="" if self.getExtendedClass()==None: # It is a potential master class, add the fake constructor str+=""" /** * This is a fake constructor to avoid the constructor * chaining when dealing with extended giws classes */ #ifdef FAKEGIWSDATATYPE %s(fakeGiwsDataType::fakeGiwsDataType /* unused */) {} #endif """%(self.getName()) return str def getMethodsProfileForMethodIdCache(self): str="" stringClassSet=False for method in self.__methods: str+="""jmethodID %s; // cache method id """%method.getUniqueNameOfTheMethod() for param in method.getParameters(): ### Avoids to load the class String each time we need it if isinstance(param.getType(),stringDataGiws) and param.getType().isArray()==True and stringClassSet!=True: str+="""jclass stringArrayClass; """ stringClassSet=True self.__stringClassSet=True return str def getProtectedFields(self): str="" if self.getExtendedClass()==None: str+=""" jobject instance; jclass instanceClass; // cache class """ return str def getMethodsCXX(self, type="header"): i=1 str="" for method in self.__methods: if type=="header": str=str+method.generateCXXHeader() else: str=str+method.generateCXXBody(self.getName()) if len(self.__methods)!=i: str+=""" """ i=i+1 return str def generateCXXHeader(self, packageName): JNIObjectName=packageName+"/"+self.getName() if self.getExtendedClass()==None: classProfile="""class GIWSEXPORT %s {""" % (self.getName()) else: classProfile="""class GIWSEXPORT %s : public %s { """ % (self.getName(), self.getExtendedClass().getName()) return """%s private: %s * %s; protected: %s %s // Caching (if any) %s /** * Get the environment matching to the current thread. */ virtual JNIEnv * getCurrentEnv(); public: // Constructor /** * Create a wrapping of the object from a JNIEnv. * It will call the default constructor * @param JEnv_ the Java Env */ %s /** * Create a wrapping of an already existing object from a JNIEnv. * The object must have already been instantiated * @param JEnv_ the Java Env * @param JObj the object */ %s %s // Destructor ~%s(); // Generic method // Synchronization methods /** * Enter monitor associated with the object. * Equivalent of creating a "synchronized(obj)" scope in Java. */ void synchronize(); /** * Exit monitor associated with the object. * Equivalent of ending a "synchronized(obj)" scope. */ void endSynchronize(); // Methods %s /** * Get class name to use for static methods * @return class name to use for static methods */ %s /** * Get class to use for static methods * @return class to use for static methods */ %s }; """ % (classProfile, JNIFrameWork().getJavaVMVariableType(), JNIFrameWork().getJavaVMVariable(), self.getMethodsProfileForMethodIdCache(), self.getProtectedFields(), self.getCacheBuffer(), self.getConstructorWhichInstanciateTheNewObjectHeaderCXX(),self.getConstructorWhichUsesAnAlreadyExistingJObjectHeaderCXX(),self.__getFakeConstructorForExtendedClasses(), self.getName(), self.getMethodsCXX(), self.getClassNameProfile(JNIObjectName), self.getInitClassProfile()) def generateCXXBody(self): return """ // Static declarations (if any) %s // Returns the current env %s // Destructor %s // Constructors %s // Generic methods %s %s // Method(s) %s """ % (self.getStaticVariableDeclaration(), JNIFrameWork().getMethodGetCurrentEnv(self.getName()), JNIFrameWork().getObjectDestuctor(self.getName(),stringClassSet=self.__stringClassSet), self.getConstructorBodyCXX(), JNIFrameWork().getSynchronizeMethod(self.getName()) , JNIFrameWork().getEndSynchronizeMethod(self.getName()), self.getMethodsCXX("body")) def getClassNameProfile(self, JNIObjectName): return """ static const std::string className() { return "%s"; } """ % (JNIObjectName) def getInitClassProfile(self): return """ static jclass initClass(JNIEnv * curEnv) { static jclass cls = 0; if (cls == 0) { jclass _cls = curEnv->FindClass(className().c_str()); if (_cls) { cls = static_cast(curEnv->NewGlobalRef(_cls)); } } return cls; } """ def needCaching(self): for method in self.__methods: for param in method.getParameters(): if param.getType().isByteBufferBased() == True: return True return False def getStaticVariableDeclaration(self): str="" if self.needCaching(): str=""" // Cache of the bytebuffer stuff jclass %s::ByteOrderClass = NULL; jmethodID %s::nativeOrderID = NULL; jobject %s::nativeOrder = NULL; jmethodID %s::orderID = NULL; jclass %s::bbCls = NULL; jmethodID %s::asdbIDByteBuffer = NULL; jmethodID %s::asdbIDCharBuffer = NULL; jmethodID %s::asdbIDDoubleBuffer = NULL; jmethodID %s::asdbIDFloatBuffer = NULL; jmethodID %s::asdbIDIntBuffer = NULL; jmethodID %s::asdbIDLongBuffer = NULL; jmethodID %s::asdbIDShortBuffer = NULL;""" % ( self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName(), self.getName() ) return str def getCacheBuffer(self): str="" if self.needCaching(): str=""" // Cache of the bytebuffer stuff static jclass ByteOrderClass; static jmethodID nativeOrderID; static jobject nativeOrder; static jmethodID orderID; static jclass bbCls; static jmethodID asdbIDByteBuffer; static jmethodID asdbIDCharBuffer; static jmethodID asdbIDDoubleBuffer; static jmethodID asdbIDFloatBuffer; static jmethodID asdbIDIntBuffer; static jmethodID asdbIDLongBuffer; static jmethodID asdbIDShortBuffer; """ return str giws-2.0.2/classRepresentation/packageGiws.py000066400000000000000000000044731224063444700213310ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from objectGiws import objectGiws class packageGiws: __name="" __objects=[] def __init__(self, name): self.__name=name self.__objects=[] def getName(self): return self.__name def getNameForCXX(self): return self.__name.replace('.','_') def getNameForJNI(self): return self.__name.replace('.','/') def getObjects(self): return self.__objects def addObject(self, object): if isinstance(object,objectGiws): self.__objects.append(object) def getObject(self, name): for object in self.__objects: if object.getName() == name: return object return None giws-2.0.2/classRepresentation/parameterGiws.py000066400000000000000000000051161224063444700217110ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from datatypes.dataGiws import dataGiws from datatypes.dataBufferGiws import dataBufferGiws from datatypes.dataFactoryGiws import dataFactoryGiws class parameterGiws(): __name="" __type="" def __init__(self, name, type): myDataFactory=dataFactoryGiws() self.__type=myDataFactory.create(type) self.__name=name def getName(self): return self.__name def getType(self): return self.__type def __str__(self): return """%s %s, """ % (self.getType().getNativeType(), self.getName()) def generateCXXHeader(self): """ Generate the profil of the parameter """ str="""%s %s""" % (self.getType().getNativeTypeWithConst(), self.getName()) if self.getType().isArray(): if self.getType().getDimensionArray() == 1: str+=", int %sSize"%self.getName() else: str+=", int %sSize, int %sSizeCol"%(self.getName(),self.getName()) return str giws-2.0.2/classRepresentation/returnDataGiws.py000066400000000000000000000041271224063444700220430ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from datatypes.dataGiws import dataGiws from datatypes.dataFactoryGiws import dataFactoryGiws class returnDataGiws(dataGiws): __type="" def __init__(self, type): myDataFactory=dataFactoryGiws() self.__type=myDataFactory.create(type) def getType(self): return self.__type def generateCXXHeader(self): return """%s""" % (self.getType().getNativeType()) giws-2.0.2/configGiws.py000066400000000000000000000066641224063444700151570ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING """ Configuration of the Env """ class configGiws: __version="2.0.2" __descriptionFile="" __splitPerObject=True __throwsException=False __generateExceptionClass=False __disableReturnSize=False __output="." # Should be changed elsewhere __headerCPPExtension=".hxx" __bodyCPPExtension=".cpp" __exceptionFileName="GiwsException" def setDescriptionFile(self, desc): self.__descriptionFile=desc def getDescriptionFile(self): return self.__descriptionFile def setSplitPerObject(self, split): self.__splitPerObject=split def setThrowsException(self, excep): configGiws.__throwsException=excep def setDisableReturnSize(self): configGiws.__disableReturnSize=True def setEnableReturnSize(self): configGiws.__disableReturnSize=False def getDisableReturnSize(self): return configGiws.__disableReturnSize def enableGenerateExceptionClass(self): configGiws.__generateExceptionClass=True def generateExceptionClass(self): return configGiws.__generateExceptionClass def setOutput(self, output): self.__output=output def getOutput(self): return self.__output def setCPPHeaderExtension(self, ext): self.__headerCPPExtension=ext def getCPPHeaderExtension(self): return self.__headerCPPExtension def setCPPBodyExtension(self, ext): self.__bodyCPPExtension=ext def getCPPBodyExtension(self): return self.__bodyCPPExtension def getExceptionFileName(self): return self.__exceptionFileName def getSplitPerObject(self): return self.__splitPerObject def getThrowsException(self): return configGiws.__throwsException def getVersion(self): return self.__version def getFullCommandLine(self): return self.__fullCommandLine def setFullCommandLine(self, cmd): self.__fullCommandLine = cmd giws-2.0.2/datatypes/000077500000000000000000000000001224063444700144705ustar00rootroot00000000000000giws-2.0.2/datatypes/ByteBufferDataGiws.py000066400000000000000000000043051224063444700205250ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class ByteBufferDataGiws(dataBufferGiws): __isArray=True nativeType="byte" def getTypeSignature(self): return "Ljava/nio/ByteBuffer;" def getJavaTypeSyntax(self): return "jobject" def getRealJavaType(self): return "java.lang.ByteBuffer" def getDescription(self): return "Java ByteBuffer" def getJavaBufferType(self): return "ByteBuffer" giws-2.0.2/datatypes/CharBufferDataGiws.py000066400000000000000000000043051224063444700204770ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class CharBufferDataGiws(dataBufferGiws): __isArray=True nativeType="char" def getTypeSignature(self): return "Ljava/nio/CharBuffer;" def getJavaTypeSyntax(self): return "jobject" def getRealJavaType(self): return "java.lang.CharBuffer" def getDescription(self): return "Java CharBuffer" def getJavaBufferType(self): return "CharBuffer" giws-2.0.2/datatypes/DoubleBufferDataGiws.py000066400000000000000000000042371224063444700210400ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class DoubleBufferDataGiws(dataBufferGiws): __isArray=True nativeType="double" def getTypeSignature(self): return "Ljava/nio/DoubleBuffer;" def getRealJavaType(self): return "java.lang.DoubleBuffer" def getDescription(self): return "Java DoubleBuffer" def getJavaBufferType(self): return "DoubleBuffer" giws-2.0.2/datatypes/FloatBufferDataGiws.py000066400000000000000000000043131224063444700206660ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class FloatBufferDataGiws(dataBufferGiws): __isArray=True nativeType="float" def getTypeSignature(self): return "Ljava/nio/FloatBuffer;" def getJavaTypeSyntax(self): return "jobject" def getRealJavaType(self): return "java.lang.FloatBuffer" def getDescription(self): return "Java FloatBuffer" def getJavaBufferType(self): return "FloatBuffer" giws-2.0.2/datatypes/IntBufferDataGiws.py000066400000000000000000000042771224063444700203640ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class IntBufferDataGiws(dataBufferGiws): __isArray=True nativeType="int" def getTypeSignature(self): return "Ljava/nio/IntBuffer;" def getJavaTypeSyntax(self): return "jobject" def getRealJavaType(self): return "java.lang.IntBuffer" def getDescription(self): return "Java IntBuffer" def getJavaBufferType(self): return "IntBuffer" giws-2.0.2/datatypes/LongBufferDataGiws.py000066400000000000000000000043121224063444700205170ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class LongBufferDataGiws(dataBufferGiws): __isArray=True nativeType="long long" def getTypeSignature(self): return "Ljava/nio/LongBuffer;" def getJavaTypeSyntax(self): return "jobject" def getRealJavaType(self): return "java.lang.LongBuffer" def getDescription(self): return "Java LongBuffer" def getJavaBufferType(self): return "LongBuffer" giws-2.0.2/datatypes/ShortBufferDataGiws.py000066400000000000000000000043131224063444700207200ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataBufferGiws import dataBufferGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class ShortBufferDataGiws(dataBufferGiws): __isArray=True nativeType="short" def getTypeSignature(self): return "Ljava/nio/ShortBuffer;" def getJavaTypeSyntax(self): return "jobject" def getRealJavaType(self): return "java.lang.ShortBuffer" def getDescription(self): return "Java ShortBuffer" def getJavaBufferType(self): return "ShortBuffer" giws-2.0.2/datatypes/__init__.py000066400000000000000000000033221224063444700166010ustar00rootroot00000000000000# Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING giws-2.0.2/datatypes/booleanDataGiws.py000066400000000000000000000121301224063444700201020ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws from JNIFrameWork import JNIFrameWork from configGiws import configGiws # This class is not like other primitive datatypes because we need # to compare variables with JNI_TRUE or JNI_FALSE class booleanDataGiws(dataGiws): type="jboolean" nativeType="bool" callMethod="CallBooleanMethod" callStaticMethod="CallStaticBooleanMethod" def getTypeSignature(self): return "Z" def getRealJavaType(self): return "boolean" def getDescription(self): return "unsigned 8 bits" def specificPreProcessing(self, parameter, detachThread): name=parameter.getName() if self.isArray(): if self.getDimensionArray() == 1: return """ jbooleanArray %s = curEnv->NewBooleanArray( %sSize ) ; curEnv->SetBooleanArrayRegion( %s, 0, %sSize, (jboolean*)%s ) ; """ % (name+"_", name, name+"_", name, name) else: return """ jobjectArray %s_ = curEnv->NewObjectArray(%sSize, curEnv->FindClass("[%s"),NULL); for (int i=0; i<%sSize; i++){ jbooleanArray %sLocal = curEnv->NewBooleanArray( %sSizeCol ) ; curEnv->SetBooleanArrayRegion( %sLocal, 0, %sSizeCol, (jboolean*)(%s[i]) ) ; curEnv->SetObjectArrayElement(%s_, i, %sLocal); curEnv->DeleteLocalRef(%sLocal); } """ % (name, name, self.getTypeSignature(), name, name, name, name, name, name, name, name, name) else: return """ jboolean %s = (static_cast(%s) ? JNI_TRUE : JNI_FALSE); """%(name+"_",name) def specificPostProcessing(self, detachThread): """ needed to avoid casting issue with Visual (myArray[i]=(resultsArray[i] == JNI_TRUE);) """ if self.isArray(): str=JNIFrameWork().getExceptionCheckProfile(detachThread) strCommon="" if configGiws().getDisableReturnSize()==True: strCommon+="int *lenRow;" strCommon+=""" *lenRow = curEnv->GetArrayLength(res); jboolean isCopy = JNI_FALSE; """ if self.getDimensionArray() == 1: return str+strCommon+""" /* faster than getXXXArrayElements */ jboolean *resultsArray = static_cast(curEnv->GetPrimitiveArrayCritical(res, &isCopy)); bool * myArray= new bool[*lenRow]; for (jsize i = 0; i < *lenRow; i++){ myArray[i]=(resultsArray[i] == JNI_TRUE); } curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT); curEnv->DeleteLocalRef(res); """ else: if configGiws().getDisableReturnSize()==True: str+="int *lenCol;" return str+strCommon+""" bool ** myArray = new bool*[*lenRow]; for(int i=0; i<*lenRow; i++) { jbooleanArray oneDim = (jbooleanArray)curEnv->GetObjectArrayElement(res, i); *lenCol=curEnv->GetArrayLength(oneDim); bool *resultsArray = static_cast(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy)); myArray[i] = new bool[*lenCol]; for(int j=0; j<*lenCol; j++) { myArray[i][j]=(resultsArray[j] == JNI_TRUE); } curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT); } curEnv->DeleteLocalRef(res); """ else: return "" def getReturnSyntax(self): """ Avoids warnings about casting a jboolean to a bool """ if self.isArray(): return """ return myArray; """ else: return """ return (res == JNI_TRUE); """ if __name__ == '__main__': print booleanDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/byteDataGiws.py000066400000000000000000000041511224063444700174320ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class byteDataGiws(dataGiws): type="jbyte" nativeType="byte" callMethod="CallByteMethod" callStaticMethod="CallStaticByteMethod" def getTypeSignature(self): return "B" def getRealJavaType(self): return "byte" def getDescription(self): return "signed 8 bits" if __name__ == '__main__': print byteDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/charDataGiws.py000066400000000000000000000041621224063444700174060ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class charDataGiws(dataGiws): type="jchar" nativeType="unsigned short" callMethod="CallCharMethod" callStaticMethod="CallStaticCharMethod" def getTypeSignature(self): return "C" def getRealJavaType(self): return "char" def getDescription(self): return "unsigned 16 bits" if __name__ == '__main__': print charDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/dataBufferGiws.py000066400000000000000000000201431224063444700177370ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class dataBufferGiws(dataGiws): callMethod="CallObjectMethod" callStaticMethod="CallStaticObjectMethod" def isByteBufferBased(self): return True def getJavaTypeSyntax(self): return "jobject" def __errorMemoryByteBuffer(self, detachThread): # Management of the error when not enough memory to create the XXXXXBuffer if configGiws().getThrowsException(): errorMgntMemBis="""%sthrow %s::JniBadAllocException(curEnv);"""%(detachThread,configGiws().getExceptionFileName()) else: errorMgntMemBis="""std::cerr << "Could not convert C %s to Java UTF %s, memory full." << std::endl;%s exit(EXIT_FAILURE);"""%(self.getJavaBufferType(), self.getJavaBufferType(), detachThread) return errorMgntMemBis def specificPreProcessing(self, parameter, detachThread): """ Overrides the preprocessing of the array """ name=parameter.getName() # Management of the error when not enought memory to create the XXXXXBuffer if configGiws().getThrowsException(): errorMgntMem="""%sthrow %s::JniBadAllocException(curEnv);"""%(detachThread,configGiws().getExceptionFileName()) else: errorMgntMem="""std::cerr << "Could not allocate Java %s array, memory full." << std::endl;%s exit(EXIT_FAILURE);"""%(self.getJavaBufferType(), detachThread) errorMgntMemBis = self.__errorMemoryByteBuffer(detachThread) str = """ jobject buffer%s = curEnv->NewDirectByteBuffer((void*)%s, (jlong)%sSize * sizeof(%s)); if (!buffer%s) { throw GiwsException::JniBadAllocException(curEnv); } if (ByteOrderClass == NULL) { ByteOrderClass = static_cast(curEnv->NewGlobalRef(curEnv->FindClass("java/nio/ByteOrder"))); if (ByteOrderClass == NULL) { curEnv->ExceptionDescribe(); } } if (nativeOrderID == NULL) { // public static ByteOrder nativeOrder() nativeOrderID = curEnv->GetStaticMethodID(ByteOrderClass, "nativeOrder", "()Ljava/nio/ByteOrder;"); if (nativeOrderID == NULL) { curEnv->ExceptionDescribe(); } } nativeOrder = curEnv->CallStaticObjectMethod(ByteOrderClass, nativeOrderID, buffer%s); // curEnv->DeleteLocalRef(cls); if (curEnv->ExceptionCheck()) { throw GiwsException::JniCallMethodException(curEnv); } if (bbCls == NULL) { bbCls = static_cast(curEnv->NewGlobalRef(curEnv->FindClass("java/nio/ByteBuffer"))); if (bbCls == NULL) { curEnv->ExceptionDescribe(); } } if (orderID == NULL) { orderID = curEnv->GetMethodID(bbCls, "order", "(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;"); if (orderID == NULL) { curEnv->ExceptionDescribe(); } } buffer%s = curEnv->CallObjectMethod(buffer%s, orderID, nativeOrder); """%(name, name, name, self.nativeType, name, name, name, name) if self.getJavaBufferType() == "ByteBuffer": str=str+""" jobject %s_ = buffer%s; """ % (name, name) return str str=str+""" if (asdbID%s == NULL) { asdbID%s = curEnv->GetMethodID(bbCls, "as%s", "()%s"); if (asdbID%s == NULL) { curEnv->ExceptionDescribe(); } } jobject %s_ = curEnv->CallObjectMethod(buffer%s, asdbID%s); if (%s_ == NULL) { // check that allocation succeed throw GiwsException::JniBadAllocException(curEnv); } """%(self.getJavaBufferType(), self.getJavaBufferType(), self.getJavaBufferType(), self.getTypeSignature(), self.getJavaBufferType(), name, name, self.getJavaBufferType(), name) return str def specificPostProcessing(self, detachThread): """ Called when we are returning a XXXXXBuffer or an array of XXXBuffer TODO """ # We are doing an exception check here JUST in this case because # in methodGiws::__createMethodBody we usually do it at the end # of the method just after deleting the variable # but when dealing with DoubleBuffer, in this method, we are calling some # methods which override the "exception engine" which drive the JNI # engine crazy. TODO check str=JNIFrameWork().getExceptionCheckProfile(detachThread) if self.isArray(): strCommon="" strDeclaration="" if configGiws().getDisableReturnSize()==True: strCommon+="int lenRow;" else: # The size of the array is returned as output argument of the function strDeclaration="*" self.temporaryVariableName="byteBufferRes" if self.getDimensionArray() == 1: str+=strCommon+""" *lenRow = curEnv->GetDirectBufferCapacity(res); %s %s = static_cast<%s>(curEnv->GetDirectBufferAddress(res)); curEnv->DeleteLocalRef(res); curEnv->DeleteLocalRef(cls); if (curEnv->ExceptionCheck()) { curEnv->ExceptionDescribe() ; } """%(self.getNativeType(), self.temporaryVariableName, self.getNativeType()) return str else: if configGiws().getDisableReturnSize()==True: str+="int lenCol;" str+=strCommon+""" TODO voir si on delete ca char ***arrayOfByteBuffer; arrayOfByteBuffer = new char **[%slenRow]; for (jsize i = 0; i < %slenRow; i++){ /* Line of the array */ jobjectArray resByteBufferLine = reinterpret_cast(curEnv->GetObjectArrayElement(res, i)); %slenCol = curEnv->GetArrayLength(resByteBufferLine); arrayOfByteBuffer[i]=new char*[%slenCol]; for (jsize j = 0; j < %slenCol; j++){ jDoubleBuffer resByteBuffer = reinterpret_cast(curEnv->GetObjectArrayElement(resByteBufferLine, j)); const char *tempByteBuffer = curEnv->GetByteBufferUTFChars(resByteBuffer, 0); arrayOfByteBuffer[i][j] = new char[strlen(tempByteBuffer) + 1]; strcpy(arrayOfByteBuffer[i][j], tempByteBuffer); curEnv->ReleaseByteBufferUTFChars(resByteBuffer, tempByteBuffer); curEnv->DeleteLocalRef(resByteBuffer); } curEnv->DeleteLocalRef(resByteBufferLine); } """%(strDeclaration, strDeclaration, strDeclaration, strDeclaration, strDeclaration) return str else: if hasattr(self,"parameterName"): str+="""curEnv->DeleteLocalRef(%s);"""%(self.parameterName+"_") return str+""" const char *tempByteBuffer = curEnv->GetByteBufferUTFChars(res, 0); char * %s = new char[strlen(tempByteBuffer) + 1]; strcpy(%s, tempByteBuffer); curEnv->ReleaseByteBufferUTFChars(res, tempByteBuffer); curEnv->DeleteLocalRef(res); """%(self.temporaryVariableName, self.temporaryVariableName) def getReturnSyntax(self): if self.isArray(): return """ curEnv->DeleteLocalRef(res); return %s; """%(self.temporaryVariableName) else: return """ return %s; """%(self.temporaryVariableName) giws-2.0.2/datatypes/dataFactoryGiws.py000066400000000000000000000111371224063444700201400ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from datatypes.intDataGiws import intDataGiws from datatypes.charDataGiws import charDataGiws from datatypes.longDataGiws import longDataGiws from datatypes.doubleDataGiws import doubleDataGiws from datatypes.booleanDataGiws import booleanDataGiws from datatypes.byteDataGiws import byteDataGiws from datatypes.floatDataGiws import floatDataGiws from datatypes.shortDataGiws import shortDataGiws from datatypes.stringDataGiws import stringDataGiws from datatypes.voidDataGiws import voidDataGiws from datatypes.DoubleBufferDataGiws import DoubleBufferDataGiws from datatypes.LongBufferDataGiws import LongBufferDataGiws from datatypes.ByteBufferDataGiws import ByteBufferDataGiws from datatypes.CharBufferDataGiws import CharBufferDataGiws from datatypes.DoubleBufferDataGiws import DoubleBufferDataGiws from datatypes.FloatBufferDataGiws import FloatBufferDataGiws from datatypes.IntBufferDataGiws import IntBufferDataGiws from datatypes.ShortBufferDataGiws import ShortBufferDataGiws import datatypes import new """ Factory which create the different data types """ class dataFactoryGiws: def __init__(self): self.dict = { "int": intDataGiws, "char": charDataGiws, "long": longDataGiws, "double": doubleDataGiws, "boolean": booleanDataGiws, "byte": byteDataGiws, "float": floatDataGiws, "short": shortDataGiws, "String": stringDataGiws, "void": voidDataGiws, "DoubleBuffer": DoubleBufferDataGiws, "ByteBuffer": ByteBufferDataGiws, "CharBuffer": CharBufferDataGiws, "DoubleBuffer": DoubleBufferDataGiws, "FloatBuffer": FloatBufferDataGiws, "IntBuffer": IntBufferDataGiws, "LongBuffer": LongBufferDataGiws, "ShortBuffer": ShortBufferDataGiws } def create(self, dataTypeToCreate): """ Create an GIWS datatype it can be int, char, long, double, boolean, byte, float, short, String and void if there is a trailing [], this object will consider it as an array of this data """ isArray=False arrayDimension=0 # Scalar if dataTypeToCreate.endswith("[]"): # It is an array isArray=True arrayDimension=dataTypeToCreate.count("[]") # Trim to load the right object dataTypeToCreate=dataTypeToCreate[0:len(dataTypeToCreate)-(arrayDimension*2)] if dataTypeToCreate not in self.dict: raise Exception("Don't know how to manage the data type %s",dataTypeToCreate) myType=self.dict[dataTypeToCreate]() if myType.isByteBufferBased(): arrayDimension=1 # It is a byte buffer type isArray=True myType.setIsArray(isArray) myType.setDimensionArray(arrayDimension) return myType if __name__ == '__main__': myFactory=dataFactoryGiws() myData=myFactory.create("int") myData=myFactory.create("IntBuffer") print myFactory.isByteBufferBased() myData2=myFactory.create("doesnt-exist") print myData.getDescription() giws-2.0.2/datatypes/dataGiws.py000066400000000000000000000232041224063444700166060ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING import sys from configGiws import configGiws from JNIFrameWork import JNIFrameWork def abstractMethod(obj=None): """ Use this instead of 'pass' for the body of abstract methods. """ raise Exception("Unimplemented abstract method: %s" % _functionId(obj, 1)) # # This class intend to create a generic object for datatype # see http://en.wikipedia.org/wiki/Java_Native_Interface#Mapping_types class dataGiws(object): __isArray=False __dimensionArray=0 temporaryVariableName="myArray" """ Interface for the datatype mapping """ def isByteBufferBased(self): return False def getJavaTypeSyntax(self, ForceNotArray=False): """ Returns the Java type syntax of a data with the Array type when applies """ if self.isArray() and not ForceNotArray: if self.getDimensionArray() == 1: return self.type+"Array" else: return "jobjectArray" else: return self.type def getJavaTypeSyntaxForceNotArray(self): """ Return the java type any time""" return self.getJavaTypeSyntax(ForceNotArray=True) def getJavaShortType(self, forceNotArray=False): if forceNotArray: type=self.getJavaTypeSyntaxForceNotArray() else: type=self.getJavaTypeSyntax() # removes the leading j and put the first char uppercase return type[1].upper()+type[2:] def getJavaShortTypeForceNotArray(self): return self.getJavaShortType(forceNotArray=True) def getNativeType(self, ForceNotArray=False, UseConst=False): """ Returns the native type (C/C++) """ if self.isArray() and not ForceNotArray: if UseConst: pointer = " const*" else: pointer = "*" return self.nativeType + pointer * self.__dimensionArray else: return self.nativeType def getNativeTypeForceNotArray(self): return self.getNativeType(ForceNotArray=True) def getNativeTypeWithConst(self): return self.getNativeType(UseConst=True) def getTypeSignature(self): """ Returns the java type signature """ if self.isArray(): return "["+self.__signature else: return self.__signature def getCallMethod(self): """ Returns the JNI method call """ if self.isArray(): return "CallObjectMethod" else: return self.callMethod def getCallStaticMethod(self): """ Returns the JNI static method call """ if self.isArray(): return "CallStaticObjectMethod" else: return self.callStaticMethod def getRealJavaType(self): """ Returns the real datatype """ abstractMethod(self) def getDescription(self): """ Returns the description """ abstractMethod(self) def setIsArray(self, isItAnArray): """ Defines if we have to deal with an array or not """ self.__isArray=isItAnArray def isArray(self): """ return if we have to deal with an array or not """ return self.__isArray def setDimensionArray(self, dimensionArray): """ Defines the size of the array """ self.__dimensionArray=dimensionArray def getDimensionArray(self): """ return the size of the array """ return self.__dimensionArray def __getProfileCreationOfTheArray(self, varName, detachThread): """ When we deal with an array as input, we need to 'transform' it for Java""" javaType=self.getJavaTypeSyntaxForceNotArray() # removes the leading j and put the first char uppercase shortType=self.getJavaShortTypeForceNotArray() if configGiws().getThrowsException(): errorMgnt=""" if (%s_ == NULL) {%s // check that allocation succeed throw %s::JniBadAllocException(curEnv); } """%(varName,detachThread,configGiws().getExceptionFileName()) errorMgntLocal=""" if (%sLocal == NULL) {%s // check that allocation succeed curEnv->DeleteLocalRef(%s_); throw %s::JniBadAllocException(curEnv); } """%(varName, detachThread, varName, configGiws().getExceptionFileName()) else: errorMgnt="" errorMgntLocal="" if self.getDimensionArray() == 1: # Yep, it seems ugly to have that much varName but it is normal. return """ %sArray %s_ = curEnv->New%sArray( %sSize ) ; %s curEnv->Set%sArrayRegion( %s_, 0, %sSize, (%s*)(%s) ) ; """%(javaType, varName, shortType, varName, errorMgnt, shortType, varName, varName, javaType, varName) else: return """ jobjectArray %s_ = curEnv->NewObjectArray(%sSize, curEnv->FindClass("[%s"),NULL); %s for (int i=0; i<%sSize; i++){ %sArray %sLocal = curEnv->New%sArray( %sSizeCol ) ; %s curEnv->Set%sArrayRegion( %sLocal, 0, %sSizeCol, (%s*)(%s[i]) ) ; curEnv->SetObjectArrayElement(%s_, i, %sLocal); curEnv->DeleteLocalRef(%sLocal); } """%(varName, varName, self.getTypeSignature(), errorMgnt, varName, javaType, varName, shortType, varName, errorMgntLocal, shortType, varName, varName, javaType, varName, varName, varName, varName) def specificPreProcessing(self, parameter, detachThread): """ Preprocessing before calling the java method """ if self.isArray(): return self.__getProfileCreationOfTheArray(parameter.getName(), detachThread) else: return None def specificPostDeleteMemory(self, parameter): """ Preprocessing before calling the java method """ return """curEnv->DeleteLocalRef(%s_); """%(parameter.getName()) def specificPostProcessing(self, detachThread): """ Preprocessing after calling the java method """ javaType=self.getJavaTypeSyntax() javaTypeNotArray=self.getJavaTypeSyntaxForceNotArray() shortType=self.getJavaShortType(forceNotArray=True) nativeTypeForceNotArray=self.getNativeTypeForceNotArray() if self.isArray(): str="""if (res == NULL) { return NULL; } """ str+=JNIFrameWork().getExceptionCheckProfile(detachThread) strCommon="" strDeclaration="" if configGiws().getDisableReturnSize()==True: strCommon+="int lenRow;" else: # The size of the array is returned as output argument of the function strDeclaration="*" strCommon+=""" %s lenRow = curEnv->GetArrayLength(res); jboolean isCopy = JNI_FALSE; """%(strDeclaration) if self.getDimensionArray() == 1: str+=strCommon+""" /* GetPrimitiveArrayCritical is faster than getXXXArrayElements */ %s *resultsArray = static_cast<%s *>(curEnv->GetPrimitiveArrayCritical(res, &isCopy)); %s myArray= new %s[%s lenRow]; for (jsize i = 0; i < %s lenRow; i++){ myArray[i]=resultsArray[i]; } curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT); curEnv->DeleteLocalRef(res); """%(javaTypeNotArray, javaTypeNotArray, self.getNativeType(), nativeTypeForceNotArray, strDeclaration, strDeclaration) return str else: if configGiws().getDisableReturnSize()==True: str+="int lenCol;" str+=strCommon+""" %s ** myArray = new %s*[%s lenRow]; for(int i=0; i<%s lenRow; i++) { %sArray oneDim = (%sArray)curEnv->GetObjectArrayElement(res, i); %s lenCol=curEnv->GetArrayLength(oneDim); %s *resultsArray = static_cast<%s *>(curEnv->GetPrimitiveArrayCritical(oneDim, &isCopy)); myArray[i] = new %s[%s lenCol]; for(int j=0; j<%s lenCol; j++) { myArray[i][j]= resultsArray[j]; } curEnv->ReleasePrimitiveArrayCritical(res, resultsArray, JNI_ABORT); } curEnv->DeleteLocalRef(res); """%(self.nativeType, self.nativeType, strDeclaration, strDeclaration, javaTypeNotArray, javaTypeNotArray, strDeclaration, self.nativeType, self.nativeType, nativeTypeForceNotArray, strDeclaration, strDeclaration) return str else: # Not post processing when dealing with primitive types return "" def getReturnSyntax(self): if self.isArray(): return """ return myArray; """ else: return """ return res; """ giws-2.0.2/datatypes/doubleDataGiws.py000066400000000000000000000041131224063444700177370ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class doubleDataGiws(dataGiws): """ Manages Java datatype double """ type="jdouble" nativeType="double" callMethod="CallDoubleMethod" callStaticMethod="CallStaticDoubleMethod" def getTypeSignature(self): return "D" def getRealJavaType(self): return "double" def getDescription(self): return "64 bits" giws-2.0.2/datatypes/floatDataGiws.py000066400000000000000000000041561224063444700176010ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class floatDataGiws(dataGiws): type="jfloat" nativeType="float" callMethod="CallFloatMethod" callStaticMethod="CallStaticFloatMethod" def getTypeSignature(self): return "F" def getRealJavaType(self): return "float" def getDescription(self): return "unsigned 8 bits" if __name__ == '__main__': print floatDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/intDataGiws.py000066400000000000000000000042061224063444700172620ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class intDataGiws(dataGiws): """ Manages Java datatype int """ type="jint" nativeType="int" callMethod="CallIntMethod" callStaticMethod="CallStaticIntMethod" def getTypeSignature(self): return "I" def getRealJavaType(self): return "int" def getDescription(self): return "signed 32 bits" if __name__ == '__main__': print intDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/longDataGiws.py000066400000000000000000000042131224063444700174250ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class longDataGiws(dataGiws): """ Manages Java datatype long """ type="jlong" nativeType="long long" callMethod="CallLongMethod" callStaticMethod="CallStaticLongMethod" def getTypeSignature(self): return "J" def getRealJavaType(self): return "long" def getDescription(self): return "signed 64 bits" if __name__ == '__main__': longDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/shortDataGiws.py000066400000000000000000000041551224063444700176320ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class shortDataGiws(dataGiws): type="jshort" nativeType="short" callMethod="CallShortMethod" callStaticMethod="CallStaticShortMethod" def getTypeSignature(self): return "S" def getRealJavaType(self): return "short" def getDescription(self): return "signed 16 bits" if __name__ == '__main__': print shortDataGiws().getReturnTypeSyntax() giws-2.0.2/datatypes/stringDataGiws.py000066400000000000000000000214331224063444700177770ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws from configGiws import configGiws from JNIFrameWork import JNIFrameWork class stringDataGiws(dataGiws): nativeType="char *" callMethod="CallObjectMethod" callStaticMethod="CallStaticObjectMethod" temporaryVariableName="myStringBuffer" def getTypeSignature(self): return "Ljava/lang/String;" def getJavaTypeSyntax(self): if self.isArray(): return "jobjectArray" else: return "jstring" def getRealJavaType(self): return "java.lang.String" def getDescription(self): return "Java String" def getNativeType(self, ForceNotArray=False, UseConst=False): if self.isArray(): if UseConst: pointer = " const*" else: pointer = "*" return ("char" + pointer) + pointer * self.getDimensionArray() else: if UseConst: pointer = " const*" else: pointer = "*" return "char" + pointer def __errorMemoryString(self, detachThread): # Management of the error when not enought memory to create the string if configGiws().getThrowsException(): errorMgntMemBis="""%sthrow %s::JniBadAllocException(curEnv);"""%(detachThread,configGiws().getExceptionFileName()) else: errorMgntMemBis="""std::cerr << "Could not convert C string to Java UTF string, memory full." << std::endl;%s exit(EXIT_FAILURE);"""%(detachThread) return errorMgntMemBis def specificPreProcessing(self, parameter, detachThread): """ Overrides the preprocessing of the array """ name=parameter.getName() # Management of the error when not enought memory to create the string if configGiws().getThrowsException(): errorMgntMem="""%sthrow %s::JniBadAllocException(curEnv);"""%(detachThread,configGiws().getExceptionFileName()) else: errorMgntMem="""std::cerr << "Could not allocate Java string array, memory full." << std::endl;%s exit(EXIT_FAILURE);"""%(detachThread) errorMgntMemBis = self.__errorMemoryString(detachThread) if self.isArray(): if self.getDimensionArray() == 1: return """ // create java array of strings. jobjectArray %s_ = curEnv->NewObjectArray( %sSize, stringArrayClass, NULL); if (%s_ == NULL) { %s } // convert each char * to java strings and fill the java array. for ( int i = 0; i < %sSize; i++) { jstring TempString = curEnv->NewStringUTF( %s[i] ); if (TempString == NULL) { %s } curEnv->SetObjectArrayElement( %s_, i, TempString); // avoid keeping reference on too many strings curEnv->DeleteLocalRef(TempString); }"""%(name,name,name,errorMgntMem,name,name,errorMgntMemBis,name) else: return """ // create java array of array of strings. jobjectArray %s_ = curEnv->NewObjectArray( %sSize, curEnv->FindClass("[Ljava/lang/String;"), NULL); if (%s_ == NULL) { %s } for ( int i = 0; i < %sSize; i++) { jobjectArray %sLocal = curEnv->NewObjectArray( %sSizeCol, stringArrayClass, NULL); // convert each char * to java strings and fill the java array. for ( int j = 0; j < %sSizeCol; j++) { jstring TempString = curEnv->NewStringUTF( %s[i][j] ); if (TempString == NULL) { %s } curEnv->SetObjectArrayElement( %sLocal, j, TempString); // avoid keeping reference on too many strings curEnv->DeleteLocalRef(TempString); } curEnv->SetObjectArrayElement(%s_, i, %sLocal); curEnv->DeleteLocalRef(%sLocal); }"""%(name,name,name,errorMgntMem,name,name,name,name,name,errorMgntMemBis,name,name,name,name) else: # Need to store is for the post processing (delete) self.parameterName=name tempName=name+"_" return """ jstring %s = curEnv->NewStringUTF( %s ); if (%s != NULL && %s == NULL) { %s } """%(tempName,name,name,tempName,errorMgntMemBis) def specificPostProcessing(self, detachThread): """ Called when we are returning a string or an array of string """ # We are doing an exception check here JUST in this case because # in methodGiws::__createMethodBody we usually do it at the end # of the method just after deleting the variable # but when dealing with string, in this method, we are calling some # methods which override the "exception engine" which drive the JNI # engine crazy. str=JNIFrameWork().getExceptionCheckProfile(detachThread) str=str+"if (res != NULL) { " if self.isArray(): strCommon="" strDeclaration="" if configGiws().getDisableReturnSize()==True: strCommon+="int lenRow;" else: # The size of the array is returned as output argument of the function strDeclaration="*" strCommon+=""" %s lenRow = curEnv->GetArrayLength(res); """%(strDeclaration) self.temporaryVariableName="arrayOfString" if self.getDimensionArray() == 1: str+=strCommon+""" char **arrayOfString; arrayOfString = new char *[%slenRow]; for (jsize i = 0; i < %slenRow; i++){ jstring resString = reinterpret_cast(curEnv->GetObjectArrayElement(res, i)); const char *tempString = curEnv->GetStringUTFChars(resString, 0); arrayOfString[i] = new char[strlen(tempString) + 1]; strcpy(arrayOfString[i], tempString); curEnv->ReleaseStringUTFChars(resString, tempString); curEnv->DeleteLocalRef(resString); } """%(strDeclaration, strDeclaration) return str else: if configGiws().getDisableReturnSize()==True: str+="int lenCol;" str+=strCommon+""" char ***arrayOfString; arrayOfString = new char **[%slenRow]; for (jsize i = 0; i < %slenRow; i++){ /* Line of the array */ jobjectArray resStringLine = reinterpret_cast(curEnv->GetObjectArrayElement(res, i)); %slenCol = curEnv->GetArrayLength(resStringLine); arrayOfString[i]=new char*[%slenCol]; for (jsize j = 0; j < %slenCol; j++){ jstring resString = reinterpret_cast(curEnv->GetObjectArrayElement(resStringLine, j)); const char *tempString = curEnv->GetStringUTFChars(resString, 0); arrayOfString[i][j] = new char[strlen(tempString) + 1]; strcpy(arrayOfString[i][j], tempString); curEnv->ReleaseStringUTFChars(resString, tempString); curEnv->DeleteLocalRef(resString); } curEnv->DeleteLocalRef(resStringLine); } """%(strDeclaration, strDeclaration, strDeclaration, strDeclaration, strDeclaration) return str else: if hasattr(self,"parameterName"): str+="""curEnv->DeleteLocalRef(%s);"""%(self.parameterName+"_") str=str+""" const char *tempString = curEnv->GetStringUTFChars(res, 0); char * %s = new char[strlen(tempString) + 1]; strcpy(%s, tempString); curEnv->ReleaseStringUTFChars(res, tempString); curEnv->DeleteLocalRef(res); """%(self.temporaryVariableName, self.temporaryVariableName) return str def getReturnSyntax(self): str="" if self.isArray(): str = str + """ curEnv->DeleteLocalRef(res); return arrayOfString; """ else: str = str + """ return %s; """%(self.temporaryVariableName) str = str + """ } else { curEnv->DeleteLocalRef(res); return NULL; }""" return str giws-2.0.2/datatypes/voidDataGiws.py000066400000000000000000000043651224063444700174370ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from dataGiws import dataGiws class voidDataGiws(dataGiws): nativeType="void" callMethod="CallVoidMethod" callStaticMethod="CallStaticVoidMethod" temporaryVariableName="myStringBuffer" def getTypeSignature(self): return "V" def getJavaTypeSyntax(self): return "void" def getJavaTypeSyntaxForceNotArray(self): return self.getJavaTypeSyntax() def getDescription(self): return "void type" def getReturnSyntax(self): return "" if __name__ == '__main__': print voidDataGiws().getReturnTypeSyntax() giws-2.0.2/examples/000077500000000000000000000000001224063444700143105ustar00rootroot00000000000000giws-2.0.2/examples/Makefile000066400000000000000000000023751224063444700157570ustar00rootroot00000000000000# Build all examples at once. # You can also build them one by one from here: # % make EX=example2 # # But you can also just enter a directory # read the README and type "make" SHELL = /bin/sh # list of buildable examples EX = basic_example example1 example2 example3 example4 example5 inherit bytebuffer \ bug_no_param_int_array bug_disable_return # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif all: build clean: $(patsubst %,%.clean,$(EX)) # run build and print the help message at the end build: $(patsubst %,%.build,$(EX)) @echo "" @echo "===========================================================================" @echo "Dont forget to set library path before running the example:" @echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/" @echo "or" @echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/amd64:$(JAVA_HOME)/jre/lib/amd64/server/" @echo "===========================================================================" # build selected examples %.build: $(MAKE) -C $(patsubst %.build,%,$@) # clean selected examples %.clean: $(MAKE) -C $(patsubst %.clean,%,$@) clean giws-2.0.2/examples/README000066400000000000000000000005561224063444700151760ustar00rootroot00000000000000GIWS is providing a few examples of use-cases: * basic_example The example detailed in the website * example1 Basic examples with String, primitive types (input and output) * example2 Advanced examples with array of String or primitives types (input and output) * example3 Example with Giws Exception in C++ * example4 Shows how to use array of array in GIWS. giws-2.0.2/examples/basic_example/000077500000000000000000000000001224063444700171045ustar00rootroot00000000000000giws-2.0.2/examples/basic_example/Makefile000066400000000000000000000042401224063444700205440ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p # # GIWS PROJECT INFORMATION # PACKAGE_NAME = basic_example OBJECT_NAME = MyComplexClass BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(OBJECT_NAME).java $(JCC) $(JFLAGS) $< # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/basic_example/MyComplexClass.giws.xml000066400000000000000000000036341224063444700235070ustar00rootroot00000000000000 giws-2.0.2/examples/basic_example/README000066400000000000000000000012471224063444700177700ustar00rootroot00000000000000Here is a simple example of the use of GIWS. Defines where is the JDK # export JAVA_HOME=/path/to/java/ Compile the java file # $JAVA_HOME/bin/javac basic_example/MyComplexClass.java Generate the wrapper # ../../giws -f MyComplexClass.giws.xml -p Where are the JVM native libraries ? (if not using another arch, please update the path) # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client/ Compile the wrapper and the sample program using it # g++ main.cpp basic_example.cpp -g -o myExample -ljvm -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/i386 -L$JAVA_HOME/jre/lib/i386/client/ Try it ! # ./myExample giws-2.0.2/examples/basic_example/basic_example/000077500000000000000000000000001224063444700217005ustar00rootroot00000000000000giws-2.0.2/examples/basic_example/basic_example/MyComplexClass.java000066400000000000000000000036011224063444700254460ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package basic_example; import java.lang.Math; public class MyComplexClass{ public MyComplexClass(){ // the constructor } public long myVeryComplexComputation(double a, double b){ return Math.round(Math.cos(a)+Math.sin(b)*9); } } giws-2.0.2/examples/basic_example/basic_example/UseCase.java000066400000000000000000000035751224063444700241050ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package basic_example; public class UseCase { public static void main(String[] args){ MyComplexClass testOfMyClass = new MyComplexClass(); System.out.println("My Computation : " +testOfMyClass.myVeryComplexComputation(1.2,80)); } } giws-2.0.2/examples/basic_example/main.cpp000066400000000000000000000047361224063444700205460ustar00rootroot00000000000000#include #include "basic_example.hxx" #include /* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace basic_example; using namespace std; int main(){ JavaVM* jvm = create_vm(); MyComplexClass *testOfMyClass = new MyComplexClass(jvm); cout << "My Computation: " << testOfMyClass->myVeryComplexComputation(1.2,80) << endl; return 0; } giws-2.0.2/examples/bug_disable_return/000077500000000000000000000000001224063444700201475ustar00rootroot00000000000000giws-2.0.2/examples/bug_disable_return/Makefile000066400000000000000000000040361224063444700216120ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -r # # GIWS PROJECT INFORMATION # PACKAGE_NAME = Plop OBJECT_NAME = plop BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(BINARY) # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/bug_disable_return/main.cpp000066400000000000000000000046301224063444700216020ustar00rootroot00000000000000#include #include "Plop.hxx" #include /* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace org_plop; using namespace std; int main(){ JavaVM* jvm = create_vm(); Plop *plop = new Plop(jvm); cout << "Does nothing. It is just to test the bug." << endl; return 0; } giws-2.0.2/examples/bug_disable_return/plop.giws.xml000066400000000000000000000002011224063444700226040ustar00rootroot00000000000000 giws-2.0.2/examples/bug_no_param_int_array/000077500000000000000000000000001224063444700210115ustar00rootroot00000000000000giws-2.0.2/examples/bug_no_param_int_array/Makefile000066400000000000000000000040321224063444700224500ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = # # GIWS PROJECT INFORMATION # PACKAGE_NAME = Bar OBJECT_NAME = plop BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(BINARY) # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/bug_no_param_int_array/main.cpp000066400000000000000000000045671224063444700224550ustar00rootroot00000000000000#include #include "Bar.hxx" #include /* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace org_foo; using namespace std; int main(){ JavaVM* jvm = create_vm(); Bar *plop = new Bar(jvm); cout << "Does nothing" << endl; return 0; } giws-2.0.2/examples/bug_no_param_int_array/plop.giws.xml000066400000000000000000000002201224063444700234470ustar00rootroot00000000000000 giws-2.0.2/examples/bytebuffer/000077500000000000000000000000001224063444700164455ustar00rootroot00000000000000giws-2.0.2/examples/bytebuffer/ByteBufferSync.giws.xml000066400000000000000000000047051224063444700230370ustar00rootroot00000000000000 giws-2.0.2/examples/bytebuffer/Makefile000066400000000000000000000043141224063444700201070ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p --throws-exception-on-error -g # # GIWS PROJECT INFORMATION # PACKAGE_NAME = bytebuffer OBJECT_NAME = ByteBufferSync BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(OBJECT_NAME).java $(JCC) $(JFLAGS) $< # build output binary $(BINARY): $(GIWS_OUT_FILES) $(GIWS_CPP_FILE) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/bytebuffer/bytebuffer/000077500000000000000000000000001224063444700206025ustar00rootroot00000000000000giws-2.0.2/examples/bytebuffer/bytebuffer/ByteBufferSync.java000066400000000000000000000020421224063444700243350ustar00rootroot00000000000000package bytebuffer; public class ByteBufferSync { public ByteBufferSync(){ System.out.println("Constructor"); } static public void bar(java.nio.DoubleBuffer aze, java.nio.LongBuffer bze, java.nio.ByteBuffer cze) { System.out.println("Into bar(java.nio.DoubleBuffer, java.nio.LongBuffer)"); System.out.println("The input argument: "+ aze); System.out.println("The second input argument: "+ bze); System.out.println("The third input argument: "+ cze); } public static java.nio.DoubleBuffer myfun() { java.nio.DoubleBuffer buf = java.nio.ByteBuffer.allocateDirect(2 * 8).order(java.nio.ByteOrder.nativeOrder()).asDoubleBuffer(); buf.put(new double[]{3.14159, 2.71828}); return buf; } public static java.nio.LongBuffer myfunLong() { java.nio.LongBuffer buf = java.nio.ByteBuffer.allocateDirect(3 * 8).order(java.nio.ByteOrder.nativeOrder()).asLongBuffer(); long[] array = new long[] {42, 6545555, 787867}; buf.put(array); return buf; } } giws-2.0.2/examples/bytebuffer/main.cpp000066400000000000000000000023101224063444700200710ustar00rootroot00000000000000 #include #include #include "bytebuffer.hxx" #include "GiwsException.hxx" JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace bytebuffer; using namespace std; int main(){ JavaVM* jvm = create_vm(); ByteBufferSync *plop = new ByteBufferSync(jvm); double arr[2]={2.2, 42}; byte arr2[2]={1, 2}; long long arrL[2]={2.2, 42}; plop->bar(jvm, arr, 2, arrL, 2, arr2, 2); int size = 0; double * ret = plop->myfun(jvm, &size); printf("C/C++ display: size=%d, ret[0]=%f, ret[1]=%f\n",size,ret[0],ret[1]); long long * retL = plop->myfunLong(jvm, &size); cout << "C/C++ display: size=" << size << " retL[0]=" << retL[0] << " retL[1]=" << retL[1] << " retL[2]=" << retL[2] << endl; return 0; } giws-2.0.2/examples/example1/000077500000000000000000000000001224063444700160245ustar00rootroot00000000000000giws-2.0.2/examples/example1/Makefile000066400000000000000000000042231224063444700174650ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p # # GIWS PROJECT INFORMATION # PACKAGE_NAME = example OBJECT_NAME = MyObject BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(OBJECT_NAME).java $(JCC) $(JFLAGS) $< # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/example1/MyObject.giws.xml000066400000000000000000000043201224063444700212310ustar00rootroot00000000000000 giws-2.0.2/examples/example1/README000066400000000000000000000012161224063444700167040ustar00rootroot00000000000000Here is a basic example of the use of giws. Defines where is the JDK # export JAVA_HOME=/path/to/java/ Compile the java file # $JAVA_HOME/bin/javac example/MyObject.java Generate the wrapper # ../../giws -f MyObject.giws.xml -p Where are the JVM native libraries ? (if not using another arch, please update the path) # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client/ Compile the wrapper and the sample program using it # g++ main.cpp example.cpp -g -o myExample -ljvm -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/i386 -L$JAVA_HOME/jre/lib/i386/client/ Try it ! # ./myExample giws-2.0.2/examples/example1/example/000077500000000000000000000000001224063444700174575ustar00rootroot00000000000000giws-2.0.2/examples/example1/example/MyObject.java000066400000000000000000000042301224063444700220350ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package example; public class MyObject{ public MyObject(){ System.out.println("Constructor"); } public String getMyString(){ return "I do love Scilab"; } public String getMyStringNull(){ return null; } public void doNothingPleaseButDisplay(int a){ System.out.println("I did display some very interesting things like the int : "+a); } public int giveMeTheHashCodePlease(String a, String b){ return a.hashCode()+b.hashCode(); } public boolean workingWithBoolean(boolean a){ return !a; } } giws-2.0.2/examples/example1/main.cpp000066400000000000000000000055351224063444700174640ustar00rootroot00000000000000#include #include "example.hxx" #include /* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace example; using namespace std; int main(){ JavaVM* jvm = create_vm(); MyObject *plop = new MyObject(jvm); cout << "A string from Java : " << plop->getMyString() <getMyStringNull()==NULL) { cout << "plop->getMyStringNull() returned NULL" << endl; } plop->doNothingPleaseButDisplay(23); cout << "Hashcode of my two strings " << plop->giveMeTheHashCodePlease(const_cast("plop"), const_cast("plop2")) << endl; cout << "Inverse my boolean. True becomes : " << plop->workingWithBoolean(true) << endl << "False becomes : " << plop->workingWithBoolean(false) << endl;; return 0; } giws-2.0.2/examples/example2/000077500000000000000000000000001224063444700160255ustar00rootroot00000000000000giws-2.0.2/examples/example2/Makefile000066400000000000000000000042711224063444700174710ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p --disable-return-size-array # # GIWS PROJECT INFORMATION # PACKAGE_NAME = example2 OBJECT_NAME = MyObjectWithArray BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(OBJECT_NAME).java $(JCC) $(JFLAGS) $< # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/example2/MyObjectWithArray.giws.xml000066400000000000000000000043221224063444700230670ustar00rootroot00000000000000 giws-2.0.2/examples/example2/README000066400000000000000000000012501224063444700167030ustar00rootroot00000000000000Here is a example of the use of giws with Array Defines where is the JDK # export JAVA_HOME=/path/to/java/ Compile the java file # $JAVA_HOME/bin/javac example2/MyObjectWithArray.java Generate the wrapper # ../../giws -f MyObjectWithArray.giws.xml -p Where are the JVM native libraries ? (if not using another arch, please update the path) # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client/ Compile the wrapper and the sample program using it # g++ main.cpp example2.cpp -g -o myExample2 -ljvm -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/i386 -L$JAVA_HOME/jre/lib/i386/client/ Try it ! # ./myExample2 giws-2.0.2/examples/example2/example2/000077500000000000000000000000001224063444700175425ustar00rootroot00000000000000giws-2.0.2/examples/example2/example2/MyObjectWithArray.java000066400000000000000000000054051224063444700237600ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package example2; public class MyObjectWithArray{ public MyObjectWithArray(){ System.out.println("Constructor"); } public String[] getMyString(){ String[] arrayOfString={ "I do love Scilab","Don't you ?" }; return arrayOfString; } public int[] getMyInts(){ int[] arrayOfInt={1,42,2}; return arrayOfInt; } public void doNothingPleaseButDisplay(int[] a, short[] b){ System.out.println("Your first array has a size of "+a.length+" elements and the second " +b.length); for(int i=0; i This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ #include #include "example2.hxx" #include JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace example2; using namespace std; int main(){ int sizeArray=3; JavaVM* jvm = create_vm(); MyObjectWithArray *plop = new MyObjectWithArray(jvm); int myArrayOfLong[sizeArray]; myArrayOfLong[0]=42; myArrayOfLong[1]=69; myArrayOfLong[2]=12; short myArrayOfShort[sizeArray+1]; myArrayOfShort[0]=4; myArrayOfShort[1]=6; myArrayOfShort[2]=1; myArrayOfShort[3]=1; plop->doNothingPleaseButDisplay(myArrayOfLong,sizeArray,myArrayOfShort, sizeArray+1 ); char ** myString=plop->getMyString(); cout << "The first string from Java : " << myString[0] <getMyInts(); cout << "The first int from Java : " << myInts[0] <setMyStrings(myStrings,4); bool arrayOfBool[]={true, false, true, true}; bool *boolReturned = plop->dealingWithBooleans(arrayOfBool, 4); for (int i=0; i < 4; i++){ cout << "Value " << i << " : " << boolReturned[i] << " (was " << arrayOfBool[i] << ")" << endl; } return 0; } giws-2.0.2/examples/example3/000077500000000000000000000000001224063444700160265ustar00rootroot00000000000000giws-2.0.2/examples/example3/Makefile000066400000000000000000000043111224063444700174650ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p --throws-exception-on-error -g # # GIWS PROJECT INFORMATION # PACKAGE_NAME = example3 OBJECT_NAME = MyObjectWhichReturnsExceptions BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(OBJECT_NAME).java $(JCC) $(JFLAGS) $< # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/example3/MyObjectWhichReturnsExceptions.giws.xml000066400000000000000000000036511224063444700256510ustar00rootroot00000000000000 giws-2.0.2/examples/example3/README000066400000000000000000000014651224063444700167140ustar00rootroot00000000000000Here is a example of the use of giws with Array Defines where is the JDK # export JAVA_HOME=/path/to/java/ Compile the java file # $JAVA_HOME/bin/javac example3/MyObjectWhichReturnsExceptions.java Generate the wrapper # ../../giws --throws-exception-on-error -p -f MyObjectWhichReturnsExceptions.giws.xml Note GiwsException.cpp & GiwsException.hxx are also generated here. Where are the JVM native libraries ? (if not using another arch, please update the path) # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client/ Compile the wrapper and the sample program using it # g++ main.cpp GiwsException.cpp example3.cpp -g -o myExample3 -ljvm -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/i386 -L$JAVA_HOME/jre/lib/i386/client/ Try it ! # ./myExample3 giws-2.0.2/examples/example3/example3/000077500000000000000000000000001224063444700175445ustar00rootroot00000000000000giws-2.0.2/examples/example3/example3/MyObjectWhichReturnsExceptions.java000066400000000000000000000011201224063444700265250ustar00rootroot00000000000000package example3; public class MyObjectWhichReturnsExceptions{ public MyObjectWhichReturnsExceptions(){ System.out.println("Constructor"); } public int getIntFromArrayOfSizeThree(int pos){ int[] arrayOfInt={42,12,69}; return arrayOfInt[pos]; } public int thisMethodWillFailWithMessage() throws RuntimeException { throw new RuntimeException("I said that will fail!"); } public static void main(String []args){ MyObjectWhichReturnsExceptions plop = new MyObjectWhichReturnsExceptions(); plop.getIntFromArrayOfSizeThree(23); plop.getIntFromArrayOfSizeThree(1); } } giws-2.0.2/examples/example3/main.cpp000066400000000000000000000071761224063444700174710ustar00rootroot00000000000000/* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ #include #include #include "example3.hxx" #include "GiwsException.hxx" JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace example3; using namespace std; int main(){ int sizeArray=3; JavaVM* jvm = create_vm(); MyObjectWhichReturnsExceptions *plop = new MyObjectWhichReturnsExceptions(jvm); int myInts = plop->getIntFromArrayOfSizeThree(0); cout << "Value from the Java with good pos : " << myInts << endl; cout << "========================" << endl; cout << "Exception catched:" << endl; try { int myIntsWithExceptionCatched = plop->getIntFromArrayOfSizeThree(22); }catch(GiwsException::JniException e) { cout << "getJavaDescription: " << e.getJavaDescription() << endl; cout << "getJavaStackTrace: " << e.getJavaStackTrace() << endl; cout << "getJavaExceptionName: " << e.getJavaExceptionName() << endl; } cout << "========================" << endl; cout << "Exception will be trigger. This will display the message of the exception" << endl; try { int value = plop->thisMethodWillFailWithMessage(); }catch(GiwsException::JniException e) { cout << "getJavaDescription: " << e.getJavaDescription() << endl; cout << "getJavaStackTrace: " << e.getJavaStackTrace() << endl; cout << "getJavaExceptionName: " << e.getJavaExceptionName() << endl; } cout << "========================" << endl; cout << "Exception not catched:" << endl; int myIntsWithException = plop->getIntFromArrayOfSizeThree(223); cout << "Value from the Java with good pos : " << myInts < This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING --> giws-2.0.2/examples/example4/README000066400000000000000000000012501224063444700167050ustar00rootroot00000000000000Here is a example of the use of giws with Array Defines where is the JDK # export JAVA_HOME=/path/to/java/ Compile the java file # $JAVA_HOME/bin/javac example2/MyObjectWithArray.java Generate the wrapper # ../../giws -f MyObjectWithArray.giws.xml -p Where are the JVM native libraries ? (if not using another arch, please update the path) # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client/ Compile the wrapper and the sample program using it # g++ main.cpp example2.cpp -g -o myExample2 -ljvm -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/i386 -L$JAVA_HOME/jre/lib/i386/client/ Try it ! # ./myExample2 giws-2.0.2/examples/example4/example4/000077500000000000000000000000001224063444700175465ustar00rootroot00000000000000giws-2.0.2/examples/example4/example4/MyObjectWithArray.java000066400000000000000000000054331224063444700237650ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package example4; public class MyObjectWithArray{ public MyObjectWithArray(){ System.out.println("Constructor"); } public String[][] getMatrixString(){ String[][] arrayOfString={{ "I do love Scilab","Don't you ?" },{"third","fourth"}}; return arrayOfString; } public boolean[][] getArrayOfBoolean(){ return new boolean[][]{{true,false,true},{false,true,false}}; } public int[][] getMatrixInts(){ int[][] arrayOfInt={{1,42,2},{2,84,4}}; return arrayOfInt; } public void doNothingPleaseButDisplay(int[][] a){ System.out.println("Your first array has a size of ["+a.length+","+a[0].length+"] elements"); for(int i=0; i This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ #include #include "example4.hxx" #include JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace example4; using namespace std; int main(){ int sizeArray=3, sizeArrayCol = 2, i, j; JavaVM* jvm = create_vm(); MyObjectWithArray *plop = new MyObjectWithArray(jvm); int **myArrayOfLong= (int**)malloc(sizeof(int) * sizeArray);//[sizeArray][sizeArrayCol]; for (i = 0; i <= sizeArray; i++) { myArrayOfLong[i]=(int*) malloc(sizeof(int) * sizeArrayCol); myArrayOfLong[i][0]=2*(i+1); myArrayOfLong[i][1]=3*(i+1); } plop->doNothingPleaseButDisplay(myArrayOfLong,sizeArray,sizeArrayCol); int lenRow, lenCol; char *** myString=plop->getMatrixString(&lenRow, &lenCol); cout << "Going to get a String[" << lenRow << "][" << lenCol << "]" << endl; for (i = 0; i < lenRow; i++) { for (j = 0; j < lenCol; j++) { cout << "String from Java [" << i << "," << j << "] : " << myString[i][j] <getMatrixInts(&lenRow, &lenCol); cout << "From Java [0,0] : " << myInts[0][0] <getArrayOfBoolean(&lenRow, &lenCol); cout << "Bool from Java [0,0] : " << myBool[0][0] <displayMatrixOfString(sendToJava,2,2); return 0; } giws-2.0.2/examples/example5/000077500000000000000000000000001224063444700160305ustar00rootroot00000000000000giws-2.0.2/examples/example5/Makefile000066400000000000000000000042241224063444700174720ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p # # GIWS PROJECT INFORMATION # PACKAGE_NAME = example5 OBJECT_NAME = MyObject BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(OBJECT_NAME).java $(JCC) $(JFLAGS) $< # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/$(OBJECT_NAME).class $(BINARY) giws-2.0.2/examples/example5/MyObject.giws.xml000066400000000000000000000035541224063444700212450ustar00rootroot00000000000000 giws-2.0.2/examples/example5/README000066400000000000000000000012471224063444700167140ustar00rootroot00000000000000Here is a example of the detach the current thread from the jvm. Defines where is the JDK # export JAVA_HOME=/path/to/java/ Compile the java file # $JAVA_HOME/bin/javac example5/MyObject.java Generate the wrapper # ../../giws -f MyObject.giws.xml -p Where are the JVM native libraries ? (if not using another arch, please update the path) # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client/ Compile the wrapper and the sample program using it # g++ main.cpp example5.cpp -g -o myExample2 -ljvm -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -L$JAVA_HOME/jre/lib/i386 -L$JAVA_HOME/jre/lib/i386/client/ Try it ! # ./myExample5 giws-2.0.2/examples/example5/example5/000077500000000000000000000000001224063444700175505ustar00rootroot00000000000000giws-2.0.2/examples/example5/example5/MyObject.java000066400000000000000000000034161224063444700221330ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package example5; public class MyObject { public static void doSomething(String str) { System.out.println(str); } } giws-2.0.2/examples/example5/main.cpp000066400000000000000000000045661224063444700174730ustar00rootroot00000000000000/* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ #include #include "example5.hxx" #include JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace example5; using namespace std; int main(){ JavaVM* jvm = create_vm(); MyObject::doSomething(jvm, (char*)"Hello World !!"); return 0; } giws-2.0.2/examples/inherit/000077500000000000000000000000001224063444700157525ustar00rootroot00000000000000giws-2.0.2/examples/inherit/Makefile000066400000000000000000000042061224063444700174140ustar00rootroot00000000000000SHELL = /bin/sh # verify that JAVA_HOME is set to something (should be the bare minimum) ifndef JAVA_HOME $(error ERROR: Variable JAVA_HOME is not set!) endif # # C++ compiler options # CC = g++ CFLAGS = -g INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux LIBS = -ljvm -L$(JAVA_HOME)/jre/lib/i386 -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/i386/client/ -L$(JAVA_HOME)/jre/lib/amd64/server/ # # Java compiler option # JCC = $(JAVA_HOME)/bin/javac JFLAGS = # # GIWS options # GIWS = ../../giws GFLAGS = -p # # GIWS PROJECT INFORMATION # PACKAGE_NAME = inherit OBJECT_NAME = inherit BINARY = main GIWS_CPP_FILE = main.cpp GIWS_DESC_FILE = $(OBJECT_NAME).giws.xml GIWS_OUT_FILES = $(addprefix $(PACKAGE_NAME),.cpp .hxx) # in case of --throws-exception-on-error, add 2 files to the list # of the ones generated by GIWS. ifneq (,$(findstring --throws-exception-on-error,$(GFLAGS))) GIWS_OUT_FILES += GiwsException.cpp GiwsException.hxx endif ######################################################################### ######################################################################### ######################################################################### # look for sources in current folder and in package name VPATH = .:$(PACKAGE_NAME) all: $(OBJECT_NAME).class $(BINARY) # build java class file $(OBJECT_NAME).class: $(JCC) $(JFLAGS) $(PACKAGE_NAME)/*.java # build output binary $(BINARY): $(GIWS_OUT_FILES) $(CC) $(GIWS_CPP_FILE) $(GIWS_OUT_FILES) $(CFLAGS) $(LIBS) $(INCLUDES) -o $(BINARY) @if test $(MAKELEVEL) -eq 0; then \ echo "==========================================================================="; \ echo "Dont forget to set library path before running the program:"; \ echo "# export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(JAVA_HOME)/jre/lib/i386:$(JAVA_HOME)/jre/lib/i386/client/"; \ echo "==========================================================================="; \ fi # run giws to generate cpp code $(GIWS_OUT_FILES): $(GIWS) -f $(GIWS_DESC_FILE) $(GFLAGS) # cleanup giws generated files (cpp/hxx, bin) and .class clean: rm -f $(GIWS_OUT_FILES) $(PACKAGE_NAME)/*.class $(BINARY) giws-2.0.2/examples/inherit/README000066400000000000000000000002151224063444700166300ustar00rootroot00000000000000Here is a example of the use of giws with inheritance Defines where is the JDK # export JAVA_HOME=/path/to/java/ # make Try it ! # ./main giws-2.0.2/examples/inherit/inherit.giws.xml000066400000000000000000000036461224063444700211170ustar00rootroot00000000000000 giws-2.0.2/examples/inherit/inherit/000077500000000000000000000000001224063444700174145ustar00rootroot00000000000000giws-2.0.2/examples/inherit/inherit/Father.java000066400000000000000000000035461224063444700215000ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package inherit; public class Father{ public Father(){ System.out.println("Java Father Constructor"); } public String fatherMethod(){ System.out.println("Father method"); return "in fatherMethod"; } } giws-2.0.2/examples/inherit/inherit/Son.java000066400000000000000000000034771224063444700210310ustar00rootroot00000000000000/* Copyright INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ package inherit; public class Son extends Father{ public Son(){ System.out.println("Java Son Constructor"); } public String sonMethod(){ return "in sonMethod"; } } giws-2.0.2/examples/inherit/main.cpp000066400000000000000000000053641224063444700174120ustar00rootroot00000000000000/* Copyright or © or Copr. INRIA/Scilab - Sylvestre LEDRU # Sylvestre LEDRU - This software is a computer program whose purpose is to generate C++ wrapper for Java objects/methods. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. For more information, see the file COPYING */ #include #include "inherit.hxx" #include JavaVM* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[2]; /* There is a new JNI_VERSION_1_4, but it doesn't add anything for the purposes of our example. */ args.version = JNI_VERSION_1_4; args.nOptions = 2; options[0].optionString = const_cast("-Djava.class.path=."); options[1].optionString = const_cast("-Xcheck:jni"); args.options = options; args.ignoreUnrecognized = JNI_FALSE; JNI_CreateJavaVM(&jvm, (void **)&env, &args); return jvm; } using namespace inherit; using namespace std; int main(){ JavaVM* jvm = create_vm(); // Father *father = new Father(jvm); Son *son = new Son(jvm); cout << "==========" << endl; Father *sonSecond = new Son(jvm); cout << "==========" << endl; cout << "Return of sonMethod: " << son->sonMethod() << endl; cout << "==========" << endl; cout << "Return of fatherMethod from Son: " << son->fatherMethod() << endl; cout << "==========" << endl; cout << "Return of fatherMethod: " << sonSecond->fatherMethod() << endl; return 0; } giws-2.0.2/examples/inherit/showcase.cpp000066400000000000000000000004701224063444700202730ustar00rootroot00000000000000/* This is just a test case to show how it is working with a straight C++ code */ #include using namespace std; class Father { public : Father() { cout << "Father" << endl;} }; class Son : public Father { public: Son() { cout << "Son" << endl;} }; int main(){ Son *son = new Son(); return 0; } giws-2.0.2/giws000077500000000000000000000150651224063444700134000ustar00rootroot00000000000000#!/usr/bin/python -u # # Matthieu WALTER - # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING import sys import getopt import os.path from parseXMLEngine import parseXMLEngine from configGiws import configGiws from CXXFile import CXXFile from CXXException import CXXException class giws: config=configGiws() templateObj = None def __init__(self, argv=sys.argv): self.argv = argv self.config.setFullCommandLine(argv[1:]) try: self.__parse_cmdline() except getopt.GetoptError, e: print "%s: %s"%(e.__class__.__name__, str(e)) self.show_help(1) # exit with EXIT_FAILURE return code """ load configuration from command line parameters """ def __parse_cmdline(self): opts, args = getopt.getopt(self.argv[1:], "f:o:b:gprsehv", ["description-file=","output-dir=","header-extension-file=","body-extension-file=","generate-exception-class","per-package","throws-exception-on-error","disable-return-size-array","enable-return-size-array","help","version"]) # we know at least one options is required (-f file...) if len(opts)==0: raise getopt.GetoptError, "too few options" elif len(args): raise getopt.GetoptError, "too many arguments" for option, value in opts: if option in ("-f", "--description-file"): if os.path.isfile(value): self.config.setDescriptionFile(value) else: print "Deadly error: Cannot find file %s"%value print "" self.show_help(0) elif option in ("-o", "--output-dir"): if os.path.isdir(value): self.config.setOutput(value) else: print "Deadly error: Cannot find output dir %s"%value print "" self.show_help(0) elif option in ("-p", "--per-package"): self.config.setSplitPerObject(False) elif option in ("-e","--throws-exception-on-error"): self.config.setThrowsException(True) elif option in ("-g","--generate-exception-class"): self.config.enableGenerateExceptionClass() elif option in ("-r","--disable-return-size-array"): self.config.setDisableReturnSize() elif option in ("-s","--enable-return-size-array"): self.config.setEnableReturnSize() elif option == '--header-extension-file': self.config.setCPPHeaderExtension(value) elif option == '--body-extension-file': self.config.setCPPBodyExtension(value) elif option in ("-v", "--version"): self.show_version(0) elif option in ("-h", "--help"): self.show_help(0) # check for some mandatory paramters if not self.config.getDescriptionFile() and not self.config.generateExceptionClass(): raise getopt.GetoptError, "You have to specify a description file" if self.config.getDescriptionFile(): templateObj=parseXMLEngine(self.config.getDescriptionFile()) CXX=CXXFile(templateObj.getJpackage()) CXX.generateCXXHeader(self.config) CXX.generateCXXBody(self.config) # this will be changed ... should not be called on the package itself # .generateCXXHeader(self.config) # templateObj.getJpackage().generateCXXBody(self.config) if self.config.generateExceptionClass(): CXXExcep=CXXException() CXXExcep.generateCXXHeader(self.config) CXXExcep.generateCXXBody(self.config) def show_help(self, exit_status=0): print "Giws usage: %s <-f file|--description-file=file> [options]"%self.argv[0] print "" print "Options can be:" print "-f --description-file=file Description of the method of the Java Object" print "-o --output-dir=dir The directory where to export files" print "-p --per-package Generates CXX/HXX files per package" print "-e --throws-exception-on-error Throws a C++ exception instead of an exit(EXIT_FAILURE)" print "-g --generate-exception-class Generate the exception class (disable by default)" print "-r --disable-return-size-array Disable the return of the size of the array/arrays through int*" print "-s --enable-return-size-array Enable the return of the size of the array/arrays through int* (default)" print "--header-extension-file=ext Specify the extension of the header file generated [Default : .hxx]" print "--body-extension-file=ext Specify the extension of the body file generated [Default : .cpp]" print "-v --version Display the version information" print "-h --help Display the help" sys.exit(exit_status) def show_version(self, exit_status=0): print "GIWS %s"%self.config.getVersion() print "Copyright (C) 2007-2012 INRIA / Digiteo / Scilab Enterprises" print """This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL http://www.cecill.info/ . """ print "" print "Written by Sylvestre Ledru " print "with the help of various developers." sys.exit(exit_status) if __name__ == '__main__': giws() giws-2.0.2/licenseWrapper.py000066400000000000000000000064701224063444700160360ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING class licenseWrapper: def getLicense(self): return """/* This is generated code. This software is a computer program whose purpose is to hide the complexity of accessing Java objects/methods from C++ code. This software is governed by the CeCILL-B license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. */ """ giws-2.0.2/outputWriter.py000066400000000000000000000037421224063444700156070ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING """ The engine which will write files """ class outputWriter: def stripTab(self, text): return text.replace("\t","") def writeIntoFile(self, directory, fileName, content): f=open(directory+"/"+fileName, 'w') f.write(self.stripTab(content)) f.close() giws-2.0.2/parseXMLEngine.py000066400000000000000000000127601224063444700156730ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING import sys, pprint import libxml2 import os.path from classRepresentation.packageGiws import packageGiws from classRepresentation.objectGiws import objectGiws from classRepresentation.methodGiws import methodGiws from classRepresentation.parameterGiws import parameterGiws from classRepresentation.returnDataGiws import returnDataGiws from datatypes.dataFactoryGiws import dataFactoryGiws libxml2.debugMemory(1) class parseXMLEngine: __ctxt=None Jpackage=None def __init__(self, descFile): if os.path.isfile(descFile)!=True: print ('Could not find declaration file "%s"'%descFile) sys.exit(-2) try: doc = libxml2.parseFile(descFile) except libxml2.parserError: print ('Error while parsing XML file "%s"'%descFile) sys.exit(-3) self.__ctxt = doc.xpathNewContext() self.__loadPackage() doc.freeDoc() def getJpackage(self): return self.Jpackage def __loadPackage(self): objectNode = self.__ctxt.xpathEval("//package") propPackage=objectNode[0].properties while propPackage is not None: if propPackage.name=="name": packageName=propPackage.getContent() propPackage = propPackage.next self.Jpackage=packageGiws(packageName) self.__loadObject() # self.__ctxt.xpathFreeContext() def __loadObject(self): objectsNode = self.__ctxt.xpathEval("//package/object") for objectNode in objectsNode: extendsObject=None propObj=objectNode.properties # look for the name of the object while propObj is not None: if propObj.name=="name": objectName=propObj.getContent() if propObj.name=="extends": extends=propObj.getContent() # Retrieve the father (inheritance) extendsObject=self.Jpackage.getObject(extends) if extendsObject==None: print ('Class "%s" must be defined before being use as father class.\nPlease check that "%s" is defined before "%s".'%(extends, extends, objectName)) sys.exit(-4) propObj = propObj.next # creates the object newObject=objectGiws(objectName,extendsObject) # Load the methods methods=objectNode.children while methods is not None: if methods.type == "element": newObject.addMethod(self.__loadMethods(methods)) methods = methods.next # Add to the package the object found self.Jpackage.addObject(newObject) self.__ctxt.xpathFreeContext() def __loadMethods(self, method): returns=method.prop("returnType") myFactory=dataFactoryGiws() myReturnData=myFactory.create(returns) modifier=method.prop("modifier") detachThreadProp=method.prop("detachThread") detachThread=False if detachThreadProp!=None: str=detachThreadProp.lower() if str=="true": detachThread=True if modifier!=None: Jmethod=methodGiws(method.properties.getContent(),myReturnData,detachThread,modifier) else: Jmethod=methodGiws(method.properties.getContent(),myReturnData,detachThread) child = method.children parametersName=[] # To check if the parameter is not already defined while child is not None: # We browse the parameters of the method if child.type == "element": prop=child.properties param=self.__loadParameter(prop) try: if parametersName.index(param.getName()) >= 0: print ('%s is already defined as parameters'%param.getName()) sys.exit(-3) except ValueError: #Cannot find the parameter => not defined. Good! parametersName.append(param.getName()) Jmethod.addParameter(param) child = child.next return Jmethod def __loadParameter(self,prop): while prop is not None: if prop.name=="type": type=prop.getContent() if prop.name=="name": name=prop.getContent() prop = prop.next return parameterGiws(name,type) if __name__ == '__main__': print "Parsing ..." templateObj=parseXMLEngine("template.xml") print templateObj.getJpackage().generateCXXHeader() print templateObj.getJpackage() giws-2.0.2/setup.py000066400000000000000000000051771224063444700142160ustar00rootroot00000000000000#!/usr/bin/python -u # Copyright or Copr. INRIA/Scilab - Sylvestre LEDRU # # Sylvestre LEDRU - # # This software is a computer program whose purpose is to generate C++ wrapper # for Java objects/methods. # # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. # # For more information, see the file COPYING from distutils.core import setup from configGiws import configGiws import os root_dir = os.path.dirname(__file__) if root_dir: os.chdir(root_dir) setup (name = "giws", description="Generate C++ class wrappers to call Java methods/objects", version=configGiws().getVersion(), author="Sylvestre Ledru", author_email="sylvestre@ledru.info", url="http://www.scilab.org/giws/", packages=['.','classRepresentation','datatypes'], scripts=['giws'], license="CeCILL", long_description="""Giws is basically doing the same stuff as SWIG but the opposite. Calling Java from C/C++ can be tricky: JNI calls are complicated especially when dealing with non primivite types or arrays, performance issues must be kept in mind all the time, the code can be redundant (checking exceptions, checking returns of operations...). Giws hides this complexity through a C++ class which wraps the Java class.""" )