Make (char*, size_t) typemap usable for strings of other types in Java.

Notably it now works for "unsigned char*" strings.

Add a test to check that it now works in Java and also showing that it already
worked for the other languages with support for this typemap.
This commit is contained in:
Vadim Zeitlin 2015-08-06 00:10:51 +02:00
commit a1bddd56eb
7 changed files with 37 additions and 3 deletions

View file

@ -1330,8 +1330,8 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
%typemap(freearg) (char *STRING, size_t LENGTH) ""
%typemap(in) (char *STRING, size_t LENGTH) {
if ($input) {
$1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
$2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
$1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0);
$2 = ($2_type) JCALL1(GetArrayLength, jenv, $input);
} else {
$1 = 0;
$2 = 0;