[Bug 15986] Specify exactly how and when ECMAScript arguments are evaluated

https://www.w3.org/Bugs/Public/show_bug.cgi?id=15986

Cameron McCormack <cam@mcc.id.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #25 from Cameron McCormack <cam@mcc.id.au> 2012-03-19 08:19:06 UTC ---
I have gone ahead with that solution.

http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.480;r2=1.481;f=h

The effect is that operation invocation is handled as follows:

  * Get the effective overload set.
  * Remove items whose length does not match exactly the number of JS
arguments.
  * Convert arguments from JS to IDL values from left to right; when the
      argument being converted is the _distinguishing index_, the JS value
      is first inspected to select which overload we'll be invoking.
      (Any arguments to the left of the distinguishing index are required to
       have the same type in all overloads of this length.)
  * Add any argument default values from the IDL.

So for example if you had

  /* f1 */ void f();
  /* f2 */ void f(long a, float b, Node c, optional Node? d);
  /* f3 */ void f(long a, float b, DOMString c, optional Window? d);

and you call it as

  f(1, 2, document, window)

then the effective overload set is:

{ <f1, ()>,
  <f2, (long, float, Node)>,
  <f2, (long, float, Node, Node?)>,
  <f3, (long, float, DOMString)>,
  <f3, (long, float, DOMString, Window?)> }

You'd select the entries of length 4 (since that's how many JS values you are
passed):

{ <f2, (long, float, Node, Node?)>,
  <f3, (long, float, DOMString, Window?)> }

Then we go from left to right:

  * Convert JS Number 1 to a long.
  * Convert JS Number 2 to a float.

We're up to the distinguishing index, so we inspect the JS value document.  It
is a platform object, and there is an argument at index 2 with an interface
type that matches (step 14.4 of the algorithm) so we select that entry:

  <f2, (long, float, Node, Node?)>

Now we continue with argument conversion:

  * Convert JS Object reference document to Node.
  * Convert JS Object reference window to Node? -- this throws TypeError.

So in the end an exception is thrown and we fail.

Let me know if this is acceptable, thanks.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Monday, 19 March 2012 08:19:20 UTC