1 #include "ScilabJavaObject.hxx"
2 /* Generated by GIWS (version 2.0.2) with command:
3 giws --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/ScilabObjects.giws.xml
7 This is generated code.
9 This software is a computer program whose purpose is to hide the complexity
10 of accessing Java objects/methods from C++ code.
12 This software is governed by the CeCILL-B license under French law and
13 abiding by the rules of distribution of free software. You can use,
14 modify and/ or redistribute the software under the terms of the CeCILL-B
15 license as circulated by CEA, CNRS and INRIA at the following URL
16 "http://www.cecill.info".
18 As a counterpart to the access to the source code and rights to copy,
19 modify and redistribute granted by the license, users are provided only
20 with a limited warranty and the software's author, the holder of the
21 economic rights, and the successive licensors have only limited
24 In this respect, the user's attention is drawn to the risks associated
25 with loading, using, modifying and/or developing or reproducing the
26 software by the user in light of its specific status of free software,
27 that may mean that it is complicated to manipulate, and that also
28 therefore means that it is reserved for developers and experienced
29 professionals having in-depth computer knowledge. Users are therefore
30 encouraged to load and test the software's suitability as regards their
31 requirements in conditions enabling the security of their systems and/or
32 data to be ensured and, more generally, to use and operate it in the
33 same conditions as regards security.
35 The fact that you are presently reading this means that you have had
36 knowledge of the CeCILL-B license and that you accept its terms.
39 namespace org_scilab_modules_external_objects_java {
41 // Static declarations (if any)
43 // Returns the current env
45 JNIEnv * ScilabJavaObject::getCurrentEnv() {
46 JNIEnv * curEnv = NULL;
47 jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
49 throw GiwsException::JniException(getCurrentEnv());
55 ScilabJavaObject::~ScilabJavaObject() {
56 JNIEnv * curEnv = NULL;
57 this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
58 curEnv->DeleteGlobalRef(this->instance);
59 curEnv->DeleteGlobalRef(this->instanceClass);
60 curEnv->DeleteGlobalRef(this->stringArrayClass);}
62 ScilabJavaObject::ScilabJavaObject(JavaVM * jvm_) {
63 jmethodID constructObject = NULL ;
64 jobject localInstance ;
67 const std::string construct="<init>";
68 const std::string param="()V";
71 JNIEnv * curEnv = getCurrentEnv();
73 localClass = curEnv->FindClass( this->className().c_str() ) ;
74 if (localClass == NULL) {
75 throw GiwsException::JniClassNotFoundException(curEnv, this->className());
78 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
80 /* localClass is not needed anymore */
81 curEnv->DeleteLocalRef(localClass);
83 if (this->instanceClass == NULL) {
84 throw GiwsException::JniObjectCreationException(curEnv, this->className());
88 constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
89 if(constructObject == NULL){
90 throw GiwsException::JniObjectCreationException(curEnv, this->className());
93 localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
94 if(localInstance == NULL){
95 throw GiwsException::JniObjectCreationException(curEnv, this->className());
98 this->instance = curEnv->NewGlobalRef(localInstance) ;
99 if(this->instance == NULL){
100 throw GiwsException::JniObjectCreationException(curEnv, this->className());
102 /* localInstance not needed anymore */
103 curEnv->DeleteLocalRef(localInstance);
105 /* Methods ID set to NULL */
106 jintinvokejintintjstringjava_lang_StringjintArray_intintID=NULL;
107 jintextractjintintjintArray_intintID=NULL;
108 voidinsertjintintjintArray_intintjintintID=NULL;
109 jobjectArray_getInfosID=NULL;
110 voidinitScilabJavaObjectID=NULL;
111 voidgarbageCollectID=NULL;
112 jstringgetRepresentationjintintID=NULL;
113 jbooleanisValidJavaObjectjintintID=NULL;
114 voidenableTracejstringjava_lang_StringID=NULL;
115 voiddisableTraceID=NULL;
116 voidwriteLogjstringjava_lang_StringID=NULL;
117 voidsetFieldjintintjstringjava_lang_StringjintintID=NULL;
118 jintgetFieldjintintjstringjava_lang_StringID=NULL;
119 jintgetFieldTypejintintjstringjava_lang_StringID=NULL;
120 jintjavaCastjintintjstringjava_lang_StringID=NULL;
121 jintjavaCastjintintjintintID=NULL;
122 jstringgetClassNamejintintID=NULL;
123 jintgetArrayElementjintintjintArray_intintID=NULL;
124 voidsetArrayElementjintintjintArray_intintjintintID=NULL;
125 voidremoveScilabJavaObjectjintintID=NULL;
126 voidremoveScilabJavaObjectjintArray_intintID=NULL;
127 voidlimitDirectBufferjintintID=NULL;
128 jintisUnwrappablejintintID=NULL;
129 jintwrapjdoubledoubleID=NULL;
130 jintwrapjdoubleArray_doubledoubleID=NULL;
131 jintwrapjobjectArray__doubledoubleID=NULL;
132 jintwrapjintintID=NULL;
133 jintwrapjintArray_intintID=NULL;
134 jintwrapjobjectArray__intintID=NULL;
135 jintwrapjbytebyteID=NULL;
136 jintwrapjbyteArray_bytebyteID=NULL;
137 jintwrapjobjectArray__bytebyteID=NULL;
138 jintwrapjshortshortID=NULL;
139 jintwrapjshortArray_shortshortID=NULL;
140 jintwrapjobjectArray__shortshortID=NULL;
141 jintwrapjstringjava_lang_StringID=NULL;
142 jintwrapjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
143 jintwrapjobjectArray__java_lang_Stringjava_lang_StringID=NULL;
144 jintwrapjbooleanbooleanID=NULL;
145 jintwrapjbooleanArray_booleanbooleanID=NULL;
146 jintwrapjobjectArray__booleanbooleanID=NULL;
147 jintwrapjcharcharID=NULL;
148 jintwrapjcharArray_charcharID=NULL;
149 jintwrapjobjectArray__charcharID=NULL;
150 jintwrapjfloatfloatID=NULL;
151 jintwrapjfloatArray_floatfloatID=NULL;
152 jintwrapjobjectArray__floatfloatID=NULL;
153 jintwrapjlonglongID=NULL;
154 jintwrapjlongArray_longlongID=NULL;
155 jintwrapjobjectArray__longlongID=NULL;
156 jintwrapListjintArray_intintID=NULL;
157 jintwrapPolyjdoubleArray_doubledoubleID=NULL;
158 jobjectArray_getAccessibleFieldsjintintID=NULL;
159 jobjectArray_getAccessibleMethodsjintintID=NULL;
160 jobjectArray_getCompletionjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
165 ScilabJavaObject::ScilabJavaObject(JavaVM * jvm_, jobject JObj) {
168 JNIEnv * curEnv = getCurrentEnv();
170 jclass localClass = curEnv->GetObjectClass(JObj);
171 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
172 curEnv->DeleteLocalRef(localClass);
174 if (this->instanceClass == NULL) {
175 throw GiwsException::JniObjectCreationException(curEnv, this->className());
178 this->instance = curEnv->NewGlobalRef(JObj) ;
179 if(this->instance == NULL){
180 throw GiwsException::JniObjectCreationException(curEnv, this->className());
182 /* Methods ID set to NULL */
183 jintinvokejintintjstringjava_lang_StringjintArray_intintID=NULL;
184 jintextractjintintjintArray_intintID=NULL;
185 voidinsertjintintjintArray_intintjintintID=NULL;
186 jobjectArray_getInfosID=NULL;
187 voidinitScilabJavaObjectID=NULL;
188 voidgarbageCollectID=NULL;
189 jstringgetRepresentationjintintID=NULL;
190 jbooleanisValidJavaObjectjintintID=NULL;
191 voidenableTracejstringjava_lang_StringID=NULL;
192 voiddisableTraceID=NULL;
193 voidwriteLogjstringjava_lang_StringID=NULL;
194 voidsetFieldjintintjstringjava_lang_StringjintintID=NULL;
195 jintgetFieldjintintjstringjava_lang_StringID=NULL;
196 jintgetFieldTypejintintjstringjava_lang_StringID=NULL;
197 jintjavaCastjintintjstringjava_lang_StringID=NULL;
198 jintjavaCastjintintjintintID=NULL;
199 jstringgetClassNamejintintID=NULL;
200 jintgetArrayElementjintintjintArray_intintID=NULL;
201 voidsetArrayElementjintintjintArray_intintjintintID=NULL;
202 voidremoveScilabJavaObjectjintintID=NULL;
203 voidremoveScilabJavaObjectjintArray_intintID=NULL;
204 voidlimitDirectBufferjintintID=NULL;
205 jintisUnwrappablejintintID=NULL;
206 jintwrapjdoubledoubleID=NULL;
207 jintwrapjdoubleArray_doubledoubleID=NULL;
208 jintwrapjobjectArray__doubledoubleID=NULL;
209 jintwrapjintintID=NULL;
210 jintwrapjintArray_intintID=NULL;
211 jintwrapjobjectArray__intintID=NULL;
212 jintwrapjbytebyteID=NULL;
213 jintwrapjbyteArray_bytebyteID=NULL;
214 jintwrapjobjectArray__bytebyteID=NULL;
215 jintwrapjshortshortID=NULL;
216 jintwrapjshortArray_shortshortID=NULL;
217 jintwrapjobjectArray__shortshortID=NULL;
218 jintwrapjstringjava_lang_StringID=NULL;
219 jintwrapjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
220 jintwrapjobjectArray__java_lang_Stringjava_lang_StringID=NULL;
221 jintwrapjbooleanbooleanID=NULL;
222 jintwrapjbooleanArray_booleanbooleanID=NULL;
223 jintwrapjobjectArray__booleanbooleanID=NULL;
224 jintwrapjcharcharID=NULL;
225 jintwrapjcharArray_charcharID=NULL;
226 jintwrapjobjectArray__charcharID=NULL;
227 jintwrapjfloatfloatID=NULL;
228 jintwrapjfloatArray_floatfloatID=NULL;
229 jintwrapjobjectArray__floatfloatID=NULL;
230 jintwrapjlonglongID=NULL;
231 jintwrapjlongArray_longlongID=NULL;
232 jintwrapjobjectArray__longlongID=NULL;
233 jintwrapListjintArray_intintID=NULL;
234 jintwrapPolyjdoubleArray_doubledoubleID=NULL;
235 jobjectArray_getAccessibleFieldsjintintID=NULL;
236 jobjectArray_getAccessibleMethodsjintintID=NULL;
237 jobjectArray_getCompletionjintintjobjectArray_java_lang_Stringjava_lang_StringID=NULL;
244 void ScilabJavaObject::synchronize() {
245 if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
246 throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaObject");
250 void ScilabJavaObject::endSynchronize() {
251 if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
252 throw GiwsException::JniMonitorException(getCurrentEnv(), "ScilabJavaObject");
257 int ScilabJavaObject::invoke (JavaVM * jvm_, int id, char const* methodName, int const* args, int argsSize){
259 JNIEnv * curEnv = NULL;
260 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
261 jclass cls = initClass(curEnv);
263 throw GiwsException::JniCallMethodException(curEnv);
266 static jmethodID jintinvokejintintjstringjava_lang_StringjintArray_intintID = curEnv->GetStaticMethodID(cls, "invoke", "(ILjava/lang/String;[I)I" ) ;
267 if (jintinvokejintintjstringjava_lang_StringjintArray_intintID == NULL) {
268 throw GiwsException::JniMethodNotFoundException(curEnv, "invoke");
271 jstring methodName_ = curEnv->NewStringUTF( methodName );
272 if (methodName != NULL && methodName_ == NULL)
274 throw GiwsException::JniBadAllocException(curEnv);
278 jintArray args_ = curEnv->NewIntArray( argsSize ) ;
282 // check that allocation succeed
283 throw GiwsException::JniBadAllocException(curEnv);
286 curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
289 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintinvokejintintjstringjava_lang_StringjintArray_intintID ,id, methodName_, args_));
290 curEnv->DeleteLocalRef(methodName_);
291 curEnv->DeleteLocalRef(args_);
292 if (curEnv->ExceptionCheck()) {
293 throw GiwsException::JniCallMethodException(curEnv);
299 int ScilabJavaObject::extract (JavaVM * jvm_, int id, int const* args, int argsSize){
301 JNIEnv * curEnv = NULL;
302 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
303 jclass cls = initClass(curEnv);
305 throw GiwsException::JniCallMethodException(curEnv);
308 static jmethodID jintextractjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "extract", "(I[I)I" ) ;
309 if (jintextractjintintjintArray_intintID == NULL) {
310 throw GiwsException::JniMethodNotFoundException(curEnv, "extract");
313 jintArray args_ = curEnv->NewIntArray( argsSize ) ;
317 // check that allocation succeed
318 throw GiwsException::JniBadAllocException(curEnv);
321 curEnv->SetIntArrayRegion( args_, 0, argsSize, (jint*)(args) ) ;
324 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintextractjintintjintArray_intintID ,id, args_));
325 curEnv->DeleteLocalRef(args_);
326 if (curEnv->ExceptionCheck()) {
327 throw GiwsException::JniCallMethodException(curEnv);
333 void ScilabJavaObject::insert (JavaVM * jvm_, int id, int const* keys, int keysSize, int value){
335 JNIEnv * curEnv = NULL;
336 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
337 jclass cls = initClass(curEnv);
339 throw GiwsException::JniCallMethodException(curEnv);
342 static jmethodID voidinsertjintintjintArray_intintjintintID = curEnv->GetStaticMethodID(cls, "insert", "(I[II)V" ) ;
343 if (voidinsertjintintjintArray_intintjintintID == NULL) {
344 throw GiwsException::JniMethodNotFoundException(curEnv, "insert");
347 jintArray keys_ = curEnv->NewIntArray( keysSize ) ;
351 // check that allocation succeed
352 throw GiwsException::JniBadAllocException(curEnv);
355 curEnv->SetIntArrayRegion( keys_, 0, keysSize, (jint*)(keys) ) ;
358 curEnv->CallStaticVoidMethod(cls, voidinsertjintintjintArray_intintjintintID ,id, keys_, value);
359 curEnv->DeleteLocalRef(keys_);
360 if (curEnv->ExceptionCheck()) {
361 throw GiwsException::JniCallMethodException(curEnv);
365 char** ScilabJavaObject::getInfos (JavaVM * jvm_, int *lenRow){
367 JNIEnv * curEnv = NULL;
368 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
369 jclass cls = initClass(curEnv);
371 throw GiwsException::JniCallMethodException(curEnv);
374 static jmethodID jobjectArray_getInfosID = curEnv->GetStaticMethodID(cls, "getInfos", "()[Ljava/lang/String;" ) ;
375 if (jobjectArray_getInfosID == NULL) {
376 throw GiwsException::JniMethodNotFoundException(curEnv, "getInfos");
379 jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray_getInfosID ));
380 if (curEnv->ExceptionCheck()) {
381 throw GiwsException::JniCallMethodException(curEnv);
383 * lenRow = curEnv->GetArrayLength(res);
385 char **arrayOfString;
386 arrayOfString = new char *[*lenRow];
387 for (jsize i = 0; i < *lenRow; i++){
388 jstring resString = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(res, i));
389 const char *tempString = curEnv->GetStringUTFChars(resString, 0);
390 arrayOfString[i] = new char[strlen(tempString) + 1];
392 strcpy(arrayOfString[i], tempString);
393 curEnv->ReleaseStringUTFChars(resString, tempString);
394 curEnv->DeleteLocalRef(resString);
396 if (curEnv->ExceptionCheck()) {
397 delete[] arrayOfString;
398 throw GiwsException::JniCallMethodException(curEnv);
400 curEnv->DeleteLocalRef(res);
401 return arrayOfString;
403 curEnv->DeleteLocalRef(res);
408 void ScilabJavaObject::initScilabJavaObject (JavaVM * jvm_){
410 JNIEnv * curEnv = NULL;
411 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
412 jclass cls = initClass(curEnv);
414 throw GiwsException::JniCallMethodException(curEnv);
417 static jmethodID voidinitScilabJavaObjectID = curEnv->GetStaticMethodID(cls, "initScilabJavaObject", "()V" ) ;
418 if (voidinitScilabJavaObjectID == NULL) {
419 throw GiwsException::JniMethodNotFoundException(curEnv, "initScilabJavaObject");
422 curEnv->CallStaticVoidMethod(cls, voidinitScilabJavaObjectID );
423 if (curEnv->ExceptionCheck()) {
424 throw GiwsException::JniCallMethodException(curEnv);
428 void ScilabJavaObject::garbageCollect (JavaVM * jvm_){
430 JNIEnv * curEnv = NULL;
431 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
432 jclass cls = initClass(curEnv);
434 throw GiwsException::JniCallMethodException(curEnv);
437 static jmethodID voidgarbageCollectID = curEnv->GetStaticMethodID(cls, "garbageCollect", "()V" ) ;
438 if (voidgarbageCollectID == NULL) {
439 throw GiwsException::JniMethodNotFoundException(curEnv, "garbageCollect");
442 curEnv->CallStaticVoidMethod(cls, voidgarbageCollectID );
443 if (curEnv->ExceptionCheck()) {
444 throw GiwsException::JniCallMethodException(curEnv);
448 char* ScilabJavaObject::getRepresentation (JavaVM * jvm_, int id){
450 JNIEnv * curEnv = NULL;
451 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
452 jclass cls = initClass(curEnv);
454 throw GiwsException::JniCallMethodException(curEnv);
457 static jmethodID jstringgetRepresentationjintintID = curEnv->GetStaticMethodID(cls, "getRepresentation", "(I)Ljava/lang/String;" ) ;
458 if (jstringgetRepresentationjintintID == NULL) {
459 throw GiwsException::JniMethodNotFoundException(curEnv, "getRepresentation");
462 jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetRepresentationjintintID ,id));
463 if (curEnv->ExceptionCheck()) {
464 throw GiwsException::JniCallMethodException(curEnv);
467 const char *tempString = curEnv->GetStringUTFChars(res, 0);
468 char * myStringBuffer = new char[strlen(tempString) + 1];
469 strcpy(myStringBuffer, tempString);
470 curEnv->ReleaseStringUTFChars(res, tempString);
471 curEnv->DeleteLocalRef(res);
472 if (curEnv->ExceptionCheck()) {
473 delete[] myStringBuffer;
474 throw GiwsException::JniCallMethodException(curEnv);
476 return myStringBuffer;
478 curEnv->DeleteLocalRef(res);
483 bool ScilabJavaObject::isValidJavaObject (JavaVM * jvm_, int id){
485 JNIEnv * curEnv = NULL;
486 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
487 jclass cls = initClass(curEnv);
489 throw GiwsException::JniCallMethodException(curEnv);
492 static jmethodID jbooleanisValidJavaObjectjintintID = curEnv->GetStaticMethodID(cls, "isValidJavaObject", "(I)Z" ) ;
493 if (jbooleanisValidJavaObjectjintintID == NULL) {
494 throw GiwsException::JniMethodNotFoundException(curEnv, "isValidJavaObject");
497 jboolean res = static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanisValidJavaObjectjintintID ,id));
498 if (curEnv->ExceptionCheck()) {
499 throw GiwsException::JniCallMethodException(curEnv);
501 return (res == JNI_TRUE);
505 void ScilabJavaObject::enableTrace (JavaVM * jvm_, char const* filename){
507 JNIEnv * curEnv = NULL;
508 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
509 jclass cls = initClass(curEnv);
511 throw GiwsException::JniCallMethodException(curEnv);
514 static jmethodID voidenableTracejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "enableTrace", "(Ljava/lang/String;)V" ) ;
515 if (voidenableTracejstringjava_lang_StringID == NULL) {
516 throw GiwsException::JniMethodNotFoundException(curEnv, "enableTrace");
519 jstring filename_ = curEnv->NewStringUTF( filename );
520 if (filename != NULL && filename_ == NULL)
522 throw GiwsException::JniBadAllocException(curEnv);
526 curEnv->CallStaticVoidMethod(cls, voidenableTracejstringjava_lang_StringID ,filename_);
527 curEnv->DeleteLocalRef(filename_);
528 if (curEnv->ExceptionCheck()) {
529 throw GiwsException::JniCallMethodException(curEnv);
533 void ScilabJavaObject::disableTrace (JavaVM * jvm_){
535 JNIEnv * curEnv = NULL;
536 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
537 jclass cls = initClass(curEnv);
539 throw GiwsException::JniCallMethodException(curEnv);
542 static jmethodID voiddisableTraceID = curEnv->GetStaticMethodID(cls, "disableTrace", "()V" ) ;
543 if (voiddisableTraceID == NULL) {
544 throw GiwsException::JniMethodNotFoundException(curEnv, "disableTrace");
547 curEnv->CallStaticVoidMethod(cls, voiddisableTraceID );
548 if (curEnv->ExceptionCheck()) {
549 throw GiwsException::JniCallMethodException(curEnv);
553 void ScilabJavaObject::writeLog (JavaVM * jvm_, char const* s){
555 JNIEnv * curEnv = NULL;
556 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
557 jclass cls = initClass(curEnv);
559 throw GiwsException::JniCallMethodException(curEnv);
562 static jmethodID voidwriteLogjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "writeLog", "(Ljava/lang/String;)V" ) ;
563 if (voidwriteLogjstringjava_lang_StringID == NULL) {
564 throw GiwsException::JniMethodNotFoundException(curEnv, "writeLog");
567 jstring s_ = curEnv->NewStringUTF( s );
568 if (s != NULL && s_ == NULL)
570 throw GiwsException::JniBadAllocException(curEnv);
574 curEnv->CallStaticVoidMethod(cls, voidwriteLogjstringjava_lang_StringID ,s_);
575 curEnv->DeleteLocalRef(s_);
576 if (curEnv->ExceptionCheck()) {
577 throw GiwsException::JniCallMethodException(curEnv);
581 void ScilabJavaObject::setField (JavaVM * jvm_, int id, char const* fieldName, int idarg){
583 JNIEnv * curEnv = NULL;
584 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
585 jclass cls = initClass(curEnv);
587 throw GiwsException::JniCallMethodException(curEnv);
590 static jmethodID voidsetFieldjintintjstringjava_lang_StringjintintID = curEnv->GetStaticMethodID(cls, "setField", "(ILjava/lang/String;I)V" ) ;
591 if (voidsetFieldjintintjstringjava_lang_StringjintintID == NULL) {
592 throw GiwsException::JniMethodNotFoundException(curEnv, "setField");
595 jstring fieldName_ = curEnv->NewStringUTF( fieldName );
596 if (fieldName != NULL && fieldName_ == NULL)
598 throw GiwsException::JniBadAllocException(curEnv);
602 curEnv->CallStaticVoidMethod(cls, voidsetFieldjintintjstringjava_lang_StringjintintID ,id, fieldName_, idarg);
603 curEnv->DeleteLocalRef(fieldName_);
604 if (curEnv->ExceptionCheck()) {
605 throw GiwsException::JniCallMethodException(curEnv);
609 int ScilabJavaObject::getField (JavaVM * jvm_, int id, char const* fieldName){
611 JNIEnv * curEnv = NULL;
612 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
613 jclass cls = initClass(curEnv);
615 throw GiwsException::JniCallMethodException(curEnv);
618 static jmethodID jintgetFieldjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getField", "(ILjava/lang/String;)I" ) ;
619 if (jintgetFieldjintintjstringjava_lang_StringID == NULL) {
620 throw GiwsException::JniMethodNotFoundException(curEnv, "getField");
623 jstring fieldName_ = curEnv->NewStringUTF( fieldName );
624 if (fieldName != NULL && fieldName_ == NULL)
626 throw GiwsException::JniBadAllocException(curEnv);
630 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFieldjintintjstringjava_lang_StringID ,id, fieldName_));
631 curEnv->DeleteLocalRef(fieldName_);
632 if (curEnv->ExceptionCheck()) {
633 throw GiwsException::JniCallMethodException(curEnv);
639 int ScilabJavaObject::getFieldType (JavaVM * jvm_, int id, char const* fieldName){
641 JNIEnv * curEnv = NULL;
642 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
643 jclass cls = initClass(curEnv);
645 throw GiwsException::JniCallMethodException(curEnv);
648 static jmethodID jintgetFieldTypejintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getFieldType", "(ILjava/lang/String;)I" ) ;
649 if (jintgetFieldTypejintintjstringjava_lang_StringID == NULL) {
650 throw GiwsException::JniMethodNotFoundException(curEnv, "getFieldType");
653 jstring fieldName_ = curEnv->NewStringUTF( fieldName );
654 if (fieldName != NULL && fieldName_ == NULL)
656 throw GiwsException::JniBadAllocException(curEnv);
660 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetFieldTypejintintjstringjava_lang_StringID ,id, fieldName_));
661 curEnv->DeleteLocalRef(fieldName_);
662 if (curEnv->ExceptionCheck()) {
663 throw GiwsException::JniCallMethodException(curEnv);
669 int ScilabJavaObject::javaCast (JavaVM * jvm_, int id, char const* objName){
671 JNIEnv * curEnv = NULL;
672 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
673 jclass cls = initClass(curEnv);
675 throw GiwsException::JniCallMethodException(curEnv);
678 static jmethodID jintjavaCastjintintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "javaCast", "(ILjava/lang/String;)I" ) ;
679 if (jintjavaCastjintintjstringjava_lang_StringID == NULL) {
680 throw GiwsException::JniMethodNotFoundException(curEnv, "javaCast");
683 jstring objName_ = curEnv->NewStringUTF( objName );
684 if (objName != NULL && objName_ == NULL)
686 throw GiwsException::JniBadAllocException(curEnv);
690 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintjavaCastjintintjstringjava_lang_StringID ,id, objName_));
691 curEnv->DeleteLocalRef(objName_);
692 if (curEnv->ExceptionCheck()) {
693 throw GiwsException::JniCallMethodException(curEnv);
699 int ScilabJavaObject::javaCast (JavaVM * jvm_, int id, int classId){
701 JNIEnv * curEnv = NULL;
702 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
703 jclass cls = initClass(curEnv);
705 throw GiwsException::JniCallMethodException(curEnv);
708 static jmethodID jintjavaCastjintintjintintID = curEnv->GetStaticMethodID(cls, "javaCast", "(II)I" ) ;
709 if (jintjavaCastjintintjintintID == NULL) {
710 throw GiwsException::JniMethodNotFoundException(curEnv, "javaCast");
713 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintjavaCastjintintjintintID ,id, classId));
714 if (curEnv->ExceptionCheck()) {
715 throw GiwsException::JniCallMethodException(curEnv);
721 char* ScilabJavaObject::getClassName (JavaVM * jvm_, int id){
723 JNIEnv * curEnv = NULL;
724 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
725 jclass cls = initClass(curEnv);
727 throw GiwsException::JniCallMethodException(curEnv);
730 static jmethodID jstringgetClassNamejintintID = curEnv->GetStaticMethodID(cls, "getClassName", "(I)Ljava/lang/String;" ) ;
731 if (jstringgetClassNamejintintID == NULL) {
732 throw GiwsException::JniMethodNotFoundException(curEnv, "getClassName");
735 jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringgetClassNamejintintID ,id));
736 if (curEnv->ExceptionCheck()) {
737 throw GiwsException::JniCallMethodException(curEnv);
740 const char *tempString = curEnv->GetStringUTFChars(res, 0);
741 char * myStringBuffer = new char[strlen(tempString) + 1];
742 strcpy(myStringBuffer, tempString);
743 curEnv->ReleaseStringUTFChars(res, tempString);
744 curEnv->DeleteLocalRef(res);
745 if (curEnv->ExceptionCheck()) {
746 delete[] myStringBuffer;
747 throw GiwsException::JniCallMethodException(curEnv);
749 return myStringBuffer;
751 curEnv->DeleteLocalRef(res);
756 int ScilabJavaObject::getArrayElement (JavaVM * jvm_, int id, int const* index, int indexSize){
758 JNIEnv * curEnv = NULL;
759 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
760 jclass cls = initClass(curEnv);
762 throw GiwsException::JniCallMethodException(curEnv);
765 static jmethodID jintgetArrayElementjintintjintArray_intintID = curEnv->GetStaticMethodID(cls, "getArrayElement", "(I[I)I" ) ;
766 if (jintgetArrayElementjintintjintArray_intintID == NULL) {
767 throw GiwsException::JniMethodNotFoundException(curEnv, "getArrayElement");
770 jintArray index_ = curEnv->NewIntArray( indexSize ) ;
774 // check that allocation succeed
775 throw GiwsException::JniBadAllocException(curEnv);
778 curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
781 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetArrayElementjintintjintArray_intintID ,id, index_));
782 curEnv->DeleteLocalRef(index_);
783 if (curEnv->ExceptionCheck()) {
784 throw GiwsException::JniCallMethodException(curEnv);
790 void ScilabJavaObject::setArrayElement (JavaVM * jvm_, int id, int const* index, int indexSize, int idArg){
792 JNIEnv * curEnv = NULL;
793 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
794 jclass cls = initClass(curEnv);
796 throw GiwsException::JniCallMethodException(curEnv);
799 static jmethodID voidsetArrayElementjintintjintArray_intintjintintID = curEnv->GetStaticMethodID(cls, "setArrayElement", "(I[II)V" ) ;
800 if (voidsetArrayElementjintintjintArray_intintjintintID == NULL) {
801 throw GiwsException::JniMethodNotFoundException(curEnv, "setArrayElement");
804 jintArray index_ = curEnv->NewIntArray( indexSize ) ;
808 // check that allocation succeed
809 throw GiwsException::JniBadAllocException(curEnv);
812 curEnv->SetIntArrayRegion( index_, 0, indexSize, (jint*)(index) ) ;
815 curEnv->CallStaticVoidMethod(cls, voidsetArrayElementjintintjintArray_intintjintintID ,id, index_, idArg);
816 curEnv->DeleteLocalRef(index_);
817 if (curEnv->ExceptionCheck()) {
818 throw GiwsException::JniCallMethodException(curEnv);
822 void ScilabJavaObject::removeScilabJavaObject (JavaVM * jvm_, int id){
824 JNIEnv * curEnv = NULL;
825 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
826 jclass cls = initClass(curEnv);
828 throw GiwsException::JniCallMethodException(curEnv);
831 static jmethodID voidremoveScilabJavaObjectjintintID = curEnv->GetStaticMethodID(cls, "removeScilabJavaObject", "(I)V" ) ;
832 if (voidremoveScilabJavaObjectjintintID == NULL) {
833 throw GiwsException::JniMethodNotFoundException(curEnv, "removeScilabJavaObject");
836 curEnv->CallStaticVoidMethod(cls, voidremoveScilabJavaObjectjintintID ,id);
837 if (curEnv->ExceptionCheck()) {
838 throw GiwsException::JniCallMethodException(curEnv);
842 void ScilabJavaObject::removeScilabJavaObject (JavaVM * jvm_, int const* id, int idSize){
844 JNIEnv * curEnv = NULL;
845 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
846 jclass cls = initClass(curEnv);
848 throw GiwsException::JniCallMethodException(curEnv);
851 static jmethodID voidremoveScilabJavaObjectjintArray_intintID = curEnv->GetStaticMethodID(cls, "removeScilabJavaObject", "([I)V" ) ;
852 if (voidremoveScilabJavaObjectjintArray_intintID == NULL) {
853 throw GiwsException::JniMethodNotFoundException(curEnv, "removeScilabJavaObject");
856 jintArray id_ = curEnv->NewIntArray( idSize ) ;
860 // check that allocation succeed
861 throw GiwsException::JniBadAllocException(curEnv);
864 curEnv->SetIntArrayRegion( id_, 0, idSize, (jint*)(id) ) ;
867 curEnv->CallStaticVoidMethod(cls, voidremoveScilabJavaObjectjintArray_intintID ,id_);
868 curEnv->DeleteLocalRef(id_);
869 if (curEnv->ExceptionCheck()) {
870 throw GiwsException::JniCallMethodException(curEnv);
874 void ScilabJavaObject::limitDirectBuffer (JavaVM * jvm_, int id){
876 JNIEnv * curEnv = NULL;
877 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
878 jclass cls = initClass(curEnv);
880 throw GiwsException::JniCallMethodException(curEnv);
883 static jmethodID voidlimitDirectBufferjintintID = curEnv->GetStaticMethodID(cls, "limitDirectBuffer", "(I)V" ) ;
884 if (voidlimitDirectBufferjintintID == NULL) {
885 throw GiwsException::JniMethodNotFoundException(curEnv, "limitDirectBuffer");
888 curEnv->CallStaticVoidMethod(cls, voidlimitDirectBufferjintintID ,id);
889 if (curEnv->ExceptionCheck()) {
890 throw GiwsException::JniCallMethodException(curEnv);
894 int ScilabJavaObject::isUnwrappable (JavaVM * jvm_, int id){
896 JNIEnv * curEnv = NULL;
897 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
898 jclass cls = initClass(curEnv);
900 throw GiwsException::JniCallMethodException(curEnv);
903 static jmethodID jintisUnwrappablejintintID = curEnv->GetStaticMethodID(cls, "isUnwrappable", "(I)I" ) ;
904 if (jintisUnwrappablejintintID == NULL) {
905 throw GiwsException::JniMethodNotFoundException(curEnv, "isUnwrappable");
908 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintisUnwrappablejintintID ,id));
909 if (curEnv->ExceptionCheck()) {
910 throw GiwsException::JniCallMethodException(curEnv);
916 int ScilabJavaObject::wrap (JavaVM * jvm_, double x){
918 JNIEnv * curEnv = NULL;
919 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
920 jclass cls = initClass(curEnv);
922 throw GiwsException::JniCallMethodException(curEnv);
925 static jmethodID jintwrapjdoubledoubleID = curEnv->GetStaticMethodID(cls, "wrap", "(D)I" ) ;
926 if (jintwrapjdoubledoubleID == NULL) {
927 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
930 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjdoubledoubleID ,x));
931 if (curEnv->ExceptionCheck()) {
932 throw GiwsException::JniCallMethodException(curEnv);
938 int ScilabJavaObject::wrap (JavaVM * jvm_, double const* x, int xSize){
940 JNIEnv * curEnv = NULL;
941 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
942 jclass cls = initClass(curEnv);
944 throw GiwsException::JniCallMethodException(curEnv);
947 static jmethodID jintwrapjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "wrap", "([D)I" ) ;
948 if (jintwrapjdoubleArray_doubledoubleID == NULL) {
949 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
952 jdoubleArray x_ = curEnv->NewDoubleArray( xSize ) ;
956 // check that allocation succeed
957 throw GiwsException::JniBadAllocException(curEnv);
960 curEnv->SetDoubleArrayRegion( x_, 0, xSize, (jdouble*)(x) ) ;
963 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjdoubleArray_doubledoubleID ,x_));
964 curEnv->DeleteLocalRef(x_);
965 if (curEnv->ExceptionCheck()) {
966 throw GiwsException::JniCallMethodException(curEnv);
972 int ScilabJavaObject::wrap (JavaVM * jvm_, double const* const* x, int xSize, int xSizeCol){
974 JNIEnv * curEnv = NULL;
975 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
976 jclass cls = initClass(curEnv);
978 throw GiwsException::JniCallMethodException(curEnv);
981 static jmethodID jintwrapjobjectArray__doubledoubleID = curEnv->GetStaticMethodID(cls, "wrap", "([[D)I" ) ;
982 if (jintwrapjobjectArray__doubledoubleID == NULL) {
983 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
986 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[D"),NULL);
990 // check that allocation succeed
991 throw GiwsException::JniBadAllocException(curEnv);
994 for (int i=0; i<xSize; i++){
996 jdoubleArray xLocal = curEnv->NewDoubleArray( xSizeCol ) ;
1000 // check that allocation succeed
1001 curEnv->DeleteLocalRef(x_);
1002 throw GiwsException::JniBadAllocException(curEnv);
1005 curEnv->SetDoubleArrayRegion( xLocal, 0, xSizeCol, (jdouble*)(x[i]) ) ;
1006 curEnv->SetObjectArrayElement(x_, i, xLocal);
1007 curEnv->DeleteLocalRef(xLocal);
1010 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__doubledoubleID ,x_));
1011 curEnv->DeleteLocalRef(x_);
1012 if (curEnv->ExceptionCheck()) {
1013 throw GiwsException::JniCallMethodException(curEnv);
1019 int ScilabJavaObject::wrap (JavaVM * jvm_, int x){
1021 JNIEnv * curEnv = NULL;
1022 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1023 jclass cls = initClass(curEnv);
1025 throw GiwsException::JniCallMethodException(curEnv);
1028 static jmethodID jintwrapjintintID = curEnv->GetStaticMethodID(cls, "wrap", "(I)I" ) ;
1029 if (jintwrapjintintID == NULL) {
1030 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1033 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjintintID ,x));
1034 if (curEnv->ExceptionCheck()) {
1035 throw GiwsException::JniCallMethodException(curEnv);
1041 int ScilabJavaObject::wrap (JavaVM * jvm_, int const* x, int xSize){
1043 JNIEnv * curEnv = NULL;
1044 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1045 jclass cls = initClass(curEnv);
1047 throw GiwsException::JniCallMethodException(curEnv);
1050 static jmethodID jintwrapjintArray_intintID = curEnv->GetStaticMethodID(cls, "wrap", "([I)I" ) ;
1051 if (jintwrapjintArray_intintID == NULL) {
1052 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1055 jintArray x_ = curEnv->NewIntArray( xSize ) ;
1059 // check that allocation succeed
1060 throw GiwsException::JniBadAllocException(curEnv);
1063 curEnv->SetIntArrayRegion( x_, 0, xSize, (jint*)(x) ) ;
1066 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjintArray_intintID ,x_));
1067 curEnv->DeleteLocalRef(x_);
1068 if (curEnv->ExceptionCheck()) {
1069 throw GiwsException::JniCallMethodException(curEnv);
1075 int ScilabJavaObject::wrap (JavaVM * jvm_, int const* const* x, int xSize, int xSizeCol){
1077 JNIEnv * curEnv = NULL;
1078 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1079 jclass cls = initClass(curEnv);
1081 throw GiwsException::JniCallMethodException(curEnv);
1084 static jmethodID jintwrapjobjectArray__intintID = curEnv->GetStaticMethodID(cls, "wrap", "([[I)I" ) ;
1085 if (jintwrapjobjectArray__intintID == NULL) {
1086 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1089 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[I"),NULL);
1093 // check that allocation succeed
1094 throw GiwsException::JniBadAllocException(curEnv);
1097 for (int i=0; i<xSize; i++){
1099 jintArray xLocal = curEnv->NewIntArray( xSizeCol ) ;
1103 // check that allocation succeed
1104 curEnv->DeleteLocalRef(x_);
1105 throw GiwsException::JniBadAllocException(curEnv);
1108 curEnv->SetIntArrayRegion( xLocal, 0, xSizeCol, (jint*)(x[i]) ) ;
1109 curEnv->SetObjectArrayElement(x_, i, xLocal);
1110 curEnv->DeleteLocalRef(xLocal);
1113 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__intintID ,x_));
1114 curEnv->DeleteLocalRef(x_);
1115 if (curEnv->ExceptionCheck()) {
1116 throw GiwsException::JniCallMethodException(curEnv);
1122 int ScilabJavaObject::wrap (JavaVM * jvm_, byte x){
1124 JNIEnv * curEnv = NULL;
1125 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1126 jclass cls = initClass(curEnv);
1128 throw GiwsException::JniCallMethodException(curEnv);
1131 static jmethodID jintwrapjbytebyteID = curEnv->GetStaticMethodID(cls, "wrap", "(B)I" ) ;
1132 if (jintwrapjbytebyteID == NULL) {
1133 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1136 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbytebyteID ,x));
1137 if (curEnv->ExceptionCheck()) {
1138 throw GiwsException::JniCallMethodException(curEnv);
1144 int ScilabJavaObject::wrap (JavaVM * jvm_, byte const* x, int xSize){
1146 JNIEnv * curEnv = NULL;
1147 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1148 jclass cls = initClass(curEnv);
1150 throw GiwsException::JniCallMethodException(curEnv);
1153 static jmethodID jintwrapjbyteArray_bytebyteID = curEnv->GetStaticMethodID(cls, "wrap", "([B)I" ) ;
1154 if (jintwrapjbyteArray_bytebyteID == NULL) {
1155 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1158 jbyteArray x_ = curEnv->NewByteArray( xSize ) ;
1162 // check that allocation succeed
1163 throw GiwsException::JniBadAllocException(curEnv);
1166 curEnv->SetByteArrayRegion( x_, 0, xSize, (jbyte*)(x) ) ;
1169 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbyteArray_bytebyteID ,x_));
1170 curEnv->DeleteLocalRef(x_);
1171 if (curEnv->ExceptionCheck()) {
1172 throw GiwsException::JniCallMethodException(curEnv);
1178 int ScilabJavaObject::wrap (JavaVM * jvm_, byte const* const* x, int xSize, int xSizeCol){
1180 JNIEnv * curEnv = NULL;
1181 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1182 jclass cls = initClass(curEnv);
1184 throw GiwsException::JniCallMethodException(curEnv);
1187 static jmethodID jintwrapjobjectArray__bytebyteID = curEnv->GetStaticMethodID(cls, "wrap", "([[B)I" ) ;
1188 if (jintwrapjobjectArray__bytebyteID == NULL) {
1189 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1192 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[B"),NULL);
1196 // check that allocation succeed
1197 throw GiwsException::JniBadAllocException(curEnv);
1200 for (int i=0; i<xSize; i++){
1202 jbyteArray xLocal = curEnv->NewByteArray( xSizeCol ) ;
1206 // check that allocation succeed
1207 curEnv->DeleteLocalRef(x_);
1208 throw GiwsException::JniBadAllocException(curEnv);
1211 curEnv->SetByteArrayRegion( xLocal, 0, xSizeCol, (jbyte*)(x[i]) ) ;
1212 curEnv->SetObjectArrayElement(x_, i, xLocal);
1213 curEnv->DeleteLocalRef(xLocal);
1216 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__bytebyteID ,x_));
1217 curEnv->DeleteLocalRef(x_);
1218 if (curEnv->ExceptionCheck()) {
1219 throw GiwsException::JniCallMethodException(curEnv);
1225 int ScilabJavaObject::wrap (JavaVM * jvm_, short x){
1227 JNIEnv * curEnv = NULL;
1228 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1229 jclass cls = initClass(curEnv);
1231 throw GiwsException::JniCallMethodException(curEnv);
1234 static jmethodID jintwrapjshortshortID = curEnv->GetStaticMethodID(cls, "wrap", "(S)I" ) ;
1235 if (jintwrapjshortshortID == NULL) {
1236 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1239 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjshortshortID ,x));
1240 if (curEnv->ExceptionCheck()) {
1241 throw GiwsException::JniCallMethodException(curEnv);
1247 int ScilabJavaObject::wrap (JavaVM * jvm_, short const* x, int xSize){
1249 JNIEnv * curEnv = NULL;
1250 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1251 jclass cls = initClass(curEnv);
1253 throw GiwsException::JniCallMethodException(curEnv);
1256 static jmethodID jintwrapjshortArray_shortshortID = curEnv->GetStaticMethodID(cls, "wrap", "([S)I" ) ;
1257 if (jintwrapjshortArray_shortshortID == NULL) {
1258 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1261 jshortArray x_ = curEnv->NewShortArray( xSize ) ;
1265 // check that allocation succeed
1266 throw GiwsException::JniBadAllocException(curEnv);
1269 curEnv->SetShortArrayRegion( x_, 0, xSize, (jshort*)(x) ) ;
1272 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjshortArray_shortshortID ,x_));
1273 curEnv->DeleteLocalRef(x_);
1274 if (curEnv->ExceptionCheck()) {
1275 throw GiwsException::JniCallMethodException(curEnv);
1281 int ScilabJavaObject::wrap (JavaVM * jvm_, short const* const* x, int xSize, int xSizeCol){
1283 JNIEnv * curEnv = NULL;
1284 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1285 jclass cls = initClass(curEnv);
1287 throw GiwsException::JniCallMethodException(curEnv);
1290 static jmethodID jintwrapjobjectArray__shortshortID = curEnv->GetStaticMethodID(cls, "wrap", "([[S)I" ) ;
1291 if (jintwrapjobjectArray__shortshortID == NULL) {
1292 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1295 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[S"),NULL);
1299 // check that allocation succeed
1300 throw GiwsException::JniBadAllocException(curEnv);
1303 for (int i=0; i<xSize; i++){
1305 jshortArray xLocal = curEnv->NewShortArray( xSizeCol ) ;
1309 // check that allocation succeed
1310 curEnv->DeleteLocalRef(x_);
1311 throw GiwsException::JniBadAllocException(curEnv);
1314 curEnv->SetShortArrayRegion( xLocal, 0, xSizeCol, (jshort*)(x[i]) ) ;
1315 curEnv->SetObjectArrayElement(x_, i, xLocal);
1316 curEnv->DeleteLocalRef(xLocal);
1319 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__shortshortID ,x_));
1320 curEnv->DeleteLocalRef(x_);
1321 if (curEnv->ExceptionCheck()) {
1322 throw GiwsException::JniCallMethodException(curEnv);
1328 int ScilabJavaObject::wrap (JavaVM * jvm_, char const* x){
1330 JNIEnv * curEnv = NULL;
1331 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1332 jclass cls = initClass(curEnv);
1334 throw GiwsException::JniCallMethodException(curEnv);
1337 static jmethodID jintwrapjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrap", "(Ljava/lang/String;)I" ) ;
1338 if (jintwrapjstringjava_lang_StringID == NULL) {
1339 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1342 jstring x_ = curEnv->NewStringUTF( x );
1343 if (x != NULL && x_ == NULL)
1345 throw GiwsException::JniBadAllocException(curEnv);
1349 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjstringjava_lang_StringID ,x_));
1350 curEnv->DeleteLocalRef(x_);
1351 if (curEnv->ExceptionCheck()) {
1352 throw GiwsException::JniCallMethodException(curEnv);
1358 int ScilabJavaObject::wrap (JavaVM * jvm_, char const* const* x, int xSize){
1360 JNIEnv * curEnv = NULL;
1361 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1362 jclass cls = initClass(curEnv);
1364 throw GiwsException::JniCallMethodException(curEnv);
1367 static jmethodID jintwrapjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrap", "([Ljava/lang/String;)I" ) ;
1368 if (jintwrapjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
1369 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1371 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
1373 // create java array of strings.
1374 jobjectArray x_ = curEnv->NewObjectArray( xSize, stringArrayClass, NULL);
1377 throw GiwsException::JniBadAllocException(curEnv);
1380 // convert each char * to java strings and fill the java array.
1381 for ( int i = 0; i < xSize; i++)
1383 jstring TempString = curEnv->NewStringUTF( x[i] );
1384 if (TempString == NULL)
1386 throw GiwsException::JniBadAllocException(curEnv);
1389 curEnv->SetObjectArrayElement( x_, i, TempString);
1391 // avoid keeping reference on too many strings
1392 curEnv->DeleteLocalRef(TempString);
1394 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray_java_lang_Stringjava_lang_StringID ,x_));
1395 curEnv->DeleteLocalRef(stringArrayClass);
1396 curEnv->DeleteLocalRef(x_);
1397 if (curEnv->ExceptionCheck()) {
1398 throw GiwsException::JniCallMethodException(curEnv);
1404 int ScilabJavaObject::wrap (JavaVM * jvm_, char const* const* const* x, int xSize, int xSizeCol){
1406 JNIEnv * curEnv = NULL;
1407 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1408 jclass cls = initClass(curEnv);
1410 throw GiwsException::JniCallMethodException(curEnv);
1413 static jmethodID jintwrapjobjectArray__java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "wrap", "([[Ljava/lang/String;)I" ) ;
1414 if (jintwrapjobjectArray__java_lang_Stringjava_lang_StringID == NULL) {
1415 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1417 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
1418 // create java array of array of strings.
1419 jobjectArray x_ = curEnv->NewObjectArray( xSize, curEnv->FindClass("[Ljava/lang/String;"), NULL);
1422 throw GiwsException::JniBadAllocException(curEnv);
1425 for ( int i = 0; i < xSize; i++)
1427 jobjectArray xLocal = curEnv->NewObjectArray( xSizeCol, stringArrayClass, NULL);
1428 // convert each char * to java strings and fill the java array.
1429 for ( int j = 0; j < xSizeCol; j++) {
1430 jstring TempString = curEnv->NewStringUTF( x[i][j] );
1432 if (TempString == NULL)
1434 throw GiwsException::JniBadAllocException(curEnv);
1437 curEnv->SetObjectArrayElement( xLocal, j, TempString);
1439 // avoid keeping reference on too many strings
1440 curEnv->DeleteLocalRef(TempString);
1442 curEnv->SetObjectArrayElement(x_, i, xLocal);
1443 curEnv->DeleteLocalRef(xLocal);
1446 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__java_lang_Stringjava_lang_StringID ,x_));
1447 curEnv->DeleteLocalRef(stringArrayClass);
1448 curEnv->DeleteLocalRef(x_);
1449 if (curEnv->ExceptionCheck()) {
1450 throw GiwsException::JniCallMethodException(curEnv);
1456 int ScilabJavaObject::wrap (JavaVM * jvm_, bool x){
1458 JNIEnv * curEnv = NULL;
1459 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1460 jclass cls = initClass(curEnv);
1462 throw GiwsException::JniCallMethodException(curEnv);
1465 static jmethodID jintwrapjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "wrap", "(Z)I" ) ;
1466 if (jintwrapjbooleanbooleanID == NULL) {
1467 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1470 jboolean x_ = (static_cast<bool>(x) ? JNI_TRUE : JNI_FALSE);
1472 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbooleanbooleanID ,x_));
1473 if (curEnv->ExceptionCheck()) {
1474 throw GiwsException::JniCallMethodException(curEnv);
1480 int ScilabJavaObject::wrap (JavaVM * jvm_, bool const* x, int xSize){
1482 JNIEnv * curEnv = NULL;
1483 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1484 jclass cls = initClass(curEnv);
1486 throw GiwsException::JniCallMethodException(curEnv);
1489 static jmethodID jintwrapjbooleanArray_booleanbooleanID = curEnv->GetStaticMethodID(cls, "wrap", "([Z)I" ) ;
1490 if (jintwrapjbooleanArray_booleanbooleanID == NULL) {
1491 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1494 jbooleanArray x_ = curEnv->NewBooleanArray( xSize ) ;
1495 curEnv->SetBooleanArrayRegion( x_, 0, xSize, (jboolean*)x ) ;
1497 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjbooleanArray_booleanbooleanID ,x_));
1498 curEnv->DeleteLocalRef(x_);
1499 if (curEnv->ExceptionCheck()) {
1500 throw GiwsException::JniCallMethodException(curEnv);
1506 int ScilabJavaObject::wrap (JavaVM * jvm_, bool const* const* x, int xSize, int xSizeCol){
1508 JNIEnv * curEnv = NULL;
1509 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1510 jclass cls = initClass(curEnv);
1512 throw GiwsException::JniCallMethodException(curEnv);
1515 static jmethodID jintwrapjobjectArray__booleanbooleanID = curEnv->GetStaticMethodID(cls, "wrap", "([[Z)I" ) ;
1516 if (jintwrapjobjectArray__booleanbooleanID == NULL) {
1517 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1520 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[Z"),NULL);
1521 for (int i=0; i<xSize; i++){
1522 jbooleanArray xLocal = curEnv->NewBooleanArray( xSizeCol ) ;
1523 curEnv->SetBooleanArrayRegion( xLocal, 0, xSizeCol, (jboolean*)(x[i]) ) ;
1524 curEnv->SetObjectArrayElement(x_, i, xLocal);
1525 curEnv->DeleteLocalRef(xLocal);
1528 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__booleanbooleanID ,x_));
1529 curEnv->DeleteLocalRef(x_);
1530 if (curEnv->ExceptionCheck()) {
1531 throw GiwsException::JniCallMethodException(curEnv);
1537 int ScilabJavaObject::wrap (JavaVM * jvm_, unsigned short x){
1539 JNIEnv * curEnv = NULL;
1540 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1541 jclass cls = initClass(curEnv);
1543 throw GiwsException::JniCallMethodException(curEnv);
1546 static jmethodID jintwrapjcharcharID = curEnv->GetStaticMethodID(cls, "wrap", "(C)I" ) ;
1547 if (jintwrapjcharcharID == NULL) {
1548 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1551 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjcharcharID ,x));
1552 if (curEnv->ExceptionCheck()) {
1553 throw GiwsException::JniCallMethodException(curEnv);
1559 int ScilabJavaObject::wrap (JavaVM * jvm_, unsigned short const* x, int xSize){
1561 JNIEnv * curEnv = NULL;
1562 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1563 jclass cls = initClass(curEnv);
1565 throw GiwsException::JniCallMethodException(curEnv);
1568 static jmethodID jintwrapjcharArray_charcharID = curEnv->GetStaticMethodID(cls, "wrap", "([C)I" ) ;
1569 if (jintwrapjcharArray_charcharID == NULL) {
1570 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1573 jcharArray x_ = curEnv->NewCharArray( xSize ) ;
1577 // check that allocation succeed
1578 throw GiwsException::JniBadAllocException(curEnv);
1581 curEnv->SetCharArrayRegion( x_, 0, xSize, (jchar*)(x) ) ;
1584 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjcharArray_charcharID ,x_));
1585 curEnv->DeleteLocalRef(x_);
1586 if (curEnv->ExceptionCheck()) {
1587 throw GiwsException::JniCallMethodException(curEnv);
1593 int ScilabJavaObject::wrap (JavaVM * jvm_, unsigned short const* const* x, int xSize, int xSizeCol){
1595 JNIEnv * curEnv = NULL;
1596 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1597 jclass cls = initClass(curEnv);
1599 throw GiwsException::JniCallMethodException(curEnv);
1602 static jmethodID jintwrapjobjectArray__charcharID = curEnv->GetStaticMethodID(cls, "wrap", "([[C)I" ) ;
1603 if (jintwrapjobjectArray__charcharID == NULL) {
1604 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1607 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[C"),NULL);
1611 // check that allocation succeed
1612 throw GiwsException::JniBadAllocException(curEnv);
1615 for (int i=0; i<xSize; i++){
1617 jcharArray xLocal = curEnv->NewCharArray( xSizeCol ) ;
1621 // check that allocation succeed
1622 curEnv->DeleteLocalRef(x_);
1623 throw GiwsException::JniBadAllocException(curEnv);
1626 curEnv->SetCharArrayRegion( xLocal, 0, xSizeCol, (jchar*)(x[i]) ) ;
1627 curEnv->SetObjectArrayElement(x_, i, xLocal);
1628 curEnv->DeleteLocalRef(xLocal);
1631 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__charcharID ,x_));
1632 curEnv->DeleteLocalRef(x_);
1633 if (curEnv->ExceptionCheck()) {
1634 throw GiwsException::JniCallMethodException(curEnv);
1640 int ScilabJavaObject::wrap (JavaVM * jvm_, float x){
1642 JNIEnv * curEnv = NULL;
1643 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1644 jclass cls = initClass(curEnv);
1646 throw GiwsException::JniCallMethodException(curEnv);
1649 static jmethodID jintwrapjfloatfloatID = curEnv->GetStaticMethodID(cls, "wrap", "(F)I" ) ;
1650 if (jintwrapjfloatfloatID == NULL) {
1651 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1654 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjfloatfloatID ,x));
1655 if (curEnv->ExceptionCheck()) {
1656 throw GiwsException::JniCallMethodException(curEnv);
1662 int ScilabJavaObject::wrap (JavaVM * jvm_, float const* x, int xSize){
1664 JNIEnv * curEnv = NULL;
1665 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1666 jclass cls = initClass(curEnv);
1668 throw GiwsException::JniCallMethodException(curEnv);
1671 static jmethodID jintwrapjfloatArray_floatfloatID = curEnv->GetStaticMethodID(cls, "wrap", "([F)I" ) ;
1672 if (jintwrapjfloatArray_floatfloatID == NULL) {
1673 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1676 jfloatArray x_ = curEnv->NewFloatArray( xSize ) ;
1680 // check that allocation succeed
1681 throw GiwsException::JniBadAllocException(curEnv);
1684 curEnv->SetFloatArrayRegion( x_, 0, xSize, (jfloat*)(x) ) ;
1687 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjfloatArray_floatfloatID ,x_));
1688 curEnv->DeleteLocalRef(x_);
1689 if (curEnv->ExceptionCheck()) {
1690 throw GiwsException::JniCallMethodException(curEnv);
1696 int ScilabJavaObject::wrap (JavaVM * jvm_, float const* const* x, int xSize, int xSizeCol){
1698 JNIEnv * curEnv = NULL;
1699 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1700 jclass cls = initClass(curEnv);
1702 throw GiwsException::JniCallMethodException(curEnv);
1705 static jmethodID jintwrapjobjectArray__floatfloatID = curEnv->GetStaticMethodID(cls, "wrap", "([[F)I" ) ;
1706 if (jintwrapjobjectArray__floatfloatID == NULL) {
1707 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1710 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[F"),NULL);
1714 // check that allocation succeed
1715 throw GiwsException::JniBadAllocException(curEnv);
1718 for (int i=0; i<xSize; i++){
1720 jfloatArray xLocal = curEnv->NewFloatArray( xSizeCol ) ;
1724 // check that allocation succeed
1725 curEnv->DeleteLocalRef(x_);
1726 throw GiwsException::JniBadAllocException(curEnv);
1729 curEnv->SetFloatArrayRegion( xLocal, 0, xSizeCol, (jfloat*)(x[i]) ) ;
1730 curEnv->SetObjectArrayElement(x_, i, xLocal);
1731 curEnv->DeleteLocalRef(xLocal);
1734 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__floatfloatID ,x_));
1735 curEnv->DeleteLocalRef(x_);
1736 if (curEnv->ExceptionCheck()) {
1737 throw GiwsException::JniCallMethodException(curEnv);
1743 int ScilabJavaObject::wrap (JavaVM * jvm_, long long x){
1745 JNIEnv * curEnv = NULL;
1746 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1747 jclass cls = initClass(curEnv);
1749 throw GiwsException::JniCallMethodException(curEnv);
1752 static jmethodID jintwrapjlonglongID = curEnv->GetStaticMethodID(cls, "wrap", "(J)I" ) ;
1753 if (jintwrapjlonglongID == NULL) {
1754 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1757 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjlonglongID ,x));
1758 if (curEnv->ExceptionCheck()) {
1759 throw GiwsException::JniCallMethodException(curEnv);
1765 int ScilabJavaObject::wrap (JavaVM * jvm_, long long const* x, int xSize){
1767 JNIEnv * curEnv = NULL;
1768 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1769 jclass cls = initClass(curEnv);
1771 throw GiwsException::JniCallMethodException(curEnv);
1774 static jmethodID jintwrapjlongArray_longlongID = curEnv->GetStaticMethodID(cls, "wrap", "([J)I" ) ;
1775 if (jintwrapjlongArray_longlongID == NULL) {
1776 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1779 jlongArray x_ = curEnv->NewLongArray( xSize ) ;
1783 // check that allocation succeed
1784 throw GiwsException::JniBadAllocException(curEnv);
1787 curEnv->SetLongArrayRegion( x_, 0, xSize, (jlong*)(x) ) ;
1790 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjlongArray_longlongID ,x_));
1791 curEnv->DeleteLocalRef(x_);
1792 if (curEnv->ExceptionCheck()) {
1793 throw GiwsException::JniCallMethodException(curEnv);
1799 int ScilabJavaObject::wrap (JavaVM * jvm_, long long const* const* x, int xSize, int xSizeCol){
1801 JNIEnv * curEnv = NULL;
1802 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1803 jclass cls = initClass(curEnv);
1805 throw GiwsException::JniCallMethodException(curEnv);
1808 static jmethodID jintwrapjobjectArray__longlongID = curEnv->GetStaticMethodID(cls, "wrap", "([[J)I" ) ;
1809 if (jintwrapjobjectArray__longlongID == NULL) {
1810 throw GiwsException::JniMethodNotFoundException(curEnv, "wrap");
1813 jobjectArray x_ = curEnv->NewObjectArray(xSize, curEnv->FindClass("[J"),NULL);
1817 // check that allocation succeed
1818 throw GiwsException::JniBadAllocException(curEnv);
1821 for (int i=0; i<xSize; i++){
1823 jlongArray xLocal = curEnv->NewLongArray( xSizeCol ) ;
1827 // check that allocation succeed
1828 curEnv->DeleteLocalRef(x_);
1829 throw GiwsException::JniBadAllocException(curEnv);
1832 curEnv->SetLongArrayRegion( xLocal, 0, xSizeCol, (jlong*)(x[i]) ) ;
1833 curEnv->SetObjectArrayElement(x_, i, xLocal);
1834 curEnv->DeleteLocalRef(xLocal);
1837 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapjobjectArray__longlongID ,x_));
1838 curEnv->DeleteLocalRef(x_);
1839 if (curEnv->ExceptionCheck()) {
1840 throw GiwsException::JniCallMethodException(curEnv);
1846 int ScilabJavaObject::wrapList (JavaVM * jvm_, int const* ids, int idsSize){
1848 JNIEnv * curEnv = NULL;
1849 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1850 jclass cls = initClass(curEnv);
1852 throw GiwsException::JniCallMethodException(curEnv);
1855 static jmethodID jintwrapListjintArray_intintID = curEnv->GetStaticMethodID(cls, "wrapList", "([I)I" ) ;
1856 if (jintwrapListjintArray_intintID == NULL) {
1857 throw GiwsException::JniMethodNotFoundException(curEnv, "wrapList");
1860 jintArray ids_ = curEnv->NewIntArray( idsSize ) ;
1864 // check that allocation succeed
1865 throw GiwsException::JniBadAllocException(curEnv);
1868 curEnv->SetIntArrayRegion( ids_, 0, idsSize, (jint*)(ids) ) ;
1871 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapListjintArray_intintID ,ids_));
1872 curEnv->DeleteLocalRef(ids_);
1873 if (curEnv->ExceptionCheck()) {
1874 throw GiwsException::JniCallMethodException(curEnv);
1880 int ScilabJavaObject::wrapPoly (JavaVM * jvm_, double const* coefs, int coefsSize){
1882 JNIEnv * curEnv = NULL;
1883 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1884 jclass cls = initClass(curEnv);
1886 throw GiwsException::JniCallMethodException(curEnv);
1889 static jmethodID jintwrapPolyjdoubleArray_doubledoubleID = curEnv->GetStaticMethodID(cls, "wrapPoly", "([D)I" ) ;
1890 if (jintwrapPolyjdoubleArray_doubledoubleID == NULL) {
1891 throw GiwsException::JniMethodNotFoundException(curEnv, "wrapPoly");
1894 jdoubleArray coefs_ = curEnv->NewDoubleArray( coefsSize ) ;
1898 // check that allocation succeed
1899 throw GiwsException::JniBadAllocException(curEnv);
1902 curEnv->SetDoubleArrayRegion( coefs_, 0, coefsSize, (jdouble*)(coefs) ) ;
1905 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintwrapPolyjdoubleArray_doubledoubleID ,coefs_));
1906 curEnv->DeleteLocalRef(coefs_);
1907 if (curEnv->ExceptionCheck()) {
1908 throw GiwsException::JniCallMethodException(curEnv);
1914 char** ScilabJavaObject::getAccessibleFields (JavaVM * jvm_, int id, int *lenRow){
1916 JNIEnv * curEnv = NULL;
1917 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1918 jclass cls = initClass(curEnv);
1920 throw GiwsException::JniCallMethodException(curEnv);
1923 static jmethodID jobjectArray_getAccessibleFieldsjintintID = curEnv->GetStaticMethodID(cls, "getAccessibleFields", "(I)[Ljava/lang/String;" ) ;
1924 if (jobjectArray_getAccessibleFieldsjintintID == NULL) {
1925 throw GiwsException::JniMethodNotFoundException(curEnv, "getAccessibleFields");
1928 jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray_getAccessibleFieldsjintintID ,id));
1929 if (curEnv->ExceptionCheck()) {
1930 throw GiwsException::JniCallMethodException(curEnv);
1932 * lenRow = curEnv->GetArrayLength(res);
1934 char **arrayOfString;
1935 arrayOfString = new char *[*lenRow];
1936 for (jsize i = 0; i < *lenRow; i++){
1937 jstring resString = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(res, i));
1938 const char *tempString = curEnv->GetStringUTFChars(resString, 0);
1939 arrayOfString[i] = new char[strlen(tempString) + 1];
1941 strcpy(arrayOfString[i], tempString);
1942 curEnv->ReleaseStringUTFChars(resString, tempString);
1943 curEnv->DeleteLocalRef(resString);
1945 if (curEnv->ExceptionCheck()) {
1946 delete[] arrayOfString;
1947 throw GiwsException::JniCallMethodException(curEnv);
1949 curEnv->DeleteLocalRef(res);
1950 return arrayOfString;
1952 curEnv->DeleteLocalRef(res);
1957 char** ScilabJavaObject::getAccessibleMethods (JavaVM * jvm_, int id, int *lenRow){
1959 JNIEnv * curEnv = NULL;
1960 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
1961 jclass cls = initClass(curEnv);
1963 throw GiwsException::JniCallMethodException(curEnv);
1966 static jmethodID jobjectArray_getAccessibleMethodsjintintID = curEnv->GetStaticMethodID(cls, "getAccessibleMethods", "(I)[Ljava/lang/String;" ) ;
1967 if (jobjectArray_getAccessibleMethodsjintintID == NULL) {
1968 throw GiwsException::JniMethodNotFoundException(curEnv, "getAccessibleMethods");
1971 jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray_getAccessibleMethodsjintintID ,id));
1972 if (curEnv->ExceptionCheck()) {
1973 throw GiwsException::JniCallMethodException(curEnv);
1975 * lenRow = curEnv->GetArrayLength(res);
1977 char **arrayOfString;
1978 arrayOfString = new char *[*lenRow];
1979 for (jsize i = 0; i < *lenRow; i++){
1980 jstring resString = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(res, i));
1981 const char *tempString = curEnv->GetStringUTFChars(resString, 0);
1982 arrayOfString[i] = new char[strlen(tempString) + 1];
1984 strcpy(arrayOfString[i], tempString);
1985 curEnv->ReleaseStringUTFChars(resString, tempString);
1986 curEnv->DeleteLocalRef(resString);
1988 if (curEnv->ExceptionCheck()) {
1989 delete[] arrayOfString;
1990 throw GiwsException::JniCallMethodException(curEnv);
1992 curEnv->DeleteLocalRef(res);
1993 return arrayOfString;
1995 curEnv->DeleteLocalRef(res);
2000 char** ScilabJavaObject::getCompletion (JavaVM * jvm_, int id, char const* const* fieldPath, int fieldPathSize, int *lenRow){
2002 JNIEnv * curEnv = NULL;
2003 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
2004 jclass cls = initClass(curEnv);
2006 throw GiwsException::JniCallMethodException(curEnv);
2009 static jmethodID jobjectArray_getCompletionjintintjobjectArray_java_lang_Stringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "getCompletion", "(I[Ljava/lang/String;)[Ljava/lang/String;" ) ;
2010 if (jobjectArray_getCompletionjintintjobjectArray_java_lang_Stringjava_lang_StringID == NULL) {
2011 throw GiwsException::JniMethodNotFoundException(curEnv, "getCompletion");
2013 jclass stringArrayClass = curEnv->FindClass("java/lang/String");
2015 // create java array of strings.
2016 jobjectArray fieldPath_ = curEnv->NewObjectArray( fieldPathSize, stringArrayClass, NULL);
2017 if (fieldPath_ == NULL)
2019 throw GiwsException::JniBadAllocException(curEnv);
2022 // convert each char * to java strings and fill the java array.
2023 for ( int i = 0; i < fieldPathSize; i++)
2025 jstring TempString = curEnv->NewStringUTF( fieldPath[i] );
2026 if (TempString == NULL)
2028 throw GiwsException::JniBadAllocException(curEnv);
2031 curEnv->SetObjectArrayElement( fieldPath_, i, TempString);
2033 // avoid keeping reference on too many strings
2034 curEnv->DeleteLocalRef(TempString);
2036 jobjectArray res = static_cast<jobjectArray>( curEnv->CallStaticObjectMethod(cls, jobjectArray_getCompletionjintintjobjectArray_java_lang_Stringjava_lang_StringID ,id, fieldPath_));
2037 if (curEnv->ExceptionCheck()) {
2038 throw GiwsException::JniCallMethodException(curEnv);
2040 * lenRow = curEnv->GetArrayLength(res);
2042 char **arrayOfString;
2043 arrayOfString = new char *[*lenRow];
2044 for (jsize i = 0; i < *lenRow; i++){
2045 jstring resString = reinterpret_cast<jstring>(curEnv->GetObjectArrayElement(res, i));
2046 const char *tempString = curEnv->GetStringUTFChars(resString, 0);
2047 arrayOfString[i] = new char[strlen(tempString) + 1];
2049 strcpy(arrayOfString[i], tempString);
2050 curEnv->ReleaseStringUTFChars(resString, tempString);
2051 curEnv->DeleteLocalRef(resString);
2053 curEnv->DeleteLocalRef(stringArrayClass);
2054 curEnv->DeleteLocalRef(fieldPath_);
2055 if (curEnv->ExceptionCheck()) {
2056 delete[] arrayOfString;
2057 throw GiwsException::JniCallMethodException(curEnv);
2059 curEnv->DeleteLocalRef(res);
2060 return arrayOfString;
2062 curEnv->DeleteLocalRef(res);