So I have code that looks like this:
bool doSomething( unsigned int x, const myStruct1 typeOne[2], myStruct2 typeTwo[2] );
using swig I get java code:
public static boolean doSomething(long x, myStruct1 typeOne, myStruct2 type2){}
what I want is:
public static boolean doSomething(long x, myStruct1[] typeOne, myStruct2[] type2){}
I get that the problem is that SWIG can't know that my array in Java is only going to be 2 elements, as java declarations are sizeless.
I've tried using carrays.i in the swig interface. I used the arrays_fuctions instruction but it didn't change the method signature.
My next idea is going to code an inline function, in the SWIG file, that takes two parameters for each struct and then acts as a proxy down to the real function.
Any better ideas?
bool doSomething( unsigned int x, const myStruct1 typeOne[2], myStruct2 typeTwo[2])is the same asbool doSomething( unsigned int x, const myStruct1* typeOne, myStruct2* typeTwo)In other words that[2]doesn't buy you anything, as C++ treats those as pointers tomyStruct1andmyStruct2.doSomething(unsigned int x, const myStruct1 (&typeOne)[2], myStruct2 (&typeTwo)[2]);Don't know if SWIG recognizes this though -- worth a shot.