The SWIG documentation explains how a variety of input types in C, like this:
void spam1(Foo *x); // Pass by pointer
void spam2(Foo &x); // Pass by reference
void spam3(Foo x); // Pass by value
void spam4(Foo x[]); // Array of objects
... would all take a single type of argument in Java, like this:
Foo f = new Foo(); // Create a Foo
example.spam1(f); // Ok. Pointer
example.spam2(f); // Ok. Reference
example.spam3(f); // Ok. Value.
example.spam4(f); // Ok. Array (1 element)
Similarly, for return types in C:
Foo *spam5();
Foo &spam6();
Foo spam7();
... all three functions will return a pointer to some Foo object that will be assigned to a Java object variable, the final one requiring an allocation of a value type that the Java garbage collection will take care of upon release.
But suppose spam5() returns a pointer to an array. In Java, I have to use array semantics to access the individual elements, but I don't think that I can just do this:
Foo foo[] = spam5();
I don't even think the compiler would accept a cast to (Foo[]), so how does this work in SWIG?