mike at vee.net
Thu Jan 5 23:02:06 PST 2017
On Mon, Jan 2, 2017 at 8:13 PM, Carlos Garcia Campos
<cgarcia at igalia.com> wrote:
> El lun, 02-01-2017 a las 11:47 +1100, Michael Gratton escribió:
> Yes, we plan to have GObject bindings of JSC that would make your life
> easier. There's a wip patch in  that is waiting review (I've been
> quite busy, but it's still in my TODO). Memory management is indeed
> main challenge, because it requires to have a good knowledge of JSC
> internals and how the garbage collector works. It's also important to
> understand how apps will use the API to try to make the lib as
> convenient as possible, so your feedback would be really useful.
Thanks for pointing that bug out, I just added some comments to it
then, but in short it's about 95% there to covering Geary's current use
>> I've been trying to work out when to use functions like
>> JSGlobalContextRelease, JSStringRelease, and JSValueUnprotect, but
>> haven't been able to find any useful documentation about it. Also,
>> examples on the web seem to conflict: E.g. The WebKitGTK docs and
>> Cookbook uses JSStringRelease on a string copied from a
>> whereas others (e.g. ) suggest that JSStringRelease only needs to
>> used in certain instances, or that it needs to be used all the time.
>> Any pointers to canonical docs and examples would be appreciated.
> JSObjectRef, but not JSGlobalContext or JSString. You should always
> release those. JSValueUnprotectc is not comparable with
> JSGlobalContextRelease or JSStringRelease, Release methods do actually
> release/free/unrefs the objects, but Unprotect tells the garbage
> collector that it's ok to release that object. It only makes sense if
> the value has been protected before, note that values are not
> by default.
That makes sense.
>> I assume I never need to release a JSGlobalContextRef obtained from
>> retain it, but what about the others? Would it hurt to call
>> JSGlobalContextRelease and JSStringRelease even if not needed? What
>> about JSValueRefs?
> Yes, the global context returned by
> transfer-none. You shouldn't Unprotect values returned by
> course. But you should release strings returned by JSValueRef.
>> Also, my assumption that JSC objects should be treated as Vala
>> types, i.e. they should be passed as copies (not by reference),
>> correct isn't it?
> I'm not sure, because I don't know anything about vala, but JSValueRef
> is a pointer.
> Most of the questions are not specific to WebKitGTK+, but to
> dev mailing list, since JSC developers can answer the questions much
> better than me :-)
Fair enough. This approach seems to be working reasonably well for now,
but I'll ping webkit-
dev if I have any more in-depth queries about JSC.
Thanks for the assistance!
PS: I was wondering if the WebKitGTK+ team is aware of Bug 88595 -
basically a request for exposing the UndoManager, which would be very
useful to be able to query the state of the stack and add custom
transactions to it. I ask since the bug doesn't seem to reference GTK
except in the summary, or CC any GTK people.
 - <https://bugs.webkit.org/show_bug.cgi?id=88595>
⊨ Michael Gratton, Percept Wrangler.
More information about the webkit-gtk