Marshalling char[] and char[ANY] to Java byte[] is now a bit easier

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12742 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-06-17 06:41:53 +00:00
commit 8a6e006a7b
3 changed files with 27 additions and 5 deletions

View file

@ -23,6 +23,7 @@ public class java_lib_arrays_runme {
// Create arrays for all the array types that ArrayStruct can handle
String array_c = "X";
byte[] array_c_extra = {11, 22};
byte[] array_sc = {10, 20};
short[] array_uc = {101, 201};
short[] array_s = {1002, 2002};
@ -105,6 +106,12 @@ public class java_lib_arrays_runme {
as.setArray_struct(array_struct);
check_struct_array(array_struct, as.getArray_struct());
// Extended element (for char[])
ArrayStructExtra ase = new ArrayStructExtra();
ase.setArray_c2(array_c_extra);
check_byte_array(array_c_extra, ase.getArray_c2());
}
// Functions to check that the array values were set correctly

View file

@ -8,6 +8,7 @@
JAVA_ARRAYSOFCLASSES(SimpleStruct)
%apply ARRAYSOFENUMS[ANY] { finger[ANY] }
//%apply signed char[ANY] { char array_c2[ANY] }
%include "arrays.i"
@ -54,3 +55,15 @@ typedef enum { Big, Little } toe;
void toestest(toe *t, toe tt[], toe ttt[2]) {}
%}
JAVA_ARRAYS_IMPL(char, jbyte, Byte, Char)
JAVA_ARRAYS_TYPEMAPS(char, byte, jbyte, Char, "[B")
%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */
signed char[ANY], signed char[]
""
%inline %{
struct ArrayStructExtra {
char array_c2[ARRAY_LEN];
};
%}