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

TimothyGu commented on this pull request.

Nice work, though operations from special declarations like iterable, maplike, and setlike still need to be defined. You probably already know this but spelling it out so that it doesn't get forgotten :)

> +    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|,

["exposed"](https://heycam.github.io/webidl/#dfn-expose) right now seems to be only defined for interfaces, not members of interfaces.

> +        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|.
+        1.  Let |setter| be the result of creating an [=attribute setter=]
+            given |attr|, |interface|,  and |realm|.
+
+            Note: the algorithm to create an [=attribute setter=]
+            returns <emu-val>undefined</emu-val> if |attr| is [=read only=].
+        1.  Let |desc| be the PropertyDescriptor{\[[Get]]: |getter|, \[[Set]]: |setter|,
+            \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>true</emu-val>}.

This needs some more work based on https://heycam.github.io/webidl/#es-attributes, specifically about unforgeability. Same for operations.

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

Received on Sunday, 10 December 2017 23:28:06 UTC