From: William S F. <ws...@fu...> - 2007-03-28 22:06:24
|
Dave Yost wrote: > Hi. > > I need to provide a simple api through which existing C++ code can > pass some data to my Java program. The C++ code is heavily-templated > and complex and does not lend itself to being swigged, so my plan is > for the C++ code to feed the data to the Java program through this > hopefully-simple little api. > > Ideally, I would like swig to produce Java equivalent to this: > > class State { > // there can be 0 or more elements in these arrays > Node[] foo; > Node[] bar; > } > > class Node { > int a; > int[] b; // 0 or more elements in this array > String c; > } > > The arrays could be stl lists or vectors or whatever will be > swiggable into data structures I can read from Java. > > I am not fluent in C++. I have failed to figure this out from the > documentation and have come up with nothing in the examples. Could > someone please put me out of my misery and show how this would be > done? > I don't know of any mappings from stl list/vector to Java arrays, however there are mappings in std_vector.i from std::vector to a Java class that looks and feels like a java.util.Vector. There are mappings from C arrays to Java arrays, read up about arrays_java.i. William |