Hi, All,
Actually, I am studying how to port native application(made by C and C++) into
B2G.
I added my test library in root directory such as "/b2g/libTEST". And I used
js-ctypes to load native library(libTEST.so).
Now library was ran properly by js-ctypes. My library should use some thread.
As my testing, thread and timer work well.
But I have a problem about js-ctypes callback.
I am defining my callback in gecko layer such as:
myCallback = function(arg) {
debug("myCallback : arg = " + arg);
}
......
SetMy_CB = library.declare("SetMyCallback",
ctypes.default_abi,
ctypes.void_t,
ctypes.voidptr_t);
My_CB = ctypes.FunctionType(
ctypes.default_abi,
ctypes.void_t,
[ctypes.voidptr_t]
).ptr;
SetMy_CB(My_CB(myCallback));
and I add some code in my library for callback such as :
**** in header file
typedef void MyCallback_forGecko(void* in_bitmap);
extern void SetMyCallback(MyCallback_forGecko* callback);
......
**** in source file
static MyCallback_forGecko* gMyCallback_forGecko;
void SetMyCallback(Callback_MyCallback_forGecko* callback)
{
gMyCallback_forGecko = callback;
}
......
gMyCallback_forGecko(arg) //call callback function
In this case, I got crash because thread is not main thread, when gMyCallback
called.
My library should be use two gThreads to run.
Of course, I know that thread is same to use js-ctypes callback. But I don't
know how to use same thread in gecko and my library.
Would please let me know how to implement js-ctypes callback?
Any help would be greatly appreciated.
Thanks,
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g