/* ----------------------------------------------------------------------------- * various.i * * SWIG Typemap library for Java. * Various useful typemaps. * ----------------------------------------------------------------------------- */ /* * char **STRING_ARRAY typemaps. * These typemaps are for C String arrays which are NULL terminated. * char *values[] = { "one", "two", "three", NULL }; // note NULL * char ** is mapped to a Java String[]. * * Example usage wrapping: * %apply char **STRING_ARRAY { char **input }; * char ** foo(char **input); * * Java usage: * String numbers[] = { "one", "two", "three" }; * String[] ret = modulename.foo( numbers }; */ %typemap(jni) char **STRING_ARRAY "jobjectArray" %typemap(jtype) char **STRING_ARRAY "String[]" %typemap(jstype) char **STRING_ARRAY "String[]" %typemap(in) char **STRING_ARRAY (jint size) { int i = 0; if ($input) { size = JCALL1(GetArrayLength, jenv, $input); #ifdef __cplusplus $1 = new char*[size+1]; #else $1 = (char **)calloc(size+1, sizeof(char *)); #endif for (i = 0; i); * modulename.foo(b); */ %typemap(jni) unsigned char *NIOBUFFER "jobject" %typemap(jtype) unsigned char *NIOBUFFER "java.nio.ByteBuffer" %typemap(jstype) unsigned char *NIOBUFFER "java.nio.ByteBuffer" %typemap(javain, pre=" assert $javainput.isDirect() : \"Buffer must be allocated direct.\";") unsigned char *NIOBUFFER "$javainput" %typemap(javaout) unsigned char *NIOBUFFER { return $jnicall; } %typemap(in) unsigned char *NIOBUFFER { $1 = (unsigned char *) JCALL1(GetDirectBufferAddress, jenv, $input); if ($1 == NULL) { SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unable to get address of direct buffer. Buffer must be allocated direct."); } } %typemap(memberin) unsigned char *NIOBUFFER { if ($input) { $1 = $input; } else { $1 = 0; } } %typemap(freearg) unsigned char *NIOBUFFER "" //define end