From 9e02bc7a38282462ed3e930272aab3583ccec484 Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Thu, 4 Aug 2022 17:15:55 +0100 Subject: [PATCH 1/5] wip: describe record to dictionary conversion --- index.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index 4537b352..fb4dd14e 100644 --- a/index.bs +++ b/index.bs @@ -7747,8 +7747,8 @@ values are represented by ECMAScript Object values (including [=function objects

Dictionary types

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=].
@@ -7756,7 +7756,7 @@ the object (or its prototype chain) correspond to [=dictionary members=]. to an IDL [=dictionary type=] value by running the following algorithm (where |D| is the [=dictionary type=]): - 1. If Type(|esDict|) is not Undefined, Null or Object, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. + 1. If Type(|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. @@ -7769,7 +7769,7 @@ the object (or its prototype chain) correspond to [=dictionary members=]. : Null :: undefined : anything else - :: [=?=] Get(|esDict|, |key|) + :: [=?=] Get([=?=] ToObject(|esDict|), |key|) 1. If |esMemberValue| is not undefined, 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. @@ -7783,7 +7783,7 @@ the object (or its prototype chain) correspond to [=dictionary members=].
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.
From af2d4cf6a848b9021cd85dfa4a123fdad4997891 Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Thu, 4 Aug 2022 17:36:22 +0100 Subject: [PATCH 2/5] wip: attempt to make tuples into sequences --- index.bs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index fb4dd14e..76aa6667 100644 --- a/index.bs +++ b/index.bs @@ -7914,16 +7914,17 @@ the ECMAScript null value.

Sequences — sequence<|T|>

IDL sequence<|T|> values are represented by -ECMAScript Array values. +ECMAScript Array or Tuple values.
An ECMAScript value |V| is [=converted to an IDL value|converted=] to an IDL sequence<T> value as follows: - 1. If Type(|V|) is not Object, + 1. If Type(|V|) is not Object or Tuple, [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. - 1. Let |method| be [=?=] GetMethod(|V|, {{@@iterator}}). + 1. Let |obj| be [=?=] ToObject(|V|) + 1. Let |method| be [=?=] GetMethod(|obj|, {{@@iterator}}). 1. If |method| is undefined, [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. 1. Return the result of [=creating a sequence from an iterable|creating a sequence=] From 796137861042f8d006298721014f7c4e1acb8c6e Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Fri, 5 Aug 2022 09:09:48 +0100 Subject: [PATCH 3/5] remove nested call to ToObject --- index.bs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 76aa6667..857c9789 100644 --- a/index.bs +++ b/index.bs @@ -7769,7 +7769,9 @@ object (or its prototype chain) or the record correspond to [=dictionary members : Null :: undefined : anything else - :: [=?=] Get([=?=] ToObject(|esDict|), |key|) + :: + 1. Let |obj| be [=?=] ToObject(|esDict|) + 1. [=?=] Get(|obj|, |key|) 1. If |esMemberValue| is not undefined, 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. From e64fed87a1132dd4cbbab5d3253ba349f130db14 Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Fri, 5 Aug 2022 09:13:44 +0100 Subject: [PATCH 4/5] hoist ToObject out of the loop --- index.bs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index 857c9789..8c053be5 100644 --- a/index.bs +++ b/index.bs @@ -7760,6 +7760,7 @@ object (or its prototype chain) or the record correspond to [=dictionary members 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 [=?=] ToObject(|esDict|) if Type(|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|. @@ -7769,9 +7770,7 @@ object (or its prototype chain) or the record correspond to [=dictionary members : Null :: undefined : anything else - :: - 1. Let |obj| be [=?=] ToObject(|esDict|) - 1. [=?=] Get(|obj|, |key|) + :: [=?=] Get(|obj|, |key|) 1. If |esMemberValue| is not undefined, 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. From 4fb12edfaa97f1db9d26e64addf3460cd30e3c44 Mon Sep 17 00:00:00 2001 From: Robin Ricard Date: Fri, 5 Aug 2022 10:17:07 +0100 Subject: [PATCH 5/5] remove unneeded ToObject --- index.bs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 8c053be5..5c5d8fd8 100644 --- a/index.bs +++ b/index.bs @@ -7924,8 +7924,7 @@ ECMAScript Array or Tuple values. 1. If Type(|V|) is not Object or Tuple, [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. - 1. Let |obj| be [=?=] ToObject(|V|) - 1. Let |method| be [=?=] GetMethod(|obj|, {{@@iterator}}). + 1. Let |method| be [=?=] GetMethod(|V|, {{@@iterator}}). 1. If |method| is undefined, [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. 1. Return the result of [=creating a sequence from an iterable|creating a sequence=]