[webkit-help] [ webkit-help ] Calling JSCallBack function on Asynchronous event from C++

anil v anil.vemulapally at gmail.com
Wed Aug 26 05:47:30 PDT 2009


Hi All,

     I am trying to call JavaScript function from C/C++ on asynchronous
event. Is it possible with webkit ? Because  I have written sample code as
mentioned below but it is crashing after some time.
*
Sample code*

    JSStringRef functionName        =
JSStringCreateWithUTF8CString("callJSFun");
    WebkitWebFrame *frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW
(web_view));
    JSGlobalContextRef jsCtx = webkit_web_frame_get_global_context (frame);
    JSValueRef jsArgs[1];

    jsString = JSStringCreateWithUTF8CString((const char *)buf);
    jsArgs[0] = JSValueMakeString(jsCtx, jsString);
    JSStringRelease(jsString);

    JSValueRef functionValue        = JSObjectGetProperty(jsCtx,
JSContextGetGlobalObject(jsCtx), functionName, &exception);
    JSStringRelease(functionName);

    JSObjectRef jsFunctionObject = JSValueToObject(jsCtx, functionValue,
&exception);

    JSObjectCallAsFunction(jsCtx,jsFunctionObject, NULL, 1, jsArgs,
&exception);


Please any one help me to call JS Callback functions from C/C++.



Thanks,
Anil.V
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20090826/df935282/attachment.html>


More information about the webkit-help mailing list