Carlos Garcia Campos
cgarcia at igalia.com
Sun Oct 16 23:31:42 PDT 2016
El lun, 10-10-2016 a las 01:19 +0000, tevaum at gmail.com escribió:
> Hello, everyone.
> Some background first: my name is Estêvão and every now and the I try
> to contribute to Gnome Web, AKA Epiphany. First time was back in
> 2010. After the migration of Epiphany to WebKit, it stopped
> bindings were only in TODO by then. Now what I need to do is a little
> untouched. So I started thinking about how could a GObject binding to
> JSC be implemented.
> The proposal:
> I'm thinking about creating GObjects to warap JSC objects. For
> instance: GJSCContext wrapping JSContextRef, GJSCObject wrapping
> JSObjectRef and so on.
We talked during the web engines hackfest about adding a GLib wrapper
for JSC, not necessarily a 1 to 1 wrapper from JSC object to GLib
> I implemented a POC of the API and a simple client to make my
> intentions clearer. It's available on https://github.com/tevaum/jsc-
Thanks for working on this!
> With that *not-so-gobject* partial API the client is able to bridge
> code. An example of error handling is also shown.
I think error handling is a bit different in this case, we probably
need a special way to handle JS exceptions.
> I think that we have to start simple and add stuff incrementally,
> based on what's already being used/requested by people. Please take
> your time to dig into the example code provided, ask questions and
> poit directions, so that we can buld a better WebKitGTK+.
I agree with the idea of starting simple and going step by step, but
before designing a new API there are a set of general things we should
decide, and the most important thing, we should know what we want this
new API to be used for. I think the API should allow:
That would cover the main uses cases, replacing the dom bindings and
Regarding the general things we should decide:
* Naming: we don't need a name for the library because it will be part
at all), but we need to use apublic header and a common prefix for
name, jscore prefix for methods and GJSC for types. The API should be
consistent in this regard.
* Memory management: this is very important to decide how to declare
your objects, they could be GObject, boxed types with ref counting,
important to have mechanisms, to prevent wrapped object from being
destroyed by the garbage collector if we still have a wrapper alive.
So, we will probably have to protect all js object when wrapped, which
means API use will always have to manually unref every single wrapper.
We might want to make it easier by making out wrappers initially
unowned, for example. There might be cases in which we want to wrapper
to be automatically destroyed when the wrapped object is garbage
collected too. We need to take into account all these cases when
designing the API.
* Error handling: I'm not sure GError is enough to handle js
exceptions. They can happen at any time and have additional information
like line number, column, etc. that can't be represented by GError. The
Objc API allows to set a callback per context to handle the exceptions.
I would start the API with the wrappers needed to setup a js context
and then the JSValueRef wrapper with methods to set an retrieve simple
values (string, bool, number, array, object/dictionary, date), leaving
the handling of custom objects out for now. We could probably use a bug
report or a dedicated thread in this list to decide about this specific
part of the API (whether we want to expose it as a single Value type or
have a different type per value type, whether to use GObjects or boxed
types, whether to make it initially unowned, etc.)
I think we can start adding the API to the source code without enabling
it in production builds, nor installing the headers until it reaches a
mature enough state. As with the GTK+ public APIs, the whole API should
be covered by unit tests and all patches adding/modifying the public
API should include a unit test.
> Estêvão Samuel Procópio Amaral
> webkit-gtk mailing list
> webkit-gtk at lists.webkit.org
Carlos Garcia Campos
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 191 bytes
Desc: This is a digitally signed message part
More information about the webkit-gtk