[Webkit-unassigned] [Bug 136989] WebKit2 Gtk+ JavaScriptCore bindings doesn't work properly

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Sep 5 07:04:59 PDT 2015


anewtobi at gmail.com changed:

           What    |Removed                     |Added
                 CC|                            |anewtobi at gmail.com

--- Comment #2 from anewtobi at gmail.com ---

I had the same problem with the send-message-received singal of UserContentManager.

The problem is JavaScriptCore doesn't have a gobject based API and therefore the introspection doesn't know what to do with it.

There are some JavaScriptCore bindings for python, but all of them are unmaintained or less than ideal in some way or  the other.

Even with those bindings (or using cffi directly) I've found no way to get the actual JSValueRef address in memory and use it from python through the C API. (If someone knows how it would be possible to do this, please enlighten me. It seems you can't easily get around the "Couldn't find conversion for foreign structure 'JavaScriptCore.Value'" error)

For my use case (receiving a message) and I imagine a lot of other use cases what I want in the end is to get a string (in python or C) representing the value, not the JSValueRef itsself.

So I created a new function for WebKitJavaScriptResult named get_value_as_string, which simply converts the value represented by JSValueRef to a gchar* (user is responsible for freeing it) and returns it.

This also works for numbers by the way, they simply get converted to a string. Objects get converted to a string like "[object Object]", so this is at least letting you know that you need to convert the object to a string with something like JSON.stringify from within JavaScript. If anything can't be converted at all, NULL is returned.

I attached the patch. It should work both with 2.8.5 and with master.

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150905/4fe37325/attachment.html>

More information about the webkit-unassigned mailing list