From 726ecde7c8b9d3a3637f4ac73eb9cc4afb27640b Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Fri, 20 Jan 2017 18:19:16 +0100 Subject: [PATCH 1/2] Editorial: use Type(x) where appropriate. Fixes #222. --- index.bs | 45 +++++++++++++++++++++------------------------ index.html | 32 ++++++++++++++++---------------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/index.bs b/index.bs index 3c11e60f..fb16d339 100644 --- a/index.bs +++ b/index.bs @@ -7641,8 +7641,7 @@ that correspond to the union’s [=member types=]. then return the IDL value null. 1. Let |types| be the [=flattened member types=] of the [=union type=]. - 1. If |V| is null or - undefined, then: + 1. If |V| is null or undefined, then: 1. If |types| includes a [=dictionary type=], then return the result of [=converted to an IDL value|converting=] |V| to that dictionary type. 1. If |types| includes a [=record type=], then return the @@ -7659,25 +7658,25 @@ that correspond to the union’s [=member types=]. |V| to that type. 1. If |types| includes {{object}}, then return the IDL value that is a reference to the object |V|. - 1. If |V| is a native Error object (that is, it has an \[[ErrorData]] [=internal slot=]), then: + 1. If [=Type=](|V|) is Object and |V| has an \[[ErrorData]] [=internal slot=]), then: 1. If |types| includes {{Error!!interface}}, then return the result of [=converted to an IDL value|converting=] |V| to {{Error!!interface}}. 1. If |types| includes {{object}}, then return the IDL value that is a reference to the object |V|. - 1. If |V| is an object with an \[[ArrayBufferData]] [=internal slot=], then: + 1. If [=Type=](|V|) is Object and |V| has an \[[ArrayBufferData]] [=internal slot=], then: 1. If |types| includes {{ArrayBuffer}}, then return the result of [=converted to an IDL value|converting=] |V| to {{ArrayBuffer}}. 1. If |types| includes {{object}}, then return the IDL value that is a reference to the object |V|. - 1. If |V| is an object with a \[[DataView]] [=internal slot=], then: + 1. If [=Type=](|V|) is Object and |V| has a \[[DataView]] [=internal slot=], then: 1. If |types| includes {{DataView}}, then return the result of [=converted to an IDL value|converting=] |V| to {{DataView}}. 1. If |types| includes {{object}}, then return the IDL value that is a reference to the object |V|. - 1. If |V| is an object with a \[[TypedArrayName]] [=internal slot=], then: + 1. If [=Type=](|V|) is Object and |V| has a \[[TypedArrayName]] [=internal slot=], then: 1. If |types| includes a [=typed array type=] whose name is the value of |V|’s \[[TypedArrayName]] [=internal slot=], then return the result of [=converted to an IDL value|converting=] @@ -7691,24 +7690,22 @@ that correspond to the union’s [=member types=]. |V| to that callback function type. 1. If |types| includes {{object}}, then return the IDL value that is a reference to the object |V|. - 1. If |V| is any kind of object, then: + 1. If [=Type=](|V|) is Object, then: 1. If |types| includes a [=sequence type=], then 1. Let |method| be the result of [=GetMethod=](|V|, [=@@iterator=]). 1. [=ReturnIfAbrupt=](|method|). - 1. If |method| is not - undefined, + 1. If |method| is not undefined, return the result of [=creating a sequence from an iterable|creating a sequence=] of that type from |V| and |method|. 1. If |types| includes a [=frozen array type=], then - 1. Let |method| be the result of - [=GetMethod=](|V|, [=@@iterator=]). + 1. Let |method| be the result of [=GetMethod=](|V|, [=@@iterator=]). 1. [=ReturnIfAbrupt=](|method|). - 1. If |method| is not - undefined, + 1. If |method| is not undefined, return the result of - [=Creating a frozen array from an iterable|creating a frozen array of that type from V and method=]. + [=Creating a frozen array from an iterable|creating a frozen array=] + of that type from |V| and |method|. 1. If |types| includes a [=dictionary type=], then return the result of [=converted to an IDL value|converting=] |V| to that dictionary type. @@ -7721,11 +7718,11 @@ that correspond to the union’s [=member types=]. |V| to that interface type. 1. If |types| includes {{object}}, then return the IDL value that is a reference to the object |V|. - 1. If |V| is a Boolean value, then: + 1. If [=Type=](|V|) is Boolean, then: 1. If |types| includes a {{boolean}}, then return the result of [=converted to an IDL value|converting=] |V| to {{boolean}}. - 1. If |V| is a Number value, then: + 1. If [=Type=](|V|) is Number, then: 1. If |types| includes a [=numeric type=], then return the result of [=converted to an IDL value|converting=] |V| to that [=numeric type=]. @@ -9802,7 +9799,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is an Error object (that is, it has an \[[ErrorData]] [=internal slot=]) and + 1. Otherwise: if [=Type=](|V|) is Object, |V| 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, * {{Error!!interface}} * {{object}} @@ -9812,7 +9809,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is an object with an \[[ArrayBufferData]] [=internal slot=] and + 1. Otherwise: if [=Type=](|V|) is Object, |V| has 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, * {{ArrayBuffer}} * {{object}} @@ -9822,7 +9819,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is an object with a \[[DataView]] [=internal slot=] and + 1. Otherwise: if [=Type=](|V|) is Object, |V| has 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, * {{DataView}} * {{object}} @@ -9832,7 +9829,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is an object with a \[[TypedArrayName]] [=internal slot=] and + 1. Otherwise: if [=Type=](|V|) is Object, |V| has 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, * a [=typed array type=] whose name is equal to the value of |V|’s \[[TypedArrayName]] [=internal slot=] @@ -9853,7 +9850,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is any kind of object, and + 1. Otherwise: if [=Type=](|V|) is Object and there is an entry in |S| that has one of the following types at position |i| of its type list, * a [=sequence type=] @@ -9871,7 +9868,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] |method| is not undefined, then remove from |S| all other entries. - 1. Otherwise: if |V| is any kind of object, and + 1. Otherwise: if [=Type=](|V|) is Object and there is an entry in |S| that has one of the following types at position |i| of its type list, * a [=callback interface=] type * a [=dictionary type=] @@ -9883,7 +9880,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is a Boolean value, + 1. Otherwise: if [=Type=](|V|) is Boolean and there is an entry in |S| that has one of the following types at position |i| of its type list, * {{boolean}} * a [=nullable type|nullable=] {{boolean}} @@ -9892,7 +9889,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] then remove from |S| all other entries. - 1. Otherwise: if |V| is a Number value, + 1. Otherwise: if [=Type=](|V|) is Number and there is an entry in |S| that has one of the following types at position |i| of its type list, * a [=numeric type=] * a [=nullable type|nullable=] [=numeric type=] diff --git a/index.html b/index.html index 67ac3666..6a70ba3c 100644 --- a/index.html +++ b/index.html @@ -7430,7 +7430,7 @@

-

If V is a native Error object (that is, it has an [[ErrorData]] internal slot), then:

+

If Type(V) is Object and V has an [[ErrorData]] internal slot), then:

  1. If types includes Error, then return the @@ -7440,7 +7440,7 @@

    -

    If V is an object with an [[ArrayBufferData]] internal slot, then:

    +

    If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then:

    1. If types includes ArrayBuffer, then return the @@ -7450,7 +7450,7 @@

      -

      If V is an object with a [[DataView]] internal slot, then:

      +

      If Type(V) is Object and V has a [[DataView]] internal slot, then:

      1. If types includes DataView, then return the @@ -7460,7 +7460,7 @@

        -

        If V is an object with a [[TypedArrayName]] internal slot, then:

        +

        If Type(V) is Object and V has a [[TypedArrayName]] internal slot, then:

        1. If types includes a typed array type whose name is the value of V’s [[TypedArrayName]] internal slot, then return the @@ -7479,7 +7479,7 @@

          -

          If V is any kind of object, then:

          +

          If Type(V) is Object, then:

          1. If types includes a sequence type, then

            @@ -7501,7 +7501,7 @@

            ReturnIfAbrupt(method).

          2. If method is not undefined, -return the result of creating a frozen array of that type from V and method.

            +return the result of creating a frozen array of that type from V and method.

        2. If types includes a dictionary type, then return the @@ -7516,14 +7516,14 @@

          -

          If V is a Boolean value, then:

          +

          If Type(V) is Boolean, then:

          1. If types includes a boolean, then return the result of converting V to boolean.

        3. -

          If V is a Number value, then:

          +

          If Type(V) is Number, then:

          1. If types includes a numeric type, @@ -9028,7 +9028,7 @@

            -

            Otherwise: if V is an Error object (that is, it has an [[ErrorData]] internal slot) and +

            Otherwise: if Type(V) is Object, V 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,

            • @@ -9043,7 +9043,7 @@

              -

              Otherwise: if V is an object with an [[ArrayBufferData]] internal slot and +

              Otherwise: if Type(V) is Object, V has 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,

              • @@ -9058,7 +9058,7 @@

                -

                Otherwise: if V is an object with a [[DataView]] internal slot and +

                Otherwise: if Type(V) is Object, V has 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,

                • @@ -9073,7 +9073,7 @@

                  -

                  Otherwise: if V is an object with a [[TypedArrayName]] internal slot and +

                  Otherwise: if Type(V) is Object, V has 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,

                  • @@ -9104,7 +9104,7 @@

                    -

                    Otherwise: if V is any kind of object, and +

                    Otherwise: if Type(V) is Object and there is an entry in S that has one of the following types at position i of its type list,

                      @@ -9128,7 +9128,7 @@

                      -

                      Otherwise: if V is any kind of object, and +

                      Otherwise: if Type(V) is Object and there is an entry in S that has one of the following types at position i of its type list,

                      • @@ -9147,7 +9147,7 @@

                        -

                        Otherwise: if V is a Boolean value, +

                        Otherwise: if Type(V) is Boolean and there is an entry in S that has one of the following types at position i of its type list,

                        • @@ -9160,7 +9160,7 @@

                          -

                          Otherwise: if V is a Number value, +

                          Otherwise: if Type(V) is Number and there is an entry in S that has one of the following types at position i of its type list,

                          • From 29003c6a6b847ae39229cda4fb25c813f05bf82c Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Fri, 20 Jan 2017 21:04:44 +0100 Subject: [PATCH 2/2] Address review comments. --- index.bs | 60 ++++++++++---------------- index.html | 122 ++++++++++++++++++++++++----------------------------- 2 files changed, 79 insertions(+), 103 deletions(-) diff --git a/index.bs b/index.bs index fb16d339..19657eb7 100644 --- a/index.bs +++ b/index.bs @@ -6557,41 +6557,27 @@ Since the IDL {{any}} type is the union of all other IDL types, it can correspond to any ECMAScript value type. -

                            - How to [=converted to an IDL value|convert an ECMAScript value=] to an IDL {{any}} value depends on the type of the - ECMAScript value: -

                            +
                            -
                            - : The undefined value - :: The IDL value is an - {{object}} reference - to a special object that represents the ECMAScript - undefined value. - : The null value - :: The IDL value is the null - {{object|object?}} reference. - : A Boolean value - :: The IDL value is the - {{boolean}} - value that represents the same truth value. - : A Number value - :: The IDL value is that which is obtained - by following the rules for converting the - Number to an IDL - {{unrestricted double}} value, - as described in [[#es-unrestricted-double]]. - : A String value - :: The IDL value is that which is obtained - by following the rules for converting the - String to an IDL - {{DOMString}} value, - as described in [[#es-DOMString]]. - : An {{object}} value - :: The IDL value is an - {{object}} value that - references the same object. -
                            + An ECMAScript value |V| is [=converted to an IDL value|converted=] + to an IDL {{any}} value by running the following algorithm: + + 1. If |V| is undefined, then + return an {{object}} reference to a special object that represents + the ECMAScript undefined value. + 1. If |V| is null, then + return the null {{object|object?}} reference. + 1. If [=Type=](|V|) is Boolean, then + return the {{boolean}} value that represents the same truth value. + 1. If [=Type=](|V|) is Number, then + return the result of converting |V| + to an {{unrestricted double}}. + 1. If [=Type=](|V|) is String, then + return the result of converting |V| + to a {{DOMString}}. + 1. If [=Type=](|V|) is Object, then + return an IDL {{object}} value that references |V|. +

                            An IDL {{any}} value is @@ -7321,7 +7307,7 @@ ECMAScript Array values. An ECMAScript value |V| is [=converted to an IDL value|converted=] to an IDL sequence<T> value as follows: - 1. If |V| is not an object, + 1. If [=Type=](|V|) is not Object, [=ECMAScript/throw=] a TypeError. 1. Let |method| be the result of [=GetMethod=](|V|, [=@@iterator=]). @@ -10164,9 +10150,9 @@ whose value is the identifier of the corresponding interface. every [=interface object=] |A| must behave as follows, assuming |V| is the object argument passed to \[[HasInstance]]: - 1. If |V| is not an object, return false. + 1. If Type(|V|) is not Object, return false. 1. Let |O| be the result of calling the \[[Get]] method of |A| with property name “prototype”. - 1. If |O| is not an object, [=ECMAScript/throw=] a TypeError exception. + 1. If Type(|O|) is not Object, [=ECMAScript/throw=] a TypeError exception. 1. If |V| is a platform object that implements the interface for which |O| is the [=interface prototype object=], return true. diff --git a/index.html b/index.html index 6a70ba3c..6001cb9e 100644 --- a/index.html +++ b/index.html @@ -6409,41 +6409,31 @@

                            3

                            Since the IDL any type is the union of all other IDL types, it can correspond to any ECMAScript value type.

                            -

                            How to convert an ECMAScript value to an IDL any value depends on the type of the - ECMAScript value:

                            -
                            -
                            -

                            The undefined value

                            -
                            -

                            The IDL value is an object reference -to a special object that represents the ECMAScript undefined value.

                            -
                            -

                            The null value

                            -
                            -

                            The IDL value is the null object? reference.

                            -
                            -

                            A Boolean value

                            -
                            -

                            The IDL value is the boolean value that represents the same truth value.

                            -
                            -

                            A Number value

                            -
                            -

                            The IDL value is that which is obtained -by following the rules for converting the Number to an IDL unrestricted double value, -as described in §3.2.8 unrestricted double.

                            -
                            -

                            A String value

                            -
                            -

                            The IDL value is that which is obtained -by following the rules for converting the String to an IDL DOMString value, -as described in §3.2.9 DOMString.

                            -
                            -

                            An object value

                            -
                            -

                            The IDL value is an object value that -references the same object.

                            -
                            -

                            An IDL any value is converted to an ECMAScript value as follows. If the value is an object reference to a special object that represents an ECMAScript undefined value, then it is converted to the ECMAScript undefined value. Otherwise, +

                            +

                            An ECMAScript value V is converted to an IDL any value by running the following algorithm:

                            +
                              +
                            1. +

                              If V is undefined, then +return an object reference to a special object that represents +the ECMAScript undefined value.

                              +
                            2. +

                              If V is null, then +return the null object? reference.

                              +
                            3. +

                              If Type(V) is Boolean, then +return the boolean value that represents the same truth value.

                              +
                            4. +

                              If Type(V) is Number, then +return the result of converting V to an unrestricted double.

                              +
                            5. +

                              If Type(V) is String, then +return the result of converting V to a DOMString.

                              +
                            6. +

                              If Type(V) is Object, then +return an IDL object value that references V.

                              +
                            +
                            +

                            An IDL any value is converted to an ECMAScript value as follows. If the value is an object reference to a special object that represents an ECMAScript undefined value, then it is converted to the ECMAScript undefined value. Otherwise, the rules for converting the specific type of the IDL any value as described in the remainder of this section are performed.

                            3.2.2. void

                            @@ -6874,19 +6864,19 @@

                            3.2.12. object

                            -

                            IDL object values are represented by ECMAScript Object values.

                            +

                            IDL object values are represented by ECMAScript Object values.

                            -

                            An ECMAScript value V is converted to an IDL object value by running the following algorithm:

                            +

                            An ECMAScript value V is converted to an IDL object value by running the following algorithm:

                            1. If Type(V) is not Object, then throw a TypeError.

                            2. -

                              Return the IDL object value that is a reference to the same object as V.

                              +

                              Return the IDL object value that is a reference to the same object as V.

                            -

                            The result of converting an IDL object value to an ECMAScript +

                            The result of converting an IDL object value to an ECMAScript value is the Object value that represents a reference to the same object that the - IDL object represents.

                            + IDL object represents.

                            3.2.13. Interface types

                            IDL interface type values are represented by ECMAScript Object or Function values.

                            @@ -7073,7 +7063,7 @@

                            converted to an IDL sequence<T> value as follows:

                            1. -

                              If V is not an object, throw a TypeError.

                              +

                              If Type(V) is not Object, throw a TypeError.

                            2. Let method be the result of GetMethod(V, @@iterator).

                            3. @@ -7416,7 +7406,7 @@

                              If types includes an interface type that V implements, then return the IDL value that is a reference to the object V.

                            4. -

                              If types includes object, then return the IDL value +

                              If types includes object, then return the IDL value that is a reference to the object V.

                          • @@ -7426,7 +7416,7 @@

                            DOMException or Error, then return the result of converting V to that type.

                          • -

                            If types includes object, then return the IDL value +

                            If types includes object, then return the IDL value that is a reference to the object V.

        4. @@ -7436,7 +7426,7 @@

          Error, then return the result of converting V to Error.

        5. -

          If types includes object, then return the IDL value +

          If types includes object, then return the IDL value that is a reference to the object V.

      2. @@ -7446,7 +7436,7 @@

        ArrayBuffer, then return the result of converting V to ArrayBuffer.

      3. -

        If types includes object, then return the IDL value +

        If types includes object, then return the IDL value that is a reference to the object V.

    2. @@ -7456,7 +7446,7 @@

      DataView, then return the result of converting V to DataView.

    3. -

      If types includes object, then return the IDL value +

      If types includes object, then return the IDL value that is a reference to the object V.

  2. @@ -7466,7 +7456,7 @@

    typed array type whose name is the value of V’s [[TypedArrayName]] internal slot, then return the result of converting V to that type.

  3. -

    If types includes object, then return the IDL value +

    If types includes object, then return the IDL value that is a reference to the object V.

  • @@ -7475,7 +7465,7 @@

    If types includes a callback function type, then return the result of converting V to that callback function type.

  • -

    If types includes object, then return the IDL value +

    If types includes object, then return the IDL value that is a reference to the object V.

  • @@ -7512,7 +7502,7 @@

    If types includes a callback interface type, then return the result of converting V to that interface type.

  • -

    If types includes object, then return the IDL value +

    If types includes object, then return the IDL value that is a reference to the object V.

  • @@ -7542,7 +7532,7 @@

    Throw a TypeError.

    -

    An IDL union type value is converted to an ECMAScript value as follows. If the value is an object reference to a special object that represents an ECMAScript undefined value, then it is converted to the ECMAScript undefined value. Otherwise, +

    An IDL union type value is converted to an ECMAScript value as follows. If the value is an object reference to a special object that represents an ECMAScript undefined value, then it is converted to the ECMAScript undefined value. Otherwise, the rules for converting the specific type of the IDL union type value as described in this section (§3.2 ECMAScript type mapping).

    3.2.22. Error

    IDL Error values are represented @@ -8620,7 +8610,7 @@

    take no arguments.

    The [SameObject] extended attribute must not -be used on anything other than a read only attribute whose type is an interface type or object.

    +be used on anything other than a read only attribute whose type is an interface type or object.

    As an example, this extended attribute is suitable for use on @@ -9002,7 +8992,7 @@

    an interface type that V implements

  • -

    object

    +

    object

  • a nullable version of any of the above types

  • @@ -9019,7 +9009,7 @@

    Error

  • -

    object

    +

    object

  • a nullable version of either of the above types

  • @@ -9034,7 +9024,7 @@

    Error

  • -

    object

    +

    object

  • a nullable version of either of the above types

  • @@ -9049,7 +9039,7 @@

    ArrayBuffer

  • -

    object

    +

    object

  • a nullable version of either of the above types

  • @@ -9064,7 +9054,7 @@

    DataView

  • -

    object

    +

    object

  • a nullable version of either of the above types

  • @@ -9080,7 +9070,7 @@

    typed array type whose name is equal to the value of V’s [[TypedArrayName]] internal slot

  • -

    object

    +

    object

  • a nullable version of either of the above types

  • @@ -9095,7 +9085,7 @@

    a callback function type

  • -

    object

    +

    object

  • a nullable version of any of the above types

  • @@ -9138,7 +9128,7 @@

    a record type

  • -

    object

    +

    object

  • a nullable version of any of the above types

  • @@ -9431,11 +9421,11 @@
    < assuming V is the object argument passed to [[HasInstance]]:

    1. -

      If V is not an object, return false.

      +

      If Type(V) is not Object, return false.

    2. Let O be the result of calling the [[Get]] method of A with property name “prototype”.

    3. -

      If O is not an object, throw a TypeError exception.

      +

      If Type(O) is not Object, throw a TypeError exception.

    4. If V is a platform object that implements the interface for which O is the interface prototype object, @@ -14823,11 +14813,11 @@

      I