Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You also need to tell WebKit/JavaScriptCore at runtime about your bindings (this is in addition to linking with filename_wrap.o).</p> <p>Specifically you need to bind them to the global JavaScript object (in order to invoke per your .js examples). A callback on the WebKit window can be used to get a timely reference to the global JavaScript context, and then you can register your functions onto it.</p> <p>Adapting this <a href="https://github.com/vrruiz/WebKit-JavaScriptCore-Extensions/blob/master/webkit-02.c#L87" rel="nofollow">example</a> of hooking into the <code>window-object-cleared</code> signal the code could look similar to this:</p> <pre><code>/* the window callback - fired when the JavaScript window object has been cleared */ static void window_object_cleared_cb(WebKitWebView *web_view, WebKitWebFrame *frame, gpointer context, gpointer window_object, gpointer user_data) { /* Add your classes to JavaScriptCore */ example_init(context); // example_init generated by SWIG } /* ... and in your main application set up */ void yourmainfunc() { .... g_signal_connect (G_OBJECT (web_view), "window-object-cleared", G_CALLBACK(window_object_cleared_cb), web_view); webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "file://filename.html"); ... } </code></pre> <p>Depending on which branch of SWIG you are using you may need to generate the <code>example_init</code> function yourself (check filename.cxx); for reference here is what an initializer function to <a href="https://github.com/oliver----/swig-v8/blob/devel/Doc/Manual/Javascript.md#wrapper-functions" rel="nofollow">register wrapped C functions</a> would look like in SWIG:</p> <pre><code>int example_init(JSContextRef context) { JSObjectRef global = JSContextGetGlobalObject(context); ... jsc_registerFunction(context, global, "gcd", _wrap_gcd); ... } </code></pre> <p><em>NOTE -- SWIG does not yet officially support JavaScript; the above refers to using the work-in-progress (non-production) SWIG branches.</em></p> <p>References:</p> <ul> <li>SWIG-V8 <a href="https://github.com/oliver----/swig-v8" rel="nofollow">source</a> and its <a href="https://github.com/oliver----/swig-v8/blob/devel/Doc/Manual/Javascript.md#wrapper-functions" rel="nofollow">Javascript documentation</a> </li> <li>swig-jsc <a href="https://github.com/ashishs99/swig-jsc" rel="nofollow">source</a> and its <a href="https://github.com/ashishs99/swig-jsc/blob/a15943ac/Examples/javascript/simple/runme.cxx#L95" rel="nofollow">example</a> of registering bindings</li> <li>SWIG JavaScriptCore GSoC project <a href="https://github.com/Neha03/gsoc2012-javascript" rel="nofollow">source</a> (Google Summer of Code 2012) </li> <li>Webkit: Extending JavaScript article-- <a href="http://rvr.typepad.com/wind/2011/10/webkit-extending-javascript-1.html" rel="nofollow">tutorial</a> / <a href="https://github.com/vrruiz/WebKit-JavaScriptCore-Extensions" rel="nofollow">example code</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload