Skip to content

Commit 8e1b529

Browse files
committed
Add an algorithm to create a platform object
1 parent 7769c5f commit 8e1b529

File tree

1 file changed

+82
-33
lines changed

1 file changed

+82
-33
lines changed

index.bs

Lines changed: 82 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
125125
text: DefinePropertyOrThrow; url: sec-definepropertyorthrow
126126
text: DetachArrayBuffer; url: sec-detacharraybuffer
127127
text: Get; url: sec-get-o-p
128+
text: GetFunctionRealm; url: sec-getfunctionrealm
128129
text: GetIterator; url: sec-getiterator
129130
text: GetMethod; url: sec-getmethod
130131
text: IsAccessorDescriptor; url: sec-isaccessordescriptor
@@ -189,6 +190,7 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
189190
text: internal method
190191
text: internal slot
191192
text: Number type; url: sec-ecmascript-language-types-number-type
193+
text: Object; for: ECMAScript; url: sec-object-type
192194
for: ordinary object; url: sec-ordinary-object-internal-methods-and-internal-slots
193195
text: internal method
194196
text: internal slot
@@ -870,6 +872,19 @@ its inheritance hierarchy has a cycle. That is, an interface
870872
|A| cannot inherit from itself, nor can it inherit from another
871873
interface |B| that inherits from |A|, and so on.
872874

875+
<div algorithm>
876+
The [=list=] of <dfn for=interface>inclusive inherited interfaces</dfn> of an [=interface=] |I|
877+
is defined as follows:
878+
879+
1. Let |result| be « ».
880+
1. Let |interface| be |I|.
881+
1. While |interface| is not null:
882+
1. [=list/Append=] |interface| to |result|.
883+
1. Set |interface| to the [=interface=] that |I| [=interface/inherits=] from, if any, and
884+
null otherwise.
885+
1. Return |result|.
886+
</div>
887+
873888
Note that general multiple inheritance of interfaces is not supported, and
874889
objects also cannot implement arbitrary sets of interfaces.
875890
Objects can be defined to implement a single given interface |A|,
@@ -10700,11 +10715,14 @@ the <code>typeof</code> operator will return "function" when applied to an inter
1070010715
1. Let &lt;|constructor|, |values|&gt; be the result
1070110716
of passing |S| and |args|.
1070210717
to the [=overload resolution algorithm=].
10703-
1. Let |R| be the result of performing
10704-
the actions listed in the description of |constructor|
10705-
with |values| as the argument values.
10718+
1. Let |object| be the result of [=internally create a new object implementing the
10719+
interface|internally creating a new object implementing=] |I|, with |realm| and
10720+
{{NewTarget}}.
10721+
1. Perform the actions listed in the description of |constructor|
10722+
with |values| as the argument values
10723+
and |object| as the <emu-val>this</emu-val> value.
1070610724
Rethrow any exceptions.
10707-
1. Let |O| be the result of [=converted to an ECMAScript value|converting=] |R|
10725+
1. Let |O| be the result of [=converted to an ECMAScript value|converting=] |object|
1070810726
to an ECMAScript [=interface type=] value |I|.
1070910727
1. Assert: |O| is an object that implements |I|.
1071010728
1. Assert: |O|.\[[Realm]] is equal to |realm|.
@@ -12347,12 +12365,65 @@ It is the responsibility of specifications using Web IDL to state
1234712365
which global environment (or, by proxy, which global object) each platform
1234812366
object is associated with.
1234912367

12368+
<div algorithm>
12369+
To <dfn export lt=new>create a new object implementing the interface</dfn> |interface|, with a
12370+
Realm |realm|, perform the following steps:
12371+
12372+
1. Return the result of [=internally create a new object implementing the
12373+
interface|internally creating a new object implementing=] |interface|, with |realm| and
12374+
<emu-val>undefined</emu-val>.
12375+
</div>
12376+
12377+
<div algorithm>
12378+
To <dfn>internally create a new object implementing the interface</dfn> |interface|, with a
12379+
Realm |realm| and a JavaScript value |newTarget|, perform the following steps:
12380+
12381+
1. Assert: |interface| is [=exposed=] in |realm|.
12382+
1. If |newTarget| is <emu-val>undefined</emu-val>, then:
12383+
1. Let |prototype| be the [=interface prototype object=] for |interface| in
12384+
|realm|.
12385+
1. Otherwise:
12386+
1. Assert: [$IsCallable$](|newTarget|) is true.
12387+
1. Let |prototype| be [=?=] [$Get$](|newTarget|, "prototype").
12388+
1. If [$Type$](|prototype|) is not Object, then:
12389+
1. Let |targetRealm| be [$GetFunctionRealm$](|newTarget|).
12390+
1. Set |prototype| to the [=interface prototype object=] for |interface| in
12391+
|targetRealm|.
12392+
1. Let |instance| be a newly created [=ECMAScript/object=] in |realm|.
12393+
1. Set |instance|.\[[Prototype]] to |prototype|.
12394+
1. Set |instance|'s essential internal methods to the definitions specified in
12395+
[=ECMA-262 Ordinary object internal methods and internal slots=].
12396+
1. Let |interfaces| be the [=inclusive inherited interfaces=] of |interface|.
12397+
1. [=list/iterate|For every=] [=interface=] |ancestor interface| in |interfaces|:
12398+
1. [=Define the unforgeable regular operations=] of |ancestor interface| on |instance|,
12399+
given |realm|.
12400+
1. [=Define the unforgeable regular attributes=] of |ancestor interface| on |instance|,
12401+
given |realm|.
12402+
1. If |interface| is declared with the [{{Global}}] [=extended attribute=], then:
12403+
1. [=Define the regular operations=] of |interface| on |instance|, given |realm|.
12404+
1. [=Define the regular attributes=] of |interface| on |instance|, given |realm|.
12405+
1. Set |instance|.\[[SetPrototypeOf]] as defined in [[#platform-object-setprototypeof]].
12406+
1. Otherwise, if |interfaces| contains an [=interface=] which
12407+
[=support indexed properties|supports indexed properties=],
12408+
[=support named properties|named properties=], or both:
12409+
1. Set |instance|.\[[GetOwnProperty]] as defined in
12410+
[[#legacy-platform-object-getownproperty]].
12411+
1. Set |instance|.\[[Set]] as defined in
12412+
[[#legacy-platform-object-set]].
12413+
1. Set |instance|.\[[DefineOwnProperty]] as defined in
12414+
[[#legacy-platform-object-defineownproperty]].
12415+
1. Set |instance|.\[[Delete]] as defined in
12416+
[[#legacy-platform-object-delete]].
12417+
1. Set |instance|.\[[PreventExtensions]] as defined in
12418+
[[#legacy-platform-object-preventextensions]].
12419+
1. Set |instance|.\[[OwnPropertyKeys]] as defined in
12420+
[[#legacy-platform-object-ownpropertykeys]].
12421+
1. Return |instance|.
12422+
</div>
12423+
1235012424
The <dfn id="dfn-primary-interface" export>primary interface</dfn> of a platform object
1235112425
that implements one or more interfaces is the most-derived [=interface=]
12352-
that it implements. The value of the \[[Prototype]] [=internal slot=]
12353-
of the platform object is the [=interface prototype object=]
12354-
of the [=primary interface=]
12355-
from the [=platform object=]’s associated global environment.
12426+
that it implements.
1235612427

1235712428
The global environment that a given [=platform object=]
1235812429
is associated with can <dfn id="dfn-change-global-environment" for="global environment" export>change</dfn> after it has been created. When
@@ -12368,24 +12439,6 @@ must be the [=qualified name=] of
1236812439
the [=primary interface=]
1236912440
of the platform object.
1237012441

12371-
[=Platform objects=] which implement an [=interface=] which has a [{{Global}}]
12372-
[=extended attribute=] have an internal \[[SetPrototypeOf]] method
12373-
as defined in [[#platform-object-setprototypeof]].
12374-
12375-
Within a [=Realm=] |realm|,
12376-
for each [=interface=] |interface| implemented by a [=platform object=] |obj|,
12377-
the following steps must be run as part of |obj|'s creation:
12378-
12379-
1. [=Define the unforgeable regular operations=] of |interface| on |obj|, given |realm|.
12380-
1. [=Define the unforgeable regular attributes=] of |interface| on |obj|, given |realm|.
12381-
12382-
If within a [=Realm=] |realm| a [=platform object=] |obj| implements
12383-
an interface |interface| which is declared with the [{{Global}}] [=extended attribute=], then
12384-
the following steps must be run as part of |obj|'s creation:
12385-
12386-
1. [=Define the regular operations=] of |interface| on |obj|, given |realm|.
12387-
1. [=Define the regular attributes=] of |interface| on |obj|, given |realm|.
12388-
1238912442
Additionally, [=platform objects=] which implement an [=interface=]
1239012443
which has a [{{Global}}] [=extended attribute=]
1239112444
get properties declaratively from:
@@ -12447,14 +12500,12 @@ Support for [=getters=] is handled in [[#legacy-platform-object-getownproperty]]
1244712500
and for [=setters=] in [[#legacy-platform-object-defineownproperty]]
1244812501
and [[#legacy-platform-object-set]].
1244912502

12450-
Additionally, [=legacy platform objects=] must have internal methods as defined in:
12503+
Additionally, [=legacy platform objects=] have internal methods as defined in:
1245112504

1245212505
* [[#legacy-platform-object-delete]],
1245312506
* [[#legacy-platform-object-preventextensions]], and
1245412507
* [[#legacy-platform-object-ownpropertykeys]].
1245512508

12456-
Issue: Define those internal methods imperatively instead.
12457-
1245812509

1245912510
<h4 id="legacy-platform-object-getownproperty" dfn oldids="getownproperty" lt=GetOwnProperty for="legacy platform object">\[[GetOwnProperty]]</h4>
1246012511

@@ -13325,10 +13376,8 @@ Each {{DOMException}} object has an associated <dfn for="DOMException">name</dfn
1332513376
The <dfn constructor for="DOMException"><code>DOMException(|message|, |name|)</code></dfn>
1332613377
constructor, when invoked, must run these steps:
1332713378

13328-
1. Let |e| be a new {{DOMException}} object.
13329-
1. Set |e|'s [=DOMException/name=] to |name|.
13330-
1. Set |e|'s [=DOMException/message=] to |message|.
13331-
1. Return |e|.
13379+
1. Set <emu-val>this</emu-val>'s [=DOMException/name=] to |name|.
13380+
1. Set <emu-val>this</emu-val>'s [=DOMException/message=] to |message|.
1333213381

1333313382
The <dfn attribute for="DOMException"><code>name</code></dfn> attribute's getter must return this
1333413383
{{DOMException}} object's [=DOMException/name=].

0 commit comments

Comments
 (0)