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

tobie commented on this pull request.



> +            given |op|, |interface|, and |realm|.
+        1.  Let |modifiable| be <emu-val>false</emu-val> if |op| is [=unforgeable=]
+            and <emu-val>true</emu-val> otherwise.
+        1.  Let |desc| be the PropertyDescriptor{\[[Value]]: |method|,
+            \[[Writable]]: |modifiable|, \[[Enumerable]]: <emu-val>true</emu-val>,
+            \[[Configurable]]: |modifiable|}.
+        1.  Let |id| be |op|'s [=identifier=].
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, |id|, |desc|).
+    1.  [=Expose the constants=] of |interface| on |interfaceProtoObj|.
+    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.  Return |interfaceProtoObj|.

I'll add them in. Wanted to make sure there was agreement to do it this way before proceeding.

>  
-*   The name of the property is the [=identifier=] of the [=constant=].
-*   The location of the property is determined as follows:
-    *   If the interface was declared with the [{{Global}}] [=extended attribute=],
-        then the property exists on the single object that implements the interface.
-    *   Otherwise, if the interface has an [=interface prototype object=],
-        then the property exists on it.
-*   The value of the property is that which is obtained by [=converted to an ECMAScript value|converting=] the [=constant=]’s IDL value to an ECMAScript value.
-*   The property has attributes { \[[Writable]]: <emu-val>false</emu-val>, \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>false</emu-val> }.
+<div algorithm>
+    To <dfn>expose the constants</dfn> of [=interface=] |interface| on |target|,

Still TODO.  

> -        the interface or if the interface was declared with the [{{Global}}] [=extended attribute=],
-        then the property exists on every object that implements the interface.
-    *   Otherwise, the property exists solely on the interface’s [=interface prototype object=].
-*   The property has attributes { \[[Get]]: |G|, \[[Set]]: |S|, \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: |configurable| },
-    where:
-    *   |configurable| is <emu-val>false</emu-val> if the attribute was
-        declared with the [{{Unforgeable}}] extended attribute and <emu-val>true</emu-val> otherwise;
-    *   |G| is the [=attribute getter=] created given the attribute, the interface,
-        and the [=relevant Realm=] of the object that is the location of the property; and
-    *   |S| is the [=attribute setter=] created given the attribute, the interface,
-        and the [=relevant Realm=] of the object that is the location of the property.
+<div algorithm>
+    To <dfn>expose the regular attributes</dfn> of [=interface=] |interface| on |target|, given [=Realm=] |realm|, 
+    run the following steps:
+
+    1.  Let |attribues| be the [=list=] of [=exposed=] [=regular attributes=] that are [=members=] of |interface|.

Thanks for catching this!

> +    1.  Let |interfaceProtoObj| be [=!=] <a abstract-op>ObjectCreate</a>(|proto|).
+    1.  If |interface| has any [=member=] declared with the [{{Unscopable}}] [=extended attribute=],
+        then:
+        1.  Let |unscopableObject| be the result of performing [=!=]
+            <a abstract-op>ObjectCreate</a>(|realm|.\[[Intrinsics]].[[{{%ObjectPrototype%}}]]).
+        1.  Let |desc| be the PropertyDescriptor{\[[Value]]: |unscopableObject|,
+            \[[Writable]]: <emu-val>false</emu-val>, \[[Enumerable]]: <emu-val>false</emu-val>,
+            \[[Configurable]]: <emu-val>true</emu-val>}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, {{@@unscopables}}, |desc|).
+        1.  [=list/For each=] [=exposed=] [=member=] |member| of |interface|
+            that is declared with the [{{Unscopable}}] [=extended attribute=]:
+            1.  Let |id| be |member|'s [=identifier=].
+            1.  Perform [=!=] <a abstract-op>CreateDataProperty</a>(|unscopableObject|, |id|,
+                <emu-val>true</emu-val>).
+    1.  [=Expose the regular attributes=] of |interface| on |interfaceProtoObj| given |realm|.
+    1.  [=list/For each=] [=exposed=] [=regular operation=] |op| that is a [=member=] of |interface|:

Yeah, have finished this part yet.

> +            \[[Configurable]]: <emu-val>true</emu-val>}.
+        1.  Perform [=!=] <a abstract-op>DefinePropertyOrThrow</a>(|interfaceProtoObj|, {{@@unscopables}}, |desc|).
+        1.  [=list/For each=] [=exposed=] [=member=] |member| of |interface|
+            that is declared with the [{{Unscopable}}] [=extended attribute=]:
+            1.  Let |id| be |member|'s [=identifier=].
+            1.  Perform [=!=] <a abstract-op>CreateDataProperty</a>(|unscopableObject|, |id|,
+                <emu-val>true</emu-val>).
+    1.  [=Expose the regular attributes=] of |interface| on |interfaceProtoObj| given |realm|.
+    1.  [=list/For each=] [=exposed=] [=regular operation=] |op| that is a [=member=] of |interface|:
+        1.  Let |method| be the result of [=creating an operation function|creating an operation function=]
+            given |op|, |interface|, and |realm|.
+        1.  Let |modifiable| be <emu-val>false</emu-val> if |op| is [=unforgeable=]
+            and <emu-val>true</emu-val> otherwise.
+        1.  Let |desc| be the PropertyDescriptor{\[[Value]]: |method|,
+            \[[Writable]]: |modifiable|, \[[Enumerable]]: <emu-val>true</emu-val>,
+            \[[Configurable]]: |modifiable|}.

Unforgeable regular operations never get that far. This is only for static unforgeable ones (and will be on the object itself for regular ops once we add a "create platform object" algorithm).

>  
-*   The name of the property is the [=identifier=] of the [=constant=].
-*   The location of the property is determined as follows:
-    *   If the interface was declared with the [{{Global}}] [=extended attribute=],
-        then the property exists on the single object that implements the interface.
-    *   Otherwise, if the interface has an [=interface prototype object=],
-        then the property exists on it.
-*   The value of the property is that which is obtained by [=converted to an ECMAScript value|converting=] the [=constant=]’s IDL value to an ECMAScript value.
-*   The property has attributes { \[[Writable]]: <emu-val>false</emu-val>, \[[Enumerable]]: <emu-val>true</emu-val>, \[[Configurable]]: <emu-val>false</emu-val> }.
+<div algorithm>
+    To <dfn>expose the constants</dfn> of [=interface=] |interface| on |target|,

oh, true. Not passing it explicitly to exposed yet, however.

-- 
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#discussion_r158342824

Received on Monday, 8 January 2018 16:40:20 UTC