Reputation: 14067
I have an .obj parser, code is:
class Model {
public:
List *coords;
List *tcoords;
List *normals;
List *faces;
Model() {
coords=new List();
tcoords=new List();
normals=new List();
faces=new List();
}
~Model() {
delete(coords);
delete(tcoords);
delete(normals);
delete(faces);
}
};
this is a model file parser tool, which is parse a big file. The List is a linkedlist. (String array, char*)
How can I return this class to Java from C++? I know how can return a simple String Array with NewObjectArray, but what is the way to return a Class?
Thanks, Leslie
Upvotes: 0
Views: 453
Reputation: 883
In C++ code you can instantiate any Java object by calling env->NewObject() method and passing appropriate constructor signature to it. Constructors have special name <init>
.
Upvotes: 0
Reputation: 231
Typically, you create a peer class on the Java side that holds a pointer to the class in a long variable.
Jim S.
Upvotes: 1