Home | History | Annotate | Download | only in common
      1 %define ENABLE_NIO_BUFFER_TYPEMAP(CTYPE, BUFFERTYPE)
      2 %typemap(jni) CTYPE* "jobject"
      3 %typemap(jtype) CTYPE* "BUFFERTYPE"
      4 %typemap(jstype) CTYPE* "BUFFERTYPE"
      5 %typemap(javain,
      6 	pre="    assert $javainput.isDirect() : \"Buffer must be allocated direct.\";") CTYPE* "$javainput"
      7 %typemap(javaout) CTYPE* {
      8     return $jnicall;
      9 }
     10 %typemap(in) CTYPE* {
     11   $1 = (CTYPE*)jenv->GetDirectBufferAddress($input);
     12   if ($1 == NULL) {
     13     SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unable to get address of direct buffer. Buffer must be allocated direct.");
     14   }
     15 }
     16 %typemap(memberin) CTYPE* {
     17   if ($input) {
     18     $1 = $input;
     19   } else {
     20     $1 = 0;
     21   }
     22 }
     23 %typemap(freearg) CTYPE* ""
     24 %enddef
     25 
     26 %define DISABLE_NIO_BUFFER_TYPEMAP(CTYPE)
     27 %clear CTYPE*
     28 %enddef