Re: [heycam/webidl] Make interface prototype object creation imperative (#494)

TimothyGu commented on this pull request.



> -    1.  Otherwise, if |A| is declared to inherit from another
-        interface, then return the
-        [=interface prototype object=]
-        for the inherited interface.
-    1.  Otherwise, if |A| is declared with the [{{LegacyArrayClass}}]
-        extended attribute, then return {{%ArrayPrototype%}}.
-    1.  Otherwise, return {{%ObjectPrototype%}}.
+    1.  Let |proto| be null.
+    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
+        and |interface| [=support named properties|supports named properties=],
+        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to the {{%ArrayPrototype%}} of |realm|.

`|realm|.[[Intrinsics]].[[{{%ArrayPrototype%}}]]`

Check out https://tc39.github.io/ecma262/#table-21.

> -        interface, then return the
-        [=interface prototype object=]
-        for the inherited interface.
-    1.  Otherwise, if |A| is declared with the [{{LegacyArrayClass}}]
-        extended attribute, then return {{%ArrayPrototype%}}.
-    1.  Otherwise, return {{%ObjectPrototype%}}.
+    1.  Let |proto| be null.
+    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
+        and |interface| [=support named properties|supports named properties=],
+        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to the {{%ArrayPrototype%}} of |realm|.
+    1.  Otherwise, set |proto| to the {{%ObjectPrototype%}} of |realm|.

Ditto.

> -        [=interface prototype object=]
-        for the inherited interface.
-    1.  Otherwise, if |A| is declared with the [{{LegacyArrayClass}}]
-        extended attribute, then return {{%ArrayPrototype%}}.
-    1.  Otherwise, return {{%ObjectPrototype%}}.
+    1.  Let |proto| be null.
+    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
+        and |interface| [=support named properties|supports named properties=],
+        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to the {{%ArrayPrototype%}} of |realm|.
+    1.  Otherwise, set |proto| to the {{%ObjectPrototype%}} of |realm|.
+    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(proto).

`|proto|`

> +    1.  Let |proto| be null.
+    1.  If |interface| is declared with the [{{Global}}] [=extended attribute=],
+        and |interface| [=support named properties|supports named properties=],
+        then set |proto| to the [=named properties object=] of |interface|,
+        as defined in [[#named-properties-object]].
+    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to the {{%ArrayPrototype%}} of |realm|.
+    1.  Otherwise, set |proto| to the {{%ObjectPrototype%}} of |realm|.
+    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(proto).
+    1.  Let |unscopableObject| be null.
+    1.  If |interface| has any [=member=] declared with the [{{Unscopable}}] [=extended attribute=],
+        then:
+        1.  Set |unscopableObject| to be [=!=]
+            <a abstract-op>ObjectCreate</a>({{%ObjectPrototype%}} of |realm|).

Ditto.

> +    1.  Otherwise, if |interface| is declared to inherit from another interface,
+        then set |proto| to the [=interface prototype object=] of the inherited interface.
+    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to the {{%ArrayPrototype%}} of |realm|.
+    1.  Otherwise, set |proto| to the {{%ObjectPrototype%}} of |realm|.
+    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(proto).
+    1.  Let |unscopableObject| be null.
+    1.  If |interface| has any [=member=] declared with the [{{Unscopable}}] [=extended attribute=],
+        then:
+        1.  Set |unscopableObject| to be [=!=]
+            <a abstract-op>ObjectCreate</a>({{%ObjectPrototype%}} of |realm|).
+        1.  Let |desc| be the PropertyDescriptor{\[[Writable]]: <emu-val>false</emu-val>,
+            \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>true</emu-val>,
+            \[[Value]]: |unscopableObject|}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, {{@@unscopables}}, |desc|).
+    1.  For each [=exposed=] [=regular attribute=] |attr| that is a [=member=] of |interface|,

Infra says this step should end with a colon instead of a comma.

> +    1.  Otherwise, if |interface| is declared with the [{{LegacyArrayClass}}] [=extended attribute=],
+        then set |proto| to the {{%ArrayPrototype%}} of |realm|.
+    1.  Otherwise, set |proto| to the {{%ObjectPrototype%}} of |realm|.
+    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(proto).
+    1.  Let |unscopableObject| be null.
+    1.  If |interface| has any [=member=] declared with the [{{Unscopable}}] [=extended attribute=],
+        then:
+        1.  Set |unscopableObject| to be [=!=]
+            <a abstract-op>ObjectCreate</a>({{%ObjectPrototype%}} of |realm|).
+        1.  Let |desc| be the PropertyDescriptor{\[[Writable]]: <emu-val>false</emu-val>,
+            \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>true</emu-val>,
+            \[[Value]]: |unscopableObject|}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, {{@@unscopables}}, |desc|).
+    1.  For each [=exposed=] [=regular attribute=] |attr| that is a [=member=] of |interface|,
+        1.  Let |getter| be the result of creating an [=attribute getter=]
+            given |attr|, |interface|,  and |realm|.

nit: extra space before `and`. Ditto two lines down.

> +        1.  Let |desc| be the PropertyDescriptor{\[[Writable]]: <emu-val>false</emu-val>,
+            \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>false</emu-val>,
+            \[[Value]]: |value|}.
+        1.  Let |id| be |const|'s [=identifier=].
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, |id|, |desc|).
+    1.  If the [{{NoInterfaceObject}}] [=extended attribute=] was not specified on |interface|, then:
+        1.  Let |constructor| be the [=interface object=] of |interface|.
+        1.  Let |desc| be the PropertyDescriptor{\[[Writable]]: <emu-val>true</emu-val>,
+            \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>true</emu-val>,
+            \[[Value]]: |constructor|}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, "<code>constructor</code>", |desc|).
+    1.  Let |value| be the concatenation of the |interface|’s [=identifier=]
+        and the string "<code>Prototype</code>".
+    1.  Let |desc| be the PropertyDescriptor{\[[Writable]]: <emu-val>false</emu-val>,
+        \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>false</emu-val>,
+        \[[Value]]: |value|}.

https://heycam.github.io/webidl/#issue-48167bcc says:

> Should define whether `@@toStringTag` is writable, enumerable and configurable. All `@@toStringTag` properties in the ECMAScript spec are non-writable and non-enumerable, and configurable.

I assume this "issue" has been resolved?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/494#pullrequestreview-82366312

Received on Sunday, 10 December 2017 23:16:58 UTC