[Webkit-unassigned] [Bug 120112] Typed Arrays have no public facing API

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Oct 30 09:13:26 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=120112

--- Comment #36 from Geoffrey Garen <ggaren at apple.com> ---
(In reply to comment #35)
> > We say "Create" or "Copy" when we make something that needs a release. Here
> > I would use "Copy" I guess.
> 
> Right, but "JSObjectCopyTypedArrayData" would be misleading, in that it
> implies you get a copy of the data and modifying the data wouldn't do
> anything on the Typed Array from where it was copied.

Since the type name is "TypedArrayDataPtr", you would say "JSObjectCopyTypedArrayDataPtr". So, the function would claim to copy the pointer, not the underlying data. Since the pointer is a reference-counted object, it's reasonable to copy it.

> Maybe it should be
> named JSDataWrapper instead: i.e. JSObjectCopyTypedArrayDataWrapper()!? I'm
> not really fan of the verbosity, though.

I wouldn't use "Wrapper" because the other API names don't use it, and it's less specific than "data pointer".

> a) JSObjectGetTypedArrayData() returns a JSDataRef unretained. If you want
> to hold on to it, you have to retain it yourself. I'm not sure if this is
> feasible - the JSDataRef would have to last as least until the scope of the
> function that called JSObjectGetTypedArrayData exits.

It's impossible to return a reference counted object unretained. By definition, that's a pointer to freed memory (or leaked memory, depending on how you design things).

> b) We name the function in a way that doesn't follow the create/copy
> nomenclature, but clearly states that you own the JSDataRef. I'd propose
> JSObjectGetRetainedTypedArrayData() or JSObjectGetTypedArrayDataRetain().

Maybe JSObjectRetainTypedArrayDataPtr(). (Retain functions return their targets.)

I think the copy name is better because it is more idiomatic.

> If it's possible in a sane matter, I think a) is preferable. Can anybody
> confirm if this would be feasible? Does JSC implement something like objc's
> autorelease?

No autorelease. Only GC and reference counting.

You could make the data pointer a GC object. I don't think that changes things much, though.

-- 
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/20151030/bbaf4090/attachment-0001.html>


More information about the webkit-unassigned mailing list