Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: Interaction with the Stage 2 Record & Tuple proposal for ECMAScript #1184

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -7747,19 +7747,20 @@ values are represented by ECMAScript Object values (including [=function objects
<h4 id="es-dictionary">Dictionary types</h4>

IDL [=dictionary type=] values are represented
by ECMAScript Object values. Properties on
the object (or its prototype chain) correspond to [=dictionary members=].
by ECMAScript Object or Record values. Properties on the
object (or its prototype chain) or the record correspond to [=dictionary members=].

<div id="es-to-dictionary" algorithm="convert an ECMAScript value to dictionary">

An ECMAScript value |esDict| is [=converted to an IDL value|converted=]
to an IDL [=dictionary type=] value by
running the following algorithm (where |D| is the [=dictionary type=]):

1. If <a abstract-op>Type</a>(|esDict|) is not Undefined, Null or Object, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
1. If <a abstract-op>Type</a>(|esDict|) is not Undefined, Null, Object or Record, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
1. Let |idlDict| be an empty [=ordered map=], representing a dictionary of type |D|.
1. Let |dictionaries| be a list consisting of |D| and all of |D|'s [=inherited dictionaries=],
in order from least to most derived.
1. Let |obj| be [=?=] <a abstract-op>ToObject</a>(|esDict|) if <a abstract-op>Type</a>(|esDict|) is not Undefined or Null
1. For each dictionary |dictionary| in |dictionaries|, in order:
1. For each dictionary member |member| declared on |dictionary|, in lexicographical order:
1. Let |key| be the [=identifier=] of |member|.
Expand All @@ -7769,7 +7770,7 @@ the object (or its prototype chain) correspond to [=dictionary members=].
: Null
:: <emu-val>undefined</emu-val>
: anything else
:: [=?=] <a abstract-op>Get</a>(|esDict|, |key|)
:: [=?=] <a abstract-op>Get</a>(|obj|, |key|)
</dl>
1. If |esMemberValue| is not <emu-val>undefined</emu-val>, then:
1. Let |idlMemberValue| be the result of [=converted to an IDL value|converting=] |esMemberValue| to an IDL value whose type is the type |member| is declared to be of.
Expand All @@ -7783,7 +7784,7 @@ the object (or its prototype chain) correspond to [=dictionary members=].
</div>

Note: The order that [=dictionary members=] are looked
up on the ECMAScript object are not necessarily the same as the object's property enumeration order.
up on the ECMAScript object or record are not necessarily the same as the object's or record's property enumeration order.

<div id="dictionary-to-es" algorithm="convert a dictionary to an ECMAScript value">

Expand Down Expand Up @@ -7914,14 +7915,14 @@ the ECMAScript <emu-val>null</emu-val> value.
<h4 id="es-sequence">Sequences — sequence&lt;|T|&gt;</h4>

IDL <a lt="sequence type">sequence&lt;|T|&gt;</a> values are represented by
ECMAScript Array values.
ECMAScript Array or Tuple values.

<div id="es-to-sequence" algorithm="convert an ECMAScript value to sequence">

An ECMAScript value |V| is [=converted to an IDL value|converted=]
to an IDL <a lt="sequence type">sequence&lt;<var ignore>T</var>&gt;</a> value as follows:

1. If <a abstract-op>Type</a>(|V|) is not Object,
1. If <a abstract-op>Type</a>(|V|) is not Object or Tuple,
[=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
1. Let |method| be [=?=] <a abstract-op>GetMethod</a>(|V|, {{@@iterator}}).
1. If |method| is <emu-val>undefined</emu-val>,
Expand Down