title: Return an array of java objects using SWIG
body: <p>I am writing a JNI wrapper for a C++ library using SWIG.
  One of the methods in a library returns an array of structs in an allocated memory:</p>
  
  <pre><code>typedef struct {
      int id;
      double x;
      double y;
  } DataStruct;
  
  int get_all_data ( long ref, DataStruct **ppdata, size_t *psize ) {
      // ... prepare the data by the ref
      *ppdata = (DataStruct*) malloc(sizeof(DataStruct) * size);
      *psize = size;
      return 0;
  }
  </code></pre>
  
  <p>Method signature in java should look something like this:</p>
  
  <pre><code> native DataStruct[] get_all_data(long ref);
  </code></pre>
  
  <p>Thus I am expecting SWIG to generate java DataStruct in java and wrapper that would call the library method, then create an jarray of DataStruct in JVM and fill it with DataStruct objects initialized from DataStruct structs returned by the library and finally free the allocated memory pointed by ppdata.</p>
  
  <p>I've been trying to wrap my head around SWIG typemaps for some time and the only solution I see for now is to use %native directive and create JNI implementaion fully manually. Can I get at least some help from SWIG in this case?</p>