Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* ----------------------------------------------------------------------------- |
2 | * java.swg | |
3 | * | |
4 | * Java typemaps | |
5 | * ----------------------------------------------------------------------------- */ | |
6 | ||
7 | ||
8 | %include "javahead.swg" | |
9 | ||
10 | /* The jni, jtype and jstype typemaps work together and so there should be one of each. | |
11 | * The jni typemap contains the JNI type used in the JNI (C/C++) code. | |
12 | * The jtype typemap contains the Java type used in the JNI intermediary class. | |
13 | * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */ | |
14 | ||
15 | /* Primitive types */ | |
16 | %typemap(jni) bool, const bool & "jboolean" | |
17 | %typemap(jni) char, const char & "jchar" | |
18 | %typemap(jni) signed char, const signed char & "jbyte" | |
19 | %typemap(jni) unsigned char, const unsigned char & "jshort" | |
20 | %typemap(jni) short, const short & "jshort" | |
21 | %typemap(jni) unsigned short, const unsigned short & "jint" | |
22 | %typemap(jni) int, const int & "jint" | |
23 | %typemap(jni) unsigned int, const unsigned int & "jlong" | |
24 | %typemap(jni) long, const long & "jint" | |
25 | %typemap(jni) unsigned long, const unsigned long & "jlong" | |
26 | %typemap(jni) long long, const long long & "jlong" | |
27 | %typemap(jni) unsigned long long, const unsigned long long & "jobject" | |
28 | %typemap(jni) float, const float & "jfloat" | |
29 | %typemap(jni) double, const double & "jdouble" | |
30 | %typemap(jni) void "void" | |
31 | ||
32 | %typemap(jtype) bool, const bool & "boolean" | |
33 | %typemap(jtype) char, const char & "char" | |
34 | %typemap(jtype) signed char, const signed char & "byte" | |
35 | %typemap(jtype) unsigned char, const unsigned char & "short" | |
36 | %typemap(jtype) short, const short & "short" | |
37 | %typemap(jtype) unsigned short, const unsigned short & "int" | |
38 | %typemap(jtype) int, const int & "int" | |
39 | %typemap(jtype) unsigned int, const unsigned int & "long" | |
40 | %typemap(jtype) long, const long & "int" | |
41 | %typemap(jtype) unsigned long, const unsigned long & "long" | |
42 | %typemap(jtype) long long, const long long & "long" | |
43 | %typemap(jtype) unsigned long long, const unsigned long long & "java.math.BigInteger" | |
44 | %typemap(jtype) float, const float & "float" | |
45 | %typemap(jtype) double, const double & "double" | |
46 | %typemap(jtype) void "void" | |
47 | ||
48 | %typemap(jstype) bool, const bool & "boolean" | |
49 | %typemap(jstype) char, const char & "char" | |
50 | %typemap(jstype) signed char, const signed char & "byte" | |
51 | %typemap(jstype) unsigned char, const unsigned char & "short" | |
52 | %typemap(jstype) short, const short & "short" | |
53 | %typemap(jstype) unsigned short, const unsigned short & "int" | |
54 | %typemap(jstype) int, const int & "int" | |
55 | %typemap(jstype) unsigned int, const unsigned int & "long" | |
56 | %typemap(jstype) long, const long & "int" | |
57 | %typemap(jstype) unsigned long, const unsigned long & "long" | |
58 | %typemap(jstype) long long, const long long & "long" | |
59 | %typemap(jstype) unsigned long long, const unsigned long long & "java.math.BigInteger" | |
60 | %typemap(jstype) float, const float & "float" | |
61 | %typemap(jstype) double, const double & "double" | |
62 | %typemap(jstype) void "void" | |
63 | ||
64 | %typemap(jni) char *, char[ANY], char[] "jstring" | |
65 | %typemap(jtype) char *, char[ANY], char[] "String" | |
66 | %typemap(jstype) char *, char[ANY], char[] "String" | |
67 | ||
68 | /* JNI types */ | |
69 | %typemap(jni) jboolean "jboolean" | |
70 | %typemap(jni) jchar "jchar" | |
71 | %typemap(jni) jbyte "jbyte" | |
72 | %typemap(jni) jshort "jshort" | |
73 | %typemap(jni) jint "jint" | |
74 | %typemap(jni) jlong "jlong" | |
75 | %typemap(jni) jfloat "jfloat" | |
76 | %typemap(jni) jdouble "jdouble" | |
77 | %typemap(jni) jstring "jstring" | |
78 | %typemap(jni) jobject "jobject" | |
79 | %typemap(jni) jbooleanArray "jbooleanArray" | |
80 | %typemap(jni) jcharArray "jcharArray" | |
81 | %typemap(jni) jbyteArray "jbyteArray" | |
82 | %typemap(jni) jshortArray "jshortArray" | |
83 | %typemap(jni) jintArray "jintArray" | |
84 | %typemap(jni) jlongArray "jlongArray" | |
85 | %typemap(jni) jfloatArray "jfloatArray" | |
86 | %typemap(jni) jdoubleArray "jdoubleArray" | |
87 | %typemap(jni) jobjectArray "jobjectArray" | |
88 | ||
89 | %typemap(jtype) jboolean "boolean" | |
90 | %typemap(jtype) jchar "char" | |
91 | %typemap(jtype) jbyte "byte" | |
92 | %typemap(jtype) jshort "short" | |
93 | %typemap(jtype) jint "int" | |
94 | %typemap(jtype) jlong "long" | |
95 | %typemap(jtype) jfloat "float" | |
96 | %typemap(jtype) jdouble "double" | |
97 | %typemap(jtype) jstring "String" | |
98 | %typemap(jtype) jobject "Object" | |
99 | %typemap(jtype) jbooleanArray "boolean[]" | |
100 | %typemap(jtype) jcharArray "char[]" | |
101 | %typemap(jtype) jbyteArray "byte[]" | |
102 | %typemap(jtype) jshortArray "short[]" | |
103 | %typemap(jtype) jintArray "int[]" | |
104 | %typemap(jtype) jlongArray "long[]" | |
105 | %typemap(jtype) jfloatArray "float[]" | |
106 | %typemap(jtype) jdoubleArray "double[]" | |
107 | %typemap(jtype) jobjectArray "Object[]" | |
108 | ||
109 | %typemap(jstype) jboolean "boolean" | |
110 | %typemap(jstype) jchar "char" | |
111 | %typemap(jstype) jbyte "byte" | |
112 | %typemap(jstype) jshort "short" | |
113 | %typemap(jstype) jint "int" | |
114 | %typemap(jstype) jlong "long" | |
115 | %typemap(jstype) jfloat "float" | |
116 | %typemap(jstype) jdouble "double" | |
117 | %typemap(jstype) jstring "String" | |
118 | %typemap(jstype) jobject "Object" | |
119 | %typemap(jstype) jbooleanArray "boolean[]" | |
120 | %typemap(jstype) jcharArray "char[]" | |
121 | %typemap(jstype) jbyteArray "byte[]" | |
122 | %typemap(jstype) jshortArray "short[]" | |
123 | %typemap(jstype) jintArray "int[]" | |
124 | %typemap(jstype) jlongArray "long[]" | |
125 | %typemap(jstype) jfloatArray "float[]" | |
126 | %typemap(jstype) jdoubleArray "double[]" | |
127 | %typemap(jstype) jobjectArray "Object[]" | |
128 | ||
129 | /* Non primitive types */ | |
130 | %typemap(jni) SWIGTYPE "jlong" | |
131 | %typemap(jtype) SWIGTYPE "long" | |
132 | %typemap(jstype) SWIGTYPE "$&javaclassname" | |
133 | ||
134 | %typemap(jni) SWIGTYPE [] "jlong" | |
135 | %typemap(jtype) SWIGTYPE [] "long" | |
136 | %typemap(jstype) SWIGTYPE [] "$javaclassname" | |
137 | ||
138 | %typemap(jni) SWIGTYPE * "jlong" | |
139 | %typemap(jtype) SWIGTYPE * "long" | |
140 | %typemap(jstype) SWIGTYPE * "$javaclassname" | |
141 | ||
142 | %typemap(jni) SWIGTYPE & "jlong" | |
143 | %typemap(jtype) SWIGTYPE & "long" | |
144 | %typemap(jstype) SWIGTYPE & "$javaclassname" | |
145 | ||
146 | /* pointer to a class member */ | |
147 | %typemap(jni) SWIGTYPE (CLASS::*) "jlong" | |
148 | %typemap(jtype) SWIGTYPE (CLASS::*) "long" | |
149 | %typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname" | |
150 | ||
151 | /* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */ | |
152 | ||
153 | /* primitive types */ | |
154 | %typemap(in) bool | |
155 | %{ $1 = $input ? true : false; %} | |
156 | ||
157 | %typemap(directorout) bool | |
158 | %{ $1 = $input ? true : false; %} | |
159 | ||
160 | %typemap(javadirectorin) bool "$jniinput" | |
161 | %typemap(javadirectorout) bool "$javacall" | |
162 | ||
163 | %typemap(in) char, | |
164 | signed char, | |
165 | unsigned char, | |
166 | short, | |
167 | unsigned short, | |
168 | int, | |
169 | unsigned int, | |
170 | long, | |
171 | unsigned long, | |
172 | long long, | |
173 | float, | |
174 | double | |
175 | %{ $1 = ($1_ltype)$input; %} | |
176 | ||
177 | %typemap(directorout) char, | |
178 | signed char, | |
179 | unsigned char, | |
180 | short, | |
181 | unsigned short, | |
182 | int, | |
183 | unsigned int, | |
184 | long, | |
185 | unsigned long, | |
186 | long long, | |
187 | float, | |
188 | double | |
189 | %{ $1 = ($1_ltype)$input; %} | |
190 | ||
191 | %typemap(directorin, descriptor="Z") bool "$input = (jboolean) $1;" | |
192 | %typemap(directorin, descriptor="C") char "$input = (jint) $1;" | |
193 | %typemap(directorin, descriptor="B") signed char "$input = (jbyte) $1;" | |
194 | %typemap(directorin, descriptor="S") unsigned char "$input = (jshort) $1;" | |
195 | %typemap(directorin, descriptor="S") short "$input = (jshort) $1;" | |
196 | %typemap(directorin, descriptor="I") unsigned short "$input = (jint) $1;" | |
197 | %typemap(directorin, descriptor="I") int "$input = (jint) $1;" | |
198 | %typemap(directorin, descriptor="J") unsigned int "$input = (jlong) $1;" | |
199 | %typemap(directorin, descriptor="I") long "$input = (jint) $1;" | |
200 | %typemap(directorin, descriptor="J") unsigned long "$input = (jlong) $1;" | |
201 | %typemap(directorin, descriptor="J") long long "$input = (jlong) $1;" | |
202 | %typemap(directorin, descriptor="F") float "$input = (jfloat) $1;" | |
203 | %typemap(directorin, descriptor="D") double "$input = (jdouble) $1;" | |
204 | ||
205 | %typemap(javadirectorin) char, | |
206 | signed char, | |
207 | unsigned char, | |
208 | short, | |
209 | unsigned short, | |
210 | int, | |
211 | unsigned int, | |
212 | long, | |
213 | unsigned long, | |
214 | long long, | |
215 | float, | |
216 | double | |
217 | "$jniinput" | |
218 | ||
219 | %typemap(javadirectorout) char, | |
220 | signed char, | |
221 | unsigned char, | |
222 | short, | |
223 | unsigned short, | |
224 | int, | |
225 | unsigned int, | |
226 | long, | |
227 | unsigned long, | |
228 | long long, | |
229 | float, | |
230 | double | |
231 | "$javacall" | |
232 | ||
233 | %typemap(out) bool %{ $result = (jboolean)$1; %} | |
234 | %typemap(out) char %{ $result = (jchar)$1; %} | |
235 | %typemap(out) signed char %{ $result = (jbyte)$1; %} | |
236 | %typemap(out) unsigned char %{ $result = (jshort)$1; %} | |
237 | %typemap(out) short %{ $result = (jshort)$1; %} | |
238 | %typemap(out) unsigned short %{ $result = (jint)$1; %} | |
239 | %typemap(out) int %{ $result = (jint)$1; %} | |
240 | %typemap(out) unsigned int %{ $result = (jlong)$1; %} | |
241 | %typemap(out) long %{ $result = (jint)$1; %} | |
242 | %typemap(out) unsigned long %{ $result = (jlong)$1; %} | |
243 | %typemap(out) long long %{ $result = (jlong)$1; %} | |
244 | %typemap(out) float %{ $result = (jfloat)$1; %} | |
245 | %typemap(out) double %{ $result = (jdouble)$1; %} | |
246 | ||
247 | /* unsigned long long */ | |
248 | /* Convert from BigInteger using the toByteArray member function */ | |
249 | %typemap(in) unsigned long long { | |
250 | jclass clazz; | |
251 | jmethodID mid; | |
252 | jbyteArray ba; | |
253 | jbyte* bae; | |
254 | jsize sz; | |
255 | int i; | |
256 | ||
257 | if (!$input) { | |
258 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); | |
259 | return $null; | |
260 | } | |
261 | clazz = JCALL1(GetObjectClass, jenv, $input); | |
262 | mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); | |
263 | ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); | |
264 | bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
265 | sz = JCALL1(GetArrayLength, jenv, ba); | |
266 | $1 = 0; | |
267 | if (bae[0] == 0) { | |
268 | for(i=sz-1; i>0; i-- ) { | |
269 | $1 = ($1 << 8) | (unsigned char)bae[sz-i]; | |
270 | } | |
271 | } | |
272 | else { | |
273 | for(i=sz; i>=0; i-- ) { | |
274 | $1 = ($1 << 8) | (unsigned char)bae[sz-1-i]; | |
275 | } | |
276 | } | |
277 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
278 | } | |
279 | ||
280 | %typemap(directorout) unsigned long long { | |
281 | jclass clazz; | |
282 | jmethodID mid; | |
283 | jbyteArray ba; | |
284 | jbyte* bae; | |
285 | jsize sz; | |
286 | int i; | |
287 | ||
288 | if (!$input) { | |
289 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); | |
290 | return $null; | |
291 | } | |
292 | clazz = JCALL1(GetObjectClass, jenv, $input); | |
293 | mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); | |
294 | ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); | |
295 | bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
296 | sz = JCALL1(GetArrayLength, jenv, ba); | |
297 | $1 = 0; | |
298 | if (bae[0] == 0) { | |
299 | for(i=sz-1; i>0; i-- ) { | |
300 | $1 = ($1 << 8) | (unsigned char)bae[sz-i]; | |
301 | } | |
302 | } | |
303 | else { | |
304 | for(i=sz; i>=0; i-- ) { | |
305 | $1 = ($1 << 8) | (unsigned char)bae[sz-1-i]; | |
306 | } | |
307 | } | |
308 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
309 | } | |
310 | ||
311 | ||
312 | /* Convert to BigInteger - byte array holds number in 2's complement big endian format */ | |
313 | %typemap(out) unsigned long long { | |
314 | jbyteArray ba = JCALL1(NewByteArray, jenv, 9); | |
315 | jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
316 | jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); | |
317 | jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); | |
318 | jobject bigint; | |
319 | int i; | |
320 | ||
321 | bae[0] = 0; | |
322 | for(i=1; i<9; i++ ) { | |
323 | bae[i] = (jbyte)($1>>8*(8-i)); | |
324 | } | |
325 | ||
326 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
327 | bigint = JCALL3(NewObject, jenv, clazz, mid, ba); | |
328 | $result = bigint; | |
329 | } | |
330 | ||
331 | /* Convert to BigInteger (see out typemap) */ | |
332 | %typemap(directorin, descriptor="Ljava/math/BigInteger;") unsigned long long, const unsigned long long & { | |
333 | jbyteArray ba = JCALL1(NewByteArray, jenv, 9); | |
334 | jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
335 | jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); | |
336 | jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); | |
337 | jobject bigint; | |
338 | int i; | |
339 | ||
340 | bae[0] = 0; | |
341 | for(i=1; i<9; i++ ) { | |
342 | bae[i] = (jbyte)($1>>8*(8-i)); | |
343 | } | |
344 | ||
345 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
346 | bigint = JCALL3(NewObject, jenv, clazz, mid, ba); | |
347 | $input = bigint; | |
348 | } | |
349 | ||
350 | %typemap(javadirectorin) unsigned long long "$jniinput" | |
351 | %typemap(javadirectorout) unsigned long long "$javacall" | |
352 | ||
353 | /* char * - treat as String */ | |
354 | %typemap(in) char * { | |
355 | $1 = 0; | |
356 | if ($input) { | |
357 | $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); | |
358 | if (!$1) return $null; | |
359 | } | |
360 | } | |
361 | ||
362 | %typemap(directorout) char * { | |
363 | $1 = 0; | |
364 | if ($input) { | |
365 | $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); | |
366 | if (!$1) return $null; | |
367 | } | |
368 | } | |
369 | ||
370 | %typemap(directorin, descriptor="Ljava/lang/String;") char * { | |
371 | $input = 0; | |
372 | if ($1) { | |
373 | $input = JCALL1(NewStringUTF, jenv, $1); | |
374 | if (!$input) return $null; | |
375 | } | |
376 | } | |
377 | ||
378 | %typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } | |
379 | %typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } | |
380 | %typemap(javadirectorin) char * "$jniinput" | |
381 | %typemap(javadirectorout) char * "$javacall" | |
382 | ||
383 | %typemap(out) void "" | |
384 | %typemap(javadirectorin) void "$jniinput" | |
385 | %typemap(javadirectorout) void "$javacall" | |
386 | %typemap(directorin, descriptor="V") void "" | |
387 | ||
388 | /* primitive types by reference */ | |
389 | %typemap(in) const bool & (bool temp) | |
390 | %{ temp = $input ? true : false; | |
391 | $1 = &temp; %} | |
392 | ||
393 | %typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const bool & | |
394 | %{ static $*1_ltype temp; | |
395 | temp = $input ? true : false; | |
396 | $1 = &temp; %} | |
397 | ||
398 | %typemap(javadirectorin) const bool & "$jniinput" | |
399 | %typemap(javadirectorout) const bool & "$javacall" | |
400 | ||
401 | %typemap(in) const char & (char temp), | |
402 | const signed char & (signed char temp), | |
403 | const unsigned char & (unsigned char temp), | |
404 | const short & (short temp), | |
405 | const unsigned short & (unsigned short temp), | |
406 | const int & (int temp), | |
407 | const unsigned int & (unsigned int temp), | |
408 | const long & (long temp), | |
409 | const unsigned long & (unsigned long temp), | |
410 | const long long & ($*1_ltype temp), | |
411 | const float & (float temp), | |
412 | const double & (double temp) | |
413 | %{ temp = ($*1_ltype)$input; | |
414 | $1 = &temp; %} | |
415 | ||
416 | %typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const char &, | |
417 | const signed char &, | |
418 | const unsigned char &, | |
419 | const short &, | |
420 | const unsigned short &, | |
421 | const int &, | |
422 | const unsigned int &, | |
423 | const long &, | |
424 | const unsigned long &, | |
425 | const long long &, | |
426 | const float &, | |
427 | const double & | |
428 | %{ static $*1_ltype temp; | |
429 | temp = ($*1_ltype)$input; | |
430 | $1 = &temp; %} | |
431 | ||
432 | %typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1_name;" | |
433 | %typemap(directorin, descriptor="C") const char & "$input = (jchar)$1_name;" | |
434 | %typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1_name;" | |
435 | %typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1_name;" | |
436 | %typemap(directorin, descriptor="S") const short & "$input = (jshort)$1_name;" | |
437 | %typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1_name;" | |
438 | %typemap(directorin, descriptor="I") const int & "$input = (jint)$1_name;" | |
439 | %typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1_name;" | |
440 | %typemap(directorin, descriptor="I") const long & "$input = (jint)$1_name;" | |
441 | %typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1_name;" | |
442 | %typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1_name;" | |
443 | %typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1_name;" | |
444 | %typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1_name;" | |
445 | ||
446 | %typemap(javadirectorin) const char & (char temp), | |
447 | const signed char & (signed char temp), | |
448 | const unsigned char & (unsigned char temp), | |
449 | const short & (short temp), | |
450 | const unsigned short & (unsigned short temp), | |
451 | const int & (int temp), | |
452 | const unsigned int & (unsigned int temp), | |
453 | const long & (long temp), | |
454 | const unsigned long & (unsigned long temp), | |
455 | const long long & ($*1_ltype temp), | |
456 | const float & (float temp), | |
457 | const double & (double temp) | |
458 | "$jniinput" | |
459 | ||
460 | %typemap(javadirectorout) const char & (char temp), | |
461 | const signed char & (signed char temp), | |
462 | const unsigned char & (unsigned char temp), | |
463 | const short & (short temp), | |
464 | const unsigned short & (unsigned short temp), | |
465 | const int & (int temp), | |
466 | const unsigned int & (unsigned int temp), | |
467 | const long & (long temp), | |
468 | const unsigned long & (unsigned long temp), | |
469 | const long long & ($*1_ltype temp), | |
470 | const float & (float temp), | |
471 | const double & (double temp) | |
472 | "$javacall" | |
473 | ||
474 | ||
475 | %typemap(out) const bool & %{ $result = (jboolean)*$1; %} | |
476 | %typemap(out) const char & %{ $result = (jchar)*$1; %} | |
477 | %typemap(out) const signed char & %{ $result = (jbyte)*$1; %} | |
478 | %typemap(out) const unsigned char & %{ $result = (jshort)*$1; %} | |
479 | %typemap(out) const short & %{ $result = (jshort)*$1; %} | |
480 | %typemap(out) const unsigned short & %{ $result = (jint)*$1; %} | |
481 | %typemap(out) const int & %{ $result = (jint)*$1; %} | |
482 | %typemap(out) const unsigned int & %{ $result = (jlong)*$1; %} | |
483 | %typemap(out) const long & %{ $result = (jint)*$1; %} | |
484 | %typemap(out) const unsigned long & %{ $result = (jlong)*$1; %} | |
485 | %typemap(out) const long long & %{ $result = (jlong)*$1; %} | |
486 | %typemap(out) const float & %{ $result = (jfloat)*$1; %} | |
487 | %typemap(out) const double & %{ $result = (jdouble)*$1; %} | |
488 | ||
489 | /* const unsigned long long & */ | |
490 | /* Similar to unsigned long long */ | |
491 | %typemap(in) const unsigned long long & ($*1_ltype temp) { | |
492 | jclass clazz; | |
493 | jmethodID mid; | |
494 | jbyteArray ba; | |
495 | jbyte* bae; | |
496 | jsize sz; | |
497 | int i; | |
498 | ||
499 | if (!$input) { | |
500 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); | |
501 | return $null; | |
502 | } | |
503 | clazz = JCALL1(GetObjectClass, jenv, $input); | |
504 | mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); | |
505 | ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); | |
506 | bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
507 | sz = JCALL1(GetArrayLength, jenv, ba); | |
508 | $1 = &temp; | |
509 | temp = 0; | |
510 | if (bae[0] == 0) { | |
511 | for(i=sz-1; i>0; i-- ) { | |
512 | temp = (temp << 8) | (unsigned char)bae[sz-i]; | |
513 | } | |
514 | } | |
515 | else { | |
516 | for(i=sz; i>=0; i-- ) { | |
517 | temp = (temp << 8) | (unsigned char)bae[sz-1-i]; | |
518 | } | |
519 | } | |
520 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
521 | } | |
522 | ||
523 | %typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const unsigned long long & { | |
524 | static $*1_ltype temp; | |
525 | jclass clazz; | |
526 | jmethodID mid; | |
527 | jbyteArray ba; | |
528 | jbyte* bae; | |
529 | jsize sz; | |
530 | int i; | |
531 | ||
532 | if (!$input) { | |
533 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null"); | |
534 | return $null; | |
535 | } | |
536 | clazz = JCALL1(GetObjectClass, jenv, $input); | |
537 | mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B"); | |
538 | ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid); | |
539 | bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
540 | sz = JCALL1(GetArrayLength, jenv, ba); | |
541 | $1 = &temp; | |
542 | temp = 0; | |
543 | if (bae[0] == 0) { | |
544 | for(i=sz-1; i>0; i-- ) { | |
545 | temp = (temp << 8) | (unsigned char)bae[sz-i]; | |
546 | } | |
547 | } | |
548 | else { | |
549 | for(i=sz; i>=0; i-- ) { | |
550 | temp = (temp << 8) | (unsigned char)bae[sz-1-i]; | |
551 | } | |
552 | } | |
553 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
554 | } | |
555 | ||
556 | %typemap(out) const unsigned long long & { | |
557 | jbyteArray ba = JCALL1(NewByteArray, jenv, 9); | |
558 | jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0); | |
559 | jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger"); | |
560 | jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V"); | |
561 | jobject bigint; | |
562 | int i; | |
563 | ||
564 | bae[0] = 0; | |
565 | for(i=1; i<9; i++ ) { | |
566 | bae[i] = (jbyte)(*$1>>8*(8-i)); | |
567 | } | |
568 | ||
569 | JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0); | |
570 | bigint = JCALL3(NewObject, jenv, clazz, mid, ba); | |
571 | $result = bigint; | |
572 | } | |
573 | ||
574 | %typemap(javadirectorin) const unsigned long long & "$jniinput" | |
575 | %typemap(javadirectorout) const unsigned long long & "$javacall" | |
576 | ||
577 | /* Default handling. Object passed by value. Convert to a pointer */ | |
578 | %typemap(in) SWIGTYPE ($&1_type argp) | |
579 | %{ argp = *($&1_ltype*)(void *)&$input; | |
580 | if (!argp) { | |
581 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); | |
582 | return $null; | |
583 | } | |
584 | $1 = *argp; %} | |
585 | ||
586 | %typemap(directorout) SWIGTYPE ($1_ltype argp) | |
587 | %{ argp = *($&1_ltype)(void *)&$input; | |
588 | if (!argp) { | |
589 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); | |
590 | return $null; | |
591 | } | |
592 | $1 = argp; %} | |
593 | ||
594 | %typemap(out) SWIGTYPE | |
595 | #ifdef __cplusplus | |
596 | %{*($&1_ltype*)(void *)&$result = new $1_ltype(($1_ltype &)$1); %} | |
597 | #else | |
598 | { | |
599 | $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); | |
600 | memmove($1ptr, &$1, sizeof($1_type)); | |
601 | *($&1_ltype*)(void *)&$result = $1ptr; | |
602 | } | |
603 | #endif | |
604 | ||
605 | %typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE | |
606 | %{ $input = 0; | |
607 | *(($&1_ltype*)(void *)&$input) = &$1; %} | |
608 | %typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)" | |
609 | %typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)" | |
610 | ||
611 | /* Generic pointers and references */ | |
612 | %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)(void *)&$input; %} | |
613 | %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)(void *)&$input; | |
614 | if(!$1) { | |
615 | SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); | |
616 | return $null; | |
617 | } %} | |
618 | %typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*) | |
619 | %{ *($&1_ltype)(void *)&$result = $1; %} | |
620 | %typemap(out) SWIGTYPE & | |
621 | %{ *($&1_ltype)(void *)&$result = $1; %} | |
622 | ||
623 | %typemap(directorout) SWIGTYPE *, SWIGTYPE (CLASS::*) | |
624 | %{ $1 = *($&1_ltype)(void *)&$input; %} | |
625 | %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*) | |
626 | %{ *(($&1_ltype)(void *)&$input) = ($1_ltype) $1; %} | |
627 | ||
628 | %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & | |
629 | %{ *($&1_ltype)(void *)&$input = ($1_ltype) &$1; %} | |
630 | ||
631 | %typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, const SWIGTYPE & "new $javaclassname($jniinput, false)" | |
632 | %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, const SWIGTYPE & "$javaclassname.getCPtr($javacall)" | |
633 | ||
634 | /* Default array handling */ | |
635 | %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)(void *)&$input; %} | |
636 | %typemap(out) SWIGTYPE [] %{ *($&1_ltype)(void *)&$result = $1; %} | |
637 | %typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] "" | |
638 | ||
639 | /* char arrays - treat as String */ | |
640 | %typemap(in) char[ANY], char[] { | |
641 | $1 = 0; | |
642 | if ($input) { | |
643 | $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); | |
644 | if (!$1) return $null; | |
645 | } | |
646 | } | |
647 | ||
648 | %typemap(directorout) char[ANY], char[] { | |
649 | $1 = 0; | |
650 | if ($input) { | |
651 | $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); | |
652 | if (!$1) return $null; | |
653 | } | |
654 | } | |
655 | ||
656 | %typemap(directorin, descriptor="Ljava/lang/String;") char[ANY], char[] { | |
657 | $input = 0; | |
658 | if ($1) { | |
659 | $input = JCALL1(NewStringUTF, jenv, $1); | |
660 | if (!$input) return $null; | |
661 | } | |
662 | } | |
663 | ||
664 | %typemap(argout) char[ANY], char[] "" | |
665 | %typemap(freearg) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } | |
666 | %typemap(out) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } | |
667 | %typemap(javadirectorin) char[ANY], char[] "$jniinput" | |
668 | %typemap(javadirectorout) char[ANY], char[] "$javacall" | |
669 | ||
670 | /* JNI types */ | |
671 | %typemap(in) jboolean, | |
672 | jchar, | |
673 | jbyte, | |
674 | jshort, | |
675 | jint, | |
676 | jlong, | |
677 | jfloat, | |
678 | jdouble, | |
679 | jstring, | |
680 | jobject, | |
681 | jbooleanArray, | |
682 | jcharArray, | |
683 | jbyteArray, | |
684 | jshortArray, | |
685 | jintArray, | |
686 | jlongArray, | |
687 | jfloatArray, | |
688 | jdoubleArray, | |
689 | jobjectArray | |
690 | %{ $1 = $input; %} | |
691 | ||
692 | %typemap(directorout) jboolean, | |
693 | jchar, | |
694 | jbyte, | |
695 | jshort, | |
696 | jint, | |
697 | jlong, | |
698 | jfloat, | |
699 | jdouble, | |
700 | jstring, | |
701 | jobject, | |
702 | jbooleanArray, | |
703 | jcharArray, | |
704 | jbyteArray, | |
705 | jshortArray, | |
706 | jintArray, | |
707 | jlongArray, | |
708 | jfloatArray, | |
709 | jdoubleArray, | |
710 | jobjectArray | |
711 | %{ $1 = $input; %} | |
712 | ||
713 | %typemap(out) jboolean, | |
714 | jchar, | |
715 | jbyte, | |
716 | jshort, | |
717 | jint, | |
718 | jlong, | |
719 | jfloat, | |
720 | jdouble, | |
721 | jstring, | |
722 | jobject, | |
723 | jbooleanArray, | |
724 | jcharArray, | |
725 | jbyteArray, | |
726 | jshortArray, | |
727 | jintArray, | |
728 | jlongArray, | |
729 | jfloatArray, | |
730 | jdoubleArray, | |
731 | jobjectArray | |
732 | %{ $result = $1; %} | |
733 | ||
734 | %typemap(directorin,descriptor="Z") jboolean "$input = $1;" | |
735 | %typemap(directorin,descriptor="C") jchar "$input = $1;" | |
736 | %typemap(directorin,descriptor="B") jbyte "$input = $1;" | |
737 | %typemap(directorin,descriptor="S") jshort "$input = $1;" | |
738 | %typemap(directorin,descriptor="I") jint "$input = $1;" | |
739 | %typemap(directorin,descriptor="J") jlong "$input = $1;" | |
740 | %typemap(directorin,descriptor="F") jfloat "$input = $1;" | |
741 | %typemap(directorin,descriptor="D") jdouble "$input = $1;" | |
742 | %typemap(directorin,descriptor="Ljava/lang/String;") jstring "$input = $1;" | |
743 | %typemap(directorin,descriptor="Ljava/lang/Object;") jobject "$input = $1;" | |
744 | %typemap(directorin,descriptor="[Z") jbooleanArray "$input = $1;" | |
745 | %typemap(directorin,descriptor="[C") jcharArray "$input = $1;" | |
746 | %typemap(directorin,descriptor="[B") jbyteArray "$input = $1;" | |
747 | %typemap(directorin,descriptor="[S") jshortArray "$input = $1;" | |
748 | %typemap(directorin,descriptor="[I") jintArray "$input = $1;" | |
749 | %typemap(directorin,descriptor="[J") jlongArray "$input = $1;" | |
750 | %typemap(directorin,descriptor="[F") jfloatArray "$input = $1;" | |
751 | %typemap(directorin,descriptor="[D") jdoubleArray "$input = $1;" | |
752 | %typemap(directorin,descriptor="[Ljava/lang/Object;") jobjectArray "$input = $1;" | |
753 | ||
754 | %typemap(javadirectorin) jboolean, | |
755 | jchar, | |
756 | jbyte, | |
757 | jshort, | |
758 | jint, | |
759 | jlong, | |
760 | jfloat, | |
761 | jdouble, | |
762 | jstring, | |
763 | jobject, | |
764 | jbooleanArray, | |
765 | jcharArray, | |
766 | jbyteArray, | |
767 | jshortArray, | |
768 | jintArray, | |
769 | jlongArray, | |
770 | jfloatArray, | |
771 | jdoubleArray, | |
772 | jobjectArray | |
773 | "$jniinput" | |
774 | ||
775 | %typemap(javadirectorout) jboolean, | |
776 | jchar, | |
777 | jbyte, | |
778 | jshort, | |
779 | jint, | |
780 | jlong, | |
781 | jfloat, | |
782 | jdouble, | |
783 | jstring, | |
784 | jobject, | |
785 | jbooleanArray, | |
786 | jcharArray, | |
787 | jbyteArray, | |
788 | jshortArray, | |
789 | jintArray, | |
790 | jlongArray, | |
791 | jfloatArray, | |
792 | jdoubleArray, | |
793 | jobjectArray | |
794 | "$javacall" | |
795 | ||
796 | /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions | |
797 | * that cannot be overloaded in Java as more than one C++ type maps to a single Java type */ | |
798 | ||
799 | %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */ | |
800 | jboolean, | |
801 | bool, | |
802 | const bool & | |
803 | "" | |
804 | ||
805 | %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */ | |
806 | jchar, | |
807 | char, | |
808 | const char & | |
809 | "" | |
810 | ||
811 | %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */ | |
812 | jbyte, | |
813 | signed char, | |
814 | const signed char & | |
815 | "" | |
816 | ||
817 | %typecheck(SWIG_TYPECHECK_INT16) /* Java short */ | |
818 | jshort, | |
819 | unsigned char, | |
820 | short, | |
821 | const unsigned char &, | |
822 | const short & | |
823 | "" | |
824 | ||
825 | %typecheck(SWIG_TYPECHECK_INT32) /* Java int */ | |
826 | jint, | |
827 | unsigned short, | |
828 | int, | |
829 | long, | |
830 | const unsigned short &, | |
831 | const int &, | |
832 | const long & | |
833 | "" | |
834 | ||
835 | %typecheck(SWIG_TYPECHECK_INT64) /* Java long */ | |
836 | jlong, | |
837 | unsigned int, | |
838 | unsigned long, | |
839 | long long, | |
840 | const unsigned int &, | |
841 | const unsigned long &, | |
842 | const long long & | |
843 | "" | |
844 | ||
845 | %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */ | |
846 | unsigned long long, | |
847 | const unsigned long long & | |
848 | "" | |
849 | ||
850 | %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */ | |
851 | jfloat, | |
852 | float, | |
853 | const float & | |
854 | "" | |
855 | ||
856 | %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */ | |
857 | jdouble, | |
858 | double, | |
859 | const double & | |
860 | "" | |
861 | ||
862 | %typecheck(SWIG_TYPECHECK_STRING) /* Java String */ | |
863 | jstring, | |
864 | char *, | |
865 | char[ANY], | |
866 | char [] | |
867 | "" | |
868 | ||
869 | %typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */ | |
870 | jbooleanArray | |
871 | "" | |
872 | ||
873 | %typecheck(SWIG_TYPECHECK_CHAR_ARRAY) /* Java char[] */ | |
874 | jcharArray | |
875 | "" | |
876 | ||
877 | %typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */ | |
878 | jbyteArray | |
879 | "" | |
880 | ||
881 | %typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */ | |
882 | jshortArray | |
883 | "" | |
884 | ||
885 | %typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */ | |
886 | jintArray | |
887 | "" | |
888 | ||
889 | %typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */ | |
890 | jlongArray | |
891 | "" | |
892 | ||
893 | %typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */ | |
894 | jfloatArray | |
895 | "" | |
896 | ||
897 | %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */ | |
898 | jdoubleArray | |
899 | "" | |
900 | ||
901 | %typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) /* Java jobject[] */ | |
902 | jobjectArray | |
903 | "" | |
904 | ||
905 | %typecheck(SWIG_TYPECHECK_POINTER) /* Default */ | |
906 | SWIGTYPE, | |
907 | SWIGTYPE *, | |
908 | SWIGTYPE &, | |
909 | SWIGTYPE [], | |
910 | SWIGTYPE (CLASS::*) | |
911 | "" | |
912 | ||
913 | ||
914 | /* Exception handling */ | |
915 | ||
916 | %typemap(throws) int, | |
917 | long, | |
918 | short, | |
919 | unsigned int, | |
920 | unsigned long, | |
921 | unsigned short { | |
922 | char error_msg[256]; | |
923 | sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); | |
924 | SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); | |
925 | return $null; | |
926 | } | |
927 | ||
928 | %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ | |
929 | (void)$1; | |
930 | SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); | |
931 | return $null; | |
932 | %} | |
933 | ||
934 | %typemap(throws) char * %{ | |
935 | SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); | |
936 | return $null; | |
937 | %} | |
938 | ||
939 | ||
940 | /* Typemaps for code generation in proxy classes and Java type wrapper classes */ | |
941 | ||
942 | /* The javain typemap is used for converting function parameter types from the type | |
943 | * used in the proxy, module or type wrapper class to the type used in the JNI class. */ | |
944 | %typemap(javain) bool, const bool &, | |
945 | char, const char &, | |
946 | signed char, const signed char &, | |
947 | unsigned char, const unsigned char &, | |
948 | short, const short &, | |
949 | unsigned short, const unsigned short &, | |
950 | int, const int &, | |
951 | unsigned int, const unsigned int &, | |
952 | long, const long &, | |
953 | unsigned long, const unsigned long &, | |
954 | long long, const long long &, | |
955 | unsigned long long, const unsigned long long &, | |
956 | float, const float &, | |
957 | double, const double & | |
958 | "$javainput" | |
959 | %typemap(javain) char *, char[ANY], char[] "$javainput" | |
960 | %typemap(javain) jboolean, | |
961 | jchar, | |
962 | jbyte, | |
963 | jshort, | |
964 | jint, | |
965 | jlong, | |
966 | jfloat, | |
967 | jdouble, | |
968 | jstring, | |
969 | jobject, | |
970 | jbooleanArray, | |
971 | jcharArray, | |
972 | jbyteArray, | |
973 | jshortArray, | |
974 | jintArray, | |
975 | jlongArray, | |
976 | jfloatArray, | |
977 | jdoubleArray, | |
978 | jobjectArray | |
979 | "$javainput" | |
980 | %typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)" | |
981 | %typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$javaclassname.getCPtr($javainput)" | |
982 | ||
983 | /* The javaout typemap is used for converting function return types from the return type | |
984 | * used in the JNI class to the type returned by the proxy, module or type wrapper class. */ | |
985 | %typemap(javaout) bool, const bool &, | |
986 | char, const char &, | |
987 | signed char, const signed char &, | |
988 | unsigned char, const unsigned char &, | |
989 | short, const short &, | |
990 | unsigned short, const unsigned short &, | |
991 | int, const int &, | |
992 | unsigned int, const unsigned int &, | |
993 | long, const long &, | |
994 | unsigned long, const unsigned long &, | |
995 | long long, const long long &, | |
996 | unsigned long long, const unsigned long long &, | |
997 | float, const float &, | |
998 | double, const double & { | |
999 | return $jnicall; | |
1000 | } | |
1001 | %typemap(javaout) char *, char[ANY], char[] { | |
1002 | return $jnicall; | |
1003 | } | |
1004 | %typemap(javaout) jboolean, | |
1005 | jchar, | |
1006 | jbyte, | |
1007 | jshort, | |
1008 | jint, | |
1009 | jlong, | |
1010 | jfloat, | |
1011 | jdouble, | |
1012 | jstring, | |
1013 | jobject, | |
1014 | jbooleanArray, | |
1015 | jcharArray, | |
1016 | jbyteArray, | |
1017 | jshortArray, | |
1018 | jintArray, | |
1019 | jlongArray, | |
1020 | jfloatArray, | |
1021 | jdoubleArray, | |
1022 | jobjectArray { | |
1023 | return $jnicall; | |
1024 | } | |
1025 | %typemap(javaout) void { | |
1026 | $jnicall; | |
1027 | } | |
1028 | %typemap(javaout) SWIGTYPE { | |
1029 | return new $&javaclassname($jnicall, true); | |
1030 | } | |
1031 | %typemap(javaout) SWIGTYPE & { | |
1032 | return new $javaclassname($jnicall, $owner); | |
1033 | } | |
1034 | %typemap(javaout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) { | |
1035 | long cPtr = $jnicall; | |
1036 | return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner); | |
1037 | } | |
1038 | ||
1039 | /* Typemaps used for the generation of proxy and type wrapper class code */ | |
1040 | %typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" | |
1041 | %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class" | |
1042 | %typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" | |
1043 | %typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" | |
1044 | %typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" | |
1045 | ||
1046 | /* javabody typemaps */ | |
1047 | ||
1048 | %define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPENAME...) | |
1049 | // Base proxy classes | |
1050 | %typemap(javabody) TYPENAME %{ | |
1051 | private long swigCPtr; | |
1052 | protected boolean swigCMemOwn; | |
1053 | ||
1054 | PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { | |
1055 | swigCMemOwn = cMemoryOwn; | |
1056 | swigCPtr = cPtr; | |
1057 | } | |
1058 | ||
1059 | CPTR_VISIBILITY static long getCPtr($javaclassname obj) { | |
1060 | return (obj == null) ? 0 : obj.swigCPtr; | |
1061 | } | |
1062 | %} | |
1063 | ||
1064 | // Derived proxy classes | |
1065 | %typemap(javabody_derived) TYPENAME %{ | |
1066 | private long swigCPtr; | |
1067 | ||
1068 | PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) { | |
1069 | super($moduleJNI.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn); | |
1070 | swigCPtr = cPtr; | |
1071 | } | |
1072 | ||
1073 | CPTR_VISIBILITY static long getCPtr($javaclassname obj) { | |
1074 | return (obj == null) ? 0 : obj.swigCPtr; | |
1075 | } | |
1076 | %} | |
1077 | %enddef | |
1078 | ||
1079 | /* Set the default for SWIGTYPE: pointer constructor is protected, | |
1080 | getCPtr is protected. Season to your own taste! */ | |
1081 | ||
1082 | SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE) | |
1083 | ||
1084 | // Typewrapper classes | |
1085 | %typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{ | |
1086 | private long swigCPtr; | |
1087 | ||
1088 | protected $javaclassname(long cPtr, boolean futureUse) { | |
1089 | swigCPtr = cPtr; | |
1090 | } | |
1091 | ||
1092 | protected $javaclassname() { | |
1093 | swigCPtr = 0; | |
1094 | } | |
1095 | ||
1096 | protected static long getCPtr($javaclassname obj) { | |
1097 | return (obj == null) ? 0 : obj.swigCPtr; | |
1098 | } | |
1099 | %} | |
1100 | ||
1101 | %typemap(javafinalize) SWIGTYPE %{ | |
1102 | protected void finalize() { | |
1103 | delete(); | |
1104 | } | |
1105 | %} | |
1106 | ||
1107 | /* | |
1108 | * Java constructor typemaps: | |
1109 | * | |
1110 | * The javaconstruct typemap is inserted when a proxy class's constructor is generated. | |
1111 | * This typemap allows control over what code is executed in the constructor as | |
1112 | * well as specifying who owns the underlying C/C++ object. Normally, Java has | |
1113 | * ownership and the underlying C/C++ object is deallocated when the Java object | |
1114 | * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is | |
1115 | * ultimately responsible for deallocating the underlying object's memory. | |
1116 | * | |
1117 | * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy | |
1118 | * class for a particular TYPENAME. OWNERSHIP is passed as the value of | |
1119 | * swigCMemOwn to the pointer constructor method. WEAKREF determines which kind | |
1120 | * of Java object reference will be used by the C++ director class (WeakGlobalRef | |
1121 | * vs. GlobalRef.) | |
1122 | * | |
1123 | * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy | |
1124 | * classes and the weak reference flag to false, meaning that the underlying C++ | |
1125 | * object will be reclaimed by C++. | |
1126 | */ | |
1127 | ||
1128 | %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) | |
1129 | %typemap(javaconstruct,directorconnect="\n $moduleJNI.$javaclassname_director_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { | |
1130 | this($imcall, OWNERSHIP);$directorconnect | |
1131 | } | |
1132 | %enddef | |
1133 | ||
1134 | %define SWIG_DIRECTOR_OWNED(TYPENAME...) | |
1135 | SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) | |
1136 | %enddef | |
1137 | ||
1138 | // Set the default for SWIGTYPE: Java owns the C/C++ object. | |
1139 | SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) | |
1140 | ||
1141 | %typemap(javadestruct, methodname="delete") SWIGTYPE { | |
1142 | if(swigCPtr != 0 && swigCMemOwn) { | |
1143 | swigCMemOwn = false; | |
1144 | $jnicall; | |
1145 | } | |
1146 | swigCPtr = 0; | |
1147 | } | |
1148 | ||
1149 | %typemap(javadestruct_derived, methodname="delete") SWIGTYPE { | |
1150 | if(swigCPtr != 0 && swigCMemOwn) { | |
1151 | swigCMemOwn = false; | |
1152 | $jnicall; | |
1153 | } | |
1154 | swigCPtr = 0; | |
1155 | super.delete(); | |
1156 | } | |
1157 | ||
1158 | %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{ | |
1159 | protected void $methodname() { | |
1160 | swigCMemOwn = false; | |
1161 | $jnicall; | |
1162 | } | |
1163 | %} | |
1164 | ||
1165 | %typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{ | |
1166 | public void $methodname() { | |
1167 | swigCMemOwn = false; | |
1168 | $jnicall; | |
1169 | } | |
1170 | %} | |
1171 | ||
1172 | %typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{ | |
1173 | public void $methodname() { | |
1174 | swigCMemOwn = true; | |
1175 | $jnicall; | |
1176 | } | |
1177 | %} | |
1178 | ||
1179 | /* Java specific directives */ | |
1180 | #define %javaconst(flag) %feature("java:const","flag") | |
1181 | #define %javaconstvalue(value) %feature("java:constvalue",value) | |
1182 | #define %javaenum(wrapapproach) %feature("java:enum","wrapapproach") | |
1183 | #define %javamethodmodifiers %feature("java:methodmodifiers") | |
1184 | #define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses) | |
1185 | #define %nojavaexception %feature("except","",throws="") | |
1186 | ||
1187 | %pragma(java) jniclassclassmodifiers="class" | |
1188 | %pragma(java) moduleclassmodifiers="public class" | |
1189 | ||
1190 | /* Some ANSI C typemaps */ | |
1191 | ||
1192 | %apply unsigned long { size_t }; | |
1193 | ||
1194 | /* java keywords */ | |
1195 | /* please test and activate */ | |
1196 | //%include "javakw.swg" | |
1197 | ||
1198 | // Default enum handling | |
1199 | %include "enumtypesafe.swg" | |
1200 |