I have no problem with simple callbacks when a free function is passed as a parameter to another, thanks @flexo .
But suppose the bit is a more complex C interface:
typedef struct { int id; const char* name; } Item; typedef struct { int value; Items_Callback callback; void *context; } Items_Call; typedef int (*Items_Callback)(const Item *item, void *context); int Items_create(const Item *item, Items_Call *call) { ... call->callback(item, call->context); ... }
I intend to generate some pretty Java wrapper for code like this. I believe that as a result
class Item { public int id; public String name; } class Items_Call { public int value; public Object context; public Interface callback; public void setInterface(Interface i){ callback=i; }; } public interface Interface { public int Items_Callback(Item item, Object context); } int Items_create(Item item, Items_Call call) { ... call.callback.Items_Callback(item, call.context); ... }
I understand that SWIG has problems generating pure Java interfaces, but I think this is not a big problem. The problem is that I have no idea how to reinterpret such a nested structure for acceptable Java code.
java c swig jni
triclosan
source share