Home | History | Annotate | Download | only in java
      1 /* -----------------------------------------------------------------------------
      2  * enumtypeunsafe.swg
      3  *
      4  * Include this file in order for C/C++ enums to be wrapped by integers values.
      5  * Each enum has an equivalent class named after the enum and the enum items are
      6  * wrapped by constant integers within this class. The enum items are not
      7  * typesafe as they are all integers.
      8  * ----------------------------------------------------------------------------- */
      9 
     10 // const enum SWIGTYPE & typemaps
     11 %typemap(jni) const enum SWIGTYPE & "jint"
     12 %typemap(jtype) const enum SWIGTYPE & "int"
     13 %typemap(jstype) const enum SWIGTYPE & "int"
     14 
     15 %typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
     16 %{ temp = ($*1_ltype)$input;
     17    $1 = &temp; %}
     18 %typemap(out) const enum SWIGTYPE &  %{ $result = (jint)*$1; %}
     19 
     20 %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
     21 %{ static $*1_ltype temp = ($*1_ltype)$input;
     22    $result = &temp; %}
     23 %typemap(directorin, descriptor="I") const enum SWIGTYPE & "$input = (jint)$1;"
     24 %typemap(javadirectorin) const enum SWIGTYPE & "$jniinput"
     25 %typemap(javadirectorout) const enum SWIGTYPE & "$javacall"
     26 
     27 %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & ""
     28 
     29 %typemap(throws) const enum SWIGTYPE &
     30 %{ (void)$1;
     31    SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %}
     32 
     33 %typemap(javain) const enum SWIGTYPE & "$javainput"
     34 %typemap(javaout) const enum SWIGTYPE & {
     35     return $jnicall;
     36   }
     37 
     38 
     39 // enum SWIGTYPE typemaps
     40 %typemap(jni) enum SWIGTYPE "jint"
     41 %typemap(jtype) enum SWIGTYPE "int"
     42 %typemap(jstype) enum SWIGTYPE "int"
     43 
     44 %typemap(in) enum SWIGTYPE  %{ $1 = ($1_ltype)$input; %}
     45 %typemap(out) enum SWIGTYPE  %{ $result = (jint)$1; %}
     46 
     47 %typemap(directorout) enum SWIGTYPE  %{ $result = ($1_ltype)$input; %}
     48 %typemap(directorin, descriptor="I") enum SWIGTYPE "$input = (jint) $1;"
     49 %typemap(javadirectorin) enum SWIGTYPE "$jniinput"
     50 %typemap(javadirectorout) enum SWIGTYPE "$javacall"
     51 
     52 %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE ""
     53 
     54 %typemap(throws) enum SWIGTYPE
     55 %{ (void)$1;
     56    SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %}
     57 
     58 %typemap(javain) enum SWIGTYPE "$javainput"
     59 %typemap(javaout) enum SWIGTYPE {
     60     return $jnicall;
     61   }
     62 
     63 // '$static' will be replaced with either 'static' or nothing depending on whether the enum is an inner Java class or not
     64 %typemap(javaclassmodifiers) enum SWIGTYPE "public final $static class"
     65 %typemap(javabase)           enum SWIGTYPE ""
     66 %typemap(javacode)           enum SWIGTYPE ""
     67 %typemap(javaimports)        enum SWIGTYPE ""
     68 %typemap(javainterfaces)     enum SWIGTYPE ""
     69 %typemap(javabody)           enum SWIGTYPE ""
     70 
     71 %javaenum(typeunsafe);
     72 
     73