~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Lib/java/java.swg

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
%typemap(in) bool
155
155
%{ $1 = $input ? true : false; %}
156
156
 
 
157
%typemap(directorout) bool
 
158
%{ $1 = $input ? true : false; %}
 
159
 
157
160
%typemap(javadirectorin) bool "$jniinput"
158
161
%typemap(javadirectorout) bool "$javacall"
159
162
 
171
174
             double
172
175
%{ $1 = ($1_ltype)$input; %}
173
176
 
 
177
%typemap(directorout) char, 
 
178
             signed char, 
 
179
             unsigned char, 
 
180
             short, 
 
181
             unsigned short, 
 
182
             int, 
 
183
             unsigned int, 
 
184
             long, 
 
185
             unsigned long, 
 
186
             long long, 
 
187
             float, 
 
188
             double
 
189
%{ $1 = ($1_ltype)$input; %}
 
190
 
174
191
%typemap(directorin, descriptor="Z") bool             "$input = (jboolean) $1;"
175
192
%typemap(directorin, descriptor="C") char             "$input = (jint) $1;"
176
193
%typemap(directorin, descriptor="B") signed char      "$input = (jbyte) $1;"
260
277
  JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
261
278
}
262
279
 
 
280
%typemap(directorout) unsigned long long { 
 
281
  jclass clazz;
 
282
  jmethodID mid;
 
283
  jbyteArray ba;
 
284
  jbyte* bae;
 
285
  jsize sz;
 
286
  int i;
 
287
 
 
288
  if (!$input) {
 
289
    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
 
290
    return $null;
 
291
  }
 
292
  clazz = JCALL1(GetObjectClass, jenv, $input);
 
293
  mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
 
294
  ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
 
295
  bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
 
296
  sz = JCALL1(GetArrayLength, jenv, ba);
 
297
  $1 = 0;
 
298
  if (bae[0] == 0) {
 
299
    for(i=sz-1; i>0; i-- ) {
 
300
      $1 = ($1 << 8) | (unsigned char)bae[sz-i];
 
301
    }
 
302
  } 
 
303
  else {
 
304
    for(i=sz; i>=0; i-- ) {
 
305
      $1 = ($1 << 8) | (unsigned char)bae[sz-1-i];
 
306
    }
 
307
  }
 
308
  JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
 
309
}
 
310
 
 
311
 
263
312
/* Convert to BigInteger - byte array holds number in 2's complement big endian format */
264
313
%typemap(out) unsigned long long { 
265
314
  jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
280
329
}
281
330
 
282
331
/* Convert to BigInteger (see out typemap) */
283
 
%typemap(directorin, descriptor="Ljava/math/Biginteger;") unsigned long long, const unsigned long long & {
 
332
%typemap(directorin, descriptor="Ljava/math/BigInteger;") unsigned long long, const unsigned long long & {
284
333
  jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
285
334
  jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
286
335
  jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
310
359
  }
311
360
}
312
361
 
 
362
%typemap(directorout) char * { 
 
363
  $1 = 0;
 
364
  if ($input) {
 
365
    $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
 
366
    if (!$1) return $null;
 
367
  }
 
368
}
 
369
 
313
370
%typemap(directorin, descriptor="Ljava/lang/String;") char * { 
314
371
  $input = 0;
315
372
  if ($1) {
333
390
%{ temp = $input ? true : false; 
334
391
   $1 = &temp; %}
335
392
 
 
393
%typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const bool &
 
394
%{ static $*1_ltype temp;
 
395
   temp = $input ? true : false; 
 
396
   $1 = &temp; %}
 
397
 
336
398
%typemap(javadirectorin) const bool & "$jniinput"
337
399
%typemap(javadirectorout) const bool & "$javacall"
338
400
 
351
413
%{ temp = ($*1_ltype)$input; 
352
414
   $1 = &temp; %}
353
415
 
 
416
%typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const char &,
 
417
             const signed char &,
 
418
             const unsigned char &,
 
419
             const short &,
 
420
             const unsigned short &,
 
421
             const int &,
 
422
             const unsigned int &,
 
423
             const long &,
 
424
             const unsigned long &,
 
425
             const long long &,
 
426
             const float &,
 
427
             const double &
 
428
%{ static $*1_ltype temp;
 
429
   temp = ($*1_ltype)$input; 
 
430
   $1 = &temp; %}
 
431
 
354
432
%typemap(directorin, descriptor="Z") const bool &           "$input = (jboolean)$1_name;"
355
433
%typemap(directorin, descriptor="C") const char &           "$input = (jchar)$1_name;"
356
434
%typemap(directorin, descriptor="B") const signed char &    "$input = (jbyte)$1_name;"
442
520
  JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
443
521
}
444
522
 
 
523
%typemap(directorout,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const unsigned long long & { 
 
524
  static $*1_ltype temp;
 
525
  jclass clazz;
 
526
  jmethodID mid;
 
527
  jbyteArray ba;
 
528
  jbyte* bae;
 
529
  jsize sz;
 
530
  int i;
 
531
 
 
532
  if (!$input) {
 
533
    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
 
534
    return $null;
 
535
  }
 
536
  clazz = JCALL1(GetObjectClass, jenv, $input);
 
537
  mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
 
538
  ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
 
539
  bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
 
540
  sz = JCALL1(GetArrayLength, jenv, ba);
 
541
  $1 = &temp;
 
542
  temp = 0;
 
543
  if (bae[0] == 0) {
 
544
    for(i=sz-1; i>0; i-- ) {
 
545
      temp = (temp << 8) | (unsigned char)bae[sz-i];
 
546
    }
 
547
  } 
 
548
  else {
 
549
    for(i=sz; i>=0; i-- ) {
 
550
      temp = (temp << 8) | (unsigned char)bae[sz-1-i];
 
551
    }
 
552
  }
 
553
  JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
 
554
}
 
555
 
445
556
%typemap(out) const unsigned long long & { 
446
557
  jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
447
558
  jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
465
576
 
466
577
/* Default handling. Object passed by value. Convert to a pointer */
467
578
%typemap(in) SWIGTYPE ($&1_type argp)
468
 
%{ argp = *($&1_ltype*)&$input; 
 
579
%{ argp = *($&1_ltype*)(void *)&$input; 
469
580
   if (!argp) {
470
581
     SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
471
582
     return $null;
472
583
   }
473
584
   $1 = *argp; %}
474
585
 
 
586
%typemap(directorout) SWIGTYPE ($1_ltype argp)
 
587
%{ argp = *($&1_ltype)(void *)&$input; 
 
588
   if (!argp) {
 
589
     SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
 
590
     return $null;
 
591
   }
 
592
   $1 = argp; %}
 
593
 
475
594
%typemap(out) SWIGTYPE 
476
595
#ifdef __cplusplus
477
 
%{*($&1_ltype*)&$result = new $1_ltype(($1_ltype &)$1); %}
 
596
%{*($&1_ltype*)(void *)&$result = new $1_ltype(($1_ltype &)$1); %}
478
597
#else
479
598
{
480
599
  $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
481
600
  memmove($1ptr, &$1, sizeof($1_type));
482
 
  *($&1_ltype*)&$result = $1ptr;
 
601
  *($&1_ltype*)(void *)&$result = $1ptr;
483
602
}
484
603
#endif
485
604
 
486
 
%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE "*(($&1_type)&$input) = &$1;"
 
605
%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE 
 
606
%{ $input = 0;
 
607
   *(($&1_ltype*)(void *)&$input) = &$1; %}
487
608
%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)"
488
609
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
489
610
 
490
611
/* Generic pointers and references */
491
 
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
492
 
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
 
612
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)(void *)&$input; %}
 
613
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)(void *)&$input;
493
614
  if(!$1) {
494
615
    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
495
616
    return $null;
496
617
  } %}
497
618
%typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*)
498
 
%{ *($&1_ltype)&$result = $1; %} 
 
619
%{ *($&1_ltype)(void *)&$result = $1; %} 
499
620
%typemap(out) SWIGTYPE &
500
 
%{ *($&1_ltype)&$result = $1; %} 
 
621
%{ *($&1_ltype)(void *)&$result = $1; %} 
501
622
 
 
623
%typemap(directorout) SWIGTYPE *, SWIGTYPE (CLASS::*)
 
624
%{ $1 = *($&1_ltype)(void *)&$input; %}
502
625
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*)
503
 
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
 
626
%{ *(($&1_ltype)(void *)&$input) = ($1_ltype) $1; %}
504
627
 
505
628
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &
506
 
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
 
629
%{ *($&1_ltype)(void *)&$input = ($1_ltype) &$1; %}
507
630
 
508
631
%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, const SWIGTYPE & "new $javaclassname($jniinput, false)"
509
632
%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, const SWIGTYPE & "$javaclassname.getCPtr($javacall)"
510
633
 
511
634
/* Default array handling */
512
 
%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
513
 
%typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %} 
 
635
%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)(void *)&$input; %}
 
636
%typemap(out) SWIGTYPE [] %{ *($&1_ltype)(void *)&$result = $1; %} 
514
637
%typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] ""
515
638
 
516
639
/* char arrays - treat as String */
522
645
  }
523
646
}
524
647
 
 
648
%typemap(directorout) char[ANY], char[] { 
 
649
  $1 = 0;
 
650
  if ($input) {
 
651
    $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
 
652
    if (!$1) return $null;
 
653
  }
 
654
}
 
655
 
525
656
%typemap(directorin, descriptor="Ljava/lang/String;") char[ANY], char[] { 
526
657
  $input = 0;
527
658
  if ($1) {
558
689
             jobjectArray
559
690
%{ $1 = $input; %}
560
691
 
 
692
%typemap(directorout) jboolean,
 
693
             jchar,
 
694
             jbyte,
 
695
             jshort,
 
696
             jint,
 
697
             jlong,
 
698
             jfloat,
 
699
             jdouble,
 
700
             jstring,
 
701
             jobject,
 
702
             jbooleanArray,
 
703
             jcharArray,
 
704
             jbyteArray,
 
705
             jshortArray,
 
706
             jintArray,
 
707
             jlongArray,
 
708
             jfloatArray,
 
709
             jdoubleArray,
 
710
             jobjectArray
 
711
%{ $1 = $input; %}
 
712
 
561
713
%typemap(out) jboolean,
562
714
              jchar,
563
715
              jbyte,
891
1043
%typemap(javaimports)          SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
892
1044
%typemap(javainterfaces)       SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
893
1045
 
894
 
// Proxy classes (base classes, ie, not derived classes)
895
 
%typemap(javabody) SWIGTYPE %{
 
1046
/* javabody typemaps */
 
1047
 
 
1048
%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPENAME...)
 
1049
// Base proxy classes
 
1050
%typemap(javabody) TYPENAME %{
896
1051
  private long swigCPtr;
897
1052
  protected boolean swigCMemOwn;
898
1053
 
899
 
  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
 
1054
  PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
900
1055
    swigCMemOwn = cMemoryOwn;
901
1056
    swigCPtr = cPtr;
902
1057
  }
903
1058
 
904
 
  protected static long getCPtr($javaclassname obj) {
 
1059
  CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
905
1060
    return (obj == null) ? 0 : obj.swigCPtr;
906
1061
  }
907
1062
%}
908
1063
 
909
1064
// Derived proxy classes
910
 
%typemap(javabody_derived) SWIGTYPE %{
 
1065
%typemap(javabody_derived) TYPENAME %{
911
1066
  private long swigCPtr;
912
1067
 
913
 
  protected $javaclassname(long cPtr, boolean cMemoryOwn) {
 
1068
  PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
914
1069
    super($moduleJNI.SWIG$javaclassnameUpcast(cPtr), cMemoryOwn);
915
1070
    swigCPtr = cPtr;
916
1071
  }
917
1072
 
918
 
  protected static long getCPtr($javaclassname obj) {
 
1073
  CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
919
1074
    return (obj == null) ? 0 : obj.swigCPtr;
920
1075
  }
921
1076
%}
 
1077
%enddef
 
1078
 
 
1079
/* Set the default for SWIGTYPE: pointer constructor is protected,
 
1080
   getCPtr is protected. Season to your own taste! */
 
1081
 
 
1082
SWIG_JAVABODY_METHODS(protected, protected, SWIGTYPE)
922
1083
 
923
1084
// Typewrapper classes
924
1085
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
925
1086
  private long swigCPtr;
926
1087
 
927
 
  protected $javaclassname(long cPtr, boolean bFutureUse) {
 
1088
  protected $javaclassname(long cPtr, boolean futureUse) {
928
1089
    swigCPtr = cPtr;
929
1090
  }
930
1091
 
943
1104
  }
944
1105
%}
945
1106
 
 
1107
/*
 
1108
 * Java constructor typemaps:
 
1109
 *
 
1110
 * The javaconstruct typemap is inserted when a proxy class's constructor is generated.
 
1111
 * This typemap allows control over what code is executed in the constructor as
 
1112
 * well as specifying who owns the underlying C/C++ object. Normally, Java has
 
1113
 * ownership and the underlying C/C++ object is deallocated when the Java object
 
1114
 * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is
 
1115
 * ultimately responsible for deallocating the underlying object's memory.
 
1116
 *
 
1117
 * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy
 
1118
 * class for a particular TYPENAME. OWNERSHIP is passed as the value of
 
1119
 * swigCMemOwn to the pointer constructor method.  WEAKREF determines which kind
 
1120
 * of Java object reference will be used by the C++ director class (WeakGlobalRef
 
1121
 * vs. GlobalRef.)
 
1122
 *
 
1123
 * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy
 
1124
 * classes and the weak reference flag to false, meaning that the underlying C++
 
1125
 * object will be reclaimed by C++.
 
1126
 */
 
1127
 
 
1128
%define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...)
 
1129
%typemap(javaconstruct,directorconnect="\n    $moduleJNI.$javaclassname_director_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME {
 
1130
    this($imcall, OWNERSHIP);$directorconnect
 
1131
  }
 
1132
%enddef
 
1133
 
 
1134
%define SWIG_DIRECTOR_OWNED(TYPENAME...)
 
1135
SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME)
 
1136
%enddef
 
1137
 
 
1138
// Set the default for SWIGTYPE: Java owns the C/C++ object.
 
1139
SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
 
1140
 
946
1141
%typemap(javadestruct, methodname="delete") SWIGTYPE {
947
1142
    if(swigCPtr != 0 && swigCMemOwn) {
948
1143
      swigCMemOwn = false;
960
1155
    super.delete();
961
1156
  }
962
1157
 
963
 
%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE {
964
 
    swigCMemOwn = false;
965
 
    $jnicall;
966
 
  }
967
 
 
968
 
%typemap(directordisconnect_derived, methodname="swigDirectorDisconnect") SWIGTYPE {
969
 
    swigCMemOwn = false;
970
 
    $jnicall;
971
 
  }
 
1158
%typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{
 
1159
  protected void $methodname() {
 
1160
    swigCMemOwn = false;
 
1161
    $jnicall;
 
1162
  }
 
1163
%}
 
1164
 
 
1165
%typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{
 
1166
  public void $methodname() {
 
1167
    swigCMemOwn = false;
 
1168
    $jnicall;
 
1169
  }
 
1170
%}
 
1171
 
 
1172
%typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{
 
1173
  public void $methodname() {
 
1174
    swigCMemOwn = true;
 
1175
    $jnicall;
 
1176
  }
 
1177
%}
972
1178
 
973
1179
/* Java specific directives */
974
1180
#define %javaconst(flag)            %feature("java:const","flag")