Open jgvictores opened 6 years ago
I started the fix-6-java-bindings
branch and made some uncommitted progress, but this is beyond my SWIG skills. Python bindings are far easier to create since it's a dynamically typed language. A statically, strongly typed one as Java requires some knowledge about the JNI wrappers around the remote library, that is, YARP. In other words, I can't compile viewIRobotManager(yarp::dev::PolyDriver&)
because of the public dependency on yarp::dev::PolyDriver
.
This is how it looks like in asrob_yarp_devices.java
(generated by SWIG):
package asrob_yarp_devices;
public class asrob_yarp_devices {
public static IRobotManager viewIRobotManager(PolyDriver d) {
long cPtr = asrob_yarp_devicesJNI.viewIRobotManager(PolyDriver.getCPtr(d));
return (cPtr == 0) ? null : new IRobotManager(cPtr, false);
}
}
Even if I smuggle a import yarp.PolyDriver
somehow, there is no yarp.PolyDriver.getCPtr
method anywhere, which means that SWIG is not aware of the intrinsics of YARP's bindings and how to treat them.
A few links I gathered while messing with this:
A q&d solution I've done in the past was essentially creating a duplicate of yarp.i
(e.g. removing parts and changing module name), but including the new header. Not sure... perhaps the world has seen worse practices...
Java example app (currently broken) at 306e108.
Inspiration: https://github.com/roboticslab-uc3m/asibot-main/tree/d640e9962ef62765f7354612cfcb88ed5cb3ca25/bindings