I have no problem with simple callbacks when free function passed as parameter to another, thanks to @flexo.
But assume bit more difficult 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 intent to generate some nice Java wrapper for code like this. I assume to have as 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 realize that SWIG have some problem with generation of pure Java interfaces, but I believe it's not major problem. The problem is I have no idea how to reinterpret such nested structure to acceptable Java code.