This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
update to JPL snapshot v09141999, with minor tweaks (from Brian
[perl5.git] / jpl / JNI / JNI.xs
1 /*
2  * Copyright 1997, O'Reilly & Associate, Inc.
3  *
4  * This package may be copied under the same terms as Perl itself.
5  */
6
7 #include "EXTERN.h"
8 #include "perl.h"
9 #include "XSUB.h"
10
11 #include <stdio.h>
12 #include <jni.h>
13
14 #ifndef PERL_VERSION
15 #  include <patchlevel.h>
16 #  define PERL_REVISION         5
17 #  define PERL_VERSION          PATCHLEVEL
18 #  define PERL_SUBVERSION       SUBVERSION
19 #endif
20
21 #if PERL_REVISION == 5 && (PERL_VERSION < 4 || \
22                            (PERL_VERSION == 4 && PERL_SUBVERSION <= 75))
23 #  define PL_na         na
24 #  define PL_sv_no      sv_no
25 #  define PL_sv_undef   sv_undef
26 #  define PL_dowarn     dowarn
27 #endif
28
29 #ifndef newSVpvn
30 #  define newSVpvn(a,b) newSVpv(a,b)
31 #endif
32
33 #ifndef pTHX
34 #  define pTHX          void
35 #  define pTHX_
36 #  define aTHX
37 #  define aTHX_
38 #  define dTHX          extern int JNI___notused
39 #endif
40
41 #ifndef WIN32
42 #  include <dlfcn.h>
43 #endif
44
45 #ifdef EMBEDDEDPERL
46 extern JNIEnv* jplcurenv;
47 extern int jpldebug;
48 #else
49 JNIEnv* jplcurenv;
50 int jpldebug = 1;
51 #endif
52
53 #define SysRet jint
54
55 #ifdef WIN32
56 static void JNICALL call_my_exit(jint status)
57 {
58     my_exit(status);
59 }
60 #else
61 static void call_my_exit(jint status)
62 {
63     my_exit(status);
64 }
65 #endif
66
67 jvalue*
68 makeargs(char *sig, SV** svp, int items)
69 {
70     jvalue* jv = (jvalue*)safemalloc(sizeof(jvalue) * items);
71     int ix = 0;
72     char *s = sig;
73     JNIEnv* env = jplcurenv;
74     char *start;
75     STRLEN n_a;
76
77     if (jpldebug)
78         fprintf(stderr, "sig = %s, items = %d\n", sig, items);
79     if (*s++ != '(')
80         goto cleanup;
81
82     while (items--) {
83         SV *sv = *svp++;
84         start = s;
85         switch (*s++) {
86         case 'Z':
87             jv[ix++].z = (jboolean)(SvIV(sv) != 0);
88             break;
89         case 'B':
90             jv[ix++].b = (jbyte)SvIV(sv);
91             break;
92         case 'C':
93             jv[ix++].c = (jchar)SvIV(sv);
94             break;
95         case 'S':
96             jv[ix++].s = (jshort)SvIV(sv);
97             break;
98         case 'I':
99             jv[ix++].i = (jint)SvIV(sv);
100             break;
101         case 'J':
102             jv[ix++].j = (jlong)SvNV(sv);
103             break;
104         case 'F':
105             jv[ix++].f = (jfloat)SvNV(sv);
106             break;
107         case 'D':
108             jv[ix++].d = (jdouble)SvNV(sv);
109             break;
110         case '[':
111             switch (*s++) {
112             case 'Z':
113                 if (SvROK(sv)) {
114                     SV* rv = (SV*)SvRV(sv);
115                     if (SvOBJECT(rv))
116                         jv[ix++].l = (jobject)(void*)SvIV(rv);
117                     else if (SvTYPE(rv) == SVt_PVAV) {
118                         jsize len = av_len((AV*)rv) + 1;
119                         jboolean* buf = (jboolean*)malloc(len * sizeof(jboolean));
120                         int i;
121                         SV** esv;
122
123 #ifdef WIN32
124                         jbooleanArray ja = env->NewBooleanArray(len);
125 #else
126                         jbooleanArray ja = (*env)->NewBooleanArray(env, len);
127 #endif
128                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
129                             buf[i] = (jboolean)SvIV(*esv);
130 #ifdef WIN32
131                         env->SetBooleanArrayRegion(ja, 0, len, buf);
132 #else
133                         (*env)->SetBooleanArrayRegion(env, ja, 0, len, buf);
134 #endif
135                         free((void*)buf);
136                         jv[ix++].l = (jobject)ja;
137                     }
138                     else
139                         jv[ix++].l = (jobject)(void*)0;
140                 }
141                 else if (SvPOK(sv)) {
142                     jsize len = sv_len(sv) / sizeof(jboolean);
143
144 #ifdef WIN32
145                     jbooleanArray ja = env->NewBooleanArray(len);
146 #else
147                     jbooleanArray ja = (*env)->NewBooleanArray(env, len);
148 #endif
149 #ifdef WIN32
150                     env->SetBooleanArrayRegion(ja, 0, len, (jboolean*)SvPV(sv,n_a));
151 #else
152                     (*env)->SetBooleanArrayRegion(env, ja, 0, len, (jboolean*)SvPV(sv,n_a));
153 #endif
154                     jv[ix++].l = (jobject)ja;
155                 }
156                 else
157                     jv[ix++].l = (jobject)(void*)0;
158                 break;
159             case 'B':
160                 if (SvROK(sv)) {
161                     SV* rv = (SV*)SvRV(sv);
162                     if (SvOBJECT(rv))
163                         jv[ix++].l = (jobject)(void*)SvIV(rv);
164                     else if (SvTYPE(rv) == SVt_PVAV) {
165                         jsize len = av_len((AV*)rv) + 1;
166                         jbyte* buf = (jbyte*)malloc(len * sizeof(jbyte));
167                         int i;
168                         SV** esv;
169
170 #ifdef WIN32
171                         jbyteArray ja = env->NewByteArray(len);
172 #else
173                         jbyteArray ja = (*env)->NewByteArray(env, len);
174 #endif
175                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
176                             buf[i] = (jbyte)SvIV(*esv);
177 #ifdef WIN32
178                         env->SetByteArrayRegion(ja, 0, len, buf);
179 #else
180                         (*env)->SetByteArrayRegion(env, ja, 0, len, buf);
181 #endif
182                         free((void*)buf);
183                         jv[ix++].l = (jobject)ja;
184                     }
185                     else
186                         jv[ix++].l = (jobject)(void*)0;
187                 }
188                 else if (SvPOK(sv)) {
189                     jsize len = sv_len(sv) / sizeof(jbyte);
190
191 #ifdef WIN32
192                     jbyteArray ja = env->NewByteArray(len);
193 #else
194                     jbyteArray ja = (*env)->NewByteArray(env, len);
195 #endif
196 #ifdef WIN32
197                     env->SetByteArrayRegion(ja, 0, len, (jbyte*)SvPV(sv,n_a));
198 #else
199                     (*env)->SetByteArrayRegion(env, ja, 0, len, (jbyte*)SvPV(sv,n_a));
200 #endif
201                     jv[ix++].l = (jobject)ja;
202                 }
203                 else
204                     jv[ix++].l = (jobject)(void*)0;
205                 break;
206             case 'C':
207                 if (SvROK(sv)) {
208                     SV* rv = (SV*)SvRV(sv);
209                     if (SvOBJECT(rv))
210                         jv[ix++].l = (jobject)(void*)SvIV(rv);
211                     else if (SvTYPE(rv) == SVt_PVAV) {
212                         jsize len = av_len((AV*)rv) + 1;
213                         jchar* buf = (jchar*)malloc(len * sizeof(jchar));
214                         int i;
215                         SV** esv;
216
217 #ifdef WIN32
218                         jcharArray ja = env->NewCharArray(len);
219 #else
220                         jcharArray ja = (*env)->NewCharArray(env, len);
221 #endif
222                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
223                             buf[i] = (jchar)SvIV(*esv);
224 #ifdef WIN32
225                         env->SetCharArrayRegion(ja, 0, len, buf);
226 #else
227                         (*env)->SetCharArrayRegion(env, ja, 0, len, buf);
228 #endif
229                         free((void*)buf);
230                         jv[ix++].l = (jobject)ja;
231                     }
232                     else
233                         jv[ix++].l = (jobject)(void*)0;
234                 }
235                 else if (SvPOK(sv)) {
236                     jsize len = sv_len(sv) / sizeof(jchar);
237
238 #ifdef WIN32
239                     jcharArray ja = env->NewCharArray(len);
240 #else
241                     jcharArray ja = (*env)->NewCharArray(env, len);
242 #endif
243 #ifdef WIN32
244                     env->SetCharArrayRegion(ja, 0, len, (jchar*)SvPV(sv,n_a));
245 #else
246                     (*env)->SetCharArrayRegion(env, ja, 0, len, (jchar*)SvPV(sv,n_a));
247 #endif
248                     jv[ix++].l = (jobject)ja;
249                 }
250                 else
251                     jv[ix++].l = (jobject)(void*)0;
252                 break;
253             case 'S':
254                 if (SvROK(sv)) {
255                     SV* rv = (SV*)SvRV(sv);
256                     if (SvOBJECT(rv))
257                         jv[ix++].l = (jobject)(void*)SvIV(rv);
258                     else if (SvTYPE(rv) == SVt_PVAV) {
259                         jsize len = av_len((AV*)rv) + 1;
260                         jshort* buf = (jshort*)malloc(len * sizeof(jshort));
261                         int i;
262                         SV** esv;
263
264 #ifdef WIN32
265                         jshortArray ja = env->NewShortArray(len);
266 #else
267                         jshortArray ja = (*env)->NewShortArray(env, len);
268 #endif
269                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
270                             buf[i] = (jshort)SvIV(*esv);
271 #ifdef WIN32
272                         env->SetShortArrayRegion(ja, 0, len, buf);
273 #else
274                         (*env)->SetShortArrayRegion(env, ja, 0, len, buf);
275 #endif
276                         free((void*)buf);
277                         jv[ix++].l = (jobject)ja;
278                     }
279                     else
280                         jv[ix++].l = (jobject)(void*)0;
281                 }
282                 else if (SvPOK(sv)) {
283                     jsize len = sv_len(sv) / sizeof(jshort);
284
285 #ifdef WIN32
286                     jshortArray ja = env->NewShortArray(len);
287 #else
288                     jshortArray ja = (*env)->NewShortArray(env, len);
289 #endif
290 #ifdef WIN32
291                     env->SetShortArrayRegion(ja, 0, len, (jshort*)SvPV(sv,n_a));
292 #else
293                     (*env)->SetShortArrayRegion(env, ja, 0, len, (jshort*)SvPV(sv,n_a));
294 #endif
295                     jv[ix++].l = (jobject)ja;
296                 }
297                 else
298                     jv[ix++].l = (jobject)(void*)0;
299                 break;
300             case 'I':
301                 if (SvROK(sv)) {
302                     SV* rv = (SV*)SvRV(sv);
303                     if (SvOBJECT(rv))
304                         jv[ix++].l = (jobject)(void*)SvIV(rv);
305                     else if (SvTYPE(rv) == SVt_PVAV) {
306                         jsize len = av_len((AV*)rv) + 1;
307                         jint* buf = (jint*)malloc(len * sizeof(jint));
308                         int i;
309                         SV** esv;
310
311 #ifdef WIN32
312                         jintArray ja = env->NewIntArray(len);
313 #else
314                         jintArray ja = (*env)->NewIntArray(env, len);
315 #endif
316                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
317                             buf[i] = (jint)SvIV(*esv);
318 #ifdef WIN32
319                         env->SetIntArrayRegion(ja, 0, len, buf);
320 #else
321                         (*env)->SetIntArrayRegion(env, ja, 0, len, buf);
322 #endif
323                         free((void*)buf);
324                         jv[ix++].l = (jobject)ja;
325                     }
326                     else
327                         jv[ix++].l = (jobject)(void*)0;
328                 }
329                 else if (SvPOK(sv)) {
330                     jsize len = sv_len(sv) / sizeof(jint);
331
332 #ifdef WIN32
333                     jintArray ja = env->NewIntArray(len);
334 #else
335                     jintArray ja = (*env)->NewIntArray(env, len);
336 #endif
337 #ifdef WIN32
338                     env->SetIntArrayRegion(ja, 0, len, (jint*)SvPV(sv,n_a));
339 #else
340                     (*env)->SetIntArrayRegion(env, ja, 0, len, (jint*)SvPV(sv,n_a));
341 #endif
342                     jv[ix++].l = (jobject)ja;
343                 }
344                 else
345                     jv[ix++].l = (jobject)(void*)0;
346                 break;
347             case 'J':
348                 if (SvROK(sv)) {
349                     SV* rv = (SV*)SvRV(sv);
350                     if (SvOBJECT(rv))
351                         jv[ix++].l = (jobject)(void*)SvIV(rv);
352                     else if (SvTYPE(rv) == SVt_PVAV) {
353                         jsize len = av_len((AV*)rv) + 1;
354                         jlong* buf = (jlong*)malloc(len * sizeof(jlong));
355                         int i;
356                         SV** esv;
357
358 #ifdef WIN32
359                         jlongArray ja = env->NewLongArray(len);
360 #else
361                         jlongArray ja = (*env)->NewLongArray(env, len);
362 #endif
363                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
364                             buf[i] = (jlong)SvNV(*esv);
365 #ifdef WIN32
366                         env->SetLongArrayRegion(ja, 0, len, buf);
367 #else
368                         (*env)->SetLongArrayRegion(env, ja, 0, len, buf);
369 #endif
370                         free((void*)buf);
371                         jv[ix++].l = (jobject)ja;
372                     }
373                     else
374                         jv[ix++].l = (jobject)(void*)0;
375                 }
376                 else if (SvPOK(sv)) {
377                     jsize len = sv_len(sv) / sizeof(jlong);
378
379 #ifdef WIN32
380                     jlongArray ja = env->NewLongArray(len);
381 #else
382                     jlongArray ja = (*env)->NewLongArray(env, len);
383 #endif
384 #ifdef WIN32
385                     env->SetLongArrayRegion(ja, 0, len, (jlong*)SvPV(sv,n_a));
386 #else
387                     (*env)->SetLongArrayRegion(env, ja, 0, len, (jlong*)SvPV(sv,n_a));
388 #endif
389                     jv[ix++].l = (jobject)ja;
390                 }
391                 else
392                     jv[ix++].l = (jobject)(void*)0;
393                 break;
394             case 'F':
395                 if (SvROK(sv)) {
396                     SV* rv = (SV*)SvRV(sv);
397                     if (SvOBJECT(rv))
398                         jv[ix++].l = (jobject)(void*)SvIV(rv);
399                     else if (SvTYPE(rv) == SVt_PVAV) {
400                         jsize len = av_len((AV*)rv) + 1;
401                         jfloat* buf = (jfloat*)malloc(len * sizeof(jfloat));
402                         int i;
403                         SV** esv;
404
405 #ifdef WIN32
406                         jfloatArray ja = env->NewFloatArray(len);
407 #else
408                         jfloatArray ja = (*env)->NewFloatArray(env, len);
409 #endif
410                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
411                             buf[i] = (jfloat)SvNV(*esv);
412 #ifdef WIN32
413                         env->SetFloatArrayRegion(ja, 0, len, buf);
414 #else
415                         (*env)->SetFloatArrayRegion(env, ja, 0, len, buf);
416 #endif
417                         free((void*)buf);
418                         jv[ix++].l = (jobject)ja;
419                     }
420                     else
421                         jv[ix++].l = (jobject)(void*)0;
422                 }
423                 else if (SvPOK(sv)) {
424                     jsize len = sv_len(sv) / sizeof(jfloat);
425
426 #ifdef WIN32
427                     jfloatArray ja = env->NewFloatArray(len);
428 #else
429                     jfloatArray ja = (*env)->NewFloatArray(env, len);
430 #endif
431 #ifdef WIN32
432                     env->SetFloatArrayRegion(ja, 0, len, (jfloat*)SvPV(sv,n_a));
433 #else
434                     (*env)->SetFloatArrayRegion(env, ja, 0, len, (jfloat*)SvPV(sv,n_a));
435 #endif
436                     jv[ix++].l = (jobject)ja;
437                 }
438                 else
439                     jv[ix++].l = (jobject)(void*)0;
440                 break;
441             case 'D':
442                 if (SvROK(sv)) {
443                     SV* rv = (SV*)SvRV(sv);
444                     if (SvOBJECT(rv))
445                         jv[ix++].l = (jobject)(void*)SvIV(rv);
446                     else if (SvTYPE(rv) == SVt_PVAV) {
447                         jsize len = av_len((AV*)rv) + 1;
448                         jdouble* buf = (jdouble*)malloc(len * sizeof(jdouble));
449                         int i;
450                         SV** esv;
451
452 #ifdef WIN32
453                         jdoubleArray ja = env->NewDoubleArray(len);
454 #else
455                         jdoubleArray ja = (*env)->NewDoubleArray(env, len);
456 #endif
457                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++)
458                             buf[i] = (jdouble)SvNV(*esv);
459 #ifdef WIN32
460                         env->SetDoubleArrayRegion(ja, 0, len, buf);
461 #else
462                         (*env)->SetDoubleArrayRegion(env, ja, 0, len, buf);
463 #endif
464                         free((void*)buf);
465                         jv[ix++].l = (jobject)ja;
466                     }
467                     else
468                         jv[ix++].l = (jobject)(void*)0;
469                 }
470                 else if (SvPOK(sv)) {
471                     jsize len = sv_len(sv) / sizeof(jdouble);
472
473 #ifdef WIN32
474                     jdoubleArray ja = env->NewDoubleArray(len);
475 #else
476                     jdoubleArray ja = (*env)->NewDoubleArray(env, len);
477 #endif
478 #ifdef WIN32
479                     env->SetDoubleArrayRegion(ja, 0, len, (jdouble*)SvPV(sv,n_a));
480 #else
481                     (*env)->SetDoubleArrayRegion(env, ja, 0, len, (jdouble*)SvPV(sv,n_a));
482 #endif
483                     jv[ix++].l = (jobject)ja;
484                 }
485                 else
486                     jv[ix++].l = (jobject)(void*)0;
487                 break;
488             case 'L':
489                 while (*s != ';') s++;
490                 s++;
491                 if (strnEQ(start, "[Ljava/lang/String;", 19)) {
492                     if (SvROK(sv)) {
493                         SV* rv = (SV*)SvRV(sv);
494                         if (SvOBJECT(rv))
495                             jv[ix++].l = (jobject)(void*)SvIV(rv);
496                         else if (SvTYPE(rv) == SVt_PVAV) {
497                             jsize len = av_len((AV*)rv) + 1;
498                             int i;
499                             SV** esv;
500                             static jclass jcl = 0;
501                             jobjectArray ja;
502
503                             if (!jcl)
504 #ifdef WIN32
505                                 jcl = env->FindClass("java/lang/String");
506 #else
507                                 jcl = (*env)->FindClass(env, "java/lang/String");
508 #endif
509 #ifdef WIN32
510                             ja = env->NewObjectArray(len, jcl, 0);
511 #else
512                             ja = (*env)->NewObjectArray(env, len, jcl, 0);
513 #endif
514                             for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++) {
515 #ifdef WIN32
516                                 jobject str = (jobject)env->NewStringUTF(SvPV(*esv,n_a));
517 #else
518                                 jobject str = (jobject)(*env)->NewStringUTF(env, SvPV(*esv,n_a));
519 #endif
520 #ifdef WIN32
521                                 env->SetObjectArrayElement(ja, i, str);
522 #else
523                                 (*env)->SetObjectArrayElement(env, ja, i, str);
524 #endif
525                             }
526                             jv[ix++].l = (jobject)ja;
527                         }
528                         else
529                             jv[ix++].l = (jobject)(void*)0;
530                     }
531                     else
532                         jv[ix++].l = (jobject)(void*)0;
533                     break;
534                 }
535                 /* FALL THROUGH */
536             default:
537                 if (SvROK(sv)) {
538                     SV* rv = (SV*)SvRV(sv);
539                     if (SvOBJECT(rv))
540                         jv[ix++].l = (jobject)(void*)SvIV(rv);
541                     else if (SvTYPE(rv) == SVt_PVAV) {
542                         jsize len = av_len((AV*)rv) + 1;
543                         int i;
544                         SV** esv;
545                        static jclass jcl = 0;
546                         jobjectArray ja;
547
548                         if (!jcl)
549 #ifdef WIN32
550                             jcl = env->FindClass("java/lang/Object");
551 #else
552                             jcl = (*env)->FindClass(env, "java/lang/Object");
553 #endif
554 #ifdef WIN32
555                         ja = env->NewObjectArray(len, jcl, 0);
556 #else
557                         ja = (*env)->NewObjectArray(env, len, jcl, 0);
558 #endif
559                         for (esv = AvARRAY((AV*)rv), i = 0; i < len; esv++, i++) {
560                             if (SvROK(*esv) && (rv = SvRV(*esv)) && SvOBJECT(rv)) {
561 #ifdef WIN32
562                                 env->SetObjectArrayElement(ja, i, (jobject)(void*)SvIV(rv));
563 #else
564                                 (*env)->SetObjectArrayElement(env, ja, i, (jobject)(void*)SvIV(rv));
565 #endif
566                             }
567                             else {
568 #ifdef WIN32
569                                 jobject str = (jobject)env->NewStringUTF(SvPV(*esv,n_a));
570 #else
571                                 jobject str = (jobject)(*env)->NewStringUTF(env, SvPV(*esv,n_a));
572 #endif
573 #ifdef WIN32
574                                 env->SetObjectArrayElement(ja, i, str);
575 #else
576                                 (*env)->SetObjectArrayElement(env, ja, i, str);
577 #endif
578                             }
579                         }
580                         jv[ix++].l = (jobject)ja;
581                     }
582                     else
583                         jv[ix++].l = (jobject)(void*)0;
584                 }
585                 else
586                     jv[ix++].l = (jobject)(void*)0;
587                 break;
588             }
589             break;
590         case 'L':
591             if (!SvROK(sv) || strnEQ(s, "java/lang/String;", 17)) {
592                 s += 17;
593 #ifdef WIN32
594                 jv[ix++].l = (jobject)env->NewStringUTF((char*) SvPV(sv,n_a));
595 #else
596                 jv[ix++].l = (jobject)(*env)->NewStringUTF(env, (char*) SvPV(sv,n_a));
597 #endif
598                 break;
599             }
600             while (*s != ';') s++;
601             s++;
602             if (SvROK(sv)) {
603                 SV* rv = SvRV(sv);
604                 jv[ix++].l = (jobject)(void*)SvIV(rv);
605             }
606             break;
607         case ')':
608             croak("too many arguments, signature: %s", sig);
609             goto cleanup;
610         default:
611             croak("panic: malformed signature: %s", s-1);
612             goto cleanup;
613         }
614
615     }
616     if (*s != ')') {
617         croak("not enough arguments, signature: %s", sig);
618         goto cleanup;
619     }
620     return jv;
621
622 cleanup:
623     safefree((char*)jv);
624     return 0;
625 }
626
627 static int
628 not_here(char *s)
629 {
630     croak("%s not implemented on this architecture", s);
631     return -1;
632 }
633
634 static double
635 constant(char *name, int arg)
636 {
637     errno = 0;
638     switch (*name) {
639     case 'A':
640         break;
641     case 'B':
642         break;
643     case 'C':
644         break;
645     case 'D':
646         break;
647     case 'E':
648         break;
649     case 'F':
650         break;
651     case 'G':
652         break;
653     case 'H':
654         break;
655     case 'I':
656         break;
657     case 'J':
658         if (strEQ(name, "JNI_ABORT"))
659 #ifdef JNI_ABORT
660             return JNI_ABORT;
661 #else
662             goto not_there;
663 #endif
664         if (strEQ(name, "JNI_COMMIT"))
665 #ifdef JNI_COMMIT
666             return JNI_COMMIT;
667 #else
668             goto not_there;
669 #endif
670         if (strEQ(name, "JNI_ERR"))
671 #ifdef JNI_ERR
672             return JNI_ERR;
673 #else
674             goto not_there;
675 #endif
676         if (strEQ(name, "JNI_FALSE"))
677 #ifdef JNI_FALSE
678             return JNI_FALSE;
679 #else
680             goto not_there;
681 #endif
682         if (strEQ(name, "JNI_H"))
683 #ifdef JNI_H
684 #ifdef WIN32
685             return 1;
686 #else
687             return JNI_H;
688 #endif
689 #else
690             goto not_there;
691 #endif
692         if (strEQ(name, "JNI_OK"))
693 #ifdef JNI_OK
694             return JNI_OK;
695 #else
696             goto not_there;
697 #endif
698         if (strEQ(name, "JNI_TRUE"))
699 #ifdef JNI_TRUE
700             return JNI_TRUE;
701 #else
702             goto not_there;
703 #endif
704         break;
705     case 'K':
706         break;
707     case 'L':
708         break;
709     case 'M':
710         break;
711     case 'N':
712         break;
713     case 'O':
714         break;
715     case 'P':
716         break;
717     case 'Q':
718         break;
719     case 'R':
720         break;
721     case 'S':
722         break;
723     case 'T':
724         break;
725     case 'U':
726         break;
727     case 'V':
728         break;
729     case 'W':
730         break;
731     case 'X':
732         break;
733     case 'Y':
734         break;
735     case 'Z':
736         break;
737     }
738     errno = EINVAL;
739     return 0;
740
741 not_there:
742     errno = ENOENT;
743     return 0;
744 }
745
746 #define FETCHENV jplcurenv
747 #define RESTOREENV jplcurenv = env
748
749 MODULE = JNI            PACKAGE = JNI           
750
751 PROTOTYPES: ENABLE
752
753 double
754 constant(name,arg)
755         char *          name
756         int             arg
757
758 jint
759 GetVersion()
760         JNIEnv *                env = FETCHENV;
761     CODE:
762         {
763 #ifdef WIN32
764             RETVAL = env->GetVersion();
765 #else
766             RETVAL = (*env)->GetVersion(env);
767 #endif
768             RESTOREENV;
769         }
770     OUTPUT:
771         RETVAL
772
773 jclass
774 DefineClass(name, loader, buf)
775         JNIEnv *                env = FETCHENV;
776         STRLEN                  tmplen = NO_INIT;
777         jsize                   buf_len_ = NO_INIT;
778         const char *            name
779         jobject                 loader
780         const jbyte *           buf
781     CODE:
782         {
783 #ifdef KAFFE
784 #ifdef WIN32
785             RETVAL = env->DefineClass( loader, buf, (jsize)buf_len_);
786 #else
787             RETVAL = (*env)->DefineClass(env,  loader, buf, (jsize)buf_len_);
788 #endif
789 #else
790 #ifdef WIN32
791             RETVAL = env->DefineClass( name, loader, buf, (jsize)buf_len_); 
792 #else
793             RETVAL = (*env)->DefineClass(env,  name, loader, buf, (jsize)buf_len_); 
794 #endif
795 #endif
796             RESTOREENV;
797         }
798     OUTPUT:
799         RETVAL
800
801 jclass
802 FindClass(name)
803         JNIEnv *                env = FETCHENV;
804         const char *            name
805     CODE:
806         {
807 #ifdef WIN32
808             RETVAL = env->FindClass( name);
809 #else
810             RETVAL = (*env)->FindClass(env,  name);
811 #endif
812             RESTOREENV;
813         }
814     OUTPUT:
815         RETVAL
816
817 jclass
818 GetSuperclass(sub)
819         JNIEnv *                env = FETCHENV;
820         jclass                  sub
821     CODE:
822         {
823 #ifdef WIN32
824             RETVAL = env->GetSuperclass( sub);
825 #else
826             RETVAL = (*env)->GetSuperclass(env,  sub);
827 #endif
828             RESTOREENV;
829         }
830     OUTPUT:
831         RETVAL
832
833 jboolean
834 IsAssignableFrom(sub, sup)
835         JNIEnv *                env = FETCHENV;
836         jclass                  sub
837         jclass                  sup
838     CODE:
839         {
840 #ifdef WIN32
841             RETVAL = env->IsAssignableFrom( sub, sup);
842 #else
843             RETVAL = (*env)->IsAssignableFrom(env,  sub, sup);
844 #endif
845             RESTOREENV;
846         }
847     OUTPUT:
848         RETVAL
849
850 SysRet
851 Throw(obj)
852         JNIEnv *                env = FETCHENV;
853         jthrowable              obj
854     CODE:
855         {
856 #ifdef WIN32
857             RETVAL = env->Throw( obj);
858 #else
859             RETVAL = (*env)->Throw(env,  obj);
860 #endif
861             RESTOREENV;
862         }
863     OUTPUT:
864         RETVAL    
865
866 SysRet
867 ThrowNew(clazz, msg)
868         JNIEnv *                env = FETCHENV;
869         jclass                  clazz
870         const char *            msg
871     CODE:
872         {
873 #ifdef WIN32
874             RETVAL = env->ThrowNew( clazz, msg);
875 #else
876             RETVAL = (*env)->ThrowNew(env,  clazz, msg);
877 #endif
878             RESTOREENV;
879         }
880     OUTPUT:
881         RETVAL
882
883 jthrowable
884 ExceptionOccurred()
885         JNIEnv *                env = FETCHENV;
886     CODE:
887         {
888 #ifdef WIN32
889             RETVAL = env->ExceptionOccurred();
890 #else
891             RETVAL = (*env)->ExceptionOccurred(env);
892 #endif
893             RESTOREENV;
894         }
895     OUTPUT:
896         RETVAL
897
898 void
899 ExceptionDescribe()
900         JNIEnv *                env = FETCHENV;
901     CODE:
902         {
903 #ifdef WIN32
904             env->ExceptionDescribe();
905 #else
906             (*env)->ExceptionDescribe(env);
907 #endif
908             RESTOREENV;
909         }
910
911 void
912 ExceptionClear()
913         JNIEnv *                env = FETCHENV;
914     CODE:
915         {
916 #ifdef WIN32
917             env->ExceptionClear();
918 #else
919             (*env)->ExceptionClear(env);
920 #endif
921             RESTOREENV;
922         }
923
924 void
925 FatalError(msg)
926         JNIEnv *                env = FETCHENV;
927         const char *            msg
928     CODE:
929         {
930 #ifdef WIN32
931             env->FatalError( msg);
932 #else
933             (*env)->FatalError(env,  msg);
934 #endif
935             RESTOREENV;
936         }
937
938 jobject
939 NewGlobalRef(lobj)
940         JNIEnv *                env = FETCHENV;
941         jobject                 lobj
942     CODE:
943         {
944 #ifdef WIN32
945             RETVAL = env->NewGlobalRef(lobj);
946 #else
947             RETVAL = (*env)->NewGlobalRef(env, lobj);
948 #endif
949             RESTOREENV;
950         }
951     OUTPUT:
952         RETVAL
953
954 void
955 DeleteGlobalRef(gref)
956         JNIEnv *                env = FETCHENV;
957         jobject                 gref
958     CODE:
959         {
960 #ifdef WIN32
961             env->DeleteGlobalRef(gref);
962 #else
963             (*env)->DeleteGlobalRef(env, gref);
964 #endif
965             RESTOREENV;
966         }
967
968 void
969 DeleteLocalRef(obj)
970         JNIEnv *                env = FETCHENV;
971         jobject                 obj
972     CODE:
973         {
974 #ifdef WIN32
975             env->DeleteLocalRef( obj);
976 #else
977             (*env)->DeleteLocalRef(env,  obj);
978 #endif
979             RESTOREENV;
980         }
981
982 jboolean
983 IsSameObject(obj1,obj2)
984         JNIEnv *                env = FETCHENV;
985         jobject                 obj1
986         jobject                 obj2
987     CODE:
988         {
989 #ifdef WIN32
990             RETVAL = env->IsSameObject(obj1,obj2);
991 #else
992             RETVAL = (*env)->IsSameObject(env, obj1,obj2);
993 #endif
994             RESTOREENV;
995         }
996     OUTPUT:
997         RETVAL
998
999 jobject
1000 AllocObject(clazz)
1001         JNIEnv *                env = FETCHENV;
1002         jclass                  clazz
1003     CODE:
1004         {
1005 #ifdef WIN32
1006             RETVAL = env->AllocObject(clazz);
1007 #else
1008             RETVAL = (*env)->AllocObject(env, clazz);
1009 #endif
1010             RESTOREENV;
1011         }
1012     OUTPUT:
1013         RETVAL
1014
1015 jobject
1016 NewObject(clazz,methodID,...)
1017         JNIEnv *                env = FETCHENV;
1018         jclass                  clazz
1019         jmethodID               methodID
1020         char *                  sig = 0;
1021         int                     argoff = $min_args;
1022     CODE:
1023         {
1024             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1025 #ifdef WIN32
1026             RETVAL = env->NewObjectA(clazz,methodID,args);
1027 #else
1028             RETVAL = (*env)->NewObjectA(env, clazz,methodID,args);
1029 #endif
1030             RESTOREENV;
1031         }
1032     OUTPUT:
1033         RETVAL
1034
1035 jobject
1036 NewObjectA(clazz,methodID,args)
1037         JNIEnv *                env = FETCHENV;
1038         jclass                  clazz
1039         jmethodID               methodID
1040         char *                  sig = 0;
1041         jvalue *                args
1042     CODE:
1043         {
1044 #ifdef WIN32
1045             RETVAL = env->NewObjectA(clazz,methodID,args);
1046 #else
1047             RETVAL = (*env)->NewObjectA(env, clazz,methodID,args);
1048 #endif
1049             RESTOREENV;
1050         }
1051     OUTPUT:
1052         RETVAL
1053
1054 jclass
1055 GetObjectClass(obj)
1056         JNIEnv *                env = FETCHENV;
1057         jobject                 obj
1058     CODE:
1059         {
1060 #ifdef WIN32
1061             RETVAL = env->GetObjectClass(obj);
1062 #else
1063             RETVAL = (*env)->GetObjectClass(env, obj);
1064 #endif
1065             RESTOREENV;
1066         }
1067     OUTPUT:
1068         RETVAL
1069
1070 jboolean
1071 IsInstanceOf(obj,clazz)
1072         JNIEnv *                env = FETCHENV;
1073         jobject                 obj
1074         jclass                  clazz
1075     CODE:
1076         {
1077 #ifdef WIN32
1078             RETVAL = env->IsInstanceOf(obj,clazz);
1079 #else
1080             RETVAL = (*env)->IsInstanceOf(env, obj,clazz);
1081 #endif
1082             RESTOREENV;
1083         }
1084     OUTPUT:
1085         RETVAL
1086
1087 jmethodID
1088 GetMethodID(clazz,name,sig)
1089         JNIEnv *                env = FETCHENV;
1090         jclass                  clazz
1091         const char *            name
1092         const char *            sig
1093     CODE:
1094         {
1095 #ifdef WIN32
1096             RETVAL = env->GetMethodID(clazz,name,sig);
1097 #else
1098             RETVAL = (*env)->GetMethodID(env, clazz,name,sig);
1099 #endif
1100             RESTOREENV;
1101         }
1102     OUTPUT:
1103         RETVAL
1104
1105 jobject
1106 CallObjectMethod(obj,methodID,...)
1107         JNIEnv *                env = FETCHENV;
1108         jobject                 obj
1109         jmethodID               methodID
1110         char *                  sig = 0;
1111         int                     argoff = $min_args;
1112     CODE:
1113         {
1114             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1115 #ifdef WIN32
1116             RETVAL = env->CallObjectMethodA(obj,methodID,args);
1117 #else
1118             RETVAL = (*env)->CallObjectMethodA(env, obj,methodID,args);
1119 #endif
1120             RESTOREENV;
1121         }
1122     OUTPUT:
1123         RETVAL
1124
1125 jobject
1126 CallObjectMethodA(obj,methodID,args)
1127         JNIEnv *                env = FETCHENV;
1128         jobject                 obj
1129         jmethodID               methodID
1130         char *                  sig = 0;
1131         jvalue *                args
1132     CODE:
1133         {
1134 #ifdef WIN32
1135             RETVAL = env->CallObjectMethodA(obj,methodID,args);
1136 #else
1137             RETVAL = (*env)->CallObjectMethodA(env, obj,methodID,args);
1138 #endif
1139             RESTOREENV;
1140         }
1141     OUTPUT:
1142         RETVAL
1143
1144 jboolean
1145 CallBooleanMethod(obj,methodID,...)
1146         JNIEnv *                env = FETCHENV;
1147         jobject                 obj
1148         jmethodID               methodID
1149         char *                  sig = 0;
1150         int                     argoff = $min_args;
1151     CODE:
1152         {
1153             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1154 #ifdef WIN32
1155             RETVAL = env->CallBooleanMethodA(obj,methodID,args);
1156 #else
1157             RETVAL = (*env)->CallBooleanMethodA(env, obj,methodID,args);
1158 #endif
1159             RESTOREENV;
1160         }
1161     OUTPUT:
1162         RETVAL
1163
1164 jboolean
1165 CallBooleanMethodA(obj,methodID, args)
1166         JNIEnv *                env = FETCHENV;
1167         jobject                 obj
1168         jmethodID               methodID
1169         char *                  sig = 0;
1170         jvalue *                args
1171     CODE:
1172         {
1173 #ifdef WIN32
1174             RETVAL = env->CallBooleanMethodA(obj,methodID, args);
1175 #else
1176             RETVAL = (*env)->CallBooleanMethodA(env, obj,methodID, args);
1177 #endif
1178             RESTOREENV;
1179         }
1180     OUTPUT:
1181         RETVAL
1182
1183 jbyte
1184 CallByteMethod(obj,methodID,...)
1185         JNIEnv *                env = FETCHENV;
1186         jobject                 obj
1187         jmethodID               methodID
1188         char *                  sig = 0;
1189         int                     argoff = $min_args;
1190     CODE:
1191         {
1192             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1193 #ifdef WIN32
1194             RETVAL = env->CallByteMethodA(obj,methodID,args);
1195 #else
1196             RETVAL = (*env)->CallByteMethodA(env, obj,methodID,args);
1197 #endif
1198             RESTOREENV;
1199         }
1200     OUTPUT:
1201         RETVAL
1202
1203 jbyte
1204 CallByteMethodA(obj,methodID,args)
1205         JNIEnv *                env = FETCHENV;
1206         jobject                 obj
1207         jmethodID               methodID
1208         char *                  sig = 0;
1209         jvalue *                args
1210     CODE:
1211         {
1212 #ifdef WIN32
1213             RETVAL = env->CallByteMethodA(obj,methodID,args);
1214 #else
1215             RETVAL = (*env)->CallByteMethodA(env, obj,methodID,args);
1216 #endif
1217             RESTOREENV;
1218         }
1219     OUTPUT:
1220         RETVAL
1221
1222 jchar
1223 CallCharMethod(obj,methodID,...)
1224         JNIEnv *                env = FETCHENV;
1225         jobject                 obj
1226         jmethodID               methodID
1227         char *                  sig = 0;
1228         int                     argoff = $min_args;
1229     CODE:
1230         {
1231             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1232 #ifdef WIN32
1233             RETVAL = env->CallCharMethodA(obj,methodID,args);
1234 #else
1235             RETVAL = (*env)->CallCharMethodA(env, obj,methodID,args);
1236 #endif
1237             RESTOREENV;
1238         }
1239     OUTPUT:
1240         RETVAL
1241
1242 jchar
1243 CallCharMethodA(obj,methodID,args)
1244         JNIEnv *                env = FETCHENV;
1245         jobject                 obj
1246         jmethodID               methodID
1247         char *                  sig = 0;
1248         jvalue *                args
1249     CODE:
1250         {
1251 #ifdef WIN32
1252             RETVAL = env->CallCharMethodA(obj,methodID,args);
1253 #else
1254             RETVAL = (*env)->CallCharMethodA(env, obj,methodID,args);
1255 #endif
1256             RESTOREENV;
1257         }
1258     OUTPUT:
1259         RETVAL
1260
1261 jshort
1262 CallShortMethod(obj,methodID,...)
1263         JNIEnv *                env = FETCHENV;
1264         jobject                 obj
1265         jmethodID               methodID
1266         char *                  sig = 0;
1267         int                     argoff = $min_args;
1268     CODE:
1269         {
1270             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1271 #ifdef WIN32
1272             RETVAL = env->CallShortMethodA(obj,methodID,args);
1273 #else
1274             RETVAL = (*env)->CallShortMethodA(env, obj,methodID,args);
1275 #endif
1276             RESTOREENV;
1277         }
1278     OUTPUT:
1279         RETVAL
1280
1281 jshort
1282 CallShortMethodA(obj,methodID,args)
1283         JNIEnv *                env = FETCHENV;
1284         jobject                 obj
1285         jmethodID               methodID
1286         char *                  sig = 0;
1287         jvalue *                args
1288     CODE:
1289         {
1290 #ifdef WIN32
1291             RETVAL = env->CallShortMethodA(obj,methodID,args);
1292 #else
1293             RETVAL = (*env)->CallShortMethodA(env, obj,methodID,args);
1294 #endif
1295             RESTOREENV;
1296         }
1297     OUTPUT:
1298         RETVAL
1299
1300 jint
1301 CallIntMethod(obj,methodID,...)
1302         JNIEnv *                env = FETCHENV;
1303         jobject                 obj
1304         jmethodID               methodID
1305         char *                  sig = 0;
1306         int                     argoff = $min_args;
1307     CODE:
1308         {
1309             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1310 #ifdef WIN32
1311             RETVAL = env->CallIntMethodA(obj,methodID,args);
1312 #else
1313             RETVAL = (*env)->CallIntMethodA(env, obj,methodID,args);
1314 #endif
1315             RESTOREENV;
1316         }
1317     OUTPUT:
1318         RETVAL
1319
1320 jint
1321 CallIntMethodA(obj,methodID,args)
1322         JNIEnv *                env = FETCHENV;
1323         jobject                 obj
1324         jmethodID               methodID
1325         char *                  sig = 0;
1326         jvalue *                args
1327     CODE:
1328         {
1329 #ifdef WIN32
1330             RETVAL = env->CallIntMethodA(obj,methodID,args);
1331 #else
1332             RETVAL = (*env)->CallIntMethodA(env, obj,methodID,args);
1333 #endif
1334             RESTOREENV;
1335         }
1336     OUTPUT:
1337         RETVAL
1338
1339 jlong
1340 CallLongMethod(obj,methodID,...)
1341         JNIEnv *                env = FETCHENV;
1342         jobject                 obj
1343         jmethodID               methodID
1344         char *                  sig = 0;
1345         int                     argoff = $min_args;
1346     CODE:
1347         {
1348             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1349 #ifdef WIN32
1350             RETVAL = env->CallLongMethodA(obj,methodID,args);
1351 #else
1352             RETVAL = (*env)->CallLongMethodA(env, obj,methodID,args);
1353 #endif
1354             RESTOREENV;
1355         }
1356     OUTPUT:
1357         RETVAL
1358
1359 jlong
1360 CallLongMethodA(obj,methodID,args)
1361         JNIEnv *                env = FETCHENV;
1362         jobject                 obj
1363         jmethodID               methodID
1364         char *                  sig = 0;
1365         jvalue *                args
1366     CODE:
1367         {
1368 #ifdef WIN32
1369             RETVAL = env->CallLongMethodA(obj,methodID,args);
1370 #else
1371             RETVAL = (*env)->CallLongMethodA(env, obj,methodID,args);
1372 #endif
1373             RESTOREENV;
1374         }
1375     OUTPUT:
1376         RETVAL
1377
1378 jfloat
1379 CallFloatMethod(obj,methodID,...)
1380         JNIEnv *                env = FETCHENV;
1381         jobject                 obj
1382         jmethodID               methodID
1383         char *                  sig = 0;
1384         int                     argoff = $min_args;
1385     CODE:
1386         {
1387             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1388 #ifdef WIN32
1389             RETVAL = env->CallFloatMethodA(obj,methodID,args);
1390 #else
1391             RETVAL = (*env)->CallFloatMethodA(env, obj,methodID,args);
1392 #endif
1393             RESTOREENV;
1394         }
1395     OUTPUT:
1396         RETVAL
1397
1398 jfloat
1399 CallFloatMethodA(obj,methodID,args)
1400         JNIEnv *                env = FETCHENV;
1401         jobject                 obj
1402         jmethodID               methodID
1403         char *                  sig = 0;
1404         jvalue *                args
1405     CODE:
1406         {
1407 #ifdef WIN32
1408             RETVAL = env->CallFloatMethodA(obj,methodID,args);
1409 #else
1410             RETVAL = (*env)->CallFloatMethodA(env, obj,methodID,args);
1411 #endif
1412             RESTOREENV;
1413         }
1414     OUTPUT:
1415         RETVAL
1416
1417 jdouble
1418 CallDoubleMethod(obj,methodID,...)
1419         JNIEnv *                env = FETCHENV;
1420         jobject                 obj
1421         jmethodID               methodID
1422         char *                  sig = 0;
1423         int                     argoff = $min_args;
1424     CODE:
1425         {
1426             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1427 #ifdef WIN32
1428             RETVAL = env->CallDoubleMethodA(obj,methodID,args);
1429 #else
1430             RETVAL = (*env)->CallDoubleMethodA(env, obj,methodID,args);
1431 #endif
1432             RESTOREENV;
1433         }
1434     OUTPUT:
1435         RETVAL
1436
1437 jdouble
1438 CallDoubleMethodA(obj,methodID,args)
1439         JNIEnv *                env = FETCHENV;
1440         jobject                 obj
1441         jmethodID               methodID
1442         char *                  sig = 0;
1443         jvalue *                args
1444     CODE:
1445         {
1446 #ifdef WIN32
1447             RETVAL = env->CallDoubleMethodA(obj,methodID,args);
1448 #else
1449             RETVAL = (*env)->CallDoubleMethodA(env, obj,methodID,args);
1450 #endif
1451             RESTOREENV;
1452         }
1453     OUTPUT:
1454         RETVAL
1455
1456 void
1457 CallVoidMethod(obj,methodID,...)
1458         JNIEnv *                env = FETCHENV;
1459         jobject                 obj
1460         jmethodID               methodID
1461         char *                  sig = 0;
1462         int                     argoff = $min_args;
1463     CODE:
1464         {
1465             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1466 #ifdef WIN32
1467             env->CallVoidMethodA(obj,methodID,args);
1468 #else
1469             (*env)->CallVoidMethodA(env, obj,methodID,args);
1470 #endif
1471             RESTOREENV;
1472         }
1473
1474 void
1475 CallVoidMethodA(obj,methodID,args)
1476         JNIEnv *                env = FETCHENV;
1477         jobject                 obj
1478         jmethodID               methodID
1479         char *                  sig = 0;
1480         jvalue *                args
1481     CODE:
1482         {
1483 #ifdef WIN32
1484             env->CallVoidMethodA(obj,methodID,args);
1485 #else
1486             (*env)->CallVoidMethodA(env, obj,methodID,args);
1487 #endif
1488             RESTOREENV;
1489         }
1490
1491 jobject
1492 CallNonvirtualObjectMethod(obj,clazz,methodID,...)
1493         JNIEnv *                env = FETCHENV;
1494         jobject                 obj
1495         jclass                  clazz
1496         jmethodID               methodID
1497         char *                  sig = 0;
1498         int                     argoff = $min_args;
1499     CODE:
1500         {
1501             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1502 #ifdef WIN32
1503             RETVAL = env->CallNonvirtualObjectMethodA(obj,clazz,methodID,args);
1504 #else
1505             RETVAL = (*env)->CallNonvirtualObjectMethodA(env, obj,clazz,methodID,args);
1506 #endif
1507             RESTOREENV;
1508         }
1509     OUTPUT:
1510         RETVAL
1511
1512 jobject
1513 CallNonvirtualObjectMethodA(obj,clazz,methodID,args)
1514         JNIEnv *                env = FETCHENV;
1515         jobject                 obj
1516         jclass                  clazz
1517         jmethodID               methodID
1518         char *                  sig = 0;
1519         jvalue *                args
1520     CODE:
1521         {
1522 #ifdef WIN32
1523             RETVAL = env->CallNonvirtualObjectMethodA(obj,clazz,methodID,args);
1524 #else
1525             RETVAL = (*env)->CallNonvirtualObjectMethodA(env, obj,clazz,methodID,args);
1526 #endif
1527             RESTOREENV;
1528         }
1529     OUTPUT:
1530         RETVAL
1531
1532 jboolean
1533 CallNonvirtualBooleanMethod(obj,clazz,methodID,...)
1534         JNIEnv *                env = FETCHENV;
1535         jobject                 obj
1536         jclass                  clazz
1537         jmethodID               methodID
1538         char *                  sig = 0;
1539         int                     argoff = $min_args;
1540     CODE:
1541         {
1542             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1543 #ifdef WIN32
1544             RETVAL = env->CallNonvirtualBooleanMethodA(obj,clazz,methodID,args);
1545 #else
1546             RETVAL = (*env)->CallNonvirtualBooleanMethodA(env, obj,clazz,methodID,args);
1547 #endif
1548             RESTOREENV;
1549         }
1550     OUTPUT:
1551         RETVAL
1552
1553 jboolean
1554 CallNonvirtualBooleanMethodA(obj,clazz,methodID, args)
1555         JNIEnv *                env = FETCHENV;
1556         jobject                 obj
1557         jclass                  clazz
1558         jmethodID               methodID
1559         char *                  sig = 0;
1560         jvalue *                args
1561     CODE:
1562         {
1563 #ifdef WIN32
1564             RETVAL = env->CallNonvirtualBooleanMethodA(obj,clazz,methodID, args);
1565 #else
1566             RETVAL = (*env)->CallNonvirtualBooleanMethodA(env, obj,clazz,methodID, args);
1567 #endif
1568             RESTOREENV;
1569         }
1570     OUTPUT:
1571         RETVAL
1572
1573 jbyte
1574 CallNonvirtualByteMethod(obj,clazz,methodID,...)
1575         JNIEnv *                env = FETCHENV;
1576         jobject                 obj
1577         jclass                  clazz
1578         jmethodID               methodID
1579         char *                  sig = 0;
1580         int                     argoff = $min_args;
1581     CODE:
1582         {
1583             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1584 #ifdef WIN32
1585             RETVAL = env->CallNonvirtualByteMethodA(obj,clazz,methodID,args);
1586 #else
1587             RETVAL = (*env)->CallNonvirtualByteMethodA(env, obj,clazz,methodID,args);
1588 #endif
1589             RESTOREENV;
1590         }
1591     OUTPUT:
1592         RETVAL
1593
1594 jbyte
1595 CallNonvirtualByteMethodA(obj,clazz,methodID,args)
1596         JNIEnv *                env = FETCHENV;
1597         jobject                 obj
1598         jclass                  clazz
1599         jmethodID               methodID
1600         char *                  sig = 0;
1601         jvalue *                args
1602     CODE:
1603         {
1604 #ifdef WIN32
1605             RETVAL = env->CallNonvirtualByteMethodA(obj,clazz,methodID,args);
1606 #else
1607             RETVAL = (*env)->CallNonvirtualByteMethodA(env, obj,clazz,methodID,args);
1608 #endif
1609             RESTOREENV;
1610         }
1611     OUTPUT:
1612         RETVAL
1613
1614 jchar
1615 CallNonvirtualCharMethod(obj,clazz,methodID,...)
1616         JNIEnv *                env = FETCHENV;
1617         jobject                 obj
1618         jclass                  clazz
1619         jmethodID               methodID
1620         char *                  sig = 0;
1621         int                     argoff = $min_args;
1622     CODE:
1623         {
1624             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1625 #ifdef WIN32
1626             RETVAL = env->CallNonvirtualCharMethodA(obj,clazz,methodID,args);
1627 #else
1628             RETVAL = (*env)->CallNonvirtualCharMethodA(env, obj,clazz,methodID,args);
1629 #endif
1630             RESTOREENV;
1631         }
1632     OUTPUT:
1633         RETVAL
1634
1635 jchar
1636 CallNonvirtualCharMethodA(obj,clazz,methodID,args)
1637         JNIEnv *                env = FETCHENV;
1638         jobject                 obj
1639         jclass                  clazz
1640         jmethodID               methodID
1641         char *                  sig = 0;
1642         jvalue *                args
1643     CODE:
1644         {
1645 #ifdef WIN32
1646             RETVAL = env->CallNonvirtualCharMethodA(obj,clazz,methodID,args);
1647 #else
1648             RETVAL = (*env)->CallNonvirtualCharMethodA(env, obj,clazz,methodID,args);
1649 #endif
1650             RESTOREENV;
1651         }
1652     OUTPUT:
1653         RETVAL
1654
1655 jshort
1656 CallNonvirtualShortMethod(obj,clazz,methodID,...)
1657         JNIEnv *                env = FETCHENV;
1658         jobject                 obj
1659         jclass                  clazz
1660         jmethodID               methodID
1661         char *                  sig = 0;
1662         int                     argoff = $min_args;
1663     CODE:
1664         {
1665             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1666 #ifdef WIN32
1667             RETVAL = env->CallNonvirtualShortMethodA(obj,clazz,methodID,args);
1668 #else
1669             RETVAL = (*env)->CallNonvirtualShortMethodA(env, obj,clazz,methodID,args);
1670 #endif
1671             RESTOREENV;
1672         }
1673     OUTPUT:
1674         RETVAL
1675
1676 jshort
1677 CallNonvirtualShortMethodA(obj,clazz,methodID,args)
1678         JNIEnv *                env = FETCHENV;
1679         jobject                 obj
1680         jclass                  clazz
1681         jmethodID               methodID
1682         char *                  sig = 0;
1683         jvalue *                args
1684     CODE:
1685         {
1686 #ifdef WIN32
1687             RETVAL = env->CallNonvirtualShortMethodA(obj,clazz,methodID,args);
1688 #else
1689             RETVAL = (*env)->CallNonvirtualShortMethodA(env, obj,clazz,methodID,args);
1690 #endif
1691             RESTOREENV;
1692         }
1693     OUTPUT:
1694         RETVAL
1695
1696 jint
1697 CallNonvirtualIntMethod(obj,clazz,methodID,...)
1698         JNIEnv *                env = FETCHENV;
1699         jobject                 obj
1700         jclass                  clazz
1701         jmethodID               methodID
1702         char *                  sig = 0;
1703         int                     argoff = $min_args;
1704     CODE:
1705         {
1706             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1707 #ifdef WIN32
1708             RETVAL = env->CallNonvirtualIntMethodA(obj,clazz,methodID,args);
1709 #else
1710             RETVAL = (*env)->CallNonvirtualIntMethodA(env, obj,clazz,methodID,args);
1711 #endif
1712             RESTOREENV;
1713         }
1714     OUTPUT:
1715         RETVAL
1716
1717 jint
1718 CallNonvirtualIntMethodA(obj,clazz,methodID,args)
1719         JNIEnv *                env = FETCHENV;
1720         jobject                 obj
1721         jclass                  clazz
1722         jmethodID               methodID
1723         char *                  sig = 0;
1724         jvalue *                args
1725     CODE:
1726         {
1727 #ifdef WIN32
1728             RETVAL = env->CallNonvirtualIntMethodA(obj,clazz,methodID,args);
1729 #else
1730             RETVAL = (*env)->CallNonvirtualIntMethodA(env, obj,clazz,methodID,args);
1731 #endif
1732             RESTOREENV;
1733         }
1734     OUTPUT:
1735         RETVAL
1736
1737 jlong
1738 CallNonvirtualLongMethod(obj,clazz,methodID,...)
1739         JNIEnv *                env = FETCHENV;
1740         jobject                 obj
1741         jclass                  clazz
1742         jmethodID               methodID
1743         char *                  sig = 0;
1744         int                     argoff = $min_args;
1745     CODE:
1746         {
1747             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1748 #ifdef WIN32
1749             RETVAL = env->CallNonvirtualLongMethodA(obj,clazz,methodID,args);
1750 #else
1751             RETVAL = (*env)->CallNonvirtualLongMethodA(env, obj,clazz,methodID,args);
1752 #endif
1753             RESTOREENV;
1754         }
1755     OUTPUT:
1756         RETVAL
1757
1758 jlong
1759 CallNonvirtualLongMethodA(obj,clazz,methodID,args)
1760         JNIEnv *                env = FETCHENV;
1761         jobject                 obj
1762         jclass                  clazz
1763         jmethodID               methodID
1764         char *                  sig = 0;
1765         jvalue *                args
1766     CODE:
1767         {
1768 #ifdef WIN32
1769             RETVAL = env->CallNonvirtualLongMethodA(obj,clazz,methodID,args);
1770 #else
1771             RETVAL = (*env)->CallNonvirtualLongMethodA(env, obj,clazz,methodID,args);
1772 #endif
1773             RESTOREENV;
1774         }
1775     OUTPUT:
1776         RETVAL
1777
1778 jfloat
1779 CallNonvirtualFloatMethod(obj,clazz,methodID,...)
1780         JNIEnv *                env = FETCHENV;
1781         jobject                 obj
1782         jclass                  clazz
1783         jmethodID               methodID
1784         char *                  sig = 0;
1785         int                     argoff = $min_args;
1786     CODE:
1787         {
1788             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1789 #ifdef WIN32
1790             RETVAL = env->CallNonvirtualFloatMethodA(obj,clazz,methodID,args);
1791 #else
1792             RETVAL = (*env)->CallNonvirtualFloatMethodA(env, obj,clazz,methodID,args);
1793 #endif
1794             RESTOREENV;
1795         }
1796     OUTPUT:
1797         RETVAL
1798
1799 jfloat
1800 CallNonvirtualFloatMethodA(obj,clazz,methodID,args)
1801         JNIEnv *                env = FETCHENV;
1802         jobject                 obj
1803         jclass                  clazz
1804         jmethodID               methodID
1805         char *                  sig = 0;
1806         jvalue *                args
1807     CODE:
1808         {
1809 #ifdef WIN32
1810             RETVAL = env->CallNonvirtualFloatMethodA(obj,clazz,methodID,args);
1811 #else
1812             RETVAL = (*env)->CallNonvirtualFloatMethodA(env, obj,clazz,methodID,args);
1813 #endif
1814             RESTOREENV;
1815         }
1816     OUTPUT:
1817         RETVAL
1818
1819 jdouble
1820 CallNonvirtualDoubleMethod(obj,clazz,methodID,...)
1821         JNIEnv *                env = FETCHENV;
1822         jobject                 obj
1823         jclass                  clazz
1824         jmethodID               methodID
1825         char *                  sig = 0;
1826         int                     argoff = $min_args;
1827     CODE:
1828         {
1829             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1830 #ifdef WIN32
1831             RETVAL = env->CallNonvirtualDoubleMethodA(obj,clazz,methodID,args);
1832 #else
1833             RETVAL = (*env)->CallNonvirtualDoubleMethodA(env, obj,clazz,methodID,args);
1834 #endif
1835             RESTOREENV;
1836         }
1837     OUTPUT:
1838         RETVAL
1839
1840 jdouble
1841 CallNonvirtualDoubleMethodA(obj,clazz,methodID,args)
1842         JNIEnv *                env = FETCHENV;
1843         jobject                 obj
1844         jclass                  clazz
1845         jmethodID               methodID
1846         char *                  sig = 0;
1847         jvalue *                args
1848     CODE:
1849         {
1850 #ifdef WIN32
1851             RETVAL = env->CallNonvirtualDoubleMethodA(obj,clazz,methodID,args);
1852 #else
1853             RETVAL = (*env)->CallNonvirtualDoubleMethodA(env, obj,clazz,methodID,args);
1854 #endif
1855             RESTOREENV;
1856         }
1857     OUTPUT:
1858         RETVAL
1859
1860 void
1861 CallNonvirtualVoidMethod(obj,clazz,methodID,...)
1862         JNIEnv *                env = FETCHENV;
1863         jobject                 obj
1864         jclass                  clazz
1865         jmethodID               methodID
1866         char *                  sig = 0;
1867         int                     argoff = $min_args;
1868     CODE:
1869         {
1870             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
1871 #ifdef WIN32
1872             env->CallNonvirtualVoidMethodA(obj,clazz,methodID,args);
1873 #else
1874             (*env)->CallNonvirtualVoidMethodA(env, obj,clazz,methodID,args);
1875 #endif
1876             RESTOREENV;
1877         }
1878
1879 void
1880 CallNonvirtualVoidMethodA(obj,clazz,methodID,args)
1881         JNIEnv *                env = FETCHENV;
1882         jobject                 obj
1883         jclass                  clazz
1884         jmethodID               methodID
1885         char *                  sig = 0;
1886         jvalue *                args
1887     CODE:
1888         {
1889 #ifdef WIN32
1890             env->CallNonvirtualVoidMethodA(obj,clazz,methodID,args);
1891 #else
1892             (*env)->CallNonvirtualVoidMethodA(env, obj,clazz,methodID,args);
1893 #endif
1894             RESTOREENV;
1895         }
1896
1897 jfieldID
1898 GetFieldID(clazz,name,sig)
1899         JNIEnv *                env = FETCHENV;
1900         jclass                  clazz
1901         const char *            name
1902         const char *            sig
1903     CODE:
1904         {
1905 #ifdef WIN32
1906             RETVAL = env->GetFieldID(clazz,name,sig);
1907 #else
1908             RETVAL = (*env)->GetFieldID(env, clazz,name,sig);
1909 #endif
1910             RESTOREENV;
1911         }
1912     OUTPUT:
1913         RETVAL
1914
1915 jobject
1916 GetObjectField(obj,fieldID)
1917         JNIEnv *                env = FETCHENV;
1918         jobject                 obj
1919         jfieldID                fieldID
1920         char *                  sig = 0;
1921     CODE:
1922         {
1923 #ifdef WIN32
1924             RETVAL = env->GetObjectField(obj,fieldID);
1925 #else
1926             RETVAL = (*env)->GetObjectField(env, obj,fieldID);
1927 #endif
1928             RESTOREENV;
1929         }
1930     OUTPUT:
1931         RETVAL
1932
1933 jboolean
1934 GetBooleanField(obj,fieldID)
1935         JNIEnv *                env = FETCHENV;
1936         jobject                 obj
1937         jfieldID                fieldID
1938         char *                  sig = 0;
1939     CODE:
1940         {
1941 #ifdef WIN32
1942             RETVAL = env->GetBooleanField(obj,fieldID);
1943 #else
1944             RETVAL = (*env)->GetBooleanField(env, obj,fieldID);
1945 #endif
1946             RESTOREENV;
1947         }
1948     OUTPUT:
1949         RETVAL
1950
1951 jbyte
1952 GetByteField(obj,fieldID)
1953         JNIEnv *                env = FETCHENV;
1954         jobject                 obj
1955         jfieldID                fieldID
1956         char *                  sig = 0;
1957     CODE:
1958         {
1959 #ifdef WIN32
1960             RETVAL = env->GetByteField(obj,fieldID);
1961 #else
1962             RETVAL = (*env)->GetByteField(env, obj,fieldID);
1963 #endif
1964             RESTOREENV;
1965         }
1966     OUTPUT:
1967         RETVAL
1968
1969 jchar
1970 GetCharField(obj,fieldID)
1971         JNIEnv *                env = FETCHENV;
1972         jobject                 obj
1973         jfieldID                fieldID
1974         char *                  sig = 0;
1975     CODE:
1976         {
1977 #ifdef WIN32
1978             RETVAL = env->GetCharField(obj,fieldID);
1979 #else
1980             RETVAL = (*env)->GetCharField(env, obj,fieldID);
1981 #endif
1982             RESTOREENV;
1983         }
1984     OUTPUT:
1985         RETVAL
1986
1987 jshort
1988 GetShortField(obj,fieldID)
1989         JNIEnv *                env = FETCHENV;
1990         jobject                 obj
1991         jfieldID                fieldID
1992         char *                  sig = 0;
1993     CODE:
1994         {
1995 #ifdef WIN32
1996             RETVAL = env->GetShortField(obj,fieldID);
1997 #else
1998             RETVAL = (*env)->GetShortField(env, obj,fieldID);
1999 #endif
2000             RESTOREENV;
2001         }
2002     OUTPUT:
2003         RETVAL
2004
2005 jint
2006 GetIntField(obj,fieldID)
2007         JNIEnv *                env = FETCHENV;
2008         jobject                 obj
2009         jfieldID                fieldID
2010         char *                  sig = 0;
2011     CODE:
2012         {
2013 #ifdef WIN32
2014             RETVAL = env->GetIntField(obj,fieldID);
2015 #else
2016             RETVAL = (*env)->GetIntField(env, obj,fieldID);
2017 #endif
2018             RESTOREENV;
2019         }
2020     OUTPUT:
2021         RETVAL
2022
2023 jlong
2024 GetLongField(obj,fieldID)
2025         JNIEnv *                env = FETCHENV;
2026         jobject                 obj
2027         jfieldID                fieldID
2028         char *                  sig = 0;
2029     CODE:
2030         {
2031 #ifdef WIN32
2032             RETVAL = env->GetLongField(obj,fieldID);
2033 #else
2034             RETVAL = (*env)->GetLongField(env, obj,fieldID);
2035 #endif
2036             RESTOREENV;
2037         }
2038     OUTPUT:
2039         RETVAL
2040
2041 jfloat
2042 GetFloatField(obj,fieldID)
2043         JNIEnv *                env = FETCHENV;
2044         jobject                 obj
2045         jfieldID                fieldID
2046         char *                  sig = 0;
2047     CODE:
2048         {
2049 #ifdef WIN32
2050             RETVAL = env->GetFloatField(obj,fieldID);
2051 #else
2052             RETVAL = (*env)->GetFloatField(env, obj,fieldID);
2053 #endif
2054             RESTOREENV;
2055         }
2056     OUTPUT:
2057         RETVAL
2058
2059 jdouble
2060 GetDoubleField(obj,fieldID)
2061         JNIEnv *                env = FETCHENV;
2062         jobject                 obj
2063         jfieldID                fieldID
2064         char *                  sig = 0;
2065     CODE:
2066         {
2067 #ifdef WIN32
2068             RETVAL = env->GetDoubleField(obj,fieldID);
2069 #else
2070             RETVAL = (*env)->GetDoubleField(env, obj,fieldID);
2071 #endif
2072             RESTOREENV;
2073         }
2074     OUTPUT:
2075         RETVAL
2076
2077 void
2078 SetObjectField(obj,fieldID,val)
2079         JNIEnv *                env = FETCHENV;
2080         jobject                 obj
2081         jfieldID                fieldID
2082         char *                  sig = 0;
2083         jobject                 val
2084     CODE:
2085         {
2086 #ifdef WIN32
2087             env->SetObjectField(obj,fieldID,val);
2088 #else
2089             (*env)->SetObjectField(env, obj,fieldID,val);
2090 #endif
2091             RESTOREENV;
2092         }
2093
2094 void
2095 SetBooleanField(obj,fieldID,val)
2096         JNIEnv *                env = FETCHENV;
2097         jobject                 obj
2098         jfieldID                fieldID
2099         char *                  sig = 0;
2100         jboolean                val
2101     CODE:
2102         {
2103 #ifdef WIN32
2104             env->SetBooleanField(obj,fieldID,val);
2105 #else
2106             (*env)->SetBooleanField(env, obj,fieldID,val);
2107 #endif
2108             RESTOREENV;
2109         }
2110
2111 void
2112 SetByteField(obj,fieldID,val)
2113         JNIEnv *                env = FETCHENV;
2114         jobject                 obj
2115         jfieldID                fieldID
2116         char *                  sig = 0;
2117         jbyte                   val
2118     CODE:
2119         {
2120 #ifdef WIN32
2121             env->SetByteField(obj,fieldID,val);
2122 #else
2123             (*env)->SetByteField(env, obj,fieldID,val);
2124 #endif
2125             RESTOREENV;
2126         }
2127
2128 void
2129 SetCharField(obj,fieldID,val)
2130         JNIEnv *                env = FETCHENV;
2131         jobject                 obj
2132         jfieldID                fieldID
2133         char *                  sig = 0;
2134         jchar                   val
2135     CODE:
2136         {
2137 #ifdef WIN32
2138             env->SetCharField(obj,fieldID,val);
2139 #else
2140             (*env)->SetCharField(env, obj,fieldID,val);
2141 #endif
2142             RESTOREENV;
2143         }
2144
2145 void
2146 SetShortField(obj,fieldID,val)
2147         JNIEnv *                env = FETCHENV;
2148         jobject                 obj
2149         jfieldID                fieldID
2150         char *                  sig = 0;
2151         jshort                  val
2152     CODE:
2153         {
2154 #ifdef WIN32
2155             env->SetShortField(obj,fieldID,val);
2156 #else
2157             (*env)->SetShortField(env, obj,fieldID,val);
2158 #endif
2159             RESTOREENV;
2160         }
2161
2162 void
2163 SetIntField(obj,fieldID,val)
2164         JNIEnv *                env = FETCHENV;
2165         jobject                 obj
2166         jfieldID                fieldID
2167         char *                  sig = 0;
2168         jint                    val
2169     CODE:
2170         {
2171 #ifdef WIN32
2172             env->SetIntField(obj,fieldID,val);
2173 #else
2174             (*env)->SetIntField(env, obj,fieldID,val);
2175 #endif
2176             RESTOREENV;
2177         }
2178
2179 void
2180 SetLongField(obj,fieldID,val)
2181         JNIEnv *                env = FETCHENV;
2182         jobject                 obj
2183         jfieldID                fieldID
2184         char *                  sig = 0;
2185         jlong                   val
2186     CODE:
2187         {
2188 #ifdef WIN32
2189             env->SetLongField(obj,fieldID,val);
2190 #else
2191             (*env)->SetLongField(env, obj,fieldID,val);
2192 #endif
2193             RESTOREENV;
2194         }
2195
2196 void
2197 SetFloatField(obj,fieldID,val)
2198         JNIEnv *                env = FETCHENV;
2199         jobject                 obj
2200         jfieldID                fieldID
2201         char *                  sig = 0;
2202         jfloat                  val
2203     CODE:
2204         {
2205 #ifdef WIN32
2206             env->SetFloatField(obj,fieldID,val);
2207 #else
2208             (*env)->SetFloatField(env, obj,fieldID,val);
2209 #endif
2210             RESTOREENV;
2211         }
2212
2213 void
2214 SetDoubleField(obj,fieldID,val)
2215         JNIEnv *                env = FETCHENV;
2216         jobject                 obj
2217         jfieldID                fieldID
2218         char *                  sig = 0;
2219         jdouble                 val
2220     CODE:
2221         {
2222 #ifdef WIN32
2223             env->SetDoubleField(obj,fieldID,val);
2224 #else
2225             (*env)->SetDoubleField(env, obj,fieldID,val);
2226 #endif
2227             RESTOREENV;
2228         }
2229
2230 jmethodID
2231 GetStaticMethodID(clazz,name,sig)
2232         JNIEnv *                env = FETCHENV;
2233         jclass                  clazz
2234         const char *            name
2235         const char *            sig
2236     CODE:
2237         {
2238 #ifdef WIN32
2239             RETVAL = env->GetStaticMethodID(clazz,name,sig);
2240 #else
2241             RETVAL = (*env)->GetStaticMethodID(env, clazz,name,sig);
2242 #endif
2243             RESTOREENV;
2244         }
2245     OUTPUT:
2246         RETVAL
2247
2248 jobject
2249 CallStaticObjectMethod(clazz,methodID,...)
2250         JNIEnv *                env = FETCHENV;
2251         jclass                  clazz
2252         jmethodID               methodID
2253         char *                  sig = 0;
2254         int                     argoff = $min_args;
2255     CODE:
2256         {
2257             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2258 #ifdef WIN32
2259             RETVAL = env->CallStaticObjectMethodA(clazz,methodID,args);
2260 #else
2261             RETVAL = (*env)->CallStaticObjectMethodA(env, clazz,methodID,args);
2262 #endif
2263             RESTOREENV;
2264         }
2265     OUTPUT:
2266         RETVAL
2267
2268 jobject
2269 CallStaticObjectMethodA(clazz,methodID,args)
2270         JNIEnv *                env = FETCHENV;
2271         jclass                  clazz
2272         jmethodID               methodID
2273         char *                  sig = 0;
2274         jvalue *                args
2275     CODE:
2276         {
2277 #ifdef WIN32
2278             RETVAL = env->CallStaticObjectMethodA(clazz,methodID,args);
2279 #else
2280             RETVAL = (*env)->CallStaticObjectMethodA(env, clazz,methodID,args);
2281 #endif
2282             RESTOREENV;
2283         }
2284     OUTPUT:
2285         RETVAL
2286
2287 jboolean
2288 CallStaticBooleanMethod(clazz,methodID,...)
2289         JNIEnv *                env = FETCHENV;
2290         jclass                  clazz
2291         jmethodID               methodID
2292         char *                  sig = 0;
2293         int                     argoff = $min_args;
2294     CODE:
2295         {
2296             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2297 #ifdef WIN32
2298             RETVAL = env->CallStaticBooleanMethodA(clazz,methodID,args);
2299 #else
2300             RETVAL = (*env)->CallStaticBooleanMethodA(env, clazz,methodID,args);
2301 #endif
2302             RESTOREENV;
2303         }
2304     OUTPUT:
2305         RETVAL
2306
2307 jboolean
2308 CallStaticBooleanMethodA(clazz,methodID,args)
2309         JNIEnv *                env = FETCHENV;
2310         jclass                  clazz
2311         jmethodID               methodID
2312         char *                  sig = 0;
2313         jvalue *                args
2314     CODE:
2315         {
2316 #ifdef WIN32
2317             RETVAL = env->CallStaticBooleanMethodA(clazz,methodID,args);
2318 #else
2319             RETVAL = (*env)->CallStaticBooleanMethodA(env, clazz,methodID,args);
2320 #endif
2321             RESTOREENV;
2322         }
2323     OUTPUT:
2324         RETVAL
2325
2326 jbyte
2327 CallStaticByteMethod(clazz,methodID,...)
2328         JNIEnv *                env = FETCHENV;
2329         jclass                  clazz
2330         jmethodID               methodID
2331         char *                  sig = 0;
2332         int                     argoff = $min_args;
2333     CODE:
2334         {
2335             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2336 #ifdef WIN32
2337             RETVAL = env->CallStaticByteMethodA(clazz,methodID,args);
2338 #else
2339             RETVAL = (*env)->CallStaticByteMethodA(env, clazz,methodID,args);
2340 #endif
2341             RESTOREENV;
2342         }
2343     OUTPUT:
2344         RETVAL
2345
2346 jbyte
2347 CallStaticByteMethodA(clazz,methodID,args)
2348         JNIEnv *                env = FETCHENV;
2349         jclass                  clazz
2350         jmethodID               methodID
2351         char *                  sig = 0;
2352         jvalue *                args
2353     CODE:
2354         {
2355 #ifdef WIN32
2356             RETVAL = env->CallStaticByteMethodA(clazz,methodID,args);
2357 #else
2358             RETVAL = (*env)->CallStaticByteMethodA(env, clazz,methodID,args);
2359 #endif
2360             RESTOREENV;
2361         }
2362     OUTPUT:
2363         RETVAL
2364
2365 jchar
2366 CallStaticCharMethod(clazz,methodID,...)
2367         JNIEnv *                env = FETCHENV;
2368         jclass                  clazz
2369         jmethodID               methodID
2370         char *                  sig = 0;
2371         int                     argoff = $min_args;
2372     CODE:
2373         {
2374             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2375 #ifdef WIN32
2376             RETVAL = env->CallStaticCharMethodA(clazz,methodID,args);
2377 #else
2378             RETVAL = (*env)->CallStaticCharMethodA(env, clazz,methodID,args);
2379 #endif
2380             RESTOREENV;
2381         }
2382     OUTPUT:
2383         RETVAL
2384
2385 jchar
2386 CallStaticCharMethodA(clazz,methodID,args)
2387         JNIEnv *                env = FETCHENV;
2388         jclass                  clazz
2389         jmethodID               methodID
2390         char *                  sig = 0;
2391         jvalue *                args
2392     CODE:
2393         {
2394 #ifdef WIN32
2395             RETVAL = env->CallStaticCharMethodA(clazz,methodID,args);
2396 #else
2397             RETVAL = (*env)->CallStaticCharMethodA(env, clazz,methodID,args);
2398 #endif
2399             RESTOREENV;
2400         }
2401     OUTPUT:
2402         RETVAL
2403
2404 jshort
2405 CallStaticShortMethod(clazz,methodID,...)
2406         JNIEnv *                env = FETCHENV;
2407         jclass                  clazz
2408         jmethodID               methodID
2409         char *                  sig = 0;
2410         int                     argoff = $min_args;
2411     CODE:
2412         {
2413             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2414 #ifdef WIN32
2415             RETVAL = env->CallStaticShortMethodA(clazz,methodID,args);
2416 #else
2417             RETVAL = (*env)->CallStaticShortMethodA(env, clazz,methodID,args);
2418 #endif
2419             RESTOREENV;
2420         }
2421     OUTPUT:
2422         RETVAL
2423
2424 jshort
2425 CallStaticShortMethodA(clazz,methodID,args)
2426         JNIEnv *                env = FETCHENV;
2427         jclass                  clazz
2428         jmethodID               methodID
2429         char *                  sig = 0;
2430         jvalue *                args
2431     CODE:
2432         {
2433 #ifdef WIN32
2434             RETVAL = env->CallStaticShortMethodA(clazz,methodID,args);
2435 #else
2436             RETVAL = (*env)->CallStaticShortMethodA(env, clazz,methodID,args);
2437 #endif
2438             RESTOREENV;
2439         }
2440     OUTPUT:
2441         RETVAL
2442
2443 jint
2444 CallStaticIntMethod(clazz,methodID,...)
2445         JNIEnv *                env = FETCHENV;
2446         jclass                  clazz
2447         jmethodID               methodID
2448         char *                  sig = 0;
2449         int                     argoff = $min_args;
2450     CODE:
2451         {
2452             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2453 #ifdef WIN32
2454             RETVAL = env->CallStaticIntMethodA(clazz,methodID,args);
2455 #else
2456             RETVAL = (*env)->CallStaticIntMethodA(env, clazz,methodID,args);
2457 #endif
2458             RESTOREENV;
2459         }
2460     OUTPUT:
2461         RETVAL
2462
2463 jint
2464 CallStaticIntMethodA(clazz,methodID,args)
2465         JNIEnv *                env = FETCHENV;
2466         jclass                  clazz
2467         jmethodID               methodID
2468         char *                  sig = 0;
2469         jvalue *                args
2470     CODE:
2471         {
2472 #ifdef WIN32
2473             RETVAL = env->CallStaticIntMethodA(clazz,methodID,args);
2474 #else
2475             RETVAL = (*env)->CallStaticIntMethodA(env, clazz,methodID,args);
2476 #endif
2477             RESTOREENV;
2478         }
2479     OUTPUT:
2480         RETVAL
2481
2482 jlong
2483 CallStaticLongMethod(clazz,methodID,...)
2484         JNIEnv *                env = FETCHENV;
2485         jclass                  clazz
2486         jmethodID               methodID
2487         char *                  sig = 0;
2488         int                     argoff = $min_args;
2489     CODE:
2490         {
2491             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2492 #ifdef WIN32
2493             RETVAL = env->CallStaticLongMethodA(clazz,methodID,args);
2494 #else
2495             RETVAL = (*env)->CallStaticLongMethodA(env, clazz,methodID,args);
2496 #endif
2497             RESTOREENV;
2498         }
2499     OUTPUT:
2500         RETVAL
2501
2502 jlong
2503 CallStaticLongMethodA(clazz,methodID,args)
2504         JNIEnv *                env = FETCHENV;
2505         jclass                  clazz
2506         jmethodID               methodID
2507         char *                  sig = 0;
2508         jvalue *                args
2509     CODE:
2510         {
2511 #ifdef WIN32
2512             RETVAL = env->CallStaticLongMethodA(clazz,methodID,args);
2513 #else
2514             RETVAL = (*env)->CallStaticLongMethodA(env, clazz,methodID,args);
2515 #endif
2516             RESTOREENV;
2517         }
2518     OUTPUT:
2519         RETVAL
2520
2521 jfloat
2522 CallStaticFloatMethod(clazz,methodID,...)
2523         JNIEnv *                env = FETCHENV;
2524         jclass                  clazz
2525         jmethodID               methodID
2526         char *                  sig = 0;
2527         int                     argoff = $min_args;
2528     CODE:
2529         {
2530             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2531 #ifdef WIN32
2532             RETVAL = env->CallStaticFloatMethodA(clazz,methodID,args);
2533 #else
2534             RETVAL = (*env)->CallStaticFloatMethodA(env, clazz,methodID,args);
2535 #endif
2536             RESTOREENV;
2537         }
2538     OUTPUT:
2539         RETVAL
2540
2541 jfloat
2542 CallStaticFloatMethodA(clazz,methodID,args)
2543         JNIEnv *                env = FETCHENV;
2544         jclass                  clazz
2545         jmethodID               methodID
2546         char *                  sig = 0;
2547         jvalue *                args
2548     CODE:
2549         {
2550 #ifdef WIN32
2551             RETVAL = env->CallStaticFloatMethodA(clazz,methodID,args);
2552 #else
2553             RETVAL = (*env)->CallStaticFloatMethodA(env, clazz,methodID,args);
2554 #endif
2555             RESTOREENV;
2556         }
2557     OUTPUT:
2558         RETVAL
2559
2560 jdouble
2561 CallStaticDoubleMethod(clazz,methodID,...)
2562         JNIEnv *                env = FETCHENV;
2563         jclass                  clazz
2564         jmethodID               methodID
2565         char *                  sig = 0;
2566         int                     argoff = $min_args;
2567     CODE:
2568         {
2569             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2570 #ifdef WIN32
2571             RETVAL = env->CallStaticDoubleMethodA(clazz,methodID,args);
2572 #else
2573             RETVAL = (*env)->CallStaticDoubleMethodA(env, clazz,methodID,args);
2574 #endif
2575             RESTOREENV;
2576         }
2577     OUTPUT:
2578         RETVAL
2579
2580 jdouble
2581 CallStaticDoubleMethodA(clazz,methodID,args)
2582         JNIEnv *                env = FETCHENV;
2583         jclass                  clazz
2584         jmethodID               methodID
2585         char *                  sig = 0;
2586         jvalue *                args
2587     CODE:
2588         {
2589 #ifdef WIN32
2590             RETVAL = env->CallStaticDoubleMethodA(clazz,methodID,args);
2591 #else
2592             RETVAL = (*env)->CallStaticDoubleMethodA(env, clazz,methodID,args);
2593 #endif
2594             RESTOREENV;
2595         }
2596     OUTPUT:
2597         RETVAL
2598
2599 void
2600 CallStaticVoidMethod(cls,methodID,...)
2601         JNIEnv *                env = FETCHENV;
2602         jclass                  cls
2603         jmethodID               methodID
2604         char *                  sig = 0;
2605         int                     argoff = $min_args;
2606     CODE:
2607         {
2608             jvalue * args = makeargs(sig, &ST(argoff), items - argoff);
2609 #ifdef WIN32
2610             env->CallStaticVoidMethodA(cls,methodID,args);
2611 #else
2612             (*env)->CallStaticVoidMethodA(env, cls,methodID,args);
2613 #endif
2614             RESTOREENV;
2615         }
2616
2617 void
2618 CallStaticVoidMethodA(cls,methodID,args)
2619         JNIEnv *                env = FETCHENV;
2620         jclass                  cls
2621         jmethodID               methodID
2622         char *                  sig = 0;
2623         jvalue *                args
2624     CODE:
2625         {
2626 #ifdef WIN32
2627             env->CallStaticVoidMethodA(cls,methodID,args);
2628 #else
2629             (*env)->CallStaticVoidMethodA(env, cls,methodID,args);
2630 #endif
2631             RESTOREENV;
2632         }
2633
2634 jfieldID
2635 GetStaticFieldID(clazz,name,sig)
2636         JNIEnv *                env = FETCHENV;
2637         jclass                  clazz
2638         const char *            name
2639         const char *            sig
2640     CODE:
2641         {
2642 #ifdef WIN32
2643             RETVAL = env->GetStaticFieldID(clazz,name,sig);
2644 #else
2645             RETVAL = (*env)->GetStaticFieldID(env, clazz,name,sig);
2646 #endif
2647             RESTOREENV;
2648         }
2649     OUTPUT:
2650         RETVAL
2651
2652 jobject
2653 GetStaticObjectField(clazz,fieldID)
2654         JNIEnv *                env = FETCHENV;
2655         jclass                  clazz
2656         jfieldID                fieldID
2657         char *                  sig = 0;
2658     CODE:
2659         {
2660 #ifdef WIN32
2661             RETVAL = env->GetStaticObjectField(clazz,fieldID);
2662 #else
2663             RETVAL = (*env)->GetStaticObjectField(env, clazz,fieldID);
2664 #endif
2665             RESTOREENV;
2666         }
2667     OUTPUT:
2668         RETVAL
2669
2670 jboolean
2671 GetStaticBooleanField(clazz,fieldID)
2672         JNIEnv *                env = FETCHENV;
2673         jclass                  clazz
2674         jfieldID                fieldID
2675         char *                  sig = 0;
2676     CODE:
2677         {
2678 #ifdef WIN32
2679             RETVAL = env->GetStaticBooleanField(clazz,fieldID);
2680 #else
2681             RETVAL = (*env)->GetStaticBooleanField(env, clazz,fieldID);
2682 #endif
2683             RESTOREENV;
2684         }
2685     OUTPUT:
2686         RETVAL
2687
2688 jbyte
2689 GetStaticByteField(clazz,fieldID)
2690         JNIEnv *                env = FETCHENV;
2691         jclass                  clazz
2692         jfieldID                fieldID
2693         char *                  sig = 0;
2694     CODE:
2695         {
2696 #ifdef WIN32
2697             RETVAL = env->GetStaticByteField(clazz,fieldID);
2698 #else
2699             RETVAL = (*env)->GetStaticByteField(env, clazz,fieldID);
2700 #endif
2701             RESTOREENV;
2702         }
2703     OUTPUT:
2704         RETVAL
2705
2706 jchar
2707 GetStaticCharField(clazz,fieldID)
2708         JNIEnv *                env = FETCHENV;
2709         jclass                  clazz
2710         jfieldID                fieldID
2711         char *                  sig = 0;
2712     CODE:
2713         {
2714 #ifdef WIN32
2715             RETVAL = env->GetStaticCharField(clazz,fieldID);
2716 #else
2717             RETVAL = (*env)->GetStaticCharField(env, clazz,fieldID);
2718 #endif
2719             RESTOREENV;
2720         }
2721     OUTPUT:
2722         RETVAL
2723
2724 jshort
2725 GetStaticShortField(clazz,fieldID)
2726         JNIEnv *                env = FETCHENV;
2727         jclass                  clazz
2728         jfieldID                fieldID
2729         char *                  sig = 0;
2730     CODE:
2731         {
2732 #ifdef WIN32
2733             RETVAL = env->GetStaticShortField(clazz,fieldID);
2734 #else
2735             RETVAL = (*env)->GetStaticShortField(env, clazz,fieldID);
2736 #endif
2737             RESTOREENV;
2738         }
2739     OUTPUT:
2740         RETVAL
2741
2742 jint
2743 GetStaticIntField(clazz,fieldID)
2744         JNIEnv *                env = FETCHENV;
2745         jclass                  clazz
2746         jfieldID                fieldID
2747         char *                  sig = 0;
2748     CODE:
2749         {
2750 #ifdef WIN32
2751             RETVAL = env->GetStaticIntField(clazz,fieldID);
2752 #else
2753             RETVAL = (*env)->GetStaticIntField(env, clazz,fieldID);
2754 #endif
2755             RESTOREENV;
2756         }
2757     OUTPUT:
2758         RETVAL
2759
2760 jlong
2761 GetStaticLongField(clazz,fieldID)
2762         JNIEnv *                env = FETCHENV;
2763         jclass                  clazz
2764         jfieldID                fieldID
2765         char *                  sig = 0;
2766     CODE:
2767         {
2768 #ifdef WIN32
2769             RETVAL = env->GetStaticLongField(clazz,fieldID);
2770 #else
2771             RETVAL = (*env)->GetStaticLongField(env, clazz,fieldID);
2772 #endif
2773             RESTOREENV;
2774         }
2775     OUTPUT:
2776         RETVAL
2777
2778 jfloat
2779 GetStaticFloatField(clazz,fieldID)
2780         JNIEnv *                env = FETCHENV;
2781         jclass                  clazz
2782         jfieldID                fieldID
2783         char *                  sig = 0;
2784     CODE:
2785         {
2786 #ifdef WIN32
2787             RETVAL = env->GetStaticFloatField(clazz,fieldID);
2788 #else
2789             RETVAL = (*env)->GetStaticFloatField(env, clazz,fieldID);
2790 #endif
2791             RESTOREENV;
2792         }
2793     OUTPUT:
2794         RETVAL
2795
2796 jdouble
2797 GetStaticDoubleField(clazz,fieldID)
2798         JNIEnv *                env = FETCHENV;
2799         jclass                  clazz
2800         jfieldID                fieldID
2801         char *                  sig = 0;
2802     CODE:
2803         {
2804 #ifdef WIN32
2805             RETVAL = env->GetStaticDoubleField(clazz,fieldID);
2806 #else
2807             RETVAL = (*env)->GetStaticDoubleField(env, clazz,fieldID);
2808 #endif
2809             RESTOREENV;
2810         }
2811     OUTPUT:
2812         RETVAL
2813
2814 void
2815 SetStaticObjectField(clazz,fieldID,value)
2816         JNIEnv *                env = FETCHENV;
2817         jclass                  clazz
2818         jfieldID                fieldID
2819         char *                  sig = 0;
2820         jobject                 value
2821     CODE:
2822         {
2823 #ifdef WIN32
2824           env->SetStaticObjectField(clazz,fieldID,value);
2825 #else
2826           (*env)->SetStaticObjectField(env, clazz,fieldID,value);
2827 #endif
2828             RESTOREENV;
2829         }
2830
2831 void
2832 SetStaticBooleanField(clazz,fieldID,value)
2833         JNIEnv *                env = FETCHENV;
2834         jclass                  clazz
2835         jfieldID                fieldID
2836         char *                  sig = 0;
2837         jboolean                value
2838     CODE:
2839         {
2840 #ifdef WIN32
2841           env->SetStaticBooleanField(clazz,fieldID,value);
2842 #else
2843           (*env)->SetStaticBooleanField(env, clazz,fieldID,value);
2844 #endif
2845             RESTOREENV;
2846         }
2847
2848 void
2849 SetStaticByteField(clazz,fieldID,value)
2850         JNIEnv *                env = FETCHENV;
2851         jclass                  clazz
2852         jfieldID                fieldID
2853         char *                  sig = 0;
2854         jbyte                   value
2855     CODE:
2856         {
2857 #ifdef WIN32
2858           env->SetStaticByteField(clazz,fieldID,value);
2859 #else
2860           (*env)->SetStaticByteField(env, clazz,fieldID,value);
2861 #endif
2862             RESTOREENV;
2863         }
2864
2865 void
2866 SetStaticCharField(clazz,fieldID,value)
2867         JNIEnv *                env = FETCHENV;
2868         jclass                  clazz
2869         jfieldID                fieldID
2870         char *                  sig = 0;
2871         jchar                   value
2872     CODE:
2873         {
2874 #ifdef WIN32
2875           env->SetStaticCharField(clazz,fieldID,value);
2876 #else
2877           (*env)->SetStaticCharField(env, clazz,fieldID,value);
2878 #endif
2879             RESTOREENV;
2880         }
2881
2882 void
2883 SetStaticShortField(clazz,fieldID,value)
2884         JNIEnv *                env = FETCHENV;
2885         jclass                  clazz
2886         jfieldID                fieldID
2887         char *                  sig = 0;
2888         jshort                  value
2889     CODE:
2890         {
2891 #ifdef WIN32
2892           env->SetStaticShortField(clazz,fieldID,value);
2893 #else
2894           (*env)->SetStaticShortField(env, clazz,fieldID,value);
2895 #endif
2896             RESTOREENV;
2897         }
2898
2899 void
2900 SetStaticIntField(clazz,fieldID,value)
2901         JNIEnv *                env = FETCHENV;
2902         jclass                  clazz
2903         jfieldID                fieldID
2904         char *                  sig = 0;
2905         jint                    value
2906     CODE:
2907         {
2908 #ifdef WIN32
2909           env->SetStaticIntField(clazz,fieldID,value);
2910 #else
2911           (*env)->SetStaticIntField(env, clazz,fieldID,value);
2912 #endif
2913             RESTOREENV;
2914         }
2915
2916 void
2917 SetStaticLongField(clazz,fieldID,value)
2918         JNIEnv *                env = FETCHENV;
2919         jclass                  clazz
2920         jfieldID                fieldID
2921         char *                  sig = 0;
2922         jlong                   value
2923     CODE:
2924         {
2925 #ifdef WIN32
2926           env->SetStaticLongField(clazz,fieldID,value);
2927 #else
2928           (*env)->SetStaticLongField(env, clazz,fieldID,value);
2929 #endif
2930             RESTOREENV;
2931         }
2932
2933 void
2934 SetStaticFloatField(clazz,fieldID,value)
2935         JNIEnv *                env = FETCHENV;
2936         jclass                  clazz
2937         jfieldID                fieldID
2938         char *                  sig = 0;
2939         jfloat                  value
2940     CODE:
2941         {
2942 #ifdef WIN32
2943           env->SetStaticFloatField(clazz,fieldID,value);
2944 #else
2945           (*env)->SetStaticFloatField(env, clazz,fieldID,value);
2946 #endif
2947             RESTOREENV;
2948         }
2949
2950 void
2951 SetStaticDoubleField(clazz,fieldID,value)
2952         JNIEnv *                env = FETCHENV;
2953         jclass                  clazz
2954         jfieldID                fieldID
2955         char *                  sig = 0;
2956         jdouble                 value
2957     CODE:
2958         {
2959 #ifdef WIN32
2960           env->SetStaticDoubleField(clazz,fieldID,value);
2961 #else
2962           (*env)->SetStaticDoubleField(env, clazz,fieldID,value);
2963 #endif
2964             RESTOREENV;
2965         }
2966
2967 jstring
2968 NewString(unicode)
2969         JNIEnv *                env = FETCHENV;
2970         STRLEN                  tmplen = NO_INIT;
2971         jsize                   unicode_len_ = NO_INIT;
2972         const jchar *           unicode
2973     CODE:
2974         {
2975 #ifdef WIN32
2976             RETVAL = env->NewString(unicode, unicode_len_);
2977 #else
2978             RETVAL = (*env)->NewString(env, unicode, unicode_len_);
2979 #endif
2980             RESTOREENV;
2981         }
2982     OUTPUT:
2983         RETVAL
2984
2985 jsize
2986 GetStringLength(str)
2987         JNIEnv *                env = FETCHENV;
2988         jstring                 str
2989     CODE:
2990         {
2991 #ifdef WIN32
2992             RETVAL = env->GetStringLength(str);
2993 #else
2994             RETVAL = (*env)->GetStringLength(env, str);
2995 #endif
2996             RESTOREENV;
2997         }
2998     OUTPUT:
2999         RETVAL
3000
3001 const jchar *
3002 GetStringChars(str)
3003         JNIEnv *                env = FETCHENV;
3004         jstring                 str
3005         jboolean                isCopy = NO_INIT;
3006         jsize                   RETVAL_len_ = NO_INIT;
3007     CODE:
3008         {
3009 #ifdef WIN32
3010             RETVAL = env->GetStringChars(str,&isCopy);
3011 #else
3012             RETVAL = (*env)->GetStringChars(env, str,&isCopy);
3013 #endif
3014 #ifdef WIN32
3015             RETVAL_len_ = env->GetStringLength(str);
3016 #else
3017             RETVAL_len_ = (*env)->GetStringLength(env, str);
3018 #endif
3019             RESTOREENV;
3020         }
3021     OUTPUT:
3022         RETVAL
3023     CLEANUP:
3024 #ifdef WIN32
3025             env->ReleaseStringChars(str,RETVAL);
3026 #else
3027             (*env)->ReleaseStringChars(env, str,RETVAL);
3028 #endif
3029
3030 jstring
3031 NewStringUTF(utf)
3032         JNIEnv *                env = FETCHENV;
3033         const char *            utf
3034     CODE:
3035         {
3036 #ifdef WIN32
3037             RETVAL = env->NewStringUTF(utf);
3038 #else
3039             RETVAL = (*env)->NewStringUTF(env, utf);
3040 #endif
3041             RESTOREENV;
3042         }
3043     OUTPUT:
3044         RETVAL
3045
3046 jsize
3047 GetStringUTFLength(str)
3048         JNIEnv *                env = FETCHENV;
3049         jstring                 str
3050     CODE:
3051         {
3052 #ifdef WIN32
3053             RETVAL = env->GetStringUTFLength(str);
3054 #else
3055             RETVAL = (*env)->GetStringUTFLength(env, str);
3056 #endif
3057             RESTOREENV;
3058         }
3059     OUTPUT:
3060         RETVAL
3061
3062 const char *
3063 GetStringUTFChars(str)
3064         JNIEnv *                env = FETCHENV;
3065         jstring                 str
3066         jboolean                isCopy = NO_INIT;
3067     CODE:
3068         {
3069 #ifdef WIN32
3070             RETVAL = env->GetStringUTFChars(str,&isCopy);
3071 #else
3072             RETVAL = (*env)->GetStringUTFChars(env, str,&isCopy);
3073 #endif
3074             RESTOREENV;
3075         }
3076     OUTPUT:
3077         RETVAL
3078     CLEANUP:
3079 #ifdef WIN32
3080         env->ReleaseStringUTFChars(str, RETVAL);
3081 #else
3082         (*env)->ReleaseStringUTFChars(env, str, RETVAL);
3083 #endif
3084
3085
3086 jsize
3087 GetArrayLength(array)
3088         JNIEnv *                env = FETCHENV;
3089         jarray                  array
3090     CODE:
3091         {
3092 #ifdef WIN32
3093             RETVAL = env->GetArrayLength(array);
3094 #else
3095             RETVAL = (*env)->GetArrayLength(env, array);
3096 #endif
3097             RESTOREENV;
3098         }
3099     OUTPUT:
3100         RETVAL
3101
3102 jobjectArray
3103 NewObjectArray(len,clazz,init)
3104         JNIEnv *                env = FETCHENV;
3105         jsize                   len
3106         jclass                  clazz
3107         jobject                 init
3108     CODE:
3109         {
3110 #ifdef WIN32
3111             RETVAL = env->NewObjectArray(len,clazz,init);
3112 #else
3113             RETVAL = (*env)->NewObjectArray(env, len,clazz,init);
3114 #endif
3115             RESTOREENV;
3116         }
3117     OUTPUT:
3118         RETVAL
3119
3120 jobject
3121 GetObjectArrayElement(array,index)
3122         JNIEnv *                env = FETCHENV;
3123         jobjectArray            array
3124         jsize                   index
3125     CODE:
3126         {
3127 #ifdef WIN32
3128             RETVAL = env->GetObjectArrayElement(array,index);
3129 #else
3130             RETVAL = (*env)->GetObjectArrayElement(env, array,index);
3131 #endif
3132             RESTOREENV;
3133         }
3134     OUTPUT:
3135         RETVAL
3136
3137 void
3138 SetObjectArrayElement(array,index,val)
3139         JNIEnv *                env = FETCHENV;
3140         jobjectArray            array
3141         jsize                   index
3142         jobject                 val
3143     CODE:
3144         {
3145 #ifdef WIN32
3146             env->SetObjectArrayElement(array,index,val);
3147 #else
3148             (*env)->SetObjectArrayElement(env, array,index,val);
3149 #endif
3150             RESTOREENV;
3151         }
3152
3153 jbooleanArray
3154 NewBooleanArray(len)
3155         JNIEnv *                env = FETCHENV;
3156         jsize                   len
3157     CODE:
3158         {
3159 #ifdef WIN32
3160             RETVAL = env->NewBooleanArray(len);
3161 #else
3162             RETVAL = (*env)->NewBooleanArray(env, len);
3163 #endif
3164             RESTOREENV;
3165         }
3166     OUTPUT:
3167         RETVAL
3168
3169 jbyteArray
3170 NewByteArray(len)
3171         JNIEnv *                env = FETCHENV;
3172         jsize                   len
3173     CODE:
3174         {
3175 #ifdef WIN32
3176             RETVAL = env->NewByteArray(len);
3177 #else
3178             RETVAL = (*env)->NewByteArray(env, len);
3179 #endif
3180             RESTOREENV;
3181         }
3182     OUTPUT:
3183         RETVAL
3184
3185 jcharArray
3186 NewCharArray(len)
3187         JNIEnv *                env = FETCHENV;
3188         jsize                   len
3189     CODE:
3190         {
3191 #ifdef WIN32
3192             RETVAL = env->NewCharArray(len);
3193 #else
3194             RETVAL = (*env)->NewCharArray(env, len);
3195 #endif
3196             RESTOREENV;
3197         }
3198     OUTPUT:
3199         RETVAL
3200
3201 jshortArray
3202 NewShortArray(len)
3203         JNIEnv *                env = FETCHENV;
3204         jsize                   len
3205     CODE:
3206         {
3207 #ifdef WIN32
3208             RETVAL = env->NewShortArray(len);
3209 #else
3210             RETVAL = (*env)->NewShortArray(env, len);
3211 #endif
3212             RESTOREENV;
3213         }
3214     OUTPUT:
3215         RETVAL
3216
3217 jintArray
3218 NewIntArray(len)
3219         JNIEnv *                env = FETCHENV;
3220         jsize                   len
3221     CODE:
3222         {
3223 #ifdef WIN32
3224             RETVAL = env->NewIntArray(len);
3225 #else
3226             RETVAL = (*env)->NewIntArray(env, len);
3227 #endif
3228             RESTOREENV;
3229         }
3230     OUTPUT:
3231         RETVAL
3232
3233 jlongArray
3234 NewLongArray(len)
3235         JNIEnv *                env = FETCHENV;
3236         jsize                   len
3237     CODE:
3238         {
3239 #ifdef WIN32
3240             RETVAL = env->NewLongArray(len);
3241 #else
3242             RETVAL = (*env)->NewLongArray(env, len);
3243 #endif
3244             RESTOREENV;
3245         }
3246     OUTPUT:
3247         RETVAL
3248
3249 jfloatArray
3250 NewFloatArray(len)
3251         JNIEnv *                env = FETCHENV;
3252         jsize                   len
3253     CODE:
3254         {
3255 #ifdef WIN32
3256             RETVAL = env->NewFloatArray(len);
3257 #else
3258             RETVAL = (*env)->NewFloatArray(env, len);
3259 #endif
3260             RESTOREENV;
3261         }
3262     OUTPUT:
3263         RETVAL
3264
3265 jdoubleArray
3266 NewDoubleArray(len)
3267         JNIEnv *                env = FETCHENV;
3268         jsize                   len
3269     CODE:
3270         {
3271 #ifdef WIN32
3272             RETVAL = env->NewDoubleArray(len);
3273 #else
3274             RETVAL = (*env)->NewDoubleArray(env, len);
3275 #endif
3276             RESTOREENV;
3277         }
3278     OUTPUT:
3279         RETVAL
3280
3281 jboolean *
3282 GetBooleanArrayElements(array)
3283         JNIEnv *                env = FETCHENV;
3284         jsize                   RETVAL_len_ = NO_INIT;
3285         jbooleanArray           array
3286         jboolean                isCopy = NO_INIT;
3287     PPCODE:
3288         {
3289 #ifdef WIN32
3290             RETVAL = env->GetBooleanArrayElements(array,&isCopy);
3291 #else
3292             RETVAL = (*env)->GetBooleanArrayElements(env, array,&isCopy);
3293 #endif
3294 #ifdef WIN32
3295             RETVAL_len_ = env->GetArrayLength(array);
3296 #else
3297             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3298 #endif
3299             if (GIMME == G_ARRAY) {
3300                 int i;
3301                 jboolean* r = RETVAL;
3302                 EXTEND(sp, RETVAL_len_);
3303                 for (i = RETVAL_len_; i; --i) {
3304                     PUSHs(sv_2mortal(newSViv(*r++)));
3305                 }
3306             }
3307             else {
3308                 if (RETVAL_len_) {
3309                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3310                         (STRLEN)RETVAL_len_ * sizeof(jboolean))));
3311                 }
3312                 else
3313                     PUSHs(&PL_sv_no);
3314             }
3315 #ifdef WIN32
3316             env->ReleaseBooleanArrayElements(array,RETVAL,JNI_ABORT);
3317 #else
3318             (*env)->ReleaseBooleanArrayElements(env, array,RETVAL,JNI_ABORT);
3319 #endif
3320             RESTOREENV;
3321         }
3322
3323 jbyte *
3324 GetByteArrayElements(array)
3325         JNIEnv *                env = FETCHENV;
3326         jsize                   RETVAL_len_ = NO_INIT;
3327         jbyteArray              array
3328         jboolean                isCopy = NO_INIT;
3329     PPCODE:
3330         {
3331 #ifdef WIN32
3332             RETVAL = env->GetByteArrayElements(array,&isCopy);
3333 #else
3334             RETVAL = (*env)->GetByteArrayElements(env, array,&isCopy);
3335 #endif
3336 #ifdef WIN32
3337             RETVAL_len_ = env->GetArrayLength(array);
3338 #else
3339             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3340 #endif
3341             if (GIMME == G_ARRAY) {
3342                 int i;
3343                 jbyte* r = RETVAL;
3344                 EXTEND(sp, RETVAL_len_);
3345                 for (i = RETVAL_len_; i; --i) {
3346                     PUSHs(sv_2mortal(newSViv(*r++)));
3347                 }
3348             }
3349             else {
3350                 if (RETVAL_len_) {
3351                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3352                         (STRLEN)RETVAL_len_ * sizeof(jbyte))));
3353                 }
3354                 else
3355                     PUSHs(&PL_sv_no);
3356             }
3357 #ifdef WIN32
3358             env->ReleaseByteArrayElements(array,RETVAL,JNI_ABORT);
3359 #else
3360             (*env)->ReleaseByteArrayElements(env, array,RETVAL,JNI_ABORT);
3361 #endif
3362             RESTOREENV;
3363         }
3364
3365 jchar *
3366 GetCharArrayElements(array)
3367         JNIEnv *                env = FETCHENV;
3368         jsize                   RETVAL_len_ = NO_INIT;
3369         jcharArray              array
3370         jboolean                isCopy = NO_INIT;
3371     PPCODE:
3372         {
3373 #ifdef WIN32
3374             RETVAL = env->GetCharArrayElements(array,&isCopy);
3375 #else
3376             RETVAL = (*env)->GetCharArrayElements(env, array,&isCopy);
3377 #endif
3378 #ifdef WIN32
3379             RETVAL_len_ = env->GetArrayLength(array);
3380 #else
3381             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3382 #endif
3383             if (GIMME == G_ARRAY) {
3384                 int i;
3385                 jchar* r = RETVAL;
3386                 EXTEND(sp, RETVAL_len_);
3387                 for (i = RETVAL_len_; i; --i) {
3388                     PUSHs(sv_2mortal(newSViv(*r++)));
3389                 }
3390             }
3391             else {
3392                 if (RETVAL_len_) {
3393                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3394                         (STRLEN)RETVAL_len_ * sizeof(jchar))));
3395                 }
3396                 else
3397                     PUSHs(&PL_sv_no);
3398             }
3399 #ifdef WIN32
3400             env->ReleaseCharArrayElements(array,RETVAL,JNI_ABORT);
3401 #else
3402             (*env)->ReleaseCharArrayElements(env, array,RETVAL,JNI_ABORT);
3403 #endif
3404             RESTOREENV;
3405         }
3406
3407 jshort *
3408 GetShortArrayElements(array)
3409         JNIEnv *                env = FETCHENV;
3410         jsize                   RETVAL_len_ = NO_INIT;
3411         jshortArray             array
3412         jboolean                isCopy = NO_INIT;
3413     PPCODE:
3414         {
3415 #ifdef WIN32
3416             RETVAL = env->GetShortArrayElements(array,&isCopy);
3417 #else
3418             RETVAL = (*env)->GetShortArrayElements(env, array,&isCopy);
3419 #endif
3420 #ifdef WIN32
3421             RETVAL_len_ = env->GetArrayLength(array);
3422 #else
3423             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3424 #endif
3425             if (GIMME == G_ARRAY) {
3426                 int i;
3427                 jshort* r = RETVAL;
3428                 EXTEND(sp, RETVAL_len_);
3429                 for (i = RETVAL_len_; i; --i) {
3430                     PUSHs(sv_2mortal(newSViv(*r++)));
3431                 }
3432             }
3433             else {
3434                 if (RETVAL_len_) {
3435                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3436                         (STRLEN)RETVAL_len_ * sizeof(jshort))));
3437                 }
3438                 else
3439                     PUSHs(&PL_sv_no);
3440             }
3441 #ifdef WIN32
3442             env->ReleaseShortArrayElements(array,RETVAL,JNI_ABORT);
3443 #else
3444             (*env)->ReleaseShortArrayElements(env, array,RETVAL,JNI_ABORT);
3445 #endif
3446             RESTOREENV;
3447         }
3448
3449 jint *
3450 GetIntArrayElements(array)
3451         JNIEnv *                env = FETCHENV;
3452         jsize                   RETVAL_len_ = NO_INIT;
3453         jintArray               array
3454         jboolean                isCopy = NO_INIT;
3455     PPCODE:
3456         {
3457 #ifdef WIN32
3458             RETVAL = env->GetIntArrayElements(array,&isCopy);
3459 #else
3460             RETVAL = (*env)->GetIntArrayElements(env, array,&isCopy);
3461 #endif
3462 #ifdef WIN32
3463             RETVAL_len_ = env->GetArrayLength(array);
3464 #else
3465             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3466 #endif
3467             if (GIMME == G_ARRAY) {
3468                 int i;
3469                 jint* r = RETVAL;
3470                 EXTEND(sp, RETVAL_len_);
3471                 for (i = RETVAL_len_; i; --i) {
3472                     PUSHs(sv_2mortal(newSViv(*r++)));
3473                 }
3474             }
3475             else {
3476                 if (RETVAL_len_) {
3477                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3478                         (STRLEN)RETVAL_len_ * sizeof(jint))));
3479                 }
3480                 else
3481                     PUSHs(&PL_sv_no);
3482             }
3483 #ifdef WIN32
3484             env->ReleaseIntArrayElements(array,RETVAL,JNI_ABORT);
3485 #else
3486             (*env)->ReleaseIntArrayElements(env, array,RETVAL,JNI_ABORT);
3487 #endif
3488             RESTOREENV;
3489         }
3490
3491 jlong *
3492 GetLongArrayElements(array)
3493         JNIEnv *                env = FETCHENV;
3494         jsize                   RETVAL_len_ = NO_INIT;
3495         jlongArray              array
3496         jboolean                isCopy = NO_INIT;
3497     PPCODE:
3498         {
3499 #ifdef WIN32
3500             RETVAL = env->GetLongArrayElements(array,&isCopy);
3501 #else
3502             RETVAL = (*env)->GetLongArrayElements(env, array,&isCopy);
3503 #endif
3504 #ifdef WIN32
3505             RETVAL_len_ = env->GetArrayLength(array);
3506 #else
3507             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3508 #endif
3509             if (GIMME == G_ARRAY) {
3510                 int i;
3511                 jlong* r = RETVAL;
3512                 EXTEND(sp, RETVAL_len_);
3513                 for (i = RETVAL_len_; i; --i) {
3514                     PUSHs(sv_2mortal(newSViv(*r++)));
3515                 }
3516             }
3517             else {
3518                 if (RETVAL_len_) {
3519                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3520                         (STRLEN)RETVAL_len_ * sizeof(jlong))));
3521                 }
3522                 else
3523                     PUSHs(&PL_sv_no);
3524             }
3525 #ifdef WIN32
3526             env->ReleaseLongArrayElements(array,RETVAL,JNI_ABORT);
3527 #else
3528             (*env)->ReleaseLongArrayElements(env, array,RETVAL,JNI_ABORT);
3529 #endif
3530             RESTOREENV;
3531         }
3532
3533 jfloat *
3534 GetFloatArrayElements(array)
3535         JNIEnv *                env = FETCHENV;
3536         jsize                   RETVAL_len_ = NO_INIT;
3537         jfloatArray             array
3538         jboolean                isCopy = NO_INIT;
3539     PPCODE:
3540         {
3541 #ifdef WIN32
3542             RETVAL = env->GetFloatArrayElements(array,&isCopy);
3543 #else
3544             RETVAL = (*env)->GetFloatArrayElements(env, array,&isCopy);
3545 #endif
3546 #ifdef WIN32
3547             RETVAL_len_ = env->GetArrayLength(array);
3548 #else
3549             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3550 #endif
3551             if (GIMME == G_ARRAY) {
3552                 int i;
3553                 jfloat* r = RETVAL;
3554                 EXTEND(sp, RETVAL_len_);
3555                 for (i = RETVAL_len_; i; --i) {
3556                     PUSHs(sv_2mortal(newSVnv(*r++)));
3557                 }
3558             }
3559             else {
3560                 if (RETVAL_len_) {
3561                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3562                         (STRLEN)RETVAL_len_ * sizeof(jfloat))));
3563                 }
3564                 else
3565                     PUSHs(&PL_sv_no);
3566             }
3567 #ifdef WIN32
3568             env->ReleaseFloatArrayElements(array,RETVAL,JNI_ABORT);
3569 #else
3570             (*env)->ReleaseFloatArrayElements(env, array,RETVAL,JNI_ABORT);
3571 #endif
3572             RESTOREENV;
3573         }
3574
3575 jdouble *
3576 GetDoubleArrayElements(array)
3577         JNIEnv *                env = FETCHENV;
3578         jsize                   RETVAL_len_ = NO_INIT;
3579         jdoubleArray            array
3580         jboolean                isCopy = NO_INIT;
3581     PPCODE:
3582         {
3583 #ifdef WIN32
3584             RETVAL = env->GetDoubleArrayElements(array,&isCopy);
3585 #else
3586             RETVAL = (*env)->GetDoubleArrayElements(env, array,&isCopy);
3587 #endif
3588 #ifdef WIN32
3589             RETVAL_len_ = env->GetArrayLength(array);
3590 #else
3591             RETVAL_len_ = (*env)->GetArrayLength(env, array);
3592 #endif
3593             if (GIMME == G_ARRAY) {
3594                 int i;
3595                 jdouble* r = RETVAL;
3596                 EXTEND(sp, RETVAL_len_);
3597                 for (i = RETVAL_len_; i; --i) {
3598                     PUSHs(sv_2mortal(newSVnv(*r++)));
3599                 }
3600             }
3601             else {
3602                 if (RETVAL_len_) {
3603                     PUSHs(sv_2mortal(newSVpvn((char*)RETVAL,
3604                         (STRLEN)RETVAL_len_ * sizeof(jdouble))));
3605                 }
3606                 else
3607                     PUSHs(&PL_sv_no);
3608             }
3609 #ifdef WIN32
3610             env->ReleaseDoubleArrayElements(array,RETVAL,JNI_ABORT);
3611 #else
3612             (*env)->ReleaseDoubleArrayElements(env, array,RETVAL,JNI_ABORT);
3613 #endif
3614             RESTOREENV;
3615         }
3616
3617 void
3618 GetBooleanArrayRegion(array,start,len,buf)
3619         JNIEnv *                env = FETCHENV;
3620         jbooleanArray           array
3621         jsize                   start
3622         jsize                   len
3623         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3624         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3625         jboolean *              buf = (jboolean*)sv_grow(ST(3),len * sizeof(jboolean)+1);
3626     CODE:
3627         {
3628 #ifdef WIN32
3629             env->GetBooleanArrayRegion(array,start,len,buf);
3630 #else
3631             (*env)->GetBooleanArrayRegion(env, array,start,len,buf);
3632 #endif
3633             SvCUR_set(ST(3), len * sizeof(jboolean));
3634             *SvEND(ST(3)) = '\0';
3635             RESTOREENV;
3636         }
3637
3638 void
3639 GetByteArrayRegion(array,start,len,buf)
3640         JNIEnv *                env = FETCHENV;
3641         jbyteArray              array
3642         jsize                   start
3643         jsize                   len
3644         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3645         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3646         jbyte *                 buf = (jbyte*)sv_grow(ST(3),len * sizeof(jbyte)+1);
3647     CODE:
3648         {
3649 #ifdef WIN32
3650             env->GetByteArrayRegion(array,start,len,buf);
3651 #else
3652             (*env)->GetByteArrayRegion(env, array,start,len,buf);
3653 #endif
3654             SvCUR_set(ST(3), len * sizeof(jbyte));
3655             *SvEND(ST(3)) = '\0';
3656             RESTOREENV;
3657         }
3658
3659 void
3660 GetCharArrayRegion(array,start,len,buf)
3661         JNIEnv *                env = FETCHENV;
3662         jcharArray              array
3663         jsize                   start
3664         jsize                   len
3665         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3666         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3667         jchar *                 buf = (jchar*)sv_grow(ST(3),len * sizeof(jchar)+1);
3668     CODE:
3669         {
3670 #ifdef WIN32
3671             env->GetCharArrayRegion(array,start,len,buf);
3672 #else
3673             (*env)->GetCharArrayRegion(env, array,start,len,buf);
3674 #endif
3675             SvCUR_set(ST(3), len * sizeof(jchar));
3676             *SvEND(ST(3)) = '\0';
3677             RESTOREENV;
3678         }
3679
3680 void
3681 GetShortArrayRegion(array,start,len,buf)
3682         JNIEnv *                env = FETCHENV;
3683         jshortArray             array
3684         jsize                   start
3685         jsize                   len
3686         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3687         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3688         jshort *                buf = (jshort*)sv_grow(ST(3),len * sizeof(jshort)+1);
3689     CODE:
3690         {
3691 #ifdef WIN32
3692             env->GetShortArrayRegion(array,start,len,buf);
3693 #else
3694             (*env)->GetShortArrayRegion(env, array,start,len,buf);
3695 #endif
3696             SvCUR_set(ST(3), len * sizeof(jshort));
3697             *SvEND(ST(3)) = '\0';
3698             RESTOREENV;
3699         }
3700
3701 void
3702 GetIntArrayRegion(array,start,len,buf)
3703         JNIEnv *                env = FETCHENV;
3704         jintArray               array
3705         jsize                   start
3706         jsize                   len
3707         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3708         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3709         jint *                  buf = (jint*)sv_grow(ST(3),len * sizeof(jint)+1);
3710     CODE:
3711         {
3712 #ifdef WIN32
3713             env->GetIntArrayRegion(array,start,len,buf);
3714 #else
3715             (*env)->GetIntArrayRegion(env, array,start,len,buf);
3716 #endif
3717             SvCUR_set(ST(3), len * sizeof(jint));
3718             *SvEND(ST(3)) = '\0';
3719             RESTOREENV;
3720         }
3721
3722 void
3723 GetLongArrayRegion(array,start,len,buf)
3724         JNIEnv *                env = FETCHENV;
3725         jlongArray              array
3726         jsize                   start
3727         jsize                   len
3728         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3729         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3730         jlong *                 buf = (jlong*)sv_grow(ST(3),len * sizeof(jlong)+1);
3731     CODE:
3732         {
3733 #ifdef WIN32
3734             env->GetLongArrayRegion(array,start,len,buf);
3735 #else
3736             (*env)->GetLongArrayRegion(env, array,start,len,buf);
3737 #endif
3738             SvCUR_set(ST(3), len * sizeof(jlong));
3739             *SvEND(ST(3)) = '\0';
3740             RESTOREENV;
3741         }
3742
3743 void
3744 GetFloatArrayRegion(array,start,len,buf)
3745         JNIEnv *                env = FETCHENV;
3746         jfloatArray             array
3747         jsize                   start
3748         jsize                   len
3749         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3750         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3751         jfloat *                buf = (jfloat*)sv_grow(ST(3),len * sizeof(jfloat)+1);
3752     CODE:
3753         {
3754 #ifdef WIN32
3755             env->GetFloatArrayRegion(array,start,len,buf);
3756 #else
3757             (*env)->GetFloatArrayRegion(env, array,start,len,buf);
3758 #endif
3759             SvCUR_set(ST(3), len * sizeof(jfloat));
3760             *SvEND(ST(3)) = '\0';
3761             RESTOREENV;
3762         }
3763
3764 void
3765 GetDoubleArrayRegion(array,start,len,buf)
3766         JNIEnv *                env = FETCHENV;
3767         jdoubleArray            array
3768         jsize                   start
3769         jsize                   len
3770         STRLEN                  tmplen = len * sizeof(jboolean) + 1;
3771         char *                  tmpbuf = (char*)sv_pvn_force(ST(3), &tmplen);
3772         jdouble *               buf = (jdouble*)sv_grow(ST(3),len * sizeof(jdouble)+1);
3773     CODE:
3774         {
3775 #ifdef WIN32
3776             env->GetDoubleArrayRegion(array,start,len,buf);
3777 #else
3778             (*env)->GetDoubleArrayRegion(env, array,start,len,buf);
3779 #endif
3780             SvCUR_set(ST(3), len * sizeof(jdouble));
3781             *SvEND(ST(3)) = '\0';
3782             RESTOREENV;
3783         }
3784
3785 void
3786 SetBooleanArrayRegion(array,start,len,buf)
3787         JNIEnv *                env = FETCHENV;
3788         STRLEN                  tmplen = NO_INIT;
3789         jbooleanArray           array
3790         jsize                   start
3791         jsize                   len
3792         jsize                   buf_len_ = NO_INIT;
3793         jboolean *              buf
3794     CODE:
3795         {
3796             if (buf_len_ < len)
3797                 croak("string is too short");
3798             else if (buf_len_ > len && PL_dowarn)
3799                 warn("string is too long");
3800 #ifdef WIN32
3801             env->SetBooleanArrayRegion(array,start,len,buf);
3802 #else
3803             (*env)->SetBooleanArrayRegion(env, array,start,len,buf);
3804 #endif
3805             RESTOREENV;
3806         }
3807
3808 void
3809 SetByteArrayRegion(array,start,len,buf)
3810         JNIEnv *                env = FETCHENV;
3811         STRLEN                  tmplen = NO_INIT;
3812         jbyteArray              array
3813         jsize                   start
3814         jsize                   len
3815         jsize                   buf_len_ = NO_INIT;
3816         jbyte *                 buf
3817     CODE:
3818         {
3819             if (buf_len_ < len)
3820                 croak("string is too short");
3821             else if (buf_len_ > len && PL_dowarn)
3822                 warn("string is too long");
3823 #ifdef WIN32
3824             env->SetByteArrayRegion(array,start,len,buf);
3825 #else
3826             (*env)->SetByteArrayRegion(env, array,start,len,buf);
3827 #endif
3828             RESTOREENV;
3829         }
3830
3831 void
3832 SetCharArrayRegion(array,start,len,buf)
3833         JNIEnv *                env = FETCHENV;
3834         STRLEN                  tmplen = NO_INIT;
3835         jcharArray              array
3836         jsize                   start
3837         jsize                   len
3838         jsize                   buf_len_ = NO_INIT;
3839         jchar *                 buf
3840     CODE:
3841         {
3842             if (buf_len_ < len)
3843                 croak("string is too short");
3844             else if (buf_len_ > len && PL_dowarn)
3845                 warn("string is too long");
3846 #ifdef WIN32
3847             env->SetCharArrayRegion(array,start,len,buf);
3848 #else
3849             (*env)->SetCharArrayRegion(env, array,start,len,buf);
3850 #endif
3851             RESTOREENV;
3852         }
3853
3854 void
3855 SetShortArrayRegion(array,start,len,buf)
3856         JNIEnv *                env = FETCHENV;
3857         STRLEN                  tmplen = NO_INIT;
3858         jshortArray             array
3859         jsize                   start
3860         jsize                   len
3861         jsize                   buf_len_ = NO_INIT;
3862         jshort *                buf
3863     CODE:
3864         {
3865             if (buf_len_ < len)
3866                 croak("string is too short");
3867             else if (buf_len_ > len && PL_dowarn)
3868                 warn("string is too long");
3869 #ifdef WIN32
3870             env->SetShortArrayRegion(array,start,len,buf);
3871 #else
3872             (*env)->SetShortArrayRegion(env, array,start,len,buf);
3873 #endif
3874             RESTOREENV;
3875         }
3876
3877 void
3878 SetIntArrayRegion(array,start,len,buf)
3879         JNIEnv *                env = FETCHENV;
3880         STRLEN                  tmplen = NO_INIT;
3881         jintArray               array
3882         jsize                   start
3883         jsize                   len
3884         jsize                   buf_len_ = NO_INIT;
3885         jint *                  buf
3886     CODE:
3887         {
3888             if (buf_len_ < len)
3889                 croak("string is too short");
3890             else if (buf_len_ > len && PL_dowarn)
3891                 warn("string is too long");
3892 #ifdef WIN32
3893             env->SetIntArrayRegion(array,start,len,buf);
3894 #else
3895             (*env)->SetIntArrayRegion(env, array,start,len,buf);
3896 #endif
3897             RESTOREENV;
3898         }
3899
3900 void
3901 SetLongArrayRegion(array,start,len,buf)
3902         JNIEnv *                env = FETCHENV;
3903         STRLEN                  tmplen = NO_INIT;
3904         jlongArray              array
3905         jsize                   start
3906         jsize                   len
3907         jsize                   buf_len_ = NO_INIT;
3908         jlong *                 buf
3909     CODE:
3910         {
3911             if (buf_len_ < len)
3912                 croak("string is too short");
3913             else if (buf_len_ > len && PL_dowarn)
3914                 warn("string is too long");
3915 #ifdef WIN32
3916             env->SetLongArrayRegion(array,start,len,buf);
3917 #else
3918             (*env)->SetLongArrayRegion(env, array,start,len,buf);
3919 #endif
3920             RESTOREENV;
3921         }
3922
3923 void
3924 SetFloatArrayRegion(array,start,len,buf)
3925         JNIEnv *                env = FETCHENV;
3926         STRLEN                  tmplen = NO_INIT;
3927         jfloatArray             array
3928         jsize                   start
3929         jsize                   len
3930         jsize                   buf_len_ = NO_INIT;
3931         jfloat *                buf
3932     CODE:
3933         {
3934             if (buf_len_ < len)
3935                 croak("string is too short");
3936             else if (buf_len_ > len && PL_dowarn)
3937                 warn("string is too long");
3938 #ifdef WIN32
3939             env->SetFloatArrayRegion(array,start,len,buf);
3940 #else
3941             (*env)->SetFloatArrayRegion(env, array,start,len,buf);
3942 #endif
3943             RESTOREENV;
3944         }
3945
3946 void
3947 SetDoubleArrayRegion(array,start,len,buf)
3948         JNIEnv *                env = FETCHENV;
3949         STRLEN                  tmplen = NO_INIT;
3950         jdoubleArray            array
3951         jsize                   start
3952         jsize                   len
3953         jsize                   buf_len_ = NO_INIT;
3954         jdouble *               buf
3955     CODE:
3956         {
3957             if (buf_len_ < len)
3958                 croak("string is too short");
3959             else if (buf_len_ > len && PL_dowarn)
3960                 warn("string is too long");
3961 #ifdef WIN32
3962             env->SetDoubleArrayRegion(array,start,len,buf);
3963 #else
3964             (*env)->SetDoubleArrayRegion(env, array,start,len,buf);
3965 #endif
3966             RESTOREENV;
3967         }
3968
3969 SysRet
3970 RegisterNatives(clazz,methods,nMethods)
3971         JNIEnv *                env = FETCHENV;
3972         jclass                  clazz
3973         JNINativeMethod *       methods
3974         jint                    nMethods
3975     CODE:
3976         {
3977 #ifdef WIN32
3978             RETVAL = env->RegisterNatives(clazz,methods,nMethods);
3979 #else
3980             RETVAL = (*env)->RegisterNatives(env, clazz,methods,nMethods);
3981 #endif
3982         }
3983
3984 SysRet
3985 UnregisterNatives(clazz)
3986         JNIEnv *                env = FETCHENV;
3987         jclass                  clazz
3988     CODE:
3989         {
3990 #ifdef WIN32
3991             RETVAL = env->UnregisterNatives(clazz);
3992 #else
3993             RETVAL = (*env)->UnregisterNatives(env, clazz);
3994 #endif
3995         }
3996     OUTPUT:
3997         RETVAL  
3998    
3999 SysRet
4000 MonitorEnter(obj)
4001         JNIEnv *                env = FETCHENV;
4002         jobject                 obj
4003     CODE:
4004         {
4005 #ifdef WIN32
4006             RETVAL = env->MonitorEnter(obj);
4007 #else
4008             RETVAL = (*env)->MonitorEnter(env, obj);
4009 #endif
4010             RESTOREENV;
4011         }
4012     OUTPUT:
4013         RETVAL
4014
4015 SysRet
4016 MonitorExit(obj)
4017         JNIEnv *                env = FETCHENV;
4018         jobject                 obj
4019     CODE:
4020         {
4021 #ifdef WIN32
4022             RETVAL = env->MonitorExit(obj);
4023 #else
4024             RETVAL = (*env)->MonitorExit(env, obj);
4025 #endif
4026             RESTOREENV;
4027         }
4028     OUTPUT:
4029         RETVAL
4030
4031 JavaVM *
4032 GetJavaVM(...)
4033         JNIEnv *                env = FETCHENV;
4034     CODE:
4035         {
4036             if (env) {  /* We're embedded. */
4037 #ifdef WIN32
4038                 if (env->GetJavaVM(&RETVAL) < 0)
4039 #else
4040                 if ((*env)->GetJavaVM(env, &RETVAL) < 0)
4041 #endif
4042                     RETVAL = 0;
4043             }
4044             else {      /* We're embedding. */
4045 #ifdef KAFFE
4046                 JavaVMInitArgs vm_args;
4047 #else
4048                 JDK1_1InitArgs vm_args;
4049 #endif
4050                 char *lib;
4051                 if (jpldebug) {
4052                     fprintf(stderr, "We're embedding Java in Perl.\n");
4053                 }
4054
4055                 if (items--) {
4056                     ++mark;
4057                     lib = SvPV(*mark, PL_na);
4058                 }
4059                 else
4060                     lib = 0;
4061                 if (jpldebug) {
4062                     fprintf(stderr, "lib is %s.\n", lib);
4063                 }
4064 #ifdef WIN32
4065                 if (!LoadLibrary("javai.dll")) {
4066                     if (lib && !LoadLibrary(lib))
4067                         croak("Can't load javai.dll");
4068                 }
4069 #else
4070                 if (jpldebug) {
4071                     fprintf(stderr, "Opening Java shared library.\n");
4072                 }
4073 #ifdef KAFFE
4074                 if (!dlopen("libkaffevm.so", RTLD_LAZY|RTLD_GLOBAL)) {
4075 #else
4076                 if (!dlopen("libjava.so", RTLD_LAZY|RTLD_GLOBAL)) {
4077 #endif
4078                     if (lib && !dlopen(lib, RTLD_LAZY|RTLD_GLOBAL))
4079                         croak("Can't load Java shared library.");
4080                 }
4081 #endif
4082
4083                 JNI_GetDefaultJavaVMInitArgs(&vm_args);
4084                 vm_args.exit = &call_my_exit;
4085                 if (jpldebug) {
4086             fprintf(stderr, "items = %d\n", items);
4087             fprintf(stderr, "mark = %s\n", SvPV(*mark, PL_na));
4088         }
4089                 ++mark;
4090                 while (items > 1) {
4091                     char *s = SvPV(*mark,PL_na);
4092                     ++mark;
4093                     if (jpldebug) {
4094                 fprintf(stderr, "*s = %s\n", s);
4095                 fprintf(stderr, "val = %s\n", SvPV(*mark, PL_na));
4096             }
4097                     items -= 2;
4098                     if (strEQ(s, "checkSource"))
4099                         vm_args.checkSource = (jint)SvIV(*mark);
4100                     else if (strEQ(s, "nativeStackSize"))
4101                         vm_args.nativeStackSize = (jint)SvIV(*mark);
4102                     else if (strEQ(s, "javaStackSize"))
4103                         vm_args.javaStackSize = (jint)SvIV(*mark);
4104                     else if (strEQ(s, "minHeapSize"))
4105                         vm_args.minHeapSize = (jint)SvIV(*mark);
4106                     else if (strEQ(s, "maxHeapSize"))
4107                         vm_args.maxHeapSize = (jint)SvIV(*mark);
4108                     else if (strEQ(s, "verifyMode"))
4109                         vm_args.verifyMode = (jint)SvIV(*mark);
4110                     else if (strEQ(s, "classpath"))
4111                         vm_args.classpath = savepv(SvPV(*mark,PL_na));
4112                     else if (strEQ(s, "enableClassGC"))
4113                         vm_args.enableClassGC = (jint)SvIV(*mark);
4114                     else if (strEQ(s, "enableVerboseGC"))
4115                         vm_args.enableVerboseGC = (jint)SvIV(*mark);
4116                     else if (strEQ(s, "disableAsyncGC"))
4117                         vm_args.disableAsyncGC = (jint)SvIV(*mark);
4118 #ifndef KAFFE
4119                     else if (strEQ(s, "verbose"))
4120                         vm_args.verbose = (jint)SvIV(*mark); 
4121                     else if (strEQ(s, "debugging"))
4122                         vm_args.debugging = (jboolean)SvIV(*mark);
4123                     else if (strEQ(s, "debugPort"))
4124                         vm_args.debugPort = (jint)SvIV(*mark); 
4125 #endif
4126                     else
4127                         croak("unrecognized option: %s", s);
4128                 }
4129
4130                 if (jpldebug) {
4131                     fprintf(stderr, "Creating Java VM...\n");
4132                     fprintf(stderr, "Working CLASSPATH: %s\n", 
4133                         vm_args.classpath);
4134                 }
4135                 JNI_CreateJavaVM(&RETVAL, &jplcurenv, &vm_args);
4136                 if (jpldebug) {
4137                     fprintf(stderr, "Created Java VM.\n");
4138                 }
4139             }
4140         }
4141