java - Callback function pointer jna -
so have native function in c declared int ngsetevent (int event, long callback)
. long callback represent callback function pointer. callback prototype declared int oncodeline(int code, int documentid, char *string)
. callback should registered method ngsetevent
. problem how pointer function should long or nativelong? have tried lot of different aproaches none of them gave result. callback never invoked.
i have tried says in turn callback pointer in jna, no success. don't know try anymore. appreciated.
oncodeline
public interface oncodeline extends callback { int oncodeline (int code, int documentid, byte[] string); }
oncodelinestruct
public class oncodelinestruct extends structure { public oncodeline onc; @override protected list getfieldorder() { return arrays.aslist(new string[] { "onc" }); } }
main class
oncodelinestruct oncodelinstruct; oncodelinstruct = new oncodelinestruct(); oncodelinstruct.onc = new oncodeline() { @override public int oncodeline(int code, int documentid, byte[] string) { system.out.println("this callback!"); return 0; } }; sbdll.ngsetevent(0, oncodelinstruct.getpointer().getnativelong(0));
Comments
Post a Comment