<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Typed Arrays have no public facing API"
href="https://bugs.webkit.org/show_bug.cgi?id=120112#c36">Comment # 36</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Typed Arrays have no public facing API"
href="https://bugs.webkit.org/show_bug.cgi?id=120112">bug 120112</a>
from <span class="vcard"><a class="email" href="mailto:ggaren@apple.com" title="Geoffrey Garen <ggaren@apple.com>"> <span class="fn">Geoffrey Garen</span></a>
</span></b>
<pre>(In reply to <a href="show_bug.cgi?id=120112#c35">comment #35</a>)
<span class="quote">> > 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.</span >
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.
<span class="quote">> Maybe it should be
> named JSDataWrapper instead: i.e. JSObjectCopyTypedArrayDataWrapper()!? I'm
> not really fan of the verbosity, though.</span >
I wouldn't use "Wrapper" because the other API names don't use it, and it's less specific than "data pointer".
<span class="quote">> 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.</span >
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).
<span class="quote">> 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().</span >
Maybe JSObjectRetainTypedArrayDataPtr(). (Retain functions return their targets.)
I think the copy name is better because it is more idiomatic.
<span class="quote">> 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?</span >
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>