JNIWrapper Help
Hopefully someone can help me with this problem.
I am trying to write a wrapper class for a C library, using the
JNIWrapper library.
I understand how to use the Pointer class, but what I'm not sure about
is how to wrap funciton pointers.
Specifically, in the C library there are several structures defined as
follows
struct vtable {
getValue_proto getValue; /* A function to get the current value
*/
...
... /* Similar functions */
...
};
struct quantity {
Quantity_getVTable getVTable /* a function to get the vtable */
...
... /* Misc. items related to the quantity */
};
Then there are several type definitions:
typedef vtable * (*Quantity_getVTable)();
typedef double (*getValue_proto) (quantity *quant, ...);
I've set up four seperate classes using JNIWrapper. Two to extend the
Structure class, and two extending Callback (which is what I assume
one is supposed to do with function pointers, though I'm not really
sure.)
Thus:
public class vtable extends Structure
{
public Pointer getValue = new Pointer(new getValue_proto());
...
}
public class quantity extends Structure
{
public Pointer getVTable = new Pointer(new Quantity_getVTable());
...
}
public class Quantity_getVTable extends Callback
{
public Pointer retVal = new Pointer(new vtable());
...
}
public class getValue_proto extends Callback
{
public Pointer quant = new Pointer(new quantity());
...
}
Doing things this way introduces a stack overflow as the classes are
now circularly dependent. So, my question is, how are virtual
functions supposed to be implemented within JNIWrapper in order to
solve this problem?
If this is the wrong forum to post, please let me know where I should
redirect this to.
Thanks,
Paul