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

TimothyGu commented on this pull request.



> @@ -12410,6 +12453,24 @@ attribute is the concatenation of the class string of the namespace, ".",
 and the class string that the interface would otherwise have without this
 extended attribute.
 
+
+<div algorithm>
+
+    A [=platform object=] implementing an [=interface=] |interface|, in [=Realm=] |realm|,

This needs to somehow say that *interface* is the [primary interface](https://heycam.github.io/webidl/#dfn-primary-interface), because a platform object can implement many different interfaces (i.e., inherited interfaces; so glad consequential interfaces are gone).

> @@ -12410,6 +12453,24 @@ attribute is the concatenation of the class string of the namespace, ".",
 and the class string that the interface would otherwise have without this
 extended attribute.
 
+
+<div algorithm>
+
+    A [=platform object=] implementing an [=interface=] |interface|, in [=Realm=] |realm|,
+    and with optional [=list=] of [=internal slots=] |internalSlotsList|,
+    is <dfn lt="create a platform object">created</dfn> as follows:
+
+    1.  Let |proto| be the [=interface prototype object=] for |interface| in |realm|.
+    1.  Let |obj| be [=ObjectCreate=](|proto|, |internalSlotsList|).
+    1.  Set |obj|.\[[SetPrototypeOf]] to the definition specified in [[#platform-object-setprototypeof]].

> ... the [[SetPrototypeOf]] internal method of a platform object *O* that **implements an interface with the [`Global`] extended attribute** is called ...

I admit I didn't see this condition until now either, but this PR should improve that.

Also this section needs to account for legacy platform objects as well.

1. Let *obj* be a newly created object.
2. If *interface* has a [`Global`] extended attribute, then set *obj*.[[SetPrototypeOf]] to ...
3. Otherwise, if *interface* supports indexed properties or named properties, then *obj* is a legacy platform object. Set *obj*'s internal methods to ... [those defined for legacy platform objects]

    *Right now, it's not very clear what happens if *interface* inherits from an interface that supports indexed/named properties. https://heycam.github.io/webidl/#idl-special-operations says:*

    > If an object implements more than one interface that defines a given special operation, then it is undefined which (if any) special operation is invoked for that operation.

    *so I assume it should support having inherited interfaces that have special operations. Yet, the definition for [support indexed properties](https://heycam.github.io/webidl/#dfn-support-indexed-properties), which [legacy platform object](https://heycam.github.io/webidl/#dfn-legacy-platform-object) uses, does not account for the possibility of inheriting a special operation. We should take care of this soon.*

4. If the specification defining *interface* provides an alternative definition for one or more internal methods for objects implementing *interface*, set *obj*'s internal methods accordingly.

5. Set all remaining internal methods of *obj* to the definitions specified in ECMA-262 section 9.1.

-- 
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-89924732

Received on Thursday, 18 January 2018 20:51:56 UTC