diff --git a/Lib/java/java.swg b/Lib/java/java.swg new file mode 100644 index 000000000..75f9bbe0a --- /dev/null +++ b/Lib/java/java.swg @@ -0,0 +1,9 @@ +#include +#include + +#ifdef __cplusplus +#define JCALL(func, jenv) jenv->func( +#else +#define JCALL(func, jenv) (*jenv)->func(jenv, +#endif + diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i new file mode 100644 index 000000000..2b2ab55fb --- /dev/null +++ b/Lib/java/typemaps.i @@ -0,0 +1,127 @@ +// +// SWIG Typemap library +// for Java + +%typemap(java,jtype) char *STRING {String} +%typemap(java,in) char *STRING { + $target = JCALL(GetStringUTFChars, jenv) $source, 0); +} + +%typemap(java,argout) char *STRING { + JCALL(ReleaseStringUTFChars, jenv) $source, $target); +} + +%typemap(java,out) char *STRING { + $target = (jarray) JCALL(NewStringUTF, jenv) $source); +} + +%typemap(java,jtype) char **STRING_IN {String[]} +%typemap(java,jni) char **STRING_IN {jobjectArray} +%typemap(java,in) char **STRING_IN { + int i; + jsize l = JCALL(GetArrayLength, jenv) $source); + $target = (char **) malloc((l+1) * sizeof(char *)); + for(i=0; i