1 #include "Jxgetmouse.hxx"
2 /* Generated by GIWS (version 2.0.2) with command:
3 giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/Jxgetmouse.giws.xml
4 */
5 /*
6
7 This is generated code.
8
9 This software is a computer program whose purpose is to hide the complexity
10 of accessing Java objects/methods from C++ code.
11
12 Copyright (C) 2012 - 2016 - Scilab Enterprises
13
14 This file is hereby licensed under the terms of the GNU GPL v2.0,
15 pursuant to article 5.3.4 of the CeCILL v.2.1.
16 This file was originally licensed under the terms of the CeCILL v2.1,
17 and continues to be available under such terms.
18 For more information, see the COPYING file which you should have received
19 along with this program.
20 */
21
22 namespace org_scilab_modules_gui_events {
23
24 // Static declarations (if any)
25
26 // Returns the current env
27
getCurrentEnv()28 JNIEnv * Jxgetmouse::getCurrentEnv() {
29 JNIEnv * curEnv = NULL;
30 jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
31 if (res != JNI_OK) {
32 throw GiwsException::JniException(getCurrentEnv());
33 }
34 return curEnv;
35 }
36 // Destructor
37
~Jxgetmouse()38 Jxgetmouse::~Jxgetmouse() {
39 JNIEnv * curEnv = NULL;
40 this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
41 curEnv->DeleteGlobalRef(this->instance);
42 curEnv->DeleteGlobalRef(this->instanceClass);
43 }
44 // Constructors
Jxgetmouse(JavaVM * jvm_)45 Jxgetmouse::Jxgetmouse(JavaVM * jvm_) {
46 jmethodID constructObject = NULL ;
47 jobject localInstance ;
48 jclass localClass ;
49
50 const std::string construct="<init>";
51 const std::string param="()V";
52 jvm=jvm_;
53
54 JNIEnv * curEnv = getCurrentEnv();
55
56 localClass = curEnv->FindClass( this->className().c_str() ) ;
57 if (localClass == NULL) {
58 throw GiwsException::JniClassNotFoundException(curEnv, this->className());
59 }
60
61 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
62
63 /* localClass is not needed anymore */
64 curEnv->DeleteLocalRef(localClass);
65
66 if (this->instanceClass == NULL) {
67 throw GiwsException::JniObjectCreationException(curEnv, this->className());
68 }
69
70
71 constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ;
72 if(constructObject == NULL){
73 throw GiwsException::JniObjectCreationException(curEnv, this->className());
74 }
75
76 localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ;
77 if(localInstance == NULL){
78 throw GiwsException::JniObjectCreationException(curEnv, this->className());
79 }
80
81 this->instance = curEnv->NewGlobalRef(localInstance) ;
82 if(this->instance == NULL){
83 throw GiwsException::JniObjectCreationException(curEnv, this->className());
84 }
85 /* localInstance not needed anymore */
86 curEnv->DeleteLocalRef(localInstance);
87
88 /* Methods ID set to NULL */
89 voidxgetmouseID=NULL;
90 voidxgetmousejbooleanbooleanjbooleanbooleanID=NULL;
91 jintgetMouseButtonNumberID=NULL;
92 jintgetWindowsIDID=NULL;
93 jdoublegetXCoordinateID=NULL;
94 jdoublegetYCoordinateID=NULL;
95
96
97 }
98
Jxgetmouse(JavaVM * jvm_,jobject JObj)99 Jxgetmouse::Jxgetmouse(JavaVM * jvm_, jobject JObj) {
100 jvm=jvm_;
101
102 JNIEnv * curEnv = getCurrentEnv();
103
104 jclass localClass = curEnv->GetObjectClass(JObj);
105 this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass));
106 curEnv->DeleteLocalRef(localClass);
107
108 if (this->instanceClass == NULL) {
109 throw GiwsException::JniObjectCreationException(curEnv, this->className());
110 }
111
112 this->instance = curEnv->NewGlobalRef(JObj) ;
113 if(this->instance == NULL){
114 throw GiwsException::JniObjectCreationException(curEnv, this->className());
115 }
116 /* Methods ID set to NULL */
117 voidxgetmouseID=NULL;
118 voidxgetmousejbooleanbooleanjbooleanbooleanID=NULL;
119 jintgetMouseButtonNumberID=NULL;
120 jintgetWindowsIDID=NULL;
121 jdoublegetXCoordinateID=NULL;
122 jdoublegetYCoordinateID=NULL;
123
124
125 }
126
127 // Generic methods
128
synchronize()129 void Jxgetmouse::synchronize() {
130 if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) {
131 throw GiwsException::JniMonitorException(getCurrentEnv(), "Jxgetmouse");
132 }
133 }
134
endSynchronize()135 void Jxgetmouse::endSynchronize() {
136 if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) {
137 throw GiwsException::JniMonitorException(getCurrentEnv(), "Jxgetmouse");
138 }
139 }
140 // Method(s)
141
xgetmouse(JavaVM * jvm_)142 void Jxgetmouse::xgetmouse (JavaVM * jvm_){
143
144 JNIEnv * curEnv = NULL;
145 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
146 jclass cls = initClass(curEnv);
147 if ( cls == NULL) {
148 throw GiwsException::JniCallMethodException(curEnv);
149 }
150
151 static jmethodID voidxgetmouseID = curEnv->GetStaticMethodID(cls, "xgetmouse", "()V" ) ;
152 if (voidxgetmouseID == NULL) {
153 throw GiwsException::JniMethodNotFoundException(curEnv, "xgetmouse");
154 }
155
156 curEnv->CallStaticVoidMethod(cls, voidxgetmouseID );
157 if (curEnv->ExceptionCheck()) {
158 throw GiwsException::JniCallMethodException(curEnv);
159 }
160 }
161
xgetmouse(JavaVM * jvm_,bool withMotion,bool withRelease)162 void Jxgetmouse::xgetmouse (JavaVM * jvm_, bool withMotion, bool withRelease){
163
164 JNIEnv * curEnv = NULL;
165 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
166 jclass cls = initClass(curEnv);
167 if ( cls == NULL) {
168 throw GiwsException::JniCallMethodException(curEnv);
169 }
170
171 static jmethodID voidxgetmousejbooleanbooleanjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "xgetmouse", "(ZZ)V" ) ;
172 if (voidxgetmousejbooleanbooleanjbooleanbooleanID == NULL) {
173 throw GiwsException::JniMethodNotFoundException(curEnv, "xgetmouse");
174 }
175
176 jboolean withMotion_ = (static_cast<bool>(withMotion) ? JNI_TRUE : JNI_FALSE);
177
178 jboolean withRelease_ = (static_cast<bool>(withRelease) ? JNI_TRUE : JNI_FALSE);
179
180 curEnv->CallStaticVoidMethod(cls, voidxgetmousejbooleanbooleanjbooleanbooleanID ,withMotion_, withRelease_);
181 if (curEnv->ExceptionCheck()) {
182 throw GiwsException::JniCallMethodException(curEnv);
183 }
184 }
185
getMouseButtonNumber(JavaVM * jvm_)186 int Jxgetmouse::getMouseButtonNumber (JavaVM * jvm_){
187
188 JNIEnv * curEnv = NULL;
189 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
190 jclass cls = initClass(curEnv);
191 if ( cls == NULL) {
192 throw GiwsException::JniCallMethodException(curEnv);
193 }
194
195 static jmethodID jintgetMouseButtonNumberID = curEnv->GetStaticMethodID(cls, "getMouseButtonNumber", "()I" ) ;
196 if (jintgetMouseButtonNumberID == NULL) {
197 throw GiwsException::JniMethodNotFoundException(curEnv, "getMouseButtonNumber");
198 }
199
200 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetMouseButtonNumberID ));
201 if (curEnv->ExceptionCheck()) {
202 throw GiwsException::JniCallMethodException(curEnv);
203 }
204 return res;
205
206 }
207
getWindowsID(JavaVM * jvm_)208 int Jxgetmouse::getWindowsID (JavaVM * jvm_){
209
210 JNIEnv * curEnv = NULL;
211 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
212 jclass cls = initClass(curEnv);
213 if ( cls == NULL) {
214 throw GiwsException::JniCallMethodException(curEnv);
215 }
216
217 static jmethodID jintgetWindowsIDID = curEnv->GetStaticMethodID(cls, "getWindowsID", "()I" ) ;
218 if (jintgetWindowsIDID == NULL) {
219 throw GiwsException::JniMethodNotFoundException(curEnv, "getWindowsID");
220 }
221
222 jint res = static_cast<jint>( curEnv->CallStaticIntMethod(cls, jintgetWindowsIDID ));
223 if (curEnv->ExceptionCheck()) {
224 throw GiwsException::JniCallMethodException(curEnv);
225 }
226 return res;
227
228 }
229
getXCoordinate(JavaVM * jvm_)230 double Jxgetmouse::getXCoordinate (JavaVM * jvm_){
231
232 JNIEnv * curEnv = NULL;
233 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
234 jclass cls = initClass(curEnv);
235 if ( cls == NULL) {
236 throw GiwsException::JniCallMethodException(curEnv);
237 }
238
239 static jmethodID jdoublegetXCoordinateID = curEnv->GetStaticMethodID(cls, "getXCoordinate", "()D" ) ;
240 if (jdoublegetXCoordinateID == NULL) {
241 throw GiwsException::JniMethodNotFoundException(curEnv, "getXCoordinate");
242 }
243
244 jdouble res = static_cast<jdouble>( curEnv->CallStaticDoubleMethod(cls, jdoublegetXCoordinateID ));
245 if (curEnv->ExceptionCheck()) {
246 throw GiwsException::JniCallMethodException(curEnv);
247 }
248 return res;
249
250 }
251
getYCoordinate(JavaVM * jvm_)252 double Jxgetmouse::getYCoordinate (JavaVM * jvm_){
253
254 JNIEnv * curEnv = NULL;
255 jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL);
256 jclass cls = initClass(curEnv);
257 if ( cls == NULL) {
258 throw GiwsException::JniCallMethodException(curEnv);
259 }
260
261 static jmethodID jdoublegetYCoordinateID = curEnv->GetStaticMethodID(cls, "getYCoordinate", "()D" ) ;
262 if (jdoublegetYCoordinateID == NULL) {
263 throw GiwsException::JniMethodNotFoundException(curEnv, "getYCoordinate");
264 }
265
266 jdouble res = static_cast<jdouble>( curEnv->CallStaticDoubleMethod(cls, jdoublegetYCoordinateID ));
267 if (curEnv->ExceptionCheck()) {
268 throw GiwsException::JniCallMethodException(curEnv);
269 }
270 return res;
271
272 }
273
274 }
275