From: William S F. <ws...@fu...> - 2006-11-07 22:40:46
|
wiesel wrote: > Hello, > > i need some help to convert c array to a java array. > > I just started swig and tried some examples like this: > > c-file: > ------------------------------------------------------------------------------------------- > > const int test[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; > > ------------------------------------------------------------------------------------------- > > i-file: > ------------------------------------------------------------------------------------------- > > %include "arrays_java.i"; > > ------------------------------------------------------------------------------------------- > > It works perfekt!! > > java-file: > ------------------------------------------------------------------------------------------- > > public static int[] getTest() { > return TestJNI.test_get(); > } > > ------------------------------------------------------------------------------------------- > > > But now i would like to try something more complex. But i have no idea how > the i-file has to look like. > > c-file > ------------------------------------------------------------------------------------------- > typedef enum > { > zero = 0, > one, // = 1, > two, // = 2, > > } MY_ENUM; > > typedef struct > { > MY_ENUM my_Enum; > char name[64]; > } MY_STRUCT; > > const MY_STRUCT my_array[3] = > { > zero, "zero name", > one, "one name", > two, "two name", > }; > > Try the JAVA_ARRAYSOFCLASSES macro in arrays_java.i. William |