[Webkit-unassigned] [Bug 120112] Typed Arrays have no public facing API
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Oct 30 10:28:31 PDT 2015
https://bugs.webkit.org/show_bug.cgi?id=120112
--- Comment #37 from Dominic Szablewski <dominic.szablewski at gmail.com> ---
(In reply to comment #36)
> (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.
In my proposal, I named the type "JSDataRef", not "TypedArrayDataPtr". Naming it "TypedArrayDataPtr" would be confusing when the returned type is not a pointer to raw data, but a ref to a "wrapper" and we would end up with function names like "TypedArrayDataPtrGetBytesPtr".
> I think the copy name is better because it is more idiomatic.
Honestly, I think these function names all come short for one reason or another:
- "JSObjectCopyTypedArrayData" implies that data is copied.
- "JSObjectCopyTypedArrayDataRef" is not consistent with the rest of the JSC API. None of the other JSC API functions that work on refs actually have the "Ref" in the name.
- "JSObjectCopyTypedArrayDataPtr" implies you get a raw pointer to bytes.
- "JSObjectRetainTypedArrayData" is maybe the most sensible, but I'd really prefer to have a "get" in the name, because the primary function of this function is to *get* the data, not to retain it. It would also be confusing to have a separate "JSDataRetain".
Aaaaaanyway, current API proposal:
https://github.com/phoboslab/JavaScriptCore-iOS/blob/new-typed-array-api/JavaScriptCore/API/JSTypedArray.h
In short:
JSTypedArrayType JSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object);
JSObjectRef JSObjectMakeTypedArray(JSContextRef ctx, JSTypedArrayType arrayType, size_t numElements);
JSDataRef JSObjectGetRetainedTypedArrayData(JSContextRef ctx, JSObjectRef object);
JSDataRef JSDataRetain(JSDataRef data);
void JSDataRelease(JSDataRef data);
void * JSDataGetBytesPtr(JSDataRef data);
size_t JSDataGetLength(JSDataRef data);
This API behaves very much like the JSStringRef stuff. From my perspective the only unresolved issue is the "JSObjectGetRetainedTypedArrayData" function name.
Thoughts?
--
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/cfae7a79/attachment.html>
More information about the webkit-unassigned
mailing list