1 /* Generated by GIWS (version 2.0.2) with command:
2 giws --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
6 This is generated code.
8 This software is a computer program whose purpose is to hide the complexity
9 of accessing Java objects/methods from C++ code.
11 This software is governed by the CeCILL-B license under French law and
12 abiding by the rules of distribution of free software. You can use,
13 modify and/ or redistribute the software under the terms of the CeCILL-B
14 license as circulated by CEA, CNRS and INRIA at the following URL
15 "http://www.cecill.info".
17 As a counterpart to the access to the source code and rights to copy,
18 modify and redistribute granted by the license, users are provided only
19 with a limited warranty and the software's author, the holder of the
20 economic rights, and the successive licensors have only limited
23 In this respect, the user's attention is drawn to the risks associated
24 with loading, using, modifying and/or developing or reproducing the
25 software by the user in light of its specific status of free software,
26 that may mean that it is complicated to manipulate, and that also
27 therefore means that it is reserved for developers and experienced
28 professionals having in-depth computer knowledge. Users are therefore
29 encouraged to load and test the software's suitability as regards their
30 requirements in conditions enabling the security of their systems and/or
31 data to be ensured and, more generally, to use and operate it in the
32 same conditions as regards security.
34 The fact that you are presently reading this means that you have had
35 knowledge of the CeCILL-B license and that you accept its terms.
39 #ifndef __ORG_SCILAB_MODULES_EXTERNAL_OBJECTS_JAVA_SCILABJAVAOBJECT__
40 #define __ORG_SCILAB_MODULES_EXTERNAL_OBJECTS_JAVA_SCILABJAVAOBJECT__
47 #include "GiwsException.hxx"
49 #if defined(_MSC_VER) /* Defined anyway with Visual */
52 typedef signed char byte;
57 # if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__)
58 # if defined(STATIC_LINKED)
61 # define GIWSEXPORT __declspec(dllexport)
65 # define GIWSEXPORT __attribute__ ((visibility ("default")))
72 namespace org_scilab_modules_external_objects_java {
73 class GIWSEXPORT ScilabJavaObject {
79 jmethodID jintinvokejintintjstringjava_lang_StringjintArray_intintID; // cache method id
80 jmethodID jintextractjintintjintArray_intintID; // cache method id
81 jmethodID voidinsertjintintjintArray_intintjintintID; // cache method id
82 jmethodID jobjectArray_getInfosID; // cache method id
83 jmethodID voidinitScilabJavaObjectID; // cache method id
84 jmethodID voidgarbageCollectID; // cache method id
85 jmethodID jstringgetRepresentationjintintID; // cache method id
86 jmethodID jbooleanisValidJavaObjectjintintID; // cache method id
87 jmethodID voidenableTracejstringjava_lang_StringID; // cache method id
88 jmethodID voiddisableTraceID; // cache method id
89 jmethodID voidwriteLogjstringjava_lang_StringID; // cache method id
90 jmethodID voidsetFieldjintintjstringjava_lang_StringjintintID; // cache method id
91 jmethodID jintgetFieldjintintjstringjava_lang_StringID; // cache method id
92 jmethodID jintgetFieldTypejintintjstringjava_lang_StringID; // cache method id
93 jmethodID jintjavaCastjintintjstringjava_lang_StringID; // cache method id
94 jmethodID jintjavaCastjintintjintintID; // cache method id
95 jmethodID jstringgetClassNamejintintID; // cache method id
96 jmethodID jintgetArrayElementjintintjintArray_intintID; // cache method id
97 jmethodID voidsetArrayElementjintintjintArray_intintjintintID; // cache method id
98 jmethodID voidremoveScilabJavaObjectjintintID; // cache method id
99 jmethodID voidremoveScilabJavaObjectjintArray_intintID; // cache method id
100 jmethodID voidlimitDirectBufferjintintID; // cache method id
101 jmethodID jintisUnwrappablejintintID; // cache method id
102 jmethodID jintwrapjdoubledoubleID; // cache method id
103 jmethodID jintwrapjdoubleArray_doubledoubleID; // cache method id
104 jmethodID jintwrapjobjectArray__doubledoubleID; // cache method id
105 jmethodID jintwrapjintintID; // cache method id
106 jmethodID jintwrapjintArray_intintID; // cache method id
107 jmethodID jintwrapjobjectArray__intintID; // cache method id
108 jmethodID jintwrapjbytebyteID; // cache method id
109 jmethodID jintwrapjbyteArray_bytebyteID; // cache method id
110 jmethodID jintwrapjobjectArray__bytebyteID; // cache method id
111 jmethodID jintwrapjshortshortID; // cache method id
112 jmethodID jintwrapjshortArray_shortshortID; // cache method id
113 jmethodID jintwrapjobjectArray__shortshortID; // cache method id
114 jmethodID jintwrapjstringjava_lang_StringID; // cache method id
115 jmethodID jintwrapjobjectArray_java_lang_Stringjava_lang_StringID; // cache method id
116 jclass stringArrayClass;
117 jmethodID jintwrapjobjectArray__java_lang_Stringjava_lang_StringID; // cache method id
118 jmethodID jintwrapjbooleanbooleanID; // cache method id
119 jmethodID jintwrapjbooleanArray_booleanbooleanID; // cache method id
120 jmethodID jintwrapjobjectArray__booleanbooleanID; // cache method id
121 jmethodID jintwrapjcharcharID; // cache method id
122 jmethodID jintwrapjcharArray_charcharID; // cache method id
123 jmethodID jintwrapjobjectArray__charcharID; // cache method id
124 jmethodID jintwrapjfloatfloatID; // cache method id
125 jmethodID jintwrapjfloatArray_floatfloatID; // cache method id
126 jmethodID jintwrapjobjectArray__floatfloatID; // cache method id
127 jmethodID jintwrapjlonglongID; // cache method id
128 jmethodID jintwrapjlongArray_longlongID; // cache method id
129 jmethodID jintwrapjobjectArray__longlongID; // cache method id
130 jmethodID jobjectArray_getAccessibleFieldsjintintID; // cache method id
131 jmethodID jobjectArray_getAccessibleMethodsjintintID; // cache method id
132 jmethodID jobjectArray_getCompletionjintintjobjectArray_java_lang_Stringjava_lang_StringID; // cache method id
137 jclass instanceClass; // cache class
144 * Get the environment matching to the current thread.
146 virtual JNIEnv * getCurrentEnv();
151 * Create a wrapping of the object from a JNIEnv.
152 * It will call the default constructor
153 * @param JEnv_ the Java Env
155 ScilabJavaObject(JavaVM * jvm_);
158 * Create a wrapping of an already existing object from a JNIEnv.
159 * The object must have already been instantiated
160 * @param JEnv_ the Java Env
161 * @param JObj the object
163 ScilabJavaObject(JavaVM * jvm_, jobject JObj);
167 * This is a fake constructor to avoid the constructor
168 * chaining when dealing with extended giws classes
170 #ifdef FAKEGIWSDATATYPE
171 ScilabJavaObject(fakeGiwsDataType::fakeGiwsDataType /* unused */) {}
178 // Synchronization methods
180 * Enter monitor associated with the object.
181 * Equivalent of creating a "synchronized(obj)" scope in Java.
186 * Exit monitor associated with the object.
187 * Equivalent of ending a "synchronized(obj)" scope.
189 void endSynchronize();
192 static int invoke(JavaVM * jvm_, int id, char const* methodName, int const* args, int argsSize);
194 static int extract(JavaVM * jvm_, int id, int const* args, int argsSize);
196 static void insert(JavaVM * jvm_, int id, int const* keys, int keysSize, int value);
198 static char** getInfos(JavaVM * jvm_, int *lenRow);
200 static void initScilabJavaObject(JavaVM * jvm_);
202 static void garbageCollect(JavaVM * jvm_);
204 static char* getRepresentation(JavaVM * jvm_, int id);
206 static bool isValidJavaObject(JavaVM * jvm_, int id);
208 static void enableTrace(JavaVM * jvm_, char const* filename);
210 static void disableTrace(JavaVM * jvm_);
212 static void writeLog(JavaVM * jvm_, char const* s);
214 static void setField(JavaVM * jvm_, int id, char const* fieldName, int idarg);
216 static int getField(JavaVM * jvm_, int id, char const* fieldName);
218 static int getFieldType(JavaVM * jvm_, int id, char const* fieldName);
220 static int javaCast(JavaVM * jvm_, int id, char const* objName);
222 static int javaCast(JavaVM * jvm_, int id, int classId);
224 static char* getClassName(JavaVM * jvm_, int id);
226 static int getArrayElement(JavaVM * jvm_, int id, int const* index, int indexSize);
228 static void setArrayElement(JavaVM * jvm_, int id, int const* index, int indexSize, int idArg);
230 static void removeScilabJavaObject(JavaVM * jvm_, int id);
232 static void removeScilabJavaObject(JavaVM * jvm_, int const* id, int idSize);
234 static void limitDirectBuffer(JavaVM * jvm_, int id);
236 static int isUnwrappable(JavaVM * jvm_, int id);
238 static int wrap(JavaVM * jvm_, double x);
240 static int wrap(JavaVM * jvm_, double const* x, int xSize);
242 static int wrap(JavaVM * jvm_, double const* const* x, int xSize, int xSizeCol);
244 static int wrap(JavaVM * jvm_, int x);
246 static int wrap(JavaVM * jvm_, int const* x, int xSize);
248 static int wrap(JavaVM * jvm_, int const* const* x, int xSize, int xSizeCol);
250 static int wrap(JavaVM * jvm_, byte x);
252 static int wrap(JavaVM * jvm_, byte const* x, int xSize);
254 static int wrap(JavaVM * jvm_, byte const* const* x, int xSize, int xSizeCol);
256 static int wrap(JavaVM * jvm_, short x);
258 static int wrap(JavaVM * jvm_, short const* x, int xSize);
260 static int wrap(JavaVM * jvm_, short const* const* x, int xSize, int xSizeCol);
262 static int wrap(JavaVM * jvm_, char const* x);
264 static int wrap(JavaVM * jvm_, char const* const* x, int xSize);
266 static int wrap(JavaVM * jvm_, char const* const* const* x, int xSize, int xSizeCol);
268 static int wrap(JavaVM * jvm_, bool x);
270 static int wrap(JavaVM * jvm_, bool const* x, int xSize);
272 static int wrap(JavaVM * jvm_, bool const* const* x, int xSize, int xSizeCol);
274 static int wrap(JavaVM * jvm_, unsigned short x);
276 static int wrap(JavaVM * jvm_, unsigned short const* x, int xSize);
278 static int wrap(JavaVM * jvm_, unsigned short const* const* x, int xSize, int xSizeCol);
280 static int wrap(JavaVM * jvm_, float x);
282 static int wrap(JavaVM * jvm_, float const* x, int xSize);
284 static int wrap(JavaVM * jvm_, float const* const* x, int xSize, int xSizeCol);
286 static int wrap(JavaVM * jvm_, long long x);
288 static int wrap(JavaVM * jvm_, long long const* x, int xSize);
290 static int wrap(JavaVM * jvm_, long long const* const* x, int xSize, int xSizeCol);
292 static char** getAccessibleFields(JavaVM * jvm_, int id, int *lenRow);
294 static char** getAccessibleMethods(JavaVM * jvm_, int id, int *lenRow);
296 static char** getCompletion(JavaVM * jvm_, int id, char const* const* fieldPath, int fieldPathSize, int *lenRow);
300 * Get class name to use for static methods
301 * @return class name to use for static methods
304 static const std::string className()
306 return "org/scilab/modules/external_objects_java/ScilabJavaObject";
311 * Get class to use for static methods
312 * @return class to use for static methods
315 static jclass initClass(JNIEnv * curEnv)
317 static jclass cls = 0;
321 jclass _cls = curEnv->FindClass(className().c_str());
324 cls = static_cast<jclass>(curEnv->NewGlobalRef(_cls));