I'm trying to convert a member of structure of type signed char * to byte array in Java. I've the following structure:
typedef struct {
signed char * content;
int contentLength;
} Foo;
I've tried this:
%typemap(jni) signed char *content [ANY] "jbyteArray"
%typemap(jtype) signed char *content [ANY] "byte[]"
%typemap(jstype) signed char *content [ANY] "byte[]"
%typemap(javaout) signed char *content [ANY] {
return $jnicall;
}
%typemap(memberin) int contentLength [ANY] {
int length=0;
$1 = &length;
}
%typemap(out) signed char * content [ANY] {
$result = JCALL1(NewByteArray, jenv, length);
JCALL4(SetByteArrayRegion, jenv, $result, 0, length, $1);
}
But there isn't a result. The method getContent of the Foo have the following signature:
SWIGTYPE_p_signed_char getContent();
I want this method to returns byte[]. Is there a solution?