diff --git a/index.html b/index.html index f777c68a..4bbfaead 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ -
W3C

Web IDL (Second Edition)

W3C Editor’s Draft 5 January 2016

This Version:
http://heycam.github.io/webidl/
Latest Version:
http://www.w3.org/TR/WebIDL/
Previous Versions:
http://www.w3.org/TR/2012/CR-WebIDL-20120419/
http://www.w3.org/TR/2012/WD-WebIDL-20120207/
http://www.w3.org/TR/2011/WD-WebIDL-20110927/
http://www.w3.org/TR/2011/WD-WebIDL-20110712/
http://www.w3.org/TR/2010/WD-WebIDL-20101021/
http://www.w3.org/TR/2008/WD-WebIDL-20081219/
http://www.w3.org/TR/2008/WD-WebIDL-20080829/
http://www.w3.org/TR/2008/WD-DOM-Bindings-20080410/
http://www.w3.org/TR/2007/WD-DOM-Bindings-20071017/
Participate:
+
@@ -72,7 +72,7 @@

Status of This Document

report can be found in the W3C technical reports index at http://www.w3.org/TR/.

- This document is the 5 January 2016 Editor’s Draft of the + This document is the 6 January 2016 Editor’s Draft of the Web IDL (Second Edition) specification. Please send comments about this document to @@ -124,7 +124,7 @@

Status of This Document

Table of Contents

-
+
@@ -2297,7 +2297,7 @@
3.2.4.3. Serializers
is exposed as a toJSON method which returns the serialized value converted into an ECMAScript value that can be serialized to JSON by the - JSON.stringify function. See section 4.5.8.2 + JSON.stringify function. See section 4.6.8.2 below for details.

@@ -2747,7 +2747,7 @@

3.2.4.4. Indexed properties

- As described in section 4.7, + As described in section 4.8, an ECMAScript implementation would create properties on a platform object implementing OrderedMap that correspond to @@ -4292,7 +4292,7 @@

3.4. Exceptions

Note

- See section 4.12 + See section 4.13 below for details on what creating and throwing an exception entails in the ECMAScript language binding.

@@ -6460,7 +6460,7 @@

4.1. ECMAScript environment

all interfaces that the implementation supports. If a given ECMAScript global environment does not expose an interface, then the requirements given in - section 4.5 are + section 4.6 are not followed for that interface.

Note
@@ -7343,7 +7343,7 @@

4.2.20. Interface types

  • If V is a platform object that implements I, then return the IDL interface type value that represents a reference to that platform object.
  • If V is a user object that is considered to implement I according to the rules in - section 4.8, + section 4.9, then return the IDL interface type value that represents a reference to that user object, with the incumbent script as the callback context. [HTML]
  • @@ -8499,10 +8499,10 @@

    4.3.2. [Constructor]

    MUST NOT be used on a callback interface.

    - See section 4.5.1.1 + See section 4.6.1.1 below for details on how a constructor for an interface is to be implemented, and - section 4.5.3 + section 4.6.3 for how a constructor for a dictionary is to be implemented.

    @@ -8764,12 +8764,12 @@

    4.3.4. [Exposed]

    See - section 4.5, - section 4.5.3, - section 4.5.6, - section 4.5.7, - section 4.5.8 and - section 4.5.9 + section 4.6, + section 4.6.3, + section 4.6.6, + section 4.6.7, + section 4.6.8 and + section 4.6.9 for the specific requirements that the use of [Exposed] entails.

    @@ -8838,7 +8838,7 @@

    4.3.5. [ImplicitThis]

    take no arguments.

    - See section 4.5.8 + See section 4.6.8 for the specific requirements that the use of [ImplicitThis] entails.

    @@ -9018,15 +9018,15 @@

    4.3.6. [Global] and [PrimaryGlobal]

    is declared on, if any, is known as the primary global interface.

    - See section 4.5.5, - section 4.7.3 and - section 4.7.7 + See section 4.6.5, + section 4.8.3 and + section 4.8.7 for the specific requirements that the use of [Global] and [PrimaryGlobal] entails for named properties, - and section 4.5.6, - section 4.5.7 and - section 4.5.8 + and section 4.6.6, + section 4.6.7 and + section 4.6.8 for the requirements relating to the location of properties corresponding to interface members.

    @@ -9114,7 +9114,7 @@

    4.3.7. [LegacyArrayClass]

    - See section 4.5.4 for the + See section 4.6.4 for the specific requirements that the use of [LegacyArrayClass] entails.

    @@ -9261,7 +9261,7 @@

    4.3.9. [NamedConstructor]

    MUST NOT be used on a callback interface.

    - See section 4.5.2 + See section 4.6.2 below for details on how named constructors are to be implemented.

    @@ -9460,8 +9460,8 @@

    4.3.12. [OverrideBuiltins]

    the named property getter.

    - See section 4.7.1 - and section 4.7.7 + See section 4.8.1 + and section 4.8.7 for the specific requirements that the use of [OverrideBuiltins] entails.

    @@ -9762,7 +9762,7 @@

    4.3.14. [Replaceable]

    a callback interface.

    - See section 4.5.7 + See section 4.6.7 for the specific requirements that the use of [Replaceable] entails.

    @@ -10110,11 +10110,11 @@

    4.3.18. [Unforgeable]

    };

    - See section 4.5.7, - section 4.5.8, - section 4.7, - section 4.7.1 and - section 4.7.7 + See section 4.6.7, + section 4.6.8, + section 4.8, + section 4.8.1 and + section 4.8.7 for the specific requirements that the use of [Unforgeable] entails.

    @@ -10182,7 +10182,7 @@

    4.3.19. [Unscopeable]

    or regular operation.

    - See section 4.5.4 + See section 4.6.4 for the specific requirements that the use of [Unscopeable] entails.

    @@ -10226,8 +10226,433 @@

    4.4. Security

    +
    +

    4.5. Overload resolution algorithm

    + +

    + In order to define how overloaded function invocations are resolved, the + overload resolution algorithm + is defined. Its input is an effective overload set, + S, and a list of ECMAScript values, arg0..n−1. + Its output is a pair consisting of the operation or + extended attribute of one of S’s entries + and a list of IDL values or the special value “missing”. The algorithm behaves as follows: +

    +
      +
    1. Let maxarg be the length of the longest type list of the entries in S.
    2. +
    3. Initialize argcount to be min(maxargn).
    4. + +
    5. Remove from S all entries whose type list is not of length argcount.
    6. + +
    7. If S is empty, then throw a TypeError.
    8. + +
    9. Initialize d to −1.
    10. + +
    11. + Initialize method to + undefined. +
    12. + +
    13. If there is more than one entry in S, then set + d to be the distinguishing argument index + for the entries of S.
    14. + +
    15. Initialize values to be an empty list, where each entry will be either an IDL value or the special value “missing”.
    16. + +
    17. Initialize i to 0.
    18. + +
    19. While i < d: +
        +
      1. Let V be argi.
      2. +
      3. Let type be the type at index i in the type list of any entry in S. +
        Note

        All entries in S at this point have the same type and optionality value at index i.

        +
      4. +
      5. Let optionality be the value at index i in the list of optionality values of any entry in S.
      6. +
      7. If optionality is “optional” and V is undefined, then: +
          +
        1. If the argument at index i is declared with a default value, + then append to values that default value.
        2. +
        3. Otherwise, append to values the special value “missing”.
        4. +
        +
      8. +
      9. Otherwise, append to values the result of converting + V to IDL type type.
      10. +
      11. Set i to i + 1.
      12. +
      +
    20. + +
    21. If i = d, then: +
        +
      1. Let V be argi. +
        Note

        This is the argument that will be used to resolve which overload is selected.

      2. + +
      3. If V is undefined, and there is an entry in S + whose list of optionality values has “optional” at index i, + then remove from S all other entries.
      4. + +
      5. Otherwise: if V is null or undefined, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      6. + +
      7. + Otherwise: if V is a platform object – but not a + platform array object – and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      8. + +
      9. + Otherwise: if V is a RegExp object and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      10. + +
      11. + Otherwise: if V is a RegExp object and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      12. + +
      13. + Otherwise: if V is a DOMException platform object and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      14. + +
      15. + Otherwise: if V is an Error object (that is, it has an [[ErrorData]] internal slot) and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      16. + +
      17. + Otherwise: if V is an object with an [[ArrayBufferData]] internal slot and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      18. + +
      19. + Otherwise: if V is an object with a [[DataView]] internal slot and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      20. + +
      21. + Otherwise: if V is an object with a [[TypedArrayName]] internal slot and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      22. + +
      23. + Otherwise: if IsCallable(V) is true, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      24. + +
      25. + Otherwise: if V is any kind of object except for + a native RegExp object, and + there is an entry in S that has one of the + following types at position i of its type list, + + and after performing the following steps, +
          +
        1. + Let method be the result of + GetMethod(V, @@iterator). +
        2. +
        3. + ReturnIfAbrupt(method). +
        4. +
        + method is not undefined, then remove from S all + other entries. +
      26. + +
      27. + Otherwise: if V is any kind of object except for + a native RegExp object, and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      28. + +
      29. + Otherwise: if V is a Boolean value, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      30. + +
      31. + Otherwise: if V is a Number value, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      32. + +
      33. + Otherwise: if there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      34. + +
      35. + Otherwise: if there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      36. + +
      37. + Otherwise: if there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      38. + +
      39. + Otherwise: if there is an entry in S that has any at position i + of its type list, + then remove from S all other entries. +
      40. + +
      41. + Otherwise: + throw a TypeError. +
      42. +
      +
    22. + +
    23. Let callable be the operation or extended attribute + of the single entry in S.
    24. + +
    25. + If i = d and method is not undefined, then +
        +
      1. + Let V be argi. +
      2. +
      3. + Let T be the type at index i in the + type list of the remaining entry in S. +
      4. +
      5. + If T is a sequence type, then + append to values the result of + creating a sequence + of type T from + V and method. +
      6. +
      7. + Otherwise, T is a frozen array type. + Append to values the result of + creating a frozen array + of type T from + V and method. +
      8. +
      9. + Set i to i + 1. +
      10. +
      +
    26. + +
    27. + While i < argcount: +
        +
      1. Let V be argi.
      2. +
      3. Let type be the type at index i in the type list of the remaining entry in S.
      4. +
      5. Let optionality be the value at index i in the list of optionality values of the remaining entry in S.
      6. +
      7. If optionality is “optional” and V is undefined, then: +
          +
        1. If the argument at index i is declared with a default value, + then append to values that default value.
        2. +
        3. Otherwise, append to values the special value “missing”.
        4. +
        +
      8. +
      9. Otherwise, append to values the result of + converting V to IDL type type.
      10. +
      11. Set i to i + 1.
      12. +
      +
    28. + +
    29. While i is less than the number of arguments callable is declared to take: +
        +
      1. If callable’s argument at index i is declared with a default value, + then append to values that default value.
      2. +
      3. Otherwise, if callable’s argument at index i is not variadic, then append to values the special value “missing”.
      4. +
      5. Set i to i + 1.
      6. +
      +
    30. + +
    31. Return the pair <callable, values>.
    32. +
    +
    Note
    +

    + The overload resolution algorithm performs both the identification + of which overloaded operation, constructor, etc. is being called, + and the conversion of the ECMAScript argument values to their + corresponding IDL values. Informally, it operates as follows. +

    +

    First, the selection of valid overloads is done by considering + the number of ECMAScript arguments that were passed in to the function:

    + +

    Once we have a set of possible overloads with the right number + of arguments, the ECMAScript values are converted from left to right. + The nature of the restrictions on overloading means that if we + have multiple possible overloads at this point, then there will + be one position in the argument list that will be used to + distinguish which overload we will finally select; this is + the distinguishing + argument index.

    +

    We first convert the arguments to the left of the distinguishing + argument. (There is a requirement that an argument to the left of + the distinguishing argument index has the same type as in the other + overloads, at the same index.) Then we inspect the type of the + ECMAScript value that is passed in at the distinguishing argument + index to determine which IDL type it may correspond to. + This allows us to select the final overload that will + be invoked. If the value passed in is undefined + and there is an overload with an optional argument at this position, then + we will choose that overload. If there is no valid overload for the type of + value passed in here, then we throw a TypeError. + The inspection of the value at the distinguishing argument index does not have any side effects; + the only side effects that come from running the overload resolution + algorithm are those that come from converting the ECMAScript values + to IDL values.

    +

    At this point, we have determined which overload to use. We now + convert the remaining arguments, from the distinguishing argument onwards, + again ignoring any additional arguments that were ignored due to being passed + after the last possible argument.

    +

    When converting an optional argument’s ECMAScript value to its equivalent IDL value, + undefined will be converted into + the optional argument’s default value, + if it has one, or a special value “missing” otherwise.

    +

    Optional arguments corresponding to a final, variadic argument do not treat + undefined as a special “missing” value, however. + The undefined value is converted to the type + of variadic argument as would be done for a non-optional argument.

    +
    +
    +
    -

    4.5. Interfaces

    +

    4.6. Interfaces

    For every interface that @@ -10249,7 +10674,7 @@

    4.5. Interfaces

    The property has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }. - The characteristics of an interface object are described in section 4.5.1 + The characteristics of an interface object are described in section 4.6.1 below.

    @@ -10263,12 +10688,12 @@

    4.5. Interfaces

    construction of objects that implement the interface. The property has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }. The characteristics of a named constructor are described in - section 4.5.2 + section 4.6.2 below.

    -

    4.5.1. Interface object

    +

    4.6.1. Interface object

    The interface object for a given non-callback interface @@ -10277,8 +10702,8 @@

    4.5.1. Interface object

    the constants and static operations defined on that interface, as described in sections - 4.5.6 and - 4.5.8 + 4.6.6 and + 4.6.8 below.

    @@ -10306,7 +10731,7 @@

    4.5.1. Interface object

    that correspond to the regular attributes and regular operations defined on the interface, and is described in more detail in - section 4.5.4 + section 4.6.4 below.

    Note
    @@ -10326,7 +10751,7 @@

    4.5.1. Interface object

    -
    4.5.1.1. Interface object [[Call]] method
    +
    4.6.1.1. Interface object [[Call]] method

    If the interface is declared with a @@ -10352,426 +10777,6 @@

    4.5.1.1. Interface object [[Call]] method
    the given interface if it returns normally (that is, if it does not throw an exception).

    --> -

    - In order to define how overloaded constructor invocations are resolved, the - overload resolution algorithm - is defined. Its input is an effective overload set, - S, and a list of ECMAScript values, arg0..n−1. - Its output is a pair consisting of the operation or - extended attribute of one of S’s entries - and a list of IDL values or the special value “missing”. The algorithm behaves as follows: -

    -
      -
    1. Let maxarg be the length of the longest type list of the entries in S.
    2. -
    3. Initialize argcount to be min(maxargn).
    4. - -
    5. Remove from S all entries whose type list is not of length argcount.
    6. - -
    7. If S is empty, then throw a TypeError.
    8. - -
    9. Initialize d to −1.
    10. - -
    11. - Initialize method to - undefined. -
    12. - -
    13. If there is more than one entry in S, then set - d to be the distinguishing argument index - for the entries of S.
    14. - -
    15. Initialize values to be an empty list, where each entry will be either an IDL value or the special value “missing”.
    16. - -
    17. Initialize i to 0.
    18. - -
    19. While i < d: -
        -
      1. Let V be argi.
      2. -
      3. Let type be the type at index i in the type list of any entry in S. -
        Note

        All entries in S at this point have the same type and optionality value at index i.

        -
      4. -
      5. Let optionality be the value at index i in the list of optionality values of any entry in S.
      6. -
      7. If optionality is “optional” and V is undefined, then: -
          -
        1. If the argument at index i is declared with a default value, - then append to values that default value.
        2. -
        3. Otherwise, append to values the special value “missing”.
        4. -
        -
      8. -
      9. Otherwise, append to values the result of converting - V to IDL type type.
      10. -
      11. Set i to i + 1.
      12. -
      -
    20. - -
    21. If i = d, then: -
        -
      1. Let V be argi. -
        Note

        This is the argument that will be used to resolve which overload is selected.

      2. - -
      3. If V is undefined, and there is an entry in S - whose list of optionality values has “optional” at index i, - then remove from S all other entries.
      4. - -
      5. Otherwise: if V is null or undefined, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      6. - -
      7. - Otherwise: if V is a platform object – but not a - platform array object – and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      8. - -
      9. - Otherwise: if V is a RegExp object and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      10. - -
      11. - Otherwise: if V is a RegExp object and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      12. - -
      13. - Otherwise: if V is a DOMException platform object and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      14. - -
      15. - Otherwise: if V is an Error object (that is, it has an [[ErrorData]] internal slot) and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      16. - -
      17. - Otherwise: if V is an object with an [[ArrayBufferData]] internal slot and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      18. - -
      19. - Otherwise: if V is an object with a [[DataView]] internal slot and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      20. - -
      21. - Otherwise: if V is an object with a [[TypedArrayName]] internal slot and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      22. - -
      23. - Otherwise: if IsCallable(V) is true, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      24. - -
      25. - Otherwise: if V is any kind of object except for - a native RegExp object, and - there is an entry in S that has one of the - following types at position i of its type list, - - and after performing the following steps, -
          -
        1. - Let method be the result of - GetMethod(V, @@iterator). -
        2. -
        3. - ReturnIfAbrupt(method). -
        4. -
        - method is not undefined, then remove from S all - other entries. -
      26. - -
      27. - Otherwise: if V is any kind of object except for - a native RegExp object, and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      28. - -
      29. - Otherwise: if V is a Boolean value, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      30. - -
      31. - Otherwise: if V is a Number value, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      32. - -
      33. - Otherwise: if there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      34. - -
      35. - Otherwise: if there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      36. - -
      37. - Otherwise: if there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      38. - -
      39. - Otherwise: if there is an entry in S that has any at position i - of its type list, - then remove from S all other entries. -
      40. - -
      41. - Otherwise: - throw a TypeError. -
      42. -
      -
    22. - -
    23. Let callable be the operation or extended attribute - of the single entry in S.
    24. - -
    25. - If i = d and method is not undefined, then -
        -
      1. - Let V be argi. -
      2. -
      3. - Let T be the type at index i in the - type list of the remaining entry in S. -
      4. -
      5. - If T is a sequence type, then - append to values the result of - creating a sequence - of type T from - V and method. -
      6. -
      7. - Otherwise, T is a frozen array type. - Append to values the result of - creating a frozen array - of type T from - V and method. -
      8. -
      9. - Set i to i + 1. -
      10. -
      -
    26. - -
    27. - While i < argcount: -
        -
      1. Let V be argi.
      2. -
      3. Let type be the type at index i in the type list of the remaining entry in S.
      4. -
      5. Let optionality be the value at index i in the list of optionality values of the remaining entry in S.
      6. -
      7. If optionality is “optional” and V is undefined, then: -
          -
        1. If the argument at index i is declared with a default value, - then append to values that default value.
        2. -
        3. Otherwise, append to values the special value “missing”.
        4. -
        -
      8. -
      9. Otherwise, append to values the result of - converting V to IDL type type.
      10. -
      11. Set i to i + 1.
      12. -
      -
    28. - -
    29. While i is less than the number of arguments callable is declared to take: -
        -
      1. If callable’s argument at index i is declared with a default value, - then append to values that default value.
      2. -
      3. Otherwise, if callable’s argument at index i is not variadic, then append to values the special value “missing”.
      4. -
      5. Set i to i + 1.
      6. -
      -
    30. - -
    31. Return the pair <callable, values>.
    32. -
    -
    Note
    -

    - The overload resolution algorithm performs both the identification - of which overloaded operation, constructor, etc. is being called, - and the conversion of the ECMAScript argument values to their - corresponding IDL values. Informally, it operates as follows. -

    -

    First, the selection of valid overloads is done by considering - the number of ECMAScript arguments that were passed in to the function:

    -
      -
    • If there are more arguments passed in than the longest - overload argument list, then they are ignored.
    • -
    • After ignoring these trailing arguments, only overloads - that can take this exact number of arguments are considered. - If there are none, then a TypeError is thrown.
    • -
    -

    Once we have a set of possible overloads with the right number - of arguments, the ECMAScript values are converted from left to right. - The nature of the restrictions on overloading means that if we - have multiple possible overloads at this point, then there will - be one position in the argument list that will be used to - distinguish which overload we will finally select; this is - the distinguishing - argument index.

    -

    We first convert the arguments to the left of the distinguishing - argument. (There is a requirement that an argument to the left of - the distinguishing argument index has the same type as in the other - overloads, at the same index.) Then we inspect the type of the - ECMAScript value that is passed in at the distinguishing argument - index to determine which IDL type it may correspond to. - This allows us to select the final overload that will - be invoked. If the value passed in is undefined - and there is an overload with an optional argument at this position, then - we will choose that overload. If there is no valid overload for the type of - value passed in here, then we throw a TypeError. - The inspection of the value at the distinguishing argument index does not have any side effects; - the only side effects that come from running the overload resolution - algorithm are those that come from converting the ECMAScript values - to IDL values.

    -

    At this point, we have determined which overload to use. We now - convert the remaining arguments, from the distinguishing argument onwards, - again ignoring any additional arguments that were ignored due to being passed - after the last possible argument.

    -

    When converting an optional argument’s ECMAScript value to its equivalent IDL value, - undefined will be converted into - the optional argument’s default value, - if it has one, or a special value “missing” otherwise.

    -

    Optional arguments corresponding to a final, variadic argument do not treat - undefined as a special “missing” value, however. - The undefined value is converted to the type - of variadic argument as would be done for a non-optional argument.

    -

    The internal [[Call]] method of the interface object behaves as follows, assuming @@ -10852,7 +10857,7 @@

    4.5.1.1. Interface object [[Call]] method
    -
    4.5.1.2. Interface object [[HasInstance]] method
    +
    4.6.1.2. Interface object [[HasInstance]] method

    The internal [[HasInstance]] method of every @@ -10881,7 +10886,7 @@

    4.5.1.2. Interface object [[HasInstance]] method
    -

    4.5.2. Named constructors

    +

    4.6.2. Named constructors

    A named constructor @@ -10972,7 +10977,7 @@

    4.5.2. Named constructors

    -

    4.5.3. Dictionary constructors

    +

    4.6.3. Dictionary constructors

    For every dictionary type @@ -11056,7 +11061,7 @@

    4.5.3. Dictionary constructors

    -

    4.5.4. Interface prototype object

    +

    4.6.4. Interface prototype object

    There MUST exist an @@ -11069,15 +11074,15 @@

    4.5.4. Interface prototype object

    properties that correspond to the regular attributes and regular operations defined on that interface. These properties are described in more detail in - sections 4.5.7 and - 4.5.8 below. + sections 4.6.7 and + 4.6.8 below.

    As with the interface object, the interface prototype object also has properties that correspond to the constants defined on that interface, described in section - 4.5.6 below. + 4.6.6 below.

    If the [NoInterfaceObject] @@ -11100,7 +11105,7 @@

    4.5.4. Interface prototype object

    extended attribute, and A supports named properties, then return the named properties object - for A, as defined in section 4.5.5 + for A, as defined in section 4.6.5 below.
  • Otherwise, if A is declared to inherit from another interface, then return the @@ -11179,7 +11184,7 @@

    4.5.4. Interface prototype object

  • -

    4.5.5. Named properties object

    +

    4.6.5. Named properties object

    For every interface declared with the @@ -11214,7 +11219,7 @@

    4.5.5. Named properties object

    -
    4.5.5.1. Named properties object [[GetOwnProperty]] method
    +
    4.6.5.1. Named properties object [[GetOwnProperty]] method

    The internal [[GetOwnProperty]] method of every @@ -11263,7 +11268,7 @@

    4.5.5.1. Named properties object [[GetOwnProperty]] method
    -
    4.5.5.2. Named properties object [[DefineOwnProperty]] method
    +
    4.6.5.2. Named properties object [[DefineOwnProperty]] method

    The internal [[DefineOwnProperty]] method of every @@ -11279,7 +11284,7 @@

    4.5.5.2. Named properties object [[DefineOwnProperty]] method
    -
    4.5.5.3. Named properties object [[Delete]] method
    +
    4.6.5.3. Named properties object [[Delete]] method

    The internal [[Delete]] method of every @@ -11351,7 +11356,7 @@

    Mixin prototype objects

    -->
    -

    4.5.6. Constants

    +

    4.6.6. Constants

    For each exposed @@ -11386,7 +11391,7 @@

    4.5.6. Constants

    -

    4.5.7. Attributes

    +

    4.6.7. Attributes

    For each exposed @@ -11580,7 +11585,7 @@

    4.5.7. Attributes

    -

    4.5.8. Operations

    +

    4.6.8. Operations

    For each unique identifier @@ -11740,7 +11745,7 @@

    4.5.8. Operations

    -
    4.5.8.1. Stringifiers
    +
    4.6.8.1. Stringifiers

    If the interface @@ -11798,7 +11803,7 @@

    4.5.8.1. Stringifiers
    -
    4.5.8.2. Serializers
    +
    4.6.8.2. Serializers

    If the interface @@ -11922,10 +11927,10 @@

    4.5.8.2. Serializers
    -

    4.5.9. Common iterator behavior

    +

    4.6.9. Common iterator behavior

    -
    4.5.9.1. @@iterator
    +
    4.6.9.1. @@iterator

    If the interface @@ -12021,7 +12026,7 @@

    4.5.9.1. @@iterator
    -
    4.5.9.2. forEach
    +
    4.6.9.2. forEach

    If the interface @@ -12131,10 +12136,10 @@

    4.5.9.2. forEach
    -

    4.5.10. Iterable declarations

    +

    4.6.10. Iterable declarations

    -
    4.5.10.1. entries
    +
    4.6.10.1. entries

    If the interface has an @@ -12178,7 +12183,7 @@

    4.5.10.1. entries
    -
    4.5.10.2. keys
    +
    4.6.10.2. keys

    If the interface has an @@ -12222,7 +12227,7 @@

    4.5.10.2. keys
    -
    4.5.10.3. values
    +
    4.6.10.3. values

    If the interface has an @@ -12248,7 +12253,7 @@

    4.5.10.3. values
    -
    4.5.10.4. Default iterator objects
    +
    4.6.10.4. Default iterator objects

    A default iterator object for a given @@ -12281,7 +12286,7 @@

    4.5.10.4. Default iterator objects
    -
    4.5.10.5. Iterator prototype object
    +
    4.6.10.5. Iterator prototype object

    The iterator prototype object @@ -12370,7 +12375,7 @@

    4.5.10.5. Iterator prototype object
    -

    4.5.11. Maplike declarations

    +

    4.6.11. Maplike declarations

    Any object that implements an interface @@ -12409,7 +12414,7 @@

    4.5.11. Maplike declarations

    -
    4.5.11.1. size
    +
    4.6.11.1. size

    There MUST exist a property named “size” on @@ -12439,7 +12444,7 @@

    4.5.11.1. size
    -
    4.5.11.2. entries
    +
    4.6.11.2. entries

    A property named “entries” MUST exist on @@ -12451,7 +12456,7 @@

    4.5.11.2. entries
    -
    4.5.11.3. keys and values
    +
    4.6.11.3. keys and values

    For both of “keys” and “values”, there MUST exist a property with that name on @@ -12467,7 +12472,7 @@

    4.5.11.3. keys and values
    -
    4.5.11.4. get and has
    +
    4.6.11.4. get and has

    For both of “get” and “has”, there MUST exist a property with that name on @@ -12499,7 +12504,7 @@

    4.5.11.4. get and has
    -
    4.5.11.5. clear
    +
    4.6.11.5. clear

    If A and A’s @@ -12520,7 +12525,7 @@

    4.5.11.5. clear
    -
    4.5.11.6. delete
    +
    4.6.11.6. delete

    If A and A’s @@ -12556,7 +12561,7 @@

    4.5.11.6. delete
    -
    4.5.11.7. set
    +
    4.6.11.7. set

    If A and A’s @@ -12598,7 +12603,7 @@

    4.5.11.7. set
    -

    4.5.12. Setlike declarations

    +

    4.6.12. Setlike declarations

    Any object that implements an interface @@ -12637,7 +12642,7 @@

    4.5.12. Setlike declarations

    -
    4.5.12.1. size
    +
    4.6.12.1. size

    There MUST exist a property named “size” on @@ -12667,7 +12672,7 @@

    4.5.12.1. size
    -
    4.5.12.2. values
    +
    4.6.12.2. values

    A property named “values” MUST exist on @@ -12679,7 +12684,7 @@

    4.5.12.2. values
    -
    4.5.12.3. entries and keys
    +
    4.6.12.3. entries and keys

    For both of “entries” and “keys”, there MUST exist a property with that name on @@ -12695,7 +12700,7 @@

    4.5.12.3. entries and keys
    -
    4.5.12.4. has
    +
    4.6.12.4. has

    There MUST exist a property with named “has” on @@ -12726,7 +12731,7 @@

    4.5.12.4. has
    -
    4.5.12.5. add and delete
    +
    4.6.12.5. add and delete

    For both of “add” and “delete”, if: @@ -12781,7 +12786,7 @@

    4.5.12.5. add and delete
    -
    4.5.12.6. clear
    +
    4.6.12.6. clear

    If A and A’s @@ -12803,7 +12808,7 @@

    4.5.12.6. clear
    -

    4.5.13. Initializing objects from iterables

    +

    4.6.13. Initializing objects from iterables

    Some objects, which are attempting to emulate map- and set-like interfaces, will want to accept iterables @@ -12852,7 +12857,7 @@

    4.5.13. Initializing objects from iterables

    -

    4.6. Implements statements

    +

    4.7. Implements statements

    The interface prototype object @@ -12902,19 +12907,19 @@

    4.6. Implements statements

    TypeError being thrown. However, calling A.prototype.f on an object that implements B or one that implements C - would succeed. This is handled by the algorithm in section 4.5.8 + would succeed. This is handled by the algorithm in section 4.6.8 that defines how IDL operation invocation works in ECMAScript.

    Similar behavior is required for the getter and setter Function objects that correspond to an IDL attributes, - and this is handled in section 4.5.7. + and this is handled in section 4.6.7.

    -

    4.7. Platform objects implementing interfaces

    +

    4.8. Platform objects implementing interfaces

    Every platform object is associated with a global environment, just @@ -13104,7 +13109,7 @@

    Host object mixin prototype object

    -

    4.7.1. Indexed and named properties

    +

    4.8.1. Indexed and named properties

    If a platform object implements an interface that @@ -13250,16 +13255,16 @@

    4.7.1. Indexed and named properties

    Support for getters is handled by the platform object [[GetOwnProperty]] method - defined in section 4.7.3, and + defined in section 4.8.3, and for setters by the platform object [[DefineOwnProperty]] method - defined in section 4.7.7 and the platform object [[Set]] method - defined in section 4.7.6. + defined in section 4.8.7 and the platform object [[Set]] method + defined in section 4.8.6.

    -

    4.7.2. The PlatformObjectGetOwnProperty abstract operation

    +

    4.8.2. The PlatformObjectGetOwnProperty abstract operation

    The PlatformObjectGetOwnProperty @@ -13336,7 +13341,7 @@

    4.7.2. The PlatformObjectGetOwnProperty abstract operation

    -

    4.7.3. Platform object [[GetOwnProperty]] method

    +

    4.8.3. Platform object [[GetOwnProperty]] method

    The internal [[GetOwnProperty]] method of every @@ -13357,7 +13362,7 @@

    4.7.3. Platform object [[GetOwnProperty]] method

    -

    4.7.4. Invoking a platform object indexed property setter

    +

    4.8.4. Invoking a platform object indexed property setter

    To invoke an indexed property setter with property name P and ECMAScript value @@ -13385,7 +13390,7 @@

    4.7.4. Invoking a platform object indexed property setter

    -

    4.7.5. Invoking a platform object named property setter

    +

    4.8.5. Invoking a platform object named property setter

    To invoke a named property setter with property name P and ECMAScript value @@ -13412,7 +13417,7 @@

    4.7.5. Invoking a platform object named property setter

    -

    4.7.6. Platform object [[Set]] method

    +

    4.8.6. Platform object [[Set]] method

    The internal [[Set]] method of every @@ -13471,7 +13476,7 @@

    4.7.6. Platform object [[Set]] method

    -

    4.7.7. Platform object [[DefineOwnProperty]] method

    +

    4.8.7. Platform object [[DefineOwnProperty]] method

    The internal [[DefineOwnProperty]] method of every @@ -13558,7 +13563,7 @@

    4.7.7. Platform object [[DefineOwnProperty]] method

    -

    4.7.8. Platform object [[Delete]] method

    +

    4.8.8. Platform object [[Delete]] method

    The internal [[Delete]] method of every @@ -13618,7 +13623,7 @@

    4.7.8. Platform object [[Delete]] method

    -

    4.7.9. Platform object [[Call]] method

    +

    4.8.9. Platform object [[Call]] method

    The internal [[Call]] method of every @@ -13646,7 +13651,7 @@

    4.7.9. Platform object [[Call]] method

    -

    4.7.10. Property enumeration

    +

    4.8.10. Property enumeration

    This document does not define a complete property enumeration order @@ -13677,7 +13682,7 @@

    4.7.10. Property enumeration

    -

    4.8. User objects implementing callback interfaces

    +

    4.9. User objects implementing callback interfaces

    As described in section 3.9 above, @@ -13861,7 +13866,7 @@

    4.8. User objects implementing callback interfaces

    -

    4.9. Invoking callback functions

    +

    4.10. Invoking callback functions

    An ECMAScript callable object that is being @@ -13934,7 +13939,7 @@

    4.9. Invoking callback functions

    -

    4.10. Exceptions

    +

    4.11. Exceptions

    There MUST exist a property on the ECMAScript global object @@ -13946,7 +13951,7 @@

    4.10. Exceptions

    -

    4.10.1. DOMException constructor object

    +

    4.11.1. DOMException constructor object

    The DOMException constructor object MUST be a function object @@ -13967,7 +13972,7 @@

    4.10.1. DOMException constructor object

    -
    4.10.1.1. DOMException(message, name)
    +
    4.11.1.1. DOMException(message, name)

    When the DOMException function is called with arguments message and name, the following steps are taken:

    @@ -13994,7 +13999,7 @@
    4.10.1.1. DOMException(message, name)
    -

    4.10.2. DOMException prototype object

    +

    4.11.2. DOMException prototype object

    The DOMException prototype object MUST @@ -14021,7 +14026,7 @@

    4.10.2. DOMException prototype object

    -

    4.11. Exception objects

    +

    4.12. Exception objects

    Simple exceptions are represented @@ -14064,7 +14069,7 @@

    4.11. Exception objects

    -

    4.12. Creating and throwing exceptions

    +

    4.13. Creating and throwing exceptions

    First, we define the current global environment @@ -14209,7 +14214,7 @@

    4.12. Creating and throwing exceptions

    -

    4.13. Handling exceptions

    +

    4.14. Handling exceptions

    None of the algorithms or processing requirements in the diff --git a/index.xml b/index.xml index 5ab7a5e7..87a943fe 100644 --- a/index.xml +++ b/index.xml @@ -10089,6 +10089,435 @@ with (thing) {

    +
    +

    Overload resolution algorithm

    + +

    + In order to define how overloaded function invocations are resolved, the + overload resolution algorithm + is defined. Its input is an effective overload set, + S, and a list of ECMAScript values, arg0..n−1. + Its output is a pair consisting of the operation or + extended attribute of one of S’s entries + and a list of IDL values or the special value “missing”. The algorithm behaves as follows: +

    +
      +
    1. Let maxarg be the length of the longest type list of the entries in S.
    2. +
    3. Initialize argcount to be min(maxargn).
    4. + +
    5. Remove from S all entries whose type list is not of length argcount.
    6. + +
    7. If S is empty, then throw a TypeError.
    8. + +
    9. Initialize d to −1.
    10. + +
    11. + Initialize method to + undefined. +
    12. + +
    13. If there is more than one entry in S, then set + d to be the distinguishing argument index + for the entries of S.
    14. + +
    15. Initialize values to be an empty list, where each entry will be either an IDL value or the special value “missing”.
    16. + +
    17. Initialize i to 0.
    18. + +
    19. While i < d: +
        +
      1. Let V be argi.
      2. +
      3. Let type be the type at index i in the type list of any entry in S. +

        All entries in S at this point have the same type and optionality value at index i.

        +
      4. +
      5. Let optionality be the value at index i in the list of optionality values of any entry in S.
      6. +
      7. If optionality is “optional” and V is undefined, then: +
          +
        1. If the argument at index i is declared with a default value, + then append to values that default value.
        2. +
        3. Otherwise, append to values the special value “missing”.
        4. +
        +
      8. +
      9. Otherwise, append to values the result of converting + V to IDL type type.
      10. +
      11. Set i to i + 1.
      12. +
      +
    20. + +
    21. If i = d, then: +
        +
      1. Let V be argi. +

        This is the argument that will be used to resolve which overload is selected.

      2. + +
      3. If V is undefined, and there is an entry in S + whose list of optionality values has “optional” at index i, + then remove from S all other entries.
      4. + +
      5. Otherwise: if V is null or undefined, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      6. + +
      7. + Otherwise: if V is a platform object – but not a + platform array object – and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      8. + +
      9. + Otherwise: if V is a RegExp object and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      10. + +
      11. + Otherwise: if V is a RegExp object and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      12. + +
      13. + Otherwise: if V is a DOMException platform object and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      14. + +
      15. + Otherwise: if V is an Error object (that is, it has an [[ErrorData]] internal slot) and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      16. + +
      17. + Otherwise: if V is an object with an [[ArrayBufferData]] internal slot and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      18. + +
      19. + Otherwise: if V is an object with a [[DataView]] internal slot and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      20. + +
      21. + Otherwise: if V is an object with a [[TypedArrayName]] internal slot and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      22. + +
      23. + Otherwise: if IsCallable(V) is true, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      24. + +
      25. + Otherwise: if V is any kind of object except for + a native RegExp object, and + there is an entry in S that has one of the + following types at position i of its type list, + + and after performing the following steps, +
          +
        1. + Let method be the result of + GetMethod(V, @@iterator). +
        2. +
        3. + ReturnIfAbrupt(method). +
        4. +
        + method is not undefined, then remove from S all + other entries. +
      26. + +
      27. + Otherwise: if V is any kind of object except for + a native RegExp object, and + there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      28. + +
      29. + Otherwise: if V is a Boolean value, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      30. + +
      31. + Otherwise: if V is a Number value, + and there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      32. + +
      33. + Otherwise: if there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      34. + +
      35. + Otherwise: if there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      36. + +
      37. + Otherwise: if there is an entry in S that has one of the following types at position i of its type list, + + then remove from S all other entries. +
      38. + +
      39. + Otherwise: if there is an entry in S that has any at position i + of its type list, + then remove from S all other entries. +
      40. + +
      41. + Otherwise: + throw a TypeError. +
      42. +
      +
    22. + +
    23. Let callable be the operation or extended attribute + of the single entry in S.
    24. + +
    25. + If i = d and method is not undefined, then +
        +
      1. + Let V be argi. +
      2. +
      3. + Let T be the type at index i in the + type list of the remaining entry in S. +
      4. +
      5. + If T is a sequence type, then + append to values the result of + creating a sequence + of type T from + V and method. +
      6. +
      7. + Otherwise, T is a frozen array type. + Append to values the result of + creating a frozen array + of type T from + V and method. +
      8. +
      9. + Set i to i + 1. +
      10. +
      +
    26. + +
    27. + While i < argcount: +
        +
      1. Let V be argi.
      2. +
      3. Let type be the type at index i in the type list of the remaining entry in S.
      4. +
      5. Let optionality be the value at index i in the list of optionality values of the remaining entry in S.
      6. +
      7. If optionality is “optional” and V is undefined, then: +
          +
        1. If the argument at index i is declared with a default value, + then append to values that default value.
        2. +
        3. Otherwise, append to values the special value “missing”.
        4. +
        +
      8. +
      9. Otherwise, append to values the result of + converting V to IDL type type.
      10. +
      11. Set i to i + 1.
      12. +
      +
    28. + +
    29. While i is less than the number of arguments callable is declared to take: +
        +
      1. If callable’s argument at index i is declared with a default value, + then append to values that default value.
      2. +
      3. Otherwise, if callable’s argument at index i is not variadic, then append to values the special value “missing”.
      4. +
      5. Set i to i + 1.
      6. +
      +
    30. + +
    31. Return the pair <callable, values>.
    32. +
    +
    +

    + The overload resolution algorithm performs both the identification + of which overloaded operation, constructor, etc. is being called, + and the conversion of the ECMAScript argument values to their + corresponding IDL values. Informally, it operates as follows. +

    +

    First, the selection of valid overloads is done by considering + the number of ECMAScript arguments that were passed in to the function:

    +
      +
    • If there are more arguments passed in than the longest + overload argument list, then they are ignored.
    • +
    • After ignoring these trailing arguments, only overloads + that can take this exact number of arguments are considered. + If there are none, then a TypeError is thrown.
    • +
    +

    Once we have a set of possible overloads with the right number + of arguments, the ECMAScript values are converted from left to right. + The nature of the restrictions on overloading means that if we + have multiple possible overloads at this point, then there will + be one position in the argument list that will be used to + distinguish which overload we will finally select; this is + the distinguishing + argument index.

    +

    We first convert the arguments to the left of the distinguishing + argument. (There is a requirement that an argument to the left of + the distinguishing argument index has the same type as in the other + overloads, at the same index.) Then we inspect the type of the + ECMAScript value that is passed in at the distinguishing argument + index to determine which IDL type it may correspond to. + This allows us to select the final overload that will + be invoked. If the value passed in is undefined + and there is an overload with an optional argument at this position, then + we will choose that overload. If there is no valid overload for the type of + value passed in here, then we throw a TypeError. + The inspection of the value at the distinguishing argument index does not have any side effects; + the only side effects that come from running the overload resolution + algorithm are those that come from converting the ECMAScript values + to IDL values.

    +

    At this point, we have determined which overload to use. We now + convert the remaining arguments, from the distinguishing argument onwards, + again ignoring any additional arguments that were ignored due to being passed + after the last possible argument.

    +

    When converting an optional argument’s ECMAScript value to its equivalent IDL value, + undefined will be converted into + the optional argument’s default value, + if it has one, or a special value “missing” otherwise.

    +

    Optional arguments corresponding to a final, variadic argument do not treat + undefined as a special “missing” value, however. + The undefined value is converted to the type + of variadic argument as would be done for a non-optional argument.

    +
    +
    +

    Interfaces

    @@ -10217,430 +10646,6 @@ with (thing) { the given interface if it returns normally (that is, if it does not throw an exception).

    --> -

    - In order to define how overloaded constructor invocations are resolved, the - overload resolution algorithm - is defined. Its input is an effective overload set, - S, and a list of ECMAScript values, arg0..n−1. - Its output is a pair consisting of the operation or - extended attribute of one of S’s entries - and a list of IDL values or the special value “missing”. The algorithm behaves as follows: -

    -
      -
    1. Let maxarg be the length of the longest type list of the entries in S.
    2. -
    3. Initialize argcount to be min(maxargn).
    4. - -
    5. Remove from S all entries whose type list is not of length argcount.
    6. - -
    7. If S is empty, then throw a TypeError.
    8. - -
    9. Initialize d to −1.
    10. - -
    11. - Initialize method to - undefined. -
    12. - -
    13. If there is more than one entry in S, then set - d to be the distinguishing argument index - for the entries of S.
    14. - -
    15. Initialize values to be an empty list, where each entry will be either an IDL value or the special value “missing”.
    16. - -
    17. Initialize i to 0.
    18. - -
    19. While i < d: -
        -
      1. Let V be argi.
      2. -
      3. Let type be the type at index i in the type list of any entry in S. -

        All entries in S at this point have the same type and optionality value at index i.

        -
      4. -
      5. Let optionality be the value at index i in the list of optionality values of any entry in S.
      6. -
      7. If optionality is “optional” and V is undefined, then: -
          -
        1. If the argument at index i is declared with a default value, - then append to values that default value.
        2. -
        3. Otherwise, append to values the special value “missing”.
        4. -
        -
      8. -
      9. Otherwise, append to values the result of converting - V to IDL type type.
      10. -
      11. Set i to i + 1.
      12. -
      -
    20. - -
    21. If i = d, then: -
        -
      1. Let V be argi. -

        This is the argument that will be used to resolve which overload is selected.

      2. - -
      3. If V is undefined, and there is an entry in S - whose list of optionality values has “optional” at index i, - then remove from S all other entries.
      4. - -
      5. Otherwise: if V is null or undefined, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      6. - -
      7. - Otherwise: if V is a platform object – but not a - platform array object – and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      8. - -
      9. - Otherwise: if V is a RegExp object and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      10. - -
      11. - Otherwise: if V is a RegExp object and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      12. - -
      13. - Otherwise: if V is a DOMException platform object and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      14. - -
      15. - Otherwise: if V is an Error object (that is, it has an [[ErrorData]] internal slot) and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      16. - -
      17. - Otherwise: if V is an object with an [[ArrayBufferData]] internal slot and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      18. - -
      19. - Otherwise: if V is an object with a [[DataView]] internal slot and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      20. - -
      21. - Otherwise: if V is an object with a [[TypedArrayName]] internal slot and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      22. - -
      23. - Otherwise: if IsCallable(V) is true, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      24. - -
      25. - Otherwise: if V is any kind of object except for - a native RegExp object, and - there is an entry in S that has one of the - following types at position i of its type list, - - and after performing the following steps, -
          -
        1. - Let method be the result of - GetMethod(V, @@iterator). -
        2. -
        3. - ReturnIfAbrupt(method). -
        4. -
        - method is not undefined, then remove from S all - other entries. -
      26. - -
      27. - Otherwise: if V is any kind of object except for - a native RegExp object, and - there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      28. - -
      29. - Otherwise: if V is a Boolean value, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      30. - -
      31. - Otherwise: if V is a Number value, - and there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      32. - -
      33. - Otherwise: if there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      34. - -
      35. - Otherwise: if there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      36. - -
      37. - Otherwise: if there is an entry in S that has one of the following types at position i of its type list, - - then remove from S all other entries. -
      38. - -
      39. - Otherwise: if there is an entry in S that has any at position i - of its type list, - then remove from S all other entries. -
      40. - -
      41. - Otherwise: - throw a TypeError. -
      42. -
      -
    22. - -
    23. Let callable be the operation or extended attribute - of the single entry in S.
    24. - -
    25. - If i = d and method is not undefined, then -
        -
      1. - Let V be argi. -
      2. -
      3. - Let T be the type at index i in the - type list of the remaining entry in S. -
      4. -
      5. - If T is a sequence type, then - append to values the result of - creating a sequence - of type T from - V and method. -
      6. -
      7. - Otherwise, T is a frozen array type. - Append to values the result of - creating a frozen array - of type T from - V and method. -
      8. -
      9. - Set i to i + 1. -
      10. -
      -
    26. - -
    27. - While i < argcount: -
        -
      1. Let V be argi.
      2. -
      3. Let type be the type at index i in the type list of the remaining entry in S.
      4. -
      5. Let optionality be the value at index i in the list of optionality values of the remaining entry in S.
      6. -
      7. If optionality is “optional” and V is undefined, then: -
          -
        1. If the argument at index i is declared with a default value, - then append to values that default value.
        2. -
        3. Otherwise, append to values the special value “missing”.
        4. -
        -
      8. -
      9. Otherwise, append to values the result of - converting V to IDL type type.
      10. -
      11. Set i to i + 1.
      12. -
      -
    28. - -
    29. While i is less than the number of arguments callable is declared to take: -
        -
      1. If callable’s argument at index i is declared with a default value, - then append to values that default value.
      2. -
      3. Otherwise, if callable’s argument at index i is not variadic, then append to values the special value “missing”.
      4. -
      5. Set i to i + 1.
      6. -
      -
    30. - -
    31. Return the pair <callable, values>.
    32. -
    -
    -

    - The overload resolution algorithm performs both the identification - of which overloaded operation, constructor, etc. is being called, - and the conversion of the ECMAScript argument values to their - corresponding IDL values. Informally, it operates as follows. -

    -

    First, the selection of valid overloads is done by considering - the number of ECMAScript arguments that were passed in to the function:

    -
      -
    • If there are more arguments passed in than the longest - overload argument list, then they are ignored.
    • -
    • After ignoring these trailing arguments, only overloads - that can take this exact number of arguments are considered. - If there are none, then a TypeError is thrown.
    • -
    -

    Once we have a set of possible overloads with the right number - of arguments, the ECMAScript values are converted from left to right. - The nature of the restrictions on overloading means that if we - have multiple possible overloads at this point, then there will - be one position in the argument list that will be used to - distinguish which overload we will finally select; this is - the distinguishing - argument index.

    -

    We first convert the arguments to the left of the distinguishing - argument. (There is a requirement that an argument to the left of - the distinguishing argument index has the same type as in the other - overloads, at the same index.) Then we inspect the type of the - ECMAScript value that is passed in at the distinguishing argument - index to determine which IDL type it may correspond to. - This allows us to select the final overload that will - be invoked. If the value passed in is undefined - and there is an overload with an optional argument at this position, then - we will choose that overload. If there is no valid overload for the type of - value passed in here, then we throw a TypeError. - The inspection of the value at the distinguishing argument index does not have any side effects; - the only side effects that come from running the overload resolution - algorithm are those that come from converting the ECMAScript values - to IDL values.

    -

    At this point, we have determined which overload to use. We now - convert the remaining arguments, from the distinguishing argument onwards, - again ignoring any additional arguments that were ignored due to being passed - after the last possible argument.

    -

    When converting an optional argument’s ECMAScript value to its equivalent IDL value, - undefined will be converted into - the optional argument’s default value, - if it has one, or a special value “missing” otherwise.

    -

    Optional arguments corresponding to a final, variadic argument do not treat - undefined as a special “missing” value, however. - The undefined value is converted to the type - of variadic argument as would be done for a non-optional argument.

    -

    The internal [[Call]] method of the interface object behaves as follows, assuming