I was wondering if anyone has any experience dealing with swig, c++ -> java. Basically I have a class which I am extending in java. It is used as an interface basically. My problem is that the virtual function parameters create a new java object everytime the function is called which sends the garbage collector through the roof. Here is an example:
class b2ContactListener
{
public:
virtual ~b2ContactListener() {}
/// Called when two fixtures begin to touch.
virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); }
/// Called when two fixtures cease to touch.
virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); }
};
If you look at b2Contact parameter in BeginContact(), in Java this generates a new Contact object everytime the virtual method is called. Is there any way to get swig to make it so this doesn't happen?
This is my swig file.
%module(directors="1") b2WorldCallbacks;
%include "enums.swg"
%javaconst(1);
%feature("director") b2QueryCallback;
%feature("director") b2ContactListener;
%include "../../../Box2D/Box2D/Dynamics/b2WorldCallbacks.h"