2

I want to parse a byte array in native C and use the results packed in structs in Java. For wrapping the C code in Java I'm using SWIG and got everything setup in my build process.

My problem is that I can't figure out how structs with dynamic arrays can be wrapped successfully:

struct myData
{ 
    float floatValue;
    char boolValue;
    int *intList;
    int intListLength;
};

The wrapper generated with SWIG has a function getIntList that returns an object of type SWIGTYPE_p_int instead of int[]. Unfortunately I couldn't get my head around typemap, carrays.i, etc., nor could find any help on my specific issue. Is there a way to achieve that I can get int[]? If not, how can I use SWIGTYPE_p_int to access data in the array?

  • trying to search with other keywords I found the solution here: https://stackoverflow.com/questions/11952365/accessing-an-array-of-pointers-within-a-structure-from-java-with-swig – beta vulgaris Jul 16 '18 at 15:36

0 Answers0