Skip to content

Commit

Permalink
fixup! Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Apr 5, 2019
1 parent aec5ddd commit 9e77280
Showing 1 changed file with 48 additions and 40 deletions.
88 changes: 48 additions & 40 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,8 @@ expected that an object that implements a particular IDL interface
provides ways to inspect and modify the object's state and to
invoke the behavior described by the interface.

An [=interface=] has an <dfn for=interface>enclosing module</dfn>, which is a [=module=] or null.
[=Interfaces=] and [=partial interfaces=] have an <dfn for="interface,partial interface">enclosing
module</dfn>, which is a [=module=] or null.
Unless otherwise specified, it is null.

<div algorithm>
Expand All @@ -817,9 +818,9 @@ Unless otherwise specified, it is null.

It is given by the result of the following steps:

1. Let |interface| be the given [=interface=].
1. Let |identifier| be |interface|'s [=identifier=].
1. Let |module| be |interface|'s [=interface/enclosing module=].
1. Let |definition| be the given [=interface=] or [=partial interface=].
1. Let |identifier| be |definition|'s [=identifier=].
1. Let |module| be |definition|'s [=enclosing module=].
1. If |module| is null, then:
1. Return |identifier|.
1. Let |specifier| be |module|'s [=module/specifier=].
Expand Down Expand Up @@ -1015,10 +1016,6 @@ The order of appearance of an [=interface=]
definition and any of its [=partial interface=]
definitions does not matter.

A [=partial interface=] has an <dfn for="partial interface">enclosing module</dfn>, which is a
[=module=] or null. Unless otherwise specified, it is null.
The [=partial interface/enclosing module=] of each [=partial interface=]

Note: A partial interface definition cannot specify that the interface
[=interface/inherits=] from another interface.
Inheritance must be specified on the original [=interface=]
Expand Down Expand Up @@ -4433,10 +4430,10 @@ A module has a [=list=] of
<dfn id="dfn-module-member" export lt="module member" for=module>module members</dfn> which are
[=interfaces=], [=read only=] [=regular attributes=], and [=regular operations=].

The [=module members=] of a [=module=] |m| are given by the result of the following steps:
The [=module members=] of a [=module=] |module| are given by the following steps:

1. Let |result| be « ».
1. Let |specifier| be |m|'s [=module/specifier=].
1. Let |specifier| be |module|'s [=module/specifier=].
1. For each [=module declaration=] |declaration| whose [=module declaration/specifier=] is
|specifier|:
1. For every member |member| in |declaration|'s [=module declaration/module
Expand All @@ -4458,11 +4455,20 @@ The [=module members=] of a [=module=] |m| are given by the result of the follow

Note: The order that members appear in this list has significance for property enumeration in the
<a href="#es-modules">ECMAScript binding</a>.

Issue: Exclude [=partial interfaces=]?
</div>

For all [=modules=] |module|, all [=interfaces=] that are in |module|'s [=module/module members=]
have their [=interface/enclosing module=] set to |module|.

<div algorithm>
The <dfn for=module>url</dfn> of a [=module=] |module| is given by the following steps:

1. Let |specifier| be |module|'s [=module/specifier=].
1. Return the [=concatenation=] of « "<code>import:std:</code>", |specifier| ».
</div>

Note that like [=namespaces=], modules do not create types.

Rather than defining behavior when accessed, the [=attributes=] of a [=module=] act as a simple
Expand All @@ -4472,56 +4478,58 @@ an IDL value of the type of the [=attribute=].
Note: See the ECMAScript binding's definition of [=set a module attribute=].

Each module may have <dfn for=module>evaluation steps</dfn> which are executed when the module is
first imported. These steps may throw an [=exception=], which prevents the module from being
accessed. The [=module/evaluation steps=] for a module |m| must invoke the "set a module
attribute" algorithm to initialize each [=attribute=] in |m|'s [=module/module members=].
first imported.
These steps have access to a <dfn>this module</dfn> value, which is the [=module=] being
evaluated, and a [=Realm=].
They may throw an [=exception=], which prevents the module from being accessed.
The [=module/evaluation steps=] for a module |m| must invoke the "set a module attribute"
algorithm to initialize each [=attribute=] in |m|'s [=module/module members=].

<div class="example" noexport>

The following [=IDL fragment=] which defines a [=module=] exposing a function
to get the current timezone, which returns an instance of an interface
exposed in the same module.
The following [=IDL fragment=] defines a [=module=] exposing a function to get the current
timezone, which returns an instance of an interface exposed in the same module.

<pre class="syntax">
[Exposed=Window, SecureContext]
module timezone {
module <dfn interface>temporal</dfn> {
interface <dfn interface>Timezone</dfn> {
readonly attribute USVString name;
long long offsetMs(long long unixTime);
};
timezone.Timezone getCurrentTimezone();
readonly attribute timezone.Timezone <dfn attribute for=timezone>initialTimezone</dfn>;
temporal.Timezone getCurrentTimezone();
readonly attribute temporal.Timezone <dfn attribute for=temporal>initialTimezone</dfn>;
};
</pre>

<blockquote>
The [=module/evaluation steps=] of the "std:timezone" module in |realm| are as follows:
The [=module/evaluation steps=] of the {{temporal}} module in |realm| are as follows:
1. Let |initial| be a [=new=] {{Timezone}} in |realm|, representing the User
Agent's preferred time zone
1. [=set a module attribute|Set the attribute=] {{timezone/initialTimezone}} of
the "std:timezone" module in |realm| to |initial|.
Agent's preferred time zone.
1. [=set a module attribute|Set the attribute=] {{temporal/initialTimezone}} of
<b>this module</b> to |initial|.
</blockquote>

An ECMAScript implementation would then expose a <code class="idl">"timezone"</code>
An ECMAScript implementation would then expose a <code class="idl">"std:temporal"</code>
module which includes an [=interface object=] for the interface and a function for the operation:

<pre highlight="js">
import * from "timezone" as timezone;
Object.keys(timezone); // Evaluates to ["Timezone", "getCurrentTimezone", "currentTimezone"]
typeof timezone.Timezone; // Evaluates to "function"
typeof timezone.getCurrentTimezone; // Evaluates to "function"
typeof timezone.initialTimezone; // Evaluates to "object"
import * from "std:temporal" as temporal;
Object.keys(temporal); // Evaluates to ["Timezone", "getCurrentTimezone", "currentTimezone"]
typeof temporal.Timezone; // Evaluates to "function"
typeof temporal.getCurrentTimezone; // Evaluates to "function"
typeof temporal.initialTimezone; // Evaluates to "object"
</pre>
</div>

### Syntax ### {#idl-modules-syntax}

<pre class="syntax">
module <mark>"std:example"</mark> {
module <mark>example</mark> {
/* module_members... */
};

partial module <mark>"std:example"</mark> {
partial module <mark>example</mark> {
/* module_members... */
};
</pre>
Expand Down Expand Up @@ -4583,12 +4591,12 @@ file an issue</a> if you see a need for this feature.

<pre class="grammar" id="prod-Module">
Module :
"module" string "{" ModuleMembers "}" ";"
"module" identifier "{" ModuleMembers "}" ";"
</pre>

<pre class="grammar" id="prod-PartialModule">
PartialModule :
"module" string "{" ModuleMembers "}" ";"
"module" identifier "{" ModuleMembers "}" ";"
</pre>

<pre class="grammar" id="prod-ModuleMembers">
Expand Down Expand Up @@ -13316,7 +13324,8 @@ Records=], allowing them to be imported as ECMAScript modules.
1. Otherwise:
1. Assert: |member| is an [=attribute=].
1. Assert: The [=module/evaluation steps=] will set each attribute.
1. Run the [=module/evaluation steps=] for |module| in |realm|, if any are present.
1. Run the [=module/evaluation steps=] with |module| as <b>[=this module=]</b> in
|realm|, if any are present.
1. Return |moduleRecord|.
</div>

Expand All @@ -13325,11 +13334,10 @@ Records=], allowing them to be imported as ECMAScript modules.

1. Let |map| be the [=module map=] associated with |realm|'s [=relevant settings object=].
1. For each [=module=] |module| that is [=exposed=] in |realm|:
1. Let |specifier| be |module|'s [=module/specifier=].
1. Let |name| be the [=concatenation=] of « "<code>import:</code>", |specifier| ».
1. Let |url| be |module|'s [=module/url=].
1. Let |record| be the result of [=create a synthetic module record=] for |module| in
|realm|.
1. [=map/Set=] |map|[|name|] to |record|.
1. [=map/Set=] |map|[|url|] to |record|.
</div>

<div algorithm>
Expand All @@ -13339,12 +13347,12 @@ Records=], allowing them to be imported as ECMAScript modules.
1. Assert: |value| is an IDL value of the type of |attribute|.

Issue(heycam/webidl#674): Relax this requirement.
1. Let |specifier| be |module|'s [=module/specifier=].
1. Let |url| be |module|'s [=module/url=].
1. Let |esValue| be |value| [=converted to an ECMAScript value=].
1. If |realm| is not provided, let |realm| be the [=current Realm=].
1. Let |map| be the [=module map=] associated with |realm|'s [=relevant settings object=].
1. Assert: |map|[|specifier|] [=map/exists=].
1. Let |moduleRecord| be |map|[|specifier|].
1. Assert: |map|[|url|] [=map/exists=].
1. Let |moduleRecord| be |map|[|url|].
1. Let |identifier| be |attribute|'s [=identifier=].
1. Assert: |moduleRecord|.\[[ExportNames]] [=list/contains=] |identifier|.
1. Perform ! [=SetSyntheticModuleExport=](|moduleRecord|, |identifier|, |esValue|).
Expand Down

0 comments on commit 9e77280

Please sign in to comment.