[Public WebGL] Should the non-typed-array overloads of uniform*v and vertextAttrib*v be IDL arrays or IDL sequences?

Kenneth Russell [email protected]
Fri Apr 27 15:14:09 PDT 2012

On Thu, Apr 26, 2012 at 7:09 PM, Boris Zbarsky <[email protected]> wrote:
> On 4/26/12 8:26 PM, Kenneth Russell wrote:
>> Early drafts of the WebGL spec used sequences for these arguments.
>> When arrays were added to Web IDL, they were changed to arrays, to
>> potentially support more efficient calls from JavaScript to C++.
> To realize this potential one would need to have platform array objects for
> those types, right?
>> If they were changed to sequence<T>, then could a browser still pass
>> them throughout its DOM bindings by reference
> It depends.  If a JavaScript Array object is passed in, then it technically
> gets copied (per WebIDL) no matter whether the argument is float[] or
> sequence<float>.  Quoting from
> http://dev.w3.org/2006/webapi/WebIDL/#es-array :
>  *  If V is a platform array object whose element type is T, then
>     return the array that the platform array object represents.
>  *  Let values be the result of converting V to a sequence with
>     element type T.
> So the only way for these overloads to do anything effective is if some
> _other_ specification defines a way to create platform array objects, right?
> If such a beastie is ever created, I think browser DOM bindings could in
> fact special-case this situation to pass it by reference, but it would take
> some sort of GLContext-specific code.
> On the other hand, right now implementing the binding as specced technically
> requires a browser to implement these platform array object things, which no
> browser actually has yet.  So they could just as easily special-case the
> fact that while it says "array" in the IDL in practice they should do the
> sequence conversion here.....

Thanks for the explanation. From a practical standpoint I think that
the change from array to sequence won't have any effect on WebKit's
DOM bindings, at least. It sounds like the only requirement is that
the incoming ECMAScript array isn't mutated, and it can't be in the
current bindings. I'm sure there's probably some rule about getters
being called in a certain order but fortunately there aren't
conformance tests for this.

I've updated the spec changing these array references to sequences.


You are currently subscribed to [email protected]
To unsubscribe, send an email to [email protected] with
the following command in the body of your email:
unsubscribe public_webgl

More information about the public_webgl mailing list