[WebIDL] Callback functions and callback interfaces should allow optional arguments sanely

The grammar for callbacks allows optional arguments.  But the processing 
model in 
http://dev.w3.org/2006/webapi/WebIDL/#es-invoking-callback-functions 
(which references the one in 
http://dev.w3.org/2006/webapi/WebIDL/#es-user-objects ) doesn't really 
describe what to do with such arguments.  I would like to propose a 
processing model as follows:

1)  Start with a list of n IDL argument values idlarg_{0 ... n-1}.  This 
assumes that we have a way to represent a "not passed" optional value as 
an IDL type, which I believe we have agreed we need anyway.
2)  Set argcount to n.
3)  Set i to n-1.
4)  While i >= 0 and the idlarg_i is not passed and the
     corresponding argument of the IDL callback type is optional:
       a)  Set argcount to argcount - 1
       b)  Set i to i - 1
5)  Continue with the algorithm as currently defined, but using
     argcount, not n, as the number of arguments.

We will also need to define that converting a "not passed" value to an 
ECMAScript value produces undefined, I think.

Thoughts?

-Boris

P.S.  I'm implementing the above in Gecko anyway, because it's needed to 
implement window.onerror.  But I figured I'd at least sanity-check it.

Received on Thursday, 1 November 2012 15:32:10 UTC