1. 序論
~INFORMATIVEW3C により発行される技術報告に含められる~programming言語~ifcは、概して Object Management Group による~IDL( `Interface Definition Language^en ) `OMGIDL$r を利用して記述されていた。 この~IDLは、これらの~ifcを,言語に依存しない方式で記述する手段を供する。 通例的に,その種の文書には、~IDLで記述された~ifcを[ 所与の言語 ]の構成子に対応付ける方法について,詳細を述べる、言語束縛についての追加の付録が含められる。 ◎ Technical reports published by the W3C that include programming language interfaces have typically been described using the Object Management Group’s Interface Definition Language (IDL) [OMGIDL]. The IDL provides a means to describe these interfaces in a language independent manner. Usually, additional language binding appendices are included in such documents which detail how the interfaces described with the IDL correspond to constructs in the given language.
しかしながら、~Web上で最も共通的に利用されている言語, ~ESに対しては、これらの仕様における言語束縛は,終始~粗い精度で指定されていたため、相互運用性の課題も生じていた。 加えて、それぞれの仕様が同じ基本的な情報を述べなければならない — 例えば、 ~IDLで記述される DOM ~ifcが~ES大域~objの~propに対応していることや, `unsigned long$T ~IDL型が~ESの `Number^jt 型に対応付けられることなど。 ◎ However, the bindings in these specifications for the language most commonly used on the web, ECMAScript, are consistently specified with low enough precision as to result in interoperability issues. In addition, each specification must describe the same basic information, such as DOM interfaces described in IDL corresponding to properties on the ECMAScript global object, or the unsigned long IDL type mapping to the Number type in ECMAScript.
この仕様は、~Web~API用の~ifcを定義する仕様で利用できる, OMG ~IDLに似た~IDL言語を定義する。 この~IDLには、以前は注釈文による記述を要していた共通の機能性を~supportするために,いくつもの拡張が加えられた。 加えて、~ES言語~用の精確な言語束縛も与えられた。 ◎ This specification defines an IDL language similar to OMG IDL for use by specifications that define interfaces for Web APIs. A number of extensions are given to the IDL to support common functionality that previously must have been written in prose. In addition, precise language bindings for the ECMAScript language are given.
【この訳に特有の表記規約】
この訳の,~algoの記述に利用されている各種記号( ~LET, ~IF, `~THROW$, ~WHILE, ~GOTO, 等々)の意味や定義の詳細は、~SYMBOL_DEF_REFを~~参照されたし。 ただし,`~THROW$ の意味は、この仕様に定義され(リンク先を~~参照),もっぱら~ES言語束縛にて利用される。
この仕様~自身にも,表記規約がある。
2. ~ifc定義~言語
この節では、~Web~platform~API用の~ifcを定義するために利用できる言語, ~Web~IDL について述べる。 ~Web~APIを定義する仕様は、[ その仕様が定義する~API用の~ifc(~objが表出し得る状態と挙動) ]を記述する, 1 個~以上の `~IDL片@ を含み得る。 `~IDL片$は、いくつかの[ 文法~記号 `Definitions$g に合致する定義 ]からなる並びである。 実装が~supportする `~IDL片$の集合は、順序付けられない。 完全な文法と利用される記法の説明については、 `idl-grammar$sec を見よ。 ◎ This section describes a language, Web IDL, which can be used to define interfaces for APIs in the Web platform. A specification that defines Web APIs can include one or more IDL fragments that describe the interfaces (the state and behavior that objects can exhibit) for the APIs defined by that specification. An IDL fragment is a sequence of definitions that matches the Definitions grammar symbol. The set of IDL fragments that an implementation supports is not ordered. See IDL grammar for the complete grammar and an explanation of the notation used.
`~IDL片$に現れ得る `定義@ には、次の種類があり,すべて後続の節にて定義される ⇒# `~ifc$, `部分的~ifc定義$, `~ifc~mixin$, `部分的~ifc~mixin定義$, `~ns$, `部分的~ns定義$, `辞書$, `部分的~辞書~定義$, `~typedef$, `~includes文$ ◎ The different kinds of definitions that can appear in an IDL fragment are: interfaces, partial interface definitions, interface mixins, partial mixin definitions, namespaces, partial namespace definitions, dictionaries, partial dictionary definitions, typedefs and includes statements. These are all defined in the following sections.
各`定義$( `Definition$g に合致)の前には、[ `拡張属性$の~list( `ExtendedAttributeList$g に合致) ]を置ける — それらは、[ 当の定義が,言語束縛において どう取扱われるか ]を制御する。 この仕様が定義する拡張属性の,どの言語束縛にも通用する部分については `idl-extended-attributes$sec にて論じられ、~ES言語束縛に特有の部分については `es-extended-attributes$sec にて論じられる。 ◎ Each definition (matching Definition) can be preceded by a list of extended attributes (matching ExtendedAttributeList), which can control how the definition will be handled in language bindings. The extended attributes defined by this specification that are language binding agnostic are discussed in §2.13 Extended attributes, while those specific to the ECMAScript language binding are discussed in §3.3 ECMAScript-specific extended attributes.
[`extended_attributes^mk] interface `identifier^i { /* interface_members... */ };
`~IDL片$の例を示す: ◎ The following is an example of an IDL fragment.
[Exposed=Window] interface Paint { }; [Exposed=Window] interface SolidColor : Paint { attribute double red; attribute double green; attribute double blue; }; [Exposed=Window] interface Pattern : Paint { attribute DOMString imageURL; }; [Exposed=Window, Constructor] interface GraphicalWindow { readonly attribute unsigned long width; readonly attribute unsigned long height; attribute Paint currentPaint; void drawRectangle(double %x, double %y, double %width, double %height); void drawText(double %x, double %y, DOMString %text); };
ここでは、 4 個の`~ifc$が定義されている。 `GraphicalWindow^T ~ifcには、 2 個の`読専$な`属性$, 1 個の~writableな属性, 2 個の`演算$ が定義されている。 `GraphicalWindow^T ~ifcを実装する~objは、利用されている 特定0の言語に適切な方式で,これらの属性と演算を公開することになる。 ◎ Here, four interfaces are being defined. The GraphicalWindow interface has two read only attributes, one writable attribute, and two operations defined on it. Objects that implement the GraphicalWindow interface will expose these attributes and operations in a manner appropriate to the particular language being used.
~ESにおいては、~IDL~ifc上の属性/演算は、すべての `GraphicalWindow^T ~objにおいて,その原型~obj上の[ `組込みの関数~obj$を値とする~data-propとして与えられる[ ~accessor~prop / 演算 ]]として,公開されることになる。 `GraphicalWindow^T を実装する各~ES~objは、その原型鎖の中にその原型~objを持つことになる。 ◎ In ECMAScript, the attributes on the IDL interfaces will be exposed as accessor properties and the operations as data properties whose value is a built-in function object on a prototype object for all GraphicalWindow objects; each ECMAScript object that implements GraphicalWindow will have that prototype object in its prototype chain.
`GraphicalWindow^T 上に現れる `Constructor$x は`拡張属性$である。 この拡張属性により、 `new GraphicalWindow()^c の~callに対し,この~ifcを実装する新たな~objを返すような`構築子$が、~ES実装に存在することになる。 ◎ The [Constructor] that appears on GraphicalWindow is an extended attribute. This extended attribute causes a constructor to exist in ECMAScript implementations, so that calling new GraphicalWindow() would return a new object that implemented the interface.
2.1. 名前(識別子)
どの[ `~ifc$ / `部分的~ifc定義$ / `~ns$ / `部分的~ns定義$ / `辞書$ / `部分的~辞書~定義$ / `列挙$ / `呼戻~関数$ / `~typedef$ ]も(これらは総称して `有名~定義@ と呼ばれる), および どの[ `定数$ / `属性$ / `辞書~mb$ ]も、何らかの`演算$を行うための `識別子@ を持つ。 識別子はその宣言~内のどこかに在る `identifier$g ~tokenから決定される: ◎ Every interface, partial interface definition, namespace, partial namespace definition, dictionary, partial dictionary definition, enumeration, callback function and typedef (together called named definitions) and every constant, attribute, and dictionary member has an identifier, as do some operations. The identifier is determined by an identifier token somewhere in the declaration:
-
`有名~定義$に対しては、~keyword[ `interface^c / `namespace^c / `dictionary^c / `enum^c / `callback^c ]の直後に現れる `identifier$g ~tokenがその定義の識別子を決定する。 ◎ For named definitions, the identifier token that appears directly after the interface, namespace, dictionary, enum or callback keyword determines the identifier of that definition.
interface `interface_identifier^mk { /* interface_members... */ }; partial interface `interface_identifier^mk { /* interface_members... */ }; namespace `namespace_identifier^mk { /* namespace_members... */ }; partial namespace `namespace_identifier^mk { /* namespace_members... */ }; dictionary `dictionary_identifier^mk { /* dictionary_members... */ }; partial dictionary `dictionary_identifier^mk { /* dictionary_members... */ }; enum `enumeration_identifier^mk { "enum", "values" /* , ... */ }; callback `callback_identifier^mk = return_type (/* arguments... */);
-
`属性$, `~typedef$, `辞書~mb$ に対しては、宣言の末尾の~semicolonの前に在る最後の `identifier$g ~tokenが識別子を決定する。 ◎ For attributes, typedefs and dictionary members, the final identifier token before the semicolon at the end of the declaration determines the identifier.
[`extended_attributes^i] interface `identifier^i { attribute `type^i `attribute_identifier^mk; }; typedef `type^i `typedef_identifier^mk; dictionary `identifier^i { `type^i `dictionary_member_identifier^mk; };
-
`定数$に対しては、等号の前に在る `identifier$g ~tokenが識別子を決定する。 ◎ For constants, the identifier token before the equals sign determines the identifier.
const `type^i `constant_identifier^mk = 42;
-
`演算$に対しては、返値型の後,かつ左~丸括弧の前に現れる `identifier$g ~token( `OperationRest$g の中の文法~記号 `OptionalIdentifier$g の部分として合致) が、その演算の識別子を決定する。 そのような `identifier$g ~tokenが無い場合、その演算は識別子を持たない。 ◎ For operations, the identifier token that appears after the return type but before the opening parenthesis (that is, one that is matched as part of the OptionalIdentifier grammar symbol in an OperationRest) determines the identifier of the operation. If there is no such identifier token, then the operation does not have an identifier.
interface interface_identifier { `return_type^i `operation_identifier^mk(/* arguments... */); };
注記: [ 取得子や設定子などの, 特殊な種類の演算 ]を宣言する演算は、識別子を持たないことがある。 ◎ Note: Operations can have no identifier when they are being used to declare a special kind of operation, such as a getter or setter.
これらの構成子のすべてにおいて、 `identifier$g ~tokenから先頭の文字 `005F^U1 を(もし在れば)除去した値が`識別子$になる。 ◎ For all of these constructs, the identifier is the value of the identifier token with any leading U+005F LOW LINE ("_") character (underscore) removed.
注記: 先頭の `"_"^char は、識別子を~escapeして,予約-済みの語と見誤られなくするために利用される。 例えば、 `interface^l という名前を持つ~ifcも定義できる。 先頭の `"_"^char は識別子の~escapeを外す際に落とされる。 ◎ Note: A leading "_" is used to escape an identifier from looking like a reserved word so that, for example, an interface named "interface" can be defined. The leading "_" is dropped to unescape the identifier.
演算~引数がとり得る識別子は、もう少し広い集合になる。 演算の宣言においては、引数の識別子はその型の直後に指定され、 `identifier$g ~tokenか, または `ArgumentNameKeyword$g 記号に合致する~keywordで与えられる。 これらの~keywordのいずれかが利用される場合、先頭の~underscoreによる~escapeは不要である。 ◎ Operation arguments can take a slightly wider set of identifiers. In an operation declaration, the identifier of an argument is specified immediately after its type and is given by either an identifier token or by one of the keywords that match the ArgumentNameKeyword symbol. If one of these keywords is used, it need not be escaped with a leading underscore.
interface interface_identifier { `return_type^i `operation_identifier^i(argument_type `argument_identifier^mk /* , ... */); };
演算~引数に `identifier$g ~tokenが利用された場合、その`識別子$はその~tokenから先頭の文字 `005F^U1 ( `underscore^en )を取り除いた値になる。 代わりにいずれかの `ArgumentNameKeyword$g ~keyword~tokenが利用された場合、演算~引数の`識別子$は単にその~tokenになる。 ◎ If an identifier token is used, then the identifier of the operation argument is the value of that token with any leading U+005F LOW LINE ("_") character (underscore) removed. If instead one of the ArgumentNameKeyword keyword token is used, then the identifier of the operation argument is simply that token.
上に示されたどの~IDL構成子のどの`識別子$も `constructor^l, `toString^l になっては~MUST_NOT。 また、文字 `005F^U1 から始まっては~MUST_NOT。 これらは `予約-済み識別子@ と呼ばれる。 ◎ The identifier of any of the abovementioned IDL constructs must not be "constructor", "toString", or begin with a U+005F LOW LINE ("_") character. These are known as reserved identifiers.
`識別子$ `toJSON^l は`予約-済み識別子$ではないが、 `idl-tojson-operation$sec に述べるように,利用されるのは[ ~objを`~JSON型$に変換する`正則~演算$ ]に限られ~MUST。 ◎ Although the "toJSON" identifier is not a reserved identifier, it must only be used for regular operations that convert objects to JSON types, as described in §2.4.3.1 toJSON.
注記: 後の節にて、一部の特定0の構成子に対しては,識別子の名前に更なる制約が課され得る。 ◎ Note: Further restrictions on identifier names for particular constructs may be made in later sections.
所与の実装が~supportする `~IDL片$の集合に属する、どの[ `~ifc$ / `~ns$ / `辞書$ / `列挙$ / `呼戻~関数$ / `~typedef$ ]の`識別子$も,他のそれと互いに同じになっては~MUST_NOT。 ◎ Within the set of IDL fragments that a given implementation supports, the identifier of every interface, namespace, dictionary, enumeration, callback function and typedef must not be the same as the identifier of any other interface, namespace, dictionary, enumeration, callback function or typedef.
`~IDL片$の中では、`定義$への参照は,参照~先の定義の宣言より後に現れる必要はない。 参照は複数の`~IDL片$をまたがることもできる。 ◎ Within an IDL fragment, a reference to a definition need not appear after the declaration of the referenced definition. References can also be made across IDL fragments.
したがって,次の`~IDL片$は妥当である: ◎ Therefore, the following IDL fragment is valid:
[Exposed=Window] interface B : A { void f(SequenceOfLongs %x); }; [Exposed=Window] interface A { }; typedef sequence<long> SequenceOfLongs;
`定義$/`~ifc~mb$に,`識別子$を与える例を、次の`~IDL片$に示す: ◎ The following IDL fragment demonstrates how identifiers are given to definitions and interface members.
/* ~typedef識別子: `number^l ◎ Typedef identifier: "number" */ typedef double number; /* ~ifc識別子: `System^l ◎ Interface identifier: "System" */ [Exposed=Window] interface System { /* 演算~識別子: `createObject^l ◎ Operation identifier: "createObject" */ /* 演算~引数~識別子: `interface^l ◎ Operation argument identifier: "interface" */ object createObject(DOMString _interface); /* 演算~引数~識別子: `interface^l ◎ Operation argument identifier: "interface" */ sequence<object> getObjects(DOMString interface); /* 演算は識別子を持たない。取得子を宣言する。 ◎ Operation has no identifier; it declares a getter. */ getter DOMString (DOMString keyName); }; /* ~ifc識別子: `TextField^l ◎ Interface identifier: "TextField" */ [Exposed=Window] interface TextField { /* 属性~識別子: `const^l ◎ Attribute identifier: "const" */ attribute boolean _const; /* 属性~識別子: `value^l ◎ Attribute identifier: "value" */ attribute DOMString? _value; };
`TextField^T `~ifc$の 2 個目の`属性$は( `value^l は~IDL文法の~keywordではないので)~underscoreで~escapeする必要はないが、属性の`識別子$を得る際には,依然として~escapeは外される。 ◎ Note that while the second attribute on the TextField interface need not have been escaped with an underscore (because "value" is not a keyword in the IDL grammar), it is still unescaped to obtain the attribute’s identifier.
2.2. ~ifc
`~IDL片$は~obj指向~systemの記述に利用される。 その種の~systemにおいては、~objは同一性( `identity^en )を備える実体であり,状態と挙動の~encapsulationである。 `~ifc@ は、[ その~ifcを実装する~objが公開することになる,何らかの状態や挙動 ]を宣言する,`定義$( `interface^sym `InterfaceRest$g / `callback^sym `interface^sym `InterfaceRest$g いずれかに合致)である。 ◎ IDL fragments are used to describe object oriented systems. In such systems, objects are entities that have identity and which are encapsulations of state and behavior. An interface is a definition (matching interface InterfaceRest or callback interface InterfaceRest) that declares some state and behavior that an object implementing that interface will expose.
[`extended_attributes^i] interface `identifier^i { /* interface_members... */ };
~ifcは、その宣言の波括弧を成す合間に現れる,一連の`~mb$が成す集合( `InterfaceMembers$g に合致)の仕様である。 これらの~mbは、 `~ifc~mb@ と称される。 ◎ An interface is a specification of a set of interface members (matching InterfaceMembers). These are the members that appear between the braces in the interface declaration.
~Web~IDLの~ifcは,その~ifcを実装する~objが どう挙動するかを記述する。 ~obj指向~言語~用の言語束縛においては、特定0の~IDL~ifcを実装する~objは,[ ~objの状態を検分したり改変する仕方,~ifcに記述された挙動を呼出す仕方 ]を供することが期待されている。 ◎ Interfaces in Web IDL describe how objects that implement the interface behave. In bindings for object oriented languages, it is 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.
~ifcは,別の~ifc(の~mb)を `継承-@ するようにも定義できる。 ~ifcの識別子に文字 `003A^U1 と`識別子$が後続している場合、後者の識別子が,継承される~ifcを識別する。 ある~ifc %I を継承する~ifcを実装する~objは, %I も実装する。 ~objはしたがって, %I からの~ifc~mbに対応する~mbも持つことになる。 ◎ An interface can be defined to inherit from another interface. If the identifier of the interface is followed by a U+003A COLON (":") character and an identifier, then that identifier identifies the inherited interface. An object that implements an interface that inherits from another also implements that inherited interface. The object therefore will also have members that correspond to the interface members from the inherited interface.
interface `identifier^i : `identifier_of_inherited_interface^mk { /* interface_members... */ };
~mbたちが現れる順序は、 ~ES言語束縛 における~prop列挙に,有意になる。 ◎ The order that members appear in has significance for property enumeration in the ECMAScript binding.
~ifcは、継承される~ifcの~mbと同じ名前を持つ,~ifc~mbを指定してもよい。 派生~ifcを実装する~objは、派生~ifc上でそれらの~mbを公開することになる。 その~obj上で上書きされた~mbに~accessできるかどうかは、言語束縛に特有になる。 ◎ Interfaces may specify an interface member that has the same name as one from an inherited interface. Objects that implement the derived interface will expose the member on the derived interface. It is language binding specific whether the overridden member can be accessed on the object.
次の 2 つの~ifcを考える ◎ Consider the following two interfaces.
[Exposed=Window] interface A { void f(); void g(); }; [Exposed=Window] interface B : A { void f(); void g(DOMString %x); };
~ES言語束縛においては、 `B^T の~instanceは,次の様な原型鎖を持つことになる: ◎ In the ECMAScript language binding, an instance of B will have a prototype chain that looks like the following:
~ESにおける `instanceOfB.f()^c の~callは、 `B^T 上で定義された `f^M を呼出すことになる。 しかしながら, `A^T 上の `f^M も、依然として `A.prototype.f.call(instanceOfB)^c の~callにより, `B^T を実装する~obj上で呼出せる。 ◎ Calling instanceOfB.f() in ECMAScript will invoke the f defined on B. However, the f from A can still be invoked on an object that implements B by calling A.prototype.f.call(instanceOfB).
所与の~ifc %A の `継承d~ifc@ とは、[ %A が直接間接に継承する,すべての~ifc ]からなる集合である。 %A が 他の~ifcを`継承-$しない場合、集合は空になる。 他の場合、集合は, %A が継承する~ifc %B と %B の`継承d~ifc$すべてを含む。 ◎ The inherited interfaces of a given interface A is the set of all interfaces that A inherits from, directly or indirectly. If A does not inherit from another interface, then the set is empty. Otherwise, the set includes the interface B that A inherits from and all of B’s inherited interfaces.
~ifcは、その継承~階層が循環するように宣言されては~MUST_NOT。 すなわち、~ifc %A は自身を継承することも, %A を継承する別の~ifc %B を継承することもできない,等々。 ◎ An interface must not be declared such that its inheritance hierarchy has a cycle. That is, an interface A cannot inherit from itself, nor can it inherit from another interface B that inherits from A, and so on.
~ifcの一般的な多重~継承は~supportされず,~objは~ifcの任意の集合を実装することはできないことに注意。 ~objは、所与の単独の~ifc %A を実装するように — すなわち %A の`継承d~ifc$すべてを実装するように — 定義できる。 加えて,`~includes文$を利用すれば、[ ある~ifc %A を実装している~objが,常に[ %A が`内包-$する各`~ifc~mixin$を成す各`~ifc~mixin~mb$を内包する ]]ように定義することもできる。 ◎ Note that general multiple inheritance of interfaces is not supported, and objects also cannot implement arbitrary sets of interfaces. Objects can be defined to implement a single given interface A, which means that it also implements all of A’s inherited interfaces. In addition, an includes statement can be used to define that objects implementing an interface A will always also include the members of the interface mixins A includes.
各~ifc~mbの前には、`拡張属性$の~list( `ExtendedAttributeList$g に合致)を置くことができる — それらは、その~ifc~mbが,言語束縛において どう取扱われるかを制御する。 ◎ Each interface member can be preceded by a list of extended attributes (matching ExtendedAttributeList), which can control how the interface member will be handled in language bindings.
[`extended_attributes^i] interface `identifier^i { [`extended_attributes^mk] const `type^i `constant_identifier^i = 42; [`extended_attributes^mk] attribute `type^i `identifier^i; [`extended_attributes^mk] `return_type^i `identifier^i(/* arguments... */); };
`呼戻~ifc@ は,その定義の先頭に `callback^c ~keywordを利用する`~ifc$である。 呼戻~ifcは、 `idl-objects$sec にて述べるように,`~platform~obj$ではなく,`利用元~obj$により実装され得るものである。 ◎ A callback interface is an interface that uses the callback keyword at the start of its definition. Callback interfaces are ones that can be implemented by user objects and not by platform objects, as described in §2.11 Objects implementing interfaces.
callback interface `identifier^i { /* interface_members... */ };
注記: 似た命名の`呼戻~関数$定義も見よ。 ◎ Note: See also the similarly named callback function definition.
`呼戻~ifc$は非~呼戻~ifcを`継承-$しては~MUST_NOT。 非~呼戻~ifcは呼戻~ifcを`継承-$しては~MUST_NOT。 呼戻~ifcは`~ifc~mixin$を`内包-$しては~MUST_NOT。 ◎ Callback interfaces must not inherit from any non-callback interfaces, and non-callback interfaces must not inherit from any callback interfaces. Callback interfaces must not include any interface mixins.
`呼戻~ifc$上に[ `静的~属性$ / `静的~演算$ ]が定義されては~MUST_NOT。 ◎ Static attributes and static operations must not be defined on a callback interface.
仕様~策定者は、既存の~APIの要件の記述に~~不可欠な場合を除き,単独の`演算$のみを持つ`呼戻~ifc$を定義するべきでない。 代わりに,`呼戻~関数$が利用されるべきである。 ◎ Specification authors should not define callback interfaces that have only a single operation, unless required to describe the requirements of existing APIs. Instead, a callback function should be used.
`呼戻~ifc$である `EventListener$T の定義は、[ その~ifcを,[ 所与の~prop(この場合は `handleEvent^jp )を伴う`利用元~obj$ ]により実装できるようにする必要がある ]ものと見なされている,既存の~APIの例である。 新たな~API, あるいは互換性の心配がない~API用の`呼戻~関数$には、(~ES言語束縛においては)`関数~obj$のみが許容されることになる。 ◎ The definition of EventListener as a callback interface is an example of an existing API that needs to allow user objects with a given property (in this case handleEvent) to be considered to implement the interface. For new APIs, and those for which there are no compatibility concerns, using a callback function will allow only a function object (in the ECMAScript language binding).
上の警告は,将来に呼戻~ifcを拡張する際には、おそらく適用されるべきではないであろう。 それが単一~演算~呼戻~ifcから取り掛かる良い理由になると見られる。 ◎ Perhaps this warning shouldn’t apply if you are planning to extend the callback interface in the future. That’s probably a good reason to start off with a single operation callback interface.
編集者は,[ 所与の呼戻~ifcを実装している利用元~obj上で,演算が実装されていない場合 ]を~supportする必要があると考えている。 既存の呼戻~ifcを拡張する仕様は、おそらく,実装されていない演算の~callを避けることが求まれるであろう(代わりに何らかの既定の挙動を持たせて)。 従って,演算が実装されているかどうか意味する用語が定義されるべきであろう — ~ES言語束縛における,~propの有無の検査に対応することになるような。 ◎ I think we need to support operations not being implemented on a given user object implementing a callback interface. If specs extending an existing callback interface, we probably want to be able to avoid calling the operations that aren’t implemented (and having some default behavior instead). So we should perhaps define a term that means whether the operation is implemented, which in the ECMAScript binding would correspond to checking for the property’s existence.
関数~引数として “~propの集まり( `property bag^en )” のような~ES~objをとる~APIを定義する仕様の策定者には、`呼戻~ifc$よりも`辞書$の利用を勧める。 ◎ Specification authors wanting to define APIs that take ECMAScript objects as “property bag” like function arguments are suggested to use dictionaries rather than callback interfaces.
例えば,次のものは: ◎ For example, instead of this:
callback interface Options { attribute DOMString? option1; attribute DOMString? option2; attribute long? option3; }; [Exposed=Window] interface A { void doTask(DOMString %type, Options %options); };
次の様な利用を可能にするために: ◎ to be used like this:
var %a = getA(); /*
`A^T の~instanceを取得する。
◎
Get an instance of A.
*/
%a.doTask("something", { option1: "banana", option3: 100 });
代わりに,次のように記す: ◎ instead write the following:
dictionary Options { DOMString? option1; DOMString? option2; long? option3; }; [Exposed=Window] interface A { void doTask(DOMString %type, optional Options %options); };
~ifc用の~IDLは、 `部分的~ifc定義@ ( `partial^sym `PartialInterfaceRest$g に合致)を利用して,複数の部分に分割できる。 部分的~ifc定義の`識別子$は、その~ifc定義の識別子と同じで~MUST。 それぞれの部分的~ifcに現れる,すべての~mbは、その~ifc自身を成す~mbと見なされる。 ◎ The IDL for interfaces can be split into multiple parts by using partial interface definitions (matching partial PartialInterfaceRest). The identifier of a partial interface definition must be the same as the identifier of an interface definition. All of the members that appear on each of the partial interfaces are considered to be members of the interface itself.
interface `SomeInterface^mk { /* interface_members... */ }; partial interface `SomeInterface^mk { /* interface_members... */ };
注記: 部分的~ifc定義に意図される用途は、~ifcの定義を 文書の複数の節, ときには複数の文書に分離できるようにして,仕様の編集を補佐することである。 ◎ Note: Partial interface definitions are intended for use as a specification editorial aide, allowing the definition of an interface to be separated over more than one section of the document, and sometimes multiple documents.
`~ifc$定義, およびその`部分的~ifc定義$が現れる順序は問題にされない。 ◎ The order of appearance of an interface definition and any of its partial interface definitions does not matter.
注記: 部分的~ifc定義においては、別の~ifcからの`継承-$は指定できない。 継承は元の`~ifc$定義に指定され~MUST。 ◎ Note: A partial interface definition cannot specify that the interface inherits from another interface. Inheritance must be specified on the original interface definition.
多少の制限もあるが、`部分的~ifc定義$にも,`拡張属性$を指定できる。 次の拡張属性は,部分的~ifc定義に指定されては~MUST_NOT: `Constructor$x, `LegacyWindowAlias$x, `NamedConstructor$x, `NoInterfaceObject$x ◎ Extended attributes can be specified on partial interface definitions, with some limitations. The following extended attributes must not be specified on partial interface definitions: [Constructor], [LegacyWindowAlias], [NamedConstructor], [NoInterfaceObject].
注記: `Exposed$x, `Global$x, `OverrideBuiltins$x, `SecureContext$x を除き,上に挙げたものが この文書に定義される中で`~ifc$に適用-可能な`拡張属性$のすべてである。 ◎ Note: The above list of extended attributes is all of those defined in this document that are applicable to interfaces except for [Exposed], [Global], [OverrideBuiltins], and [SecureContext].
`部分的~ifc定義$に指定される `拡張属性$は `~ifc$自身に現れるものと見なされる。 ◎ Any extended attribute specified on a partial interface definition is considered to appear on the interface itself.
関連する言語束縛が,~ifcと[ 言語の構成子 ]との間の対応付けを決定する。 ◎ The relevant language binding determines how interfaces correspond to constructs in the language.
~ifcに適用-可能な拡張属性は ⇒ `Constructor$x, `Exposed$x, `Global$x, `LegacyWindowAlias$x, `NamedConstructor$x, `NoInterfaceObject$x, `OverrideBuiltins$x, `SecureContext$x ◎ The following extended attributes are applicable to interfaces: [Constructor], [Exposed], [Global], [LegacyWindowAlias], [NamedConstructor], [NoInterfaceObject], [OverrideBuiltins], and [SecureContext].
次に該当するものは、 `Exposed$r `拡張属性$で注釈され~MUST ⇒# `NoInterfaceObject$x `拡張属性$で注釈されていない非~呼戻`~ifc$ / `定数$を宣言している`呼戻~ifc$ ◎ Non-callback interfaces which are not annotated with a [NoInterfaceObject] extended attribute, and callback interfaces which declare constants must be annotated with an [Exposed] extended attribute.
次の`~IDL片$に、 2 つの相互に参照しあう`~ifc$ — `Human^T と `Dog^T — の定義~例を示す。 いずれも `Animal^T を継承するので、 2 つの~ifcいずれかを実装する~objは, `name^M 属性も持つことになる。 ◎ The following IDL fragment demonstrates the definition of two mutually referential interfaces. Both Human and Dog inherit from Animal. Objects that implement either of those two interfaces will thus have a name attribute.
[Exposed=Window] interface Animal { attribute DOMString name; }; [Exposed=Window] interface Human : Animal { attribute Dog? pet; }; [Exposed=Window] interface Dog : Animal { attribute Human? owner; };
次の`~IDL片$は DOM `~ifc$の一部を単純化した~versionを定義する。 うち 1 個は`呼戻~ifc$である。 ◎ The following IDL fragment defines simplified versions of a few DOM interfaces, one of which is a callback interface.
[Exposed=Window] interface Node { readonly attribute DOMString nodeName; readonly attribute Node? parentNode; Node appendChild(Node %newChild); void addEventListener(DOMString %type, EventListener %listener); }; callback interface EventListener { void handleEvent(Event %event); };
`EventListener$T ~ifcは呼戻~注釈付きの~ifcなので,`利用元~obj$により実装できる: ◎ Since the EventListener interface is annotated callback interface, user objects can implement it:
var %node = getNode(); /* `Node^T の~instanceを得る。 ◎ Obtain an instance of Node. */ var %listener = { handleEvent: function(%event) { /* ... */ } }; %node.addEventListener("click", %listener); /* これは働く。 ◎ This works. */ %node.addEventListener("click", function() { ... }); /* これと同様に。 ◎ As does this. */
しかしながら,利用元~objは `Node^T を実装することはアリでない: ◎ It is not possible for a user object to implement Node, however:
var %node = getNode(); /* */
var %newNode = {
nodeName: "span",
parentNode: null,
appendChild: function(%newchild) {
/* */
},
addEventListener: function(%type, %listener) {
/* */
}
};
%node.appendChild(%newNode); /*
`TypeError^jE 例外が投出されることになる。
◎
This will throw a TypeError exception.
*/
2.3. ~ifc~mixin
【 この節に定義される `includes^c 文は、従来の `implements^c 文を置き換えるものになる(が、他の一部の仕様には、まだ `implements^c 文のまま更新されていないものもある)。 】
`~ifc~mixin@ は、[ それを`内包-$する`~ifc$を実装する各~obj ]により公開される状態や挙動を宣言する,`定義$( `interface^sym `MixinRest$g に合致)である。 `~ifc~mixin$は、複数の`~ifc$に`内包-$され得る。 ◎ An interface mixin is a definition (matching interface MixinRest) that declares state and behavior that can be included by one or more interfaces, and that are exposed by objects that implement an interface that includes the interface mixin.
interface mixin `identifier^i { /* mixin_members... */ };
注記: `~ifc~mixin$に意図されている用途は、`部分的~ifc$と同様に,[ 複数の~ifcに — 場合によっては複数の文書にわたって — 内包されるような,首尾一貫する機能性の集合 ]を一つに~group化できるようにして,仕様の編集を補佐することである。 それには、言語束縛を通して公開されることは意味されていない。 [ `部分的~ifc$, `~ifc~mixin$, `部分的~ifc~mixin$ ]のどれを選ぶかについての目安は、 `using-mixins-and-partials$sec に見出せる。 ◎ Note: Interface mixins, much like partial interfaces, are intended for use as a specification editorial aide, allowing a coherent set of functionalities to be grouped together, and included in multiple interfaces, possibly across documents. They are not meant to be exposed through language bindings. Guidance on when to choose partial interfaces, interface mixins, or partial interface mixins can be found in §2.3.1 Using mixins and partials.
`~ifc~mixin$は、その宣言を成す波括弧の合間に現れる,一連の`~mb$ — [ `定数$, `正則~演算$, `正則~属性$, `文字列化子$ ] — が成す集合( `MixinMembers$g に合致)の仕様である。 これらの~mbは、 `~ifc~mixin~mb@ と称され、それぞれが[ 当の`~ifc~mixin$を`内包-$する`~ifc$ ]に指定されていたかのように,~objに実装できる挙動を述べる。 ◎ An interface mixin is a specification of a set of interface mixin members (matching MixinMembers), which are the constants, regular operations, regular attributes, and stringifiers that appear between the braces in the interface mixin declaration. ◎ These constants, regular operations, regular attributes, and stringifiers describe the behaviors that can be implemented by an object, as if they were specified on the interface that includes them.
`~ifc~mixin$の宣言には、次に挙げるものは現れ得ない ⇒ `静的~属性$ / `静的~演算$ / `文字列化子$を除く`特殊~演算$ / `可反復~宣言$ / `~maplike 宣言$ / `~setlike 宣言$ ◎ Static attributes, static operations, special operations except for stringifiers, and iterable, maplike, and setlike declarations cannot appear in interface mixin declarations.
~ifcと同じく,`~ifc~mixin$用の~IDLは、 `部分的~ifc~mixin@ 定義( `partial^sym `interface^sym `MixinRest$g に合致)を用いて,複数の部分に分割できる。 `部分的~ifc~mixin$`定義$の`識別子$は、`~ifc~mixin$`定義$の`識別子$と同じで~MUST。 各`部分的~ifc~mixin$`定義$に現れる どの`~ifc~mixin~mb$も,[ `~ifc~mixin$自身に加え,当の`~ifc~mixin$を — 拡張により — `内包-$している`~ifc$ ]を成す`~mb$と見なされる。 ◎ As with interfaces, the IDL for interface mixins can be split into multiple parts by using partial interface mixin definitions (matching partial interface MixinRest). The identifier of a partial interface mixin definition must be the same as the identifier of an interface mixin definition. All of the members that appear on each of the partial interface mixin definitions are considered to be members of the interface mixin itself, and—by extension—of the interfaces that include the interface mixin.
interface mixin `SomeMixin^mk { /* mixin_members... */ }; partial interface mixin `SomeMixin^mk { /* mixin_members... */ };
~mbたちが現れる順序は、 ~ES言語束縛 における~prop列挙に,有意になる。 ◎ The order that members appear in has significance for property enumeration in the ECMAScript binding.
`~ifc$や`辞書$と違って、`~ifc~mixin$は,型を作成しないことに注意。 ◎ Note that unlike interfaces or dictionaries, interface mixins do not create types.
この仕様に定義される拡張属性のうち,`~ifc~mixin$に適用-可能な拡張属性は、 `Exposed$x, `SecureContext$x に限られる。 ◎ Of the extended attributes defined in this specification, only the [Exposed] and [SecureContext] extended attributes are applicable to interface mixins.
`~includes文@ は、 ( 1 個目の`識別子$により識別される)`~ifc$ %I が ( 2 個目の`識別子$により識別される)`~ifc~mixin$ %M を `内包-@ すること — すなわち, %I を実装しているどの~objも %M を成す各~mbも内包し~MUSTこと — を宣言するために利用される,`定義$( `IncludesStatement$g に合致)である。 ◎ An includes statement is a definition (matching IncludesStatement) used to declare that all objects implementing an interface I (identified by the first identifier) must additionally include the members of interface mixin M (identified by the second identifier). Interface I is said to include interface mixin M.
`interface_identifier^i includes `mixin_identifier^i;
1 個目の`識別子$は [ `呼戻~ifc$/`~ifc$ ]を参照し~MUST。 2 個目の識別子は `~ifc~mixin$を参照し~MUST。 ◎ The first identifier must reference a non-callback interface I. The second identifier must reference an interface mixin M.
%M を成す各`~ifc~mixin~mb$は、 %M を`内包-$する各`~ifc$[ %I, %J, %K, … ]を成す`~mb$と見なされる — 各~ifcごとに,`~ifc~mixin~mb$の複製が作られたかのように。 すなわち、 %M のある~mb %m に対し,~ifc[ %I / %J / %K / … ]は`~mb$[ %m%I / %m%J / %m%K / … ]を持つと見なされる。 [ %m%I / %m%J / %m%K / … ]の `~host~ifc@ は、[ %I / %J / %K / 等々 ]になる。 ◎ Each member of M is considered to be a member of each interface I, J, K, … that includes M, as if a copy of each member had been made. So for a given member m of M, interface I is considered to have a member mI, interface J is considered to have a member mJ, interface K is considered to have a member mK, and so on. The host interfaces of mI, mJ, and mK, are I, J, and K respectively.
注記: このことは,~ESにおいては、次のことを含意する — `~ifc~mixin$ %M にて`~ifc~mixin~mb$として宣言された各 %m に対し:
- %m は[ `正則~演算$であり,`組込みの関数~obj$値を伴うものとして公開される~data-prop ]になるならば、[ %M を`内包-$する 各`~ifc$に結付けられている`~ifc原型~obj$ ]ごとに,別個の`組込みの関数~obj$がある。
- %m は`属性$ならば、その~accessor~propの各~複製ごとに別個の`組込みの関数~obj$が,[ 取得子 / 設定子 ]用にある。
`~includes文$が現れる順序は、`~ifc~mixin$が`~host~ifc$に`内包-$される順序に影響する。 【その順序は何に影響する?】 ◎ The order of appearance of includes statements affects the order in which interface mixin are included by their host interface.
`~ifc~mixin~mb$の順序は、まだ明瞭に指定されていない — 特に、`~ifc~mixin$が別々の文書~内に定義されている場合には。 issue #432 にて論じられている。 ◎ Member order isn’t clearly specified, in particular when interface mixins are defined in separate documents. It is discussed in issue #432.
`~includes文$に適用-可能な`拡張属性$は、この仕様には定義されていない。 ◎ No extended attributes defined in this specification are applicable to includes statements.
次の`~IDL片$は、[ `~ifc$ `Entry^T, `~ifc~mixin$ `Observable^T ]を定義する。 `~includes文$は、[ `Observable^T の`~ifc~mixin~mb$は, `Entry^T を実装している~objに常に内包される ]ことを指定する。 ◎ The following IDL fragment defines an interface, Entry, and an interface mixin, Observable. The includes statement specifies that Observable’s members are always included on objects implementing Entry.
interface Entry { readonly attribute unsigned short entryType; /* */ }; interface mixin Observable { void addEventListener(DOMString %type, EventListener %listener, boolean %useCapture); /* */ }; Entry includes Observable;
~ES実装は、各 `Entry^T ごとに,その原型鎖~内に `addEventListener^jp ~propを有することになる: ◎ An ECMAScript implementation would thus have an addEventListener property in the prototype chain of every Entry:
var %e = getEntry(); /*
`Entry^T の~instanceを得る。
◎
Obtain an instance of Entry.
*/
typeof %e.addEventListener; /* */
2.3.1. ~mixinと~partialの用法
~INFORMATIVE`~ifc~mixin$は、[ `属性$ / `定数$ / `演算$ ]を,複数の`~ifc$から共有できるようにする。 単独の~ifcを拡張したければ、代わりに`部分的~ifc$の利用を考えるであろう。 ◎ Interface mixins allow the sharing of attributes, constants, and operations across multiple interfaces. If you’re only planning to extend a single interface, you might consider using a partial interface instead.
例えば,次に代えて: ◎ For example, instead of:
interface mixin WindowSessionStorage { readonly attribute Storage sessionStorage; }; Window includes WindowSessionStorage;
次にするなど: ◎ do:
partial interface Window { readonly attribute Storage sessionStorage; };
加えて,共通的な利用事例 — 一連の[ `属性$, `定数$, `演算$ ]の集合を, ~window, ~worker 両~文脈に`公開され$るようにするなど — を~~対象にするため、他の仕様により公開される`~ifc~mixin$を拡張することに依拠できる。 ◎ Additionally, you can rely on extending interface mixins exposed by other specifications to target common use cases, such as exposing a set of attributes, constants, or operations across both window and worker contexts.
例えば、共通的にあるが冗長な,次のものに代えて: ◎ For example, instead of the common but verbose:
interface mixin GlobalCrypto { readonly attribute Crypto crypto; }; Window includes GlobalCrypto; WorkerGlobalScope includes GlobalCrypto;
`部分的~ifc~mixin$を用いれば, `WindowOrWorkerGlobalScope$T `~ifc~mixin$を拡張できる: ◎ you can extend the WindowOrWorkerGlobalScope interface mixin using a partial interface mixin:
partial interface mixin WindowOrWorkerGlobalScope { readonly attribute Crypto crypto; };
2.4. ~mb
[ `~ifc$ / `~ifc~mixin$ / `~ns$ ]は、その宣言を成す波括弧の合間に現れる,一連の `~mb@ — [ `定数$, `属性$, `演算$, その他の宣言 ] — からなる集合の仕様である(順に, `InterfaceMembers$g / `MixinMembers$g / `NamespaceMembers$g に合致)。 %A を実装している~objを %O とするとき ⇒# `属性$は、 %O が公開することになる状態を述べる。 `演算$は、 %O 上で呼出せる挙動を述べる。 `定数$は、 %O に公開される有名~定数~値を宣言する — ~systemにおける %O の利用者~用の便利として。 ◎ Interfaces, interface mixins, and namespaces are specifications of a set of members (respectively matching InterfaceMembers, MixinMembers, and NamespaceMembers), which are the constants, attributes, operations, and other declarations that appear between the braces of their declarations. Attributes describe the state that an object implementing the interface, interface mixin, or namespace will expose, and operations describe the behaviors that can be invoked on the object. Constants declare named constant values that are exposed as a convenience to users of objects in the system.
[ `~ifc$, `~ifc~mixin$, `~ns$ ]が~supportする`~mb$の~~種類は、それぞれに異なる — それらは順に `idl-interfaces$sec, `idl-interface-mixins$sec, `idl-namespaces$sec にて指定され,次の表(参考)に要約される: ◎ Interfaces, interface mixins, and namespaces each support a different set of members, which are specified in §2.2 Interfaces, §2.3 Interface mixins, and §2.5 Namespaces, and summarized in the following informative table:
`~ifc$ | `呼戻~ifc$ | `~ifc~mixin$ | `~ns$ | |
---|---|---|---|---|
`定数$ | ● | ● | ● | |
`正則~属性$ | ● | ● | ● | `読専$な属性のみ |
`静的~属性$ | ● | |||
`正則~演算$ | ● | ● | ● | ● |
`特殊~演算$ | ● | `文字列化子$のみ | ||
`静的~演算$ | ● | |||
`可反復~宣言$ | ● | |||
`~maplike 宣言$ | ● | |||
`~setlike 宣言$ | ● |
2.4.1. 定数
`定数@ は、定数~値を名前に束縛するために利用される,宣言( `Const$g に合致)である。 定数は`~ifc$に現れ得る。 ◎ A constant is a declaration (matching Const) used to bind a constant value to a name. Constants can appear on interfaces.
過去においては,定数は、主に,有名~整数~codeを列挙する~styleで定義されていた。 ~Web~platformは、文字列~利用の支持を受けて,この設計~patternから離れつつある。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use Constants$fI した上で論交することを,強く勧める。 ◎ Constants have in the past primarily been used to define named integer codes in the style of an enumeration. The Web platform is moving away from this design pattern in favor of the use of strings. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
const `type^i `constant_identifier^i = 42;
`定数$の`識別子$は[ 同じ~ifc上で定義される別の`~ifc~mb$ ]の識別子と同じになっては~MUST_NOT。 また、識別子が[ `length^l / `name^l / `prototype^l ]になっては~MUST_NOT。 ◎ The identifier of a constant must not be the same as the identifier of another interface member defined on the same interface. The identifier also must not be "length", "name" or "prototype".
これらの名前は、`関数~obj$に存在する~propの名前である。 ◎ Note: These three names are the names of properties that may exist on function objects at the time the function object is created in the ECMAScript language binding.
定数の型( `ConstType$g に合致)は、[ `~primitive型$または`~nullable$~primitive型 ]で~MUST。 `識別子$が利用される場合、その識別子は[ ~primitive型または~nullable~primitive型 ]の`~typedef$を参照し~MUST。 ◎ The type of a constant (matching ConstType) must not be any type other than a primitive type or a nullable primitive type. If an identifier is used, it must reference a typedef whose type is a primitive type or a nullable primitive type.
定数~宣言の `ConstValue$g 部は定数の値を与え、次のいずれかとして与えられる `定数~token@ をとり得る:
- 2 個の真偽~literal: `true^c と `false^c
- `null^c
- `integer$g
- `float$g
- 3 個の特別な浮動小数点~定数~値: `-Infinity^c, `Infinity^c, `NaN^c
【 “定数~token” は、簡潔に総称できるよう,この訳にて導入した用語である。 】
◎ The ConstValue part of a constant declaration gives the value of the constant, which can be one of the two boolean literal tokens (true and false), the null token, an integer token, a float token, or one of the three special floating point constant values (-Infinity, Infinity and NaN).注記: 文字列や空~連列に加え,これらの値も[ 辞書~mbの`既定~値$diCや, `随意~引数$の`既定~値$ ]を指定するために利用できる。 文字列や空~連列 `[]^c は、`定数$の値には利用できないことに注意。 ◎ Note: These values – in addition to strings and the empty sequence – can also be used to specify the default value of a dictionary member or of an optional argument. Note that strings and the empty sequence [] cannot be used as the value of a constant.
真偽~literal~tokenの値は、それぞれ, ~IDL `boolean$T 値[ `true^V, `false^V ]になる。 ◎ The value of the boolean literal tokens true and false are the IDL boolean values true and false.
`integer$g ~tokenの値は、それを成す文字~並び %S に対し,次に従って決定される整数~値になる: ◎ The value of an integer token is an integer whose value is determined as follows: • Let S be the sequence of characters matched by the integer token.
- %符号 ~LET 1 ◎ ↓
- ~IF[ %S の先頭の文字 ~EQ `002D^U1 ] ⇒# %符号 ~SET −1; %S から先頭の文字を除去する ◎ Let sign be −1 if S begins with U+002D HYPHEN-MINUS ("-"), and 1 otherwise.
-
%基数 ~LET %S の頭部の文字~並びに応じて ⇒# `0X^l ( `0030^U1 `0058^U1 )ならば 16 / `0x^l ( `0030^U1 `0078^U1 )ならば 16 / `0030^U1 ならば 8 / ~ELSE_ 10 ◎ Let base be the base of the number based on the characters that follow the optional leading U+002D HYPHEN-MINUS ("-") character: ◎ U+0030 DIGIT ZERO ("0"), U+0058 LATIN CAPITAL LETTER X ("X") U+0030 DIGIT ZERO ("0"), U+0078 LATIN SMALL LETTER X ("x") • The base is 16. U+0030 DIGIT ZERO ("0") • The base is 8. Otherwise • The base is 10.
- ~IF[ %基数 ~EQ 16 ] ⇒ %S の先頭から 2 個の文字を除去する ◎ ↓
- %数 ~LET %S を基数 %基数 に基づいて整数に解釈した結果 ◎ Let number be the result of interpreting all remaining characters following the optional leading U+002D HYPHEN-MINUS ("-") character and any characters indicating the base as an integer specified in base base.
- ~RET %符号 ~MUL %数 ◎ Return sign × number.
`integer$g ~tokenの型は、それを値に利用している[ 定数/辞書~mb/随意~引数 ]の型と同じである。 `integer$g ~tokenの値は、 `idl-types$sec で与えられる,その型の値として妥当な範囲に入ら~MUST。 ◎ The type of an integer token is the same as the type of the constant, dictionary member or optional argument it is being used as the value of. The value of the integer token must not lie outside the valid range of values for its type, as given in §2.12 Types.
`float$g ~tokenの値は、それを値に利用している[ 定数/辞書~mb/随意~引数 ]の型に依存して,単精度, 倍精度 いずれかの IEEE 754 浮動小数点数になり、次に従って決定される: ◎ The value of a float token is either an IEEE 754 single-precision floating point number or an IEEE 754 double-precision floating point number, depending on the type of the constant, dictionary member or optional argument it is being used as the value for, determined as follows:
- %S ~LET `float$g ~tokenに合致する文字~並び ◎ Let S be the sequence of characters matched by the float token.
- %result ~LET %S を~ES `NumericLiteral$i として構文解析して得られる `Mathematical Value^i ◎ Let result be the Mathematical Value that would be obtained if S were parsed as an ECMAScript NumericLiteral.
-
`float$g ~tokenは どの型の値として利用されているかに応じて:
- `float$T
- `unrestricted float$T
- ~RET %result に最も近い IEEE 754 単精度 浮動小数点数
- `double$T
- `unrestricted double$T
- ~RET %result に最も近い IEEE 754 倍精度 浮動小数点数
`IEEE-754$r
◎ If the float token is being used as the value for a float or unrestricted float, then the value of the float token is the IEEE 754 single-precision floating point number closest to result. ◎ Otherwise, the float token is being used as the value for a double or unrestricted double, and the value of the float token is the IEEE 754 double-precision floating point number closest to result. [IEEE-754]
`Infinity^c, `-Infinity^c, `NaN^c のいずれかとして指定された定数~値は、それを値に利用している[ 定数/辞書~mb/随意~引数 ]の型に依存して,単精度, 倍精度 いずれかの IEEE 754 浮動小数点数になり、次に従って決定される: ◎ The value of a constant value specified as Infinity, -Infinity or NaN is either an IEEE 754 single-precision floating point number or an IEEE 754 double-precision floating point number, depending on the type of the constant, dictionary member or optional argument is is being used as the value for:
- `unrestricted float$T 型の定数~値 `Infinity^c ◎ Type unrestricted float, constant value Infinity
- 値は IEEE 754 単精度,正の無限~値 ◎ The value is the IEEE 754 single-precision positive infinity value.
- `unrestricted double$T 型の定数~値 `Infinity^c ◎ Type unrestricted double, constant value Infinity
- 値は IEEE 754 倍精度,正の無限~値 ◎ The value is the IEEE 754 double-precision positive infinity value.
- `unrestricted float$T 型の定数~値 `-Infinity^c ◎ Type unrestricted float, constant value -Infinity
- 値は IEEE 754 単精度,負の無限~値 ◎ The value is the IEEE 754 single-precision negative infinity value.
- `unrestricted double$T 型の定数~値 `-Infinity^c ◎ Type unrestricted double, constant value -Infinity
- 値は IEEE 754 倍精度,負の無限~値 ◎ The value is the IEEE 754 double-precision negative infinity value.
- `unrestricted float$T 型の定数~値 `NaN^c ◎ Type unrestricted float, constant value NaN
- 値は~bit~pattern `7fc00000^X の, IEEE 754 単精度 NaN ◎ The value is the IEEE 754 single-precision NaN value with the bit pattern 0x7fc00000.
- `unrestricted double$T 型の定数~値 `NaN^c ◎ Type unrestricted double, constant value NaN
- 値は~bit~pattern `7ff8000000000000^X の, IEEE 754 倍精度 NaN ◎ The value is the IEEE 754 double-precision NaN value with the bit pattern 0x7ff8000000000000.
`float$g ~tokenの型は、それを値に利用している[ 定数/辞書~mb/随意~引数 ]の型と同じになる。 `float$g ~tokenの値は、 `idl-types$sec で与えられる,その型の値として妥当な範囲に入ら~MUST。 また、[ `Infinity^c, `-Infinity^c, `NaN^c ]が[ `float$T や `double$T ]の値として利用されては~MUST_NOT。 ◎ The type of a float token is the same as the type of the constant, dictionary member or optional argument it is being used as the value of. The value of the float token must not lie outside the valid range of values for its type, as given in §2.12 Types. Also, Infinity, -Infinity and NaN must not be used as the value of a float or double.
`null^c ~tokenの値は、`~nullable型$に属する特別な `null^V 値である。 `null^c ~tokenの型は、それを値に利用している[ 定数/辞書~mb/随意~引数 ]の型と同じになる。 ◎ The value of the null token is the special null value that is a member of the nullable types. The type of the null token is the same as the type of the constant, dictionary member or optional argument it is being used as the value of.
%VT を定数にあてがわれる値の型, %DT を[ 定数/辞書~mb/随意~引数 ]自身の型とするとき、これらの型は互換,すなわち %DT と %VT が一致するか, または %DT はその`内縁~型$が %VT であるような`~nullable型$でなければ~MUST。 ◎ If VT is the type of the value assigned to a constant, and DT is the type of the constant, dictionary member or optional argument itself, then these types must be compatible, which is the case if DT and VT are identical, or DT is a nullable type whose inner type is VT.
`定数$は、それが現れる`~ifc$の特定0の~instanceには結付けられない。 `定数$が~instanceにも公開されるかどうかは、言語束縛に特有になる。 ◎ Constants are not associated with particular instances of the interface on which they appear. It is language binding specific whether constants are exposed on instances.
~ES言語束縛では,しかしながら、`定数$が宣言されている~IDL`~ifc$を実装する~objを通して,`定数$への~accessが許容される。 例えば次の~IDLでは: ◎ The ECMAScript language binding does however allow constants to be accessed through objects implementing the IDL interfaces on which the constants are declared. For example, with the following IDL:
[Exposed=Window] interface A { const short rambaldi = 47; };
~ESにおいては、この定数~値は,[ `A.rambaldi^c および (`A^T の~instance)`.rambaldi^c ]として~accessできる。 ◎ the constant value can be accessed in ECMAScript either as A.rambaldi or instanceOfA.rambaldi.
定数に適用-可能な拡張属性は ⇒ `Exposed$x, `SecureContext$x ◎ The following extended attributes are applicable to constants: [Exposed], [SecureContext].
次の`~IDL片$に、上の型の`定数$を定義する例を示す。 ◎ The following IDL fragment demonstrates how constants of the above types can be defined.
[Exposed=Window] interface Util { const boolean DEBUG = false; const octet LF = 10; const unsigned long BIT_MASK = 0x0000fc00; const double AVOGADRO = 6.022e23; };
2.4.2. 属性
`属性@ ( `inherit^sym `ReadOnly$g `AttributeRest$g / `static^sym `ReadOnly$g `AttributeRest$g / `stringifier^sym `ReadOnly$g `AttributeRest$g / `ReadOnly$g `AttributeRest$g いずれかに合致)は、`~ifc~mb$であり,次を宣言するために利用される ⇒ 当の`~ifc$を実装している~objは、所与の[ 型, `識別子$ ]により,値の取得0や(一部の場合は)変更を行える~data~fieldを持つ ◎ An attribute is an interface member (matching inherit ReadOnly AttributeRest, static ReadOnly AttributeRest, stringifier ReadOnly AttributeRest, or ReadOnly AttributeRest) that is used to declare data fields with a given type and identifier whose value can be retrieved and (in some cases) changed.\
`属性$は、次の 2 種類に分けられる: ◎ There are two kinds of attributes:
-
`正則~属性$は、次を宣言するために利用される ⇒ 当の`~ifc$を実装している~objは、所与の`識別子$を伴う~data~field~mbを持つ ◎ regular attributes, which are those used to declare that objects implementing the interface will have a data field member with the given identifier
interface `interface_identifier^i { attribute `type^i `identifier^i; };
-
`静的~属性$は、次を宣言するために利用される ⇒ 当の~ifcを実装している特定0の~objには結付けられない属性 ◎ static attributes, which are used to declare attributes that are not associated with a particular object implementing the interface
interface `interface_identifier^i { static attribute `type^i `identifier^i; };
`static^c ~keywordを伴わない属性は `正則~属性@ を宣言する。 そうでなければ,`静的~属性$を宣言する。 `読専$な`正則~属性$には、`~ifc~mb$以外にも,`~ns~mb$であるものもあることに注意。 ◎ If an attribute has no static keyword, then it declares a regular attribute. Otherwise, it declares a static attribute. Note that in addition to being interface members, read only regular attributes can be namespace members as well.
`属性の下層~値を取得する@ ときは、所与の ( %~target, 属性 %属性 ) に対し,次を走らす:
- ~IF[ %属性 は`取得子を継承-$するように宣言されている ] ⇒ %属性 ~SET 継承されている属性
- ~RET [ %属性 の取得子の記述に挙げられている動作 ]を — %~target ~NEQ ~NULL ならば %~target 上で — 遂行した結果
`属性$の`識別子$は[ 同じ`~ifc$上に定義される別の`~ifc~mb$の識別子 ]と同じになっては~MUST_NOT。 静的~属性の識別子が `prototype^l になっては~MUST_NOT。 ◎ The identifier of an attribute must not be the same as the identifier of another interface member defined on the same interface. The identifier of a static attribute must not be "prototype".
属性の型は、 `attribute^c ~keywordの後に現れる型( `Type$g に合致)で与えられる。 `Type$g が[ `識別子$, または `?^c が後続する識別子 ]である場合、その識別子は[ `~ifc$/`列挙$/`呼戻~関数$/`~typedef$ ]を識別し~MUST。 ◎ The type of the attribute is given by the type (matching Type) that appears after the attribute keyword. If the Type is an identifier or an identifier followed by ?, then the identifier must identify an interface, enumeration, callback function or typedef.
属性の型は、~typedefの解決-後に,次に挙げる型, あるいはその`~nullable型$になっては~MUST_NOT。 ◎ The type of the attribute, after resolving typedefs, must not be a nullable or non-nullable version of any of the following types:
- `連列~型$ ◎ a sequence type
- `辞書~型$ ◎ a dictionary type
- `~record型$ ◎ a record type
- その`平坦化~mb型$に[ [ ~nullable/非~nullable ]の連列~型 / 辞書 / ~record ]を含んでいるような,`共用体~型$ 【平坦化~mb型は~nullableを含み得ないので,この “~nullable” の記述は不要では?】 ◎ a union type that has a nullable or non-nullable sequence type, dictionary, or record as one of its flattened member types
`attribute^c ~keywordの前に `readonly^c ~keywordが利用されている場合、属性は `読専@( `read only^en, 読み取り専用) になる。 [ 読専の属性が定義されている~ifc ]を実装する~objにおいては、その属性に対する代入は許容されないことになる。 代入が、単に言語において許容されないのか, 無視されるのか, あるいは例外が投出されるのか,については、言語束縛に特有になる。 ◎ The attribute is read only if the readonly keyword is used before the attribute keyword. An object that implements the interface on which a read only attribute is defined will not allow assignment to that attribute. It is language binding specific whether assignment is simply disallowed by the language, ignored or an exception is thrown.
interface `interface_identifier^i { readonly attribute `type^i `identifier^i; };
`~promise型$である属性は、`読専$で~MUST。 加えて、次の`拡張属性$は持てない ⇒ `LenientSetter$x, `PutForwards$x, `Replaceable$x, `SameObject$x ◎ Attributes whose type is a promise type must be read only. Additionally, they cannot have any of the extended attributes [LenientSetter], [PutForwards], [Replaceable], or [SameObject].
`読専$でない`正則~属性$は、先祖の~ifcからその `取得子を継承-@ するように宣言できる。 これにより、先祖~ifcの読専の属性を,派生~ifc上で~writableにできる。 属性は、その宣言が `inherit^c を伴うとき,`取得子を継承-$するものとされる。 その属性が取得子を継承する読専の属性は、[ 同じ識別子の属性が定義されている,先祖の~ifc ]のうち,最も末端の~ifcに属する属性である。 取得子を[ 継承する側, される側 ]の属性の型は同じで~MUST。 また、 `inherit^c が[ `読専$な属性/`静的~属性$ ]に現れては~MUST_NOT。 ◎ A regular attribute that is not read only can be declared to inherit its getter from an ancestor interface. This can be used to make a read only attribute in an ancestor interface be writable on a derived interface. An attribute inherits its getter if its declaration includes inherit in the declaration. The read only attribute from which the attribute inherits its getter is the attribute with the same identifier on the closest ancestor interface of the one on which the inheriting attribute is defined. The attribute whose getter is being inherited must be of the same type as the inheriting attribute, and inherit must not appear on a read only attribute or a static attribute.
[Exposed=Window] interface `Ancestor^i { readonly attribute `TheType^i `theIdentifier^i; }; [Exposed=Window] interface `Derived^i : `Ancestor^i { inherit attribute `TheType^i `theIdentifier^i; };
`正則~属性$の宣言に `stringifier^c ~keywordが利用されている場合、その~ifcを実装している~objが文字列化されるときに,その属性の値になることを指示する。 詳細は `idl-stringifiers$sec を見よ。 ◎ When the stringifier keyword is used in a regular attribute declaration, it indicates that objects implementing the interface will be stringified to the value of the attribute. See §2.4.4.1 Stringifiers for details.
interface `interface_identifier^i { stringifier attribute DOMString `identifier^i; };
実装が`利用元~obj$上の`属性$の値を取得-または設定しようと試みたときに(例えば 呼戻~objが実装に給されているとき),その試みによる~~結果,例外が投出される場合、他が指定されない限り,その例外は[ 実装からその属性への~accessを生じさせた,利用元~code ]まで伝播することになる。 同様に、属性の取得-により返される値を~IDL型の値に変換できない場合、それにより生じた例外も[ 実装からその属性の値の取得を試みさせた,利用元~code ]まで伝播することになる。 ◎ If an implementation attempts to get or set the value of an attribute on a user object (for example, when a callback object has been supplied to the implementation), and that attempt results in an exception being thrown, then, unless otherwise specified, that exception will be propagated to the user code that caused the implementation to access the attribute. Similarly, if a value returned from getting the attribute cannot be converted to an IDL type, then any exception resulting from this will also be propagated to the user code that resulted in the implementation attempting to get the value of the attribute.
[ 正則/静的 ]属性に適用-可能な拡張属性は ⇒ `Exposed$x, `SameObject$x, `SecureContext$x ◎ The following extended attributes are applicable to regular and static attributes: [Exposed], [SameObject], [SecureContext].
次の`拡張属性$は、正則~属性にしか適用-可能でない ⇒ `LenientSetter$x, `LenientThis$x, `PutForwards$x, `Replaceable$x, `Unforgeable$x ◎ The following extended attributes are applicable only to regular attributes: [LenientSetter], [LenientThis], [PutForwards], [Replaceable], [Unforgeable].
次の`~IDL片$に,`~ifc$上にて`属性$を宣言する例を示す: ◎ The following IDL fragment demonstrates how attributes can be declared on an interface:
[Exposed=Window] interface Animal { /* 単純な,任意の文字列に設定され得る属性。 ◎ A simple attribute that can be set to any string value. */ readonly attribute DOMString name; /* 値を代入できる属性。 ◎ An attribute whose value can be assigned to. */ attribute unsigned short age; }; [Exposed=Window] interface Person : Animal { /* 取得子の挙動を `Animal^T から継承する属性。 `Person^T の記述にて指定する必要はない。 ◎ An attribute whose getter behavior is inherited from Animal, and need not be specified in the description of Person. */ inherit attribute DOMString name; };
2.4.3. 演算
`演算@ ( `static^sym `RegularOperation$g / `stringifier^sym `RegularOperation$g / `RegularOperation$g / `SpecialOperation$g いずれかに合致)は、`~ifc~mb$であり,その~ifcを実装している~obj上で呼出せる挙動を定義する。 ◎ An operation is an interface member (matching static RegularOperation, stringifier RegularOperation, RegularOperation or SpecialOperation) that defines a behavior that can be invoked on objects implementing the interface.\
演算には次の 3 種類がある: ◎ There are three kinds of operation:
-
`正則~演算$は、次を宣言するために利用される ⇒ 当の`~ifc$を実装している~objは、所与の`識別子$を伴う~methを持つ ◎ regular operations, which are those used to declare that objects implementing the interface will have a method with the given identifier
interface `interface_identifier^i { `return_type^i `identifier^i(/* arguments... */); };
-
`特殊~演算$は、次を宣言するために利用される ⇒ ~objの~index法や文字列化などの,当の~ifcを実装している~obj上の特殊な挙動 ◎ special operations, which are used to declare special behavior on objects implementing the interface, such as object indexing and stringification
interface `interface_identifier^i { /* special_keywords... */ `return_type^i `identifier^i(/* arguments... */); /* special_keywords... */ `return_type^i (/* arguments... */); };
-
`静的~演算$は、次を宣言するために利用される ⇒ 当の~ifcを実装している特定0の~objには結付けられない演算 ◎ static operations, which are used to declare operations that are not associated with a particular object implementing the interface
interface `interface_identifier^i { static `return_type^i `identifier^i(/* arguments... */); };
演算のうち,[ 識別子を持つ ]~AND[ `static^sym ~keywordは伴わない ]ものは、 `正則~演算@ を宣言する。 `特殊~keyword$(すなわち,[ `Special$g に合致する~keyword, または `stringifier^c ~keyword ])が宣言に利用されている演算は,`特殊~演算$を宣言する。 演算を,正則~演算と特殊~演算を兼ねるように宣言することもできる。 特殊~演算についての詳細は、 `idl-special-operations$sec を見よ。 `正則~演算$には、`~ifc~mb$以外にも,`~ns~mb$であるものもあることに注意。 ◎ If an operation has an identifier but no static keyword, then it declares a regular operation. If the operation has a special keyword used in its declaration (that is, any keyword matching Special, or the stringifier keyword), then it declares a special operation. A single operation can declare both a regular operation and a special operation; see §2.4.4 Special operations for details on special operations. Note that in addition to being interface members, regular operations can also be namespace members.
識別子を持たない演算は、いずれかの特殊~keywordを利用して,`特殊~演算$として宣言され~MUST。 ◎ If an operation has no identifier, then it must be declared to be a special operation using one of the special keywords.
`正則~演算$/`静的~演算$の識別子は、同じ`~ifc$上に定義される`定数$や`属性$の識別子と同じになっては~MUST_NOT。 静的~演算の識別子は `prototype^l になっては~MUST_NOT。 ◎ The identifier of a regular operation or static operation must not be the same as the identifier of a constant or attribute defined on the same interface. The identifier of a static operation must not be "prototype".
注記: しかしながら、識別子をその~ifc上の別の演算と同じにすることはできる。 演算の多重定義は、これにより指定される。 ◎ Note: The identifier can be the same as that of another operation on the interface, however. This is how operation overloading is specified.
`静的~演算$の`識別子$は、同じ`~ifc$上に定義される`正則~演算$の識別子と同じになっては~MUST_NOT。 ◎ The identifier of a static operation also must not be the same as the identifier of a regular operation defined on the same interface.
演算の `返値型@ ( `ReturnType$g に合致)は、[ 随意の[ 演算の`識別子$ ]]の前に現れる型で与えられる。 返値型 `void@T は,演算は値を返さないことを指示する。 返値型が `?^c 付きの`識別子$である場合、その識別子は[ `~ifc$/`辞書$/`列挙$/`呼戻~関数$/`~typedef$ ]を識別し~MUST。 ◎ The return type of the operation is given by the type (matching ReturnType) that appears before the operation’s optional identifier. A return type of void indicates that the operation returns no value. If the return type is an identifier followed by ?, then the identifier must identify an interface, dictionary, enumeration, callback function or typedef.
演算の引数( `ArgumentList$g に合致)は、宣言の中の丸括弧の合間にて与えられる。 それぞれの引数は、型( `Type$g に合致)の後に `識別子$( `ArgumentName$g に合致)を続けて指定される。 ◎ An operation’s arguments (matching ArgumentList) are given between the parentheses in the declaration. Each individual argument is specified as a type (matching Type) followed by an identifier (matching ArgumentName).
注記: 表現力のため、演算~引数の識別子には, `ArgumentNameKeyword$g 記号に合致する~keywordも,~escapeを要することなく 指定できる。 ◎ Note: For expressiveness, the identifier of an operation argument can also be specified as one of the keywords matching the ArgumentNameKeyword symbol without needing to escape it.
演算~引数の型を与える `Type$g が:
- `?^c が後続する`識別子$である場合、その識別子は[ `~ifc$/`列挙$/`呼戻~関数$/`~typedef$ ]を識別し~MUST。
- `?^c が後続しない`識別子$である場合、その識別子は[ `辞書$/前項に挙げたいずれかの定義 ]を識別し~MUST。
演算~引数の型が`~typedef$の解決-後に`~nullable型$になる場合、その`内縁~型$は`辞書~型$になっては~MUST_NOT。 ◎ If the operation argument type, after resolving typedefs, is a nullable type, its inner type must not be a dictionary type.
interface `interface_identifier^i { `return_type^i `identifier^i(`type^i `identifier^i, `type^i `identifier^i /* , ... */); };
各~引数の識別子は、同じ演算~宣言~内の他の引数の識別子と同じになっては~MUST_NOT。 ◎ The identifier of each argument must not be the same as the identifier of another argument in the same operation declaration.
各~引数の前には、`拡張属性$の~list( `ExtendedAttributeList$g に合致)を置くことができる — それらは、その引数として渡された値が,言語束縛において どう取扱われるかを制御する。 ◎ Each argument can be preceded by a list of extended attributes (matching ExtendedAttributeList), which can control how a value passed as the argument will be handled in language bindings.
interface `interface_identifier^i { `return_type^i `identifier^i([`extended_attributes^mk] `type^i `identifier^i, [`extended_attributes^mk] `type^i `identifier^i /* , ... */); };
次の`~IDL片$は `~ifc$上に`正則~演算$を宣言する: ◎ The following IDL fragment demonstrates how regular operations can be declared on an interface:
[Exposed=Window] interface Dimensions { attribute unsigned long width; attribute unsigned long height; }; [Exposed=Window] interface Button { /* 引数をとらず, `boolean^T を返す演算 ◎ An operation that takes no arguments and returns a boolean. */ boolean isMouseOver(); /* 多重定義された演算。 ◎ Overloaded operations. */ void setDimensions(Dimensions %size); void setDimensions(unsigned long %width, unsigned long %height); };
演算の 最後の引数 の引数~型の直後に `...^c ~tokenが利用されている場合、その演算は `可変個的な@ もの( `variadic^en )と見なされ、その最後の引数を指して `可変個~引数@ という 【この用語は、参照し易くするため,この訳に導入している】 。 そのように宣言された演算は: ◎ An operation is considered to be variadic if the final argument uses the ... token just after the argument type.\
- `可変個~引数$の後に,任意~個数の引数を伴って呼出せることを指示し、それらの余分な暗黙の形式的~引数の型は,`可変個~引数$と同じ型と見なされる。 ◎ Declaring an operation to be variadic indicates that the operation can be invoked with any number of arguments after that final argument. Those extra implied formal arguments are of the same type as the final explicit argument in the operation declaration.\
- 呼出すときには、`可変個~引数$も省略できる。 ◎ The final argument can also be omitted when invoking the operation.\
- `可変個~引数$以外の引数は `...^c ~tokenを伴って宣言されては~MUST_NOT。 ◎ An argument must not be declared with the ... token unless it is the final argument in the operation’s argument list.
interface `interface_identifier^i { `return_type^i `identifier^i(`type^i... `identifier^i); `return_type^i `identifier^i(`type^i `identifier^i, `type^i... `identifier^i); };
`引数~listを引数にとる$`拡張属性$(この仕様で定義される `Constructor$x と `NamedConstructor$x ), および `呼戻~関数$についても、その引数~listに `...^c ~tokenが利用されているならば,`可変個的な$ものと見なされる。 【以下の記述における可変個的な演算の “演算” には,これらの(構築子を与える)拡張属性や呼戻子も含まれる。】 ◎ Extended attributes that take an argument list ([Constructor] and [NamedConstructor], of those defined in this specification) and callback functions are also considered to be variadic when the ... token is used in their argument lists.
次の`~IDL片$は,可変個的な演算を 2 つ持つ~ifcを定義する: ◎ The following IDL fragment defines an interface that has two variadic operations:
[Exposed=Window] interface IntegerSet { readonly attribute unsigned long cardinality; void union(long... %ints); void intersection(long... %ints); };
~ES言語束縛においては、可変個的な演算は,後続の引数を受容できる関数により実装される: ◎ In the ECMAScript binding, variadic operations are implemented by functions that can accept the subsequent arguments:
var %s = getIntegerSet(); /* `IntegerSet^T の~instanceを得る。 ◎ Obtain an instance of IntegerSet. */ %s.union(); /* `ints^l に対応する引数を~~省略。 ◎ Passing no arguments corresponding to 'ints'. */ %s.union(1, 4, 7); /* `ints^l に対応する 3 個の引数を渡す。 ◎ Passing three arguments corresponding to 'ints'. */
可変個的な関数を~supportしない言語~用の言語束縛においては、その種の演算には,整数の 配列または~list を明示的に渡すように指定することになるであろう。 ◎ A binding for a language that does not support variadic functions might specify that an explicit array or list of integers be passed to such an operation.
`optional^c ~keywordを伴って宣言された引数は、 `随意~引数@ であるものと見なされる。 `可変個的な$演算の`可変個~引数$も随意~引数と見なされる。 随意として宣言された引数は、演算を呼出すときに,その値を省略できることを指示する。 `可変個~引数$は、明示的に随意として宣言されては~MUST_NOT。 ◎ An argument is considered to be an optional argument if it is declared with the optional keyword. The final argument of a variadic operation is also considered to be an optional argument. Declaring an argument to be optional indicates that the argument value can be omitted when the operation is invoked. The final argument in an operation must not explicitly be declared to be optional if the operation is variadic.
interface `interface_identifier^i { `return_type^i `identifier^i(`type^i `identifier^i, optional `type^i `identifier^i); };
随意~引数には `既定~値@ を指定できる。 引数の識別子に `003D^U1 と値( `DefaultValue$g に合致)が後続している場合、その値がその随意~引数の `既定~値$ を与える。 ただし、`可変個的な$演算の`可変個~引数$には、既定~値が指定されては~MUST_NOT。 既定~値は、対応する引数が省略されて演算が~callされたときに,その引数がとる値と見做される。 ◎ Optional arguments can also have a default value specified. If the argument’s identifier is followed by a U+003D EQUALS SIGN ("=") and a value (matching DefaultValue), then that gives the optional argument its default value. The implicitly optional final argument of a variadic operation must not have a default value specified. The default value is the value to be assumed when the operation is called with the corresponding argument omitted.
interface `interface_identifier^i { `return_type^i `identifier^i(`type^i `identifier^i, optional `type^i `identifier^i = "`value^i"); };
`boolean$T 型の引数には、`既定~値$として `true^V を利用しないことを強く勧める。 さもなければ、 `undefined^jv に既定の変換(すなわち, `false^V )が利用されると期待する作者たちを惑わすことになるので。 ◎ It is strongly suggested not to use a default value of true for boolean-typed arguments, as this can be confusing for authors who might otherwise expect the default conversion of undefined to be used (i.e., false).
次をすべて満たす引数は、随意として指定され~MUST。 ◎ If\
- 引数の型は、[ `辞書~型$である ]~OR[ `共用体~型$であって,その`平坦化~mb型$に ある`辞書~型$を含んでいる ] ◎ the type of an argument is a dictionary type or a union type that has a dictionary as one of its flattened member types, and\
- 前項の辞書~型と その先祖には、必須の~mbは無い ◎ that dictionary type and its ancestors have no required members, and\
- [ 引数は最後の引数である ]~OR[ 引数に後続するどの引数も`随意~引数$である ] ◎ the argument is either the final argument or is followed only by optional arguments,\
そのような引数は、他が指定されない限り,常に[ 既定~値として,空の辞書をとる ]ものと見なされる。 【この辞書の各~mbは、`既定~値$diCがあれば それをとるものと扱われることになる。】 ◎ then the argument must be specified as optional. Such arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
注記: これは、作者が辞書の既定~値のみの利用を望むときでも,空の辞書~値を渡さずに済むような~APIの設計を促すためにある。 ◎ This is to encourage API designs that do not require authors to pass an empty dictionary value when they wish only to use the dictionary’s default values.
注記: 辞書~型には,既定~値を明示的には指定できないので、上の “他が指定されない限り” にて 他を指定できるものは,`平坦化~mb型$に辞書~型を含んでいる`共用体~型$に限られる。 ◎ Dictionary types cannot have a default value specified explicitly, so the “unless otherwise specified” clause above can only be invoked for a union type that has a dictionary type as one of its flattened member types.
`既定~値$に`定数~token$が利用された場合、`定数$に対するときと同じ仕方で解釈される。 ◎ When a boolean literal token (true or false), the null token, an integer token, a float token or one of the three special floating point literal values (Infinity, -Infinity or NaN) is used as the default value, it is interpreted in the same way as for a constant.
随意~引数の既定~値には、 `string$g ~tokenも指定できる。 それは、次に従って決定される`文字列~型$の値をとる: ◎ Optional argument default values can also be specified using a string token, whose value is a string type determined as follows:
- %S ~LET `string$g ~tokenに合致する[ `~Unicode~scalar値$の並び ]から,先頭と末尾の文字 `0022^U1 を除去したもの ◎ Let S be the sequence of Unicode scalar values matched by the string token with its leading and trailing U+0022 QUOTATION MARK ('"') characters removed.
-
`string$g ~tokenの値は、引数の型に応じて,次で与えられる: ◎ Depending on the type of the argument:
- `DOMString$T
- `列挙$ 型
- %S を~UTF-16符号化した結果に対応する, 16 ~bit無符号~整数~符号単位 — 以下、単に `符号単位@ と略称される — の並び ◎ The value of the string token is the sequence of 16 bit unsigned integer code units (hereafter referred to just as code units) corresponding to the UTF-16 encoding of S.
- `ByteString$T
- %S を~UTF-8符号化した結果に対応する, 8 ~bit無符号~整数~符号単位の並び ◎ The value of the string token is the sequence of 8 bit unsigned integer code units corresponding to the UTF-8 encoding of S.
- `USVString$T
- %S ◎ The value of the string token is S.
`随意~引数$の型が`列挙$である場合、その`既定~値$に指定される値は,その列挙を成すいずれかの`列挙~値$で~MUST。 ◎ If the type of the optional argument is an enumeration, then its default value if specified must be one of the enumeration’s values.
`連列~型$(`~nullable$も含む)の随意~引数の既定~値には、[ 2 個の~tokenが成す値 `[]^c ]を利用して,[ その型と同じ型の空~連列~値 ]を表現する値も指定できる。 この既定~値の型は、次のいずれかで~MUST ⇒# `連列~型$ / `~nullable$であって その`内縁~型$は`連列~型$であるもの / `共用体~型$または`~nullable$なそれであって その`平坦化~mb型$は`連列~型$を含むもの ◎ Optional argument default values can also be specified using the two token value [], which represents an empty sequence value. The type of this value is the same as the type of the optional argument it is being used as the default value of. That type must be a sequence type, a nullable type whose inner type is a sequence type or a union type or nullable union type that has a sequence type in its flattened member types.
次の`~IDL片$は、[ 2 通りの長さによる引数~listで呼出せる,単独の`演算$ ]を伴う`~ifc$を定義する: ◎ The following IDL fragment defines an interface with a single operation that can be invoked with two different argument list lengths:
[Exposed=Window] interface ColorCreator { object createColor(double %v1, double %v2, double %v3, optional double %alpha); };
それは、次の,`多重定義$された 2 つの`演算$を持つ`~ifc$と等価になる: ◎ It is equivalent to an interface that has two overloaded operations:
[Exposed=Window] interface ColorCreator { object createColor(double %v1, double %v2, double %v3); object createColor(double %v1, double %v2, double %v3, double %alpha); };
実装が`利用元~obj$上の`演算$の呼出しを試みた結果 (例えば,呼戻~objが実装に給されていて),例外が投出される場合、他が指定されない限り,その例外は[ 実装からその演算の呼出しを生じさせた,利用元~code ]まで伝播することになる。 同様に,演算の呼出しにより返される値を~IDL型に変換できない場合、それにより生じた例外も[ 実装からその演算の呼出しを試みさせた,利用元~code ]まで伝播することになる。 ◎ If an implementation attempts to invoke an operation on a user object (for example, when a callback object has been supplied to the implementation), and that attempt results in an exception being thrown, then, unless otherwise specified, that exception will be propagated to the user code that caused the implementation to invoke the operation. Similarly, if a value returned from invoking the operation cannot be converted to an IDL type, then any exception resulting from this will also be propagated to the user code that resulted in the implementation attempting to invoke the operation.
演算に適用-可能な拡張属性は ⇒ `Default$x, `Exposed$x, `NewObject$x, `SecureContext$x, `Unforgeable$x ◎ The following extended attributes are applicable to operations: [Default], [Exposed], [NewObject], [SecureContext], [Unforgeable].
2.4.3.1. ~toJSON
~toJSON`正則~演算$を宣言することにより、`~ifc$は,それを実装する~objを`~JSON型$に変換する方法を指定する。 ◎ By declaring a toJSON regular operation, an interface specifies how to convert the objects that implement it to JSON types.
~toJSON`正則~演算$は、この用法のために予約される。 それは、 0 個の引数をとり,`~JSON型$を返さ~MUST。 ◎ The toJSON regular operation is reserved for this usage. It must take zero arguments and return a JSON type.
次に挙げる型が `~JSON型@ とされる: ◎ The JSON types are:
- `実数~型$ ◎ numeric types,
- `boolean$T 型 ◎ boolean,
- `文字列~型$ ◎ string types,
- `~nullable型$のうち,その`内縁~型$は`~JSON型$であるもの ◎ nullable types whose inner type is a JSON type,
- `注釈付きの型$のうち,その`内縁~型$anOは`~JSON型$であるもの ◎ annotated types whose inner type is a JSON type,
- `共用体~型$のうち,その`~mb型$は`~JSON型$であるもの ◎ union types whose member types are JSON types,
- `~typedef$のうち,それにより`新たな名前が与えられる型$は`~JSON型$であるもの ◎ typedefs whose type being given a new name is a JSON type,
- `連列~型$のうち,その~parameter化された型は`~JSON型$であるもの ◎ sequence types whose parameterized type is a JSON type,
- `凍結~配列~型$のうち,その~parameter化された型は`~JSON型$であるもの ◎ frozen array types whose parameterized type is a JSON type,
- `辞書~型$のうち,[ 自身/自身の`継承d辞書$ ]に宣言された どの`辞書~mb$の型も `~JSON型$であるもの ◎ dictionary types where the types of all members declared on the dictionary and all its inherited dictionaries are JSON types,
- `~record型$のうち,そのすべての`値$は`~JSON型$であるもの ◎ records where all of their values are JSON types,
- `object$T 型 ◎ object,
- `~ifc型$のうち,[ 自身または`継承d~ifc$ ]上に~toJSON演算が宣言されているもの ◎ interface types that have a toJSON operation declared on themselves or one of their inherited interfaces.
言語束縛において~toJSON`正則~演算$を~obj上でどう可用にするか, および `~JSON型$を~JSON文字列に正確にどう変換するかは、言語束縛に特有になる。 ◎ How the toJSON regular operation is made available on an object in a language binding, and how exactly the JSON types are converted into a JSON string, is language binding specific.
注記: ~ES言語束縛においては、これは,~toJSON~methを公開することにより行われる — この~methは、`~JSON型$を[ `JSON.stringify()$c 関数により~JSON文字列に転換できるような,~ES値 ]に変換して返す。 加えて,~ES言語束縛においては、~toJSON演算は `Default$x `拡張属性$をとれる — その事例では、代わりに `既定の~toJSON演算$が公開される。 ◎ Note: In the ECMAScript language binding, this is done by exposing a toJSON method which returns the JSON type converted into an ECMAScript value that can be turned into a JSON string by the JSON.stringify() function. Additionaly, in the ECMAScript language binding, the toJSON operation can take a [Default] extended attribute, in which case the default toJSON operation is exposed instead.
次の`~IDL片$は、~toJSON~methを持つような `Transaction^T ~ifcを定義する — ~methは注釈文にて定義されることになる: ◎ The following IDL fragment defines an interface Transaction that has a toJSON method defined in prose:
[Exposed=Window] interface Transaction { readonly attribute DOMString from; readonly attribute DOMString to; readonly attribute double amount; readonly attribute DOMString description; readonly attribute unsigned long number; TransactionJSON toJSON(); }; dictionary TransactionJSON { Account from; Account to; double amount; DOMString description; };
`Transaction^T `~ifc$の~toJSON`正則~演算$は、[ 被呼出時には次の手続きを走らす ]ように定義することもできる: ◎ The toJSON regular operation of Transaction interface could be defined as follows: ◎ To invoke the toJSON() operation of the Transaction interface, run the following steps:
- %O ~LET 当の `Transaction^T ~obj ◎ ↓
- %json ~LET 新たな `TransactionJSON^T 辞書 ◎ Let json be a new TransactionJSON dictionary.
-
属性`識別子$の`~list$ « `from^l, `to^l, `amount^l, `description^l » 内の ~EACH( %識別子 ) に対し: ◎ For each attribute identifier attr in « "from", "to", "amount", "description" »:
- %json [ %識別子 ] ~SET `属性の下層~値を取得する$( %O, %識別子 で識別される`属性$ ) ◎ Let value be result of getting the underlying value of the attribute identified by attr, given this Transaction object. ◎ Set json[attr] to value.
- ~RET %json ◎ Return json.
~ES言語束縛においては、 `Transaction^T ~obj上に `toJSON()^M ~methが存在することになる: ◎ In the ECMAScript language binding, there would exist a toJSON() method on Transaction objects:
/* `Transaction^T の~instanceを取得する ◎ Get an instance of Transaction. */ var %txn = getTransaction(); /* 次の様な~objに評価される: ◎ Evaluates to an object like this: */ { from: "Bob", to: "Alice", amount: 50, description: "books" } */ %txn.toJSON(); /* 次の様な文字列に評価される: ◎ Evaluates to a string like this: */ '{"from":"Bob","to":"Alice","amount":50,"description":"books"}' */ JSON.stringify(%txn);
2.4.4. 特殊~演算
`特殊~演算@ は、[ その特殊~演算~宣言が現れる~ifc ]を実装する~obj上における[ 一定の種類の特殊な挙動 ]の宣言である。 `特殊~演算$は,演算~宣言において `特殊~keyword@ を利用して宣言される。 ◎ A special operation is a declaration of a certain kind of special behavior on objects implementing the interface on which the special operation declarations appear. Special operations are declared by using a special keyword in an operation declaration.
`特殊~演算$には、次の一覧に挙げる 4 種類がある。 一覧には、それぞれの種類の特殊~演算に対し,その宣言-時に利用される特殊~keyword, および演算の目的も示す: ◎ There are four kinds of special operations. The table below indicates for a given kind of special operation what special keyword is used to declare it and what the purpose of the special operation is:
`特殊~演算$◎ Special operation | ~keyword◎ Keyword | 目的◎ Purpose |
---|---|---|
`取得子@ | `getter^c | ~prop取得1 用に~objが~index-される際の挙動を定義する。 ◎ Defines behavior for when an object is indexed for property retrieval. |
`設定子@ | `setter^c | ~prop[ 代入/作成 ]用に~objが~index-される際の挙動を定義する。 ◎ Defines behavior for when an object is indexed for property assignment or creation. |
`削除子@ | `deleter^c | ~prop削除 用に~objが~index-される際の挙動を定義する。 ◎ Defines behavior for when an object is indexed for property deletion. |
`文字列化子@ | `stringifier^c | ~objを `DOMString$T に変換する方法を定義する。 ◎ Defines how an object is converted into a DOMString. |
すべての言語束縛が、[ これら 4 種類の,~objの特殊な挙動 ]すべてを~supportするわけではない。 `特殊~演算$が,識別子を伴わない演算を利用して宣言された場合、その特定0の種類の特殊~演算を~supportしない言語束縛においては,単にその機能性が存在しないことになる。 ◎ Not all language bindings support all of the five kinds of special object behavior. When special operations are declared using operations with no identifier, then in language bindings that do not support the particular kind of special operations there simply will not be such functionality.
次の~IDL片は、取得子と設定子を伴う~ifcを定義する: ◎ The following IDL fragment defines an interface with a getter and a setter:
[Exposed=Window] interface Dictionary { readonly attribute unsigned long propertyCount; getter double (DOMString %propertyName); setter void (DOMString %propertyName, double %propertyValue); };
~propの取得子や設定子を~supportしない言語束縛では、 `Dictionary^T を実装している~objはこの特殊な挙動を持たないことになる。 ◎ In language bindings that do not support property getters and setters, objects implementing Dictionary will not have that special behavior.
`特殊~演算$を`識別子$を伴わせて定義することは、その宣言から識別子のない特殊~演算を分離することと,等価である。 この書き方は、~ifcの演算についての注釈文の記述を単純化するために許容されている。 ◎ Defining a special operation with an identifier is equivalent to separating the special operation out into its own declaration without an identifier. This approach is allowed to simplify prose descriptions of an interface’s operations.
次の 2 つの~ifcは等価である: ◎ The following two interfaces are equivalent:
[Exposed=Window] interface Dictionary { readonly attribute unsigned long propertyCount; getter double getProperty(DOMString %propertyName); setter void setProperty(DOMString %propertyName, double %propertyValue); };
[Exposed=Window] interface Dictionary { readonly attribute unsigned long propertyCount; double getProperty(DOMString %propertyName); void setProperty(DOMString %propertyName, double %propertyValue); getter double (DOMString %propertyName); setter void (DOMString %propertyName, double %propertyValue); };
1 つの演算に同じ`特殊~keyword$が複数~回 現れては~MUST_NOT。 ◎ A given special keyword must not appear twice on an operation.
取得子, 設定子, 削除子は 2 種の系列に分類される: ◎ Getters and setters come in two varieties:\
- `有名~prop取得子@, `有名~prop設定子@, `有名~prop削除子@ と呼ばれる,~prop名として `DOMString$T をとるもの。 ◎ ones that take a DOMString as a property name, known as named property getters and named property setters, and\
- `有index~prop取得子@, `有index~prop設定子@ と呼ばれる,~prop~indexとして `unsigned long$T をとるもの — 有index~propには,削除子は無い。 ◎ ones that take an unsigned long as a property index, known as indexed property getters and indexed property setters. There is only one variety of deleter: named property deleters.\
詳細は、 `idl-indexed-properties$sec, `idl-named-properties$sec を見よ。 ◎ See §2.4.4.2 Indexed properties and §2.4.4.3 Named properties for details.
所与の`~ifc$上に存在する,[ `文字列化子$, `削除子$ および, 各~系列の[ `取得子$, `設定子$ ]]は、それぞれ,高々 1 個までで~MUST。 ◎ On a given interface, there must exist at most one stringifier, at most one named property deleter, and at most one of each variety of getter and setter.
~ifcが[ いずれかの系列の`設定子$, あるいは`有名~prop削除子$ ]を持つ場合、同じ系列の`取得子$も持た~MUST。 ◎ If an interface has a setter of a given variety, then it must also have a getter of that variety. If it has a named property deleter, then it must also have a named property getter.
演算を利用して宣言される`特殊~演算$は,[ `可変個的な$ / `随意~引数$をとる ]ようにされては~MUST_NOT。 ◎ Special operations declared using operations must not be variadic nor have any optional arguments.
`特殊~演算$は,`呼戻~ifc$上で宣言されては~MUST_NOT。 ◎ Special operations must not be declared on callback interfaces.
~objが,所与の`特殊~演算$を定義する複数の`~ifc$を実装する場合、その演算に対し,どの特殊~演算が呼出されるかは 未定義である。 ◎ If an object implements more than one interface that defines a given special operation, then it is undefined which (if any) special operation is invoked for that operation.
2.4.4.1. 文字列化子
`~ifc$が`文字列化子$を持つとき、[ その~ifcを実装する~objは,文字列への既定でない変換を持つ ]ことを指示する。 上で言及したように、文字列化子は,[ `stringifier^c ~keywordを伴って宣言される`演算$ ]を利用して指定できる。 ◎ When an interface has a stringifier, it indicates that objects that implement the interface have a non-default conversion to a string. As mentioned above, stringifiers can be specified using an operation declared with the stringifier keyword.
interface `interface_identifier^i { stringifier DOMString `identifier^i(); stringifier DOMString (); };
`文字列化子$の宣言-時に利用された演算が`識別子$を持たない場合、~ifcに付帯する注釈文において,~ifcの `文字列化の挙動@ が定義され~MUST。 演算が識別子を持つ場合、その演算の呼出しにより,~objは文字列に変換される。 ◎ If an operation used to declare a stringifier does not have an identifier, then prose accompanying the interface must define the stringification behavior of the interface. If the operation does have an identifier, then the object is converted to a string by invoking the operation to obtain the string.
演算により宣言される`文字列化子$は、[ 0 個の引数をとり, `DOMString$T を返す ]ように宣言され~MUST。 ◎ Stringifiers declared with operations must be declared to take zero arguments and return a DOMString.
略記として、[ `stringifier^c ~keywordを,識別子を伴わない演算を利用して宣言する ]場合,その演算の[ `返値型$, 引数~list ]を省略できる。 ◎ As a shorthand, if the stringifier keyword is declared using an operation with no identifier, then the operation’s return type and argument list can be omitted.
interface `interface_identifier^i { stringifier; };
次の 2 つの~ifcは等価である: ◎ The following two interfaces are equivalent:
[Exposed=Window] interface A { stringifier DOMString (); };
[Exposed=Window] interface A { stringifier; };
`stringifier^c ~keywordは、`属性$上に置くこともできる。 この場合、その属性の値が,~objから文字列への変換-を与える。 `stringifier^c ~keywordは、[ `静的~属性$ /[ `DOMString$T/`USVString$T ]として宣言されていない属性 ]上に置かれては~MUST_NOT。 ◎ The stringifier keyword can also be placed on an attribute. In this case, the string to convert the object to is the value of the attribute. The stringifier keyword must not be placed on an attribute unless it is declared to be of type DOMString or USVString. It also must not be placed on a static attribute.
interface `interface_identifier^i { stringifier attribute DOMString `identifier^i; };
次の`~IDL片$は、 `name^M 属性の値に文字列化する~ifcを定義する: ◎ The following IDL fragment defines an interface that will stringify to the value of its name attribute:
[Exposed=Window, Constructor] interface Student { attribute unsigned long id; stringifier attribute DOMString name; };
~ES言語束縛においては、文字列が期待されている文脈において `Student^T ~objが利用されたときの結果は、その~objの `name^jp ~propの値になる: ◎ In the ECMAScript binding, using a Student object in a context where a string is expected will result in the value of the object’s name property being used:
var %s = new Student();
%s.id = 12345678;
%s.name = '周杰倫';
var %挨拶 = 'こんにちは、 ' + %s + ' さん。';
/*
`こんにちは、 周杰倫 さん。^l になる。
◎
Now greeting == 'Hello, 周杰倫!'.
*/
次の`~IDL片$は、~IDL自身には指定されない~customな文字列化の挙動を備える~ifcを定義する。 ◎ The following IDL fragment defines an interface that has custom stringification behavior that is not specified in the IDL itself.
[Exposed=Window, Constructor] interface Student { attribute unsigned long id; attribute DOMString? familyName; attribute DOMString givenName; stringifier DOMString (); };
したがって、例えば次の段落の様な,文字列化の挙動を説明する注釈文が要求される: ◎ Thus, prose is required to explain the stringification behavior, such as the following paragraph:
`Student^T ~ifc を実装する~objを文字列化した結果は、 `familyName^M 属性の値が `null^V の場合は `givenName^M 属性の値,他の場合は[ `givenName^M 属性の値, 1 個の space 文字, `familyName^M 属性の値 ]の連結にならなければ~MUST_NOT。 ◎ Objects that implement the Student interface must stringify as follows. If the value of the familyName attribute is null, the stringification of the object is the value of the givenName attribute. Otherwise, if the value of the familyName attribute is not null, the stringification of the object is the concatenation of the value of the givenName attribute, a single space character, and the value of the familyName attribute.
この~IDLの~ES実装は、次に従って挙動することになる: ◎ An ECMAScript implementation of the IDL would behave as follows:
var %s = new Student();
%s.id = 12345679;
%s.familyName = 'Smithee';
%s.givenName = 'Alan';
var %挨拶 = 'こんにちは、 ' + %s + ' さん。';
/*
`こんにちは、 Alan Smithee さん^l になる。
◎
Now greeting == 'Hi Alan Smithee'.
*/
2.4.4.2. 有index~prop
`有index~prop取得子$を定義する`~ifc$は、 `有index~propを~support@ するという。 そのような~ifcを実装する`~platform~obj$もまた,`有index~propを~support$するという。 ◎ An interface that defines an indexed property getter is said to support indexed properties. By extension, a platform object is said to support indexed properties if it implements an interface that itself does.
~ifcが`有index~propを~support$する場合、その~ifc定義には,所与の任意の時点で~objに~index-できる~indexについての記述も付帯してい~MUST。 これらの~indexは、~objが `~supportする~prop~index@ と呼ばれる。 ◎ If an interface supports indexed properties, then the interface definition must be accompanied by a description of what indices the object can be indexed with at any given time. These indices are called the supported property indices.
`有index~propを~support$する~ifcは、`整数~型$である 名前 `length^l の属性を定義し~MUST。 ◎ Interfaces that support indexed properties must define an integer-typed attribute named "length".
`有index~prop取得子$は、 1 個の `unsigned long$T 引数をとるように宣言され~MUST。 有index~propの設定子は、 2 個の引数をとり, 1 個目の引数が `unsigned long$T をとるように宣言され~MUST。 ◎ Indexed property getters must be declared to take a single unsigned long argument. Indexed property setters must be declared to take two arguments, where the first is an unsigned long.
interface `interface_identifier^i { getter `type^i `identifier^i(unsigned long `identifier^i); setter `type^i `identifier^i(unsigned long `identifier^i, `type^i `identifier^i); getter `type^i (unsigned long `identifier^i); setter `type^i (unsigned long `identifier^i, `type^i `identifier^i); };
次の要件が,有index~propの[ 取得子/設定子 ]の定義に適用される: ◎ The following requirements apply to the definitions of indexed property getters and setters:
-
`有index~prop取得子$の宣言に利用された`演算$ %演算 が`識別子$を: ◎ ↓
- 持つ場合、~objに対し[ 所与の ( ~objが`~supportする~prop~index$ %index ) で~index-した ]ときの返値は[ %演算 を,その唯一の引数に %index を渡して呼出した ]ときと同じになる。 ◎ If an indexed property getter was specified using an operation with an identifier, then the value returned when indexing the object with a given supported property index is the value that would be returned by invoking the operation, passing the index as its only argument.\
- 持たない場合、その~ifc定義には,所与の~indexに対し `有index~propの値を決定する@ 方法を成す記述も付帯してい~MUST。 ◎ If the operation used to declare the indexed property getter did not have an identifier, then the interface definition must be accompanied by a description of how to determine the value of an indexed property for a given index.
-
`有index~prop設定子$の宣言に利用された`演算$ %演算 が`識別子$を: ◎ ↓
- 持つ場合、~objに対し[ 所与の ( ~objが`~supportする~prop~index$ %index, 値 %V ) で,~prop代入~用に~index-した ]ときに生じる挙動は[ %演算 を,その ( 1 個目, 2 個目 ) の引数に ( %index, %V ) を渡して呼出した ]ときと同じになる。 ◎ If an indexed property setter was specified using an operation with an identifier, then the behavior that occurs when indexing the object for property assignment with a given supported property index and value is the same as if the operation is invoked, passing the index as the first argument and the value as the second argument.\
- 持たない場合、その~ifc定義には,所与の ( ~prop~index, 値 ) に対し[ `既存の有index~propを設定する@ 方法, および `新たな有index~propを設定する@ 方法 ]を成す記述も付帯してい~MUST。 ◎ If the operation used to declare the indexed property setter did not have an identifier, then the interface definition must be accompanied by a description of how to set the value of an existing indexed property and how to set the value of a new indexed property for a given property index and value.
`有index~prop$の[ 取得子/設定子 ]が`識別子$を伴う`演算$を利用して指定されている場合、[ ~objが`~supportする~prop~index$でない整数 %index ]で~index-したときの挙動が[ %index でその演算を呼出したとき ]と同じになる必要はない。 この事例における実際の挙動は、言語束縛に特有になる。 ◎ Note that if an indexed property getter or setter is specified using an operation with an identifier, then indexing an object with an integer that is not a supported property index does not necessarily elicit the same behavior as invoking the operation with that index. The actual behavior in this case is language binding specific.
~ES言語束縛においては,定例の~prop検索が行われる。 例えば次の~IDLでは: ◎ In the ECMAScript language binding, a regular property lookup is done. For example, take the following IDL:
[Exposed=Window] interface A { getter DOMString toWord(unsigned long %index); };
`A^T を実装している~objが`~supportする~prop~index$は、 0 以上 2 未満とする。 また、 `toWord^M は,引数の数字を英単語に変換した文字列を返すように定義されているとする。 範囲~外の~indexで`演算$を呼出したときの挙動は、~objを直に~index-したときとは異なる: ◎ Assume that an object implementing A has supported property indices in the range 0 ≤ index < 2. Also assume that toWord is defined to return its argument converted into an English word. The behavior when invoking the operation with an out of range index is different from indexing the object directly:
var %a = getA(); %a.toWord(0); /* `zero^l に評価される。 ◎ Evaluates to "zero". */ %a[0]; /* これも `zero^l に評価される。 ◎ Also evaluates to "zero". */ %a.toWord(5); /* `five^l に評価される。 ◎ Evaluates to "five". */ %a[5]; /* ~prop `5^l は存在しないので `undefined^jv に評価される。 ◎ Evaluates to undefined, since there is no property "5". */
次の`~IDL片$は 名前または~indexによる値の取得0と設定を許容する `OrderedMap^T ~ifcを定義する: ◎ The following IDL fragment defines an interface OrderedMap which allows retrieving and setting values by name or by index number:
[Exposed=Window] interface OrderedMap { readonly attribute unsigned long size; getter any getByIndex(unsigned long %index); setter void setByIndex(unsigned long %index, any %value); getter any get(DOMString %name); setter void set(DOMString %name, any %value); };
すべての特殊~演算が識別子を伴う演算を利用して宣言されているので、必要とされる唯一の注釈文は,これらの集合が持つ~keyを与える記述になる。 `OrderedMap^T 内に存在しない~itemに対する検索が試みられた場合に対し, `get()^M 演算が `null^V を返すように定義されているとするとき、次の 2 つの~~文で足りるであろう: ◎ Since all of the special operations are declared using operations with identifiers, the only additional prose that is necessary is that which describes what keys those sets have. Assuming that the get() operation is defined to return null if an attempt is made to look up a non-existing entry in the OrderedMap, then the following two sentences would suffice:
`OrderedMap^T を実装する~obj %map は、範囲[ 0 ~LTE %index ~LT `map.size^c ]の`有index~propを~support$する。 ◎ An object map implementing OrderedMap supports indexed properties with indices in the range 0 ≤ index < map.size.
そのような~objは、 `get()^M に渡されたときに非 `null^V 値が返されるような,どの名前に対しても、有名~propを~supportする。 ◎ Such objects also support a named property for every name that, if passed to get(), would return a non-null value.
`es-legacy-platform-objects$sec に述べられるように、~ES実装は[ 有名, 有index ]いずれの~propの集合に対しても、その集合に属する各項に対応する~propを[ `OrderedMap^T を実装している`旧来の~platform~obj$ ]上に,作成することになるであろう。 下に示すように、これらの~propを,~objの~methの呼出しと同じ仕方で,~objと相互作用するために利用できる: ◎ As described in §3.8 Legacy platform objects, an ECMAScript implementation would create properties on a legacy platform object implementing OrderedMap that correspond to entries in both the named and indexed property sets. These properties can then be used to interact with the object in the same way as invoking the object’s methods, as demonstrated below:
/* %map は `OrderedMap^T ~ifcを実装する旧来の~platform~objであるとする。 ◎ Assume map is a legacy platform object implementing the OrderedMap interface. */ var %map = getOrderedMap(); var %x, %y; %x = %map[0]; /* `map.length^c ~GT 0 ならば、これは `x = map.getByIndex(0)^c と等価になる(名前 `0^l の~propが %map 上に置かれるので)。 他の場合、名前 `0^l の~propは %map 上にないので, %x は `undefined^jv に設定されることになる。 ◎ If map.length > 0, then this is equivalent to: x = map.getByIndex(0) since a property named "0" will have been placed on map. Otherwise, x will be set to undefined, since there will be no property named "0" on map. */ %map[1] = false; /* これは、 `map.setByIndex(1, false)^c と等価な動作になる。 ◎ This will do the equivalent of: map.setByIndex(1, false) */ %y = %map.apple; /* 名前 `apple^l の有名~propが存在する場合、 %map 上には名前 `apple^l の~propがあり, `y = map.get('apple')^c と等価な動作になる。 他の場合、 %map 上に名前 `apple^l の~propはないので, %y は `undefined^jv に設定されることになる。 ◎ If there exists a named property named "apple", then this will be equivalent to: y = map.get('apple') since a property named "apple" will have been placed on map. Otherwise, y will be set to undefined, since there will be no property named "apple" on map. */ %map.berry = 123; /* これは、 `map.set('berry', 123)^c と等価な動作になる。 ◎ This will do the equivalent of: map.set('berry', 123) */ delete %map.cake; /* 有名~prop `cake^l が存在するならば、 `cake^jp ~propは削除され, `map.remove("cake")^c と等価な動作になる。 ◎ If a named property named "cake" exists, then the "cake" property will be deleted, and then the equivalent to the following will be performed: map.remove("cake") */
2.4.4.3. 有名~prop
`有名~prop取得子$を定義する`~ifc$は、 `有名~propを~support@ するという。 そのような~ifcを実装する`~platform~obj$もまた,`有名~propを~support$するという。 ◎ An interface that defines a named property getter is said to support named properties. By extension, a platform object is said to support named properties if it implements an interface that itself does.
`有名~propを~support$する~ifcの~ifc定義には、[ 所与の任意の時点で~objに~index-できるような名前からなる,有順序~集合 ]についての記述も付帯してい~MUST。 これらの名前は、~objが `~supportする~prop名@ と呼ばれる。 ◎ If an interface supports named properties, then the interface definition must be accompanied by a description of the ordered set of names that can be used to index the object at any given time. These names are called the supported property names.
有名~propの取得子と削除子は、 1 個の `DOMString$T 引数をとるように宣言され~MUST。 有名~propの設定子は、 2 個の引数をとり, 1 個目の引数に `DOMString$T をとるように宣言され~MUST。 ◎ Named property getters and deleters must be declared to take a single DOMString argument. Named property setters must be declared to take two arguments, where the first is a DOMString.
interface `interface_identifier^i { getter `type^i `identifier^i(DOMString `identifier^i); setter `type^i `identifier^i(DOMString `identifier^i, `type^i `identifier^i); deleter `type^i `identifier^i(DOMString `identifier^i); getter `type^i (DOMString `identifier^i); setter `type^i (DOMString `identifier^i, `type^i `identifier^i); deleter `type^i (DOMString `identifier^i); };
次の要件が,有名~propの[ 取得子/設定子/削除子 ]の定義に適用される: ◎ The following requirements apply to the definitions of named property getters, setters and deleters:
-
`有名~prop取得子$の宣言に利用された`演算$ %演算 が`識別子$を: ◎ ↓
- 持つ場合、~objに対し[ 所与の ( ~objが`~supportする~prop名$ %name ) で~index-した ]ときの返値は[ %演算 を,その唯一の引数に %name を渡して呼出した ]ときと同じになる。 ◎ If a named property getter was specified using an operation with an identifier, then the value returned when indexing the object with a given supported property name is the value that would be returned by invoking the operation, passing the name as its only argument.\
- 持たない場合、その~ifc定義には,所与の~prop名に対し `有名~propの値を決定する@ 方法を成す記述も付帯してい~MUST。 ◎ If the operation used to declare the named property getter did not have an identifier, then the interface definition must be accompanied by a description of how to determine the value of a named property for a given property name.
-
`有名~prop設定子$の宣言に利用された`演算$ %演算 が`識別子$を: ◎ ↓
- 持つ場合、~objに対し[ 所与の ( ~objが`~supportする~prop名$ %name, 値 %V ) で,~prop代入~用に~index-した ]ときに生じる挙動は[ %演算 を,その ( 1 個目, 2 個目 ) の引数に ( %name, %V ) を渡して呼出した ]ときと同じになる。 ◎ If a named property setter was specified using an operation with an identifier, then the behavior that occurs when indexing the object for property assignment with a given supported property name and value is the same as if the operation is invoked, passing the name as the first argument and the value as the second argument.\
- 持たない場合、その~ifc定義には,所与の ( ~prop名, 値 ) に対し[ `既存の有名~propを設定する@ 方法, および `新たな有名~propを設定する@ 方法 ]を成す記述も付帯してい~MUST。 ◎ If the operation used to declare the named property setter did not have an identifier, then the interface definition must be accompanied by a description of how to set the value of an existing named property and how to set the value of a new named property for a given property name and value.
-
`有名~prop削除子$の宣言に利用された`演算$ %演算 が`識別子$を: ◎ ↓
- 持つ場合、~objに対し[ 所与の ( ~objが`~supportする~prop名$ %name ) で,~prop削除~用に~index-した ]ときに生じる挙動は[ %演算 を, %name を唯一の引数に渡して呼出した ]ときと同じになる。 ◎ If a named property deleter was specified using an operation with an identifier, then the behavior that occurs when indexing the object for property deletion with a given supported property name is the same as if the operation is invoked, passing the name as the only argument.\
- 持たない場合、その~ifc定義には,所与の~prop名に対し `既存の有名~propを削除する@ 方法を成す記述も付帯してい~MUST。 ◎ If the operation used to declare the named property deleter did not have an identifier, then the interface definition must be accompanied by a description of how to delete an existing named property for a given property name.
注記: `有index~prop$のときと同様に,`有名~prop$の[ 取得子/設定子/削除子 ]が`識別子$を伴う`演算$を利用して指定された場合、~objに対し[ ~objが`~supportする~prop名$でない名前で~index-した ]ときの挙動が[ その名前でその演算を呼出した ]ときと同じになる必要はない。 挙動は、言語束縛に特有になる。 ◎ Note: As with indexed properties, if an named property getter, setter or deleter is specified using an operation with an identifier, then indexing an object with a name that is not a supported property name does not necessarily elicit the same behavior as invoking the operation with that name; the behavior is language binding specific.
2.4.5. 静的~属性と静的~演算
`静的~属性@, `静的~演算@ は、それが宣言される`~ifc$の特定0の~instance上には結付けられないものであり、代わりに,その ~ifc自身に結付けられる。 静的~属性と静的~演算は,それらの宣言の中で `static^c ~keywordを利用して宣言される。 ◎ Static attributes and static operations are ones that are not associated with a particular instance of the interface on which it is declared, and is instead associated with the interface itself. Static attributes and operations are declared by using the static keyword in their declarations.
[ 静的~演算を呼出す/ 静的~属性を取得する/ 静的~属性を設定する ]ことが,~ifcの~instanceへの参照を通してアリかどうかは、言語束縛に特有になる。 ◎ It is language binding specific whether it is possible to invoke a static operation or get or set a static attribute through a reference to an instance of the interface.
静的~演算/静的~属性は,`呼戻~ifc$上で宣言されては~MUST_NOT。 ◎ Static attributes and operations must not be declared on callback interfaces.
次の`~IDL片$は、静的~演算が宣言されている `Circle^T ~ifcを定義する: ◎ The following IDL fragment defines an interface Circle that has a static operation declared on it:
[Exposed=Window] interface Point { /* ... */ }; [Exposed=Window] interface Circle { attribute double cx; attribute double cy; attribute double radius; static readonly attribute long triangulationCount; static Point triangulate(Circle %c1, Circle %c2, Circle %c3); };
~ES言語束縛においては、 `Circle^T 用の`~ifc~obj$上に, `triangulate^M に対応する`関数~obj$, および `triangulationCount^M に対応する~accessor~prop が存在することになる: ◎ In the ECMAScript language binding, the function object for triangulate and the accessor property for triangulationCount will exist on the interface object for Circle:
var %circles = getCircles(); /* `Circle^T ~objの `Array^jt ◎ an Array of Circle objects */ typeof Circle.triangulate; /* `function^l に評価される。 ◎ Evaluates to "function" */ typeof Circle.triangulationCount; /* `number^l に評価される。 ◎ Evaluates to "number" */ Circle.prototype.triangulate; /* `undefined^jv に評価される。 ◎ Evaluates to undefined */ Circle.prototype.triangulationCount; /* これも `undefined^jv に評価される。 ◎ Also evaluates to undefined */ %circles[0].triangulate; /* これも。 ◎ As does this */ %circles[0].triangulationCount; /* これも。 ◎ And this */ /* 静的~演算の~call ◎ Call the static operation */ var %triangulationPoint = Circle.triangulate(%circles[0], %circles[1], %circles[2]); /* `triangulate^M を呼んだ回数を調べる ◎ Find out how many triangulations we have done */ window.alert(Circle.triangulationCount);
2.4.6. 多重定義
`~ifc$上に定義される[ `正則~演算$/`静的~演算$ ]が,その~ifc上の同じ種類の別の(正則/静的)演算と 同じ`識別子$を持つ場合、その演算は `多重定義@ されているという。 その~ifcを実装する~obj上で[ それらの演算のどれかを呼出すために[ 多重定義された演算の識別子 ]が利用された ]ときに,どの演算が実際に呼出されるかは、演算に渡された引数の個数と型により決定される。 ~ES言語束縛においては `Constructor$x も多重定義され得る。 多重定義された[ 演算/構築子 ]がとり得る引数の指定には一定の制約があり、これらの制約を記述するため,`有効~多重定義~集合$の~~概念が利用される。 ◎ If a regular operation or static operation defined on an interface has an identifier that is the same as the identifier of another operation on that interface of the same kind (regular or static), then the operation is said to be overloaded. When the identifier of an overloaded operation is used to invoke one of the operations on an object that implements the interface, the number and types of the arguments passed to the operation determine which of the overloaded operations is actually invoked. In the ECMAScript language binding, constructors can be overloaded too. There are some restrictions on the arguments that overloaded operations and constructors can be specified to take, and in order to describe these restrictions, the notion of an effective overload set is used.
`演算$は、複数の[ `~ifc$, `部分的~ifc$, `~ifc~mixin$, `部分的~ifc~mixin$ ]にまたがって多重定義されては~MUST_NOT。 ◎ Operations must not be overloaded across interface, partial interface, interface mixin, and partial interface mixin definitions.
例えば,次の様な `f^T, `g^T の多重定義は許容されない: ◎ For example, the overloads for both f and g are disallowed:
[Exposed=Window] interface A { void f(); }; partial interface A { void f(double %x); void g(); }; partial interface A { void g(DOMString %x); };
構築子の多重定義については、元々`部分的~ifc定義$上には[ `Constructor$x, `NamedConstructor$x ]`拡張属性$の出現が許容されていないので,同様の制約は~~自動的に満たされることに注意。 ◎ Note that the [Constructor] and [NamedConstructor] extended attributes are disallowed from appearing on partial interface definitions, so there is no need to also disallow overloading for constructors.
`有効~多重定義~集合@ は、特定0の `関数類@ — [ `演算$ / 構築子( `Constructor$x または `NamedConstructor$x により指定される) / `呼戻~関数$ ] — に許容され得る呼出を表現する。
【 “関数類(引数を伴って~callできる~IDL構成子)” は、簡潔に総称できるよう,この訳にて導入した用語である。 】
`有効~多重定義~集合$を算出する~algoは、次に挙げる~IDL構成子いずれかに対し演算する。 算出するために必要な入力は、渡される引数の個数, および `関数類$の種別に応じて,以下に示されるものになる:
◎ An effective overload set represents the allowable invocations for a particular operation, constructor (specified with [Constructor] or [NamedConstructor]), or callback function. The algorithm to compute an effective overload set operates on one of the following six types of IDL constructs, and listed with them below are the inputs to the algorithm needed to compute the set.- 正則~演算 ◎ For regular operations
- 静的~演算 ◎ For static operations
- `演算$が見出される`~ifc$, および 演算の`識別子$ ◎ the interface on which the operations are to be found ◎ the identifier of the operations ◎ the number of arguments to be passed
- 構築子 ◎ For constructors
- `Constructor$x `拡張属性$が見出される`~ifc$ ◎ the interface on which the [Constructor] extended attributes are to be found ◎ the number of arguments to be passed
- 有名~構築子 ◎ For named constructors
- `NamedConstructor$x `拡張属性$が見出される`~ifc$, および 有名~構築子の`識別子$ ◎ the interface on which the [NamedConstructor] extended attributes are to be found ◎ the identifier of the named constructors ◎ the number of arguments to be passed
- 呼戻~関数 ◎ For callback functions
- `呼戻~関数$ ◎ the callback function ◎ the number of arguments to be passed
有効~多重定義~集合は、~ifc上に多重定義された`関数類$たちに多義性があるかどうかを — 他と伴に — 決定するために利用される。 ◎ An effective overload set is used, among other things, to determine whether there are ambiguities in the overloaded operations and constructors specified on an interface.
`有効~多重定義~集合$は、`有順序~集合$であり,それを成す各`~item$は[ 次に挙げる`~item$sctからなる`~tuple$ ]である — これらの~tupleは、 ( `~callable$oL, `型~list$oL, `省略可否~list$oL ) の形で記される: ◎ The items of an effective overload set are tuples of the form (callable, type list, optionality list) whose items are described below:
- `~callable@oL
-
`関数類$の種別に応じて,次で与えられる:
- `正則~演算$
- `静的~演算$
- 【同じ識別子を共有する】いずれかの`演算$
- 構築子
- `有名~構築子$
- 【同じ識別子を共有する】いずれかの`拡張属性$
- `呼戻~関数$
- 呼戻~関数~自身
- `型~list@oL
- 0 個~以上の~IDL型からなる`~list$。 — `~callable$oL の引数たちにあてがわれているそれらになる。 ◎ A type list is a list of IDL types.
- `省略可否~list@oL
-
0 個~以上の `省略可否 値@ からなる`~list$。 各 `省略可否 値$にアリな値は、次のいずれかであり,所与の~indexに位置する引数について指示する:
- `必須^C — 引数は省略できない
- `省略可^C — `随意~引数$である
- `可変個^C — `可変個~引数$である
各`~tuple$は、[ 引数~値~listに伴われる一連の型であって,当の`関数類$の呼出に許容され得るもの ]を表現する。 [ `随意~引数$/[ `可変個的な$`関数類$ (すなわち,演算または構築子) ]]の利用に因り、有効~多重定義~集合~内には,同じ種類の`関数類$を識別する複数の~itemが存在し得る。 ◎ Each tuple represents an allowable invocation of the operation, constructor, or callback function with an argument value list of the given types. Due to the use of optional arguments and variadic operations and constructors, there may be multiple items in an effective overload set identifying the same operation or constructor.
有効~多重定義~集合を算出する方法は、以下の~algoに述べられる。 必要に応じて,上述の入力~変数が利用される: ◎ The algorithm below describes how to compute an effective overload set. The following input variables are used, if they are required:
- %A は[ 演算/有名~構築子 ]の識別子 ◎ the identifier of the operation or named constructor is A
- %N は引数個数 ◎ the argument count is N
- %I は~ifc ◎ the interface is I
- %C は呼戻~関数 ◎ the callback function is C
以下において言及される,拡張属性の引数は、その`有名~引数~list$の引数を指すとする。 ◎ Whenever an argument of an extended attribute is mentioned, it is referring to an argument of the extended attribute’s named argument list.
- %S ~LET 新たな`有順序~集合$ ◎ Let S be an ordered set.
-
%F ~LET [ 有効~多重定義~集合の種類に応じて,次で与えられる~itemたち ]からなる新たな`有順序~集合$: ◎ Let F be an ordered set with items as follows, according to the kind of effective overload set:
- 正則~演算 ◎ For regular operations
- %I 上で定義された`正則~演算$のうち,[ その識別子 ~EQ %A ]なるもの ◎ The elements of F are the regular operations with identifier A defined on interface I.
- 静的~演算 ◎ For static operations
- %I 上で定義された`静的~演算$のうち,[ その識別子 ~EQ %A ]なるもの ◎ The elements of F are the static operations with identifier A defined on interface I.
- 構築子 ◎ For constructors
- %I 上の `Constructor$x `拡張属性$ ◎ The elements of F are the [Constructor] extended attributes on interface I.
- 有名~構築子 ◎ For named constructors
- %I 上の `NamedConstructor$x `拡張属性$のうち,[ その`有名~引数~list$の識別子 ~EQ %A ]なるもの ◎ The elements of F are the [NamedConstructor] extended attributes on interface I whose named argument lists’ identifiers are A.
- 呼戻~関数 ◎ For callback functions
- 呼戻~関数~自身である %C (唯一つ) ◎ The single element of F is the callback function itself, C.
-
%maxarg ~LET [ %F 内の各~item(`関数類$)が宣言している引数~個数 ]の最大 — ただし,[ `可変個的な$`関数類$ ]の中の`可変個~引数$は、 1 個の引数に数える ◎ Let maxarg be the maximum number of arguments the operations, constructor extended attributes or callback functions in F are declared to take. For variadic operations and constructor extended attributes, the argument on which the ellipsis appears counts as a single argument.
注記: したがって `void f(long x, long... y);^c が宣言している引数~個数は 2 個と見なされる。 ◎ Note: So void f(long x, long... y); is considered to be declared to take two arguments.
- %max ~LET `max$op( %maxarg, %N ) ◎ Let max be max(maxarg, N).
-
%F 内の ~EACH( %X ) に対し: ◎ For each operation, extended attribute, or callback function X in F:
- %引数~list ~LET %X がとるよう宣言されている引数たちからなる`~list$ ◎ Let arguments be the list of arguments X is declared to take.
- %n ~LET %引数~list の`~size$ (したがって %n ~LTE %max ) ◎ Let n be the size of arguments.
- %型~list ~LET 新たな`~list$ (これは、`型~list$oLを与えることになる) ◎ Let types be a type list.
- %省略可否~list ~LET 新たな`~list$ (これは、`省略可否~list$oLを与えることになる) ◎ Let optionalityValues be an optionality list.
-
%引数~list 内の ~EACH( %引数 ) に対し: ◎ For each argument in arguments:
- %型~list に %引数 の型を`付加する$ ◎ Append the type of argument to types.
- %省略可否~list に[ %引数 に応じて,次で与えられる値 ]を`付加する$ ⇒# `可変個~引数$ならば `可変個^C / ~ELSE_ `随意~引数$ならば `省略可^C / ~ELSE_ `必須^C ◎ Append "variadic" to optionalityValues if argument is a final, variadic argument, "optional" if argument is optional, and "required" otherwise.
- %S に `~tuple$( %X, %型~list, %省略可否~list ) を`付加する$set ◎ Append the tuple (X, types, optionalityValues) to S.
-
~IF[ %X は `可変個的な$ものと宣言されている ]: ◎ If X is declared to be variadic, then:
-
%n ~LTE %i ~LT %max なる ~EACH( 整数 %i ) に対し,~~昇順に: ◎ For each i in the range n to max − 1, inclusive:
- %t ~LET %型~list の複製 ◎ Let t be a type list.
- %o ~LET %省略可否~list の複製 ◎ Let o be an optionality list. ◎ For each j in the range 0 to n − 1, inclusive: • Append types[j] to t. • Append optionalityValues[j] to o.
-
%n ~LTE %j ~LTE %i なる ~EACH( 整数 %j ) に対し: ◎ For each j in the range n to i, inclusive:
- %t に %型~list[ %n ~MINUS 1] を`付加する$ ◎ Append types[n − 1] to t.
- %o に `可変個^C を`付加する$ ◎ Append "variadic" to o.
- %S に`~tuple$( %X, %t, %o ) を`付加する$set ◎ Append the tuple (X, t, o) to S.
-
-
%n ~GT %i ~GTE 0 なる ~EACH( 整数 %i ) に対し,~~降順に: ◎ Let i be n − 1. ◎ While i ≥ 0:
- ~IF[ %省略可否~list[ %i ] ~EQ `必須^C ] ⇒ ~BREAK ◎ If arguments[i] is not optional (i.e., it is not marked as "optional" and is not a final, variadic argument), then break.
- [ %t, %o ] ~LET 順に[ %型~list, %省略可否~list ]の複製 ◎ ↓
- [ %t, %o ]それぞれに対し,その尾部から 0 個~以上の~itemたちを[ その`~size$ ~EQ %i ]になるよう除去する ◎ Let t be a type list. ◎ Let o be an optionality list. ◎ For each j in the range 0 to i − 1, inclusive: • Append types[j] to t. • Append optionalityValues[j] to o.
-
%S に`~tuple$( %X, %t, %o ) を`付加する$set ◎ Append the tuple (X, t, o) to S.
注記: %i ~EQ 0 ならば %t, %o は`空$になる。 ◎ Note: if i is 0, this means to add to S the tuple (X, « », « »); (where "« »" represents an empty list). ◎ Set i to i − 1.
- ~RET %S ◎ Return S.
次の~ifcに対し: ◎ For the following interface:
[Exposed=Window] interface A { /* f1 */ void f(DOMString %a); /* f2 */ void f(Node %a, DOMString %b, double... %c); /* f3 */ void f(); /* f4 */ void f(Event %a, DOMString %b, optional DOMString %c, double... %d); };
`Node^T と `Event^T は、どの~objからも両方同時には実装できない,別々の~ifcとする。 [ 識別子 `f^c, 引数個数 4 ]の`正則~演算$からなる`有効~多重定義~集合$は: ◎ assuming Node and Event are two other interfaces of which no object can implement both, the effective overload set for regular operations with identifier f and argument count 4 is:
« (f1, « DOMString », « `必須^C »), (f2, « Node, DOMString », « `必須^C, `必須^C »), (f2, « Node, DOMString, double », « `必須^C, `必須^C, `可変個^C »), (f2, « Node, DOMString, double, double », « `必須^C, `必須^C, `可変個^C, `可変個^C »), (f3, « », « »), (f4, « Event, DOMString », « `必須^C, `必須^C »), (f4, « Event, DOMString, DOMString », « `必須^C, `必須^C, `省略可^C »), (f4, « Event, DOMString, DOMString, double », « `必須^C, `必須^C, `省略可^C, `可変個^C ») »
2 つの型は、次の~algoが ~T を返すならば, `判別-可能@ であるとされる: ◎ Two types are distinguishable if the following algorithm returns true.
-
~IF[ 一方の型は`~nullable型を内包する$ ]~AND[ 他方の型は 次のいずれかを満たす ] ⇒ ~RET ~F:
- `~nullable型を内包する$
- [ `共用体~型$である ]~AND[ その`平坦化~mb型$に`辞書~型$が含まれている ]
- `辞書~型$である
次の各~pairは、いずれも判別-可能でない:
- `double?^T と `Dictionary1^T
- `(Interface1 or long)?^T と `(Interface2 or DOMString)?^T
- `(Interface1 or long?)^T と `(Interface2 or DOMString)?^T
- `(Interface1 or long?)^T と `(Interface2 or DOMString?)^T
- `(Dictionary1 or long)^T と `(Interface2 or DOMString)?^T
- `(Dictionary1 or long)^T と `(Interface2 or DOMString?)^T
( `Interface1^T, `Interface2^T は ~ifc型, `Dictionary1^T は 辞書~型とする)
◎ None of the following pairs are distinguishable: • double? and Dictionary1 • (Interface1 or long)? and (Interface2 or DOMString)? • (Interface1 or long?) and (Interface2 or DOMString)? • (Interface1 or long?) and (Interface2 or DOMString?) • (Dictionary1 or long) and (Interface2 or DOMString)? • (Dictionary1 or long) and (Interface2 or DOMString?) - ~IF[ 両方の型とも[ `共用体~型$ /`~nullable$`共用体~型$ ]である ] ⇒ ~RET 両者のどの`~mb型$どうしも互いに判別-可能であるならば ~T / ~ELSE_ ~F ◎ If both types are either a union type or nullable union type, return true if each member type of the one is distinguishable with each member type of the other, or false otherwise.
- ~IF[ 一方の型は[ `共用体~型$ /~nullable共用体~型 ]である ] ⇒ ~RET その共用体のどの`~mb型$も 他方の型と`判別-可能$であるならば ~T / ~ELSE_ ~F ◎ If one type is a union type or nullable union type, return true if each member type of the union type is distinguishable with the non-union type, or false otherwise.
-
~IF[ 2 つそれぞれの`最内縁の型$は,[ 下の表に現れるか, 下の表に現れる分類に入る ]~AND[[ 対応する欄に “●” 印がある ]~OR[ 対応する欄に英字が在って,表の下に指定される追加の要件を満たす ]] ⇒ ~RET ~T
ここで、所与の型 %T の `最内縁の型@ は,次に従って決定される型とする:
- ~IF[ %T は`注釈付きの型$である ] ⇒ %T ~SET %T の`内縁~型$anO
- ~IF[ %T は`~nullable型$である ] ⇒ %T ~SET %T の`内縁~型$
- ~RET %T
下の表に現れる分類は、次で定義される: ◎ Categories:
- ~ifc類 ⇒ `呼戻~ifc$でない`~ifc型$ / `例外~型$ / `~buffer~source型$ ◎ interface-like • non-callback interface types • exception types • buffer source types
- 辞書~類 ⇒ `辞書~型$ / `~record型$ / `呼戻~ifc$である`~ifc型$ ◎ dictionary-like • dictionary types • record types • callback interface types
- 連列~類 ⇒ `連列~型$ / `凍結~配列~型$ ◎ sequence-like • sequence types • frozen array types
`boolean$T `実数~型$ `文字列~型$ `object$T `symbol$T ~ifc類 `呼戻~関数$ 辞書~類 連列~類 `boolean$T ● ● ● ● ● ● ● ● `実数~型$ ● ● ● ● ● ● ● `文字列~型$ ● ● ● ● ● ● `object$T ● `symbol$T ● ● ● ● ~ifc~類 (a) ● ● ● 呼戻~関数 ● 辞書~類 ● 連列~類 (a) — 識別される 2 つの~ifc類の型が同じ`~platform~obj$に実装されることは、起こり得ない(特に, 2 つは同じ~ifcでない)。 ◎ The two identified interface-like types are not the same, and no single platform object implements both interface-like types.
- ~RET ~F ◎ ↑
- `double$T と `DOMString$T とは判別-可能になる — `実数~型$と`文字列~型$の交差する欄に ● 印があるので。 ◎ double and DOMString are distinguishable because there is a ● at the intersection of numeric types with string types.
- `double$T と `long$T は判別-可能でない — 両者とも`実数~型$であり,`実数~型$と`実数~型$の交差する欄に ● 印はないので ◎ double and long are not distinguishable because they are both numeric types, and there is no ● or letter at the intersection of numeric types with numeric types.
-
次の~IDL片が与えられたとするとき: ◎ Given:
callback interface CBIface { attribute DOMString attr1; }; [Exposed=Window] interface Iface { attribute DOMString attr2; }; dictionary Dict { DOMString field1; };
`CBIface^T は、 `Iface^T とは 判別-可能になる(辞書~類 と ~ifc類が交差する欄に ● があるので)が, `Dict^T とは判別-可能にならない(辞書~類どうしが交差する欄に ● がないので) ◎ CBIface is distinguishable from Iface because there’s a ● at the intersection of dictionary-like and interface-like, but it is not distinguishable from Dict because there’s no ● at the intersection of dictionary-like and itself.
- `~promise型$は、上の表には現れていないので,他のどの型とも判別-可能でない。 ◎ Promise types do not appear in the above table, and as a consequence are not distinguishable with any other type.
負でない整数 %N 【すなわち引数~個数】, 【N から算出される】 `有効~多重定義~集合$ %S が与えられた下で:
- %S の中の複数の`~item$が[ その`型~list$oLの`~size$ ~EQ %N ]を満たすならば、[ それらのどの 2 つの~itemに対しても~index %i に位置する 2 つの型が`判別-可能$になる ]ような,~index %i が存在し~MUST。
- そのような~indexのうち,最小のものを、 %~size に対する `判別~引数~index@ と呼ぶ。
前の例に示された有効~多重定義~集合を考える。 `型~list$oL ~size %~size ~IN { 2, 3, 4 } に対するそれは、いずれも複数の~itemを含む。 これらいずれの %~size に対しても、[ `Node^T, `Event^T ]は`判別-可能$になるので,`判別~引数~index$は 0 になる。 ◎ Consider the effective overload set shown in the previous example. There are multiple items in the set with type lists 2, 3 and 4. For each of these type list size, the distinguishing argument index is 0, since Node and Event are distinguishable.
しかしながら,次の多重定義の利用は妥当でない: ◎ The following use of overloading however is invalid:
[Exposed=Window] interface B { void f(DOMString %x); void f(USVString %x); };
`DOMString$T と `USVString$T は判別-可能でないので。 ◎ since DOMString and USVString are not distinguishable.
加えて,[ 0 ~LTE %j ~LT [ 所与の `型~list$oL ~sizeに対する`判別~引数~index$ ]]を満たすどの~index %j に対しても,次が満たされ~MUST ⇒ 【~sizeから算出される】 `有効~多重定義~集合$のすべての~itemにわたり ⇒ [ それらの`型~list$oL[ %j ] は互いに同じ ]~AND[ それらの`省略可否~list$oL[ %j ] は互いに同じ ] ◎ In addition, for each index j, where j is less than the distinguishing argument index for a given type list size, the types at index j in all of the items’ type lists must be the same, and the optionality values at index j in all of the items’ optionality lists must be the same.
次は妥当でない: ◎ The following is invalid:
[Exposed=Window] interface B { /* f1 */ void f(DOMString %w); /* f2 */ void f(long %w, double %x, Node %y, Node %z); /* f3 */ void f(double %w, double %x, DOMString %y, Node %z); };
引数個数 4 に対する有効~多重定義~集合は: ◎ For argument count 4, the effective overload set is:
« (f1, « DOMString », « `必須^C »), (f2, « long, double, Node, Node », « `必須^C, `必須^C, `必須^C, `必須^C »), (f3, « double, double, DOMString, Node », « `必須^C, `必須^C, `必須^C, `必須^C ») »
であり、`型~list$oL ~size 4 の~itemを調べると, `Node^T と `DOMString$T は`判別-可能$なので、 `判別~引数~index$は 2 になる。 しかしながら,これらの 2 つの多重定義の~index 0 に位置する引数~型は異なるので、この多重定義は妥当でない。 ◎ Looking at items with type list size 4, the distinguishing argument index is 2, since Node and DOMString are distinguishable. However, since the arguments in these two overloads at index 0 are different, the overloading is invalid.
【 複雑な条件だが,概念的には、共用体~型を利用して,多重定義された宣言を等価な単独の宣言に併合するために必要な条件が意図されている様に見られる。 例えば、先に挙げられた例は,次のように書き換え得る: 】
[Exposed=Window] interface A { /*---f4----*/ /*-f2-*/ /*---f1----*/ /*-f3-*/ void f( optional ( Event or Node or DOMString ) %a, /*----*/ optional DOMString %b, /*---------------------*/ optional ( DOMString or double ) %c, /*---------------------*/ double... %d /*---------------------*/ ); };
【 これらの書き方の相違は、 `idl-overloading-vs-union$sec に述べられている。 】
2.4.6.1. 多重定義 vs. 共用体~型
~INFORMATIVE~IDL`演算$を定義している仕様にとって、`多重定義$と[[ `共用体~型$, `随意~引数$ ]の組合わせ ]とは,特色機能が~~重複しているように見えるかもしれない。 ◎ For specifications defining IDL operations, it might seem that overloads and a combination of union types and optional arguments have some feature overlap.
先ず,重要な点として、`多重定義$の挙動は `共用体~型$, `随意~引数$とで相違するので,他方を用いて 全部的に定義できないことに注意(もちろん、~Web~IDL型~systemの目的を無為にしかねない 追加の注釈文が供されない限り)。 例えば `CanvasDrawPath$T ~ifcに定義される `stroke()$M 演算 `HTML$r を考える: ◎ It is first important to note that overloads have different behaviors than union types or optional arguments, and one cannot be fully defined using the other (unless, of course, additional prose is provided, which can defeat the purpose of the Web IDL type system). For example, consider the stroke() operations defined on the CanvasDrawPath interface [HTML]:
interface CanvasDrawPathExcerpt { void stroke(); void stroke(Path2D %path); };
~ES言語束縛により、 `CanvasDrawPathExcerpt^T を実装している~obj上で `stroke(undefined)^c を~callした場合, 2 個目の多重定義を~callしようと試みる結果 `TypeError$jE になる — `undefined^jv は `Path2D$T に変換-できないので。 しかしながら~~仮に、演算が,`随意~引数$を伴って定義されていて,一つに併合されていた場合: ◎ Per the ECMAScript language binding, calling stroke(undefined) on an object implementing CanvasDrawPathExcerpt would attempt to call the second overload, yielding a TypeError since undefined cannot be converted to a Path2D. However, if the operations were instead defined with optional arguments and merged into one,
interface CanvasDrawPathExcerptOptional { void stroke(optional Path2D %path); };
`多重定義~解決~algo$は、同じ `stroke(undefined)^c ~callに対し, %path 引数 を在さないものと扱うことになり,例外は投出されない。 ◎ the overload resolution algorithm would treat the path argument as not present given the same call stroke(undefined), and not throw any exceptions.
注記: この特定0の例では、後者の挙動が,実際に~Web開発者たちが一般に期待するものである。 今日 `CanvasDrawPath$T を設計するなら、 `stroke()^M には`随意~引数$を利用することになるであろう。 ◎ Note: For this particular example, the latter behavior is actually what Web developers would generally expect. If CanvasDrawPath were to be designed today, optional arguments would be used for stroke().
加えて,意味論的な相違もある。 `共用体~型$は、通例的に “どの型もおよそ同じ仕方で働く” ような~~意味で利用される。 対照的に,`多重定義$された演算は、 C++ の多重定義などの言語~特色機能に上手く対応付けられるように設計されており、通例的に,所与の引数の異なる型ごとに何を行うかについて相当の相違がある演算たちに、より良く収まる。 しかしながら,ほとんどの事例では、そのような相違がある演算たちには 異なる名前を伴わせて,~Web開発者からの混同を避けるのが最善になる — ~ES言語は、言語~levelの多重定義を供さないので。 そのため,多重定義は、新たな~APIに適切になるのは稀であり,旧来の~APIや特化された状況下で現れることが多い。 ◎ Additionally, there are semantic differences as well. Union types are usually used in the sense that "any of the types would work in about the same way". In contrast, overloaded operations are designed to map well to language features such as C++ overloading, and are usually a better fit for operations with more substantial differences in what they do given arguments of different types. However, in most cases, operations with such substantial differences are best off with different names to avoid confusion for Web developers, since the ECMAScript language does not provide language-level overloading. As such, overloads are rarely appropriate for new APIs, instead often appearing in legacy APIs or in specialized circumstances.
どの~Web~IDL言語~特色機能を利用するか決定するのが難しい事例のために、次の推奨と例を提供する: ◎ That being said, we offer the following recommendations and examples in case of difficulties to determine what Web IDL language feature to use:
-
演算の返値型を 引数の型ごとに異ならせる必要があるような,通例的でない事例では、`多重定義$の方が,より表現力のある~IDL片になる。 これが適切な~API設計になることは、まずない。 そのような事例では、別個の名前を伴う別々の演算にする方が,通例的に良くなる。 ◎ In the unusual case where the operation needs to return values of different types for different argument types, overloading will result in more expressive IDL fragments. This is almost never appropriate API design, and separate operations with distinct names usually are a better choice for such cases.
演算 `calculate()^M は,[ `long$T, `DOMString$T, `CalculatableInterface^T ( `~ifc型$ ) ]を受容する引数を 1 個だけとり,引数と同じ型の値を返すとする。 この場合、`多重定義$された演算を用いて~IDL片を書く方が明瞭になるであろう: ◎ Suppose there is an operation calculate() that accepts a long, DOMString, or CalculatableInterface (an interface type) as its only argument, and returns a value of the same type as its argument. It would be clearer to write the IDL fragment using overloaded operations as
interface A { long calculate(long %input); DOMString calculate(DOMString %input); CalculatableInterface calculate(CalculatableInterface %input); };
`~typedef$を伴う`共用体~型$を利用するよりも: ◎ than using a union type with a typedef as
typedef (long or DOMString or CalculatableInterface) Calculatable; interface A { Calculatable calculate(Calculatable %input); };
これは、返値が常に %入力 と同じ型になる事実を伝えないので。 ◎ which does not convey the fact that the return value is always of the same type as input.
多重定義のいずれかの返値型が `void$T であるときには、より問題になる — `共用体~型$は`~mb型$に `void$T すら包含できないので。 その事例では、返値型を定義する適切な注釈文を伴わせた上で,返値型に `any$T を利用する必要があり、表現力はさらに乏しくなる。 ◎ The problem is exacerbated when one of the overloads has a return type of void, since union types cannot even contain void as a member type. In that case, a return type of any needs to be used with appropriate prose defining the return type, further decreasing expressiveness.
仕様~化する `calculate()^M が新たな~APIで,互換性の懸念はない場合、多重定義される演算に対しては,互いに異なる名前を利用することが示唆される — 例えば,次のように: ◎ If the specified calculate() is a new API and does not have any compatibility concerns, it is suggested to use different names for the overloaded operations, perhaps as
interface A { long calculateNumber(long %input); DOMString calculateString(DOMString %input); CalculatableInterface calculateCalculatableInterface(CalculatableInterface %input); };
こうすれば、~Web開発者は,明示的かつ一義的な~codeを書けるようになる。 ◎ which allows Web developers to write explicit and unambiguous code.
-
【 他にも、演算ごとに異なる拡張属性や特殊~演算を指定する場合も、多重定義する他にないであろう — 例えば: 】
interface A { `NewObject$x X calculate f(B %a); X calculate f(C %a); };
【 (このように指定される演算は,ほぼないと思われるが、このような指定-法を総じて禁止している箇所は,この仕様の中には見当たらない。) 】
-
引数の型や個数ごとに,演算が意味論的に有意に異なる場合、`多重定義$が選好される。 ここでも,そのような局面では、別個の名前を伴わせた別々の演算を作成する方が通例的には良いが、旧来の~APIには,この~patternに従うものもある。 ◎ When the operation has significantly different semantics for different argument types or lengths, overloading is preferred. Again, in such scenarios, it is usually better to create separate operations with distinct names, but legacy APIs sometimes follow this pattern.
例として, `CSS$T ~ifc 【現在は`~ns$に変更されている】 の `supports()$M 演算 `CSS3-CONDITIONAL$r `CSSOM$r は、次の~IDL片として定義されている: ◎ As an example, the supports() operations of the CSS interface is defined as the following IDL fragment [CSS3-CONDITIONAL] [CSSOM].
partial interface CSS { static boolean supports(CSSOMString %property, CSSOMString %value); static boolean supports(CSSOMString %conditionText); };
この~IDL片は、`随意~引数$を用いて,次のように書き直すこともできる: ◎ Using optional arguments one can rewrite the IDL fragment as follows:
partial interface CSSExcerptOptional { static boolean supports(CSSOMString %propertyOrConditionText, optional CSSOMString %value); };
この~versionの~IDLは、元のものより短くなっているが, 1 個目の引数に全く異なる 2 つの概念が~~併合されている。 `多重定義$しない場合、注釈文による演算の定義を読むことなく, “ %property / %conditionText は %value と~pairになるのか? ” のような問いに答えるのは、はるかに難しくなる。 そのため、この~versionは,元のものより著しく読み取り難くなっている。 ◎ Even though the IDL is shorter in the second version, two distinctively different concepts are conflated in the first argument. Without overloads, the question "is property or conditionText paired with value?" is much more difficult to answer without reading the prose definition of the operation. This makes the second version remarkably less readable than the first.
別の考慮点として、`多重定義$された演算の注釈文は,演算ごとに別々の~block内に指定できるので、仕様を読むときにも書くときにも援助になることが挙げられる — このことは、`随意~引数$にはあてはまらない。 すなわち,最初の事例に対しては、仕様~策定者は,演算の定義を 次のように注釈文に書けるようになる: ◎ Another consideration is that the prose for overloaded operations can be specified in separate blocks, which can aid in both reading and writing specifications. This is not the case for optional arguments. This means that in the first case the specification author can write the prose definition of the operations as:
supports(%property, %value)
~methの~call時には、次を走らせ~MUST: ◎ The supports(property, value) method, when called, must run these steps:- …
supports(%conditionText)
~methの~call時には、次を走らせ~MUST: ◎ The supports(conditionText) method, when called, must run these steps:- …
それでも`随意~引数$として %value を用いる場合、仕様~策定者は,[ 実質的に`多重定義~解決~algo$を再現するような,模範文例的~style ]で~textを書く必要がある。 ◎ Yet using value as an optional argument, the specification author has to use more boilerplate-style text to effectively replicate the overload resolution algorithm.
supports(%propertyOrConditionText, %value)
~methの~call時には、次を走らせ~MUST: ◎ The supports(propertyOrConditionText, value) method, when called, must run these steps:-
~IF[ %value は与えられている ]: ◎ If value is given, then:
- %property ~LET %propertyOrConditionText ◎ Let property be propertyOrConditionText.
- …
-
~ELSE: ◎ Otherwise:
- %conditionText ~LET %propertyOrConditionText ◎ Let conditionText be propertyOrConditionText.
- …
2 つの多重定義が共有する部分が少ししかないなら、多重定義~解決を~IDLの仕組みに委ねる方が良い。 ◎ If the two overloads have little to no shared parts, it is better to leave overload resolution to the IDL mechanism.
-
演算が 複数の引数をとり,その それぞれが複数の型を受容していて,異なる引数どうしの型が組にされていない場合、`共用体~型$の他は~~実現できそうにないこともある。 ◎ If the operation accepts multiple types for multiple arguments with no coupling between types of different arguments, union types can sometimes be the only viable solution.
typedef (long long or DOMString or CalculatableInterface) SupportedArgument; interface A { void add(SupportedArgument %operand1, SupportedArgument %operand2); };
上の `add()^M 演算を,`多重定義$を利用して指定しようとした場合、次が要求されることになる: ◎ For the add() operation above, to specify it using overloads would require
interface A { void add(long long %operand1, long long %operand2); void add(long long %operand1, DOMString %operand2); void add(long long %operand1, CalculatableInterface %operand2); void add(DOMString %operand1, long long %operand2); void add(DOMString %operand1, DOMString %operand2); void add(DOMString %operand1, CalculatableInterface %operand2); void add(CalculatableInterface %operand1, long long %operand2); void add(CalculatableInterface %operand1, DOMString %operand2); void add(CalculatableInterface %operand1, CalculatableInterface %operand2); };
対応する注釈文も, 9 回重ねることになる。 ◎ and nine times the corresponding prose!
-
仕様~策定者には、 `missing^C 引数と `undefined^jv 引数とを,~ES言語束縛において同じ仕方で扱うことが奨励される。 ◎ Specification authors are encouraged to treat missing argument and undefined argument the same way in the ECMAScript language binding.
次の~IDL片が与えられたとき: ◎ Given the following IDL fragment:
interface A { void foo(); void foo(Node? %arg); };
~ES言語束縛を利用する下で, `foo()^M を~callするとき、引数に[ `undefined^jv / `null^jv ]を渡した場合は, %arg を ~NULL に設定した上で 2 個目の `foo()^M 演算に対応する手続きを走らすことになる。 一方で、引数を省いた場合は, 1 個目の多重定義に行くことになり、多くの~API利用者にとって意外な挙動になるであろう。 仕様~策定者には、代わりに,`随意~引数$を利用することが奨励される — そうすれば、引数が省かれたときも `undefined^jv のときも, “%arg は在さない” に分類されることになる。 ◎ Using the ECMAScript language binding, calling foo(undefined) and foo(null) would both run the steps corresponding to the foo(arg) operation, with arg set to null, while foo() alone would go to the first overload. This can be a surprising behavior for many API users. Instead, specification authors are encouraged to use an optional argument, which would categorize both foo() and foo(undefined) as "arg is not present".
interface A { void foo(optional Node? %arg); };
一般に,随意~性は、多重定義は利用せず, `optional^c ~keywordを利用して表すのが最善になる。 ◎ In general, optionality is best expressed using the optional keyword, and not using overloads.
上のどの分類にも収まらない事例で,どの~styleを選ぶかは、仕様~策定者に委ねられる — ほとんどの場合、どちらの~styleでも,意図される挙動を簡便に述べるに足るので。 しかしながら、[ `共用体~型$, `随意~引数$ ]の定義と変換~algoの方が,`多重定義$のそれよりも実装して選り分けるのは単純であり、通例的に,~ES言語束縛において より成句的な~APIになる。 したがって,他の考慮点が適用されない限り、`共用体~型$や`随意~引数$を選ぶ方が既定になる。 ◎ When the case fits none of the categories above, it is up to the specification author to choose the style, since it is most likely that either style would sufficiently and conveniently describe the intended behavior. However, the definition and conversion algorithms of union types and optional arguments are simpler to implement and reason about than those of overloads, and usually result in more idiomatic APIs in the ECMAScript language binding. Thus, unless any other considerations apply, union types (and/or optional arguments) are the default choice.
仕様~策定者は、適切かつ簡便であると見出したなら,共用体~型と多重定義を混ぜ合わせるのも自由である。 ◎ Specifications are also free to mix and match union types and overloads, if the author finds it appropriate and convenient.
2.4.7. 可反復~宣言
~ifcは `可反復@ になるように宣言できる。 そのためには、`~ifc$の本体にて `可反復~宣言@ (`Iterable$g に合致)を利用する。 ◎ An interface can be declared to be iterable by using an iterable declaration (matching Iterable) in the body of the interface.
interface `interface_identifier^i { iterable<`value_type^i>; iterable<`key_type^i, `value_type^i>; };
可反復として宣言された~ifcを実装している~objは、値の連列を得るために反復できるようになる。 ◎ Objects implementing an interface that is declared to be iterable support being iterated over to obtain a sequence of values.
注記: ~ES言語束縛においては、可反復な~ifcは、その`~ifc原型~obj$上に,[ `entries^jp, `forEach^jp, `keys^jp, `values^jp, `iterator$jS ]~propを持つことになる。 ◎ Note: In the ECMAScript language binding, an interface that is iterable will have entries, forEach, keys, values, and @@iterator properties on its interface prototype object.
~parameterとして所与の型の個数が: ◎ ↓
- 1 個の場合、~ifcは,その型の値たちを供する `値~反復子@ を持つことになる。 ◎ If a single type parameter is given, then the interface has a value iterator and provides values of the specified type.\
- 2 個の場合、~ifcは,[ ~key, 値 ]からなる~pairたちを供する `~pair反復子@ を持つことになる。 ここで、~pairの~keyは, 1 個目の型の値をとり、~pairの値は, 2 個目の型の値をとる。 ◎ If two type parameters are given, then the interface has a pair iterator and provides value pairs, where the first value is a key and the second is the value associated with the key.
`値~反復子$は、`有index~propを~support$する~ifc上を除き,宣言されては~MUST_NOT。 `値~反復子$の値~型は、`有index~prop取得子$が返す型と同じで~MUST。 `値~反復子$は暗黙的に,当の~objの有index~prop上を反復するように定義される。 ◎ A value iterator must only be declared on an interface that supports indexed properties. The value-type of the value iterator must be the same as the type returned by the indexed property getter. A value iterator is implicitly defined to iterate over the object’s indexed properties.
`~pair反復子$は、`有index~propを~support$する~ifc上に宣言されては~MUST_NOT。 `~pair反復子$を伴う`~ifc$においては、付帯する注釈文にて[ 何が `反復される値~pair@ の~listを成すのか ]が定義され~MUST。 ◎ A pair iterator must not be declared on an interface that supports indexed properties. Prose accompanying an interface with a pair iterator must define what the list of value pairs to iterate over is.
`値~反復子$に対し生成される~ES `forEach^jp ~methは、 `Array.prototype.forEach^c が行うように,その呼戻子を呼出す。 `~pair反復子$用の `forEach^jp ~methは、 `Map.prototype.forEach^c が行うように,その呼戻子を呼出す。 ◎ The ECMAScript forEach method that is generated for a value iterator invokes its callback like Array.prototype.forEach does, and the forEach method for a pair iterator invokes its callback like Map.prototype.forEach does.
現在,`値~反復子$は`有index~propを~support$する~ifcに限り許容されているので、 `forEach^jp ~methを配列のように利用することにも~~意味がある。 `値~反復子$は、次のものにも必要かもしれない: (a) `有index~propを~support$しない~ifc上, あるいは (b) 呼戻子を,代わりに `Set.protoype.forEach^c のように呼出す(ここで~keyは,値と同じ)ような `forEach^jp ~methに対して。 そのような `forEach^jp ~methを必要とする~APIを再~作成している策定者は、`Enhancement request for Iterables$fIされたし。 ◎ Since value iterators are currently allowed only on interfaces that support indexed properties, it makes sense to use an Array-like forEach method. There may be a need for value iterators (a) on interfaces that do not support indexed properties, or (b) with a forEach method that instead invokes its callback like Set.protoype.forEach (where the key is the same as the value). If you’re creating an API that needs such a forEach method, please file an issue.
注記: `配列~反復子~obj$は,このように働く。 `有index~propを~support$する ~ifcに対しては、[ `entries^jp / `keys^jp / `values^jp / `iterator$jS ]から返される反復子~objは,実際の`配列~反復子~obj$である。 ◎ Note: This is how array iterator objects work. For interfaces that support indexed properties, the iterator objects returned by entries, keys, values, and @@iterator are actual array iterator objects.
[ 可反復~宣言を伴う~ifc, および その`継承d~ifc$ ]の`~ifc~mb$の名前は[ `entries^l / `forEach^l / `keys^l / `values^l ]にされては~MUST_NOT。 ◎ Interfaces with iterable declarations must not have any interface members named "entries", "forEach", "keys", or "values", or have any inherited interfaces that have members with these names.
次の~ifcを考える。 `SessionManager^T は、文字列 %username を~keyに,一連の `Session^T ~objに~accessできるようにする: ◎ Consider the following interface SessionManager, which allows access to a number of Session objects keyed by username:
[Exposed=Window] interface SessionManager { Session getSessionForUser(DOMString %username); iterable<DOMString, Session>; }; [Exposed=Window] interface Session { readonly attribute DOMString username; /* */ };
反復子の挙動は、次の様に定義することもできる: ◎ The behavior of the iterator could be defined like so:
`反復される値~pair$の~listを成す各 ( ~key / 値 ) ~pairは, ( `username^M / [ `SessionManager^T ~obj上で open している `Session^T ~obj ] ) で与えられ、~listは `username^M の昇順で整列される。 ◎ The value pairs to iterate over are the list of key-value pairs with the key being the username and the value being the open Session object on the SessionManager object corresponding to that username, sorted by username.
~ES言語束縛においては、 `SessionManager^T `~ifc$用の`~ifc原型~obj$は、次の~methを持つことになる:
- `values^jp ~meth: 被呼出時には[[ 次の反復値を返す `next^jp ~meth ]を持つ反復子~obj ]を返す関数。
- `keys^jp ~meth: 一連の `Session^T ~objの `username^M を反復する。
- `entries^jp ~meth: 一連の ( `username^M / `Session^T ~obj ) ~pairを反復する。
- `iterator$jS ~meth: `entries^jp ~methと同じ値をとり, `SessionManager^T を `for..of^c ~loopの中でも利用できるようする。
/* `SessionManager^T の~instanceを取得する。 2 人の利用者 `anna^l, `brian^l 用の session があるとする。 ◎ Get an instance of SessionManager. Assume that it has sessions for two users, "anna" and "brian". */ var %sm = getSessionManager(); typeof SessionManager.prototype.values; /* */ var %it = %sm.values(); /* `values()^c は反復子~objを返す ◎ values() returns an iterator object */ typeof %it.next; /* */ /* この~loopは、順に `anna^l, `brian^l を log することになる。 ◎ This loop will log "anna" and then "brian". */ for (;;) { let %result = %it.next(); if (%result.done) { break; } let %session = %result.value; console.log(%session.username); } /* この~loopも、順に `anna^l, `brian^l を log することになる。 ◎ This loop will also log "anna" and then "brian". */ for (let %username of %sm.keys()) { console.log(%username); } /* 同じことを達成する別の仕方。 ◎ Yet another way of accomplishing the same. */ for (let [%username, %session] of %sm) { console.log(%username); }
`可反復~宣言$を伴う~ifc %I に対しては、[ %I, および %I の`継承d~ifc$ ]に[ 別の`可反復~宣言$, `~maplike 宣言$, `~setlike 宣言$ ]が宣言されていては~MUST_NOT。 ◎ An interface must not have more than one iterable declaration. The inherited interfaces of an interface with an iterable declaration must not also have an iterable declaration. An interface with an iterable declaration and its inherited interfaces must not have a maplike declaration or setlike declaration.
`可反復~宣言$に適用-可能な拡張属性は ⇒ `Exposed$x, `SecureContext$x ◎ The following extended attributes are applicable to iterable declarations: [Exposed], [SecureContext].
2.4.8. ~maplike 宣言
~ifcは `~maplike@ ( `maplike^en )になるように宣言できる。 そのためには、`~ifc$の本体にて `~maplike 宣言@ ( `ReadWriteMaplike$g / `readonly^sym `MaplikeRest$g いずれかに合致)を利用する。 ◎ An interface can be declared to be maplike by using a maplike declaration (matching ReadWriteMaplike or readonly MaplikeRest) in the body of the interface.
interface `interface_identifier^i { readonly maplike<`key_type^i, `value_type^i>; maplike<`key_type^i, `value_type^i>; };
~maplikeになるように宣言された~ifcを実装する~objは、その一連の[ `~map~entry@ と呼ばれる~key-value ]からなる,有順序~listを表現する。 ~keyおよび~valueに利用される型は、~maplike 宣言の山括弧の中で与えられる。 それらの~keyは一意になることが要求される。 ◎ Objects implementing an interface that is declared to be maplike represent an ordered list of key–value pairs known as its map entries. The types used for the keys and values are given in the angle brackets of the maplike declaration. Keys are required to be unique.
`~maplike$ ~ifcを実装している~objの`~map~entry$の~listは、~objの作成~時には空である。 ~ifcに付帯している注釈文は、~objの一連の`~map~entry$が どう変化するかを述べ得る。 ◎ The map entries of an object implementing a maplike interface is empty at the of the object’s creation. Prose accompanying the interface can describe how the map entries of an object change.
~maplike~ifcは、一連の~map~entryを照会するための,言語束縛に適切な~APIを~supportする。 `readonly^c ~keywordが利用されなかった場合†、~map~entryを改変するための~APIも~supportする。 【† 以下, “可書~maplike” とも記される】 ◎ Maplike interfaces support an API for querying the map entries appropriate for the language binding. If the readonly keyword is not used, then it also supports an API for modifying the map entries.
注記: ~ES言語束縛においては、一連の~map~entryと相互作用するための~APIは, ~ESにて可用な `Map$jt ~objに類似する。 `readonly^c ~keywordが利用された場合、それは[ `entries^jp, `forEach^jp, `get^jp, `has^jp, `keys^jp, `values^jp, `iterator$jS ]~meth, および `size^jp 取得子を含む。 可書~maplikeに対しては、更に[ `clear^jp, `delete^jp, `set^jp ]~methも含む。 ◎ Note: In the ECMAScript language binding, the API for interacting with the map entries is similar to that available on ECMAScript Map objects. If the readonly keyword is used, this includes entries, forEach, get, has, keys, values, @@iterator methods, and a size getter. For read–write maplikes, it also includes clear, delete, and set methods.
[ ~maplike~ifc, および その`継承d~ifc$ ]の`~ifc~mb$の名前は[ `entries^l / `forEach^l / `get^l / `has^l / `keys^l / `size^l / `values^l ]にされては~MUST_NOT。 [ 可書~maplike~ifc, および その`継承d~ifc$ ]の[ `属性$, `定数$ ]の名前は[ `clear^l / `delete^l / `set^l ]にされては~MUST_NOT。 ◎ Maplike interfaces must not have any interface members named "entries", "forEach", "get", "has", "keys", "size", or "values", or have any inherited interfaces that have members with these names. Read–write maplike interfaces must not have any attributes or constants named "clear", "delete", or "set", or have any inherited interfaces that have attributes or constants with these names.
注記: [ 名前 ~IN { `clear^l, `delete^l, `set^l } ]なる演算は,可書~maplike~ifc上にも許容され、その場合,~ES言語束縛においては,その~methの既定の実装は `~ifc原型~obj$に追加されなくなる。 これにより、これらの演算の既定の挙動を上書きできるようになる。 ◎ Note: Operations named "clear", "delete", or "set" are allowed on read–write maplike interfaces and will prevent the default implementation of these methods being added to the interface prototype object in the ECMAScript language binding. This allows the default behavior of these operations to be overridden.
~maplike~ifc %I に対しては、[ %I, および %I の`継承d~ifc$ ]に[ `可反復~宣言$, 別の`~maplike 宣言$, `~setlike 宣言$ ]が宣言されていては~MUST_NOT。 ◎ An interface must not have more than one maplike declaration. The inherited interfaces of a maplike interface must not also have a maplike declaration. A maplike interface and its inherited interfaces must not have an iterable declaration or setlike declaration.
`~maplike 宣言$に適用-可能な`拡張属性$は、この仕様では定義されない。 ◎ No extended attributes defined in this specification are applicable to maplike declarations.
例を追加する。 ◎ Add example.
2.4.9. ~setlike 宣言
~ifcは `~setlike@ ( `setlike^en )になるように宣言できる。 そのためには、`~ifc$の本体にて `~setlike 宣言@ ( `ReadWriteSetlike$g / `readonly^sym `SetlikeRest$g いずれかに合致)を利用する。 ◎ An interface can be declared to be setlike by using a setlike declaration (matching ReadWriteSetlike or readonly SetlikeRest) in the body of the interface.
interface `interface_identifier^i { readonly setlike<`type^i>; setlike<`type^i>; };
~setlikeになるように宣言された~ifcを実装する~objは、その一連の[ `~set~entry@ と呼ばれる~value ]からなる,有順序~listを表現する。 ~valueに利用される型は、~setlike 宣言の山括弧の中で与えられる。 それらの~valueは一意になることが要求される。 ◎ Objects implementing an interface that is declared to be setlike represent an ordered list of values known as its set entries. The type of the values is given in the angle brackets of the setlike declaration. Values are required to be unique.
`~setlike$ ~ifcを実装している~objの`~set~entry$の~listは、~objの作成~時には空である。 ~ifcに付帯している注釈文は、~objの一連の`~set~entry$が どう変化するかを述べ得る。 ◎ The set entries of an object implementing a setlike interface is empty at the of the object’s creation. Prose accompanying the interface can describe how the set entries of an object change.
~setlike~ifcは、一連の~set~entryを照会するための,言語束縛に適切な~APIを~supportする。 `readonly^c ~keywordが利用されなかった場合†、~set~entryを改変するための API も~supportする。 【† 以下, “可書~setlike” とも記される】 ◎ Setlike interfaces support an API for querying the set entries appropriate for the language binding. If the readonly keyword is not used, then it also supports an API for modifying the set entries.
注記: ~ES言語束縛においては、一連の~set~entryと相互作用するための~APIは, ~ESにて可用な `Set$jt ~objに類似する。 `readonly^c ~keywordが利用された場合、それは[ `entries^jp, `forEach^jp, `has^jp, `keys^jp, `values^jp, `iterator$jS ]~meth, および `size^jp 取得子を含む。 可書~setlikeに対しては、更に[ `add^jp, `clear^jp, `delete^jp ]~methも含む。 ◎ Note: In the ECMAScript language binding, the API for interacting with the set entries is similar to that available on ECMAScript Set objects. If the readonly keyword is used, this includes entries, forEach, has, keys, values, @@iterator methods, and a size getter. For read–write setlikes, it also includes add, clear, and delete methods.
[ ~setlike~ifc, および その`継承d~ifc$ ]の`~ifc~mb$の名前は[ `entries^l / `forEach^l / `has^l / `keys^l / `size^l / `values^l ]にされては~MUST_NOT。 [ 可書~setlike~ifc, および その`継承d~ifc$ ]の[ `属性$, `定数$ ]の名前は[ `add^l / `clear^l / `delete^l ]にされては~MUST_NOT。 ◎ Setlike interfaces must not have any interface members named "entries", "forEach", "has", "keys", "size", or "values", or have any inherited interfaces that have members with these names. Read–write setlike interfaces must not have any attributes or constants named "add", "clear", or "delete", or have any inherited interfaces that have attributes or constants with these names.
注記: 名前[ `add^l/`clear^l/`delete^l ]の演算は,可書~setlike~ifc上にも許容され、その場合,~ES言語束縛においては,その~methの既定の実装は `~ifc原型~obj$に追加されなくなる。 これにより、これらの演算の既定の挙動を上書きできるようになる。 ◎ Note: Operations named "add", "clear", or "delete" are allowed on read–write setlike interfaces and will prevent the default implementation of these methods being added to the interface prototype object in the ECMAScript language binding. This allows the default behavior of these operations to be overridden.
~setlike~ifc %I に対しては、[ %I, および %I の`継承d~ifc$ ]に[ `可反復~宣言$, `~maplike 宣言$, 別の`~setlike 宣言$ ]が宣言されていては~MUST_NOT。 ◎ An interface must not have more than one setlike declaration. The inherited interfaces of a setlike interface must not also have a setlike declaration. A setlike interface and its inherited interfaces must not have an iterable declaration or maplike declaration.
`~setlike 宣言$に適用-可能な`拡張属性$は、この仕様では定義されない。 ◎ No extended attributes defined in this specification are applicable to setlike declarations.
例を追加する。 ◎ Add example.
2.5. ~ns
`~ns@ ( `namespace^en )は、いくつかの挙動が結付けられた 大域~singletonを宣言する,`定義$( `Namespace$g に合致)である。 ◎ A namespace is a definition (matching Namespace) that declares a global singleton with associated behaviors.
【 すなわち、~instanceは 1 個しか存在し得ない(かつ,その 1 個は常に存在する)ような~ifcのようなものと捉えればよいであろう。 】
namespace `identifier^i { /* namespace_members... */ };
`~ns$は、その宣言を成す波括弧の合間に現れる[ `正則~演算$, `読専$な`正則~属性$ ]の集合( `NamespaceMembers$g に合致)の仕様である — これらの[ 演算/属性 ]~mbは、 `~ns~mb@ と称され,~nsの中に梱包された挙動を述べる。 ◎ A namespace is a specification of a set of namespace members (matching NamespaceMembers), which are the regular operations and read only regular attributes that appear between the braces in the namespace declaration. These operations and attributes describe the behaviors packaged into the namespace.
~ifcと同様、~ns用の~IDLは、 `部分的~ns定義@ ( `partial^sym `Namespace$g に合致)を利用して,複数の部分に分割できる。 部分的~ns定義の`識別子$は、その~ns定義の識別子と同じで~MUST。 それぞれの部分的~nsに現れる,すべての~mbは、その~ns自身を成す~mbと見なされる。 ◎ As with interfaces, the IDL for namespaces can be split into multiple parts by using partial namespace definitions (matching partial Namespace). The identifier of a partial namespace definition must be the same as the identifier of a namespace definition. All of the members that appear on each of the partial namespace definitions are considered to be members of the namespace itself.
namespace `SomeNamespace^mk { /* namespace_members... */ }; partial namespace `SomeNamespace^mk { /* namespace_members... */ };
注記: 部分的~ifc定義と同様に、部分的~ns定義に意図される用途は、~nsの定義を 文書の複数の節, ときには複数の文書に分離できるようにして,仕様の編集を補佐することである。 ◎ Note: As with partial interface definitions, partial namespace definitions are intended for use as a specification editorial aide, allowing the definition of a namespace to be separated over more than one section of the document, and sometimes multiple documents.
~mbたちが現れる順序は、 ~ES言語束縛 における~prop列挙に,有意になる。 ◎ The order that members appear in has significance for property enumeration in the ECMAScript binding.
~ifcや辞書と違って、~nsは型を作成しないことに注意。 ◎ Note that unlike interfaces or dictionaries, namespaces do not create types.
この仕様に定義される拡張属性のうち,~nsに適用-可能なのは `Exposed$x, `SecureContext$x に限られる。 ◎ Of the extended attributes defined in this specification, only the [Exposed] and [SecureContext] extended attributes are applicable to namespaces.
`~ns$は、 `Exposed$r `拡張属性$で注釈され~MUST。 ◎ Namespaces must be annotated with the [Exposed] extended attribute.
次の`~IDL片$は、`~ns$を定義する: ◎ The following IDL fragment defines an namespace.
[Exposed=Window] namespace VectorUtils { readonly attribute Vector unit; double dotProduct(Vector %x, Vector %y); Vector crossProduct(Vector %x, Vector %y); };
~ES実装は、(原型 `ObjectPrototype$jI を伴う)単純~objであった `VectorUtils^jp ~data-propを,宣言された各[ 演算に対する列挙-可能な~data-prop / 属性に対する列挙-可能な取得-のみの~accessor ]たちで公開することになる: ◎ An ECMAScript implementation would then expose a global VectorUtils data property which was a simple object (with prototype %ObjectPrototype%) with enumerable data properties for each declared operation, and enumerable get-only accessors for each declared attribute:
Object.getPrototypeOf(VectorUtils); /* `Object.prototype^c に評価される。 ◎ Evaluates to Object.prototype. */ Object.keys(VectorUtils); /* [`dotProduct^l, `crossProduct^l] に評価される。 ◎ Evaluates to ["dotProduct", "crossProduct"]. */ Object.getOwnPropertyDescriptor(VectorUtils, "dotProduct"); /* { value: <ある関数>, enumerable: true, configurable: true, writable: true } に評価される。 ◎ Evaluates to { value: <a function>, enumerable: true, configurable: true, writable: true }. */ Object.getOwnPropertyDescriptor(VectorUtils, "unit"); /* { get: <ある関数>, enumerable: true, configurable: true } に評価される。 ◎ Evaluates to { get: <a function>, enumerable: true, configurable: true }. */
2.6. 辞書
`辞書@ ( `dictionary^en )は、[ 有順序かつ固定的な,一連の[ `辞書~mb@ と呼ばれる`~entry$ ]からなる`有順序~map$~data型 ]を定義するために利用される,`定義$( `Dictionary$g に合致)である。 各`~entry$の`~key$は文字列であり,その`値$は定義の中で指定される特定0の型に属する。 ◎ A dictionary is a definition (matching Dictionary) used to define an ordered map data type with a fixed, ordered set of entries, termed dictionary members, where keys are strings and values are of a particular type specified in the definition.
dictionary `identifier^i { /* dictionary_members... */ };
辞書は常に値渡しである。 辞書が何らかの種類の~objで表現される言語束縛においても、`~platform~obj$に辞書が渡された際に,その辞書への参照が~objに保有されることはない。 同様に,~platform~objから返されるどの辞書も複製であり、それに対する改変は~platform~objからは可視にならないことになる。 ◎ Dictionaries are always passed by value. In language bindings where a dictionary is represented by an object of some kind, passing a dictionary to a platform object will not result in a reference to the dictionary being kept by that object. Similarly, any dictionary returned from a platform object will be a copy and modifications made to it will not be visible to the platform object.
辞書は 別の辞書を `継承-@diC するように定義できる。 辞書の識別子に~colonと`識別子$が後続する場合、後者の識別子が,継承される辞書を識別する。 この識別子は、辞書を識別するもので~MUST。 ◎ A dictionary can be defined to inherit from another dictionary. If the identifier of the dictionary is followed by a colon and a identifier, then that identifier identifies the inherited dictionary. The identifier must identify a dictionary.
辞書は、その継承~階層が循環するように宣言されては~MUST_NOT。 すなわち,辞書 %D は、 %D 自身を継承することも, %D を継承する別の辞書を継承することもできない,等々。 ◎ A dictionary must not be declared such that its inheritance hierarchy has a cycle. That is, a dictionary A cannot inherit from itself, nor can it inherit from another dictionary B that inherits from A, and so on.
dictionary `Base^mk { /* dictionary_members... */ }; dictionary `Derived^i : `Base^mk { /* dictionary_members... */ };
所与の辞書~型 %D の `継承d辞書@ とは、 %D が直接間接に継承するすべての辞書が成す集合である。 %D が他の辞書を`継承-$diCしない場合、集合は空になる。 他の場合、集合は %D が`継承-$diCする辞書 %E と %E の`継承d辞書$すべてを含む。 ◎ The inherited dictionaries of a given dictionary D is the set of all dictionaries that D inherits from, directly or indirectly. If D does not inherit from another dictionary, then the set is empty. Otherwise, the set includes the dictionary E that D inherits from and all of E’s inherited dictionaries.
型 %D の辞書~値 %d は、 %D 上および %D の`継承d辞書$上で定義される辞書~mbに対応する~key-valueを持ち得る。 %d 上における,各~辞書~mbの存在pは、それが %D において`必須~辞書~mb$であると指定されていない限り,随意である。 %d 上に指定されているならば,その辞書~mbは `在する@ ( `present^en )といい、そうでなければ `在さない$ ( `not present^en )という。 辞書~mbは,随意で `既定~値@diC も持ち得る。 それは、 %d 上にその~mb値が指定されずに %d が`~platform~obj$に渡された際に,辞書~mbに利用される値になる。 既定~値を伴う辞書~mbは常に在するものと見なされる。 ◎ A dictionary value of type D can have key–value pairs corresponding to the dictionary members defined on D and on any of D’s inherited dictionaries. On a given dictionary value, the presence of each dictionary member is optional, unless that member is specified as required. When specified in the dictionary value, a dictionary member is said to be present, otherwise it is not present. Dictionary members can also optionally have a default value, which is the value to use for the dictionary member when passing a value to a platform object that does not have a specified value. Dictionary members with default values are always considered to be present.
注記: ~ES言語束縛における `undefined^jv 値は,`在さない$ものと扱われ、適用-可能な所では`既定~値$diCが用いられることになる。 ◎ In the ECMAScript binding, a value of undefined is treated as not present, or will trigger the default value where applicable.
文字列を`~key$とする`有順序~map$ %M は、次を満たすならば,暗黙的に特定の辞書 %D の辞書~値として扱える ⇒ [ %M を成すどの`~entry$も、 %D を成すある`辞書~mb$に対応していて, 正しい型の値を伴う ]~AND[ %M における`~entry$たちの順序は、この対応の下で, %D における`辞書~mb$たちの順序に従っている ]~AND[ %D を成すどの`必須~辞書~mb$に対しても,それに対応する %M の~entryがある ] ◎ An ordered map with string keys can be implicitly treated as a dictionary value of a specific dictionary D if all of its entries correspond to dictionary members, in the correct order and with the correct types, and with appropriate entries for any required dictionary members.
演算~引数の`既定~値$と同様に、 `boolean$T 型の`辞書~mb$に対しては、`既定~値$diCとして `true^V を利用しないことを強く勧める。 さもなければ、 `undefined^jv に既定の変換(すなわち, `false^V )が利用されると期待する作者たちを惑わすことになるので。 ◎ As with operation argument default values, it is strongly suggested not to use true as the default value for boolean-typed dictionary members, as this can be confusing for authors who might otherwise expect the default conversion of undefined to be used (i.e., false).
各`辞書~mb$( `DictionaryMember$g に合致)は、型( `Type$g に合致)および, 後続の( `identifier$g ~tokenで与えられる)`識別子$により指定され、その識別子が~key-valueの~key名になる。 ◎ Each dictionary member (matching DictionaryMember) is specified as a type (matching Type) followed by an identifier (given by an identifier token following the type). The identifier is the key name of the key–value pair.\
辞書~mb型を与える `Type$g が:
- `?^c が後続する`識別子$である場合、その識別子は[ `~ifc$/`列挙$/`呼戻~関数$/`~typedef$ ]を識別し~MUST。
- `?^c が後続しない`識別子$である場合、その識別子は[ `辞書$/前項に挙げたいずれかの定義 ]を識別し~MUST。
`辞書~mb$の型が`~typedef$の解決-後に`~nullable型$になる場合、その`内縁~型$は,`辞書~型$になっては~MUST_NOT。 ◎ If the type of the dictionary member, after resolving typedefs, is a nullable type, its inner type must not be a dictionary type.
dictionary `identifier^i { `type^i `identifier^i; };
識別子に `003D^U1 と値( `DefaultValue$g に合致)が後続している場合、それが辞書~mbの`既定~値$diCを与える。 ◎ If the identifier is followed by a U+003D EQUALS SIGN ("=") and a value (matching DefaultValue), then that gives the dictionary member its default value.
dictionary `identifier^i { `type^i `identifier^i = "value"; };
`既定~値$diCに[ `定数~token$ / `string$g ~token / 2 個の~token並び `[]^c ]が利用された場合、 `演算$の引数の`既定~値$ のときと同じ仕方で解釈される。 ◎ When a boolean literal token (true or false), the null token, an integer token, a float token, one of the three special floating point literal values (Infinity, -Infinity or NaN), a string token or the two token sequence [] used as the default value, it is interpreted in the same way as for an operation’s optional argument default value.
`辞書~mb$の型が`列挙$である場合、その`既定~値$diCに指定される値は,その`列挙~値$のいずれかで~MUST。 ◎ If the type of the dictionary member is an enumeration, then its default value if specified must be one of the enumeration’s values.
辞書~mbの型の前に ~keyword `required^c が置かれた場合、その~mbは `必須~辞書~mb@ と見なされ,辞書~上に`在する$ことが要求される。 `必須~辞書~mb$は、`既定~値$を持っては~MUST_NOT。 ◎ If the type of the dictionary member is preceded by the required keyword, the member is considered a required dictionary member and must be present on the dictionary. A required dictionary member must not have a default value.
dictionary `identifier^i { required `type^i `identifier^i; };
辞書~mbの型は,その辞書を 内包- しては~MUST_NOT。 次のいずれかを満たす型 %T は、辞書~型 %D を内包するものとされる: ◎ The type of a dictionary member must not include the dictionary it appears on. A type includes a dictionary D if at least one of the following is true:
- %T は %D である ◎ the type is D
- %T は %D を`継承-$diCしている辞書である ◎ the type is a dictionary that inherits from D
- %T は`~nullable型$であり,その`内縁~型$は %D を内包している ◎ the type is a nullable type whose inner type includes D
- %T は[ `連列~型$, または`凍結~配列~型$ ]であり,その要素~型は %D を内包している ◎ the type is a sequence type or frozen array whose element type includes D
- %T は`共用体~型$であり,そのいずれかの`~mb型$は %D を内包している ◎ the type is a union type, one of whose member types includes D
- %T は辞書であり,そのいずれかの[ 自前の, または 継承している ]~mbの型は %D を内包している ◎ the type is a dictionary, one of whose members or inherited members has a type that includes D
- %T は `~record_KV$ であり, %V は %D を内包している ◎ the type is record<K, V> where V includes D
~ifcと同様に、辞書~用の~IDLは `部分的~辞書~定義@ ( `partial^sym `Dictionary$g に合致)を利用して複数の部分に分割できる。 部分的~辞書~定義の`識別子$は、当の辞書~定義の識別子と同じで~MUST。 それぞれの部分的~辞書~定義に現れるすべての~mbは、辞書~自身を成す~mbと見なされる。 ◎ As with interfaces, the IDL for dictionaries can be split into multiple parts by using partial dictionary definitions (matching partial Dictionary). The identifier of a partial dictionary definition must be the same as the identifier of a dictionary definition. All of the members that appear on each of the partial dictionary definitions are considered to be members of the dictionary itself.
dictionary `SomeDictionary^mk { /* dictionary_members... */ }; partial dictionary `SomeDictionary^mk { /* dictionary_members... */ };
注記: 部分的~ifc定義と同様に、部分的~辞書~定義に意図される用途は、辞書の定義を 文書の複数の節, ときには複数の文書に分離できるようにして,仕様の編集を補佐することである。 ◎ Note: As with partial interface definitions, partial dictionary definitions are intended for use as a specification editorial aide, allowing the definition of an interface to be separated over more than one section of the document, and sometimes multiple documents.
所与の辞書~上の`辞書~mb$は、継承された辞書~mbが 継承していない~mbより前に位置するように順序付けられる。 同じ辞書~定義~上の(部分的~辞書~定義もすべて含めた)すべての辞書~mbは、それらの識別子を構成する~Unicode符号位置により,辞書式に順序付けられる。 ◎ The order of the dictionary members on a given dictionary is such that inherited dictionary members are ordered before non-inherited members, and the dictionary members on the one dictionary definition (including any partial dictionary definitions) are ordered lexicographically by the Unicode codepoints that comprise their identifiers.
例えば,次の定義では: ◎ For example, with the following definitions:
dictionary B : A { long b; long a; }; dictionary A { long c; long g; }; dictionary C : B { long e; long f; }; partial dictionary A { long h; long d; };
型 `C^T の辞書~値を成す`辞書~mb$の順序は[ `c^M, `d^M, `g^M, `h^M, `a^M, `b^M, `e^M, `f^M ]になる。 ◎ the order of the dictionary members of a dictionary value of type C is c, d, g, h, a, b, e, f.
辞書の~mbは順序付けられることが要求される。 一部の言語束縛においては、~platform~objに辞書~値を渡した際に観測される挙動が,辞書~mbを取りに行く順序に依存するので。 例えば,次の追加の~ifc: ◎ Dictionaries are required to have their members ordered because in some language bindings the behavior observed when passing a dictionary value to a platform object depends on the order the dictionary members are fetched. For example, consider the following additional interface:
[Exposed=Window] interface Something { void f(A %a); };
および,次の~ES~codeを考えるとき: ◎ and this ECMAScript code:
var %something = getSomething(); /*
`Something^T の~instanceを取得する。
◎
Get an instance of Something.
*/
var %x = 0;
var %dict = { };
Object.defineProperty(dict, "d", { get: function() { return ++%x; } });
Object.defineProperty(dict, "c", { get: function() { return ++%x; } });
%something.f(%dict);
辞書~mbを取りに行く順序が、それらがとることになる値を決定する。 `A^T における順序は, `c^M の次が `d^M と定義されるので、 `c^M に対する値は 1 になり, `d^M に対する値は 2 になる。 ◎ The order that the dictionary members are fetched in determines what values they will be taken to have. Since the order for A is defined to be c then d, the value for c will be 1 and the value for d will be 2.
辞書~mbの識別子は、その辞書~上, またはその辞書の`継承d辞書$上で定義される,別の辞書~mbの識別子と同じになっては~MUST_NOT。 ◎ The identifier of a dictionary member must not be the same as that of another dictionary member defined on the dictionary or on that dictionary’s inherited dictionaries.
辞書は[ `属性$/`定数$ ]の型に利用されては~MUST_NOT。 ◎ Dictionaries must not be used as the type of an attribute or constant.
`辞書$には、適用-可能な`拡張属性$はない。 ◎ No extended attributes are applicable to dictionaries.
辞書~型の利用の一つは、`演算$に対し、 呼出し~codeの所で指定される順序に制約を課すことなく,随意~引数をいくつでも与えられるようにすることである。 例えば,次の`~IDL片$を考える: ◎ One use of dictionary types is to allow a number of optional arguments to an operation without being constrained as to the order they are specified at the call site. For example, consider the following IDL fragment:
[Exposed=Window, Constructor] interface Point { attribute double x; attribute double y; }; dictionary PaintOptions { DOMString? fillPattern = "black"; DOMString? strokePattern = null; Point position; }; [Exposed=Window] interface GraphicsContext { void drawRectangle( double %width, double %height, optional PaintOptions %options ); };
この~IDLの~ES実装においては、随意の `PaintOptions^T 辞書 により, `Object^jt を渡すことができる: ◎ In an ECMAScript implementation of the IDL, an Object can be passed in for the optional PaintOptions dictionary:
/* `GraphicsContext^T の~instanceを取得する。 ◎ Get an instance of GraphicsContext. */ var %ctx = getGraphicsContext(); /* 矩形を描く。 ◎ Draw a rectangle. */ %ctx.drawRectangle( 300, 200, { fillPattern: "red", position: new Point(10, 10) } );
`fillPattern^M, `strokePattern^M とも`既定~値$diCが与えられているので、 `drawRectangle^M の定義においては[ それらが省略された場合でも所与の既定~値を持つ ]と見做すことができ,[ それらが`在さない$場合に取扱う方法についての明示的な言及 ]は不要になる。 ◎ Both fillPattern and strokePattern are given default values, so if they are omitted, the definition of drawRectangle can assume that they have the given default values and not include explicit wording to handle their non-presence.
2.7. 例外
`例外@ とは、~errorを表現する~objの型であり,実装により[ 投出される, または first ~class値として扱われる ]ものである。 ~Web~IDLでは,例外を定義することは許容されないが、代わりに 仕様が参照し,その演算, 属性, 等々の定義にて投出できるような,いくつもの定義済み例外がある。 ◎ An exception is a type of object that represents an error and which can be thrown or treated as a first class value by implementations. Web IDL does not allow exceptions to be defined, but instead has a number of pre-defined exceptions that specifications can reference and throw in their definition of operations, attributes, and so on.\
各 例外は、次のものを持つ:
- `~error名@
- `DOMString$T による,例外が表現する~errorの型
- `~message@(随意)
- ~errorの詳細を人が読める~~形で供する,~UAにより定義される値
仕様にて投出するために可用な例外には 2 つの種類がある。 まず、次のいずれかの型として識別される `単純例外@ : ◎ There are two kinds of exceptions available to be thrown from specifications. The first is a simple exception, which is identified by one of the following types:
- `EvalError@jE
- `RangeError@jE
- `ReferenceError@jE
- `TypeError@jE
- `URIError@jE
これらは、~ES`~error~obj$に対応する(ただし, `SyntaxError^jE, `Error$jt は除く — 順に ~ES構文解析器~用, 作者~用に予約されているので、~~意図的に除かれている)。 各 `単純例外$の意味は、~ES仕様における対応する~error~objに合致する。 ◎ These correspond to all of the ECMAScript error objects (apart from SyntaxError and Error, which are deliberately omitted as they are reserved for use by the ECMAScript parser and by authors, respectively). The meaning of each simple exception matches its corresponding error object in the ECMAScript specification.
もう一種の例外は `DOMException$T である — それは,歴史的に DOM にて定義された例外との互換性をとるための例外であり、名前と整数~code(後者は随意)を,~encapsulateする。 ◎ The second kind of exception is a DOMException, which is an exception that encapsulates a name and an optional integer code, for compatibility with historically defined exceptions in the DOM.
`単純例外$に対しては、`~error名$がその例外の型になる。 `DOMException$T の`~error名$は、後に示す`~error名~一覧$に挙げられている いずれかの名前で~MUST。 その一覧には、その~error名に対する `DOMException$T の整数~codeも(もし在れば)指示される。 ◎ For simple exceptions, the error name is the type of the exception. For a DOMException, the error name must be one of the names listed in the error names table below. The table also indicates the DOMException's integer code for that error name, if it has one.
例外~objを指すためには、 2 種の型 `DOMException$T, `Error$T を利用できる。 後者は、`単純例外$と `DOMException$T の両者を包摂する。 これにより、`演算$の`返値型$を `DOMException$T に宣言したり,`属性$の型を `Error$T 型にすることも可能になる。 ◎ There are two types that can be used to refer to exception objects: DOMException and Error, where the latter encompasses simple exceptions and DOMException. This allows for example an operation to be declared to have a DOMException return type or an attribute to be of type Error.
`例外を作成する@ よう記すときは、`単純例外$に対しては その`~error名$, `DOMException$T に対しては `~error名$に `DOMException$T も加えて表記する。 例外は、`例外を作成する$ために要求される詳細を供して `例外を投出する@ よう表記することもできる。 ◎ Simple exceptions can be created by providing their error name. A DOMException can be created by providing its error name followed by DOMException. Exceptions can also be thrown, by providing the same details required to create one.
例外を作成したり, 作成した例外を投出した結果の挙動は、言語束縛に特有になる。 ◎ The resulting behavior from creating and throwing an exception is language binding-specific.
注記: ~ES言語束縛の場合にどうなるかについては、 `es-creating-throwing-exceptions$sec を見よ。 ◎ Note: See §3.12.3 Creating and throwing exceptions for details on what creating and throwing an exception entails in the ECMAScript language binding.
例外を作成して投出する言い回しの用例をここに示す†。 名前 `TypeError^jE の新たな `単純例外$を投出するときは: ◎ Here is are some examples of wording to use to create and throw exceptions. To throw a new simple exception named TypeError:
Throw a `TypeError^jE.
`~error名$ `NotAllowedError$E の新たな `DOMException$T を投出するときは: ◎ To throw a new DOMException with error name "NotAllowedError":
Throw an "`NotAllowedError^E" `DOMException^T.
`~error名$ "`SyntaxError$E" の新たな `DOMException$T を作成するときは: ◎ To create a new DOMException with error name "SyntaxError":
Let %object be a newly created "`SyntaxError^E" `DOMException^T.
【† このサイトの和訳全般においては、次のように例外~名の引用符や “`DOMException^T” を省略して表記している:
- `~THROW$ `TypeError^jE
- `~THROW$ `NotAllowedError^E
- %object ~LET 新たな `SyntaxError^E 例外
投出-の表記は,`単純例外$も `DOMException$T も同じ表記になっているが、単純例外は一握りしかない上、これらが同じ名前を共有することも,まずないと考えられるので(詳細は、~SYMBOL_DEF_REFを~~参照されたし)。 】
2.7.1. ~error名
下の `~error名~一覧@ は、 `DOMException$T に許容されるすべての~error名, ~~説明, および 旧来の code 名とその値の一覧である。 ◎ The error names table below lists all the allowed error names for DOMException, a description, and legacy code values.
“非推奨” と記されている `DOMException$T 名は、旧来の目的~用に保たれてはいるが,利用しないことが奨励される。 ◎ The DOMException names marked as deprecated are kept for legacy purposes but their usage is discouraged.
注記: ここに挙げられていない~error名があれば、この仕様の冒頭に指示したように, ~bugを提出されるよう願う。 間もなく解消に向けて取組まれることになる。 Thanks! ◎ Note: If an error name is not listed here, please file a bug as indicated at the top of this specification and it will be addressed shortly. Thanks!
注記: ここに定義される `SyntaxError$E `DOMException$T 例外と ~ESの `SyntaxError$jE とを混同しないように。 前者は — 例えば選択子を構文解析するときなど — ~Web~APIにおける構文解析-時の~errorを報告するために利用される一方で、後者は~ES構文解析器~用に予約されている。 これをより一義化し易くするため、単に `SyntaxError$E を用いずに,常に[ "`SyntaxError$E" `DOMException$T ]と表記して `DOMException$T を指す方が好ましい。 【が,上述したように、他の~Web仕様の和訳では, `DOMException^T は省略している — ~ES `SyntaxError^jE は,それらの仕様には現れないので。】 `DOM$r ◎ Note: Don’t confuse the "SyntaxError" DOMException defined here with ECMAScript’s SyntaxError. "SyntaxError" DOMException is used to report parsing errors in web APIs, for example when parsing selectors, while the ECMAScript SyntaxError is reserved for the ECMAScript parser. To help disambiguate this further, always favor the "SyntaxError" DOMException notation over just using SyntaxError to refer to the DOMException. [DOM]
名前 ◎ Name | ~~説明 ◎ Description | 旧来の~code名(括弧内は数値) ◎ Legacy code name and value |
---|---|---|
`IndexSizeError@E | 非推奨。 `RangeError$jE を利用すること。 ◎ Deprecated. Use RangeError instead. | `INDEX_SIZE_ERR@Ec (1) |
`DOMStringSizeError@E | 非推奨。 `RangeError$jE を利用すること。 ◎ Deprecated. Use RangeError instead. | `DOMSTRING_SIZE_ERR@Ec (2) |
`HierarchyRequestError@E | 演算から不正な`~node木$が得られることになる。 `DOM$r ◎ The operation would yield an incorrect node tree. [DOM] | `HIERARCHY_REQUEST_ERR@Ec (3) |
`WrongDocumentError@E | ~objが属している`文書$は間違っている。 `DOM$r ◎ The object is in the wrong document. [DOM] | `WRONG_DOCUMENT_ERR@Ec (4) |
`InvalidCharacterError@E | 文字列に妥当でない文字が含まれている。 ◎ The string contains invalid characters. | `INVALID_CHARACTER_ERR@Ec (5) |
`NoDataAllowedError@E | 非推奨。 ◎ Deprecated. | `NO_DATA_ALLOWED_ERR@Ec (6) |
`NoModificationAllowedError@E | ~objは改変できない。 ◎ The object can not be modified. | `NO_MODIFICATION_ALLOWED_ERR@Ec (7) |
`NotFoundError@E | ~objは見出せなかった。 ◎ The object can not be found here. | `NOT_FOUND_ERR@Ec (8) |
`NotSupportedError@E | 演算は~supportされていない。 ◎ The operation is not supported. | `NOT_SUPPORTED_ERR@Ec (9) |
`InUseAttributeError@E | 属性は利用~中にある。 ◎ The attribute is in use. | `INUSE_ATTRIBUTE_ERR@Ec (10) |
`InvalidStateError@E | ~objは不正な状態にある。 ◎ The object is in an invalid state. | `INVALID_STATE_ERR@Ec (11) |
`SyntaxError@E | 文字列は期待される~patternに合致していない。 ◎ The string did not match the expected pattern. | `SYNTAX_ERR@Ec (12) |
`InvalidModificationError@E | ~objはこの仕方では改変できない。 ◎ The object can not be modified in this way. | `INVALID_MODIFICATION_ERR@Ec (13) |
`NamespaceError@E | 演算は Namespaces in XML において許容されない。 `XML-NAMES$r ◎ The operation is not allowed by Namespaces in XML. [XML-NAMES] | `NAMESPACE_ERR@Ec (14) |
`InvalidAccessError@E | 非推奨。 代わりに、[ 妥当でない引数に対しては `TypeError$jE / 未~supportの演算に対しては `NotSupportedError$E / 否認された要請に対しては `NotAllowedError$E ]を利用すること。 ◎ Deprecated. Use TypeError for invalid arguments, "NotSupportedError" DOMException for unsupported operations, and "NotAllowedError" DOMException for denied requests instead. | `INVALID_ACCESS_ERR@Ec (15) |
`ValidationError@E | 非推奨。 ◎ Deprecated. | `VALIDATION_ERR@Ec (16) |
`TypeMismatchError@E | 非推奨。 代わりに、 `TypeError$jE を利用すること。 ◎ Deprecated. Use TypeError instead. | `TYPE_MISMATCH_ERR@Ec (17) |
`SecurityError@E | 演算は保安的でない。 ◎ The operation is insecure. | `SECURITY_ERR@Ec (18) |
`NetworkError@E | ~network~errorが生じた。 ◎ A network error occurred. | `NETWORK_ERR@Ec (19) |
`AbortError@E | 演算は中止された。 ◎ The operation was aborted. | `ABORT_ERR@Ec (20) |
`URLMismatchError@E | 所与の URL は他方の URLに合致していない。 ◎ The given URL does not match another URL. | `URL_MISMATCH_ERR@Ec (21) |
`QuotaExceededError@E | quota の上限を超えた。 ◎ The quota has been exceeded. | `QUOTA_EXCEEDED_ERR@Ec (22) |
`TimeoutError@E | 演算は時間切れになった。 ◎ The operation timed out. | `TIMEOUT_ERR@Ec (23) |
`InvalidNodeTypeError@E | 給された~nodeは不正か, またはこの演算において不正な先祖を持つ。 ◎ The supplied node is incorrect or has an incorrect ancestor for this operation. | `INVALID_NODE_TYPE_ERR@Ec (24) |
`DataCloneError@E | ~objは~cloneできない。 ◎ The object can not be cloned. | `DATA_CLONE_ERR@Ec (25) |
`EncodingError@E | 符号化する演算に失敗した(符号化-時, 復号-時とも含め)。 ◎ The encoding operation (either encoded or decoding) failed. | — |
`NotReadableError@E | I/O 読み取り演算に失敗した。 ◎ The I/O read operation failed. | — |
`UnknownError@E | 未知の一時的な事由により,演算に失敗した(例:記憶域を使い果たした)。 ◎ The operation failed for an unknown transient reason (e.g. out of memory). | — |
`ConstraintError@E | ~transactionにおける変異~演算は、拘束を満たせないため,失敗した。 ◎ A mutation operation in a transaction failed because a constraint was not satisfied. | — |
`DataError@E | 供された~dataは、必要十分でない。 ◎ Provided data is inadequate. | — |
`TransactionInactiveError@E | 現在~作動中でない/すでに終わった ~transactionに対し,要請が行われた。 ◎ A request was placed against a transaction which is currently not active, or which is finished. | — |
`ReadOnlyError@E | “読み取り専用” ( `readonly^l ~mode)の~transactionにおいて,変異させようとする演算が試みられた。 ◎ The mutating operation was attempted in a "readonly" transaction. | — |
`VersionError@E | 既存の~versionより低い~versionを利用して~databaseを open しようとした。 ◎ An attempt was made to open a database using a lower version than the existing version. | — |
`OperationError@E | 演算に特有の事由により,演算に失敗した。 ◎ The operation failed for an operation-specific reason. | — |
`NotAllowedError@E | 要請された演算は、現在の文脈においては ~UA/~platform からは — 場合によっては,利用者が否認したことにより — 許容されない。 ◎ The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. | — |
2.8. 列挙
`列挙@ ( `enumeration^en )は、[ 妥当な値の集合が,定義済み文字列の集合になる ]ような型を宣言するために利用される,`定義$( `Enum$g に合致)である。 `属性$に代入できる/`演算$に渡せる `DOMString$T 値を制約する用途に,列挙を利用できる。 ◎ An enumeration is a definition (matching Enum) used to declare a type whose valid values are a set of predefined strings. Enumerations can be used to restrict the possible DOMString values that can be assigned to an attribute or passed to an operation.
enum `identifier^i { "enum", "values" /* , ... */ };
一連の `列挙~値@ は、 `string$g ~literalの~comma区切りの~listとして指定される。 `列挙~値$の~list内に重複が在っては~MUST_NOT。 ◎ The enumeration values are specified as a comma-separated list of string literals. The list of enumeration values must not include duplicates.
別の命名法を利用する理由が特にない限り、列挙~値は,すべて小文字にすることを強く勧める — 複数の単語は,~dashで区切るか全く区切らないことにして。 例えば、~objが作成されるべきであることを指示する列挙~値は, `createobject^l や `create-object^l などと命名することもできる。 列挙~値の単語を~dashで区切るかどうか決めるときは、類似の他の~APIと一貫するように,関係する列挙~値の利用を考慮すること。 ◎ It is strongly suggested that enumeration values be all lowercase, and that multiple words be separated using dashes or not be separated at all, unless there is a specific reason to use another value naming scheme. For example, an enumeration value that indicates an object should be created could be named "createobject" or "create-object". Consider related uses of enumeration values when deciding whether to dash-separate or not separate enumeration value words so that similar APIs are consistent.
妥当な列挙~値のいずれでもない文字列~値が,[ 列挙~型の`属性$に代入するときや, 列挙~型の`演算$に渡される引数 ]に利用されたときの挙動は、言語束縛に特有になる。 ◎ The behavior when a string value that is not one a valid enumeration value is used when assigning to an attribute, or passed as an operation argument, whose type is the enumeration, is language binding specific.
注記: ~ES言語束縛においては、`属性$への妥当でない文字列~値の代入は無視される一方,そのような値を`演算$の引数に渡したときには例外が投出される。 ◎ Note: In the ECMAScript binding, assignment of an invalid string value to an attribute is ignored, while passing such a value as an operation argument results in an exception being thrown.
`列挙$に適用-可能な`拡張属性$は、この仕様では定義されない。 ◎ No extended attributes defined in this specification are applicable to enumerations.
次の`~IDL片$は 1 個の`属性$と 1 個の`演算$引数の型として利用される `列挙$を定義する ◎ The following IDL fragment defines an enumeration that is used as the type of an attribute and an operation argument:
enum MealType { "米", "麺", "その他" };
[Exposed=Window]
interface Meal {
attribute MealType type;
attribute double size; /*
グラム~~単位
◎
in grams
*/
void initialize(MealType %type, double %size);
};
~ES実装は、 type ~propに代入され得る, あるいは `initialize^M 関数に渡され得る文字列を, `列挙$内にて識別されるものに制約することになる。 ◎ An ECMAScript implementation would restrict the strings that can be assigned to the type property or passed to the initializeMeal function to those identified in the enumeration.
var %meal = getMeal(); /* `Meal^T の~instanceを取得する。 ◎ Get an instance of Meal. */ %meal.initialize("米", 200); /* 演算は通常通り呼出される。 ◎ Operation invoked as normal. */ try { %meal.initialize("肉", 100); /* `TypeError^jE が投出される。 ◎ Throws a TypeError. */ } catch (%e) { } %meal.type = "麺"; /* 属性は通常通り代入される。 ◎ Attribute assigned as normal. */ %meal.type = "魚"; /* 属性~代入は無視される。 ◎ Attribute assignment ignored. */ %meal.type == "麺"; /* `true^jv に評価される。 ◎ Evaluates to true. */
2.9. 呼戻~関数
“Custom DOM Elements” 仕様からは、`呼戻~関数~型$を,~platform~objから供される関数に利用することが求められている。 “呼戻~関数” を,両方の目的に利用できることを明らかにするため、単に “関数” と改称するべきだろうか? ◎ The “Custom DOM Elements” spec wants to use callback function types for platform object provided functions. Should we rename “callback functions” to just “functions” to make it clear that they can be used for both purposes?
`呼戻~関数@ は、関数~型を宣言するときに利用される,`定義$( `callback^sym `CallbackRest$g に合致)である。 ◎ A callback function is a definition (matching callback CallbackRest) used to declare a function type.
callback `identifier^i = `return_type^i (/* arguments... */);
注記: 似た命名の`呼戻~ifc$も見よ。 ◎ Note: See also the similarly named callback interfaces.
等号の左側の`識別子$が `呼戻~関数$の名前を与える。 等号の右側の[ 返値型( `ReturnType$g に合致) と[ 引数~list( `ArgumentList$g に合致) 【による一連の型】 ]]が,`呼戻~関数~型$の~signatureを与える。 ◎ The identifier on the left of the equals sign gives the name of the callback function and the return type and argument list (matching ReturnType and ArgumentList) on the right side of the equals sign gives the signature of the callback function type.
`呼戻~関数$は `定数$の型に利用されては~MUST_NOT。 ◎ Callback functions must not be used as the type of a constant.
呼戻~関数に適用-可能な拡張属性は ⇒ `TreatNonObjectAsNull$x ◎ The following extended attribute is applicable to callback functions: [TreatNonObjectAsNull].
次の`~IDL片$は、演算の完了-時に利用者により定義される関数を呼出す~API用に利用される,`呼戻~関数$を定義する。 ◎ The following IDL fragment defines a callback function used for an API that invokes a user-defined function when an operation is complete.
callback AsyncOperationCallback = void (DOMString %status); [Exposed=Window] interface AsyncOperations { void performOperation(AsyncOperationCallback %whenFinished); };
~ES言語束縛においては、`関数~obj$は演算~引数として渡される。 ◎ In the ECMAScript language binding, a function object is passed as the operation argument.
var %ops = getAsyncOperations(); /*
`AsyncOperations^T の~instanceを取得する。
◎
Get an instance of AsyncOperations.
*/
%ops.performOperation(function(%status) {
window.alert("Operation finished, status is " + %status + ".");
});
2.10. ~typedef
`~typedef@ は、ある型に対し 新たな名前を宣言するために利用される,`定義$( `Typedef$g に合致)である。 この新たな名前は、言語束縛からは公開されない。 これはもっぱら,~IDLにおいて型を参照するための略記として利用される。 ◎ A typedef is a definition (matching Typedef) used to declare a new name for a type. This new name is not exposed by language bindings; it is purely used as a shorthand for referencing the type in the IDL.
typedef `type^i `identifier^i;
`新たな名前が与えられる型@ ( `TypeWithExtendedAttributes$g に合致)は, `typedef^c ~keywordの後に指定され、型に後続する `identifier$g ~tokenが,その新たな名前を与える。 ◎ The type being given a new name is specified after the typedef keyword (matching TypeWithExtendedAttributes), and the identifier token following the type gives the name.
`Type$g は、同じまたは別の`~typedef$の識別子にされては~MUST_NOT。 ◎ The Type must not be the identifier of the same or another typedef.
`~typedef$に適用-可能な`拡張属性$は、この仕様では定義されない。 ◎ No extended attributes defined in this specification are applicable to typedefs.
次の`~IDL片$は、`~typedef$を利用して,長い`連列~型$の代わりに短い`識別子$を使えるようしている。 ◎ The following IDL fragment demonstrates the use of typedefs to allow the use of a short identifier instead of a long sequence type.
[Exposed=Window] interface Point { attribute double x; attribute double y; }; typedef sequence<Point> Points; [Exposed=Window] interface Widget { boolean pointWithinBounds(Point %p); boolean allPointsWithinBounds(Points %ps); };
2.11. ~ifcを実装している~obj
一連の`~IDL片$が成す集合の実装においては、~objは,[ `~platform~obj$, `利用元~obj$, そのどちらでもないもの ]として述べられ得る。 ◎ In a given implementation of a set of IDL fragments, an object can be described as being a platform object, a user object, or neither.
`~platform~obj@ は、`呼戻~ifc$でない`~ifc$を実装する~objである。 ◎ Platform objects are objects that implement a non-callback interface.
`旧来の~platform~obj@ は、`~platform~obj$のうち,次を満たすものである ⇒[ `Global$x `拡張属性$を有さない`~ifc$を実装する ]~AND[[ `有index~propを~support$する ]~OR[ `有名~propを~support$する ]] ◎ Legacy platform objects are platform objects that implement an interface which does not have a [Global] extended attribute, and which supports indexed properties, named properties, or both.
~browserにおいては、例えば,[ ~page内で走らせている~ESに対し,~page内容への~accessを供する ]ために,~browserに実装されている( `Node^T や `Document^T などの~ifcを実装している) DOM ~objが、~platform~objになる。 これらの~objは、 C++ などの言語で実装される~exotic~objになるか, または~native~ES~objになるであろう。 いずれにせよ,所与の~IDL片の集合に対する実装は、[ 実装により作成されたすべての~platform~obj ]を認識できる必要がある。 これは、所与の~objに[ その~objが実装における~platform~objであるかどうかを記録するための,何らかの内部~状態 ]を~~実際に持たせるか、あるいは, おそらく,[ ~objが一定の内部 C++ ~classにより実装されているかどうか ]を見ることにより、実現できるであろう。 ~platform~objが,正確に どう実装から認識されるかについては、実装に特有になる。 ◎ In a browser, for example, the browser-implemented DOM objects (implementing interfaces such as Node and Document) that provide access to a web page’s contents to ECMAScript running in the page would be platform objects. These objects might be exotic objects, implemented in a language like C++, or they might be native ECMAScript objects. Regardless, an implementation of a given set of IDL fragments needs to be able to recognize all platform objects that are created by the implementation. This might be done by having some internal state that records whether a given object is indeed a platform object for that implementation, or perhaps by observing that the object is implemented by a given internal C++ class. How exactly platform objects are recognized by a given implementation of a set of IDL fragments is implementation specific.
~system内の他のすべての~objは、~platform~objとしては扱われないことになる。 例えば、~browserが開いた~Web~pageが, DOM Core を実装する~ES~libraryを読込んだとする。 この~libraryは、~browserが供する実装とは異なる実装と見なされることになる。 ~ES~libraryにより作成された[ `Node^T ~ifcを実装する~obj ]は、~browser実装による[ `Node^T を実装する~platform~obj ]としては扱われないことになる。 ◎ All other objects in the system would not be treated as platform objects. For example, assume that a web page opened in a browser loads an ECMAScript library that implements DOM Core. This library would be considered to be a different implementation from the browser provided implementation. The objects created by the ECMAScript library that implement the Node interface will not be treated as platform objects that implement Node by the browser implementation.
`利用元~obj@ とは、`呼戻~ifc$ — [ 作者により定義される演算を~Web~APIから呼出せるようにする,あるいは~Web~APIからの~objの属性~操作を通して, 作者の~programと値を受け~~渡せるようにする ]ための~ifc — を実装するものとして,作者が作成することになる~objである。 ~Web~pageにおいては、[ DOM Events 実装から呼出される呼戻を登録する際に利用される, `EventListener$T ~ifcを実装する~ES~obj ]は,利用元~objと見なされることになる。 ◎ User objects are those that authors would create, implementing callback interfaces that the Web APIs use to be able to invoke author-defined operations or to send and receive values to the author’s program through manipulating the object’s attributes. In a web page, an ECMAScript object that implements the EventListener interface, which is used to register a callback that the DOM Events implementation invokes, would be considered to be a user object.
`利用元~obj$が実装できるのは`呼戻~ifc$のみであり,`~platform~obj$が実装できるのは非~呼戻~ifcのみであることに注意。 ◎ Note that user objects can only implement callback interfaces and platform objects can only implement non-callback interfaces.
2.12. 型
この節では、~Web~IDLで~supportされる型, それぞれの型に対応する値の集合, その型の`定数$が どう表現されるか, について挙げていく。 ◎ This section lists the types supported by Web IDL, the set of values corresponding to each type, and how constants of that type are represented.
互いに類似する型の集合には、次のような総称が付与されている:
- `整数~型@
- `byte$T , `octet$T , `short$T , `unsigned short$T , `long$T , `unsigned long$T , `long long$T , `unsigned long long$T ◎ The following types are known as integer types: byte, octet, short, unsigned short, long, unsigned long, long long and unsigned long long.
- `実数~型@
- すべての`整数~型$ , `float$T , `unrestricted float$T , `double$T , `unrestricted double$T ◎ The following types are known as numeric types: the integer types, float, unrestricted float, double and unrestricted double.
- `~primitive型@
- `boolean$T , すべての`実数~型$ ◎ The primitive types are boolean and the numeric types.
- `文字列~型@
- `DOMString$T, すべての`列挙~型$ , `ByteString$T, `USVString$T ◎ The string types are DOMString, all enumeration types, ByteString and USVString.
- `例外~型@
- `Error$T, `DOMException$T ◎ The exception types are Error and DOMException.
- `有型~配列~型@
- `Int8Array$T, `Int16Array$T, `Int32Array$T, `Uint8Array$T, `Uint16Array$T, `Uint32Array$T, `Uint8ClampedArray$T, `Float32Array$T, `Float64Array$T ◎ The typed array types are Int8Array, Int16Array, Int32Array, Uint8Array, Uint16Array, Uint32Array, Uint8ClampedArray, Float32Array and Float64Array.
- `~buffer~source型@
- `ArrayBuffer$T, `DataView$T, すべての`有型~配列~型$ ◎ The buffer source types are ArrayBuffer, DataView, and the typed array types.
- `~obj型@
- `object$T 型, すべての `~ifc型$, すべての`例外~型$ ◎ The object type, all interface types and the exception types are known as object types.
どの型も, `型~名@ を持つ — それは、型を識別する文字列であり,一意になる必要はない。 以下の各~節では、各~型にあてがわれる型~名も定義する。 ◎ Every type has a type name, which is a string, not necessarily unique, that identifies the type. Each sub-section below defines what the type name is for each type.
`演算$の呼出しや`属性$に値を代入する際に必要とされる,言語束縛に特有の型から~IDL型への変換はすべて、[ 演算に指定された機能性や 属性~代入 ]が~~実行に移される前に遂行される。 変換が遂行できない場合、演算は走らされず, 属性は更新されないことになる。 一部の言語束縛では、この型~変換により,例外が投出され得る。 そのような場合、これらの例外は,演算の呼出しや属性への代入-を試みた~codeまで,伝播することになる。 ◎ When conversions are made from language binding specific types to IDL types in order to invoke an operation or assign a value to an attribute, all conversions necessary will be performed before the specified functionality of the operation or attribute assignment is carried out. If the conversion cannot be performed, then the operation will not run or the attribute will not be updated. In some language bindings, type conversions could result in an exception being thrown. In such cases, these exceptions will be propagated to the code that made the attempt to invoke the operation or assign to the attribute.
2.12.1. `any^T
`any$T 型は、 `共用体~型$ 以外の,アリなすべての型の和集合である。 その`型~名$は、 `Any^l である。 ◎ The any type is the union of all other possible non-union types. Its type name is "Any".
`any$T 型は、そのそれぞれの値ごとに特有の非 `any$T 型が結付けられる意味で,~~特別な共用体~型のようなものである。 例えば, `any$T 型のある値は `unsigned long$T 150 をとり得る一方、別の値は `long$T 150 をとり得る。 これらは別個の型の値になる。 ◎ The any type is like a discriminated union type, in that each of its values has a specific non-any type associated with it. For example, one value of the any type is the unsigned long 150, while another is the long 150. These are distinct values.
`any$T 型のある値を成す特定0の型は、その値の `特有~型@ と呼ばれる。 ( `共用体~型$の値も`特有~型$を持つ。) ◎ The particular type of an any value is known as its specific type. (Values of union types also have specific types.)
【 `any^T 型は、 `es-any$sec にも見られるように `null^V 値もとり得るようだが, “`~nullable$型である” ものと定義されてはいない。 】
2.12.2. `boolean^T
`boolean$T 型は 2 つの値: `true^V と `false^V をとり得る。 ◎ The boolean type has two values: true and false.
~IDLにおいては、 `boolean$T 定数~値は[ `true^c / `false^c ]~tokenで表現される。 ◎ boolean constant values in IDL are represented with the true and false tokens.
`boolean$T 型の`型~名$は、 `Boolean^l である。 ◎ The type name of the boolean type is "Boolean".
2.12.3〜10. 整数~型
【 この訳では、原文の 2.12.3 〜 2.12.10 節の内容 — 各種~IDL整数~型の定義を集約して,一括して与える。 】
各種 有符号/無符号 `整数~型$の,とり得る値の範囲, および `型~名$は、次の表で与えられる: ◎ The xxx ~LET (byte|short|long|long long/octet|unsigned short|unsigned long|unsigned long long) type is a (signed/unsigned) integer type that has values in the range ([−P÷2, P÷2 − 1]/[0, P − 1]); P ~LET 2^(8|16|32|64). ◎ xxx constant values in IDL are represented with integer tokens. ◎ The type name of the xxx type is "Xxx".
~IDL型 | 最小~値 | 最大~値 | 型~名 |
---|---|---|---|
`byte@T | −2`7^sup | 2`7^sup ~MINUS 1 | `Byte^l |
`octet@T | 0 | 2`8^sup ~MINUS 1 | `Octet^l |
`short@T | −2`15^sup | 2`15^sup ~MINUS 1 | `Short^l |
`unsigned short@T | 0 | 2`16^sup ~MINUS 1 | `UnsignedShort^l |
`long@T | −2`31^sup | 2`31^sup ~MINUS 1 | `Long^l |
`unsigned long@T | 0 | 2`32^sup ~MINUS 1 | `UnsignedLong^l |
`long long@T | −2`63^sup | 2`63^sup ~MINUS 1 | `LongLong^l |
`unsigned long long@T | 0 | 2`64^sup ~MINUS 1 | `UnsignedLongLong^l |
~IDLにおいては、どの`整数~型$の定数~値も, `integer$g ~tokenで表現される。
2.12.11〜14. 浮動小数点数~型
【 この訳では、原文の 2.12.11 〜 2.12.14 節の内容 — 各種~IDL浮動小数点数~型の定義を集約して,一括して与える。 】
各種 “浮動小数点数 型” — `整数~型$でない`実数~型$ — に対応する値の範囲, および それぞれの`型~名$は、次の表で与えられる:
~IDL型 | 値の範囲 `IEEE-754$r | 型~名 |
---|---|---|
`float@T | すべての有限[ 単精度 32 ~bit IEEE 754 浮動小数点数 ]の集合 ◎ The float type is a floating point numeric type that corresponds to the set of finite single-precision 32 bit IEEE 754 floating point numbers. [IEEE-754] | `Float^l |
`unrestricted float@T | アリなすべての有限, 非~有限[ 単精度 32 ~bit IEEE 754 浮動小数点数 ]の集合に “非数( `not a number^en )” ( 各種 NaN )を加えた集合 ◎ The unrestricted float type is a floating point numeric type that corresponds to the set of all possible single-precision 32 bit IEEE 754 floating point numbers, finite, non-finite, and special "not a number" values (NaNs). [IEEE-754] | `UnrestrictedFloat^l |
`double@T | すべての有限[ 倍精度 64 ~bit IEEE 754 浮動小数点数 ]の集合 ◎ The double type is a floating point numeric type that corresponds to the set of finite double-precision 64 bit IEEE 754 floating point numbers. [IEEE-754] | `Double^l |
`unrestricted double@T | アリなすべての有限, 非~有限[ 倍精度 64 ~bit IEEE 754 浮動小数点数 ]の集合に “非数( `not a number^en )” ( 各種 NaN )を加えた集合 ◎ The unrestricted double type is a floating point numeric type that corresponds to the set of all possible double-precision 64 bit IEEE 754 floating point numbers, finite, non-finite, and special "not a number" values (NaNs). [IEEE-754] | `UnrestrictedDouble^l |
~IDLにおいては、どの浮動小数点数 型の定数~値も, `float$g ~tokenで表現される。 ◎ The type name of the( xxx)? yyy type is “(Xxx)Yyy”.
特に 32 ~bit浮動小数点~型を利用する理由が無い限り,仕様は `float$T でなく,`double$T を利用するべきである。 `double$T が表現できる値~集合は,より近く~ES `Number^jt に合致するので。 ◎ Unless there are specific reasons to use a 32 bit floating point type, specifications should use double rather than float, since the set of values that a double can represent more closely matches an ECMAScript Number.
2.12.15. `DOMString^T
`DOMString$T 型は、アリなすべての[ `符号単位$の並び ]の集合に対応する。 そのような並びは、共通的に,~UTF-16に符号化された文字列 `RFC2781$r として解釈されるが、要求されてはいない。 `DOMString$T は DOM Level 3 Core §The DOMString Type において[ OMG IDL boxed `sequence<unsigned short>^T valuetype ]として定義されているが、この文書は,文字列が要求される様々な状況における,その連列~型に対する特別な場合分けを避けるため、 `DOMString$T を内在的な型として定義する。 ◎ The DOMString type corresponds to the set of all possible sequences of code units. Such sequences are commonly interpreted as UTF-16 encoded strings [RFC2781] although this is not required. While DOMString is defined to be an OMG IDL boxed sequence<unsigned short> valuetype in DOM Level 3 Core §The DOMString Type, this document defines DOMString to be an intrinsic type so as to avoid special casing that sequence type in various situations where a string is required.
注記:
`null^V は `DOMString$T の値ではないことにも注意。
~IDLにおいて `null^V を許容するためには,
DOMString?
と記される
`~nullable$
`DOMString$T
を利用する必要がある。
◎
Note: Note also that null is not a value of type DOMString. To allow null, a nullable DOMString, written as DOMString? in IDL, needs to be used.
この仕様においては、 `DOMString$T 値が妥当な~UTF-16文字列であることは要求されない — 例えば、対を成さない~surrogate(代用対( `surrogate pair^en )を成し得る符号単位)も含み得る。 しかしながら,~Web~IDLを利用する仕様の策定者は、所与の[ 特定0の`符号単位$列 ]から `~Unicode~scalar値$列を得たいと求めることもあろう。 ◎ Nothing in this specification requires a DOMString value to be a valid UTF-16 string. For example, a DOMString value might include unmatched surrogate pair characters. However, authors of specifications using Web IDL might want to obtain a sequence of Unicode scalar values given a particular sequence of code units.
次の~algoが、所与の ( `DOMString$T 値 %S ) を `~Unicode~scalar値~列に変換-@ する仕方を定義する: ◎ The following algorithm defines a way to convert a DOMString to a sequence of Unicode scalar values:
- %n ~LET %S の長さ ◎ Let S be the DOMString value. ◎ Let n be the length of S.
- %i ~LET 0 ◎ Initialize i to 0.
- %U ~LET ~Unicode文字の空~連列 ◎ Initialize U to be an empty sequence of Unicode characters.
- %置換~文字 ~LET `FFFD^U REPLACEMENT CHARACTER ◎ ↓
-
~WHILE %i ~LT %n : ◎ While i < n:
- %c ~LET %S 内で~index %i に位置する`符号単位$ ◎ Let c be the code unit in S at index i.
-
%c の値に応じて: ◎ Depending on the value of c:
- %c ~LT `D800^X
- %c ~GT `DFFF^X
-
%U に符号位置 %c の~Unicode文字を付加する ◎ Append to U the Unicode character with code point c.
- `DC00^X ~LTE %c ~LTE `DFFF^X
-
%U に %置換~文字 を付加する ◎ Append to U a U+FFFD REPLACEMENT CHARACTER.
- `D800^X ~LTE %c ~LTE `DBFF^X
-
- ~IF[ %i ~PLUS 1 ~GTE %n ] ⇒ %U に %置換~文字 を付加する ◎ If i = n−1, then append to U a U+FFFD REPLACEMENT CHARACTER.
-
~ELSE : ◎ Otherwise, i < n−1:
- %d ~LET %S 内の~index %i ~PLUS 1 に位置する`符号単位$ ◎ Let d be the code unit in S at index i+1.
-
~IF[ `DC00^X ~LTE %d ~LTE `DFFF^X ]: ◎ If 0xDC00 ≤ d ≤ 0xDFFF, then:
- %U に符号位置[ 2`16^sup ~PLUS 2`10^sup ~MUL ( %c & `3FF^X ) ~PLUS ( %d & `3FF^X ) ]の~Unicode文字を付加する ◎ Let a be c & 0x3FF. ◎ Let b be d & 0x3FF. ◎ Append to U the Unicode character with code point 2^16 + 2^10 a+b.
- %i ~INCBY 1 ◎ Set i to i+1.
- ~ELSE ⇒ %U に %置換~文字 を付加する ◎ Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a U+FFFD REPLACEMENT CHARACTER.
- %i ~INCBY 1 ◎ Set i to i+1.
- ~RET %U ◎ Return U.
~IDLにおいて,定数 `DOMString$T 値を表現する仕方は、ない。 `string$g ~literalを利用して, `DOMString$T 型の[ `辞書~mb$ / 演算の`随意~引数$ ]に既定~値を指定することはできる。 ◎ There is no way to represent a constant DOMString value in IDL, although DOMString dictionary member and operation optional argument default values can be specified using a string literal.
`DOMString$T 型の`型~名$は、 `String^l である。 ◎ The type name of the DOMString type is "String".
2.12.16. `ByteString^T
`ByteString$T 型は、アリなすべての[ byte の並び ]の集合に対応する。 その種の並びは、要求されてはいないが,[ ~UTF-8に符号化された文字列 `RFC3629$r, あるいは[ 他の何らかの[ 1 符号単位あたり 8 ~bit ]になる符号化法 ]により符号化された文字列 ]に解釈し得る。 ◎ The ByteString type corresponds to the set of all possible sequences of bytes. Such sequences might be interpreted as UTF-8 encoded strings [RFC3629] or strings in some other 8-bit-per-code-unit encoding, although this is not required.
~IDLにおいて,定数 `ByteString$T 値を表現する仕方は、ない。 `string$g ~literalを利用して, `ByteString$T 型の[ `辞書~mb$ / 演算の`随意~引数$ ]に既定~値を指定することはできる。 ◎ There is no way to represent a constant ByteString value in IDL, although ByteString dictionary member and operation optional argument default values can be specified using a string literal.
`ByteString$T 型の`型~名$は、 `ByteString^l である。 ◎ The type name of the ByteString type is "ByteString".
仕様は、[ HTTP などの,~byteや文字列を交換-可能に利用する~protocol ]を~ifc化するときに限り, `ByteString$T を利用するべきである。 一般に、文字列は,その値が[ 常に ASCII または 何らかの 8 ~bit文字~符号化法 ]になることが期待されているとしても, `DOMString$T 値により表現されるべきである。 8 ~bit~dataを保持するためには、 `ByteString$T ではなく,[ `octet$T または `byte$T ]を要素とする[ `連列~型$ / `凍結~配列~型$ / `Uint8Array$T / `Int8Array$T ]が利用されるべきである。 ◎ Specifications should only use ByteString for interfacing with protocols that use bytes and strings interchangeably, such as HTTP. In general, strings should be represented with DOMString values, even if it is expected that values of the string will always be in ASCII or some 8 bit character encoding. Sequences or frozen arrays with octet or byte elements, Uint8Array, or Int8Array should be used for holding 8 bit data rather than ByteString.
2.12.17. `USVString^T
`USVString$T 型は、アリなすべての[[ `~Unicode~scalar値$ — ~surrogate符号位置でない~Unicode符号位置 ]の並び ]の集合に対応する。 ◎ The USVString type corresponds to the set of all possible sequences of Unicode scalar values, which are all of the Unicode code points apart from the surrogate code points.
~IDLにおいて,定数 `USVString$T 値を表現する仕方は、ない。 `string$g ~literalを利用して, `USVString$T 型の[ `辞書~mb$ / 演算の`随意~引数$ ]に既定~値を指定することはできる。 ◎ There is no way to represent a constant USVString value in IDL, although USVString dictionary member and operation optional argument default values can be specified using a string literal.
`USVString$T 型の`型~名$は、 `USVString^l である。 ◎ The type name of the USVString type is "USVString".
仕様は、[ ~text処理を遂行する際に `~Unicode~scalar値$による文字列~演算が必要になる ]ときに限り, `USVString$T を~APIに利用するべきである。 文字列を利用する ほとんどの~APIは、文字列~内の`符号単位$に いかなる解釈も行わない `DOMString$T を利用するべきである。 疑わしい場合は `DOMString$T を利用すること。 ◎ Specifications should only use USVString for APIs that perform text processing and need a string of Unicode scalar values to operate on. Most APIs that use strings should instead be using DOMString, which does not make any interpretations of the code units in the string. When in doubt, use DOMString.
2.12.18. `object^T
`object$T 型は、アリなすべての[ 非 `null^V ~obj参照 ]の集合に対応する。 ◎ The object type corresponds to the set of all possible non-null object references.
~IDLにおいて,定数 `object$T 値を表現する仕方は、ない。 ◎ There is no way to represent a constant object value in IDL.
アリなすべての~obj参照に加えて, `null^V 値も内包する型を表すためには、 `~nullable型$ `object?^T を利用する。 ◎ To denote a type that includes all possible object references plus the null value, use the nullable type object?.
`object$T 型の`型~名$は、 `Object^l である。 ◎ The type name of the object type is "Object".
2.12.19. `symbol^T
`symbol$T 型は、アリなすべての~symbol値の集合に対応する。 ~symbol値は、不透明かつ `object$T でない値であるが,同一性( `identity^en )は備える(すなわち、自身のみに等しい)。 ◎ The symbol type corresponds to the set of all possible symbol values. Symbol values are opaque, non-object values which nevertheless have identity (i.e., are only equal to themselves).
~IDLにおいて,定数 `symbol$T 値を表現する仕方は、ない。 ◎ There is no way to represent a constant symbol value in IDL.
`symbol$T 型の`型~名$は、 `Symbol^l である。 ◎ The type name of the symbol type is "Symbol".
2.12.20. ~ifc型
`~ifc$を識別する`識別子$は、その~ifcを実装する,アリなすべての[ 非 `null^V ~obj参照の集合 ]に対応する型を指すために利用される。 ◎ An identifier that identifies an interface is used to refer to a type that corresponds to the set of all possible non-null references to objects that implement that interface.
非~呼戻~ifcに対しては、~ifc型の~IDL値は,単に~obj参照により表現される。 `呼戻~ifc$ に対しては、~ifc型の~IDL値は[ ~obj参照, `呼戻~文脈$ ]の組により表現される。 `呼戻~文脈@ とは、言語束縛に特有の値であり、[ 言語束縛に特有の~obj参照が~IDL値に変換される時点における,実行~文脈についての情報 ]を格納するために利用されるものである。 ◎ For non-callback interfaces, an IDL value of the interface type is represented just by an object reference. For callback interfaces, an IDL value of the interface type is represented by a tuple of an object reference and a callback context. The callback context is a language binding specific value, and is used to store information about the execution context at the time the language binding specific object reference is converted to an IDL value.
注記: ~ES~objに対しては、`呼戻~文脈$は, `Object^jt 値が~IDL呼戻~ifc型の値に変換される時点の `現任の設定群~obj$への参照を保持するために利用される。 `es-interface$sec を見よ。 ◎ Note: For ECMAScript objects, the callback context is used to hold a reference to the incumbent settings object at the time the Object value is converted to an IDL callback interface type value. See §3.2.14 Interface types.
~IDLにおいて,特定0の~ifc型の定数~obj参照~値を表現する仕方は、ない。 ◎ There is no way to represent a constant object reference value for a particular interface type in IDL.
[ 所与の~ifcを実装する アリなすべての~obj参照に加え, `null^V 値も内包する ]ような型を表すためには、`~nullable型$を利用する。 ◎ To denote a type that includes all possible references to objects implementing the given interface plus the null value, use a nullable type.
~ifc型の`型~名$は、その~ifcの`識別子$である。 ◎ The type name of an interface type is the identifier of the interface.
2.12.21. 辞書~型
`辞書$を識別する`識別子$は、[ 辞書~定義に~~寄与する,すべての辞書の集合 ]に対応する型を指すために利用される。 ◎ An identifier that identifies a dictionary is used to refer to a type that corresponds to the set of all dictionaries that adhere to the dictionary definition.
`有順序~map$用の~literal構文も,辞書を表現するために利用できる — その文脈から、暗黙的に[ 当の~mapが,特定の辞書~型の~instanceとして扱われる ]ものと解されるならば。 しかしながら、~IDL片の内側では,定数~辞書~値を表現する仕方は、ない。 ◎ The literal syntax for ordered maps may also be used to represent dictionaries, when it is implicitly understood from context that the map is being treated as an instance of a specific dictionary type. However, there is no way to represent a constant dictionary value inside IDL fragments.
辞書~型の`型~名$は、その辞書の`識別子$である。 ◎ The type name of a dictionary type is the identifier of the dictionary.
2.12.22. 列挙~型
`列挙$を識別する`識別子$は、[ その`列挙~値$に属する文字列( `DOMString$T と同様の,`符号単位$の並び)の集合 ]を値にとる型を指すために利用される。 ◎ An identifier that identifies an enumeration is used to refer to a type whose values are the set of strings (sequences of code units, as with DOMString) that are the enumeration’s values.
`DOMString$T と同様に、 ~IDLにおいて,定数`列挙$値を表現する仕方は、ない。 `string$g ~literalを利用して、列挙~型にされた`辞書~mb$に `既定~値$diCを指定することはできる。 ◎ Like DOMString, there is no way to represent a constant enumeration value in IDL, although enumeration-typed dictionary member default values can be specified using a string literal.
列挙~型の`型~名$は、その列挙の`識別子$である。 ◎ The type name of an enumeration type is the identifier of the enumeration.
2.12.23. 呼戻~関数~型
`呼戻~関数$を識別する`識別子$は、[ 所与の~signatureを伴う関数~objへの参照 ]を値にとる型を指すために利用される。 ◎ An identifier that identifies a callback function is used to refer to a type whose values are references to objects that are functions with the given signature.
呼戻~関数~型の~IDL値は,[ ~obj参照, `呼戻~文脈$ ]の組により表現される。 ◎ An IDL value of the callback function type is represented by a tuple of an object reference and a callback context.
注記: `~ifc型$と同様に、`呼戻~文脈$は, ~ES `Object^jt 値が~IDL呼戻~ifc型の値に変換される時点の `現任の設定群~obj$への参照を保持するために利用される。 `es-callback-function$sec を見よ。 ◎ Note: As with callback interface types, the callback context is used to hold a reference to the incumbent settings object at the time an ECMAScript Object value is converted to an IDL callback function type value. See §3.2.17 Callback function types.
~IDLにおいて,定数 `呼戻~関数$値を表現する仕方は、ない。 ◎ There is no way to represent a constant callback function value in IDL.
呼戻~関数~型の`型~名$は、その呼戻~関数の`識別子$である。 ◎ The type name of a callback function type is the identifier of the callback function.
2.12.24. ~nullable型 — `~varT?^T
`~nullable型@ は、(その `内縁~型@ と呼ばれる)既存の型から構築される~IDL型であり、とり得る値の集合は,内縁~型がとり得る値に値 `null^V のみを~~追加したものになる。 ~IDLにおいては、`~nullable型$は,既存の型の後に文字 `003F^U1 を置いて表現される。 `内縁~型$は次のいずれであっても~MUST_NOT: ◎ A nullable type is an IDL type constructed from an existing type (called the inner type), which just allows the additional value null to be a member of its set of values. Nullable types are represented in IDL by placing a U+003F QUESTION MARK ("?") character after an existing type. The inner type must not be:
- `any$T 型
- `~promise型$
- 別の~nullable型
- `共用体~型$であって[ それ自身が`~nullable型を内包する$, または その`平坦化~mb型$に`辞書~型$が含まれている ]もの。
注記: 辞書~型は,一般には~nullableになれるが、その場合,演算~引数や辞書~mbの型には利用できない。 ◎ Note: Although dictionary types can in general be nullable, they cannot when used as the type of an operation argument or a dictionary member.
~IDLにおいては、~nullable型の定数~値は,その`内縁~型$の定数~値と同じ仕方で表現されるか, または `null^c ~tokenで表現される。 ◎ Nullable type constant values in IDL are represented in the same way that constant values of their inner type would be represented, or with the null token.
~nullable型の`型~名$は、次の連結とする ⇒# その`内縁~型$ %T の型~名, 文字列 `OrNull^l ◎ The type name of a nullable type is the concatenation of the type name of the inner type T and the string "OrNull".
例えば、値 `true^V, `false^V, `null^V をとり得る型は, `boolean?^T と記される: ◎ For example, a type that allows the values true, false and null is written as boolean?:
[Exposed=Window] interface NetworkFetcher { void get(optional boolean? areWeThereYet = false); };
次の`~ifc$は 2 個の`属性$を持つ。 一方は `DOMString$T または `null^V 値を値にとり得る。 他方は `Node^T ~objへの参照または `null^V 値を値にとり得る: ◎ The following interface has two attributes: one whose value can be a DOMString or the null value, and another whose value can be a reference to a Node object or the null value:
[Exposed=Window] interface Node { readonly attribute DOMString? namespaceURI; readonly attribute Node? parentNode; /* */ };
2.12.25. 連列~型 — ~sequence_T
`連列~型@ — ~sequence_T — は、[ 一連の[ 型 %T の値 ]からなる`~list$(長さ 0 にもなり得る) ]を値にとり得るような,~parameter化された型である。 ◎ The sequence<T> type is a parameterized type whose values are (possibly zero-length) lists of values of type T.
連列は常に値渡しである。 連列が何らかの種類の~objで表現される言語束縛においても、`~platform~obj$に連列が渡された際に,その連列への参照が~objに保有されることはない。 同様に,~platform~objから返されるどの連列も複製であり、それに対する改変は~platform~objからは可視にならないことになる。 ◎ Sequences are always passed by value. In language bindings where a sequence is represented by an object of some kind, passing a sequence to a platform object will not result in a reference to the sequence being kept by that object. Similarly, any sequence returned from a platform object will be a copy and modifications made to it will not be visible to the platform object.
`~list$用の~literal構文も,連列を表現するために利用できる — その文脈から、暗黙的に[ 当の~listが,ある連列の~instanceとして扱われる ]ものと解されるならば。 しかしながら、~IDL片の内側では,定数~連列~値を表現する仕方は、ない。 ◎ The literal syntax for lists may also be used to represent sequences, when it is implicitly understood from context that the list is being treated as a sequences. However, there is no way to represent a constant sequence value inside IDL fragments.
連列は[ `属性$/`定数$ ]の型に利用されては~MUST_NOT。 ◎ Sequences must not be used as the type of an attribute or constant.
注記: この制約は、[ `連列~型$は、その参照が渡し回されるものではなく,複製されるものである ]ことを,仕様の[ 策定者/利用者 ]から見て明らかにするためにある。 連列~型の~writableな`属性$には、代わりに,連列を取得-/設定する`演算$~pairの利用を勧める。 ◎ Note: This restriction exists so that it is clear to specification writers and API users that sequences are copied rather than having references to them passed around. Instead of a writable attribute of a sequence type, it is suggested that a pair of operations to get and set the sequence is used.
連列~型の`型~名$は、次の連結とする ⇒# %T の型~名, 文字列 `Sequence^l ◎ The type name of a sequence type is the concatenation of the type name for T and the string "Sequence".
どの`~list$であれ、そのどの`~item$の型も %T である限り,暗黙的に ~sequence_T として扱える。 ◎ Any list can be implicitly treated as a sequence<T>, as long as it contains only items that are of type T.
2.12.26. ~record型 — ~record_KV
`~record型@ — ~record_KV — は、`有順序~map$であって,その各`~entry$の[ `~key$は型 %K の ある~instance, `値$は型 %V の ある~instance ]であるような,~parameter化された型である。 %K は[ `DOMString$T / `USVString$T / `ByteString$T ]でなければ~MUST。 ◎ A record type is a parameterized type whose values are ordered maps with keys that are instances of K and values that are instances of V. K must be one of DOMString, USVString, or ByteString.
`有順序~map$用の~literal構文も,~recordを表現するために利用できる — その文脈から、暗黙的に[ 当の~mapが,~record型の~instanceとして扱われる ]ものと解されるならば。 しかしながら、~IDL片の内側では,定数~record値を表現する仕方は、ない。 ◎ The literal syntax for ordered maps may also be used to represent records, when it is implicitly understood from context that the map is being treated as a record. However, there is no way to represent a constant record value inside IDL fragments.
~recordは常に値渡しである。 ~recordが何らかの種類の~objで表現される言語束縛においても、`~platform~obj$に~recordが渡された際に,その~recordへの参照が~objに保有されることはない。 同様に,~platform~objから返されるどの~recordも複製であり、それに対する改変は~platform~objからは可視にならないことになる。 ◎ Records are always passed by value. In language bindings where a record is represented by an object of some kind, passing a record to a platform object will not result in a reference to the record being kept by that object. Similarly, any record returned from a platform object will be a copy and modifications made to it will not be visible to the platform object.
~recordは[ `属性$/`定数$ ]の型に利用されては~MUST_NOT。 ◎ Records must not be used as the type of an attribute or constant.
~record型の`型~名$は、次の連結とする ⇒# %K の型~名, %V の型~名, 文字列 `Record^l ◎ The type name of a record type is the concatenation of the type name for K, the type name for V and the string "Record".
どの`有順序~map$であれ、そのどの`~entry$も,その[ `~key$の型は %K, `値$の型は %V ]である限り,暗黙的に ~record_KV として扱える。 ◎ Any ordered map can be implicitly treated as a record<K, V>, as long as it contains only entries whose keys are all of of type K and whose values are all of type V.
2.12.27. ~promise型 — ~promise_T
`~promise型@ — ~promise_T — は、[[[[ “[[ 非同期 演算において,先送りされ得る(非同期にもなり得る)計算 ]の最終的な結果† ]の置き場( `place holder^en )” `ECMA-262$r ]として利用される~obj ]への参照 ]を値にとる ]ような,~parameter化された型である。 【† %T が,充足-時における結果の値の型を与える。】 ~promise~objの意味論についての詳細は~ES仕様 25.4 節 を見よ。 ◎ A promise type is a parameterized type whose values are references to objects that “is used as a place holder for the eventual results of a deferred (and possibly asynchronous) computation result of an asynchronous operation”. See section 25.4 of the ECMAScript specification for details on the semantics of promise objects.
~promise型は~nullableでないが、 %T は~nullableにもなり得る。 ◎ Promise types are non-nullable, but T may be nullable.
~IDLにおいて,~promise値を表現する仕方は、ない。 ◎ There is no way to represent a promise value in IDL.
~promise型の`型~名$は、次の連結とする ⇒# %T の型~名, 文字列 `Promise^l ◎ The type name of a promise type is the concatenation of the type name for T and the string "Promise".
2.12.28. 共用体~型
`共用体~型@ ( `union^en )は、とり得る値の集合が[ 複数の型の,それぞれがとり得る値の集合 ]の和集合であるような,型である。 共用体~型( `UnionType$g に合致)は、 `or^c ~keywordで区切られた型の並びを左右~丸括弧で括って記される。 共用体~型を構成する型は、共用体の `~mb型@ と呼ばれる。 ◎ A union type is a type whose set of values is the union of those in two or more other types. Union types (matching UnionType) are written as a series of types separated by the or keyword with a set of surrounding parentheses. The types which comprise the union type are known as the union’s member types.
例えば, `(Node or DOMString)^c や `(double or sequence<double>)^c などのように記す。 `共用体~型$に全体として `?^c 接尾辞を適用するときは, `(Node or DOMString)?^c のように,右~丸括弧の後に置く。 ◎ For example, you might write (Node or DOMString) or (double or sequence<double>). When applying a ? suffix to a union type as a whole, it is placed after the closing parenthesis, as in (Node or DOMString)?.
共用体~型の`~mb型$は、入子にされた共用体~型にまでは掘り下げられないことに注意。 したがって, `(double or (sequence<long> or Event) or (Node or DOMString)?)^T の~mb型は、 `double^T , `(sequence<long> or Event)^T , `(Node or DOMString)?^T になる。 ◎ Note that the member types of a union type do not descend into nested union types. So for (double or (sequence<long> or Event) or (Node or DOMString)?) the member types are double, (sequence<long> or Event) and (Node or DOMString)?.
`any$T 型と同様、共用体~型の値は,その値に合致する特定0の`~mb型$を`特有~型$として持つ。 ◎ Like the any type, values of union types have a specific type, which is the particular member type that matches the value.
`共用体~型$ %T — `注釈付きの型$にもなり得る — の `平坦化~mb型@ とは、次の手続きで決定される型の集合である: ◎ The flattened member types of a union type, possibly annotated, is a set of types determined as follows:
- %S ~LET 空~集合 ◎ Let T be the union type. ◎ Initialize S to ∅.
-
%T 内の ~EACH( `~mb型$ %U ) に対し: ◎ For each member type U of T:
- %U ~SET %U の`最内縁の型$ ◎ If U is an annotated type, then set U to be the inner type of U. ◎ If U is a nullable type, then set U to be the inner type of U.
- ~IF[ %U は `共用体~型$である ] ⇒ %U の`平坦化~mb型$に属するすべての型を %S に追加する ◎ If U is a union type, then add to S the flattened member types of U.
- ~ELSE ⇒ %U を %S に追加する ◎ Otherwise, U is not a union type. Add U to S.
- ~RET %S ◎ Return S.
注記: 例えば,`共用体~型$ `(Node or (sequence<long> or Event) or (XMLHttpRequest or DOMString)? or sequence<(sequence<double> or NodeList)>)^T の`平坦化~mb型$は、 6 つの型[ `Node^T , `sequence<long>^T , `Event^T , `XMLHttpRequest^T , `DOMString^T , `sequence<(sequence<double> or NodeList)>^T ]からなる。 ◎ Note: For example, the flattened member types of the union type (Node or (sequence<long> or Event) or (XMLHttpRequest or DOMString)? or sequence<(sequence<double> or NodeList)>) are the six types Node, sequence<long>, Event, XMLHttpRequest, DOMString and sequence<(sequence<double> or NodeList)>.
`共用体~型$ %T の `~nullable~mb型の個数@ とは、次の手続きで決定される整数である: ◎ The number of nullable member types of a union type is an integer determined as follows:
- %n ~LET 0 ◎ Let T be the union type. ◎ Initialize n to 0.
-
-
~IF[ %U は `~nullable型$である ]: ◎ If U is a nullable type, then:
- %n ~INCBY 1 ◎ Set n to n + 1.
- %U ~SET %U の`内縁~型$ ◎ Set U to be the inner type of U.
-
~IF[ %U は `共用体~型$である ]: ◎ If U is a union type, then:
- %m ~LET %U の`~nullable~mb型の個数$ ◎ Let m be the number of nullable member types of U.
- %n ~INCBY %m ◎ Set n to n + m.
-
- ~RET %n ◎ Return n.
`~mb型$に `any$T 型が利用されては~MUST_NOT。 ◎ The any type must not be used as a union member type.
`共用体~型$の`~nullable~mb型の個数$は 0 か 1 で~MUST。 1 の場合、その共用体~型は`平坦化~mb型$に`辞書~型$を含んでは~MUST_NOT。 ◎ The number of nullable member types of a union type must be 0 or 1, and if it is 1 then the union type must also not have a dictionary type in its flattened member types.
次のいずれかを満たす型は `~nullable型を内包する@ とされる。 ◎ A type includes a nullable type if:
- `~nullable型$である ◎ the type is a nullable type, or
- [ `注釈付きの型$である ]~AND[ その`内縁~型$anOは`~nullable型$である ] ◎ the type is an annotated type and its inner type is a nullable type, or
- [ `共用体~型$である ]~AND[ その `~nullable~mb型の個数$は 0 でない( 1 である) ] ◎ the type is a union type and its number of nullable member types is 1.
【 概念的には, `null^V を値にとり得る型と考えられる。 ただし、この定義では `any$T 型は含まれないことになる。 】
`共用体~型$の`平坦化~mb型$に属する どの 2 つの型も`判別-可能$で~MUST。 ◎ Each pair of flattened member types in a union type, T and U, must be distinguishable.
~IDLにおいては、`共用体~型$の定数~値は,それらの`~mb型$の定数~値と同じ仕方で表現される。 ◎ Union type constant values in IDL are represented in the same way that constant values of their member types would be represented.
共用体~型の`型~名$は、その各~mb型の型~名を 文字列 `Or^l で区切って順に連結した結果とする。 ◎ The type name of a union type is formed by taking the type names of each member type, in order, and joining them with the string "Or".
2.12.29. 注釈付きの型
既存の型に ある種の`拡張属性$を指定することにより,追加の型を作成できる。 そのような型は `注釈付きの型@ と呼ばれ、注釈された~~元の型は その `内縁~型@anO と呼ばれる。 ◎ Additional types can be created from existing ones by specifying certain extended attributes on the existing types. Such types are called annotated types, and the types they annotate are called inner types.
`[Clamp] long^c は、新たな`注釈付きの型$を定義する — その挙動は`内縁~型$anO `long$T に基づくが, `Clamp$x 拡張属性に指定されるように改変される。 ◎ [Clamp] long defines a new annotated type, whose behavior is based on that of the inner type long, but modified as specified by the [Clamp] extended attribute.
次のものが `型に適用でき@ る拡張属性とされる: `Clamp$x, `EnforceRange$x, `TreatNullAs$x ◎ The following extended attributes are applicable to types: [Clamp], [EnforceRange], and [TreatNullAs].
所与の~IDL型 %型 に `結付けられている拡張属性@ は、次に従って決定される: ◎ The extended attributes associated with an IDL type type are determined as follows:
- %拡張属性~集合 ~LET 新たな空`集合$ ◎ Let extended attributes be a new empty set.
-
~IF[ %型 は `TypeWithExtendedAttributes$g 生成規則 %P の一部として現れている ] ⇒ %P の中の `ExtendedAttributeList$g 内に在する ~EACH( `拡張属性$ %X ) に対し ⇒ %拡張属性~集合 に %X を`付加する$set ◎ If type appears as part of a TypeWithExtendedAttributes production, append each of the extended attributes present in the production’s ExtendedAttributeList to extended attributes.
[Exposed=Window] interface I { attribute [XAttr] long attrib; void f1(sequence<[XAttr] long> %arg); void f2(optional [XAttr] long %arg); maplike<[XAttr2] DOMString, [XAttr3] long>; }; dictionary D { required [XAttr] long member; };
【 `XAttr*^x が該当する拡張属性を表す。以下の例も同様。】 -
~IF[ %型 は`共用体~型$ %U の`~mb型$である ] ⇒ ~EACH( %U に`結付けられている拡張属性$ %X ) に対し ⇒ %拡張属性~集合 に %X を`付加する$set ◎ If type is a member type of a union type U, append each of the extended attributes associated with U to extended attributes.
[Exposed=Window] interface I { attribute [XAttr] (long or Node) attrib; };
-
~IF[ %型 は[ `Argument$g 生成規則 %P の中に直に現れる `Type$g 生成規則 ]の一部として現れている ] ⇒ %P の中の `ExtendedAttributeList$g 内に在する ~EACH( `拡張属性$ %X ) に対し ⇒ ~IF[ %X は`型に適用でき$る ] ⇒ %拡張属性~集合 に %X を`付加する$set ◎ If type appears as part of a Type production directly within an Argument production, append to extended attributes all of the extended attributes present in the production’s ExtendedAttributeList that are applicable to types.
[Exposed=Window] interface I { void f([XAttr] long %attrib); };
この例の `XAttr^x は、`型に適用でき$る場合に限り,引数の型に結付けられる(他の場合、 `XAttr^x は,引数に適用される)。 ◎ Note that this is an example of this step only if [XAttr] is applicable to types; otherwise [XAttr] applies to the argument, and not the argument’s type.
-
~IF[ %型 は[ `DictionaryMember$g 生成規則 %P の中に直に現れる `Type$g 生成規則 ]の一部として現れている ] ⇒ %P の中の `ExtendedAttributeList$g 内に在する ~EACH( `拡張属性$ %X ) に対し ⇒ ~IF[ %X は`型に適用でき$る ] ⇒ %拡張属性~集合 に %X を`付加する$set ◎ If type appears as part of a Type production directly within an DictionaryMember production, append to extended attributes all of the extended attributes present in the production’s ExtendedAttributeList that are applicable to types.
dictionary D { [XAttr] long member; };
この例の `XAttr^x は、`型に適用でき$る場合に限り,辞書~mbの型に結付けられる(他の場合、 `XAttr^x は,辞書~mbに適用される)。 ◎ Note that this is an example of this step only if [XAttr] is applicable to types; otherwise [XAttr] applies to the dictionary member, and not the member’s type.
-
~IF[ %型 は`~typedef$である ] ⇒ ~EACH( %型 により`新たな名前が与えられる型$に`結付けられている拡張属性$ %X ) に対し ⇒ %拡張属性~集合 に %X を`付加する$set ◎ If type is a typedef, append the extended attributes associated with the type being given a new name to extended attributes.
typedef [XAttr] long xlong;
- ~RET %拡張属性~集合 ◎ Return extended attributes.
どの型に対しても,それに`結付けられている拡張属性$は、`型に適用でき$るもので~MUST。 ◎ For any type, the extended attributes associated with it must only contain extended attributes that are applicable to types.
`拡張属性が結付けられ$ている型の`型~名$は、次の連結とする:
- 元の型の`型~名$
- 各[ 型に`結付けられている拡張属性$ ]の`識別子$に対応する文字列すべてを辞書式~順序で連結した結果
`[B, A] long?^c の形による型の`型~名$は、 `LongOrNullAB^l になる。 ◎ The type name for a type of the form [B, A] long? is "LongOrNullAB".
2.12.30. `Error^T
`Error$T 型は、[ `単純例外$, `DOMException$T ]~objを含む,アリなすべての[ 非 null 例外~objへの参照 ]の集合に対応する。 ◎ The Error type corresponds to the set of all possible non-null references to exception objects, including simple exceptions and DOMException objects.
~IDLにおいて,定数 `Error$T 値を表現する仕方は、ない。 ◎ There is no way to represent a constant Error value in IDL.
`Error$T の`型~名$は、 `Error^l である。 ◎ The type name of the Error type is "Error".
2.12.31. ~buffer~source型
アリなすべての[[[ ~dataの~buffer, または[ ~dataの~buffer上の~view ]]を表現する~obj ]への 非 `null^V 参照 ]の集合に対応する,いくつかの型がある。 下の一覧に、それらの型, および それらが表現する[ ~bufferまたは その~view ]の種類を挙げる。 ◎ There are a number of types that correspond to sets of all possible non-null references to objects that represent a buffer of data or a view on to a buffer of data. The table below lists these types and the kind of buffer or view they represent.
型◎ Type | ~bufferの種類◎ Kind of buffer |
---|---|
`ArrayBuffer@T | 固定的な個数の~byteからなる~bufferへの~pointer( `null^V もとり得る)を保持する~obj。 ◎ An object that holds a pointer (which may be null) to a buffer of a fixed number of bytes |
`DataView@T | `ArrayBuffer$T への~viewであって、~bufferの中の,任意の~offsetに格納されている 整数/浮動小数点 値への~accessを可能にするもの。 ◎ A view on to an ArrayBuffer that allows typed access to integers and floating point values stored at arbitrary offsets into the buffer |
`Int8Array@T, `Int16Array@T, `Int32Array@T | `ArrayBuffer$T への~viewであって、[ 所与の~bit~sizeの 2 の補数による有符号~整数からなる配列 ]を公開するもの。 ◎ A view on to an ArrayBuffer that exposes it as an array of two’s complement signed integers of the given size in bits |
`Uint8Array@T, `Uint16Array@T, `Uint32Array@T | `ArrayBuffer$T への~viewであって、[ 所与の~bit~sizeの 無符号~整数からなる配列 ]を公開するもの。 ◎ A view on to an ArrayBuffer that exposes it as an array of unsigned integers of the given size in bits |
`Uint8ClampedArray@T | `ArrayBuffer$T への~viewであって、値を切詰める変換も伴われるような,[ 8~bit無符号~整数からなる配列 ]を公開するもの。 ◎ A view on to an ArrayBuffer that exposes it as an array of unsigned 8 bit integers with clamped conversions |
`Float32Array@T, `Float64Array@T | `ArrayBuffer$T への~viewであって、[ 所与の~bit~sizeの IEEE 754 浮動小数点数 ]からなる配列を公開するもの。 ◎ A view on to an ArrayBuffer that exposes it as an array of IEEE 754 floating point numbers of the given size in bits |
注記: これらの型はすべて、~ESにて定義される~classに対応する。 ◎ Note: These types all correspond to classes defined in ECMAScript.
これらのどの型についても: ◎ ↓
- ~IDLにおいて,その型の定数~値を表現する仕方は、ない。 ◎ There is no way to represent a constant value of any of these types in IDL.
- その`型~名$は、その型~自身の名前である。 ◎ The type name of all of these types is the name of the type itself.
仕様の中の注釈文~levelにおいては、~IDL`~buffer~source型$は,単純に~objへの参照である。 仕様の注釈文にて,~buffer内の~byte列を 検分したり操作するときは、最初に,~buffer~sourceに保持されている~byte列の `参照/複製を取得-@ する手続きを介さ~MUST。 仕様の注釈文では、その結果の~byte列への参照/複製を利用して,個々の~byte値を取得したり設定できる。 ◎ At the specification prose level, IDL buffer source types are simply references to objects. To inspect or manipulate the bytes inside the buffer, specification prose must first either get a reference to the bytes held by the buffer source or get a copy of the bytes held by the buffer source. With a reference to the buffer source’s bytes, specification prose can get or set individual byte values using that reference.
仕様において、[ ~buffer~sourceに保持されている~byteへの参照を取得する ]ような ~textを書くときには、細心の注意を払う必要がある — 下層の~dataは、作者や他の~APIにより,予測し得ない時に容易に変更され得るので。 改変されないような ~binary~dataの~chunkを得るために,演算~引数として~buffer~source型を利用する場合は、その演算を定義する注釈文の始めの方で,~buffer~sourceの~byte列の複製を取得することが、強く推奨される。 ◎ Extreme care must be taken when writing specification text that gets a reference to the bytes held by a buffer source, as the underlying data can easily be changed by the script author or other APIs at unpredictable times. If you are using a buffer source type as an operation argument to obtain a chunk of binary data that will not be modified, it is strongly recommended to get a copy of the buffer source’s bytes at the beginning of the prose defining the operation.
~byte列の 参照/複製 を取得する明示的な注釈文を要することの意図は、仕様の査読者が,これらの~buffer~source型の利用に孕まれる問題を見つけ易くするためである。 ◎ Requiring prose to explicitly get a reference to or copy of the bytes is intended to help specification reviewers look for problematic uses of these buffer source types.
注記: ~bufferを~~入力にとる~APIを設計するときは、 `ArrayBuffer$T や他の~view~型よりも `BufferSource^T ~typedefの利用が推奨される。 ◎ When designing APIs that take a buffer, it is recommended to use the BufferSource typedef rather than ArrayBuffer or any of the view types.
~bufferを作成したり返す~APIを設計するときは、 `Uint8Array$T よりも `ArrayBuffer$T 型の利用が推奨される。 ◎ When designing APIs that create and return a buffer, it is recommended to use the ArrayBuffer type rather than Uint8Array.
`切離された$ `ArrayBuffer$T ~objに対し,~buffer~sourceに保持されている~byte列の`参照/複製を取得-$しようと試みたときは、言語束縛に特有の方式で失敗することになる。 ◎ Attempting to get a reference to or get a copy of the bytes held by a buffer source when the ArrayBuffer has been detached will fail in a language binding-specific manner.
注記: ~ES言語束縛において ~buffer~source型とどう相互作用するかについては、 `es-buffer-source-types$sec を見よ。 ◎ Note: See §3.2.25 Buffer source types below for how interacting with buffer source types works in the ECMAScript language binding.
これらの型や用語を利用する仕様~textの例を含ませる必要がある。 ◎ We should include an example of specification text that uses these types and terms.
2.12.32. 凍結~配列~型 — ~FrozenArray_T
`凍結~配列~型@ — ~FrozenArray_T — は、[[[ 一連の[ 改変できない,型 %T の値 ]からなる,固定長の配列 ]を保持する~obj ]への参照 ]を値にとり得るような,~parameter化された型である。 ◎ A frozen array type is a parameterized type whose values are references to objects that hold a fixed length array of unmodifiable values. The values in the array are of type T.
`~FrozenArray_T$ 値は参照である — 値の~listであり,値渡しである`連列~型$と違って。 ◎ Since FrozenArray<T> values are references, they are unlike sequence types, which are lists of values that are passed by value.
~IDLにおいて,定数~凍結~配列~値を表現する仕方は、ない。 ◎ There is no way to represent a constant frozen array value in IDL.
凍結~配列~型の`型~名$は、次の連結とする ⇒# %T の型~名, 文字列 `Array^l ◎ The type name of a frozen array type is the concatenation of the type name for T and the string "Array".
2.13. 拡張属性
`拡張属性@ は、[ `定義$ / `注釈付きの型$としての型 / `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ / `辞書~mb$ / `演算$引数 ]上に現れ得る 注釈 ( `annotation^en )であり,[ 言語束縛がこれらの構成子をどう取扱うことになるか ]を制御するために利用される。 拡張属性は `ExtendedAttributeList$g により指定される。 それは、全体が角括弧で括られた,いくつかの `ExtendedAttribute$g からなる~comma区切りの~listである。 ◎ An extended attribute is an annotation that can appear on definitions, types as annotated types, interface members, interface mixin members, namespace members, dictionary members, and operation arguments, and is used to control how language bindings will handle those constructs. Extended attributes are specified with an ExtendedAttributeList, which is a square bracket enclosed, comma separated list of ExtendedAttributes.
文法~記号 `ExtendedAttribute$g は,ほぼ任意の~token並びに合致するが、この文書で定義される`拡張属性$は,より制約された構文のみを受容する。 `~IDL片$に~~現れるどの拡張属性も、次の表に示す文法~記号のいずれかへの合致により、それが属する( 1 個~以上の)形が決定される: ◎ The ExtendedAttribute grammar symbol matches nearly any sequence of tokens, however the extended attributes defined in this document only accept a more restricted syntax. Any extended attribute encountered in an IDL fragment is matched against the following five grammar symbols to determine which form (or forms) it is in:
文法~記号◎ Grammar symbol | 形◎ Form | 例◎ Example |
---|---|---|
`ExtendedAttributeNoArgs$g | `引数をとらない@ ◎ takes no arguments | `[Replaceable]^c |
`ExtendedAttributeArgList$g | `引数~listを引数にとる@ ◎ takes an argument list | `[Constructor(double x, double y)]^c |
`ExtendedAttributeNamedArgList$g | `有名~引数~listを引数にとる@ ◎ takes a named argument list | `[NamedConstructor=Image(DOMString src)]^c |
`ExtendedAttributeIdent$g | `識別子を引数にとる@ ◎ takes an identifier | `[PutForwards=name]^c |
`ExtendedAttributeIdentList$g | `識別子~listを引数にとる@ ◎ takes an identifier list | `[Exposed=(Window,Worker)]^c |
この仕様は、~ES言語束縛に適用-可能な,種々の拡張属性を定義する。 それらについては `es-extended-attributes$sec にて述べる。 各~拡張属性~定義において、上に挙げたどの形が許容されるかについて言明される。 ◎ This specification defines a number of extended attributes that are applicable to the ECMAScript language binding, which are described in §3.3 ECMAScript-specific extended attributes. Each extended attribute definition will state which of the above five forms are allowed.
3. ~ES言語束縛
この節では、 `idl$sec にて定義された~IDLで記される`定義$が, ~ES言語~仕様 `ECMA-262$r により定義される~ESの中の特定0の構成子にどう対応するかを述べる。 ◎ This section describes how definitions written with the IDL defined in §2 Interface definition language correspond to particular constructs in ECMAScript, as defined by the ECMAScript Language Specification [ECMA-262].
他が指定されない限り,この節に定義される~objは、 [ `普通の~objの内部~methと内部~slot$ / `関数~obj$である場合は`組込みの関数~obj$ ]節 `ECMA-262$r に述べられる,普通の~objであるとする。 ◎ Unless otherwise specified, objects defined in this section are ordinary objects as described in ECMA-262 §9.1 Ordinary object internal methods and internal slots, and if the object is a function object, §9.3 Built-in function objects.
この節では、一部の~objに対し,一定の[ 内部~meth / 内部~slot ]を再~定義する。 他の仕様も、[ `~ifc$の~instanceである`~platform~obj$ ]の[ 内部~meth / 内部~slot ]の定義を上書きして~MAY。 これらの,意味論が変更された~objは、~exotic~obj用の規則に則って扱われるものとする。 ◎ This section may redefine certain internal methods and/or internal slots of objects. Other specifications may also override the definitions of any internal method and/or internal slots of a platform object that is an instance of an interface. These objects with changed semantics shall be treated in accordance with the rules for exotic objects.
内部~ES~obj~methを上書きすることは、低~levelの演算であり,~objの挙動を普通の~objから違えさせ得るので、この便宜性は,保安/互換性のために必要とされない限り,利用されるべきでない。 これは現在、 `HTMLAllCollection$T, `Location$T ~ifcを定義するために利用されている。 `HTML$r ◎ As overriding internal ECMAScript object methods is a low level operation and can result in objects that behave differently from ordinary objects, this facility should not be used unless necessary for security or compatibility. This is currently used to define the HTMLAllCollection and Location interfaces. [HTML]
他が指定されない限り,[ この節 / 他の仕様 ]に定義される~exotic~objは、普通の~objと同じ`内部~slot$たちを持ち,その内部~methのうち代替の定義が与えられなかったものすべては,`普通の~objの内部~methと内部~slot$と同じとする。 ◎ Unless otherwise specified, exotic objects defined in this section and other specifications have the same internal slots as ordinary objects, and all of the internal methods for which alternative definitions are not given are the same as those of ordinary objects.
他が指定されない限り,この節に定義される~objの `Extensible^sl 内部~slotの値は `true^jv とする。 ◎ Unless otherwise specified, the [[Extensible]] internal slot of objects defined in this section has the value true.
他が指定されない限り,この節に定義される~objの `Prototype^sl 内部~slotは `ObjectPrototype$jI とする。 ◎ Unless otherwise specified, the [[Prototype]] internal slot of objects defined in this section is %ObjectPrototype%.
この節にて述べる一部の~objは、 `~class文字列@ を持つものと定義される。 この文字列は、 `Object.prototype.toString^c が返す文字列に内包されることになる。 ◎ Some objects described in this section are defined to have a class string, which is the string to include in the string returned from Object.prototype.toString.
`~class文字列$ %~class文字列 を持つ~objは、その作成-時に,次の特徴を有する~propを持つようにされ~MUST:
- 名前: `toStringTag$jS ~symbol
- 属性 `FFT-~class文字列^desc を持つ。
この節の中の~algoは、手続きとその下位手続き, 数学的~演算, 等々の利用に関し, `ECMA-262$r による`~algo規約$節に記述されている表記規約を利用する。 この節は、 ECMA-262 の他所で定義される[ 抽象~演算 / 記法 ]も参照する。 ◎ Algorithms in this section use the conventions described in ECMA-262 §5.2 Algorithm conventions, such as the use of steps and substeps, the use of mathematical operations, and so on. This section may also reference abstract operations and notations defined in other parts of ECMA-262.
~algoにおいて “`~THROW@ `SomethingError^E” と記される所では、`現在の~Realm$に属する新たな~ES `SomethingError^E ~objを構築して, ECMA-262 の~algoとちょうど同じ様に投出することを意味する。 ◎ When an algorithm says to throw a SomethingError then this means to construct a new ECMAScript SomethingError object in the current Realm and to throw it, just as the algorithms in ECMA-262 do.
~algoの手続きは,他の~algoや抽象~演算の中へ~callできるが、それらから投出される例外は 明示的に取扱われていないことに注意。 ~algoまたは抽象~演算により例外が投出され,それが~call元により明示的に取扱われない所では、~algoは終端され,その~call元の更に外へ伝播する,等々となる。 ◎ Note that algorithm steps can call in to other algorithms and abstract operations and not explicitly handle exceptions that are thrown from them. When an exception is thrown by an algorithm or abstract operation and it is not explicitly handled by the caller, then it is taken to end the algorithm and propagate out to its caller, and so on.
次の~algoを考える: ◎ Consider the following algorithm:
- %x ~LET この~algoに渡された~ES値 ◎ Let x be the ECMAScript value passed in to this algorithm.
- %y ~LET `ToString$A( %x ) ◎ Let y be the result of calling ToString(x).
- ~RET %y ◎ Return y.
`ToString$A は例外を投出し得るが(例えば~obj `({ toString: function() { throw 1 } })^c が渡されたとき),例外は上の~algoでは取扱われないので、もし投出された場合、この~algoは終端され,その例外は ~call元が在るならばその~call元に伝播する。 ◎ Since ToString can throw an exception (for example if passed the object ({ toString: function() { throw 1 } })), and the exception is not handled in the above algorithm, if one is thrown then it causes this algorithm to end and for the exception to propagate out to its caller, if there is one.
3.1. ~ES環境
所与の[ `~IDL片$の集合 ]に対する~ES実装においては、それらの`~IDL片$の中の それぞれの定義に対応する,~ES~objが存在することになる。 これらの~objは `初期~obj@ と呼ばれ、次のものからなる: ◎ In an ECMAScript implementation of a given set of IDL fragments, there will exist a number of ECMAScript objects that correspond to definitions in those IDL fragments. These objects are termed the initial objects, and comprise the following:
- `~ifc~obj$ ◎ interface objects
- `旧来の呼戻~ifc~obj$ ◎ legacy callback interface objects
- `有名~構築子$ ◎ named constructors
- `~ifc原型~obj$ ◎ interface prototype objects
- `有名~prop~obj$ ◎ named properties objects
- `反復子~原型~obj$ ◎ iterator prototype objects
- `属性~取得子$ ◎ attribute getters
- `属性~設定子$ ◎ attribute setters
- 演算に対応する関数~obj ◎ the function objects that correspond to operations
- 文字列化子に対応する関数~obj ◎ the function objects that correspond to stringifiers
- 反復子に対応する関数~obj ◎ the function objects that correspond to iterators
- `~map~size取得子$ ◎ map size getters
どの ~ES大域~環境 %G も、それぞれに一意な自前の[ 各種`初期~obj$からなる集合 %S ]を持た~MUST。 %S が作成されるのは、[ %G 用の大域~objが作成された後, かつ %G に結付けられている~ES実行~文脈に制御が移る前 ]で~MUST。 %S に属する どの初期~objも,その `Prototype^sl は %G に属してい~MUST。 ◎ Each ECMAScript global environment must have its own unique set of each of the initial objects, created before control enters any ECMAScript execution context associated with the environment, but after the global object for that environment is created. The [[Prototype]]s of all initial objects in a given global environment must come from that same global environment.
【 上の “大域~環境 %G に属する” という句は、所与の~objが同時に複数の大域~環境に 属する ことは,決してないことを含意する。 】
HTML ~UAにおいては、複数の frame や window が作成されたときに,複数の大域~環境が存在し得る。 frame や window のそれぞれは、自前の`初期~obj$の集合を持つことになる。 次の HTML 文書の例のように: ◎ In an HTML user agent, multiple global environments can exist when multiple frames or windows are created. Each frame or window will have its own set of initial objects, which the following HTML document demonstrates:
<!DOCTYPE html> <title> 相異なる大域~環境 ◎ Different global environments </title> <iframe id=a></iframe> <script> var %iframe = document.getElementById("a"); var %w = %iframe.contentWindow; /* frame 内の大域~obj ◎ The global object in the frame */ Object == %w.Object; /* ECMA-262 に則り, `false^jv に評価される ◎ Evaluates to false, per ECMA-262 */ Node == %w.Node; /* `false^jv に評価される。 ◎ Evaluates to false. */ %iframe instanceof %w.Node; /* */ %iframe instanceof %w.Object; /* */ %iframe.appendChild instanceof Function; /* */ %iframe.appendChild instanceof %w.Function; /* */ </script>
他が指定されない限り、各~ES大域~環境は,実装が~supportする すべての`~ifc$を `公開する@ 。 所与の~ES大域~環境が公開しない~ifcは, `es-interfaces$sec にて与える要件に従うとは限らない。 ◎ Unless otherwise specified, each ECMAScript global environment exposes all interfaces that the implementation supports. If a given ECMAScript global environment does not expose an interface, then the requirements given in §3.6 Interfaces are not followed for that interface.
注記: これにより,例えば、 Web Workers 用の~ES大域~環境が[ ~supportするものとして`公開する$,~ifcの集合 ]を[ ~Web~page用の環境 ]が公開するそれと異ならせることも許容される。 ◎ Note: This allows, for example, ECMAScript global environments for Web Workers to expose different sets of supported interfaces from those exposed in environments for Web pages.
これを書いている時点では,~ES仕様は それを反映していないが、どの~ES~objにも`~Realm$が結付けられ~MUST — この~Realmを指して, ~objが `属する~Realm@ という。
各~objと~Realmを結付ける仕組みは、今の所,策定中にあるが:
- `~platform~obj$については、それが`属する~Realm$は,その~objに`関連する~Realm$に等しい。
- ~exoticでない`関数~obj$(すなわち,`~callable$~proxyでも~bindされた関数でもない)についても、それが`属する~Realm$は,その`関数~obj$の `Realm^sl 内部~slotの値に等しい。
3.2. ~ES型との対応関係
この節では、~IDLにおける各~型が,~ESにおける型に どう対応付けられるかについて述べる。 ◎ This section describes how types in the IDL map to types in ECMAScript.
以下の各~下位~節では、所与の[ ~IDL型の値 ]が,~ESの中では どう表現されるかを述べる。 各種~IDL型に対し、その型を期待する`~platform~obj$に~ES値が渡された際に `~IDL値に変換-@ する方法, および その型の~IDL値が~platform~objから返される際に `~ES値に変換-@ する方法が述べられる。 ◎ Each sub-section below describes how values of a given IDL type are represented in ECMAScript. For each IDL type, it is described how ECMAScript values are converted to an IDL value when passed to a platform object expecting that type, and how IDL values of that type are converted to ECMAScript values when returned from a platform object.
以下の各 下位~節と~algoは、[[ その見出しに挙げられる名前の型 ]に拡張属性を適用して作成される,`注釈付きの型$ ]にも適用されることに注意。 ◎ Note that the sub-sections and algorithms below also apply to annotated types created by applying extended attributes to the types named in their headers.
3.2.1. `any^T
~IDL `any$T 型は、他のすべての~IDL型の和集合なので,どの~ES値~型にも対応し得る。 ◎ Since the IDL any type is the union of all other IDL types, it can correspond to any ECMAScript value type.
次の~algoにより,~ES値 %V は `any$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL any value by running the following algorithm:
- ~IF[ %V ~EQ `undefined^jv ] ⇒ ~RET ~ES `undefined^jv 値を表現する特別な~objへの `object$T 参照 ◎ If V is undefined, then return an object reference to a special object that represents the ECMAScript undefined value.
- ~IF[ %V ~EQ `null^jv ] ⇒ ~RET `null^V `object$T? 参照 ◎ If V is null, then return the null object? reference.
-
~RET `Type$A( %V ) に応じて,次で与えられる値: ◎ ↓
- `Boolean^jt
- 同じ真偽~値を表現する `boolean$T 値 ◎ If Type(V) is Boolean, then return the boolean value that represents the same truth value.
- `Number^jt
- `es-unrestricted-double$secに従って, %V を `unrestricted double$T 値に変換した結果 ◎ If Type(V) is Number, then return the result of converting V to an unrestricted double.
- `String^jt
- `es-DOMString$secに従って, %V を `DOMString$T 値に変換した結果 ◎ If Type(V) is String, then return the result of converting V to a DOMString.
- `Symbol^jt
- `es-symbol$secに従って, %V を `symbol$T 値に変換した結果 ◎ If Type(V) is Symbol, then return the result of converting V to a symbol.
- `Object^jt
- %V を参照する~IDL `object$T 値 ◎ If Type(V) is Object, then return an IDL object value that references V.
~IDL `any$T 値 %V は,次のように`~ES値に変換-$される: ◎ An IDL any value is converted to an ECMAScript value as follows.\
- %V が[ ~ES `undefined^jv 値を表現する特別な~objへの `object$T 参照 ]ならば、~ES `undefined^jv 値に変換される。 ◎ If the value is an object reference to a special object that represents an ECMAScript undefined value, then it is converted to the ECMAScript undefined value.\
- 他の場合、この節の残りで述べられる, %V の`特有~型$を変換するための規則に従う。 ◎ Otherwise, the rules for converting the specific type of the IDL any value as described in the remainder of this section are performed.
3.2.2. `void^T
`void$T が~IDLに現れ得る唯一の場所は、`演算$の`返値型$である。 [ ~IDLにおいて `void$T 返値型が指定されている演算 ]を実装する[ `~platform~obj$上の関数 ]は、 `undefined^jv 値を返さ~MUST。 ◎ The only place that the void type may appear in IDL is as the return type of an operation. Functions on platform objects that implement an operation whose IDL specifies a void return type must return the undefined value.
[ ~IDLにおいて `void$T 返値型が指定されている演算 ]を実装する~ES関数は、どのような値を返しても~MAY(破棄されることになる)。 ◎ ECMAScript functions that implement an operation whose IDL specifies a void return type may return any value, which will be discarded.
3.2.3. `boolean^T
次の~algoにより,~ES値 %V は `boolean$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL boolean value by running the following algorithm:
- %x ~LET `ToBoolean$A( %V ) の算出-結果 ◎ Let x be the result of computing ToBoolean(V).
- ~RET [ ~ES `Boolean^jt 値 %x ]と同じ真偽~値を表現する~IDL `boolean$T 値 ◎ Return the IDL boolean value that is the one that represents the same truth value as the ECMAScript Boolean value x.
~IDL `boolean$T 値[ `true^V/`false^V ]は,~ES[ `true^jv/`false^jv ]値に 変換される。 ◎ The IDL boolean value true is converted to the ECMAScript true value and the IDL boolean value false is converted to the ECMAScript false value.
3.2.4. 整数~型
この節に利用される数学的~演算は、 `ECMA-262$r による`~algo規約$節に定義されるものも含め,数学的実数による数学的に正確な結果を算出していると解されるとする。 ◎ Mathematical operations used in this section, including those defined in ECMA-262 §5.2 Algorithm conventions, are to be understood as computing exact mathematical results on mathematical real numbers.
`Number^jt 値 %x に対し, “%x に演算する” ことは、実質的に “%x と同じ実数~値を表現する数学的実数に演算する” ことの略記である。 ◎ In effect, where x is a Number value, “operating on x” is shorthand for “operating on the mathematical real number that represents the same numeric value as x”.
- 3.2.4.1. `byte^T
- 3.2.4.2. `octet^T
- 3.2.4.3. `short^T
- 3.2.4.4. `unsigned short^T
- 3.2.4.5. `long^T
- 3.2.4.6. `unsigned long^T
- 3.2.4.7. `long long^T
- 3.2.4.8. `unsigned long long^T
- 【 この訳では、原文のこれら各~下位~節の内容 — ~ES値 から各種~IDL整数~型 値への変換, およびその逆の変換の定義 — を集約して,一括して与える。 】
次の~algoにより,~ES値 %V は `整数~型$ %T の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL _T_ value by running the following algorithm:
- %x ~LET ? `ConvertToInt$A( %V, %T ) ◎ Let x be ? ConvertToInt(V, _N_, "signed|unsigned").
- ~RET %x と同じ実数~値を表現する,型 %T の~IDL値 ◎ Return the IDL _T_ value that represents the same numeric value as x.
~IDL`整数~型$ %T の値 %V を`~ES値に変換-$した結果は, %T に応じて次で与えられる: ◎ The result of converting an IDL _T_ value to an ECMAScript value is a ...
- `long long$T
- `unsigned long long$T
- %V に最も近い実数~値を表現する `Number^jt 値 ⇒ 2 数が等距離にある場合は,仮数が偶数になる方を選ぶとする
- %V が範囲 [%MIN, %MAX] に入るならば、その値 は %V と正確に同じ値を表現できることになる。†
- 他の整数~型
- %V と同じ実数~値を表現する `Number^jt 値。
- その値は 範囲 [%MIN, %MAX] の整数になる。†
† 上の %MIN, %MAX は、次節の `ConvertToInt$A にて与えられる。
◎ The result of converting an IDL _T_ value to an ECMAScript value is a Number value that represents the closest numeric value to the _T_, choosing the numeric value with an even significand if there are two equally close values. If the _T_ is in the range [_MIN_, _MAX_], then the Number will be able to represent exactly the same value as the _T_. ◎ Number that represents the same numeric value as the IDL _T_ value. The Number value will be an integer in the range [_MIN_, _MAX_].3.2.4.9. 抽象~演算
`IntegerPart@A( %n ): ◎ IntegerPart(n):
- %r ~LET `floor$op( `abs$op( %n ) ) ◎ Let r be floor(abs(n)).
- ~IF[ %n ~LT 0 ] ⇒ ~RET −1 ~MUL %r ◎ If n < 0, then return -1 × r.
- ~RET %r ◎ Otherwise, return r.
`ConvertToInt@A( %V, %T ) ◎ ConvertToInt(V, bitLength, signedness):
-
( %MIN, %MAX, %N, %signed ) ~LET %T に応じて,次の表で与えられる値:
%T %N %MIN %MAX %signed `byte$T 8 −2`7^sup 2`7^sup ~MINUS 1 ~T `octet$T 8 0 2`8^sup ~MINUS 1 ~F `short$T 16 −2`15^sup 2`15^sup ~MINUS 1 ~T `unsigned short$T 16 0 2`16^sup ~MINUS 1 ~F `long$T 32 −2`31^sup 2`31^sup ~MINUS 1 ~T `unsigned long$T 32 0 2`32^sup ~MINUS 1 ~F `long long$T 64 −2`53^sup ~PLUS 1 2`53^sup ~MINUS 1 ~T `unsigned long long$T 64 0 2`53^sup ~MINUS 1 ~F 注記: `long long^T, `unsigned long long^T の %MIN, %MAX を 2 の 53 乗で~~制限しているのは、[ `EnforceRange$x / `Clamp$x ]`拡張属性が結付けられ$ている `long long$T 型を,~ES `Number$jt 型の整数として一義的に表現できることを確保するためである。
◎ If bitLength is 64, then: • Let upperBound be 253 − 1. • If signedness is "unsigned", then let lowerBound be 0. • Otherwise let lowerBound be −253 + 1. ◎ Note: this ensures long long types associated with [EnforceRange] or [Clamp] extended attributes are representable in ECMAScript’s Number type as unambiguous integers. ◎ Otherwise, if signedness is "unsigned", then: • Let lowerBound be 0. • Let upperBound be 2bitLength − 1. ◎ Otherwise: • Let lowerBound be -2bitLength − 1. • Let upperBound be 2bitLength − 1 − 1. - %x ~LET ? `ToNumber$A( %V ) ◎ Let x be ? ToNumber(V).
- ~IF[ %x ~EQ −0 ] ⇒ %x ~SET +0 ◎ If x is −0, then set x to +0.
-
~IF[ `EnforceRange$x `拡張属性が結付けられ$ている~IDL型への変換である ]: ◎ If the conversion is to an IDL type associated with the [EnforceRange] extended attribute, then:
- ~IF[ %x ~IN { `NaN^jv, +∞, −∞ } ] ⇒ ~throwTypeError ◎ If x is NaN, +∞, or −∞, then throw a TypeError.
- %x ~SET ! `IntegerPart$A( %x ) ◎ Set x to ! IntegerPart(x).
- ~IF[ %x ~LT %MIN ]~OR[ %x ~GT %MAX ] ⇒ ~throwTypeError ◎ If x < lowerBound or x > upperBound, then throw a TypeError.
- ~RET %x ◎ Return x.
-
~IF[ %x ~NEQ `NaN^jv ]~AND[ `Clamp$x `拡張属性が結付けられ$ている~IDL型への変換である ]: ◎ If x is not NaN and the conversion is to an IDL type associated with the [Clamp] extended attribute, then:
- %x ~SET `min$op( `max$op( %x, %MIN ), %MAX ) ◎ Set x to min(max(x, lowerBound), upperBound).
- ~RET %x を最も近い整数に丸めた結果 ⇒ 2 つの整数と等距離にある場合は偶数を選び,−0 より +0 の方を選ぶとする ◎ Round x to the nearest integer, choosing the even integer if it lies halfway between two, and choosing +0 rather than −0. ◎ Return x.
- ~IF[ %x ~IN { `NaN^jv, +0, +∞, −∞ } ] ⇒ ~RET 0 ◎ If x is NaN, +0, +∞, or −∞, then return +0.
- %x ~SET %x `modulo$op 2%N ◎ Set x to x modulo 2bitLength.
- ~IF[ %signed ~EQ ~T ]~AND[ %x ~GTE 2%N ~MINUS 1 ] ⇒ ~RET %x ~MINUS 2%N ◎ If signedness is "signed" and x ≥ 2bitLength − 1, then return x − 2bitLength.
- ~RET %x ◎ Otherwise, return x.
3.2.5. `float^T
次の~algoにより,~ES値 %V は `float$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL float value by running the following algorithm:
- %x ~LET ? `ToNumber$A( %V ) ◎ Let x be ? ToNumber(V).
- %S ~LET [ −0 を除く有限 IEEE 754 単精度 浮動小数点~値の集合に, 2 つの特別な値{ 2`128^sup, −2`128^sup } を追加した集合 ] ◎ Let S be the set of finite IEEE 754 single-precision floating point values except −0, but with two special values added: 2^128 and −2^128.
- %y ~LET %S の中で %x に最も近い実数~値 ⇒ 2 数が等距離にある場合は,仮数が偶数になる方を選ぶとする ⇒ この目的においては, 2 つの特別な値 2`128^sup, −2`128^sup の仮数は偶数と見なされる。 ◎ Let y be the number in S that is closest to x, selecting the number with an even significand if there are two equally close values. (The two special values 2^128 and −2^128 are considered to have even significands for this purpose.)
- ~IF[ %y ~IN { 2`128^sup, −2`128^sup } ] ⇒ ~throwTypeError ◎ If y is 2^128 or −2^128, then throw a TypeError.
- ~IF[ %y ~EQ +0 ]~AND[ %x ~LT 0 ] ⇒ ~RET −0 ◎ If y is +0 and x is negative, return −0.
- ~RET %y ◎ Return y.
~IDL `float$T 値を`~ES値に変換-$した結果は、その ~IDL値と同じ実数~値を表現する `Number^jt 値になる。 ◎ The result of converting an IDL float value to an ECMAScript value is the Number value that represents the same numeric value as the IDL float value.
3.2.6. `unrestricted float^T
次の~algoにより,~ES値 %V は `unrestricted float$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL unrestricted float value by running the following algorithm:
- ~IF[ %x ~EQ `NaN^jv ] ⇒ ~RET [ ~bit~pattern `7fc00000^X の IEEE 754 NaN 値 `IEEE-754$r ]を表現する~IDL `unrestricted float$T 値 ◎ If x is NaN, then return the IDL unrestricted float value that represents the IEEE 754 NaN value with the bit pattern 0x7fc00000 [IEEE-754].
- ~IF[ %y ~EQ 2`128^sup ] ⇒ ~RET +∞ ◎ If y is 2^128, return +∞.
- ~IF[ %y ~EQ −2`128^sup ] ⇒ ~RET −∞ ◎ If y is −2^128, return −∞.
注記: ~ES `NaN^jv 値は唯 1 個しかないので,特定0の単精度 IEEE 754 NaN 値に正準化されなければならない。 上で言及した NaN 値は、単純に,その~bit~patternが無符号 32 ~bit整数に解釈されたときに最低~値の quiet NaN になることから,選ばれている。 ◎ Note: Since there is only a single ECMAScript NaN value, it must be canonicalized to a particular single precision IEEE 754 NaN value. The NaN value mentioned above is chosen simply because it is the quiet NaN with the lowest value when its bit pattern is interpreted as an unsigned 32 bit integer.
~IDL `unrestricted float$T 値 %V を`~ES値に変換-$した結果は、次の `Number^jt になる: ◎ The result of converting an IDL unrestricted float value to an ECMAScript value is a Number:
- ~IF[ %V ~EQ NaN ] ⇒ ~RET `NaN^jv ◎ If the IDL unrestricted float value is a NaN, then the Number value is NaN.
- ~RET %V と同じ実数~値を表現する(~~唯一の) `Number^jt 値 ◎ Otherwise, the Number value is the one that represents the same numeric value as the IDL unrestricted float value.
3.2.7. `double^T
次の~algoにより,~ES値 %V は `double$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL double value by running the following algorithm:
- ~RET [ %x と同じ実数~値 ]を表現する~IDL `double$T 値 ◎ Return the IDL double value that represents the same numeric value as x.
~IDL `double$T 値を`~ES値に変換-$した結果は、その ~IDL値と同じ実数~値を表現する `Number^jt 値になる。 ◎ The result of converting an IDL double value to an ECMAScript value is the Number value that represents the same numeric value as the IDL double value.
3.2.8. `unrestricted double^T
次の~algoにより,~ES値 %V は `unrestricted double$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL unrestricted double value by running the following algorithm:
- ~IF[ %x ~EQ `NaN^jv ] ⇒ ~RET [ ~bit~pattern `7ff8000000000000^X の IEEE 754 NaN 値 `IEEE-754$r ]を表現する~IDL `unrestricted double$T 値 ◎ If x is NaN, then return the IDL unrestricted double value that represents the IEEE 754 NaN value with the bit pattern 0x7ff8000000000000 [IEEE-754].
- ~RET [ %x と同じ実数~値 ]を表現する~IDL `unrestricted double$T 値 ◎ Return the IDL unrestricted double value that represents the same numeric value as x.
注記: ~ES `NaN^jv 値は唯 1 個しかないので,特定0の倍精度 IEEE 754 NaN 値に正準化されなければならない。 上で言及した NaN 値は、単純に,その~bit~patternが無符号 64 ~bit整数に解釈されたときに最低~値の quiet NaN になることから,選ばれている。 ◎ Note: Since there is only a single ECMAScript NaN value, it must be canonicalized to a particular double precision IEEE 754 NaN value. The NaN value mentioned above is chosen simply because it is the quiet NaN with the lowest value when its bit pattern is interpreted as an unsigned 64 bit integer.
~IDL `unrestricted double$T 値 %V を`~ES値に変換-$した結果は、次の `Number^jt になる: ◎ The result of converting an IDL unrestricted double value to an ECMAScript value is a Number:
- ~IF[ %V ~EQ NaN ] ⇒ ~RET `NaN^jv ◎ If the IDL unrestricted double value is a NaN, then the Number value is NaN.
- ~RET %V と同じ実数~値を表現する(~~唯一の) `Number^jt 値 ◎ Otherwise, the Number value is the one that represents the same numeric value as the IDL unrestricted double value.
3.2.9. `DOMString^T
次の~algoにより,~ES値 %V は `DOMString$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL DOMString value by running the following algorithm:
- ~IF[ %V ~EQ `null^jv ]~AND[ `TreatNullAs$x `拡張属性が結付けられ$ている~IDL型への変換である ] ⇒ ~RET 空~文字列を表現する `DOMString$T 値 ◎ If V is null and the conversion is to an IDL type associated with the [TreatNullAs] extended attribute, then return the DOMString value that represents the empty string.
- %x ~LET `ToString$A( %V ) ◎ Let x be ToString(V).
- ~RET [ その~ES `String^jt 値 %x が表現するものと同じ,符号単位の並び ]を表現する~IDL `DOMString$T 値 ◎ Return the IDL DOMString value that represents the same sequence of code units as the one the ECMAScript String value x represents.
~IDL `DOMString$T 値を`~ES値に変換-$した結果は、 その~IDL `DOMString$T が表現するものと同じ, `符号単位$の並びを表現する `String^jt 値になる。 ◎ The result of converting an IDL DOMString value to an ECMAScript value is the String value that represents the same sequence of code units that the IDL DOMString represents.
3.2.10. `ByteString^T
次の~algoにより,~ES値 %V は `ByteString$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL ByteString value by running the following algorithm:
- %x ~LET `ToString$A( %V ) ◎ Let x be ToString(V).
- ~IF[ %x の中に 値 ~GT 255 なる`要素$eSがある ] ⇒ ~throwTypeError ◎ If the value of any element of x is greater than 255, then throw a TypeError.
- ~RET [[ 各~要素の値 ~SET %x の対応する要素の値 ]にされた, 長さ ~EQ %x の長さ ]の~IDL `ByteString$T 値 ◎ Return an IDL ByteString value whose length is the length of x, and where the value of each element is the value of the corresponding element of x.
~IDL `ByteString$T 値 %V を`~ES値に変換-$した結果は、次を満たすようにされた `String^jt 値になる ⇒ [ 長さ ~EQ %V の長さ ]~AND[ 各 `要素$eSに対し,その値 ~EQ %V の対応する要素の値 ] ◎ The result of converting an IDL ByteString value to an ECMAScript value is a String value whose length is the length of the ByteString, and the value of each element of which is the value of the corresponding element of the ByteString.
3.2.11. `USVString^T
次の~algoにより,~ES値 %V は `USVString$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL USVString value by running the following algorithm:
- %string ~LET %V を `DOMString$T 型の`~IDL値に変換-$した結果 ◎ Let string be the result of converting V to a DOMString.
- ~RET %string を `~Unicode~scalar値~列に変換-$した結果の~IDL `USVString$T 値 ◎ Return an IDL USVString value that is the result of converting string to a sequence of Unicode scalar values.
次の~algoにより,~IDL `USVString$T 値 %V は`~ES値に変換-$される: ◎ An IDL USVString value is converted to an ECMAScript value by running the following algorithm:
- %scalarValues ~LET `USVString$T が表現する`~Unicode~scalar値$の並び ◎ Let scalarValues be the sequence of Unicode scalar values the USVString represents.
- %string ~LET %scalarValues を~UTF-16に符号化した結果の`符号単位$の並び ◎ Let string be the sequence of code units that results from encoding scalarValues in UTF-16.
- ~RET %string と同じ`符号単位$の並びを表現する `String^jt 値 ◎ Return the String value that represents the same sequence of code units as string.
3.2.12. `object^T
~IDL `object$T 値は、~ES `Object^jt 値により表現される。 ◎ IDL object values are represented by ECMAScript Object values.
次の~algoにより,~ES値 %V は `object$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL object value by running the following algorithm:
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, then throw a TypeError.
- ~RET %V と同じ~objを参照する~IDL `object$T 値 ◎ Return the IDL object value that is a reference to the same object as V.
~IDL `object$T 値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Object^jt 値になる。 ◎ The result of converting an IDL object value to an ECMAScript value is the Object value that represents a reference to the same object that the IDL object represents.
3.2.13. `symbol^T
~IDL `symbol$T 値は、~ES `Symbol^jt 値により表現される。 ◎ IDL symbol values are represented by ECMAScript Symbol values.
次の~algoにより,~ES値 %V は `symbol$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL symbol value by running the following algorithm:
- ~IF[ `Type$A( %V ) ~NEQ `Symbol^jt ] ⇒ ~throwTypeError ◎ If Type(V) is not Symbol, then throw a TypeError.
- ~RET %V と同じ~symbolを参照する~IDL `symbol$T 値 ◎ Return the IDL symbol value that is a reference to the same symbol as V.
~IDL `symbol$T 値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~symbolへの参照を表現する `Symbol^jt 値になる。 ◎ The result of converting an IDL symbol value to an ECMAScript value is the Symbol value that represents a reference to the same symbol that the IDL symbol represents.
3.2.14. ~ifc型
~IDL`~ifc型$の値は、~ES `Object^jt 値(`関数~obj$も含む)により表現される。 ◎ IDL interface type values are represented by ECMAScript Object values (including function objects).
次の~algoにより,~ES値 %V は `~ifc型$ %I の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL interface type value by running the following algorithm (where I is the interface):
- ~IF[ %V は %I を実装する`~platform~obj$である ] ⇒ ~RET その~platform~objへの参照を表現する,~IDL`~ifc型$の値 ◎ If V is a platform object that implements I, then return the IDL interface type value that represents a reference to that platform object.
- ~IF[ %V は[ `es-user-objects$secの規則に則って %I を実装する ]ものと見なされる`利用元~obj$である ] ⇒ ~RET その利用元~objへの参照を表現し, `呼戻~文脈$として`現任の設定群~obj$を伴う,~IDL`~ifc型$の値 ◎ If V is a user object that is considered to implement I according to the rules in §3.9 User objects implementing callback interfaces, then return the IDL interface type value that represents a reference to that user object, with the incumbent settings object as the callback context.
- ~throwTypeError ◎ Throw a TypeError.
~IDL`~ifc型$の値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Object^jt 値になる。 ◎ The result of converting an IDL interface type value to an ECMAScript value is the Object value that represents a reference to the same object that the IDL interface type value represents.
3.2.15. 辞書~型
~IDL`辞書~型$の値は、~ES `Object^jt 値により表現される。 その~obj(またはその原型鎖)上の~propが`辞書~mb$に対応する。 ◎ IDL dictionary type values are represented by ECMAScript Object values. Properties on the object (or its prototype chain) correspond to dictionary members.
次の~algoにより,~ES値 %~es辞書 は `辞書~型$ %D の`~IDL値に変換-$される: ◎ An ECMAScript value esDict is converted to an IDL dictionary type value by running the following algorithm (where D is the dictionary type):
- ~IF[ `Type$A( %~es辞書 ) ~NIN { `Undefined^jt, `Null^jt, `Object^jt } ] ⇒ ~throwTypeError ◎ If Type(esDict) is not Undefined, Null or Object, then throw a TypeError.
- %~IDL辞書 ~LET 型 %D の空の辞書~値(初期~時にはどの`辞書~mb$も`在さない$ものと見なされる) ◎ Let idlDict be an empty dictionary value of type D; every dictionary member is initially considered to be not present.
-
[ %D および %D のすべての`継承d辞書$ ]を成す ~EACH( %辞書 ) に対し,先祖から継承-順に: ◎ Let dictionaries be a list consisting of D and all of D’s inherited dictionaries, in order from least to most derived. ◎ For each dictionary dictionary in dictionaries, in order:
-
%辞書 上に宣言されている ~EACH( 辞書~mb %member ) に対し,~mbの`識別子$の辞書式~順序で: ◎ For each dictionary member member declared on dictionary, in lexicographical order:
-
%~es~mb値 ~LET `Type$A( %~es辞書 ) に応じて,次で与えられる~ES値: ◎ Let key be the identifier of member. ◎ Let esMemberValue be an ECMAScript value, depending on Type(esDict):
- `Undefined^jt
- `Null^jt
- `undefined^jv ◎ undefined
- その他
- ? `Get$A( %~es辞書, %member の`識別子$ ) ◎ ? Get(esDict, key)
- ~IF[ %~es~mb値 ~NEQ `undefined^jv ] ⇒ %~IDL値 ~LET %~es~mb値 を %member に宣言されている型の`~IDL値に変換-$した結果 ◎ If esMemberValue is not undefined, then: • Let idlMemberValue be the result of converting esMemberValue to an IDL value whose type is the type member is declared to be of. • Set the dictionary member on idlDict with key name key to the value idlMemberValue. This dictionary member is considered to be present.
- ~ELIF[ %member は`既定~値$diC %d を持つ ] ⇒ %~IDL値 ~LET %d ◎ Otherwise, if esMemberValue is undefined but member has a default value, then: • Let idlMemberValue be member’s default value. • Set the dictionary member on idlDict with key name key to the value idlMemberValue. This dictionary member is considered to be present.
- ~ELIF[ %member は `必須~辞書~mb$である ] ⇒ ~throwTypeError ◎ Otherwise, if esMemberValue is undefined and member is a required dictionary member, then throw a TypeError.
- ~ELSE ⇒ ~CONTINUE ◎ ↑
- %~IDL辞書 上の %member の値 ~SET %~IDL値 (この辞書~mb %member は`在する$ものと見なされるようになる) ◎ ↑
-
-
- ~RET %~IDL辞書 ◎ Return idlDict.
注記: ~ES~obj上で`辞書~mb$を検索する順序は、~objの~prop列挙~順序と同じになる必要はない。 ◎ 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.
次の~algoにより,~IDL辞書 %D 型の値 %V は `Object^jt 型の`~ES値に変換-$される: ◎ An IDL dictionary value V is converted to an ECMAScript Object value by running the following algorithm (where D is the dictionary):
- %O ~LET ! `ObjectCreate$A( `ObjectPrototype$jI ) ◎ Let O be ! ObjectCreate(%ObjectPrototype%).
-
-
- ~IF[ %member は %V 上に`在さない$ ] ⇒ ~CONTINUE ◎ Let key be the identifier of member. ◎ If the dictionary member named key is present in V, then:
- %~IDL値 ~LET %V 上の %member の値 ◎ Let idlValue be the value of member on V.
- %~es値 ~LET %~IDL値 を`~ES値に変換-$した結果 ◎ Let value be the result of converting idlValue to an ECMAScript value.
- ! `CreateDataProperty$A( %O, %member の`識別子$, %~es値 ) ◎ Perform ! CreateDataProperty(O, key, value).
-
- ~RET %O ◎ Return O.
3.2.16. 列挙~型
~IDL`列挙~型$の値は、~ES `String^jt 値により表現される。 ◎ IDL enumeration types are represented by ECMAScript String values.
次の~algoにより,~ES値 %V は `列挙$型 %E の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL enumeration type value as follows (where E is the enumeration):
- %S ~LET `ToString$A( %V ) ◎ Let S be the result of calling ToString(V).
- ~IF[ %S は %E の`列挙~値$のいずれでもない ] ⇒ ~throwTypeError ◎ If S is not one of E’s enumeration values, then throw a TypeError.
- ~RET 型 %E の, %S に等しい列挙~値 ◎ Return the enumeration value of type E that is equal to S.
~IDL`列挙$型の値を`~ES値に変換-$した結果は、[ その`列挙~値$と同じ`符号単位$の並び ]を表現する `String^jt 値になる。 ◎ The result of converting an IDL enumeration type value to an ECMAScript value is the String value that represents the same sequence of code units as the enumeration value.
3.2.17. 呼戻~関数~型
~IDL`呼戻~関数~型$の値は、~ES`関数~obj$により表現される。 ただし, `TreatNonObjectAsNull$x の場合は、任意の~objをとり得る。 ◎ IDL callback function types are represented by ECMAScript function objects, except in the [TreatNonObjectAsNull] case, when they can be any object.
次の~algoにより,~ES値 %V は `呼戻~関数~型$の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL callback function type value by running the following algorithm:
-
~IF[ 次のいずれかが満たされる ]…:
- `IsCallable$A( %V ) ~EQ ~T
- %V から~IDL値への変換は、次を満たす`属性$へ代入することに因り遂行されている ⇒ [ `~nullable$ `呼戻~関数$型である ]~AND[ `TreatNonObjectAsNull$x 注釈付きである ]
…ならば ⇒ ~RET %V が表現するものと同じ~objを表現し, `呼戻~文脈$として`現任の設定群~obj$を伴う,~IDL`呼戻~関数~型$の値
◎ If the result of calling IsCallable(V) is false and the conversion to an IDL value is not being performed due to V being assigned to an attribute whose type is a nullable callback function that is annotated with [TreatNonObjectAsNull], then throw a TypeError. ◎ Return the IDL callback function type value that represents a reference to the same object that V represents, with the incumbent settings object as the callback context. - ~throwTypeError ◎ ↑
~IDL`呼戻~関数~型$の値を`~ES値に変換-$した結果は、その`呼戻~関数~型$の値が表現するものと同じ~objへの参照になる。 ◎ The result of converting an IDL callback function type value to an ECMAScript value is a reference to the same object that the IDL callback function type value represents.
3.2.18. ~nullable型 — `~varT?^T
~IDL`~nullable型$の値は、その`内縁~型$に対応する~ES型の値か, または ~ES `null^jv 値により表現される。 ◎ IDL nullable type values are represented by values of either the ECMAScript type corresponding to the inner IDL type, or the ECMAScript null value.
この節を通して、 `~varT?^T は,`内縁~型$が %T である~IDL`~nullable型$を表す。
次の~algoにより,~ES値 %V は 型 `~varT?^T の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL nullable type T? value (where T is the inner type) as follows:
-
~IF[ 次のいずれかが満たされる ]…:
- [ `Type$A( %V ) ~NEQ `Object^jt ]~AND[ %V から~IDL値への変換は、次を満たす`属性$へ代入することに因り遂行されている ] ⇒ [ `~nullable$`呼戻~関数$型である ]~AND[ `TreatNonObjectAsNull$x 注釈付きである ]
- %V ~IN { `null^jv, `undefined^jv }
…ならば ⇒ ~RET 型 `~varT?^T の値 `null^V
◎ If Type(V) is not Object, and the conversion to an IDL value is being performed due to V being assigned to an attribute whose type is a nullable callback function that is annotated with [TreatNonObjectAsNull], then return the IDL nullable type T? value null. ◎ Otherwise, if V is null or undefined, then return the IDL nullable type T? value null. - ~RET %V を`内縁~型$ %T 用の規則に従って`~IDL値に変換-$した結果 ◎ Otherwise, return the result of converting V using the rules for the inner IDL type T.
型 `~varT?^T の~IDL値 %V を`~ES値に変換-$した結果は、[ %V ~EQ `null^V ならば `null^jv / ~ELSE_ %V を型 %T の値として`~ES値に変換-$した結果 ]になる。 ◎ The result of converting an IDL nullable type value to an ECMAScript value is: • If the IDL nullable type T? value is null, then the ECMAScript value is null. • Otherwise, the ECMAScript value is the result of converting the IDL nullable type value to the inner IDL type T.
3.2.19. 連列 — ~sequence_T
~IDL `~sequence_T$ 値は、~ES `Array^jt 値により表現される。 ◎ IDL sequence<T> values are represented by ECMAScript Array values.
次の~algoにより,~ES値 %V は `~sequence_T$ 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL sequence<T> value as follows:
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, throw a TypeError.
- %method ~LET ? `GetMethod$A( %V, `iterator$jS ) ◎ Let method be ? GetMethod(V, @@iterator).
- ~IF[ %method ~EQ `undefined^jv ] ⇒ ~throwTypeError ◎ If method is undefined, throw a TypeError.
- ( %V, %method ) から `~sequence_T$ 型の`連列~値を作成-$した結果 ◎ Return the result of creating a sequence from V and method.
次の~algoにより,型 `~sequence_T$ の~IDL連列~値 %S は `Array^jt 型の`~ES値に変換-$される: ◎ An IDL sequence value S of type sequence<T> is converted to an ECMAScript Array object as follows:
- %n ~LET %S の長さ ◎ Let n be the length of S.
- %A ~LET 式 `[]^c で作成されるものと同じ,新たな `Array^jt ~obj ◎ Let A be a new Array object created as if by the expression [].
- %i ~LET 0 ◎ Initialize i to be 0.
-
~WHILE %i ~LT %n : ◎ While i < n:
- %V ~LET %S 内の~index %i に位置する値 ◎ Let V be the value in S at index i.
- %E ~LET %V を`~ES値に変換-$した結果 ◎ Let E be the result of converting V to an ECMAScript value.
- %P ~LET `ToString$A( %i ) ◎ Let P be the result of calling ToString(i).
- `CreateDataProperty$A( %A, %P, %E ) を~callする ◎ Call CreateDataProperty(A, P, E).
- %i ~INCBY 1 ◎ Set i to i + 1.
- ~RET %A ◎ Return A.
3.2.19.1. 可反復から連列を作成する
所与の ( 可反復 %iterable, 反復子~取得子 %method ) から 型 `~sequence_T$ の~IDL値を作成するときは、次の手続きを遂行する: ◎ To create an IDL value of type sequence<T> given an iterable iterable and an iterator getter method, perform the following steps:
- %iter ~LET ? `GetIterator$A( %iterable, %method ) ◎ Let iter be ? GetIterator(iterable, method).
- %i ~LET 0 ◎ Initialize i to be 0.
-
~WHILE 無条件: ◎ Repeat
- %next ~LET ? `IteratorStep$A( %iter ) ◎ Let next be ? IteratorStep(iter).
- ~IF[ %next ~EQ `false^jv ] ⇒ ~RET ~index %j に位置する要素の値が %S%j で, 長さ %i の,型 `~sequence_T$ の~IDL連列~値 ◎ If next is false, then return an IDL sequence value of type sequence<T> of length i, where the value of the element at index j is Sj.
- %nextItem ~LET ? `IteratorValue$A( %next ) ◎ Let nextItem be ? IteratorValue(next).
- %S%i ~LET %nextItem を型 %T の`~IDL値に変換-$した結果 ◎ Initialize Si to the result of converting nextItem to an IDL value of type T.
次の`~ifc$は 連列~型の引数を伴う`演算$と伴に 連列~型の`属性$を定義する。 ◎ The following interface defines an attribute of a sequence type as well as an operation with an argument of a sequence type.
[Exposed=Window] interface Canvas { sequence<DOMString> getSupportedImageCodecs(); void drawPolygon(sequence<double> %coordinates); sequence<double> getLastDrawnPolygon(); /* */ };
この~ifcの~ES実装においては、型[ `String^jt / `Number^jt ]の要素からなる `Array^jt ~objが,それぞれ[ `sequence<DOMString>^T / `sequence<double>^T ]の表現-に利用される。 この `Array^jt ~objは実質的には値渡しであり、 `getSupportedImageCodecs()^M 関数が~callされる度に,新たな `Array^jt が返され、 `Array^jt が `drawPolygon^M に渡されたときは常に,その参照は~call完了-後には保有されないことになる。 ◎ In an ECMAScript implementation of this interface, an Array object with elements of type String is used to represent a sequence<DOMString>, while an Array with elements of type Number represents a sequence<double>. The Array objects are effectively passed by value; every time the getSupportedImageCodecs() function is called a new Array is returned, and whenever an Array is passed to drawPolygon no reference will be kept after the call completes.
/* `Canvas^T の~instanceを得る。 `getSupportedImageCodecs()^M は、 2 個の `DOMString^T 値 `image/png^l, `image/svg+xml^l からなる連列を返すものとする。 ◎ Obtain an instance of Canvas. Assume that getSupportedImageCodecs() returns a sequence with two DOMString values: "image/png" and "image/svg+xml". */ var %canvas = getCanvas(); /* 長さ 2 の `Array^jt ~obj。 ◎ An Array object of length 2. */ var %supportedImageCodecs = %canvas.getSupportedImageCodecs(); /* `image/png^l に評価される。 ◎ Evaluates to "image/png". */ %supportedImageCodecs[0]; /* %canvas`.getSupportedImageCodecs()^c が~callされる度に,新たな `Array^jt object が返される。 したがって,返された `Array^jt を改変しても,後続の関数~callで返される値には影響しないことになる。 ◎ Each time canvas.getSupportedImageCodecs() is called, it returns a new Array object. Thus modifying the returned Array will not affect the value returned from a subsequent call to the function. */ %supportedImageCodecs[0] = `image/jpeg^l; /* */ %canvas.getSupportedImageCodecs()[0]; /* 各~callで新たな `Array^jt ~objが返されるので、これは `false^jv に評価される。 ◎ This evaluates to false, since a new Array object is returned each call. */ %canvas.getSupportedImageCodecs() == %canvas.getSupportedImageCodecs(); /* 実数~値の `Array^jt は... ◎ An Array of Numbers... */ var %a = [0, 0, 100, 0, 50, 62.5]; /* ...は `sequence<double>^T を期待する~platform~objに渡すことができる ◎ ...can be passed to a platform object expecting a sequence<double>. */ %canvas.drawPolygon(%a); /* 各~要素は最初に `ToNumber$A() の~callにより, `double^T に変換される。 したがって,次の~callは `drawPolygon()^M が返る前に `hi^l が alert されることを除き,前のものと等価になる。 ◎ Each element will be converted to a double by first calling ToNumber(). So the following call is equivalent to the previous one, except that "hi" will be alerted before drawPolygon() returns. */ %a = [ false, '', { valueOf: function() { alert('hi'); return 100; } }, 0, '50', new Number(62.5) ]; %canvas.drawPolygon(%a); /* `Array^jt は実質的に値渡しなので,`drawPolygon()^M に渡された `Array^jt を改変しても, `Canvas^T には効果を及ぼさないことが保証される。 ◎ Modifying an Array that was passed to drawPolygon() is guaranteed not to have an effect on the Canvas, since the Array is effectively passed by value. */ %a[4] = 20; var %b = %canvas.getLastDrawnPolygon(); alert(%b[4]); /* これは `50^l を alert することになる。 ◎ This would alert "50". */
3.2.20. ~record — ~record_KV
~IDL `record$T 値は、~ES `Object^jt 値により表現される。 ◎ IDL record<K, V> values are represented by ECMAScript Object values.
次の~algoにより,~ES値 %O は `~record_KV$ 型の`~IDL値に変換-$される: ◎ An ECMAScript value O is converted to an IDL record<K, V> value as follows:
- ~IF[ `Type$A( %O ) ~NEQ `Object^jt ] ⇒ ~throwTypeError ◎ If Type(O) is not Object, throw a TypeError.
- %result ~LET 新たな空の`~record_KV$ 値 ◎ Let result be a new empty instance of record<K, V>.
- %keys ~LET ? %O.`OwnPropertyKeys^sl() ◎ Let keys be ? O.[[OwnPropertyKeys]]().
-
%keys 内の ~EACH( %key ) に対し: ◎ For each key of keys:
- %記述子 ~LET ? %O.`GetOwnProperty^sl( %key ) ◎ Let desc be ? O.[[GetOwnProperty]](key).
-
~IF[ %記述子 ~NEQ `undefined^jv ]~AND[ %記述子.`Enumerable^sl ~EQ `true^jv ]: ◎ If desc is not undefined and desc.[[Enumerable]] is true:
- %typedKey ~LET %key を %K 型の`~IDL値に変換-$した結果 ◎ Let typedKey be key converted to an IDL value of type K.
- %value ~LET ? `Get$A( %O, %key) ◎ Let value be ? Get(O, key).
- %typedValue ~LET %value を %V 型の`~IDL値に変換-$した結果 ◎ Let typedValue be value converted to an IDL value of type V.
-
%result[%typedKey] ~SET %typedValue ◎ Set result[typedKey] to typedValue.
注記: %O が~proxy~objである場合、 %typedKey は,すでに %result 内にあり得る。 ◎ Note: it’s possible that typedKey is already in result, if O is a proxy object.
- ~RET %result ◎ Return result.
次の~algoにより,~IDL `record$T 値 %D は`~ES値に変換-$される: ◎ An IDL record<…> value D is converted to an ECMAScript value as follows:
- %result ~LET ! `ObjectCreate$A( `ObjectPrototype$jI ) ◎ Let result be ! ObjectCreate(%ObjectPrototype%).
-
%D 内の ~EACH( %key → %value ) に対し: ◎ For each key → value of D:
- %esKey ~LET %key を`~ES値に変換-$した結果 ◎ Let esKey be key converted to an ECMAScript value.
- %esValue ~LET %value を`~ES値に変換-$した結果 ◎ Let esValue be value converted to an ECMAScript value.
- %created ~LET ! `CreateDataProperty$A( %result, %esKey, %esValue ) ◎ Let created be ! CreateDataProperty(result, esKey, esValue).
- ~Assert: %created ~EQ `true^jv ◎ Assert: created is true.
- ~RET %result ◎ Return result.
`record<DOMString, double>^T 型の引数として~ES値 `{b: 3, a: 4}^jv を渡した結果は、~IDL値 «[ `b^l → 3, `a^l → 4 ]» になる。 ◎ Passing the ECMAScript value {b: 3, a: 4} as a record<DOMString, double> argument would result in the IDL value «[ "b" → 3, "a" → 4 ]».
~recordが考慮するのは,自前の列挙-可能な~prop — own enumerable ~prop — に限られるので、引数を返すだけの~IDL演算 `record<DOMString, double>^T identity(`record<DOMString, double>^T %arg) が与えられたとき、次の~codeは 各~表明( `assert^c )に合格する: ◎ Records only consider own enumerable properties, so given an IDL operation record<DOMString, double> identity(record<DOMString, double> arg) which returns its argument, the following code passes its assertions:
let %proto = {a: 3, b: 4}; let %obj = {__proto__: proto, d: 5, c: 6} Object.defineProperty(%obj, "e", {value: 7, enumerable: false}); let %result = identity(%obj); console.assert(%result.a === undefined); console.assert(%result.b === undefined); console.assert(%result.e === undefined); let %entries = Object.entries(%result); console.assert(%entries[0][0] === "d"); console.assert(%entries[0][1] === 5); console.assert(%entries[1][0] === "c"); console.assert(%entries[1][1] === 6);
~recordの[ ~key, 値 ]は、他から拘束され得る — ~keyは、 3 種の文字列~型に拘束されるに過ぎないが。 例えば: ◎ Record keys and values can be constrained, although keys can only be constrained among the three string types. The following conversions have the described results:
渡された値◎ Value | 値が渡された型◎ Passed to type | 結果◎ Result |
---|---|---|
`{"😞": 1}^jv | `record<ByteString, double>^T | `TypeError^jE |
`{"\uD83D": 1}^jv | `record<USVString, double>^T | «[ `\uFFFD^l → 1 ]» |
`{"\uD83D": {hello: "world"}}^jv | `record<DOMString, double>^T | «[ `\uD83D^l → 0 ]» |
3.2.21. ~promise型 — ~promise_T
~IDL`~promise型$値は、~ES `Promise$jt ~objにより表現される。 ◎ IDL promise type values are represented by ECMAScript Promise objects.
次の~algoにより,~ES値 %V は `~promise_T$ 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL Promise<T> value as follows:
- %promise ~LET ! `Call$A(`Promise_resolve$jI, `Promise$jI, « %V » ) ◎ Let promise be ! Call(%Promise_resolve%, %Promise%, «V»).
- ~RET %promise と同じ~objへの参照である~IDL`~promise型$値 ◎ Return the IDL promise type value that is a reference to the same object as promise.
~IDL`~promise型$値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Promise$jt 値になる。 ◎ The result of converting an IDL promise type value to an ECMAScript value is the Promise value that represents a reference to the same object that the IDL promise type represents.
~promiseが決着したとき、すなわち,それが[ 充足された, または却下された ]とき、それぞれに応じて,何らかの手続きが遂行され得る — そのいずれかは省略され得る 【これらの手続きは、~promiseを利用する仕様が指定する】 。 仕様にて `~promiseが決着したときの手続きを遂行する@ と記された所では、次の手続きに従わ~MUST: ◎ One can perform some steps once a promise is settled. There can be one or two sets of steps to perform, covering when the promise is fulfilled, rejected, or both. When a specification says to perform some steps once a promise is settled, the following steps must be followed:
- %promise ~LET 型 `~promise_T$ の~promise~obj ◎ Let promise be the promise object of type Promise<T>.
-
%onFulfilled ~LET 被呼出時の挙動が次で与えられる,新たな`組込みの関数~obj$ ◎ Let onFulfilled be a new built-in function object whose behavior when invoked is as follows:
-
~IF[ %T は `void$T 型である ]: ◎ If T is void, then:
- ~RET ~promiseの充足-時に走らすことが要求されている手続きを遂行した結果 ◎ Return the result of performing any steps that were required to be run if the promise was fulfilled.
-
~ELSE : ◎ Otherwise, T is a type other than void:
- %V ~LET %onFulfilled に渡された 1 個目の引数 ◎ Let V be the first argument to onFulfilled.
- %value ~LET %V を型 %T の`~IDL値に変換-$した結果 ◎ Let value be the result of converting V to an IDL value of type T.
- ~IF[ ~promiseの充足-時に走らすことが要求されている手続きはある ] ⇒ ~RET ~promiseの値として %value を渡して,その手続きを遂行した結果 ◎ If there are no steps that are required to be run if the promise was fulfilled, then return undefined. ◎ Otherwise, return the result of performing any steps that were required to be run if the promise was fulfilled, with value as the promise’s value.
- ~RET `undefined^jv ◎ ↑
-
-
%onRejected ~LET 被呼出時の挙動が次で与えられる,新たな`組込みの関数~obj$: ◎ Let onRejected be a new built-in function object whose behavior when invoked is as follows:
- %R ~LET %onRejected に渡された 1 個目の引数 ◎ Let R be the first argument to onRejected.
- %reason ~LET %R を `any$T 型の`~IDL値に変換-$した結果 ◎ Let reason be the result of converting R to an IDL value of type any.
- ~IF[ ~promiseの却下-時に走らすことが要求されている手続きはある ] ⇒ ~RET 却下~事由として %reason を渡して,その手続きを遂行した結果 ◎ If there are no steps that are required to be run if the promise was rejected, then return undefined. ◎ Otherwise, return the result of performing any steps that were required to be run if the promise was rejected, with reason as the rejection reason.
- ~RET `undefined^jv ◎ ↑
- %then ~LET ? `GetMethod$A( %promise, `then^l ) ◎ Let then be ? GetMethod(promise, "then").
- ~IF[ %then ~EQ `undefined^jv ] ⇒ ~throwTypeError ◎ If then is undefined, then throw a TypeError.
- ~RET `Call$A( %then, « %onFulfilled, %onRejected » ) ◎ Return Call(then, promise, «onFulfilled, onRejected»).
この用語を用いて仕様を書く例を含める必要がある。 ◎ Include an example of how to write spec text using this term.
3.2.22. 共用体~型
~IDL`共用体~型$の値は、共用体の`~mb型$に対応する~ES値により表現される。 ◎ IDL union type values are represented by ECMAScript values that correspond to the union’s member types.
次の~algoにより,~ES値 %V は `共用体~型$ %U の`~IDL値に変換-$される: ◎ To convert an ECMAScript value V to an IDL union type value is done as follows:
- ~IF[ %V ~IN { `null^jv, `undefined^jv } ]~AND[ %U は`~nullable型を内包する$ ] ⇒ ~RET ~IDL値 `null^V ◎ If the union type includes a nullable type and V is null or undefined, then return the IDL value null.
- %型たち ~LET %U の`平坦化~mb型$ ◎ Let types be the flattened member types of the union type.
-
~IF[ %V ~IN { `null^jv, `undefined^jv } ]: ◎ If V is null or undefined, then:
- ~IF[ %型たち に`辞書~型$が含まれている ] ⇒ ~RET %V をその辞書~型の`~IDL値に変換-$した結果 ◎ If types includes a dictionary type, then return the result of converting V to that dictionary type.
-
~IF[ %V は `~platform~obj$である ]: ◎ If V is a platform object, then:
- ~IF[ %型たち に %V が実装する`~ifc型$が含まれている ] ⇒ ~RET ~obj %V への参照である~IDL値 ◎ If types includes an interface type that V implements, then return the IDL value that is a reference to the object V.
- ~IF[ %型たち に `object$T が含まれている ] ⇒ ~RET ~obj %V への参照である~IDL値 ◎ If types includes object, then return the IDL value that is a reference to the object V.
-
~IF[ %V は `DOMException^T ~platform~objである ]: ◎ If V is a DOMException platform object, then:
- ~IF[ %型たち に `DOMException$T または `Error$T が含まれている ] ⇒ ~RET %V を その型の`~IDL値に変換-$した結果 ◎ If types includes DOMException or Error, then return the result of converting V to that type.
- %型 ~LET `Type$A( %V ) ◎ ↓
-
~IF[ %型 ~EQ `Object^jt ]~AND[ %V は `ErrorData^sl `内部~slot$を持つ ]: ◎ If Type(V) is Object and V has an [[ErrorData]] internal slot), then:
- ~IF[ %型たち に `Error$T が含まれている ] ⇒ ~RET %V を `Error$T 型の`~IDL値に変換-$した結果 ◎ If types includes Error, then return the result of converting V to Error.
-
~IF[ %型 ~EQ `Object^jt ]~AND[ %V は `ArrayBufferData^sl `内部~slot$を持つ ]: ◎ If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then:
- ~IF[ %型たち に `ArrayBuffer$T が含まれている ] ⇒ ~RET %V を `ArrayBuffer$T 型の`~IDL値に変換-$した結果 ◎ If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
-
~IF[ %型 ~EQ `Object^jt ]~AND[ %V は `DataView^sl `内部~slot$を持つ ]: ◎ If Type(V) is Object and V has a [[DataView]] internal slot, then:
- ~IF[ %型たち に `DataView$T が含まれている ] ⇒ ~RET %V を `DataView$T 型の`~IDL値に変換-$した結果 ◎ If types includes DataView, then return the result of converting V to DataView.
-
~IF[ %型 ~EQ `Object^jt ]~AND[ %V は `TypedArrayName^sl `内部~slot$を持つ ]: ◎ If Type(V) is Object and V has a [[TypedArrayName]] internal slot, then:
- ~IF[ %型たち に[ `有型~配列~型$であって,[ その型~名 ~EQ %V の `TypedArrayName^sl `内部~slot$の値 ]なるもの ]が含まれている ] ⇒ ~RET %V をその型の`~IDL値に変換-$した結果 ◎ If types includes a typed array type whose name is the value of V’s [[TypedArrayName]] internal slot, then return the result of converting V to that type.
-
~IF[ `IsCallable$A( %V ) ~EQ ~T ]: ◎ If IsCallable(V) is true, then:
- ~IF[ %型たち に`呼戻~関数$型が含まれている ] ⇒ ~RET %V をその呼戻~関数~型の`~IDL値に変換-$した結果 ◎ If types includes a callback function type, then return the result of converting V to that callback function type.
-
~IF[ %型 ~EQ `Object^jt ]: ◎ If Type(V) is Object, then:
-
~IF[ %型たち に`連列~型$が含まれている ]: ◎ If types includes a sequence type, then
- ~IF[ %method ~NEQ `undefined^jv ] ⇒ ~RET ( %V, %method ) から その型の`連列~値を作成-$した結果 ◎ If method is not undefined, return the result of creating a sequence of that type from V and method.
-
~IF[ %型たち に`凍結~配列~型$が含まれている ]: ◎ If types includes a frozen array type, then
- ~IF[ %method ~NEQ `undefined^jv ] ⇒ ~RET ( %V, %method ) から その型の`凍結~配列~値を作成-$した結果 ◎ If method is not undefined, return the result of creating a frozen array of that type from V and method.
- ~IF[ %型たち に`辞書~型$が含まれている ] ⇒ ~RET %V をその型の`~IDL値に変換-$した結果 ◎ If types includes a dictionary type, then return the result of converting V to that dictionary type.
- ~IF[ %型たち に`~record型$が含まれている ] ⇒ ~RET %V をその型の`~IDL値に変換-$した結果 ◎ If types includes a record type, then return the result of converting V to that record type.
- ~IF[ %型たち に`呼戻~ifc$型が含まれている ] ⇒ ~RET %V をその型の`~IDL値に変換-$した結果 ◎ If types includes a callback interface type, then return the result of converting V to that interface type.
-
-
~IF[ %型 ~EQ `Boolean^jt ]: ◎ If Type(V) is Boolean, then:
- ~IF[ %型たち に `boolean$T が含まれている ] ⇒ ~RET %V を `boolean$T 型の`~IDL値に変換-$した結果 ◎ If types includes a boolean, then return the result of converting V to boolean.
-
~IF[ %型 ~EQ `Number^jt ]: ◎ If Type(V) is Number, then:
- ~IF[ %型たち に`実数~型$が含まれている ] ⇒ ~RET %V をその`実数~型$の`~IDL値に変換-$した結果 ◎ If types includes a numeric type, then return the result of converting V to that numeric type.
- ~IF[ %型たち に`文字列~型$が含まれている ] ⇒ ~RET %V をその型の`~IDL値に変換-$した結果 ◎ If types includes a string type, then return the result of converting V to that type.
~IDL共用体~型の値 %U は,次に従って`~ES値に変換-$される: ◎ An IDL union type value is converted to an ECMAScript value as follows.
- %U が[ ~ES `undefined^jv 値を表現する特別な~objへの `object$T 参照 ]ならば、~ES `undefined^jv 値に変換される。 ◎ If the value is an object reference to a special object that represents an ECMAScript undefined value, then it is converted to the ECMAScript undefined value.\
- 他の場合、この`es-type-mapping$secにて述べている, %U の`特有~型$を変換するための規則に従う。 ◎ Otherwise, the rules for converting the specific type of the IDL union type value as described in this section (§3.2 ECMAScript type mapping).
3.2.23. `Error^T
~IDL `Error$T 値は、[ ~native~ES `Error$jt ~obj / `DOMException$T ~platform~obj ]により表現される。 ◎ IDL Error values are represented by native ECMAScript Error objects and by DOMException platform objects.
次の~algoにより,~ES値 %V は `Error$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL Error value by running the following algorithm:
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ]~OR[ %V は `ErrorData^sl `内部~slot$を持たない ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, or V does not have an [[ErrorData]] internal slot, then throw a TypeError.
- ~RET %V と同じ~objへの参照である~IDL `Error$T 値 ◎ Return the IDL Error value that is a reference to the same object as V.
~IDL `Error$T 値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Error$jt 値になる。 ◎ The result of converting an IDL Error value to an ECMAScript value is the Error value that represents a reference to the same object that the IDL Error represents.
3.2.24. `DOMException^T
~IDL `DOMException$T 値は、~ES `Object^jt 値により表現される。 ◎ IDL DOMException values are represented by ECMAScript Object values.
次の~algoにより,~ES値 %V は `DOMException$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL DOMException value by running the following algorithm:
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ]~OR[ %V は `DOMException$T を表現する~platform~objでない ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, or V is not a platform object that represents a DOMException, then throw a TypeError.
- ~RET %V と同じ~objへの参照である~IDL `DOMException$T 値 ◎ Return the IDL DOMException value that is a reference to the same object as V.
~IDL `DOMException$T 値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Object^jt 値になる。 ◎ The result of converting an IDL DOMException value to an ECMAScript value is the Object value that represents a reference to the same object that the IDL DOMException represents.
3.2.25. ~buffer~source型
~IDL`~buffer~source型$の値は、対応する~ES~classの~objにより表現され,~ES[ `ArrayBuffer$jt / `SharedArrayBuffer$jt ]~objに~backされ得るが、後者に~backできるのは,当の型に `AllowShared$x `拡張属性が結付けられ$ている場合に限られる。 ◎ Values of the IDL buffer source types are represented by objects of the corresponding ECMAScript class, with the additional restriction that unless the type is associated with the [AllowShared] extended attribute, they can only be backed by ECMAScript ArrayBuffer objects, and not SharedArrayBuffer objects.
次の~algoにより,~ES値 %V は `ArrayBuffer$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL ArrayBuffer value by running the following algorithm:
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ]~OR[ %V は `ArrayBufferData^sl `内部~slot$を持たない ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, or V does not have an [[ArrayBufferData]] internal slot, then throw a TypeError.
- ~IF[ `AllowShared$x `拡張属性が結付けられ$ている~IDL型への変換でない ]~AND[ `IsSharedArrayBuffer$A( %V ) ~EQ `true^jv ] ⇒ ~throwTypeError ◎ If the conversion is not to an IDL type associated with the [AllowShared] extended attribute, and IsSharedArrayBuffer(V) is true, then throw a TypeError.
- ~RET %V と同じ~objへの参照である~IDL `ArrayBuffer$T 値 ◎ Return the IDL ArrayBuffer value that is a reference to the same object as V.
次の~algoにより,~ES値 %V は `DataView$T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL DataView value by running the following algorithm:
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ]~OR[ %V は `DataView^sl `内部~slot$を持たない ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, or V does not have a [[DataView]] internal slot, then throw a TypeError.
- ~RET %V と同じ~objへの参照である~IDL `DataView$T 値 ◎ Return the IDL DataView value that is a reference to the same object as V.
%T をいずれかの`有型~配列~型$とするとき、次の~algoにより,~ES値 %V は %T 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL Int8Array, Int16Array, Int32Array, Uint8Array, Uint16Array, Uint32Array, Uint8ClampedArray, Float32Array or Float64Array value by running the following algorithm:
- %有型~配列~名 ~LET [ %T は`注釈付きの型$であるならば %T の`内縁~型$anOの`型~名$ / ~ELSE_ %T の`型~名$ ] ◎ Let T be the IDL type V is being converted to. ◎ Let typedArrayName be the name of T’s inner type if T is an annotated type, or the name of T otherwise.
- ~IF[ `Type$A( %V ) ~NEQ `Object^jt ]~OR[ %V は `TypedArrayName^sl `内部~slot$を持たない ]~OR[ %V の `TypedArrayName^sl `内部~slot$の値 ~NEQ %有型~配列~名 ] ⇒ ~throwTypeError ◎ If Type(V) is not Object, or V does not have a [[TypedArrayName]] internal slot with a value equal to typedArrayName, then throw a TypeError.
- ~RET %V と同じ~objへの参照である~IDL %T 型~値 ◎ Return the IDL value of type T that is a reference to the same object as V.
いずれの`~buffer~source型$に対しても、その型の~IDL値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Object^jt 値になる。 ◎ The result of converting an IDL value of any buffer source type to an ECMAScript value is the Object value that represents a reference to the same object that the IDL value represents.
~buffer~source %O は[ ~ES[ `ArrayBuffer$jt / `DataView$jt ] / `有型~配列~型$ ]~objであるとする。 %O に保持されている~byte列の`参照/複製を取得-$するときは、次の手続きに従わ~MUST: ◎ When getting a reference to or getting a copy of the bytes held by a buffer source that is an ECMAScript ArrayBuffer, DataView or typed array object, these steps must be followed:
- %arrayBuffer ~LET %O ◎ Let O be the ECMAScript object that is the buffer source. ◎ Initialize arrayBuffer to O.
- %offset ~LET 0 ◎ Initialize offset to 0.
- %長さ ~LET 0 ◎ Initialize length to 0.
-
~IF[ %O は `ViewedArrayBuffer^sl `内部~slot$を持つ ]: ◎ If O has a [[ViewedArrayBuffer]] internal slot, then:
- %arrayBuffer ~SET %O の `ViewedArrayBuffer^sl `内部~slot$の値 ◎ Set arrayBuffer to the value of O’s [[ViewedArrayBuffer]] internal slot.
- ~IF[ %arrayBuffer ~EQ `undefined^jv ] ⇒ ~throwTypeError ◎ If arrayBuffer is undefined, then throw a TypeError.
- %offset ~SET %O の `ByteOffset^sl `内部~slot$の値 ◎ Set offset to the value of O’s [[ByteOffset]] internal slot.
- %長さ ~SET %O の `ByteLength^sl `内部~slot$の値 ◎ Set length to the value of O’s [[ByteLength]] internal slot.
- ~ELSE %長さ ~SET %O の `ArrayBufferByteLength^sl `内部~slot$の値 ◎ Otherwise, set length to the value of O’s [[ArrayBufferByteLength]] internal slot.
- ~IF[ `IsDetachedBuffer$A( %O ) ] ⇒ ~throwTypeError ◎ If IsDetachedBuffer(O), then throw a TypeError.
- %data ~LET %O の `ArrayBufferData^sl `内部~slot$の値 ◎ Let data be the value of O’s [[ArrayBufferData]] internal slot.
- ~RET [ %data 内の~byte~offset %offset の所から, %長さ 個の~byte ][ への参照, または の複製 ](いずれか要求された方)。 ◎ Return a reference to or copy of (as required) the length bytes in data starting at byte offset offset.
`ArrayBuffer$T ~objを `切離す@ ときは、次の手続きに従わ~MUST: ◎ To detach an ArrayBuffer, these steps must be followed:
- %O ~LET その `ArrayBuffer$T である~ES~obj ◎ Let O be the ECMAScript object that is the ArrayBuffer.
- ! `DetachArrayBuffer$A( %O ) ◎ Perform ! DetachArrayBuffer(O).
3.2.26. 凍結~配列 — ~FrozenArray_T
`凍結~配列~型$の値は、~~凍結された( `frozen^en )~ES `Array^jt ~obj参照により表現される。 ◎ Values of frozen array types are represented by frozen ECMAScript Array object references.
次の~algoにより,~ES値 %V は `~FrozenArray_T$ 型の`~IDL値に変換-$される: ◎ An ECMAScript value V is converted to an IDL FrozenArray<T> value by running the following algorithm:
- %値~list ~LET %V を ~sequence_T 型の`~IDL値に変換-$した結果 ◎ Let values be the result of converting V to IDL type sequence<T>.
- ~RET %値~list から`凍結~配列を作成-$した結果 ◎ Return the result of creating a frozen array from values.
型 %T の値の連列 %S から `凍結~配列を作成-@ するときは、次の手続きに従う: ◎ To create a frozen array from a sequence of values of type T, follow these steps:
- %array ~LET %S を`~ES値に変換-$した結果 ◎ Let array be the result of converting the sequence of values of type T to an ECMAScript value.
- `SetIntegrityLevel$A( %array, `frozen^l ) ◎ Perform SetIntegrityLevel(array, "frozen").
- ~RET %array ◎ Return array.
~IDL `~FrozenArray_T$ 値 %V を`~ES値に変換-$した結果は、 %V が表現するものと同じ~objへの参照を表現する `Object^jt 値になる。 ◎ The result of converting an IDL FrozenArray<T> value to an ECMAScript value is the Object value that represents a reference to the same object that the IDL FrozenArray<T> represents.
3.2.26.1. 可反復から凍結~配列を作成する
所与の ( 可反復 %iterable, 反復子~取得子 %method ) から 型 `~FrozenArray_T$ の~IDL値を作成するときは、次の手続きを遂行する: ◎ To create an IDL value of type FrozenArray<T> given an iterable iterable and an iterator getter method, perform the following steps:
- %値~list ~LET ( %iterable, %method ) から 型 %T の`連列~値を作成-$した結果 ◎ Let values be the result of creating a sequence of type sequence<T> from iterable and method.
- ~RET %値~list から`凍結~配列を作成-$した結果 ◎ Return the result of creating a frozen array from values.
3.3. ~ESに特有の拡張属性
この節では、その存在pが~ES言語束縛にのみ影響する,いくつかの`拡張属性$を定義する。 ◎ This section defines a number of extended attributes whose presence affects only the ECMAScript binding.
3.3.2. `Clamp^x
`Clamp$x `拡張属性$が`整数~型$に現れた場合、次に従ってふるまう,新たな型を作成する ⇒ ~ES `Number^jt 値がこの~IDL型へ変換される際には、範囲~外の値に対しては,範囲~内の最も近い妥当な値に切詰める — modulo 演算を利用する演算子( `ToInt32$A, `ToUint32$A, 等々)は利用せずに。 ◎ If the [Clamp] extended attribute appears on one of the integer types, it creates a new IDL type such that that when an ECMAScript Number is converted to the IDL type, out-of-range values will be clamped to the range of valid values, rather than using the operators that use a modulo operation (ToInt32, ToUint32, etc.).
`Clamp$x 拡張属性には、`引数をとらない$ことが要求される。 ◎ The [Clamp] extended attribute must take no arguments.
型 %T に `Clamp$x `拡張属性が結付けられ$るときは、次のすべてが満たされ~MUST:
- %T は、`読専$な属性に現れていない。
- %T には `EnforceRange$x `拡張属性が結付けられ$てはいない。
- %T は`整数~型$である。
`Clamp$x の利用に課される特有の要件については、 `es-integer-types$secの[ ~ES値から種々の~IDL整数~型へ変換する規則 ]を見よ。 ◎ See the rules for converting ECMAScript values to the various IDL integer types in §3.2.4 Integer types for the specific requirements that the use of [Clamp] entails.
次の`~IDL片$では,それぞれが 3 個の `octet$T 引数をとる, 2 個の`演算$が宣言される。 一方には 3 個すべての引数に `Clamp$x `拡張属性$が利用され,他方はそうでない: ◎ In the following IDL fragment, two operations are declared that take three octet arguments; one uses the [Clamp] extended attribute on all three arguments, while the other does not:
[Exposed=Window] interface GraphicsContext { void setColor(octet %red, octet %green, octet %blue); void setColorClamped([Clamp] octet %red, [Clamp] octet %green, [Clamp] octet %blue); };
`setColorClamped^M の~callに渡された, `octet$T の範囲~外の `Number^jt 値は、範囲 [0, 255] に切詰められる。 ◎ A call to setColorClamped with Number values that are out of range for an octet are clamped to the range [0, 255].
/* `GraphicsContext^T の~instanceを取得する。 ◎ Get an instance of GraphicsContext. */ var %context = getGraphicsContext(); /* 非 `Clamp^x 版の~callは実数~値を~octetに強制する ToUint8 を利用する。 ◎ Calling the non-[Clamp] version uses ToUint8 to coerce the Numbers to octets */ /* 次は `setColor(255, 255, 1)^c の~callと等価。 ◎ This is equivalent to calling setColor(255, 255, 1). */ %context.setColor(-1, 255, 257); /* 範囲~外の値を渡して `setColorClamped^M を~callする。 ◎ Call setColorClamped with some out of range values. */ /* 次は `setColorClamped(0, 255, 255)^c の~callと等価。 ◎ This is equivalent to calling setColorClamped(0, 255, 255). */ %context.setColorClamped(-1, 255, 257);
3.3.3. `Constructor^x
`Constructor$x `拡張属性$が `~ifc$上に現れた場合、その~ifc用の`~ifc~obj$は,[ その~ifcを実装する~objを構築できるようにする, `Construct^sl `内部~meth$ ]を持つことになる。 ◎ If the [Constructor] extended attribute appears on an interface, it indicates that the interface object for this interface will have an [[Construct]] internal method, allowing objects implementing the interface to be constructed.
同じ~ifc上に複数の `Constructor$x 拡張属性が現れてもよい。 ◎ Multiple [Constructor] extended attributes may appear on a given interface.
`Constructor$x 拡張属性には、[ `引数をとらない$ か, または `有名~引数~listを引数にとる$ ]ことが要求される。 略記形の前者 `[Constructor]^c は、引数~listが空にされた `[Constructor()]^c と同じ意味になる。 ~ifc上のそれぞれの `Constructor$x 拡張属性が、[ 指定された引数を渡して,その~ifcを実装する~objを構築する仕方 ]を~~供することになる。 ◎ The [Constructor] extended attribute must either take no arguments or take an argument list. The bare form, [Constructor], has the same meaning as using an empty argument list, [Constructor()]. For each [Constructor] extended attribute on the interface, there will be a way to construct an object that implements the interface by passing the specified arguments.
構築子の注釈文においては,[ `Constructor$x 拡張属性が現れる~ifcに対応する型の~IDL値を返すか, または 例外を投出する ]ように定義され~MUST。 ◎ The prose definition of a constructor must either return an IDL value of a type corresponding to the interface the [Constructor] extended attribute appears on, or throw an exception.
`Constructor$x 拡張属性は: ◎ ↓
- 同じ~ifc上で, `NoInterfaceObject$x 拡張属性と併用されては~MUST_NOT。 ◎ The [Constructor] and [NoInterfaceObject] extended attributes must not be specified on the same interface.
- `呼戻~ifc$上に利用されては~MUST_NOT。 ◎ The [Constructor] extended attribute must not be used on a callback interface.
ある~ifc用の構築子がどう実装されるかの詳細は、 `interface-object$sec を見よ。 ◎ See §3.6.1 Interface object for details on how a constructor for an interface is to be implemented.
次の~IDLは 2 つの~ifcを定義する。 2 個目のものには `Constructor$x 拡張属性がある一方, 1 個目のものにはない。 ◎ The following IDL defines two interfaces. The second has the [Constructor] extended attribute, while the first does not.
[Exposed=Window] interface NodeList { Node item(unsigned long %index); readonly attribute unsigned long length; }; [Exposed=Window, Constructor, Constructor(double %radius)] interface Circle { attribute double r; attribute double cx; attribute double cy; readonly attribute double circumference; };
これらの~ifcを~supportする~ES実装は、 `Circle^T ~ifc~obj上に,[ その~ifcを実装する新たな~obj ]を返す `Construct^sl ~propを持つことになる。 それは 0 個または 1 個の引数をとる。 `NodeList^T ~ifc~objは `Construct^sl ~propを持たないことになる。 ◎ An ECMAScript implementation supporting these interfaces would have a [[Construct]] property on the Circle interface object which would return a new object that implements the interface. It would take either zero or one argument. The NodeList interface object would not have a [[Construct]] property.
var %x = new Circle(); /* これは,引数なしの構築子を利用して、 `Circle^T ~ifcを実装する~platform~objへの参照を作成する。 ◎ The uses the zero-argument constructor to create a reference to a platform object that implements the Circle interface. */ var %y = new Circle(1.25); /* 今度は 1 個の引数をとる構築子を利用して `Circle^T ~objを作成する。 ◎ This also creates a Circle object, this time using the one-argument constructor. */ var %z = new NodeList(); /* `Constructor^x が宣言されていないので `TypeError^jE が投出されることになる。 ◎ This would throw a TypeError, since no [Constructor] is declared. */
3.3.4. `Default^x
`Default$x `拡張属性$が`正則~演算$上に現れた場合、[ その演算が呼出されたときには,`対応する既定の演算$に述べられる手続きが行われ~MUST ]ことを指示する。 ◎ If the [Default] extended attribute appears on a regular operation, then it indicates that steps described in the corresponding default operation must be carried out when the operation is invoked.
`Default$x 拡張属性は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [Default] extended attribute must take no arguments.
- 次のもの以外に利用されては~MUST_NOT ⇒ `正則~演算$であって,`対応する既定の演算$が定義されているもの ◎ The [Default] extended attribute must not be used on anything other than a regular operation for which a corresponding default operation has been defined.
例として、 `Default$x 拡張属性は,~toJSON`正則~演算$の利用に相応しくなる: ◎ As an example, the [Default] extended attribute is suitable for use on toJSON regular operations:
[Exposed=Window] interface Animal { attribute DOMString name; attribute unsigned short age; [Default] object toJSON(); }; [Exposed=Window] interface Human : Animal { attribute Dog? pet; [Default] object toJSON(); }; [Exposed=Window] interface Dog : Animal { attribute DOMString? breed; };
~ES言語束縛においては、 `toJSON()^M ~methは, `Animal^T, `Human^T ~obj上に, および 継承を介して `Dog^T ~obj上にも存在することになる: ◎ In the ECMAScript language binding, there would exist a toJSON() method on Animal, Human, and (via inheritance) Dog objects:
/* `Human^T の~instanceを取得する ◎ Get an instance of Human. */ var %alice = getHuman(); /* 次の様な~objに評価される(この時点で, `Dog^T の~instanceは依然として `pet^l を保持することに注意): ◎ Evaluates to an object like this (notice how "pet" still holds an instance of Dog at this point): */ { name: "Alice", age: 59, pet: Dog } */ %alice.toJSON(); /* 次の様な~objに評価される( `Dog^T ~ifcは既定の~toJSON演算を宣言していないので, `breed^l は~~不在になることに注意): ◎ Evaluates to an object like this (notice how "breed" is absent, as the Dog interface doesn’t declare a default toJSON operation): */ { name: "Tramp", age: 6 } */ %alice.pet.toJSON(); /* 次の様な文字列に評価される: ◎ Evaluates to a string like this: */ '{"name":"Alice","age":59,"pet":{"name":"Tramp","age":6}}' */ JSON.stringify(%alice);
3.3.5. `EnforceRange^x
`EnforceRange$x `拡張属性$が`整数~型$に現れた場合、次に従ってふるまう,新たな型を作成する ⇒ ~ES `Number^jt 値をこの~IDL型へ変換する際には、 0 側に丸めた結果が範囲~外になる値に対しては,例外を投出する — modulo 演算を利用する演算子( `ToInt32$A, `ToUint32$A, 等々)は利用せずに。 ◎ If the [EnforceRange] extended attribute appears on one of the integer types, it creates a new IDL type such that that when an ECMAScript Number is converted to the IDL type, out-of-range values will cause an exception to be thrown, rather than being converted to a valid value using using the operators that use a modulo operation (ToInt32, ToUint32, etc.). The Number will be rounded toward zero before being checked against its range.
`EnforceRange$x 拡張属性には、`引数をとらない$ことが要求される。 ◎ The [EnforceRange] extended attribute must take no arguments.
型 %T に `EnforceRange$x `拡張属性が結付けられ$るときは、次のすべてが満たされ~MUST:
- %T は、`読専$な属性に現れていない。
- %T には `Clamp$x `拡張属性が結付けられ$ていない。
- %T は`整数~型$である。
`EnforceRange$x の利用に課される特有の要件については、 `es-type-mapping$secの[ ~ES値から種々の~IDL整数~型へ変換する規則 ]を見よ。 ◎ See the rules for converting ECMAScript values to the various IDL integer types in §3.2 ECMAScript type mapping for the specific requirements that the use of [EnforceRange] entails.
次の`~IDL片$では,それぞれが 3 個の `octet$T 引数をとる, 2 個の`演算$が宣言される。 一方には 3 個すべての引数に `EnforceRange$x `拡張属性$が利用され,他方はそうでない: ◎ In the following IDL fragment, two operations are declared that take three octet arguments; one uses the [EnforceRange] extended attribute on all three arguments, while the other does not:
[Exposed=Window] interface GraphicsContext { void setColor(octet %red, octet %green, octet %blue); void setColorEnforcedRange([EnforceRange] octet %red, [EnforceRange] octet %green, [EnforceRange] octet %blue); };
この~IDLの~ES実装においては、 `octet$T の範囲~外の `Number^jt 値を渡して `setColorEnforcedRange^M を~callしたときの結果は、例外の投出になる。 ◎ In an ECMAScript implementation of the IDL, a call to setColorEnforcedRange with Number values that are out of range for an octet will result in an exception being thrown.
/* `GraphicsContext^T の~instanceを取得する。 ◎ Get an instance of GraphicsContext. */ var %context = getGraphicsContext(); /* 非 `EnforceRange^x 版の~callは実数~値を~octetに強制する ToUint8 を利用する。これは `setColor(255, 255, 1)^c の~callと等価になる。 ◎ Calling the non-[EnforceRange] version uses ToUint8 to coerce the Numbers to octets. This is equivalent to calling setColor(255, 255, 1). */ %context.setColor(-1, 255, 257); /* 実数~値は `setColorEnforcedRange^M が~callされる際に 0 側に丸められる。 これは `setColor(0, 255, 255)^c の~callと等価になる。 ◎ When setColorEnforcedRange is called, Numbers are rounded towards zero. This is equivalent to calling setColor(0, 255, 255). */ %context.setColorEnforcedRange(-0.9, 255, 255.2); /* 次は `TypeError^jE を投出させる。丸められた後でも, 1 個目, 3 個目の引数は範囲~外になるので。 ◎ The following will cause a TypeError to be thrown, since even after rounding the first and third argument values are out of range. */ %context.setColorEnforcedRange(-1, 255, 256);
3.3.6. `Exposed^x
`Exposed$x `拡張属性$が,次に挙げる構成子に現れたときは、その構成子が[ 拡張属性の引数により指定される,大域~ifc【 `Global$x が指定された~ifc】の集合 ]上に公開されることを指示する ⇒# `~ifc$ / `部分的~ifc$ / `~ifc~mixin$ / `部分的~ifc~mixin$ / `~ns$ / `部分的~ns$ / 個々の`~ifc~mb$ / 個々の`~ifc~mixin~mb$ / 個々の`~ns~mb$ ◎ When the [Exposed] extended attribute appears on an interface, partial interface, interface mixin, partial interface mixin, namespace, partial namespace, or an individual interface member, interface mixin member, or namespace member, it indicates that the construct is exposed on that particular set of global interfaces.
`Exposed$x `拡張属性$には、[ `識別子を引数にとる$か, または `識別子~listを引数にとる$ ]ことが要求される。 挙げられた各~識別子は、引数~内で一意, かつ`大域~名$で~MUST。 これらの識別子が成す~listは、当の構成子の `自前の公開~集合@ と呼ばれる。 ◎ The [Exposed] extended attribute must either take an identifier or take an identifier list. Each of the identifiers mentioned must be a global name and be unique. This list of identifiers is known as the construct’s own exposure set.
所与の構成子 %C の `公開~集合@ を取得するときは、次の手続きを走らす: ◎ To get the exposure set of a construct C, run the following steps:
- ~Assert: %C は[ `~ifc$ / `~ns$ / `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ]である。 ◎ Assert: C is an interface, namespace, interface member, interface mixin member, or namespace member.
- %H ~LET [ %C は`~ifc~mixin~mb$ならば %C の`~host~ifc$ / ~ELSE_ ε ] ◎ Let H be C’s host interface if C is an interface mixin member, or null otherwise.
- %E ~LET [ %H ~NEQ ε ならば %H の`公開~集合$ / ~ELSE_ すべての大域~ifcからなる集合 ] ◎ ↓
-
~IF[ %C は[ `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ]である ]: ◎ If C is an interface member, interface mixin member, or namespace member, then:
- ~IF[ %C 上に `Exposed$x `拡張属性$は指定されている ] ⇒ ~RET `交差集合$( %C の`自前の公開~集合$, %E ) ◎ If the [Exposed] extended attribute is specified on C, then: • If H is set, return the intersection of C’s own exposure set and H’s exposure set. • Otherwise, return C’s own exposure set.
- %C ~SET %C を宣言している[ `~ifc$ / `部分的~ifc$ / `~ifc~mixin$ / `部分的~ifc~mixin$ / `~ns$ / `部分的~ns$ ] ◎ Otherwise, set C to be the interface, partial interface, interface mixin, partial interface mixin, namespace, or partial namespace C is declared on.
-
~IF[ %C は[ `部分的~ifc$ / `部分的~ifc~mixin$ / `部分的~ns$ ]である ]: ◎ If C is a partial interface, partial interface mixin, or partial namespace, then:
- ~IF[ %C 上に `Exposed$x `拡張属性$は指定されている ] ⇒ ~RET `交差集合$( %C の`自前の公開~集合$, %E ) ] ◎ If the [Exposed] extended attribute is specified on C, then: • If H is set, return the intersection of C’s own exposure set and H’s exposure set. • Otherwise, return C’s own exposure set.
- %C ~SET %C の元の[ `~ifc$ / `~ifc~mixin$ / `~ns$ ]定義 ◎ Otherwise, set C to be the original interface, interface mixin, or namespace definition of C.
-
~IF[ %C は`~ifc~mixin$である ]: ◎ If C is an interface mixin, then:
- ~IF[ %C 上に `Exposed$x `拡張属性$は指定されている ] ⇒ ~RET `交差集合$( %C の`自前の公開~集合$, %E ) ◎ If the [Exposed] extended attribute is specified on C, then return the intersection of C’s own exposure set and H’s exposure set.
- ~ELSE ⇒ %C ~SET %H ◎ Otherwise, set C to H.
- ~Assert: %C は[ `~ifc$ / `~ns$ ]である ◎ Assert: C is a interface or namespace.
- ~Assert: %C 上に `Exposed$x `拡張属性$は指定されている ◎ Assert: The [Exposed] extended attribute is specified on C.
- ~RET %C の`自前の公開~集合$ ◎ Return C’s own exposure set.
`Exposed$x 拡張属性は: ◎ ↓
- `多重定義$された ある`演算$に現れた場合、その多重定義を成す他のすべての演算にも現れ~MUST。 ◎ If [Exposed] appears on an overloaded operation, then it must appear identically on all overloads.
-
[ `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ], および それを宣言している[ `部分的~ifc$ / `部分的~ifc~mixin$ / `部分的~ns$ ]定義の両者に指定されては~MUST_NOT。 ◎ The [Exposed] extended attribute must not be specified both on an interface, mixin, or namespace member, and on the partial interface, partial interface mixin, or partial namespace definition the member is declared on.
注記: そのわけは、[ `部分的~ifc$ / `部分的~ifc~mixin$ / `部分的~ns$ ]上に `Exposed$x `拡張属性$を追加することは,その各`~mb$を注釈することの略記だからである。 ◎ Note: This is because adding an [Exposed] extended attribute on a partial interface, partial interface mixin, or partial namespace is shorthand for annotating each of its members.
- [ `部分的~ifc$ / `部分的~ns$ ] %A に現れた場合、 %A の`自前の公開~集合$は, %A の元の[ `~ifc$ / `~ns$ ]の`公開~集合$の`下位集合$で~MUST。 ◎ If [Exposed] appears on a partial interface or partial namespace, then the partial’s own exposure set must be a subset of the exposure set of the partial’s original interface or namespace.
- [ `~ifc$ / `~ns$ ] %A 上の[ `~ifc~mb$ / `~ns~mb$ ] %m に現れた場合、 %m の`公開~集合$は %A の`公開~集合$の`下位集合$で~MUST。 ◎ If [Exposed] appears on an interface or namespace member, then the member's exposure set must be a subset of the exposure set of the interface or namespace it is a member of.
- [ `部分的~ifc~mixin$ %A, %A の元の`~ifc~mixin$ %B ]の両者に現れた場合、 %A の`自前の公開~集合$は %B の`自前の公開~集合$の`下位集合$で~MUST。 ◎ If [Exposed] appears both on a partial interface mixin and its original interface mixin, then the partial interface mixin's own exposure set must be a subset of the interface mixin's own exposure set.
- `~ifc~mixin$ %A, %A の`~ifc~mixin~mb$ %m の両者に現れた場合、 %m の`自前の公開~集合$は %A の`自前の公開~集合$の`下位集合$で~MUST。 ◎ If [Exposed] appears both on an interface mixin member and the interface mixin it is a member of, then the interface mixin members's own exposure set must be a subset of the interface mixin's own exposure set.
%A が別の~ifc %B を`継承-$しているならば、 %A の`公開~集合$は %B の`公開~集合$の`下位集合$で~MUST。 ◎ If an interface X inherits from another interface Y then the exposure set of X must be a subset of the exposure set of Y.
注記: `~ifc~mixin$ %M は,互いに異なる`~ifc$に`内包-$され得るので、 %M の`~ifc~mixin~mb$ %m の`公開~集合$は, %M を`内包-$している`~ifc$ — すなわち, %m の`~host~ifc$ %I — の関数になり、 %F を %I の`公開~集合$とするならば,次で与えられる ⇒ %m は `Exposed$x `拡張属性$で注釈されているならば `交差集合$( %m の`自前の公開~集合$, %F ) / ~ELSE_ %M は `Exposed$x `拡張属性$で注釈されているならば `交差集合$( %M の`自前の公開~集合$, %F ) / ~ELSE_ %F ◎ Note: As an interface mixin can be included by different interfaces, the exposure set of its members is a function of the interface that includes them. If the interface mixin member, partial interface mixin, or interface mixin is annotated with an [Exposed] extended attribute, then the interface mixin member's exposure set is the intersection of the relevant construct’s own exposure set with the the host interface's exposure set. Otherwise, it is the host interface's exposure set.
所与の[ `~ifc$ / `~ns$ / `~mb$ ] %構成子 が`~Realm$ %~realm に `公開されて@ いるとは、次の両者が満たされることを意味する: ◎ An interface, namespace, or member construct is exposed in a given Realm realm if the following steps return true:
- ある[ ~ifc %I ~IN %構成子 の`公開~集合$ ]が在って, %~realm.`GlobalObject^sl は %I を実装している
-
次のいずれかが満たされる:
- %構成子 は`保安的かどうかに関わらず可用$である
- %~realm.`GlobalObject^sl に`関連する設定群~obj$は`保安的~文脈$である
注記: ~ES大域~objに`関連する設定群~obj$が`保安的~文脈$であるかどうかは,変化し得ないので、実装が %構成子 用の~propを作成するかどうか決めるのは、`初期~obj$を作成する時点の一度限りになる。 ◎ Note: Since it is not possible for the relevant settings object for an ECMAScript global object to change whether it is a secure context or not over time, an implementation’s decision to create properties for an interface or interface member can be made once, at the time the initial objects are created.
`Exposed$x の利用に課される特有の要件については、 `es-interfaces$sec, `es-constants$sec, `es-attributes$sec, `es-operations$sec, `es-iterators$sec を見よ。 ◎ See §3.6 Interfaces, §3.6.6 Constants, §3.6.7 Attributes, §3.6.8 Operations, and §3.6.9 Common iterator behavior for the specific requirements that the use of [Exposed] entails.
`Exposed$x に意図されている用途は、[ ~ifc / ~ns / 個々の[ `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ]]が可用になるのは[ ~worker, `Worklet$T, `Window$T ]のうち[ どれ, あるいは どの組合わせ ]の中に限るかを,制御することである。 ◎ [Exposed] is intended to be used to control whether interfaces, namespaces, or individual interface, mixin or namespace members are available for use in workers, Worklet, Window, or any combination of the above.
それが どうやって得られるかを,次の~IDL片に示す: ◎ The following IDL fragment shows how that might be achieved:
[Exposed=Window, Global=Window] interface Window { /* */ }; /* `SharedWorkerGlobalScope^T と `DedicatedWorkerGlobalScope^T の両者に同じ識別子 `Worker^l を利用する — 両者は `Exposed^x 拡張属性からまとめて指せるようになる。 ◎ By using the same identifier Worker for both SharedWorkerGlobalScope and DedicatedWorkerGlobalScope, both can be addressed in an [Exposed] extended attribute at once. */ [Exposed=Worker, Global=Worker] interface SharedWorkerGlobalScope : WorkerGlobalScope { /* */ }; [Exposed=Worker, Global=Worker] interface DedicatedWorkerGlobalScope : WorkerGlobalScope { /* */ }; /* `Dimensions^T は、[ 主thread上と~workerの中 ]でのみ可用。 ◎ Dimensions is available for use in workers and on the main thread. */ [Exposed=(Window,Worker), Constructor(double %width, double %height)] interface Dimensions { readonly attribute double %width; readonly attribute double %height; }; /* `WorkerNavigator^T は~workerの中でのみ可用。 ~workerの大域~scopeの中で `WorkerNavigator^T を評価したときは~ifc~objを得られる一方で、主thread上でそうしたときは `ReferenceError^jE になる。 ◎ WorkerNavigator is only available in workers. Evaluating WorkerNavigator in the global scope of a worker would give you its interface object, while doing so on the main thread will give you a ReferenceError. */ [Exposed=Worker] interface WorkerNavigator { /* */ }; /* `Node^T は主thread上でのみ可用。 ~workerの大域~scopeの中で `Node^T を評価したときは `ReferenceError^jE になる。 ◎ Node is only available on the main thread. Evaluating Node in the global scope of a worker would give you a ReferenceError. */ [Exposed=Window] interface Node { /* */ }; /* `MathUtils^T は、[ 主thread上と~workerの中 ]でのみ可用。 ◎ MathUtils is available for use in workers and on the main thread. */ [Exposed=(Window,Worker)] namespace MathUtils { double someComplicatedFunction(double %x, double %y); }; /* `WorkerUtils^T は,~workerの中でのみ可用。 ~workerの大域~scopeの中で `WorkerUtils^T を評価したときは その~ns~objを得られる一方で、主thread上でそうしたときは `ReferenceError^jE になる。 ◎ WorkerUtils is only available in workers. Evaluating WorkerUtils in the global scope of a worker would give you its namespace object, while doing so on the main thread will give you a ReferenceError. */ [Exposed=Worker] namespace WorkerUtils { void setPriority(double %x); }; /* `NodeUtils^T は主thread上でのみ可用。 ~workerの大域~scopeの中で `Node^T を評価したときは `ReferenceError^jE になる。 ◎ NodeUtils is only available in the main thread. Evaluating NodeUtils in the global scope of a worker would give you a ReferenceError. */ [Exposed=Window] namespace NodeUtils { DOMString getAllText(Node %node); };
3.3.7. `Global^x
`Global$x `拡張属性$が `~ifc$上に現れた場合、[ その~ifcを実装している~objは,~ES環境にて大域~objとして利用できる ]ことを指示する。 また、原型鎖の構造, および[ `~ifc~mb$に対応する~propが原型~obj上に どう反映されるか ]についても、他の~ifcと異なるものにされることを指示する。 特定的には: ◎ If the [Global] extended attribute appears on an interface, it indicates that objects implementing this interface can be used as the global object in an ECMAScript environment, and that the structure of the prototype chain and how properties corresponding to interface members will be reflected on the prototype objects will be different from other interfaces. Specifically:
- どの`有名~prop$も,~obj自身ではなく, 原型鎖の中の~obj — `有名~prop~obj$ — 上に公開されることになる。 ◎ Any named properties will be exposed on an object in the prototype chain – the named properties object – rather than on the object itself.
- `~ifc$からの`~ifc~mb$は、`~ifc原型~obj$上ではなく, ~obj自身の~propに対応することになる。 ◎ Interface members from the interface will correspond to properties on the object itself rather than on interface prototype objects.
原型鎖の中の~obj上に置かれる有名~propは、変数~宣言とそのままの名前の代入を通して,大域~obj自身の~propにより隠蔽される。 ◎ Placing named properties on an object in the prototype chain is done so that variable declarations and bareword assignments will shadow the named property with a property on the global object itself.
~ifc~mbに対応する~propを~obj自身の上に置くことは、次の様な,特色機能を検出するためによく利用される手法が働くことになることを意味する: ◎ Placing properties corresponding to interface members on the object itself will mean that common feature detection methods like the following will work:
var %indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB; var %requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || ...;
~ESにおける変数~宣言が取扱われる仕方から,代入が評価される前に隠蔽する変数~propが作成されることになるので、上の~codeでは, `window.indexedDB^c と `window.requestAnimationFrame^c が `undefined^jv に評価されることになる。 ◎ Because of the way variable declarations are handled in ECMAScript, the code above would result in the window.indexedDB and window.requestAnimationFrame evaluating to undefined, as the shadowing variable property would already have been created before the assignment is evaluated.
`Global$x `拡張属性$を利用する`~ifc$ %I に対しては: ◎ If the [Global] extended attribute is used on an interface, then:
- `有名~prop設定子$は 定義されては~MUST_NOT。 ◎ The interface must not define a named property setter.
- [ `有index~prop取得子$/`有index~prop設定子$ ]は 定義されては~MUST_NOT。 ◎ The interface must not define indexed property getters or setters.
- [ %I, および %I の`継承d~ifc$ ]は `OverrideBuiltins$x 拡張属性を伴って宣言されては~MUST_NOT。 ◎ The interface must not also be declared with the [OverrideBuiltins] extended attribute. ◎ The interface must not inherit from another interface with the [OverrideBuiltins] extended attribute.
- %I は 他の~ifcは`継承-$しては~MUST_NOT。 ◎ Any other interface must not inherit from it.
- %I の`部分的~ifc定義$上に指定される場合、その部分的~ifc定義は, %I を成す~ifc定義の中で`有名~prop取得子$を定義する部分を成してい~MUST。 ◎ If [Global] is specified on a partial interface definition, then that partial interface definition must be the part of the interface definition that defines the named property getter.
-
%I は、同じ~ES大域~環境~内で,複数の~objから実装され得るものであっては~MUST_NOT。 ◎ The [Global] extended attribute must not be used on an interface that can have more than one object implementing it in the same ECMAScript global environment.
注記: そのわけは、有名~propを公開する`有名~prop~obj$が 原型鎖の中にあるものであり、複数の[ ~objの有名~prop ]を,それらの~objを継承する 1 個の~obj上で公開することに意味が無いからである。 ◎ Note: This is because the named properties object, which exposes the named properties, is in the prototype chain, and it would not make sense for more than one object’s named properties to be exposed on an object that all of those objects inherit from.
-
%I には[ `識別子$が同じになる複数の`~mb$ ]が在っては~MUST_NOT。 また、 %I には[ 複数の`文字列化子$ / 複数の[ `可反復~宣言$, `~maplike 宣言$, `~setlike 宣言$【混在も含む】 ]]が在っては~MUST_NOT。 ◎ If an interface is declared with the [Global] extended attribute, then there must not be more than one member across the interface with the same identifier. There also must not be more than one stringifier or more than one iterable declaration, maplike declaration or setlike declaration across those interfaces.
注記: そのわけは、~ifcを成す`~mb$すべてが、~ifcを実装する~objに平坦化されるからである。 ◎ Note: This is because all of the members of the interface get flattened down on to the object that implements the interface.
`Global$x 拡張属性は、 1 個~以上の大域~ifcに同じ名前を与えて, `Exposed$x 拡張属性から参照できるようにするときにも利用できる。 ◎ The [Global] extended attribute can also be used to give a name to one or more global interfaces, which can then be referenced by the [Exposed] extended attribute.
`Global$x 拡張属性には、[ `識別子を引数にとる$か, または `識別子~listを引数にとる$ ]ことが要求される。 ◎ The [Global] extended attribute must either take an identifier or take an identifier list.
`Global$x `拡張属性$の宣言に伴われた[ 識別子~引数/識別子~list~引数 ]は、一連の[ ~ifcの `大域~名@ ]を定義する。 ◎ The identifier argument or identifier list argument the [Global] extended attribute is declared with define the interface’s global names.
注記: 識別子~list引数は、 `Exposed$x `拡張属性$の中の単独の名前で,複数の大域~ifcを指せるようにするためにある。 ◎ Note: The identifier argument list exists so that more than one global interface can be addressed with a single name in an [Exposed] extended attribute.
`有名~prop$における `Global$x の利用に課される特有の要件については、 `named-properties-object$sec を見よ。 `~ifc~mb$に対応する~propの所在に関する要件については、 `es-constants$sec, `es-attributes$sec, `es-operations$sec を見よ。 ◎ See §3.6.5 Named properties object for the specific requirements that the use of [Global] entails for named properties, and §3.6.6 Constants, §3.6.7 Attributes and §3.6.8 Operations for the requirements relating to the location of properties corresponding to interface members.
`Window^T ~ifcは frame を `Window^T ~obj上の~propとして公開する。 `Window^T ~objは~ES大域~objとしても~~働くので、有名~propに対する代入や変数~宣言は、新たな値への置換-になる。 属性に対する変数~宣言は、既存の~propを置換する~propを作成しない。 ◎ The Window interface exposes frames as properties on the Window object. Since the Window object also serves as the ECMAScript global object, variable declarations or assignments to the named properties will result in them being replaced by the new value. Variable declarations for attributes will not create a property that replaces the existing one.
[Exposed=Window, Global] interface Window { getter any (DOMString %name); attribute DOMString name; /* */ };
次の HTML 文書では、 `Window^T ~obj上の有名~propが隠蔽され, 属性に対する~propは同じ名前の変数が宣言されても置換されない: ◎ The following HTML document illustrates how the named properties on the Window object can be shadowed, and how the property for an attribute will not be replaced when declaring a variable of the same name:
<!DOCTYPE html> <title> Window 上の変数~宣言と代入 ◎ Variable declarations and assignments on Window </title> <iframe name=abc></iframe> <!-- 有名~propを隠蔽する ◎ Shadowing named properties --> <script> window.abc; /* `iframe^c の `Window^T ~objに評価される。 ◎ Evaluates to the iframe’s Window object. */ %abc = 1; /* 有名~propを隠蔽する。 ◎ Shadows the named property. */ window.abc; /* `1^jv に評価される。 ◎ Evaluates to 1. */ </script> <!-- ~IDL属性~用の~propは保全される ◎ Preserving properties for IDL attributes --> <script> Window.prototype.def = 2; /* 原型~上に~propを置く。 ◎ Places a property on the prototype. */ window.hasOwnProperty("length"); /* */ %length; /* */ %def; /* `2^jv に評価される。 ◎ Evaluates to 2. */ </script> <script> var %length; /* この変数~宣言は既存の~propに触らない。 ◎ Variable declaration leaves existing property. */ %length; /* */ var %def; /* この変数~宣言は隠蔽する~propを作成する。 ◎ Variable declaration creates shadowing property. */ %def; /* */ </script>
3.3.8. `LegacyNamespace^x
`LegacyNamespace$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 ~ifc名は、~nsを利用する代わりに,[ 一連の~ifcの識別子を,特定0の接頭辞から開始させるような命名~規約 ]により形成できる。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [LegacyNamespace]$fI した上で論交することを,強く勧める。 ◎ The [LegacyNamespace] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Instead, interface names can be formed with a naming convention of starting with a particular prefix for a set of interfaces, as part of the identifier, rather than using a namespace. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`LegacyNamespace$x `拡張属性$が`~ifc$上に現れた場合、その~ifc用の`~ifc~obj$は、大域~objの~propとしてではなく,この拡張属性の引数により識別される`~ns$の~propとして作成されることを指示する。 ◎ If the [LegacyNamespace] extended attribute appears on an interface, it indicates that the interface object for this interface will not be created as a property of the global object, but rather as a property of the namespace identified by the argument to the extended attribute.
`LegacyNamespace$x 拡張属性は: ◎ ↓
- ある`~ns$の`識別子を引数にとる$ことが要求される。 ◎ The [LegacyNamespace] extended attribute take an identifier. This identifier must be the identifier of a namespace.
- 同じ~ifc上で, `NoInterfaceObject$x 拡張属性と併用されては~MUST_NOT。 ◎ The [LegacyNamespace] and [NoInterfaceObject] extended attributes must not be specified on the same interface.
- `呼戻~ifc$上に利用されては~MUST_NOT。 ◎ The [LegacyNamespace] extended attribute must not be used on a callback interface.
~ifcが~ns上にどう公開されるかの詳細は `namespace-object$sec を見よ。 ◎ See §3.11.1 Namespace object for details on how an interface is exposed on a namespace.
次の`~IDL片$は、`~ns$, および その内側に定義されることになる[ `LegacyNamespace$x を利用する`~ifc$ ]を定義する: ◎ The following IDL fragment defines a namespace and an interface which uses [LegacyNamespace] to be defined inside of it.
[Exposed=Window] namespace Foo { }; [LegacyNamespace=Foo, Constructor] interface Bar { };
上の~nsと~ifcの~ES実装においては、構築子 `Bar^M は、次のように~accessできる: ◎ In an ECMAScript implementation of the above namespace and interface, the constructor Bar can be accessed as follows:
var %instance = new Foo.Bar();
3.3.9. `LegacyUnenumerableNamedProperties^x
`LegacyUnenumerableNamedProperties$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [LegacyUnenumerableNamedProperties]$fI した上で論交することを,強く勧める。 ◎ The [LegacyUnenumerableNamedProperties] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`LegacyUnenumerableNamedProperties$x `拡張属性$は、次の`~ifc$に現れる ⇒# `HTMLCollection$T, `NamedNodeMap$T, `HTMLAllCollection$T, `HTMLFormElement$T, `PluginArray$T, `MimeTypeArray$T, `Plugin$T, `Window$T ◎終 `DOM$r `HTML$r ◎ The [LegacyUnenumerableNamedProperties] extended attribute appears on the following interfaces: HTMLCollection, NamedNodeMap, HTMLAllCollection, HTMLFormElement, PluginArray, MimeTypeArray, Plugin, and Window. [DOM] [HTML]
`LegacyUnenumerableNamedProperties$x `拡張属性$が[ `有名~propを~support$する`~ifc$ ]に現れた場合、その~ifc上の すべての有名~propは,列挙-不能であることを指示する。 ◎ If the [LegacyUnenumerableNamedProperties] extended attribute appears on a interface that supports named properties, it indicates that all the interface’s named properties are unenumerable.
`LegacyUnenumerableNamedProperties$x 拡張属性は:
- `引数をとらない$ことが要求される。
- `有名~prop取得子$を定義しない~ifc上に現れては~MUST_NOT。
- 当の~ifcのすべての派生~ifcにも適用され、それらには,この拡張属性は指定されては~MUST_NOT。
`LegacyUnenumerableNamedProperties$x の利用に課される特有の要件については、 `legacy-platform-object-getownproperty$sec を見よ。 ◎ See §3.8.1 [[GetOwnProperty]] for the specific requirements that the use of [LegacyUnenumerableNamedProperties] entails.
3.3.10. `LegacyWindowAlias^x
`LegacyWindowAlias$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [LegacyWindowAlias]$fI した上で論交することを,強く勧める。 ◎ The [LegacyWindowAlias] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`LegacyWindowAlias$x `拡張属性$は、次の`~ifc$に現れる ⇒# `DOMPoint$T, `DOMRect$T, `DOMMatrix$T, `URL$T ◎終 `GEOMETRY$r `URL$r ◎ The [LegacyWindowAlias] extended attribute appears on the following interfaces: DOMPoint, DOMRect, DOMMatrix, and URL. [GEOMETRY] [URL]
`LegacyWindowAlias$x `拡張属性$が `~ifc$ %I 上に現れた場合、[ `Window$T `~ifc$は、その拡張属性~内に挙げられた各 `識別子$に対し, %I 用の`~ifc~obj$を値にとるような~propを持つことになる ]ことを指示する。 ◎ If the [LegacyWindowAlias] extended attribute appears on an interface, it indicates that the Window interface will have a property for each identifier mentioned in the extended attribute, whose value is the interface object for the interface.
`LegacyWindowAlias$x 拡張属性は: ◎ ↓
- `識別子を引数にとる$か, または `識別子~listを引数にとる$ことが要求される。 `=^sym の直後に~~現れる `identifier$g が `LegacyWindowAlias$x の `識別子@wA になる。 ◎ The [LegacyWindowAlias] extended attribute must either take an identifier or take an identifier list. The identifiers that occur after the “=” are the [LegacyWindowAlias]'s identifiers.
-
次に挙げる識別子は、 `LegacyWindowAlias$x の`識別子$wAとして利用されては~MUST_NOT:
- 当のまたは別の~ifc上の `LegacyWindowAlias$x 拡張属性に利用されている他の`識別子$wA
- 当のまたは別の~ifc上の `NamedConstructor$x 拡張属性に利用されている`識別子$nC
- `~ifc~obj$を持つ~ifcの`識別子$
- `予約-済み識別子$
- 同じ~ifc上で, `NoInterfaceObject$x 拡張属性と併用されては~MUST_NOT。 ◎ The [LegacyWindowAlias] and [NoInterfaceObject] extended attributes must not be specified on the same interface.
- 自身の`公開~集合$内に `Window$T `~ifc$を含んでいない~ifcには、指定されては~MUST_NOT。 ◎ The [LegacyWindowAlias] extended attribute must not be specified on an interface that does not include the Window interface in its exposure set.
- `呼戻~ifc$上に利用されては~MUST_NOT。 ◎ The [LegacyWindowAlias] extended attribute must not be specified on a callback interface.
- 同じ~ifc上に複数~個 指定されては~MUST_NOT。 ◎ An interface must not have more than one [LegacyWindowAlias] extended attributes specified.
`LegacyWindowAlias^x がどう実装されるかの詳細は `es-interfaces$sec を見よ。 ◎ See §3.6 Interfaces for details on how legacy window aliases are to be implemented.
次の~IDLは `LegacyWindowAlias$x 拡張属性を利用する~ifcを定義する。 ◎ The following IDL defines an interface that uses the [LegacyWindowAlias] extended attribute.
[Exposed=Window, Constructor, LegacyWindowAlias=WebKitCSSMatrix] interface DOMMatrix : DOMMatrixReadOnly { /* */ };
この~ifcを~supportする~ES実装は、 `Window$T ~obj上に,同じ値, 同じ特徴を備える 2 個の~propを公開することになる — 1 つは`~ifc~obj$を通常~のように公開するためのもの,もう 1 つは それを旧来の名前で公開するためのもの。 ◎ An ECMAScript implementation that supports this interface will expose two properties on the Window object with the same value and the same characteristics; one for exposing the interface object normally, and one for exposing it with a legacy name.
WebKitCSSMatrix === DOMMatrix; /* */ var %m = new WebKitCSSMatrix(); /* `DOMMatrix^T を実装する新たな~objを作成する。 ◎ Creates a new object that implements DOMMatrix. */ %m.constructor === DOMMatrix; /* */ %m.constructor === WebKitCSSMatrix; /* */ {}.toString.call(%m); /* `[object DOMMatrix]^l に評価される。 ◎ Evaluates to '[object DOMMatrix]'. */
3.3.11. `LenientSetter^x
互換性の理由から要求されない限り、仕様は `LenientSetter$x を利用するべきでない。 ~pageにて、作者が当の~propへ代入することで~IDL属性を~polyfillしようと試みていて、~propが存在するときでも不用意にそうしたとする。 ~strict-mode下では、これは例外を投出させ,~pageを壊しかねない。 `LenientSetter$x が無いと、このことから~browserは,将来に出荷できなくなる。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [LenientSetter]$fI した上で論交することを,強く勧める。 ◎ Specifications should not use [LenientSetter] unless required for compatibility reasons. Pages have been observed where authors have attempted to polyfill an IDL attribute by assigning to the property, but have accidentally done so even if the property exists. In strict mode, this would cause an exception to be thrown, potentially breaking page. Without [LenientSetter], this could prevent a browser from shipping the feature. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`LenientSetter$x `拡張属性$は、次の`属性$に現れる: `Document$T ~ifcの[ `fullscreen$M, `fullscreenEnabled$M ]属性, `DocumentOrShadowRoot$T `~ifc~mixin$の `fullscreenElement$M `FULLSCREEN$r ◎ The [LenientSetter] extended attribute appears on the fullscreenEnabled and fullscreenEnabled attributes of the Document interface, and on the fullscreenElement attribute of the DocumentOrShadowRoot interface mixin. [FULLSCREEN]
`LenientSetter$x `拡張属性$が[ `読専$な`正則~属性$ ]に現れた場合、[ 属性の~accessor~propとして,何もしない設定子が生成される ]ことを指示する。 その結果,~strict-mode下では、~propに対する誤った代入に対しては,例外は投出されずに無視されるようになる。 ◎ If the [LenientSetter] extended attribute appears on a read only regular attribute, it indicates that a no-op setter will be generated for the attribute’s accessor property. This results in erroneous assignments to the property in strict mode to be ignored rather than causing an exception to be thrown.
`LenientSetter$x 拡張属性は:
- `引数をとらない$ことが要求される。
- `読専$な`正則~属性$以外に利用されては~MUST_NOT。
- 同じ属性~上で, `PutForwards$x / `Replaceable$x 拡張属性と併用されては~MUST_NOT。
- `~ns$上で宣言される属性~上に利用されては~MUST_NOT。
`LenientSetter$x がどう実装されるかの詳細は、 `es-attributes$sec を見よ。 ◎ See the Attributes section for how [LenientSetter] is to be implemented.
次の~IDL片は `LenientSetter$x 拡張属性を利用する~ifcを定義する。 ◎ The following IDL fragment defines an interface that uses the [LenientSetter] extended attribute.
[Exposed=Window] interface Example { [LenientSetter] readonly attribute DOMString x; readonly attribute DOMString y; };
この~ifcを~supportする~ES実装は, `x^M に対応する~accessor~prop上に設定子を持つことになり、~strict-mode下では,どのような代入も無視されるようになる。 ◎ An ECMAScript implementation that supports this interface will have a setter on the accessor property that correspond to x, which allows any assignment to be ignored in strict mode.
"use strict"; var %example = getExample(); /* `Example^T の~instanceを取得する。 ◎ Get an instance of Example. */ /* ~~問題ない。~strict-mode下では,何もしない設定子がある。 ◎ Fine; while we are in strict mode, there is a setter that is a no-op. */ %example.x = 1; /* `TypeError^jE が投出される。~strict-mode下にあり,設定子がないので。 ◎ Throws a TypeError, since we are in strict mode and there is no setter. */ %example.y = 1;
3.3.12. `LenientThis^x
互換性の理由から要求されない限り、仕様は `LenientThis$x を利用するべきでない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [LenientThis]$fI した上で論交することを,強く勧める。 ◎ Specifications should not use [LenientThis] unless required for compatibility reasons. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`LenientThis$x `拡張属性$は、 `Document$T ~ifcの次の`属性$に現れる ⇒# `onreadystatechange$M, `onmouseenter$M, `onmouseleave$M ◎終 `HTML$r ◎ The [LenientThis] extended attribute appears on the onreadystatechange, onmouseenter, and onmouseleave attributes of the Document interface. [HTML]
`LenientThis$x `拡張属性$が `正則~属性$上に現れた場合、その属性が現れる`~ifc$を実装する~objとは異なる `this^jv 値を伴うような,その属性の取得子や設定子の呼出は、無視されることになる。 ◎ If the [LenientThis] extended attribute appears on a regular attribute, it indicates that invocations of the attribute’s getter or setter with a this value that is not an object that implements the interface on which the attribute appears will be ignored.
`LenientThis$x 拡張属性は:
- `引数をとらない$ことが要求される。
- `静的~属性$上に利用されては~MUST_NOT。
- `~ns$上で宣言される属性~上に利用されては~MUST_NOT。
`LenientThis$x がどう実装されるかについては、 `es-attributes$sec を見よ。 ◎ See the Attributes section for how [LenientThis] is to be implemented.
次の~IDL片は `LenientThis$x 拡張属性を利用する ~ifcを定義する。 ◎ The following IDL fragment defines an interface that uses the [LenientThis] extended attribute.
[Exposed=Window] interface Example { [LenientThis] attribute DOMString x; attribute DOMString y; };
この~ifcを~supportする~ES実装では、 `x^M に対応する~accessor~propの取得子/設定子では, `Example^T ~obj以外の何かを伴う呼出しも許容されることになる。 ◎ An ECMAScript implementation that supports this interface will allow the getter and setter of the accessor property that corresponds to x to be invoked with something other than an Example object.
var %example = getExample(); /* `Example^T の~instanceを取得する。 ◎ Get an instance of Example. */ var %obj = { }; /* ~~通常。 ◎ Fine. */ %example.x; /* この値は `Example^T ~objでなく, かつ `LenientThis^x が利用されているので、無視される。 ◎ Ignored, since the this value is not an Example object and [LenientThis] is used. */ Object.getOwnPropertyDescriptor(Example.prototype, "x").get.call(%obj); /* `Example.prototype^jv は `Example^T ~objでなく, かつ `LenientThis^x が利用されているので、これも無視される。 ◎ Also ignored, since Example.prototype is not an Example object and [LenientThis] is used. */ Example.prototype.x; /* `Example.prototype^jv は `Example^T ~objでないので `TypeError^jE が投出される。 ◎ Throws a TypeError, since Example.prototype is not an Example object. */ Example.prototype.y;
3.3.13. `NamedConstructor^x
[ `NamedConstructor$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [NamedConstructor]$fI した上で論交することを,強く勧める。 ◎ [NamedConstructor] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`NamedConstructor$x `拡張属性$は、次の`~ifc$に現れる ⇒# `HTMLAudioElement$T, `HTMLOptionElement$T, `HTMLImageElement$T ◎終 `HTML$r ◎ The [NamedConstructor] extended attribute appears on the following interfaces: HTMLAudioElement, HTMLOptionElement, and HTMLImageElement. [HTML]
`NamedConstructor$x `拡張属性$が `~ifc$上に現れた場合、~ES大域~objは,次を伴う~propを持つことになる:
- その名前は、拡張属性の引数に指定された名前。
- 値は、その~ifcを実装する~objを作成できる`構築子$。
所与の~ifc上に,複数の `NamedConstructor$x 拡張属性が現れてもよい。 ◎ Multiple [NamedConstructor] extended attributes may appear on a given interface.
`NamedConstructor$x 拡張属性は: ◎ ↓
-
`識別子を引数にとる$か, または`有名~引数~listを引数にとる$ことが要求される。
`=^sym の直後に現れる `identifier$g が
`NamedConstructor$x の
`識別子@nC
になる。
前者の形
[NamedConstructor=`identifier$g]
は、空の引数~list[NamedConstructor=`identifier$g()]
を利用するのと同じ意味になる。 ~ifc上の各 `NamedConstructor$x 拡張属性が、[[ 前述の~propの値である`構築子$ ]に,指定された引数を渡して、その~ifcを実装する~objを構築する仕方 ]を~~供することになる。 ◎ The [NamedConstructor] extended attribute must either take an identifier or take a named argument list. The identifier that occurs directly after the “=” is the [NamedConstructor]'s identifier. The first form, [NamedConstructor=identifier], has the same meaning as using an empty argument list, [NamedConstructor=identifier()]. For each [NamedConstructor] extended attribute on the interface, there will be a way to construct an object that implements the interface by passing the specified arguments to the constructor that is the value of the aforementioned property. -
次に挙げる識別子は、有名~構築子の識別子として利用されては~MUST_NOT:
- 別の~ifc上の `NamedConstructor$x 拡張属性に利用されている`識別子$nC
- 当のまたは別の~ifc上の `LegacyWindowAlias$x 拡張属性に利用されている`識別子$wA
- `~ifc~obj$を持つ~ifcの`識別子$
- `予約-済み識別子$
- `呼戻~ifc$上に利用されては~MUST_NOT。 ◎ The [NamedConstructor] extended attribute must not be used on a callback interface.
有名~構築子がどう実装されるかの詳細は `named-constructors$sec を見よ。 ◎ See §3.6.2 Named constructors for details on how named constructors are to be implemented.
次の~IDLは `NamedConstructor$x 拡張属性を利用する~ifcを定義する。 ◎ The following IDL defines an interface that uses the [NamedConstructor] extended attribute.
[Exposed=Window, NamedConstructor=Audio, NamedConstructor=Audio(DOMString %src)] interface HTMLAudioElement : HTMLMediaElement { /* */ };
この~ifcを~supportする~ES実装は、 `Audio^T `構築子$を利用する `HTMLAudioElement^T ~objの構築を許容することになる。 ◎ An ECMAScript implementation that supports this interface will allow the construction of HTMLAudioElement objects using the Audio constructor.
typeof Audio; /* */ var %a1 = new Audio(); /* 引数なしの構築子を利用して, `HTMLAudioElement^T を実装する ~objを作成する。 ◎ Creates a new object that implements HTMLAudioElement, using the zero-argument constructor. */ var %a2 = new Audio('a.flac'); /* 1 個の引数をとる構築子を利用して, `HTMLAudioElement^T を作成する。 ◎ Creates an HTMLAudioElement using the one-argument constructor. */
3.3.14. `NewObject^x
`NewObject$x `拡張属性$が[ `正則~演算$/`静的~演算$ ]上に現れた場合、その演算が~callされる際に,常に 新たに作成された~objへの参照が返され~MUSTことを指示する。 ◎ If the [NewObject] extended attribute appears on a regular or static operation, then it indicates that when calling the operation, a reference to a newly created object must always be returned.
`NewObject$x 拡張属性は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [NewObject] extended attribute must take no arguments.
- `返値型$が[ `~ifc型$, または `~promise型$ ]である[ `正則~演算$/`静的~演算$ ]以外の所に利用されては~MUST_NOT。 ◎ The [NewObject] extended attribute must not be used on anything other than a regular or static operation whose return type is an interface type or a promise type.
この拡張属性の利用が適する一例には、 `Document$T ~ifc上の `createElement()$M 演算 `DOM$r がある — これは、~callされる度に新たな~objが返すべきなので。 `DOM$r ◎ As an example, this extended attribute is suitable for use on the createElement() operation on the Document interface, since a new object should always be returned when it is called. [DOM]
[Exposed=Window] interface Document : Node { [NewObject] Element createElement(DOMString %localName); /* */ };
3.3.15. `NoInterfaceObject^x
`NoInterfaceObject$x 拡張属性は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [NoInterfaceObject]$fI することにより,論交することを強く勧める。 ◎ The [NoInterfaceObject] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`NamedConstructor$x `拡張属性$は、次の`~ifc$に現れる ⇒# `Geolocation$T, `Coordinates$T, `Position$T, `PositionError$T, `DeviceAcceleration$T, `DeviceRotationRate$T, `ConstrainablePattern$T, `WEBGL_compressed_texture_astc$T, `WEBGL_compressed_texture_s3tc_srgb$T, `WEBGL_draw_buffers$T, `WEBGL_lose_context$T, `ANGLE_instanced_arrays$T, `EXT_blend_minmax$T, `EXT_color_buffer_float$T, `EXT_disjoint_timer_query$T, `OES_standard_derivatives$T, `OES_vertex_array_object$T ◎終 `GEOLOCATION-API$r `ORIENTATION-EVENT$r `MEDIACAPTURE-STREAMS$r 各種 `WEBGL$r 拡張~仕様 ◎ The [NoInterfaceObject] extended attribute appears on the following interfaces: • Geolocation, Coordinates, Position, PositionError, DeviceAcceleration, DeviceRotationRate, ConstrainablePattern, WEBGL_compressed_texture_astc, WEBGL_compressed_texture_s3tc_srgb, WEBGL_draw_buffers, WEBGL_lose_context, ANGLE_instanced_arrays, EXT_blend_minmax, EXT_color_buffer_float, EXT_disjoint_timer_query, OES_standard_derivatives, and OES_vertex_array_object. [GEOLOCATION-API] [ORIENTATION-EVENT] [MEDIACAPTURE-STREAMS] (various [WEBGL] extension specifications)
注記: `NoInterfaceObject$x `拡張属性$は、以前は,[[ (今は無き “`implements^sym 文” を用いて、) `~ifc$を,それが~mixinであったかのように他の`~ifc$が実装できる ]ようにする ]ために注釈する用途があった。 今や、この利用事例をまかなうための,専用の構文 — `~ifc~mixin$/`~includes文$ — がある。 この目的に `NoInterfaceObject$x `拡張属性$を用いることは、もはや~supportされない。 依然としてそうしている仕様は、アリな限りすみやかに`~ifc~mixin$に移行することが,強く奨励される。 ◎ Note: Previously, the [NoInterfaceObject] extended attribute could also be used to annotate interfaces, which other interfaces could then implement (using the defunct "implements statement") as if they were mixins. There is now dedicated syntax to cater for this use case in the form of interface mixins and includes statements. Using the [NoInterfaceObject] extended attribute for this purpose is no longer supported. Specifications which still do are strongly encouraged to migrate to interface mixins as soon as possible.
`NoInterfaceObject$x `拡張属性$が `~ifc$上に現れた場合、その~ifc用の`~ifc~obj$は,~ES言語束縛には存在しないことになる。 ◎ If the [NoInterfaceObject] extended attribute appears on an interface, it indicates that an interface object will not exist for the interface in the ECMAScript binding.
`NoInterfaceObject$x 拡張属性は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [NoInterfaceObject] extended attribute must take no arguments.
- 同じ~ifc上で, `Constructor$x 拡張属性と併用されては~MUST_NOT。 一方, `NamedConstructor$x 拡張属性との併用は差し支えない。 ◎ If the [NoInterfaceObject] extended attribute is specified on an interface, then the [Constructor] extended attribute must not also be specified on that interface. A [NamedConstructor] extended attribute is fine, however.
- `静的~演算$が定義されている~ifc上に指定されては~MUST_NOT。 ◎ The [NoInterfaceObject] extended attribute must not be specified on an interface that has any static operations defined on it.
- `呼戻~ifc$上に指定されては~MUST_NOT。 ◎ The [NoInterfaceObject] extended attribute must not be specified on a callback interface.
- この拡張属性が指定されていない~ifcが,この拡張属性が指定されている~ifcを継承しては~MUST_NOT ◎ An interface that does not have the [NoInterfaceObject] extended attribute specified must not inherit from an interface that has the [NoInterfaceObject] extended attribute specified.
`NoInterfaceObject$x の利用に課される特有の要件については、 `es-interfaces$sec を見よ。 ◎ See §3.6 Interfaces for the specific requirements that the use of [NoInterfaceObject] entails.
次の`~IDL片$は 2 つの~ifcを定義する。 一方はその~ifc~objが~ES大域~obj上に公開され,他方はそうでない: ◎ The following IDL fragment defines two interfaces, one whose interface object is exposed on the ECMAScript global object, and one whose isn’t:
[Exposed=Window] interface Storage { void addEntry(unsigned long %key, any %value); }; [Exposed=Window, NoInterfaceObject] interface Query { any lookupEntry(unsigned long %key); };
上の~IDLの~ES実装においては、 `Storage^T の原型に対する操作は許容される一方, `Query^T に対してはそうならない。 ◎ An ECMAScript implementation of the above IDL would allow manipulation of Storage’s prototype, but not Query’s.
typeof Storage; /* `object^l に評価される。 ◎ evaluates to "object" */ /* `Storage.addEntry^c に~trace用の `alert()^c ~callを追加する ◎ Add some tracing alert() call to Storage.addEntry. */ var %fn = Storage.prototype.addEntry; Storage.prototype.addEntry = function(%key, %value) { alert('Calling addEntry()'); return %fn.call(this, %key, %value); }; typeof Query; /* `undefined^l に評価される。 ◎ evaluates to "undefined" */ var %fn = Query.prototype.lookupEntry; /* 例外が投出される。 `Query^T は定義されていないので。 ◎ exception, Query isn’t defined */
3.3.16. `OverrideBuiltins^x
`OverrideBuiltins$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [OverrideBuiltins]$fI した上で論交することを,強く勧める。 ◎ The [OverrideBuiltins] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`OverrideBuiltins$x `拡張属性$は、次の`~ifc$に現れる ⇒# `DOMStringMap$T, `Document$T, `HTMLFormElement$T ◎終 `HTML$r ◎ The [OverrideBuiltins] extended attribute appears on the DOMStringMap, Document, and HTMLFormElement interfaces. [HTML]
`OverrideBuiltins$x `拡張属性$が `~ifc$上に現れた場合,その~ifcを実装する`旧来の~platform~obj$ %O においては、[ %O や %O の原型鎖 ]上に存在する他の~propに関わらず,各[ %O が`~supportする~prop名$ ]に対し,対応する~propが %O 上に現れることになる。 このことは、(通例の挙動では、有名~propは[ %O 自身やその原型鎖 ]上のどこにも同じ名前の~propが存在しないときに限り,公開されるのに対し、)有名~propが、[ さもなければ %O 上に現れることになる,同じ名前のどの~prop ]も,常に隠蔽することになることを意味する。 ◎ If the [OverrideBuiltins] extended attribute appears on an interface, it indicates that for a legacy platform object implementing the interface, properties corresponding to all of the object’s supported property names will appear to be on the object, regardless of what other properties exist on the object or its prototype chain. This means that named properties will always shadow any properties that would otherwise appear on the object. This is in contrast to the usual behavior, which is for named properties to be exposed only if there is no property with the same name on the object itself or somewhere on its prototype chain.
`OverrideBuiltins$x `拡張属性$は:
- `引数をとらない$ことが要求される。
- `有名~prop取得子$を定義しない~ifc上に現れては~MUST_NOT。
- `Global$x `拡張属性$と併用されては~MUST_NOT。
- `部分的~ifc定義$上に指定される場合、その部分的~ifc定義は,~ifc定義の中で`有名~prop取得子$を定義する部分を成してい~MUST。
`OverrideBuiltins$x の利用に課される特有の要件については、 `es-legacy-platform-objects$sec, `legacy-platform-object-defineownproperty$sec を見よ。 ◎ See §3.8 Legacy platform objects and §3.8.3 [[DefineOwnProperty]] for the specific requirements that the use of [OverrideBuiltins] entails.
次の`~IDL片$は 2 つの`~ifc$を定義する。 一方は`有名~prop取得子$を持ち, 他方はそうでない: ◎ The following IDL fragment defines two interfaces, one that has a named property getter and one that does not.
[Exposed=Window] interface StringMap { readonly attribute unsigned long length; getter DOMString lookup(DOMString %key); }; [Exposed=Window, OverrideBuiltins] interface StringMap2 { readonly attribute unsigned long length; getter DOMString lookup(DOMString %key); };
これら 2 つの~ifcの~ES実装においては、それぞれの~ifcを実装する~obj上の一部の~propについて,その取得による結果が異なってくることになる: ◎ In an ECMAScript implementation of these two interfaces, getting certain properties on objects implementing the interfaces will result in different values:
/* `StringMap^T の~instanceを得る。 ~supportする~prop名として, `abc^l, `length^l, `toString^l を持つとする。 ◎ Obtain an instance of StringMap. Assume that it has "abc", "length" and "toString" as supported property names. */ var %map1 = getStringMap(); /* 有名~prop取得子を呼出す。 ◎ This invokes the named property getter. */ %map1.abc; /* `length^M 属性に対応する~obj上の `length^jp ~propを取りに行く。 ◎ This fetches the "length" property on the object that corresponds to the length attribute. */ %map1.length; /* ~objの原型鎖~上の `toString^jp ~propを取りに行く。 ◎ This fetches the "toString" property from the object’s prototype chain. */ %map1.toString; /* `StringMap2^T の~instanceを得る。 これも~supportする~prop名として, `abc^l, `length^l, `toString^l を持つとする。 ◎ Obtain an instance of StringMap2. Assume that it also has "abc", "length" and "toString" as supported property names. */ var %map2 = getStringMap2(); /* これは 有名~prop取得子を呼出す。 ◎ This invokes the named property getter. */ %map2.abc; /* これも 有名~prop取得子を呼出す。 ~obj上の `length^jp ~propが length 属性に対応しているにも関わらず。 ◎ This also invokes the named property getter, despite the fact that the "length" property on the object corresponds to the length attribute. */ %map2.length; /* これもまた 有名~prop取得子を呼出す。 `toString^l が %map2 の prototype chain 内にある~propであるにも関わらず。 ◎ This too invokes the named property getter, despite the fact that "toString" is a property in map2’s prototype chain. */ %map2.toString;
3.3.17. `PutForwards^x
`PutForwards$x `拡張属性$が[ `~ifc型$の`読専$な`正則~属性$宣言 ]上に現れた場合、その属性への代入-時に特有に挙動することになる。 すなわち,その代入は、代入-が試みられた属性から,現在~参照されている~objの属性(その拡張属性の引数で指定される)に “回送-” される。 ◎ If the [PutForwards] extended attribute appears on a read only regular attribute declaration whose type is an interface type, it indicates that assigning to the attribute will have specific behavior. Namely, the assignment is “forwarded” to the attribute (specified by the extended attribute argument) on the object that is currently referenced by the attribute being assigned to.
`PutForwards$x 拡張属性には、`識別子を引数にとる$ことが要求される。 次が与えられるとき: ◎ The [PutForwards] extended attribute must take an identifier. Assuming that:
- %A は `PutForwards$x 拡張属性が現れる`属性$, ◎ A is the attribute on which the [PutForwards] extended attribute appears,
- %I は %A が宣言されている`~ifc$, ◎ I is the interface on which A is declared,
- %J は %A の型として宣言されている `~ifc型$, ◎ J is the interface type that A is declared to be of, and
- %N は その拡張属性の`識別子$引数, ◎ N is the identifier argument of the extended attribute,
このとき,`識別子$ %N を持つ別の`属性$ %B が %J 上に宣言されてい~MUST。 %I を実装している~obj上の属性 %A への値の代入では、代わりに, %A が参照する~objの属性 %B にその値が代入されることになる。 ◎ then there must be another attribute B declared on J whose identifier is N. Assignment of a value to the attribute A on an object implementing I will result in that value being assigned to attribute B of the object that A references, instead.
`PutForwards$x 注釈付きの`属性$は連鎖し得ることに注意。 すなわち、 `PutForwards$x `拡張属性$を伴う属性は,この拡張属性を持つ他の属性を指すことができる。 ただし、この代入の連鎖が循環しては~MUST_NOT。 代入の連鎖が辿られる際に,同じ`~ifc$上の特定0の属性に複数~回 遭遇するならば、循環が存在する。 ◎ Note that [PutForwards]-annotated attributes can be chained. That is, an attribute with the [PutForwards] extended attribute can refer to an attribute that itself has that extended attribute. There must not exist a cycle in a chain of forwarded assignments. A cycle exists if, when following the chain of forwarded assignments, a particular attribute on an interface is encountered more than once.
`PutForwards$x 拡張属性は: ◎ ↓
- 同じ属性~上で, `LenientSetter$x / `Replaceable$x 拡張属性と併用されては~MUST_NOT。 ◎ An attribute with the [PutForwards] extended attribute must not also be declared with the [LenientSetter] or [Replaceable] extended attributes.
- `読専$でない`属性$~上に利用されては~MUST_NOT。 ◎ The [PutForwards] extended attribute must not be used on an attribute that is not read only.
- `静的~属性$上に利用されては~MUST_NOT。 ◎ The [PutForwards] extended attribute must not be used on a static attribute.
- [ `呼戻~ifc$/`~ns$ ]上で宣言される属性~上に利用されては~MUST_NOT。 ◎ The [PutForwards] extended attribute must not be used on an attribute declared on a callback interface or namespace.
`PutForwards$x がどう実装されるかについては、 `es-attributes$sec を見よ。 ◎ See the Attributes section for how [PutForwards] is to be implemented.
次の`~IDL片$は、姓名と人を表す~ifcを定義する。 `Person^T ~ifcの `name^M 属性~上に利用される `PutForwards$x 拡張属性は、その属性への代入による結果が `Person^T ~objの 【 `name^M 属性が指す `Name^T ~objの】 `full^M 属性への代入になることを指示する: ◎ The following IDL fragment defines interfaces for names and people. The [PutForwards] extended attribute is used on the name attribute of the Person interface to indicate that assignments to that attribute result in assignments to the full attribute of the Person object:
[Exposed=Window] interface Name { attribute DOMString full; attribute DOMString family; attribute DOMString given; }; [Exposed=Window] interface Person { [PutForwards=full] readonly attribute Name name; attribute unsigned short age; };
~ES言語束縛においては、 `name^jp ~propへの代入が許容されることになる: ◎ In the ECMAScript binding, this would allow assignments to the name property:
var %p = getPerson(); /* `Person^T の~instanceを得る。 ◎ Obtain an instance of Person. */ %p.name = 'John Citizen'; /* この文は... ◎ This statement... */ %p.name.full = 'John Citizen'; /* ...これと同じ挙動になる。 ◎ ...has the same behavior as this one. */
3.3.18. `Replaceable^x
`Replaceable$x `拡張属性$が `読専$な`正則~属性$上に現れた場合、`~platform~obj$上の対応する~propが設定される際に、その~obj上に,代入される値をとる同じ名前の自前の~propが作成されることになる。 この~propは、 `~ifc原型~obj$上に存在する,その属性に対応する~accessor~propを隠蔽する。 ◎ If the [Replaceable] extended attribute appears on a read only regular attribute, it indicates that setting the corresponding property on the platform object will result in an own property with the same name being created on the object which has the value being assigned. This property will shadow the accessor property corresponding to the attribute, which exists on the interface prototype object.
`Replaceable$x 拡張属性は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [Replaceable] extended attribute must take no arguments.
- 同じ属性~上で, `LenientSetter$x / `Replaceable$x 拡張属性と併用されては~MUST_NOT。 ◎ An attribute with the [Replaceable] extended attribute must not also be declared with the [LenientSetter] or [PutForwards] extended attributes.
- `読専$でない`属性$~上に利用されては~MUST_NOT。 ◎ The [Replaceable] extended attribute must not be used on an attribute that is not read only.
- `静的~属性$上に利用されては~MUST_NOT。 ◎ The [Replaceable] extended attribute must not be used on a static attribute.
- `呼戻~ifc$上で宣言される属性に利用されては~MUST_NOT。 ◎ The [Replaceable] extended attribute must not be used on an attribute declared on a callback interface.
`Replaceable$x の利用に課される特有の要件については、 `es-attributes$sec を見よ。 ◎ See §3.6.7 Attributes for the specific requirements that the use of [Replaceable] entails.
次の`~IDL片$は、計数を増やす`演算$と,計数~値を公開する初期~値 0 の`属性$を持つ`~ifc$を定義する: ◎ The following IDL fragment defines an interface with an operation that increments a counter, and an attribute that exposes the counter’s value, which is initially 0:
[Exposed=Window] interface Counter { [Replaceable] readonly attribute unsigned long value; void increment(); };
`Counter^T を実装する `~platform~obj$上の `value^jp ~propに代入することにより,その`属性$に対応する~propは隠蔽されることになる: ◎ Assigning to the value property on a platform object implementing Counter will shadow the property that corresponds to the attribute:
var %counter = getCounter(); /* `Counter^T の~instanceを得る。 ◎ Obtain an instance of Counter. */ %counter.value; /* `0^jv に評価される。 ◎ Evaluates to 0. */ %counter.hasOwnProperty("value"); /* */ Object.getPrototypeOf(%counter).hasOwnProperty("value"); /* */ %counter.increment(); %counter.increment(); %counter.value; /* `2^jv に評価される。 ◎ Evaluates to 2. */ %counter.value = 'a'; /* `Counter::value^V に関係無いもので~propを隠蔽する。 ◎ Shadows the property with one that is unrelated to Counter::value. */ %counter.hasOwnProperty("value"); /* */ %counter.increment(); %counter.value; /* `a^l に評価される。 ◎ Evaluates to 'a'. */ delete %counter.value; /* 元の~propを露にする。 ◎ Reveals the original property. */ %counter.value; /* `3^jv に評価される。 ◎ Evaluates to 3. */
3.3.19. `SameObject^x
`SameObject$x `拡張属性$が `読専$な`属性$に現れた場合、所与の~obj上でその属性の値が取得される度に,常に同じ値が返され~MUSTことを指示する。 ◎ If the [SameObject] extended attribute appears on a read only attribute, then it indicates that when getting the value of the attribute on a given object, the same value must always be returned.
`SameObject$x 拡張属性は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [SameObject] extended attribute must take no arguments.
- [[ `~ifc型$/`~obj型$ ]である`読専$な`属性$ ]以外の所に利用されては~MUST_NOT。 ◎ The [SameObject] extended attribute must not be used on anything other than a read only attribute whose type is an interface type or object.
この拡張属性の利用が適する一例には, `Document$T ~ifc上の `implementation$M 属性がある。 — 所与の `Document^T ~objに対しては、常に同じ~objを返すので。 `DOM$r ◎ As an example, this extended attribute is suitable for use on the implementation attribute on the Document interface since the same object is always returned for a given Document object. [DOM]
[Exposed=Window] interface Document : Node { [SameObject] readonly attribute DOMImplementation implementation; /* */ };
3.3.20. `SecureContext^x
`SecureContext$x `拡張属性$が[ `~ifc$ / `部分的~ifc$ / `~ifc~mixin$ / `部分的~ifc~mixin$ / `~ns$ / `部分的~ns$ / 個々の[ `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ]] %X 上に現れた場合、[ %X が公開されるのは `保安的~文脈$の中に限られる ]ことを指示する。 ◎ If the [SecureContext] extended attribute appears on an interface, partial interface, interface mixin, partial interface mixin, namespace, partial namespace, interface member, interface mixin member, or namespace member, it indicates that the construct is exposed only within a secure context.\
`SecureContext$x 拡張属性は: ◎ ↓
- 上に挙げたもの以外の構成子に利用されては~MUST_NOT。 ◎ The [SecureContext] extended attribute must not be used on any other construct.
- `引数をとらない$ことが要求される。 ◎ The [SecureContext] extended attribute must take no arguments.
既定では、構成子は `保安的かどうかに関わらず可用@ とされる。 ◎ By default, constructs are available in both secure and non-secure contexts.
所与の構成子 %C が `保安的~文脈~下に限り可用@ かどうか検査するときは、次の手続きを走らす(結果が ~T ならば可用とされる): ◎ To check if a construct C is available only in secure contexts, run the following steps:
- ~Assert: %C は[ `~ifc$ / `~ns$ / `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ]である ◎ Assert: C is an interface, namespace, interface member, interface mixin member, or namespace member.
- %H ~LET [ %C は`~ifc~mixin~mb$であるならば %C の`~host~ifc$ / ~ELSE_ ~NULL ] ◎ Let H be C’s host interface if C is an interface mixin member, or null otherwise.
-
~IF[ %C は[ `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ]である ]: ◎ If C is an interface member, interface mixin member, or namespace member, then:
- ~IF[ %C 上に `SecureContext$x `拡張属性$は指定されている ] ⇒ ~RET ~T ◎ If the [SecureContext] extended attribute is specified on C, then return true.
- ~ELSE ⇒ %C ~SET %C を宣言している[ `~ifc$ / `部分的~ifc$ / `~ifc~mixin$ / `部分的~ifc~mixin$ / `~ns$ / `部分的~ns$ ] ◎ Otherwise, set C to be the interface, partial interface, interface mixin, partial interface mixin, namespace, or partial namespace C is declared on.
-
~IF[ %C は[ `部分的~ifc$ / `部分的~ifc~mixin$ / `部分的~ns$ ]である ]: ◎ If C is a partial interface, partial interface mixin, or partial namespace, then:
- ~IF[ %C 上に `SecureContext$x `拡張属性$は指定されている ] ⇒ ~RET ~T ◎ If the [SecureContext] extended attribute is specified on C, then return true.
- %C ~SET %C の元の[ `~ifc$ / `~ifc~mixin$ / `~ns$ ]定義 ◎ Otherwise, set C to be the original interface, interface mixin, or namespace definition of C.
-
~IF[ %C は`~ifc~mixin$である ]: ◎ If C is an interface mixin, then:
- ~IF[ %C 上に `SecureContext$x `拡張属性$は指定されている ] ⇒ ~RET ~T ◎ If the [SecureContext] extended attribute is specified on C, then return true.
- %C ~SET %H ◎ Otherwise, set C to H.
- ~Assert: %C は[ `~ifc$ / `~ns$ ]である ◎ Assert: C is a interface or namespace
- ~IF[ %C 上に `SecureContext$x `拡張属性$は指定されている ] ⇒ ~RET ~T ◎ If the [SecureContext] extended attribute is specified on C, then return true.
- ~RET ~F ◎ Otherwise, return false.
注記: 所与の構成子が`保安的~文脈~下に限り可用$かどうかは、所与の~ES大域~環境~内に`公開され$るかどうかに波及する。 ◎ Note: Whether a construct is available only in secure contexts influences whether it is exposed in a given ECMAScript global environment.
`SecureContext$x `拡張属性$は:
- `多重定義$された ある`演算$に現れるならば、その多重定義を成す他のすべての演算にも現れ~MUST。 ◎ If [SecureContext] appears on an overloaded operation, then it must appear on all overloads.
-
次の両者に指定されては~MUST_NOT ⇒ [ `~ifc~mb$ / `~ifc~mixin~mb$ / `~ns~mb$ ], および その`~mb$を宣言している[ `部分的~ifc$ / `部分的~ifc~mixin$ / `部分的~ns$ ]定義 ◎ The [SecureContext] extended attribute must not be specified both on an interface, mixin, or namespace member, and on the partial interface, partial interface mixin, or partial namespace definition the member is declared on.
注記: そのわけは、[ `部分的~ifc$ / `部分的~ifc~mixin$ / `部分的~ns$ ]上に `SecureContext$x `拡張属性$を追加することは,その各`~mb$を注釈することの略記だからである。 ◎ Note: This is because adding a [SecureContext] extended attribute on a partial interface, partial interface mixin, or partial namespace is shorthand for annotating each of its members.
- 次の両者に指定されては~MUST_NOT ⇒ `~ifc~mb$, および その`~mb$を宣言している[ `~ifc$ / `部分的~ifc$ ]定義 ◎ The [SecureContext] extended attribute must not be specified on both an interface member and the interface or partial interface definition the interface member is declared on.\
- 次の両者に指定されては~MUST_NOT ⇒ `~ns~mb$, および その`~mb$を宣言している[ `~ns$ / `部分的~ns$ ]定義 ◎ It must also not be specified on both a namespace member and the namespace or partial namespace definition the namespace member is declared on.
`SecureContext$x`拡張属性$を伴わない`~ifc$は、 `SecureContext$x を指定する別の~ifcを`継承-$しては~MUST_NOT。 ◎ An interface without the [SecureContext] extended attribute must not inherit from another interface that does specify [SecureContext].
次の`~IDL片$が定義する~ifcには、 3 個の~mbがある — うち 1 個は すべて文脈から実行できる`演算$であり,他は 保安的~文脈に限り実行できる: ◎ The following IDL fragment defines an interface with one operation that is executable from all contexts, and two which are executable only from secure contexts.
[Exposed=Window] interface PowerfulFeature { /* 次の演算の~callはどの文脈~下でも成功する。 ◎ This call will succeed in all contexts. */ Promise <Result> calculateNotSoSecretResult(); /* 次の演算は、保安的でない文脈には公開されない。 `PowerfulFeature.prototype^c 上に `calculateSecretResult^jp ~propはない。 ◎ This operation will not be exposed to a non-secure context. In such a context, there will be no "calculateSecretResult" property on PowerfulFeature.prototype. */ [SecureContext] Promise<Result> calculateSecretResult(); /* 次の属性にも同じことが言え、保安的でない文脈には公開されない — `PowerfulFeature.prototype^c 上に `secretBoolean^jp ~propはない。 ◎ The same applies here: the attribute will not be exposed to a non-secure context, and in a non-secure context there will be no "secretBoolean" property on PowerfulFeature.prototype. */ [SecureContext] readonly attribute boolean secretBoolean; }; /* `HeartbeatSensor^T は、保安的でない文脈にも その~mbにも公開されない — `Window^T 上に `HeartbeatSensor^jp ~propはない。 ◎ HeartbeatSensor will not be exposed in a non-secure context, nor will its members. In such a context, there will be no "HeartbeatSensor" property on Window. */ [SecureContext] interface HeartbeatSensor { Promise<float> getHeartbeatsPerMinute(); }; /* 次に定義される~ifc~mixin~mbは、それを内包する~ifcが保安的かどうかに関わらず,保安的でない文脈には決して公開されない — `PowerfulFeature.prototype^c 上に `snap^jp ~propはない。 ◎ The interface mixin members defined below will never be exposed in a non-secure context, regardless of whether the interface that includes them is. In a non-secure context, there will be no "snap" property on PowerfulFeature.prototype. */ [SecureContext] interface mixin Snapshotable { Promise<boolean> snap(); }; PowerfulFeature includes Snapshotable; /* 他方,次の各 ~ifc~mixin~mbは、 `SecureContext$x 拡張属性を伴わない~host~ifcに内包された場合には,保安的でない文脈にも公開されることになる — そのような文脈においても, `PowerfulFeature.prototype^c 上に `log^jp ~propはある。 ◎ On the other hand, the following interface mixin members will be exposed to a non-secure context when included by a host interface that doesn’t have the [SecureContext] extended attribute. In a non-secure context, there will be a "log" property on PowerfulFeatures.prototype. */ interface mixin Loggable { Promise<boolean> log(); }; PowerfulFeatures includes Loggable;
3.3.21. `TreatNonObjectAsNull^x
`TreatNonObjectAsNull$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [TreatNonObjectAsNull]$fI した上で論交することを,強く勧める。 ◎ The [TreatNonObjectAsNull] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`TreatNonObjectAsNull$x `拡張属性$は、 `onclick^M や `onerror^M などの`~event-handler~IDL属性$の型として利用される,次のものに現れる ⇒# `呼戻~関数$, `EventHandlerNonNull$T, `OnBeforeUnloadEventHandlerNonNull$T, `OnErrorEventHandlerNonNull$T ◎終 `HTML$r ◎ The [TreatNonObjectAsNull] extended attribute appears on the callback functions EventHandlerNonNull, OnBeforeUnloadEventHandlerNonNull, and OnErrorEventHandlerNonNull used as the type of event handler IDL attributes such as onclick and onerror. [HTML]
`TreatNonObjectAsNull$x `拡張属性$が `呼戻~関数$上に現れた場合、 `属性$に代入される[ `~nullable$`呼戻~関数$型であって, ~objではない ]どの値も, `null^V 値に変換するようにすることを指示する。 ◎ If the [TreatNonObjectAsNull] extended attribute appears on a callback function, then it indicates that any value assigned to an attribute whose type is a nullable callback function that is not an object will be converted to the null value.
`TreatNonObjectAsNull$x の利用に課される特有の要件については、 `es-nullable-type$sec を見よ。 ◎ See §3.2.18 Nullable types — T? for the specific requirements that the use of [TreatNonObjectAsNull] entails.
次の`~IDL片$は、 `TreatNonObjectAsNull$x 注釈付きの`呼戻~関数$型の属性と, この`拡張属性$を伴わない`呼戻~関数$を持つ~ifcを定義する。 ◎ The following IDL fragment defines an interface that has one attribute whose type is a [TreatNonObjectAsNull]-annotated callback function and another whose type is a callback function without the extended attribute:
callback OccurrenceHandler = void (DOMString %details); [TreatNonObjectAsNull] callback ErrorHandler = void (DOMString %details); [Exposed=Window] interface Manager { attribute OccurrenceHandler? handler1; attribute ErrorHandler? handler2; };
~ES実装においては、~objでない値( `Number^jt 値など)を `handler1^M に代入したときと, `handler2^M に代入したときとの挙動と異なる: ◎ In an ECMAScript implementation, assigning a value that is not an object (such as a Number value) to handler1 will have different behavior from that when assigning to handler2:
var %manager = getManager(); /* `Manager^T の~instanceを取得する。 ◎ Get an instance of Manager. */ %manager.handler1 = function() { }; %manager.handler1; /* 当の function に評価される。 ◎ Evaluates to the function. */ try { %manager.handler1 = 123; /* `TypeError^jE が投出される。 ◎ Throws a TypeError. */ } catch (%e) { } %manager.handler2 = function() { }; %manager.handler2; /* */ %manager.handler2 = 123; %manager.handler2; /* `null^jv に評価される。 ◎ Evaluates to null. */
3.3.22. `TreatNullAs^x
`TreatNullAs$x `拡張属性$は、望ましくない特色機能である。 旧来の~Web~platform特色機能を指定できるようにするためのみに存在するので、旧来の~API[ の挙動を指定するため/との整合性のため ]に要求されない限り,仕様に利用されるべきではない。 この特色機能を利用したいと望む編集者には、先に進む前に `Intent to use [TreatNullAs]$fI した上で論交することを,強く勧める。 ◎ The [TreatNullAs] extended attribute is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this by filing an issue before proceeding.
`TreatNullAs$x `拡張属性$が `DOMString$T 型に現れた場合、次に従ってふるまう,新たな型を作成する ⇒ ~ES `null^jv 値がこの~IDL型に変換される際には、既定による `null^l に文字列化される代わりに,空~文字列に変換される。 ◎ If the [TreatNullAs] extended attribute appears on the DOMString type, it creates a new IDL type such that that when an ECMAScript null is converted to the IDL type, it will be handled differently from its default handling. Instead of being stringified to "null", which is the default, it will be converted to the empty string.
`TreatNullAs$x 拡張属性には、次の`識別子を引数にとる$ことが要求される: `EmptyString^c ◎ The [TreatNullAs] extended attribute must take the identifier EmptyString.
`TreatNullAs$x `拡張属性が結付けられ$ている型は、 `DOMString$T で~MUST。 ◎ The [TreatNullAs] extended attribute must not be associated with a type that is not DOMString.
注記: すなわち、 `DOMString?^T 型であっても, `TreatNullAs$x を利用してはならない — `null^V はその型の妥当な値なので。 ◎ Note: This means that even DOMString? must not use [TreatNullAs], since null is a valid value of that type.
`TreatNullAs$x の利用に課される特有の要件については、 `es-DOMString$sec を見よ。 ◎ See §3.2.9 DOMString for the specific requirements that the use of [TreatNullAs] entails.
次の`~IDL片$が定義する[ 属性 / 演算がとる引数 ]の型は、 `TreatNullAs$x 拡張属性を有している: ◎ The following IDL fragment defines an interface that has one attribute whose type has the extended attribute, and one operation whose argument’s type has the extended attribute:
[Exposed=Window] interface Dog { attribute DOMString name; attribute [TreatNullAs=EmptyString] DOMString owner; boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString %breedName); };
`Dog^T ~ifcを実装する~ES実装においては、 `owner^jp ~propに代入される, あるいは `isMemberOfBreed^M 関数の引数に渡される `null^jv 値は、 `null^l ではなく,空~文字列に変換されることになる: ◎ An ECMAScript implementation implementing the Dog interface would convert a null value assigned to the owner property or passed as the argument to the isMemberOfBreed function to the empty string rather than "null":
var %d = getDog(); /* %d は `Dog^T ~ifcを実装する~platform~objとする。 ◎ Assume d is a platform object implementing the Dog interface. */ %d.name = null; /* 文字列 `null^l を `.name^jp ~propに代入する。 ◎ This assigns the string "null" to the .name property. */ %d.owner = null; /* 文字列 "" を `.owner^jp ~propに代入する。 ◎ This assigns the string "" to the .owner property. */ %d.isMemberOfBreed(null); /* 文字列 "" を `isMemberOfBreed^M 関数に渡す。 ◎ This passes the string "" to the isMemberOfBreed function. */
3.3.23. `Unforgeable^x
`Unforgeable$x `拡張属性$が[ `正則~属性$/`静的$oPでない`演算$ ]上に現れた場合、その属性/演算は,次のような仕方で~ES~propとして反映されることになる:
- その挙動は改変できない。
- ~obj上で~prop検索が遂行された際には,常にその属性の~prop値が返される。
特に,そのような~propは、~configure不能になり,かつ[ ~objの原型~上ではなく, ~obj上の自前の~prop ]として存在することになる。
◎ If the [Unforgeable] extended attribute appears on regular attributes or non-static operations, it indicates that the attribute or operation will be reflected as an ECMAScript property in a way that means its behavior cannot be modified and that performing a property lookup on the object will always result in the attribute’s property value being returned. In particular, the property will be non-configurable and will exist as an own property on the object itself rather than on its prototype.所与の~ifc %A 上にて `Unforgeable$x `拡張属性$ 注釈付きで宣言されている[ 属性/演算 ]は、 %A 上において `偽装-不能@ であるとされる。 ◎ An attribute or operation is said to be unforgeable on a given interface A if the attribute or operation is declared on A, and is annotated with the [Unforgeable] extended attribute.
`Unforgeable$x `拡張属性$は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [Unforgeable] extended attribute must take no arguments.
- [ `正則~属性$, `静的$oPでない`演算$ ]以外の所に現れては~MUST_NOT。 ◎ The [Unforgeable] extended attribute must not appear on anything other than a regular attribute or a non-static operation.\
- ある演算~上に現れるならば、その~ifc上で同じ識別子を持つ他のすべての演算~上にも現れ~MUST。 ◎ If it does appear on an operation, then it must appear on all operations with the same identifier on that interface.
- `~ns$上で宣言される属性~上に利用されては~MUST_NOT。 ◎ The [Unforgeable] extended attribute must not be used on an attribute declared on a namespace.
~ifc %A 上の[ 属性/演算 ] %m が`偽装-不能$である場合、 %A を自身の`継承d~ifc$に含むような別の~ifc %B は,`識別子$が %m と同じである[ `正則~属性$, `静的$oPでない`演算$ ]のいずれも持っては~MUST_NOT。 ◎ If an attribute or operation X is unforgeable on an interface A, and A is one of the inherited interfaces of another interface B, then B must not have a regular attribute or non-static operation with the same identifier as X.
例えば,次は許容されない: ◎ For example, the following is disallowed:
[Exposed=Window] interface A1 { [Unforgeable] readonly attribute DOMString x; }; [Exposed=Window] interface B1 : A1 { void x(); /* 妥当でない — `A1^T の `x^M で隠蔽されるので。 ◎ Invalid; would be shadowed by A1’s x. */ }; [Exposed=Window] interface B2 : A1 { }; B2 includes M1; interface mixin M1 { void x(); /* 妥当でない — `B2^T における `x^M の複製は `A1^T の `x^M で隠蔽されるので。 ◎ Invalid; B2’s copy of x would be shadowed by A1’s x. */ };
`Unforgeable$x の利用に課される特有の要件については、 `es-attributes$sec, `es-operations$sec, `es-platform-objects$sec, `es-legacy-platform-objects$sec, `legacy-platform-object-defineownproperty$sec を見よ。 ◎ See §3.6.7 Attributes, §3.6.8 Operations, §3.7 Platform objects implementing interfaces, §3.8 Legacy platform objects and §3.8.3 [[DefineOwnProperty]] for the specific requirements that the use of [Unforgeable] entails.
次の`~IDL片$は 片方に `Unforgeable$x が指定された 2 個の`属性$を持つ~ifcを定義する: ◎ The following IDL fragment defines an interface that has two attributes, one of which is designated as [Unforgeable]:
[Exposed=Window] interface System { [Unforgeable] readonly attribute DOMString username; readonly attribute long long loginTime; };
この~ifcの~ES実装においては、 `username^M 属性は,~obj自身において~configure不能な~propとして公開されることになる: ◎ In an ECMAScript implementation of the interface, the username attribute will be exposed as a non-configurable property on the object itself:
var %system = getSystem(); /* `System^T の~instanceを取得する。 ◎ Get an instance of System. */ %system.hasOwnProperty("username"); /* */ %system.hasOwnProperty("loginTime"); /* */ System.prototype.hasOwnProperty("username"); /* */ System.prototype.hasOwnProperty("loginTime"); /* */ try { /* この~callは失敗することになる — ~propは~configure不能なので。 ◎ This call would fail, since the property is non-configurable. */ Object.defineProperty(system, "username", { value: "administrator" }); } catch (%e) { } /* 次の `defineProperty^jp ~callは成功する — `System.prototype.loginTime^c が~configure可能なので。 ◎ This defineProperty call would succeed, because System.prototype.loginTime is configurable. */ var %forgedLoginTime = 5; Object.defineProperty(System.prototype, "loginTime", { value: %forgedLoginTime }); %system.loginTime; /* よって,これは今や %forgedLoginTime に評価される。 ◎ So this now evaluates to forgedLoginTime. */
3.3.24. `Unscopable^x
`Unscopable$x `拡張属性$が[ `正則~属性$/`正則~演算$ ] %m 上に現れた場合、[ %m を伴う~ifcを実装する~obj %O ]は, %O に伴われるどの[ ~obj環境~record ]内にも[ その基底~objとして, %m の~prop名 %N を内包しない ]ことを指示する。 その~~結果、 `with^c 文の中では,[ %N に合致する “素の” 識別子 ]は,その~propには解決されないことになる。 このふるまいは、 %N を[ `~ifc原型~obj$上の `unscopables$jS ~propの値 ]に含ませることで,得られる。 ◎ If the [Unscopable] extended attribute appears on a regular attribute or regular operation, it indicates that an object that implements an interface with the given interface member will not include its property name in any object environment record with it as its base object. The result of this is that bare identifiers matching the property name will not resolve to the property in a with statement. This is achieved by including the property name on the interface prototype object’s @@unscopables property’s value.
`Unscopable$x 拡張属性は: ◎ ↓
- `引数をとらない$ことが要求される。 ◎ The [Unscopable] extended attribute must take no arguments.
- [ `正則~属性$, `正則~演算$ ]以外の所に現れては~MUST_NOT。 ◎ The [Unscopable] extended attribute must not appear on anything other than a regular attribute or regular operation.
- `~ns$上で宣言される属性~上に利用されては~MUST_NOT。 ◎ The [Unscopable] extended attribute must not be used on an attribute declared on a namespace.
`Unscopable$x の利用に課される特有の要件については、 `interface-prototype-object$sec を見よ。 ◎ See §3.6.3 Interface prototype object for the specific requirements that the use of [Unscopable] entails.
例えば、次の~IDLが与えられたとき: ◎ For example, with the following IDL:
[Exposed=Window] interface Thing { void f(); [Unscopable] g(); };
`f^jp ~propは、 `with^c 文の中で “素の” 識別子により参照できるが, `g^jp ~propはできない: ◎ the f property can be referenced with a bare identifier in a with statement but the g property cannot:
var %thing = getThing(); /* `Thing^T の~instance ◎ An instance of Thing */ with (%thing) { f; /* `Function^jt ~objに評価される。 ◎ Evaluates to a Function object. */ g; /* `ReferenceError^jE が投出される。 ◎ Throws a ReferenceError. */ }
3.4. 保安~検査
以下の節の一部の~algoでは、所与の~objに対し `保安~検査を遂行する@ ものがある。 この検査は、所与の[ `演算$/`属性$ ] %m に対する[ 呼出/~access ]が許容されるべきかどうかを決定するために利用される。 保安~検査は、次の 3 つを入力にとる: ◎ Certain algorithms in the sections below are defined to perform a security check on a given object. This check is used to determine whether a given operation invocation or attribute access should be allowed. The security check takes the following three inputs:
- [ %m の呼出 / %m への~access ]が行われている当の`~platform~obj$ ◎ the platform object on which the operation invocation or attribute access is being done,
- %m の`識別子$ ◎ the identifier of the operation or attribute, and
-
%m を実装する`関数~obj$の種別 — 次のいずれかとして与えられる:
- `~meth^C ( %m が演算に対応するとき)
- `取得子^C ( %m が “取得子” 関数に対応するとき)
- `設定子^C ( %m が “設定子” 関数に対応するとき)
注記: 保安~検査がどう遂行されるかは、 HTML 仕様が定義する。 `HTML$r ◎ Note: The HTML Standard defines how a security check is performed. [HTML]
3.5. 多重定義~解決~algo
`関数類$の呼出を解決するために, `多重定義~解決~algo@ が定義される: ◎ In order to define how function invocations are resolved, the overload resolution algorithm is defined.\
-
その入力は:
- %S — `有効~多重定義~集合$
- %args — 一連の~ES値からなる`~list$
-
その出力は,次の組である:
- %S 内のいずれかの~entryの[ `演算$/`拡張属性$(構築子) ]
- 各項が[ ~IDL値/特殊~値 `missing^C ]であるような,~list
~algoは次に従って挙動する: ◎ The algorithm behaves as follows:
- %maxarg ~LET %S 内の各~entryの`型~list$oL の長さのうち,最大 ◎ Let maxarg be the length of the longest type list of the entries in S.
- %n ~LET %args の`~size$ ◎ Let n be the size of args.
- %argcount ~LET min(%maxarg, %n) ◎ Initialize argcount to be min(maxarg, n).
- %S から,次を満たす~entryはすべて除去する ⇒ `型~list$oL の長さ ~NEQ %argcount ◎ Remove from S all entries whose type list is not of length argcount.
- ~IF[ %S は空である ] ⇒ ~throwTypeError ◎ If S is empty, then throw a TypeError.
- %method ~LET `undefined^jv ◎ ↓
- %entry ~LET ε ◎ ↓
- %値~list ~LET 空~list(各項は[ ~IDL値/特殊~値 `missing^C ]になる) ◎ ↓
-
~IF[ %S は 1 個の~entryのみからなる ]:
- %entry ~SET その~entry
- ~GOTO `多重定義~解決-済み^i
- %d ~LET %S の~entryたちに対する`判別~引数~index$ ◎ ↑
- %i ~LET 0 ◎ Initialize i to 0.
-
~WHILE %i ~LT %d : ◎ While i < d:
- %V ~LET %args[ %i ] ◎ Let V be args[i].
-
%type ~LET %S から任意に選んだ~entryの `型~list$oL[ %i ] ◎ Let type be the type at index i in the type list of any entry in S.
注記: この時点では、 %S 内のすべての~entryにわたる,[ `型~list$oL[ %i ], および `省略可否~list$oL[ %i ] ]は 互いに同じである。 ◎ Note: All entries in S at this point have the same type and optionality value at index i.
- %省略可否 ~LET %S から任意に選んだ~entryの `省略可否~list$oL[ %i ] ◎ Let optionality be the value at index i in the list of optionality values of any entry in S.
-
~IF[ %省略可否 ~EQ “`省略可^C” ]~AND[ %V ~EQ `undefined^jv ]: ◎ If optionality is “optional” and V is undefined, then:
- ~IF[ ~index %i に位置する引数は `既定~値$を伴って宣言されている ] ⇒ %値~list にその既定~値を付加する ◎ If the argument at index i is declared with a default value, then append to values that default value.
- ~ELSE ⇒ %値~list に特殊~値 `missing^C を付加する ◎ Otherwise, append to values the special value “missing”.
- ~ELSE ⇒ %値~list に[ %V を %type 型の`~IDL値に変換-$した結果 ]を付加する ◎ Otherwise, append to values the result of converting V to IDL type type.
-
%V ~LET %args[ %i ] ◎ If i = d, then: ◎ Let V be args[i].
注記: この引数が、多重定義を解決するために利用される。 ◎ Note: This is the argument that will be used to resolve which overload is selected.
-
%entry ~SET 次の下位手続きを走らせた結果:
- ~IF[ %V ~EQ `undefined^jv ]~AND[ %S 内の~entryに[ `省略可否~list$oL[ %i ] ~EQ “`省略可^C” ]なるものが在る ] ⇒ ~RET 該当する~entry†
- ~ELIF[[ %V ~IN { `null^jv, `undefined^jv } ]~AND[ %S 内の~entryに[ その `型~list$oL[ %i ] は `~nullable型を内包する$ ]ものは在る ] ⇒ ~RET 該当する~entry†
-
下に示す “多重定義~選別表” の ~EACH( %行 ) に対し,挙げられた順に:
- ~IF[ %V は %行 の 1 列目の条件を満たさない ] ⇒ ~CONTINUE
- %型~集合 ~LET %行 の 2 列目に挙げられる型の集合
-
~IF[ %S 内の~entryに[ その `型~list$oL[ %i ] の`最内縁の型$ %T は、次のいずれかを満たす ]ものは在る ]…:
- %T は %型~集合 に属する
- [ %T は`共用体~型$である ]~AND[ %T の`平坦化~mb型$の中に %型~集合 に属するものが在る ]
…ならば ⇒ ~RET 該当する~entry††
- ~throwTypeError
【† いずれの場合も、 %S (`有効~多重定義~集合$)に課される拘束, %i (`判別~引数~index$)の定義により,該当する~entryは 1 個に限られる。 】【†† 下の表のどの行についても、 2 列目に挙げられた型たちは,どの 2 つも互いに`判別-可能$でない。 したがってこれも † と同様に、どの行についても, %S 内で条件を満たす~entryは高々 1 個になる。 】【 簡潔するため,この段では、原文の記述を再構成して,上の下位手続きと下の “多重定義~選別表” に集約している。 】
◎ If V is undefined, and there is an entry in S whose list of optionality values has “optional” at index i, then remove from S all other entries. ◎ ↓多重定義~選別表 %V が満たす条件 %型~集合 %V ~IN { `null^jv, `undefined^jv } ◎ Otherwise: if V is null or undefined, and there is an entry in S that has one of the following types at position i of its type list, `辞書~型$ ◎ • a nullable type • a dictionary type • an annotated type whose inner type is one of the above types • a union type or annotated union type that includes a nullable type or that has a dictionary type in its flattened members ◎ then remove from S all other entries. `~platform~obj$である ◎ Otherwise: if V is a platform object, and there is an entry in S that has one of the following types at position i of its type list, %V が実装する`~ifc型$, `object$T ◎ • an interface type that V implements • object • a nullable version of any of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. `DOMException^T ~objである ◎ Otherwise: if V is a DOMException platform object and there is an entry in S that has one of the following types at position i of its type list, `DOMException$T, `Error$T, `object$T ◎ • DOMException • Error • object • a nullable version of either of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. [ `Type$A( %V ) ~EQ `Object^jt ]~AND[ %V は `ErrorData^sl `内部~slot$を持つ ] ◎ Otherwise: if Type(V) is Object, V has an [[ErrorData]] internal slot, and there is an entry in S that has one of the following types at position i of its type list, `Error$T, `object$T ◎ • Error • object • a nullable version of either of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. [ `Type$A( %V ) ~EQ `Object^jt ]~AND[ %V は `ArrayBufferData^sl `内部~slot$を持つ ] ◎ Otherwise: if Type(V) is Object, V has an [[ArrayBufferData]] internal slot, and there is an entry in S that has one of the following types at position i of its type list, `ArrayBuffer$T, `object$T ◎ • ArrayBuffer • object • a nullable version of either of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. [ `Type$A( %V ) ~EQ `Object^jt ]~AND[ %V は `DataView^sl `内部~slot$を持つ ] ◎ Otherwise: if Type(V) is Object, V has a [[DataView]] internal slot, and there is an entry in S that has one of the following types at position i of its type list, `DataView$T, `object$T ◎ • DataView • object • a nullable version of either of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. [ `Type$A( %V ) ~EQ `Object^jt ]~AND[ %V は `TypedArrayName^sl `内部~slot$を持つ ] ◎ Otherwise: if Type(V) is Object, V has a [[TypedArrayName]] internal slot, and there is an entry in S that has one of the following types at position i of its type list, [ 型~名が %V の `TypedArrayName^sl `内部~slot$に等しい `有型~配列~型$ ], `object$T ◎ • a typed array type whose name is equal to the value of V’s [[TypedArrayName]] internal slot • object • a nullable version of either of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. `IsCallable$A( %V ) ~EQ ~T ◎ Otherwise: if IsCallable(V) is true, and there is an entry in S that has one of the following types at position i of its type list, `呼戻~関数$ 型, `object$T ◎ • a callback function type • object • a nullable version of any of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. [ `Type$A( %V ) ~EQ `Object^jt ]~AND[ 次を遂行した結果の %method ~NEQ `undefined^jv ]:
- %method ~SET ? `GetMethod$A( %V, `iterator$jS )
`連列~型$, `凍結~配列~型$ ◎ • a sequence type • a frozen array type • a nullable version of any of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ and after performing the following steps, • Let method be ? GetMethod(V, @@iterator). ◎ method is not undefined, then remove from S all other entries. `Type$A( %V ) ~EQ `Object^jt ◎ Otherwise: if Type(V) is Object and there is an entry in S that has one of the following types at position i of its type list, `呼戻~ifc$型, `辞書~型$, `~record型$, `object$T ◎ • a callback interface type • a dictionary type • a record type • object • a nullable version of any of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. `Type$A( %V ) ~EQ `Boolean^jt ◎ Otherwise: if Type(V) is Boolean and there is an entry in S that has one of the following types at position i of its type list, `boolean$T ◎ • boolean • a nullable boolean • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. `Type$A( %V ) ~EQ `Number^jt ◎ Otherwise: if Type(V) is Number and there is an entry in S that has one of the following types at position i of its type list, `実数~型$ ◎ • a numeric type • a nullable numeric type • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. 無条件 ◎ Otherwise: if there is an entry in S that has one of the following types at position i of its type list, `文字列~型$ ◎ • a string type • a nullable version of any of the above types • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. 無条件 ◎ Otherwise: if there is an entry in S that has one of the following types at position i of its type list, `実数~型$ ◎ • a numeric type • a nullable numeric type • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. 無条件 ◎ Otherwise: if there is an entry in S that has one of the following types at position i of its type list, `boolean$T ◎ • boolean • a nullable boolean • an annotated type whose inner type is one of the above types • a union type, nullable union type, or annotated union type that has one of the above types in its flattened member types ◎ then remove from S all other entries. 無条件 `any$T ◎ Otherwise: if there is an entry in S that has any at position i of its type list, then remove from S all other entries. ◎ ↑↑Otherwise: throw a TypeError. -
`多重定義~解決-済み^i:
%callable ~LET %entry の `~callable$oL ( `演算$/`拡張属性$ ) ◎ Let callable be the operation or extended attribute of the single entry in S. -
~IF[ %i ~EQ %d ]~AND[ %method ~NEQ `undefined^jv ]: ◎ If i = d and method is not undefined, then
- %V ~LET %args[ %i ] ◎ Let V be args[i].
- %T ~LET %entry の `型~list$oL[ %i ] ◎ Let T be the type at index i in the type list of the remaining entry in S.
- ~IF[ %T は`連列~型$である ] ⇒ %値~list に次の結果を付加する ⇒ ( %V, %method ) から 型 %T の`連列~値を作成-$した結果 ◎ If T is a sequence type, then append to values the result of creating a sequence of type T from V and method.
- ~ELSE( %T は`凍結~配列~型$である) ] ⇒ %値~list に次の結果を付加する ⇒ ( %V, %method ) から 型 %T の`凍結~配列~値を作成-$した結果 ◎ Otherwise, T is a frozen array type. Append to values the result of creating a frozen array of type T from V and method.
-
~WHILE %i ~LT %argcount : ◎ While i < argcount:
- %V ~LET %args[ %i ] ◎ Let V be args[i].
- %type ~LET %entry の `型~list$oL[ %i ] ◎ Let type be the type at index i in the type list of the remaining entry in S.
- %省略可否 ~LET %entry の `省略可否~list$oL[ %i ] ◎ Let optionality be the value at index i in the list of optionality values of the remaining entry in S.
-
~WHILE %i ~LT %callable が宣言している引数~個数: ◎ While i is less than the number of arguments callable is declared to take:
- ~IF[ %callable の~index %i に位置する引数に `既定~値$ が宣言されている ] ⇒ %値~list にその既定~値を付加する ◎ If callable’s argument at index i is declared with a default value, then append to values that default value.
- ~ELIF[ %callable の~index %i に位置する引数は`可変個~引数$でない ] ⇒ %値~list に特殊~値 `missing^C を付加する ◎ Otherwise, if callable’s argument at index i is not variadic, then append to values the special value “missing”.
- ~RET ~pair <%callable, %値~list> ◎ Return the pair <callable, values>.
多重定義~解決~algoは、~callされている[ 多重定義された`関数類$ ]の識別に加えて、 ~ES引数~値から,それぞれに対応する~IDL値への変換を遂行する。 概略的には次のように演算する。 ◎ The overload resolution algorithm performs both the identification of which overloaded operation, constructor, etc. is being called, and the conversion of the ECMAScript argument values to their corresponding IDL values. Informally, it operates as follows.
まず、関数に渡された~ES引数の個数を考慮しつつ,妥当な多重定義の選定が行われる: ◎ First, the selection of valid overloads is done by considering the number of ECMAScript arguments that were passed in to the function:
- 最長の多重定義~引数~listより多い引数が渡された場合、余分な引数は無視する。 ◎ If there are more arguments passed in than the longest overload argument list, then they are ignored.
- 考慮する必要があるのは、余分な引数を無視した後の引数の個数, および同じ個数の引数をとれる多重定義に限られる。 もし無ければ, `TypeError^jE が投出される。 ◎ After ignoring these trailing arguments, only overloads that can take this exact number of arguments are considered. If there are none, then a TypeError is thrown.
~~正しい個数の引数をとる,アリな多重定義の集合が得られたなら、 ~ES値は左から右の順に変換される。 多重定義に対する制約の定義から、この時点でアリな多重定義が複数ある場合、引数~listの中で,最終的に選定される多重定義を判別する際の~~基準となる位置がある。 これが`判別~引数~index$である。 ◎ Once we have a set of possible overloads with the right number of arguments, the ECMAScript values are converted from left to right. The nature of the restrictions on overloading means that if we have multiple possible overloads at this point, then there will be one position in the argument list that will be used to distinguish which overload we will finally select; this is the distinguishing argument index.
まず最初に,判別~引数より左に位置する引数を変換する(これらの引数については、同じ~indexに位置する他の多重定義の引数と同じ型であることが要件にされている)。 次に、対応し得る~IDL型を決定するために,判別~引数~indexの位置に渡された~ES値の型を検分する。 これにより、呼出されることになる多重定義の最終的な選定が可能になる。 [ 渡された値は `undefined^jv である ]~AND[ この位置に随意~引数を伴う多重定義がある ]場合、その多重定義が選定される。 このとき,渡された値の型に対する妥当な多重定義が無ければ、 `TypeError^jE が投出される。 判別~引数~indexに位置する値の検分は副作用を持たない。 多重定義~解決~algoを走らすことに因る唯一の副作用は、 ~ES値から~IDL値への変換-に因るものに限られる。 ◎ We first convert the arguments to the left of the distinguishing argument. (There is a requirement that an argument to the left of the distinguishing argument index has the same type as in the other overloads, at the same index.) Then we inspect the type of the ECMAScript value that is passed in at the distinguishing argument index to determine which IDL type it may correspond to. This allows us to select the final overload that will be invoked. If the value passed in is undefined and there is an overload with an optional argument at this position, then we will choose that overload. If there is no valid overload for the type of value passed in here, then we throw a TypeError. The inspection of the value at the distinguishing argument index does not have any side effects; the only side effects that come from running the overload resolution algorithm are those that come from converting the ECMAScript values to IDL values.
この時点で,利用する多重定義が決定されたことになる。 しかる後、判別~引数に後続する残りの引数~値も左から右の順に変換する。 ここでも,前述の余分な引数は、無視される。 ◎ At this point, we have determined which overload to use. We now convert the remaining arguments, from the distinguishing argument onwards, again ignoring any additional arguments that were ignored due to being passed after the last possible argument.
随意~引数の~ES値からそれに等価な~IDL値へ変換する際には、 `undefined^jv は,[ 随意~引数に`既定~値$が在ればそれに/ 無ければ特殊~値 `missing^C に ]変換されることになる。 ◎ When converting an optional argument’s ECMAScript value to its equivalent IDL value, undefined will be converted into the optional argument’s default value, if it has one, or a special value “missing” otherwise.
しかしながら、`可変個~引数$に対応する随意~引数に対する `undefined^jv は,特殊~値 `missing^C とは見なされない。 この場合の `undefined^jv 値は、必須の引数と同様に,`可変個~引数$の型に変換されることになる。 ◎ Optional arguments corresponding to a final, variadic argument do not treat undefined as a special “missing” value, however. The undefined value is converted to the type of variadic argument as would be done for a non-optional argument.
3.6. ~ifc
所与の~ES大域~環境 %G にて`公開されて$いる,どの`~ifc$ %I に対しても:
-
%I が[ `NoInterfaceObject$x, `LegacyNamespace$x ]いずれの`拡張属性$も伴わずに宣言されているならば、 %I に対応して,次の特徴を有する~propが %G の大域~obj上に存在し~MUST:
- 名前: %I の`識別子$
- 値: `~ifc~obj@ と呼ばれる~obj — この~objの特徴については、下の `interface-object$sec にて述べる。
- 属性 `TFT^desc を持つ。
-
%I に `LegacyWindowAlias$x 拡張属性が指定されている場合、その拡張属性~内の各`識別子$wAに対し, `Window$T `~ifc$上にも[ 次の特徴を有する,対応する~prop ]が存在し~MUST:
- 名前: その`識別子$wA
- 値: %I 用の`~ifc~obj$への参照
- 属性 `TFT^desc を持つ
-
加えて, %I に `NamedConstructor$x 拡張属性たちが伴われるならば、そのそれぞれに対し,次の特徴を有する~propが %G の大域~obj上に存在し~MUST:
- 名前: `NamedConstructor$x 拡張属性の`識別子$nC
- 値: `有名~構築子@ と呼ばれる~obj — それは、 %I を実装する~objの構築を可能にする。 この構築子の特徴については、下の `named-constructors$sec にて述べる。
3.6.1. ~ifc~obj
所与の`~ifc$ %I 用の`~ifc~obj$ %O は、`組込みの関数~obj$である: ◎ The interface object for a given interface is a built-in function object.\
- %O は、 %I 上に定義される各[ `定数$/`静的~演算$ ]ごとに対応する~propを持つ — 詳細は `es-constants$sec, `es-operations$sec にて述べる。 ◎ It has properties that correspond to the constants and static operations defined on that interface, as described in sections §3.6.6 Constants and §3.6.8 Operations.
- %I は `Constructor$x `拡張属性$を伴って宣言されている場合、 %O を`構築子$として~callして, %I を実装する~objを作成できる。 %I を関数として~callした場合、例外が投出される。 ◎ If the interface is declared with a [Constructor] extended attribute, then the interface object can be called as a constructor to create an object that implements that interface. Calling that interface as a function will throw an exception.
- %I は `Constructor$x `拡張属性$を伴わずに宣言されている場合、`構築子$として~callしようが関数として~callしようが,例外が投出される。 ◎ Interface objects whose interfaces are not declared with a [Constructor] extended attribute will throw when called, both as a function and as a constructor.
- %I は非~呼戻`~ifc$である場合、 %O には`~ifc原型~obj$と呼ばれる~objが結付けられる — それは、 %I 上に定義される各[ `正則~属性$ / `正則~演算$ ]ごとに対応する~propを持つ — 詳細は `interface-prototype-object$sec にて述べる。 ◎ An interface object for a non-callback interface has an associated object called the interface prototype object. This object has properties that correspond to the regular attributes and regular operations defined on the interface, and is described in more detail in §3.6.3 Interface prototype object.
注記: `~ifc~obj$は `関数~obj$なので、 `typeof^c 演算子が適用されたときは, "`function^jv" を返すことになる。 ◎ Note: Since an interface object is a function object the typeof operator will return "function" when applied to an interface object.
非~呼戻`~ifc$用の`~ifc~obj$は、以下に従って作成される — `~ifc~objを作成する@ ときは、所与の ( 非~呼戻`~ifc$ %I, `識別子$ %識別子, `~Realm$ %~realm ) に対し,次を走らす: ◎ The interface object for a given non-callback interface I with identifier id and in Realm realm is created as follows:
-
%手続き ~LET 以下を走らす手続き: ◎ Let steps be the following steps:
- ~IF[ %I は `Constructor$x `拡張属性$を伴って宣言されていない ] ⇒ ~throwTypeError ◎ If I was not declared with a [Constructor] extended attribute, then throw a TypeError.
- ~IF[ `NewTarget$ ~EQ `undefined^jv ] ⇒ ~throwTypeError ◎ If NewTarget is undefined, then throw a TypeError.
- %args ~LET 渡された引数たちからなる~list ◎ Let args be the passed arguments.
- %S ~LET %I 上の構築子のうち[ `識別子$ %識別子, 引数個数 %n ]から得られる`有効~多重定義~集合$ ◎ Let id be the identifier of interface I. 原文削除漏れ ◎ Initialize S to the effective overload set for constructors with identifier id on interface I and with argument count n.
- <%構築子, %値~list> ~LET %S と %args を`多重定義~解決~algo$に渡した結果 ◎ Let <constructor, values> be the result of passing S and args. to the overload resolution algorithm.
- %R ~LET %値~list を一連の引数~値として[ %構築子 の記述に挙げられている手続き ]を遂行した結果 — 例外は再~投出する ◎ Let R be the result of performing the actions listed in the description of constructor with values as the argument values. Rethrow any exceptions.
- %O ~LET %R を`~ifc型$ %I の値とする下で`~ES値に変換-$した結果 ◎ Let O be the result of converting R to an ECMAScript interface type value I.
- ~Assert: %O は %I を実装する~objである ◎ Assert: O is an object that implements I.
- ~Assert: %O.`Realm^sl ~EQ %~realm ◎ Assert: O.[[Realm]] is equal to realm.
- ~RET %O ◎ Return O.
- %構築子~原型 ~LET %~realm.`FunctionPrototype$jIsl ◎ Let constructorProto be realm.[[Intrinsics]].[[%FunctionPrototype%]].
- ~IF[ %I は他の~ifc %P を継承する ] ⇒ %構築子~原型 ~SET %~realm に属する %P 用の`~ifc~obj$ ◎ If I inherits from some other interface P, then set constructorProto to the interface object of P in realm.
- %F ~LET ! `CreateBuiltinFunction$A( %~realm, %手続き, %構築子~原型 ) ◎ Let F be ! CreateBuiltinFunction(realm, steps, constructorProto).
- ! `SetFunctionName$A( %F, %識別子 ) ◎ Perform ! SetFunctionName(F, id).
- %長さ ~LET 0 ◎ Let length be 0.
-
~IF[ %I は `Constructor$x 拡張属性を伴って宣言されている ]: ◎ If I was declared with a [Constructor] extended attribute, then
- %S ~LET `~ifc$ %I 上の構築子のうち[ `識別子$ %識別子, 引数個数 0 ]から得られる`有効~多重定義~集合$ ◎ Initialize S to the effective overload set for constructors with identifier id on interface I and with argument count 0.
- %長さ ~SET %S 内の各~entryの引数~listの長さのうち,最小 ◎ Set length to the length of the shortest argument list of the entries in S.
- ! `SetFunctionLength$A( %F, %長さ ) ◎ Perform ! SetFunctionLength(F, length).
- %proto ~LET %~realm 内で %I を成す`~ifc原型~obj$ ◎ Let proto be the interface prototype object of interface I in realm.
- ! `DefinePropertyOrThrow$A( %F, `prototype^l, `FFF-proto^desc ) ◎ Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor{[[Value]]: proto, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false}).
- `定数を定義する$( %I, %F, %~realm ) ◎ Define the constants of interface I on F given realm.
- `静的~属性を定義する$( %I, %F, %~realm ) ◎ Define the static attributes of interface I on F given realm.
- ~RET %F ◎ Return F.
3.6.2. 有名~構築子
`有名~構築子$は、`識別子$nCを伴う 1 個~以上の `NamedConstructor$x `拡張属性$に因り存在することになる,`組込みの関数~obj$である。 それは、その拡張属性が現れる`~ifc$(以下 %I とする)を実装する~objの構築を可能にする。 ◎ A named constructor that exists due to one or more [NamedConstructor] extended attributes with a given identifier is a built-in function object. It allows constructing objects that implement the interface on which the [NamedConstructor] extended attributes appear.
`有名~構築子$の記述に挙げられる手続きは、例外を投出しないならば, %I を実装する~objを返さ~MUST。 この~objに`関連する~Realm$は、有名~構築子のそれと同じで~MUST。 ◎ If the actions listed in the description of the constructor return normally, then those steps must return an object that implements interface I. This object’s relevant Realm must be the same as that of the named constructor.
`~ifc$用の`有名~構築子$は、以下に従って作成される — `有名~構築子を作成する@ ときは、所与の ( `~ifc$ %I, `識別子$ %識別子, `~Realm$ %~realm ) に対し,次を走らす: ◎ The named constructor with identifier id for a given interface I in Realm realm is created as follows:
- %識別子 ~LET `有名~構築子$の`識別子$nC ◎ ↑
-
- ~RET %R を`~ifc型$ %I の値とする下で`~ES値に変換-$した結果 ◎ Return the result of converting R to an ECMAScript interface type value I.
- %F ~LET ! `CreateBuiltinFunction$A( %~realm, %手続き, %~realm.`FunctionPrototype$jIsl ) ◎ Let F be ! CreateBuiltinFunction(realm, steps, realm.[[Intrinsics]].[[%FunctionPrototype%]]).
- %長さ ~LET %S 内の各~entryの引数~listの長さのうち,最小 ◎ Let length be the length of the shortest argument list of the entries in S.
3.6.3. ~ifc原型~obj
定義されたどの非~呼戻`~ifc$に対しても、その~ifcが `NoInterfaceObject$x `拡張属性$を伴って宣言されたかどうかに関わらず,対応する `~ifc原型~obj@ が存在し~MUST。 ◎ There must exist an interface prototype object for every non-callback interface defined, regardless of whether the interface was declared with the [NoInterfaceObject] extended attribute.
`~ifc$用の`~ifc原型~obj$は、以下に従って作成される — `~ifc原型~objを作成する@ ときは、所与の ( `~ifc$ %~ifc, `~Realm$ %~realm ) に対し,次を走らす: ◎ The interface prototype object for a given interface interface and Realm realm is created as follows:
- %原型 ~LET ~NULL ◎ Let proto be null.
- ~IF[ %~ifc は `Global$x `拡張属性$を伴って宣言されている ]~AND[ %~ifc は`有名~propを~support$する ] ⇒ %原型 ~SET %~realm 内の, %~ifc の`有名~prop~obj$ ◎ If interface is declared with the [Global] extended attribute, and interface supports named properties, then set proto to the named properties object in realm of interface.
- ~ELIF[ %~ifc は別の~ifc %B を`継承-$するように宣言されている ] ⇒ %原型 ~SET %~realm 内の %B 用の`~ifc原型~obj$ ◎ Otherwise, if interface is declared to inherit from another interface, then set proto to the interface prototype object in realm of that inherited interface.
- ~ELIF[ %~ifc は `DOMException$T `~ifc$である ] ⇒ %原型 ~SET %~realm.`ErrorPrototype$jIsl ◎ Otherwise, if interface is the DOMException interface, then set proto to realm.[[Intrinsics]].[[%ErrorPrototype%]].
- ~ELSE ⇒ %原型 ~SET %~realm.`ObjectPrototype$jIsl ◎ Otherwise, set proto to realm.[[Intrinsics]].[[%ObjectPrototype%]].
- ~Assert: `Type$A( %原型 ) ~EQ `Object^jt ◎ Assert: Type(proto) is Object.
- %~ifc原型~obj ~LET ! `ObjectCreate$A( %原型 ) ◎ Let interfaceProtoObj be ! ObjectCreate(proto).
-
~IF[ %~ifc のある`~mb$は `Unscopable$x `拡張属性$を伴って宣言されている ]: ◎ If interface has any member declared with the [Unscopable] extended attribute, then:
%~ifc は `Global$x `拡張属性$を伴って宣言されている場合、 `toStringTag$jS ~propも定義されるべきか? これは issue #544 にて論じられている。 ◎ Should an @@unscopables property also be defined if interface is declared with the [Global] extended attribute? This is discussed in issue #544.
- %~scope不能~obj ~LET ! `ObjectCreate$A( `null^jv ) ◎ Let unscopableObject be the result of performing ! ObjectCreate(null).
-
%~ifc に`公開されて$いる, かつ `Unscopable$x `拡張属性$を伴って宣言されている ~EACH( `~mb$ %~mb ) に対し: ◎ For each exposed member member of interface that is declared with the [Unscopable] extended attribute:
- %識別子 ~LET %~mb の`識別子$ ◎ Let id be member’s identifier.
- ! `CreateDataProperty$A( %~scope不能~obj, %識別子, `true^jv ) ◎ Perform ! CreateDataProperty(unscopableObject, id, true).
- %記述子 ~LET `FFT-~scope不能~obj^desc ◎ Let desc be the PropertyDescriptor{[[Value]]: unscopableObject, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}.
- ! `DefinePropertyOrThrow$A( %~ifc原型~obj, `toStringTag$jS, %記述子 ) ◎ Perform ! DefinePropertyOrThrow(interfaceProtoObj, @@unscopables, desc).
-
~IF[ %~ifc は `Global$x `拡張属性$を伴って宣言されている ]~OR[ %~ifc は ある[ `Global$x `拡張属性$を伴って宣言されている~ifc ]の`継承d~ifc$である ]: ◎ If interface is declared with the [Global] extended attribute, or interface is in the set of inherited interfaces of an interface that is declared with the [Global] extended attribute, then:
- %~ifc原型~obj を成す[ `変異-不能な原型~exotic~obj$に特有の内部~methたち ]を[ `変異-不能な原型~exotic~obj$節に指定される定義たち ]に設定する ◎ Set the internal methods of interfaceProtoObj which are specific to immutable prototype exotic objects to the definitions specified in ECMA-262 §9.4.7 Immutable prototype exotic objects.
-
~IF[ %~ifc は `Global$x `拡張属性$を伴って宣言されていない ]: ◎ If interface is not declared with the [Global] extended attribute, then:
- `正則~属性を定義する$( %~ifc, %~ifc原型~obj, %~realm ) ◎ Define the regular attributes of interface on interfaceProtoObj given realm.
- `正則~演算を定義する$( %~ifc, %~ifc原型~obj, %~realm ) ◎ Define the regular operations of interface on interfaceProtoObj given realm.
- `定数を定義する$( %~ifc, %~ifc原型~obj, %~realm ) ◎ Define the constants of interface on interfaceProtoObj given realm.
-
~IF[ %~ifc には `NoInterfaceObject$x `拡張属性$は指定されていない ]: ◎ If the [NoInterfaceObject] extended attribute was not specified on interface, then:
- %構築子 ~LET %~realm 内で %~ifc を成す`~ifc~obj$ ◎ Let constructor be the interface object of interface in realm.
- %記述子 ~LET `TFT-構築子^desc ◎ Let desc be the PropertyDescriptor{[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true, [[Value]]: constructor}.
- ! `DefinePropertyOrThrow$A( %~ifc原型~obj, `constructor^l, %記述子 ) ◎ Perform ! DefinePropertyOrThrow(interfaceProtoObj, "constructor", desc).
- ~RET %~ifc原型~obj ◎ Return interfaceProtoObj.
加えて,`~ifc原型~obj$は、次に挙げるものから宣言的に~propを取得する ⇒# `es-stringifier$sec, `es-iterators$sec, `es-iterable$sec, `es-maplike$sec, `es-setlike$sec ◎ Additionally, interface prototype objects get properties declaratively from: • §3.6.8.2 Stringifiers, • §3.6.9 Common iterator behavior, • §3.6.10 Iterable declarations, • §3.6.11 Maplike declarations, and • §3.6.12 Setlike declarations.
これらの~propを,代わりに命令的に定義する。 ◎ Define those properties imperatively instead.
`NoInterfaceObject$x `拡張属性$を伴って定義された`~ifc$用の`~ifc原型~obj$は、~access可能になる。 例えば、次の~IDLでは: ◎ The interface prototype object of an interface that is defined with the [NoInterfaceObject] extended attribute will be accessible. For example, with the following IDL:
[Exposed=Window, NoInterfaceObject] interface Foo { }; partial interface Window { attribute Foo foo; };
`~ifc~obj$を通して ~ifc原型~objに~accessすることはアリでない( `window.Foo^c として存在しないので)。 しかしながら, `Foo^T の~instanceは、その `GetPrototypeOf^sl `内部~meth$を~callすること — この例では, `Object.getPrototypeOf(window.foo)^c — により,~ifc原型~objを公開できる。 ◎ it is not possible to access the interface prototype object through the interface object (since it does not exist as window.Foo). However, an instance of Foo can expose the interface prototype object by calling its [[GetPrototypeOf]] internal method – Object.getPrototypeOf(window.foo) in this example.
`~ifc原型~obj$の `~class文字列$は、次の連結とする ⇒# `~ifc$の`識別子$, 文字列 `Prototype^l ◎ The class string of an interface prototype object is the concatenation of the interface’s identifier and the string "Prototype".
3.6.4. 旧来の呼戻~ifc~obj
所与の~ES大域~環境 %G にて`公開されて$いる どの`呼戻~ifc$ %I に対しても、 %I 上に`定数$が定義されているならば %G の大域~obj上に,次の特徴を有するような 対応する~propが存在し~MUST:
- 名前: %I の`識別子$
- 値: `旧来の呼戻~ifc~obj@ と呼ばれる~obj
所与の`~ifc$ %I 用の`旧来の呼戻~ifc~obj$は、`組込みの関数~obj$であり、下の `es-constants$sec にて述べるように, %I 上に定義される`定数$のそれぞれに対応する~propを持つ。 ◎ The legacy callback interface object for a given callback interface is a built-in function object. It has properties that correspond to the constants defined on that interface, as described in sections §3.6.6 Constants.
注記: `旧来の呼戻~ifc~obj$は `関数~obj$なので、 `typeof^c 演算子が適用されたときは, "`function^jv" を返すことになる。 ◎ Note: Since a legacy callback interface object is a function object the typeof operator will return "function" when applied to a legacy callback interface object.
`呼戻~ifc$用の`旧来の呼戻~ifc~obj$は、以下に従って作成される — `旧来の呼戻~ifc~objを作成する@ ときは、所与の ( `呼戻~ifc$ %I, `識別子$ %識別子, `~Realm$ %~realm ) に対し,次を走らす: ◎ The legacy callback interface object for a given callback interface interface with identifier id and in Realm realm is created as follows:
-
- ! `SetFunctionLength$A( %F, 0 ) ◎ Perform ! SetFunctionLength(F, 0).
- `定数を定義する$( %I, %F, %~realm ) ◎ Define the constants of interface on F given realm.
3.6.5. 有名~prop~obj
`Global$x `拡張属性$を伴って宣言されていて, かつ `有名~propを~support$する どの`~ifc$に対しても、その~ifcに対応する `有名~prop~obj@ と呼ばれる~objが,当の有名~propが公開される~ifc上に存在し~MUST。 ◎ For every interface declared with the [Global] extended attribute that supports named properties, there must exist an object known as the named properties object for that interface on which named properties are exposed.
`~ifc$用の`有名~prop~obj$は、以下に従って作成される — `有名~prop~objを作成する@ ときは、所与の ( `~ifc$ %~ifc, `~Realm$ %~realm ) に対し,次を走らす: ◎ The named properties object for a given interface interface and Realm realm, is created as follows:
- %原型 ~LET ~NULL ◎ Let proto be null.
- ~IF[ %~ifc は別の~ifc %B を`継承-$するように宣言されている ] ⇒ %原型 ~SET %~realm 内の %B 用の`~ifc原型~obj$ ◎ If interface is declared to inherit from another interface, then set proto to the interface prototype object in realm for the inherited interface.
- %~obj ~LET 新たな~obj ◎ Let obj be a newly created object.
-
%~obj を成す内部~methたちを[ `普通の~objの内部~methと内部~slot$節に指定される定義たち `ECMA-262$r ]に設定する — ただし、以下に与えるものは,それに従って指定する: ◎ Set obj’s internal methods to the definitions specified in ECMA-262 §9.1 Ordinary object internal methods and internal slots, unless they are specified in the the rest of §3.6.5 Named properties object. ◎ Set obj’s remaining internal methods to the definitions specified below.
- %~obj.`Prototype^sl ~SET %原型 ◎ Set obj.[[Prototype]] to proto.
- %~obj.`Extensible^sl ~SET `true^jv ◎ Set obj.[[Extensible]] to true.
- ~RET %~obj ◎ Return obj.
`有名~prop~obj$の `~class文字列$は、次の連結とする ⇒# `~ifc$の`識別子$, 文字列 `Properties^l ◎ The class string of a named properties object is the concatenation of the interface’s identifier and the string "Properties".
3.6.5.1. `GetOwnProperty^sl
`有名~prop~obj$ %O の `GetOwnProperty^sl 内部~methが ~prop名 %P を伴って~callされたときは、次を走らす: ◎ When the [[GetOwnProperty]] internal method of a named properties object O is called with property key P, the following steps are taken:
- %A ~LET %O 用の`~ifc$ ◎ Let A be the interface for the named properties object O.
-
%object ~LET %O が属する~ES大域~環境に属する, %A を実装する~~唯一の~obj ◎ Let object be the sole object from O’s ECMAScript global environment that implements A.
注記: 例えば,`~ifc$が HTML5 で定義される `Window^T ~ifcならば、この大域~環境の window ~objが~~唯一の~objになる。 ◎ Note: For example, if the interface is the Window interface, then the sole object will be this global environment’s window object.
-
~IF[ `有名~propは可視か?$( %P, %object ) ~EQ ~T ]: ◎ If the result of running the named property visibility algorithm with property name P and object object is true, then:
- %演算 ~LET `有名~prop取得子$の宣言-時に利用された演算 ◎ Let operation be the operation used to declare the named property getter.
- %value ~LET 未初期化の変数 ◎ Let value be an uninitialized variable.
- ~IF[ %演算 は `識別子$なしに定義されている ] ⇒ %value ~SET [ 名前 %P を与える下で[ ~ifcの記述に挙げられている`有名~propの値を決定する$手続き ]を遂行した結果 ] ◎ If operation was defined without an identifier, then set value to the result of performing the steps listed in the interface description to determine the value of a named property with P as the name.
- ~ELSE ⇒ %value ~SET ( %P ) を引数に[ %演算 の記述に挙げられている手続き ]を遂行した結果 ◎ Otherwise, operation was defined with an identifier. Set value to the result of performing the steps listed in the description of operation with P as the only argument value.
-
~RET 次の様な新たな`~pdesc$: ◎ Let desc be a newly created Property Descriptor with no fields.
`TET-V^desc — ここで:- %V は %value を`~ES値に変換-$した結果
- %E は [ %A が実装するある~ifcに `LegacyUnenumerableNamedProperties$x `拡張属性$が伴われているならば `false^jv / ~ELSE_ `true^jv ]
- ~RET `OrdinaryGetOwnProperty$A( %O, %P ) ◎ Return OrdinaryGetOwnProperty(O, P).
3.6.5.2. `DefineOwnProperty^sl
`有名~prop~obj$の `DefineOwnProperty^sl 内部~methが~callされたときは、次を走らす: ◎ When the [[DefineOwnProperty]] internal method of a named properties object is called, the following steps are taken:
- ~RET `false^jv ◎ Return false.
3.6.5.3. `Delete^sl
`有名~prop~obj$の `Delete^sl 内部~methが~callされたときには,次を走らす: ◎ When the [[Delete]] internal method of a named properties object is called, the following steps are taken:
- ~RET `false^jv ◎ Return false.
3.6.5.4. `SetPrototypeOf^sl
`有名~prop~obj$ %O の `SetPrototypeOf^sl 内部~methが,~ES言語~値 %V で~callされたときは、次を走らす: ◎ When the [[SetPrototypeOf]] internal method of a named properties object O is called with ECMAScript language value V, the following step is taken:
- ~RET ? `SetImmutablePrototype$A( %O, %V ) ◎ Return ? SetImmutablePrototype(O, V).
3.6.5.5. `PreventExtensions^sl
`有名~prop~obj$の `PreventExtensions^sl 内部~methが~callされたときは、次を走らす: ◎ When the [[PreventExtensions]] internal method of a named properties object is called, the following steps are taken:
- ~RET `false^jv ◎ Return false.
注記: これにより、`有名~prop~obj$は 拡張-可能に保たれる — それらに対する `PreventExtensions^sl を失敗させることにより。 ◎ Note: this keeps named properties object extensible by making [[PreventExtensions]] fail.
3.6.6. 定数
`定数$は[ `~ifc~obj$ / `旧来の呼戻~ifc~obj$ / `~ifc原型~obj$ ]上に — 当の~ifcは `Global$x `拡張属性$を伴って宣言されているときには,~ifcを実装する単独の~obj上に — 公開される。 ◎ Constants are exposed on interface objects, legacy callback interface objects, interface prototype objects, and on the single object that implements the interface, when an interface is declared with the [Global] extended attribute.
`定数を定義する@ ときは、所与の ( `~ifc$ %~ifc, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the constants of interface interface on target, given Realm realm, run the following steps:
-
%~ifc を成す`~mb$のうち,`定数$である ~EACH( %定数 ) に対し: ◎ For each constant const that is a member of interface:
- ~IF[ %定数 は%~realm 内に`公開されて$いない ] ⇒ ~CONTINUE ◎ If const is not exposed in realm, then continue.
- %値 ~LET %定数 の~IDL値を`~ES値に変換-$した結果 ◎ Let value be the result of converting const’s IDL value to an ECMAScript value.
- %記述子 ~LET `FTF-値^desc ◎ Let desc be the PropertyDescriptor{[[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false, [[Value]]: value}.
- %識別子 ~LET %定数 の`識別子$ ◎ Let id be const’s identifier.
- ! `DefinePropertyOrThrow$A( %~target, %識別子, %記述子 ) ◎ Perform ! DefinePropertyOrThrow(target, id, desc).
3.6.7. 属性
`静的~属性$は、`~ifc~obj$上に公開される。 `正則~属性$は、`~ifc原型~obj$上に公開される — ただし,[ 属性は`偽装-不能$である/ 当の~ifcは `Global$x `拡張属性$を伴って宣言されている ]事例では、その~ifcを実装する どの~objにも公開される。 ◎ Static attributes are exposed on the interface object. Regular attributes are exposed on the interface prototype object, unless the attribute is unforgeable or if the interface was declared with the [Global] extended attribute, in which case they are exposed on every object that implements the interface.
`正則~属性を定義する@ ときは、所与の ( `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the regular attributes of interface or namespace definition on target, given Realm realm, run the following steps:
- %属性たち ~LET [ %定義 を成す`~mb$のうち,`正則~属性$である, かつ `偽装-不能$でないもの ]からなる`~list$ ◎ Let attributes be the list of regular attributes that are members of definition. ◎ Remove from attributes all the attributes that are unforgeable.
- `属性を定義する$( %属性たち, %定義, %~target, %~realm ) ◎ Define the attributes attributes of definition on target given realm.
`静的~属性を定義する@ ときは、所与の ( `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the static attributes of interface or namespace definition on target, given Realm realm, run the following steps:
- %属性たち ~LET [ %定義 を成す`~mb$のうち,`静的~属性$であるもの ]からなる`~list$ ◎ Let attributes be the list of static attributes that are members of definition.
`偽装-不能な正則~属性を定義する@ ときは、所与の ( `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the unforgeable regular attributes of interface or namespace definition on target, given Realm realm, run the following steps:
- %属性たち ~LET [ %定義 を成す`~mb$のうち,`正則~属性$である, かつ `偽装-不能$であるもの ]からなる`~list$ ◎ Let attributes be the list of unforgeable regular attributes that are members of definition.
`属性を定義する@ ときは、所与の ( %属性たち, `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the attributes attributes of interface or namespace definition on target given Realm realm, run the following steps:
-
%属性たち を成す ~EACH( `属性$ %属性 ) に対し: ◎ For each attribute attr of attributes:
- ~IF[ %属性 は %~realm 内に`公開されて$いない ] ⇒ ~CONTINUE ◎ If attr is not exposed in realm, then continue.
- %取得子 ~LET `属性~取得子を作成する$( %属性, %定義, %~realm ) ◎ Let getter be the result of creating an attribute getter given attr, definition, and realm.
-
%設定子 ~LET `属性~設定子を作成する$( %属性, %定義, %~realm ) ◎ Let setter be the result of creating an attribute setter given attr, definition, and realm.
注記: `属性~設定子を作成する$~algoは、 %属性 は`読専$である場合には `undefined^jv を返す。 ◎ Note: the algorithm to create an attribute setter returns undefined if attr is read only.
- %~configure可能 ~LET [ %属性 は`偽装-不能$であるならば `false^jv / ~ELSE_ `true^jv ] ◎ Let configurable be false if attr is unforgeable and true otherwise.
- %記述子 ~LET { [[Get]]: %取得子, [[Set]]: %設定子, [[Enumerable]]: `true^jv, [[Configurable]]: %~configure可能 } ◎ Let desc be the PropertyDescriptor{[[Get]]: getter, [[Set]]: setter, [[Enumerable]]: true, [[Configurable]]: configurable}.
- %識別子 ~LET %属性 の`識別子$ ◎ Let id be attr’s identifier.
- ! `DefinePropertyOrThrow$A( %~target, %識別子, %記述子 ) ◎ Perform ! DefinePropertyOrThrow(target, id, desc).
`属性~取得子を作成する@ ときは、所与の ( `属性$ %属性, [`~ifc$/`~ns$] %target, `~Realm$ %~realm ) に対し,次を走らす: ◎ The attribute getter is created as follows, given an attribute attribute, a namespace or interface target, and a Realm realm:
-
%手続き ~LET 以下を走らす手続き — ただし,手続きの中で`例外が投出された$ときは、その下に与える手続きを走らすとする: ◎ Let steps be the following series of steps: ◎ Try running the following steps:
- %O ~LET `null^jv ◎ Let O be null.
-
~IF[ %target は`~ifc$である ]~AND[ %属性 は`正則~属性$である ]: ◎ If target is an interface, and attribute is a regular attribute:
-
~IF[ `this^jv 値 ~IN { `null^jv, `undefined^jv } ] ⇒ %O ~SET %~realm の`大域~obj$
(この大域~objが %target を実装しない, かつ `LenientThis$x は指定されていない場合、数~段~先で `TypeError^jE が生じることになる。)
◎ If the this value is null or undefined, set O to realm’s global object. (This will subsequently cause a TypeError in a few steps, if the global object does not implement target and [LenientThis] is not specified.) - ~ELSE ⇒ %O ~SET `this^jv 値 ◎ Otherwise, set O to the this value.
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, %属性 の`識別子$, `取得子^C ) ◎ If O is a platform object, then perform a security check, passing O, attribute’s identifier, and "getter".
-
~IF[ %O は %target を実装する`~platform~obj$ではない ]: ◎ If O is not a platform object that implements the interface target, then:
- ~IF[ %属性 `LenientThis$x `拡張属性$が指定されている ] ⇒ ~RET `undefined^jv ◎ If attribute was specified with the [LenientThis] extended attribute, then return undefined.
- ~ELSE ⇒ ~throwTypeError ◎ Otherwise, throw a TypeError.
-
- %R ~LET `属性の下層~値を取得する$( %O, %属性 ) ◎ Let R be the result of getting the underlying value of attribute given O.
- ~RET %R を %属性 に宣言されている型から`~ES値に変換-$した結果 ◎ Return the result of converting R to an ECMAScript value of the type attribute is declared as.
上で`例外が投出された$ときは、その例外 %E に対し: ◎ And then, if an exception E was thrown:
- ~IF[ %属性 の型は`~promise型$である ] ⇒ ~RET ! `Call$A( `Promise_reject$jI, `Promise$jI, « %E » ) ◎ If attribute’s type is a promise type, then return ! Call(%Promise_reject%, %Promise%, «E»).
- ~ELSE ⇒ `~THROW$ %E ◎ Otherwise, end these steps and allow the exception to propagate.
- %name ~LET 次の連結 ⇒# 文字列 `get^l, `0020^U ~SPACE, %属性 の`識別子$ ◎ Let name be the string "get " prepended to attribute’s identifier.
- ! `SetFunctionName$A( %F, %name ) ◎ Perform ! SetFunctionName(F, name).
`属性~設定子を作成する@ ときは、所与の ( `属性$ %属性, `~ifc$ %target, `~Realm$ %~realm ) に対し,次を走らす: ◎ The attribute setter is created as follows, given an attribute attribute, an interface target, and a Realm realm:
- ~IF[ %属性 は`読専$である ]~AND[ %属性 は[ `LenientSetter$x, `PutForwards$x, `Replaceable$x ]いずれの`拡張属性$も伴わない ] ⇒ ~RET `undefined^jv — `属性~設定子$ 関数はない。 ◎ If attribute is read only and does not have a [LenientSetter], [PutForwards] or [Replaceable] extended attribute, return undefined; there is no attribute setter function.
- ~Assert: %属性 の型は`~promise型$でない ◎ Assert: attribute’s type is not a promise type.
-
%手続き ~LET 以下を走らす手続き: ◎ Let steps be the following series of steps:
- ~IF[ 渡された引数の個数 ~EQ 0 ] ⇒ ~throwTypeError ◎ If no arguments were passed, then throw a TypeError.
- %V ~LET 渡された最初の引数の値 ◎ Let V be the value of the first argument passed.
- %識別子 ~LET %属性 の`識別子$ ◎ Let id be attribute’s identifier.
- %O ~LET `null^jv ◎ Let O be null.
-
~IF[ %属性 は`正則~属性$である ]: ◎ If attribute is a regular attribute:
- ~IF[ %O は`~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, %識別子, `設定子^C ) ◎ If O is a platform object, then perform a security check, passing O, id, and "setter".
- %validThis ~LET [ %O は %target を実装する`~platform~obj$であるならば ~T / ~ELSE_ ~F ] ◎ Let validThis be true if O is a platform object that implements the interface target, or false otherwise.
- ~IF[ %validThis ~EQ ~F ]~AND[ %属性 には `LenientThis$x `拡張属性$は指定されていない ] ⇒ ~throwTypeError ◎ If validThis is false and attribute was not specified with the [LenientThis] extended attribute, then throw a TypeError.
-
~IF[ %属性 は `Replaceable$x 拡張属性を伴って宣言されている ]: ◎ If attribute is declared with the [Replaceable] extended attribute, then:
- ? `CreateDataProperty$A( %O, %識別子, %V ) ◎ Perform ? CreateDataProperty(O, id, V).
- ~RET `undefined^jv ◎ Return undefined.
- ~IF[ %validThis ~EQ ~F ] ⇒ ~RET `undefined^jv ◎ If validThis is false, then return undefined.
- ~IF[ %属性 は `LenientSetter$x 拡張属性を伴って宣言されている ] ⇒ ~RET `undefined^jv ◎ If attribute is declared with a [LenientSetter] extended attribute, then return undefined.
-
~IF[ %属性 は `PutForwards$x 拡張属性を伴って宣言されている ]: ◎ If attribute is declared with a [PutForwards] extended attribute, then:
- %Q ~LET ? `Get$A( %O, %識別子 ) ◎ Let Q be ? Get(O, id).
- ~IF[ `Type$A( %Q )~NEQ `Object^jt ] ⇒ ~throwTypeError ◎ If Type(Q) is not Object, then throw a TypeError.
- %forwardId ~LET `PutForwards$x 拡張属性の識別子~引数 ◎ Let forwardId be the identifier argument of the [PutForwards] extended attribute.
- ? `Set$A( %Q, %forwardId, %V, `true^jv ) ◎ Perform ? Set(Q, forwardId, V, true).
- ~RET `undefined^jv ◎ Return undefined.
- %~IDL値 ~LET 未初期化の変数 ◎ Let idlValue be determined as follows:
-
~IF[ %属性 の型 は`列挙$である ]: ◎ attribute’s type is an enumeration
- %S ~LET ? `ToString$A( %V ) ◎ Let S be ? ToString(V).
- ~IF[ %S は `列挙~値$のいずれでもない ] ⇒ ~RET `undefined^jv ◎ If S is not one of the enumeration’s values, then return undefined.
- %~IDL値 ~SET %S に等しい列挙~値 ◎ Otherwise, idlValue is the enumeration value equal to S.
- ~ELSE ⇒ %~IDL値 ~SET %V を%属性 の型の`~IDL値に変換-$した結果 ◎ Otherwise • idlValue is the result of converting V to an IDL value of attribute’s type.
- %~IDL値 を与える下で[ %属性 の記述に挙げられている 設定-時に生じる動作 ]を — %O ~NEQ `null^jv ならば %O 上で — 遂行する ◎ Perform the actions listed in the description of attribute that occur on setting, on O if O is not null.
- ~RET `undefined^jv ◎ Return undefined
- %name ~LET 次の連結 ⇒# 文字列 `set^l, `0020^U ~SPACE, %識別子 ◎ Let name be the string "set " prepended to id.
- ! `SetFunctionLength$A( %F, 1 ) ◎ Perform ! SetFunctionLength(F, 1).
注記: 1 個の~IDL属性に対応する~propは 1 個に限られるが、~accessor~prop[ 取得子/設定子 ]には,[[ その~IDL属性に対応する~prop ]が~accessされた ]~objを指す `this^jv 値が渡されるので、それらの~propは,~instanceに特有の~dataを公開できる。 ◎ Note: Although there is only a single property for an IDL attribute, since accessor property getters and setters are passed a this value for the object on which property corresponding to the IDL attribute is accessed, they are able to expose instance-specific data.
注記: `読専$な`属性$に対応する~propへの代入を試みた結果は、それを行う~scriptが~strict-modeであるかどうかに依存して異なる挙動になる。 ~strict-modeの場合、その種の代入により `TypeError^jE が投出されることになる。 ~strict-modeでない場合、代入の試みは無視されることになる。 ◎ Note: Attempting to assign to a property corresponding to a read only attribute results in different behavior depending on whether the script doing so is in strict mode. When in strict mode, such an assignment will result in a TypeError being thrown. When not in strict mode, the assignment attempt will be ignored.
3.6.8. 演算
[ `~ifc$上に定義され, `公開されて$いる`演算$ ]の各 一意な`識別子$ごとに,対応する~propが存在する。 `静的~演算$は、`~ifc~obj$上に公開される。 `正則~演算$は、`~ifc原型~obj$上に公開される — ただし,[ 演算は`偽装-不能$である / 当の~ifcは `Global$x `拡張属性$を伴って宣言されている ]事例では、~ifcを実装する どの~obj上にも公開される。 ◎ For each unique identifier of an exposed operation defined on the interface, there exist a corresponding property. Static operations are exposed of the interface object. Regular operations are exposed on the interface prototype object, unless the operation is unforgeable or the interface was declared with the [Global] extended attribute, in which case they are exposed on every object that implements the interface.
`正則~演算を定義する@ ときは、所与の ( `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the regular operations of interface or namespace definition on target, given Realm realm, run the following steps:
- %演算たち ~LET [ %定義 を成す`~mb$のうち,`正則~演算$である, かつ `偽装-不能$でないもの ]からなる`~list$ ◎ Let operations be the list of regular operations that are members of definition. ◎ Remove from operations all the operations that are unforgeable.
- `演算を定義する$( %演算たち, %定義, %~target, %~realm ) ◎ Define the operations operations of definition on target given realm.
`静的~演算を定義する@ ときは、所与の ( `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the static operations of interface or namespace definition on target, given Realm realm, run the following steps:
- %演算たち ~LET [ %定義 を成す`~mb$のうち,`静的~演算$であるもの ]からなる`~list$ ◎ Let operations be the list of static operations that are members of definition.
`偽装-不能な正則~演算を定義する@ ときは、所与の ( `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the unforgeable regular operations of interface or namespace definition on target, given Realm realm, run the following steps:
- %演算たち ~LET [ %定義 を成す`~mb$のうち,`正則~演算$である, かつ `偽装-不能$であるもの ]からなる`~list$ ◎ Let operations be the list of unforgeable regular operations that are members of definition.
`演算を定義する@ ときは、所与の ( %演算たち, `~ifc$/`~ns$ %定義, %~target, `~Realm$ %~realm ) に対し,次を走らす: ◎ To define the operations operations of interface or namespace definition on target, given Realm realm, run the following steps:
-
%演算たち を成す ~EACH( `演算$ %演算 ) に対し: ◎ For each operation op of operations:
- ~IF[ %演算 は %~realm 内に`公開されて$いない ] ⇒ ~CONTINUE ◎ If op is not exposed in realm, then continue.
- %~meth ~LET `演算~関数を作成する$( %演算, %定義, %~realm ) ◎ Let method be the result of creating an operation function given op, definition, and realm.
- %M ~LET [ %演算 は`偽装-不能$であるならば `false^jv / ~ELSE_ `true^jv ] ◎ Let modifiable be false if op is unforgeable and true otherwise.
- %記述子 ~LET `MTM-method^desc ◎ Let desc be the PropertyDescriptor{[[Value]]: method, [[Writable]]: modifiable, [[Enumerable]]: true, [[Configurable]]: modifiable}.
- %識別子 ~LET %演算 の`識別子$ ◎ Let id be op’s identifier.
- ! `DefinePropertyOrThrow$A( %~target, %識別子, %記述子 ) ◎ Perform ! DefinePropertyOrThrow(target, id, desc).
`演算~関数を作成する@ ときは、所与の ( `演算$ %演算, `~ns$または`~ifc$ %target, `~Realm$ %~realm ) に対し: ◎ To create an operation function, given an operation op, a namespace or interface target, and a Realm realm:
- %識別子 ~LET %演算 の`識別子$ ◎ Let id be op’s identifier.
-
%手続き ~LET 所与の ( 関数~引数~list %args ) に対し,次を走らす手続き — ただし,手続きの中で`例外が投出された$ときは、その下に与える手続きを走らすとする: ◎ Let steps be the following series of steps, given function argument values args: ◎ Try running the following steps:
- %O ~LET `null^jv ◎ Let O be null.
-
~IF[ %target は`~ifc$である ]~AND[ %演算 は`静的~演算$でない ]: ◎ If target is an interface, and op is not a static operation:
-
~IF[ `this^jv 値 ~IN { `null^jv, `undefined^jv } ] ⇒ %O ~SET %~realm の`大域~obj$
(この大域~objが %target を実装しない場合、数~段~先で `TypeError^jE が生じることになる。)
◎ If the this value is null or undefined, set O to realm’s global object. (This will subsequently cause a TypeError in a few steps, if the global object does not implement target.) - ~ELSE ⇒ %O ~SET `this^jv 値 ◎ Otherwise, set O to the this value.
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, %識別子, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing O, id, and "method".
- ~IF[ %O は ~ifc %target を実装する`~platform~obj$でない ] ⇒ ~throwTypeError ◎ If O is not a platform object that implements the interface target, throw a TypeError.
-
-
%S ~LET %target 上の[ %演算 が[ 正則~演算ならば`正則~演算$ / 静的~演算ならば`静的~演算$ ]]のうち,[ `識別子$ %識別子, 引数個数 %n ]から得られる`有効~多重定義~集合$ ◎ Let S be the effective overload set for regular operations (if op is a regular operation) or for static operations (if op is a static operation) with identifier id on target and with argument count n.
- <%演算, %値~list> ~LET %S と %args を`多重定義~解決~algo$に渡した結果 ◎ Let <operation, values> be the result of passing S and args to the overload resolution algorithm.
- %R ~LET ~NULL ◎ Let R be null.
- ~IF[ %演算 は `Default$x 拡張属性を伴って宣言されている ] ⇒ %R ~SET %値~list を一連の引数~値として, %演算 に`対応する既定の演算$に挙げられている動作を %O 上で遂行した結果 ◎ If operation is declared with a [Default] extended attribute, then: • Set R be the result of performing the actions listed in operation’s corresponding default operation on O, with values as the argument values.
-
~ELSE : ◎ Otherwise:
- %R ~SET ( %演算, %値~list ) を引数に[ 演算の記述に挙げられている手続き ]を — %O ~NEQ `null^jv ならば %O 上で — 遂行した結果 ◎ Set R be the result of performing the actions listed in the description of operation, on O if O is not null, with values as the argument values.
- ~RET %R を[ %演算 の返値に宣言された型 ]の`~ES値に変換-$した結果 ◎ Return the result of converting R to an ECMAScript value of the type op is declared to return.
- ~IF[ %演算 の`返値型$は `~promise型$である ] ⇒ ~RET ! `Call$A( `Promise_reject$jI, `Promise$jI, « %E » ) ◎ If op has a return type that is a promise type, then return ! Call(%Promise_reject%, %Promise%, «E»).
- %S ~LET %target 上の[ %演算 が正則~演算である場合は`正則~演算$ / 静的~演算である場合は`静的~演算$ ]のうち[ `識別子$ %識別子, 引数個数 0 ]から得られる`有効~多重定義~集合$ ◎ Let S be the effective overload set for regular operations (if op is a regular operation) or for static operations (if op is a static operation) with identifier id on target and with argument count 0.
- %長さ ~LET %S 内の各~entryの引数~listの長さのうち,最小 ◎ Let length be the length of the shortest argument list in the entries in S.
3.6.8.1. 既定の演算
`Default$x `拡張属性$を宣言してよい`正則~演算$は、下に定義される `対応する既定の演算@ 持つものに限られる。 【現時点では、~toJSONしかない。】 ◎ Only regular operations which have a corresponding default operation defined below may be declared with a [Default] extended attribute.
3.6.8.1.1. 既定の~toJSON演算
~toJSON演算に`対応する既定の演算$は、`既定の~toJSON演算$で与えられる。 ◎ The corresponding default operation of the toJSON operation is the default toJSON operation.
`既定の~toJSON演算$の`返値型$は、 `object$T で~MUST。 ◎ The return type of the default toJSON operation must be object.
`~ifc$ %I の `既定の~toJSON演算@ を %O 上で呼出すときは、次の手続きを走らす: ◎ To invoke the default toJSON operation of interface I on O, run the the following steps:
- %~map ~LET 新たな`有順序~map$ ◎ Let map be a new ordered map.
- %~stack ~LET `継承~stackを作成する$( %I ) ◎ Let stack be the result of creating an inheritance stack for interface I.
- %O 上の`継承~stackの属性~値を収集する$( %~stack, %~map ) ◎ Invoke collect attribute values of an inheritance stack on O, passing it stack and map as arguments.
- %結果 ~LET ! `ObjectCreate$A( `ObjectPrototype$jI ) ◎ Let result be ! ObjectCreate(%ObjectPrototype%).
-
%~map 内の ~EACH( %key → %value ) に対し: ◎ For each key → value of map,
- %k ~LET %key を`~ES値に変換-$した結果 ◎ Let k be key converted to an ECMAScript value.
- %v ~LET %value を`~ES値に変換-$した結果 ◎ Let v be value converted to an ECMAScript value.
- ! `CreateDataProperty$A( %結果, %k, %v ) ◎ Perform ! CreateDataProperty(result, k, v).
- ~RET %結果 ◎ Return result.
%O 上の `継承~stackの属性~値を収集する@ 抽象~演算は、所与の ( `~stack$ %~stack, `有順序~map$ %~map ) に対し,次を走らす: ◎ To invoke the collect attribute values of an inheritance stack abstract operation on O with stack stack and ordered map map as arguments, run the the following steps:
- %I ~LET %~stack から`~pop$した結果 ◎ Let I be the result of popping from stack.
- %O 上の`属性~値を収集する$( %I, %~map ) ◎ Invoke collect attribute values on O, passing it I and map as arguments.
- ~IF[ %~stack は`空$でない ] ⇒ %O 上の`継承~stackの属性~値を収集する$( %~stack, %~map ) ◎ If stack is not empty, then invoke collect attribute values of an inheritance stack on O, passing it stack and map as arguments.
%O 上の `属性~値を収集する@ 抽象~演算は、所与の ( `~ifc$ %I, `有順序~map$ %~map ) に対し,次を走らす: ◎ To invoke the collect attribute values abstract operation on O with interface I and ordered map map as arguments, run the the following steps:
-
~IF[ %I 上に[ `Default$x `拡張属性$を伴う~toJSON演算 ]は宣言されている ] ⇒ %I を成す`~ifc~mb$のうち,`公開されて$いる, かつ`正則~属性$である ~EACH( %属性 ) に対し: ◎ If a toJSON operation with a [Default] extended attribute is declared on I, then for each exposed regular attribute attr that is an interface member of I, in order:
- %識別子 ~LET %属性 の`識別子$ ◎ Let id be the identifier of attr.
- %値 ~LET `属性の下層~値を取得する$( %O, %属性 ) ◎ Let value be the result of getting the underlying value of attr given O.
- ~IF[ %値 は`~JSON型$である ] ⇒ %~map[ %識別子 ] ~SET %値 ◎ If value is a JSON type, then set map[id] to value.
`継承~stackを作成する@ ときは、所与の ( `~ifc$ %I ) に対し,次を走らす: ◎ To create an inheritance stack for interface I, run the the following steps:
- %~stack ~LET 新たな`~stack$ ◎ Let stack be a new stack.
- %~stack に %I を`~push$する ◎ Push I onto stack.
- %I の`継承d~ifc$である ~EACH( `~ifc$ %J ) に対し,最も末端のものから順に ⇒ %J を %~stack に`~push$する ◎ While I inherits from an interface, • Let I be that interface. • Push I onto stack.
- ~RET %~stack ◎ Return stack.
下に与える`~IDL片$は、`~ifc$ `A^T の`継承d~ifc$, および[ `A^T, または `A^T の`継承d~ifc$ ]に`内包-$されている`~ifc~mixin$たちを成す,いくつかの`~ifc$を定義する — 次の継承~木に示されるような: ◎ The following IDL fragment defines a number of interfaces, which are inherited interfaces of A, and interface mixins, which are included by A or by A’s inherited interfaces, as show in the below inheritance tree.
C* - M4 | B - M3 | M1 - A - M2*
`*^c が付与されている[ `~ifc$/`~ifc~mixin$ ]は、 `Default$x `拡張属性$を伴う~toJSON`演算$を宣言する。 ◎ Interfaces and interface mixins marked with an asterisk ("*") declare a toJSON operation with a [Default] extended attribute.
[Exposed=Window] interface A : B { attribute DOMString a; }; [Exposed=Window] interface B : C { attribute DOMString b; }; [Exposed=Window] interface C { [Default] object toJSON(); attribute DOMString c; }; interface mixin M1 { attribute DOMString m1; }; interface mixin M2 { [Default] object toJSON(); attribute DOMString m2; }; interface mixin M3 { attribute DOMString m3; }; interface mixin M4 { attribute DOMString m4; }; A includes M1; A includes M2; B includes M3; C includes M4;
上に定義した~ifc `A^T を実装している~obj上で `toJSON()^M を~methを~callした場合、次のような~JSON~objを返すことになる: ◎ Calling the toJSON() method of an object implementing interface A defined above would return the following JSON object:
{ "a": "...", "m1": "...", "m2": "...", "c": "...", "m4": "..." }
~ifc `B^T を実装している~objでは、次のような~JSON~objを返すことになる: ◎ An object implementing interface B would return:
{ "c": "...", "m4": "..." }
3.6.8.2. 文字列化子
`~ifc$に`公開されて$いる`文字列化子$ %文字列化子 がある場合、次の特徴を有する~propが存在し~MUST:
- 名前: `toString^l
- 値: 下に与える`組込みの関数~obj$ %F
- 属性 `BTB^desc を持つ。 ここで %B は[ %文字列化子 が~ifc上で`偽装-不能$である場合は `false^jv / ~ELSE_ `true^jv ]とする。
~propの所在は:
- %文字列化子 が~ifc上で`偽装-不能$であるか, または ~ifcが `Global$x 拡張属性を伴って宣言されているならば、~ifcを実装するどの~obj上にも存在する。
- 他の場合、~ifc用の`~ifc原型~obj$上に存在する。
~prop値 %F は、被呼出時には次に従って挙動し~MUST: ◎ which behaves as follows:
- %O ~LET `this^jv 値~上で `ToObject$A を~callした結果 ◎ Let O be the result of calling ToObject on the this value.
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, %文字列化子 の`識別子$, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • the identifier of the stringifier, and • the type "method".
- ~IF[ %O は[ %文字列化子 を宣言する~ifcを実装する~obj ]でない ] ⇒ ~throwTypeError ◎ If O is not an object that implements the interface on which the stringifier was declared, then throw a TypeError.
- %V ~LET 未初期化の変数 ◎ Let V be an uninitialized variable.
-
`stringifier^c が指定されている場所に応じて: ◎ Depending on where stringifier was specified:
- `属性$上 ◎ on an attribute
- %V ~SET %O を~objとして、[[ その属性, あるいは[ その属性がその`取得子を継承-$するように宣言されている場合は,継承-先の属性 ]]の記述に挙げられている,取得-時に生じる手続き ]を遂行した結果 ◎ Set V to the result of performing the actions listed in the description of the attribute that occur when getting (or those listed in the description of the inherited attribute, if this attribute is declared to inherit its getter), with O as the object.
- 識別子を伴う`演算$上 ◎ on an operation with an identifier
- %V ~SET %O を `this^jv 値として, 引数は渡さずに[ その演算の記述に挙げられている手続き ]を遂行した結果 ◎ Set V to the result of performing the actions listed in the description of the operation, using O as the this value and passing no arguments.
- 識別子を伴わない`演算$上 ◎ on an operation with no identifier
- %V ~SET ~ifcの`文字列化の挙動$を遂行した結果 ◎ Set V to the result of performing the stringification behavior of the interface.
- ~RET %V を `String^jt 型の`~ES値に変換-$した結果 ◎ Return the result of converting V to a String value.
この`関数~obj$の `length^jp ~propの値は、 `Number^jt 値 `0^jv とする。 ◎ The value of the function object’s length property is the Number value 0.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `toString^l とする。 ◎ The value of the function object’s name property is the String value "toString".
3.6.9. 反復子に共通する挙動
3.6.9.1. `iterator^jS
所与の`~ifc$が,次のいずれかを持つならば…: ◎ If the interface has any of the following:
- `可反復~宣言$ ◎ an iterable declaration
- `有index~prop取得子$, および[ `整数~型$の, `length^M `属性$ ] ◎ an indexed property getter and an integer-typed length attribute
- `~maplike 宣言$ ◎ a maplike declaration
- `~setlike 宣言$ ◎ a setlike declaration
…ならば、次の特徴を有する~propが存在し~MUST:
- 名前: `iterator^jS ~symbol
- 値: 下に与える`関数~obj$ %F
~propの所在は、次に従って決定される: ◎ The location of the property is determined as follows:
- 当の~ifcは `Global$x `拡張属性$を伴って宣言されているならば、~ifcを実装する単独の~obj上に存在する。 ◎ If the interface was declared with the [Global] extended attribute, then the property exists on the single object that implements the interface.
- 他の場合、もっぱら~ifc用の`~ifc原型~obj$上に存在する。 ◎ Otherwise, the property exists solely on the interface’s interface prototype object.
~prop値 %F は、次で与えられる: ◎ ↓
- ~ifcに `有index~prop取得子$が定義されている場合: ◎ If the interface defines an indexed property getter, then\
- `ArrayProto_values$jI 。 ◎ the function object is %ArrayProto_values%.
- ~ifcは `~pair反復子$を持つ場合: ◎ If the interface has a pair iterator, then\
-
%F は`組込みの関数~obj$であり、被呼出時には次に従って挙動し~MUST: ◎ the function object is a built-in function object that, when invoked, must behave as follows:
- %object ~LET `this^jv 値~上の `ToObject$A を~callした結果 ◎ Let object be the result of calling ToObject on the this value.
- ~IF[ %object は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %object, "`iterator^jS", `~meth^C ) ◎ If object is a platform object, then perform a security check, passing: • the platform object object, • the identifier "@@iterator", and • the type "method".
- %interface ~LET `可反復~宣言$が宣言されている`~ifc$ ◎ Let interface be the interface the iterable declaration is on.
- ~IF[ %object は[ %interface を実装する`~platform~obj$ ]でない ] ⇒ ~throwTypeError ◎ If object is not a platform object that implements interface, then throw a TypeError.
- ~RET [ %interface, ~target %object, 反復子の種類 `key+value^l ]に対し,新たに作成した`既定の反復子~obj$ ◎ Let iterator be a newly created default iterator object for interface with object as its target and iterator kind "key+value". ◎ Return iterator.
- ~ifcは `~maplike 宣言$/`~setlike 宣言$を持つ場合: ◎ If the interface has a maplike declaration or setlike declaration, then\
-
- ~IF[ %object は[ `~maplike 宣言$ / `~setlike 宣言$ を定義する`~ifc$を実装する`~platform~obj$ ]でない ] ⇒ ~throwTypeError ◎ If object is not a platform object that implements the interface on which the maplike declaration or setlike declaration is defined, then throw a TypeError.
-
~IF[ ~ifcは`~maplike 宣言$を持つ ]: ◎ If the interface has a maplike declaration, then:
- %backing ~LET %object の `BackingMap^sl `内部~slot$の値 ◎ Let backing be the value of the [[BackingMap]] internal slot of object.
- ~RET `CreateMapIterator$A( %backing, `key+value^l ) ◎ Return CreateMapIterator(backing, "key+value").
-
~ELSE : ◎ Otherwise:
- %backing ~LET %object の `BackingSet^sl `内部~slot$の値 ◎ Let backing be the value of the [[BackingSet]] internal slot of object.
- ~RET `CreateSetIterator$A( %backing, `value^l ) ◎ Return CreateSetIterator(backing, "value").
%F の `length^jp ~propの値は、 `Number^jt 値 `0^jv とする。 ◎ The value of the @@iterator function object’s length property is the Number value 0.
%F の `name^jp ~propの値は、当の~ifcが[[ `~pair反復子$ / `~maplike 宣言$ ]を持つならば `String^jt 値 `entries^l / `~setlike 宣言$を持つならば `String^jt 値 `values^l ]とする。 ◎ The value of the @@iterator function object’s name property is the String value "entries" if the interface has a pair iterator or a maplike declaration and the String "values" if the interface has a setlike declaration.
3.6.9.2. `forEach^jp
`~ifc$が次のいずれかを持つならば: ◎ If the interface has any of the following:
- `可反復~宣言$ ◎ an iterable declaration
- `~maplike 宣言$ ◎ a maplike declaration
- `~setlike 宣言$ ◎ a setlike declaration
…ならば、次の特徴を有する `forEach^jp ~data-propが存在し~MUST:
- 属性 `TTT^desc を持つ
- ~ifcに `有index~prop取得子$が定義されている場合: ◎ If the interface defines an indexed property getter, then\
- `ArrayProto_forEach$jI ◎ the function object is %ArrayProto_forEach%.
- ~ifcは `~pair反復子$を持つ場合: ◎ If the interface has a pair iterator, then\
-
[[ 当の~ifcが,その`~pair反復子$の代わりに 次に与える[ `演算$, および注釈文による定義 ]を持つ ]と見なしたときに,存在することになるもの ]と同じに挙動する: ◎ the method must have the same behavior, when invoked with argument callback and optional argument thisArg, as one that would exist assuming the interface had this operation instead of the iterable declaration:
[Exposed=Window] interface Iterable { void forEach(Function %callback, optional any %thisArg); };
注釈文による定義は、 ( 引数 %callback, 随意~引数 %thisArg ) で呼出されたとき: ◎ with the following prose definition:
- %O ~LET `this^jv 値 ◎ Let O be the this value.
- %pairs ~LET `反復される値~pair$が成す~list ◎ Let pairs be the list of value pairs to iterate over.
- %i ~LET 0 ◎ Let i be 0.
-
~WHILE[ %i ~LT %pairs の長さ ]: ◎ While i is less than the length of pairs:
- %pair ~LET %pairs 内で~index %i に位置する~entry ◎ Let pair be the entry in pairs at index i.
- %key ~LET %pair の~key ◎ Let key be pair’s key.
- %value ~LET %pair の値 ◎ Let value be pair’s value.
- ~IF[ %thisArg は給されていない ] ⇒ %thisArg ~SET `undefined^jv ◎ ↓
- `呼戻~関数を呼出す$( %callback, « %value, %key, %O », %thisArg ) ◎ Invoke callback with thisArg (or undefined, if the argument was not supplied) as the callback this value and value, key and O as its arguments.
- %pairs を[ 現在の`反復される値~pair$の~list ]に更新する ◎ Update pairs to the current list of value pairs to iterate over.
- %i ~INCBY 1 ◎ Set i to i + 1.
- ~ifcは `~maplike 宣言$/`~setlike 宣言$を持つ場合: ◎ If the interface has a maplike declaration or setlike declaration then\
-
~methの被呼出時には、次に従って挙動し~MUST: ◎ the method, when invoked, must behave as follows:
- ~IF[ %object は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %object, `forEach^l, `~meth^C ) ◎ If object is a platform object, then perform a security check, passing: • the platform object object, • the identifier "forEach", and • the type "method".
- %interface ~LET `~maplike 宣言$/`~setlike 宣言$が宣言されている`~ifc$ ◎ Let interface be the interface on which the maplike declaration or setlike declaration is declared.
- %callbackFn ~LET [ この関数に引数が給されているならば その 1 個目の引数の値 / ~ELSE_ `undefined^jv ] ◎ Let callbackFn be the value of the first argument passed to the function, or undefined if the argument was not supplied.
- ~IF[ `IsCallable$A( %callbackFn ) ~EQ ~F ] ⇒ ~throwTypeError ◎ If IsCallable(callbackFn) is false, throw a TypeError.
- %thisArg ~LET [ 関数に 2 個目の引数が給されているならば その引数の値 / ~ELSE_ `undefined^jv ] ◎ Let thisArg be the value of the second argument passed to the function, or undefined if the argument was not supplied.
- %backing ~LET %interface が[ `~maplike 宣言$ / `~setlike 宣言$ ]のいずれを持つかに応じて, %object の[ `BackingMap^sl / `BackingSet^sl ]`内部~slot$の値 ◎ Let backing be the value of the [[BackingMap]] internal slot of object, if the interface has a maplike declaration, or the [[BackingSet]] internal slot of object otherwise.
-
%callbackWrapper ~LET 被呼出時には次に従って挙動する`組込みの関数~obj$: ◎ Let callbackWrapper be a built-in function object that, when invoked, behaves as follows:
- ( %v, %k ) ~LET 関数に渡された ( 1 個目の引数, 2 個目の引数 ) ◎ Let v and k be the first two arguments passed to the function.
- %thisArg ~LET `this^jv 値 ◎ Let thisArg be the this value.
- `Call$A( %callbackFn, %thisArg, « %v, %k, %object » ) ◎ Call(callbackFn, thisArg, «v, k, object»).
注記: %callbackWrapper 関数は、単純に, 3 個目の引数に %object を渡して ~~入力の %callbackFn を~callする — その内部[ `BackingMap^sl / `BackingSet^sl ]~objではなく。 ◎ Note: The callbackWrapper function simply calls the incoming callbackFn with object as the third argument rather than its internal [[BackingMap]] or [[BackingSet]] object.
~script作者は、[ forEach が~callされる度に, %callbackWrapper が新たな関数になる ]かどうか,観測し得るだろうか? [ 環境を capture した唯一の関数が在ること ]を指定する仕方として,何が最良になるだろうか? ◎ Can the script author observe that callbackWrapper might be a new function every time forEach is called? What’s the best way of specifying that there’s only one function that has captured an environment?
- %forEach ~LET `GetMethod$A( %backing, `forEach^l ) ◎ Let forEach be ? GetMethod(backing, "forEach").
- ~IF[ %forEach ~EQ `undefined^jv ] ⇒ ~throwTypeError ◎ If forEach is undefined, then throw a TypeError.
- `Call$A( %forEach, %backing, « %callbackWrapper, %thisArg » ) ◎ Call(forEach, backing, «callbackWrapper, thisArg»).
- ~RET `undefined^jv ◎ Return undefined.
この`関数~obj$の `length^jp ~propの値は、 `Number^jt 値 `1^jv とする。 ◎ The value of the function object’s length property is the Number value 1.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `forEach^l とする。 ◎ The value of the function object’s name property is the String value "forEach".
3.6.10. 可反復~宣言
3.6.10.1. `entries^jp
`可反復~宣言$を持つ`~ifc$には、次の特徴を有する `entries^jp ~data-propが存在し~MUST:
- ~ifcは`値~反復子$を持つ場合: ◎ If the interface has a value iterator, then\
- `ArrayProto_entries$jI 。 ◎ the function object is %ArrayProto_entries%.
- ~ifcは `~pair反復子$を持つ場合: ◎ If the interface has a pair iterator, then\
- `iterator$jS ~propの値で与えられる`関数~obj$。 ◎ the function object is the value of the @@iterator property.
3.6.10.2. `keys^jp
`可反復~宣言$を持つ`~ifc$には、次の特徴を有する `keys^jp ~data-propが存在し~MUST:
- ~ifcは`値~反復子$を持つ場合: ◎ If the interface has a value iterator,\
- `ArrayProto_keys$jI 。 ◎ then the function object is %ArrayProto_keys%.
- ~ifcは `~pair反復子$を持つ場合: ◎ If the interface has a pair iterator, then\
-
- ~IF[ %object は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %object, `keys^l, `~meth^C ) ◎ If object is a platform object, then perform a security check, passing: • the platform object object, • the identifier "keys", and • the type "method".
- %interface ~LET `可反復~宣言$が宣言されている`~ifc$ ◎ Let interface be the interface on which the iterable declaration is declared on.
- ~RET [ %interface, ~target %object, 反復子の種類 `key^l ]に対し,新たに作成した`既定の反復子~obj$ ◎ Let iterator be a newly created default iterator object for interface with object as its target and iterator kind "key". ◎ Return iterator.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `keys^l とする。 ◎ The value of the function object’s name property is the String value "keys".
3.6.10.3. `values^jp
`可反復~宣言$を持つ`~ifc$には、次の特徴を有する `values^jp ~data-propが存在し~MUST:
- ~ifcは`値~反復子$を持つ場合: ◎ If the interface has a value iterator,\
- `iterator$jS ~propの値で与えられる`関数~obj$。 ◎ then the function object is the value of the @@iterator property.
- ~ifcは `~pair反復子$を持つ場合: ◎ If the interface has a pair iterator, then\
-
- ~IF[ %object は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %object, `entries^l, `~meth^C ) ◎ If object is a platform object, then perform a security check, passing: • the platform object object, • the identifier "entries", and • the type "method".
- ~RET [ %interface, ~target %object, 反復子の種類 `value^l ]に対し,新たに作成した`既定の反復子~obj$ ◎ Let iterator be a newly created default iterator object for interface with object as its target and iterator kind "value". ◎ Return iterator.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `values^l とする。 ◎ The value of the function object’s name property is the String value "values".
3.6.10.4. 既定の反復子~obj
所与の[ `~ifc$, ~target, 反復の種類 ]用の `既定の反復子~obj@ とは、~objであって,その `Prototype^sl `内部~slot$が,その~ifcの`反復子~原型~obj$であるものである。 ◎ A default iterator object for a given interface, target and iteration kind is an object whose [[Prototype]] internal slot is the iterator prototype object for the interface.
`既定の反復子~obj$は、次の 3 つの値を内部に持つ: ◎ A default iterator object has three internal values:
- ~target
- 反復される値を~~給する~obj ◎ its target, which is an object whose values are to be iterated,
- 種類
- 反復の種類 【 ~IN { `key^l, `value^l, `key+value^l } 】 ◎ its kind, which is the iteration kind,
- ~index
- 一連の値のうち,反復されることになる値を指す、現在の~index。 ◎ its index, which is the current index into the values value to be iterated.
注記: 既定の反復子~objは、`~pair反復子$のみに利用される — `値~反復子$は、現在は,~objが`~supportする~prop~index$上を反復するように制約されており、標準の~ES `Array^jt 反復子~objを利用する。 ◎ Note: Default iterator objects are only used for pair iterators; value iterators, as they are currently restricted to iterating over an object’s supported indexed properties, use standard ECMAScript Array iterator objects.
`既定の反復子~obj$が最初に作成されたときの~indexは、 0 とする。 ◎ When a default iterator object is first created, its index is set to 0.
`既定の反復子~obj$には `~class文字列$は無い。 所与の`~ifc$の`既定の反復子~obj$上で `Object.prototype.toString()^c が~callされたときは、その~ifcの`~class文字列$が利用されるとする。 ◎ Default iterator objects do not have class strings; when Object.prototype.toString() is called on a default iterator object of a given interface, the class string of the iterator prototype object of that interface is used.
3.6.10.5. 反復子~原型~obj
`~pair反復子$を持つどの`~ifc$に対しても、 `反復子~原型~obj@ と呼ばれる~objが存在する。 それは、その~ifc用の`既定の反復子~obj$の原型として~~働く。 ◎ The iterator prototype object for a given interface is an object that exists for every interface that has a pair iterator. It serves as the prototype for default iterator objects for the interface.
`反復子~原型~obj$の `Prototype^sl `内部~slot$は、 `IteratorPrototype$jI で~MUST。 ◎ The [[Prototype]] internal slot of an iterator prototype object must be %IteratorPrototype%.
`反復子~原型~obj$は、次の特徴を有する `next^jp ~data-propを持た~MUST:
- 値は 下に与えるように挙動する`組込みの関数~obj$
- %interface ~LET その`反復子~原型~obj$が存在する`~ifc$ ◎ Let interface be the interface for which the iterator prototype object exists.
- ~IF[ %object は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %object, `next^l, `~meth^C ) ◎ If object is a platform object, then perform a security check, passing: • the platform object object, • the identifier "next", and • the type "method".
- ~IF[ %object は %interface 用の`既定の反復子~obj$でない ] ⇒ ~throwTypeError ◎ If object is not a default iterator object for interface, then throw a TypeError.
- %index ~LET %object の~index ◎ Let index be object’s index.
- %kind ~LET %object の種類 ◎ Let kind be object’s kind.
- %値~list ~LET `反復される値~pair$の~list ◎ Let values be the list of value pairs to iterate over.
- %len ~LET %値~list の長さ ◎ Let len be the length of values.
- ~IF[ %index ~GTE %len ] ⇒ ~RET `CreateIterResultObject$A(`undefined^jv, `true^jv) ◎ If index is greater than or equal to len, then return CreateIterResultObject(undefined, true).
- %pair ~LET %値~list 内の %index に位置する~entry ◎ Let pair be the entry in values at index index.
- %object の~index ~SET %index ~PLUS 1 ◎ Set object’s index to index + 1.
-
%result ~LET %kind の値に応じて,次で決定される値: ◎ Let result be a value determined by the value of kind:
- `key^l
-
- %~IDL~key ~LET %pair の~key ◎ Let idlKey be pair’s key.
- %key ~LET %~IDL~key を`~ES値に変換-$した結果 ◎ Let key be the result of converting idlKey to an ECMAScript value.
- %result ~SET %key ◎ result is key.
- `value^l
-
- %~IDL値 ~LET %pair の~key ◎ Let idlValue be pair’s value.
- %value ~LET %~IDL値 を`~ES値に変換-$した結果 ◎ Let value be the result of converting idlValue to an ECMAScript value.
- %result ~SET %value ◎ result is value.
- `key+value^l
-
- %array ~LET `ArrayCreate$A( 2 ) を遂行した結果 ◎ Let array be the result of performing ArrayCreate(2).
- `CreateDataProperty$A( %array, `0^l, %key ) を~callする ◎ Call CreateDataProperty(array, "0", key).
- `CreateDataProperty$A( %array, `1^l, %value ) を~callする ◎ Call CreateDataProperty(array, "1", value).
- %result ~SET %array ◎ result is array.
- ~RET `CreateIterResultObject$A( %result, `false^jv ) ◎ Return CreateIterResultObject(result, false).
所与の`~ifc$用の`反復子~原型~obj$の `~class文字列$は、次の連結とする ⇒# その~ifcの`識別子$, `0020^U ~SPACE, 文字列 `Iterator^l ◎ The class string of an iterator prototype object for a given interface is the result of concatenating the identifier of the interface and the string " Iterator".
3.6.11. ~maplike 宣言
`~maplike 宣言$を持つ`~ifc$ — この節を通して, %A と記される — を実装する どの~objも, `BackingMap^sl `内部~slot$を持た~MUST。 — それは、初期~時には,新たに作成された `Map$jt ~objに設定される。 この `Map$jt ~objの `MapData^sl 内部~slotが,~objの一連の`~map~entry$になる。 ◎ Any object that implements an interface that has a maplike declaration must have a [[BackingMap]] internal slot, which is initially set to a newly created Map object. This Map object’s [[MapData]] internal slot is the object’s map entries.
%A 用の`~ifc原型~obj$上には、いくつかの追加の~propが存在する。 これらの追加の~propは、以下の各 下位~節にて述べられる。 ◎ If an interface A is declared with a maplike declaration, then there exists a number of additional properties on A’s interface prototype object. These additional properties are described in the sub-sections below.
それらの~propのうち一部のものは、以下において[ 所与の関数~名に対し, `内部~map~objへ回送する@ ような`組込みの関数~obj$ 値を持つ ]ように定義される。 その種の関数は、被呼出時には次に従って挙動する: ◎ Some of the properties below are defined to have a function object value that forwards to the internal map object for a given function name. Such functions behave as follows when invoked:
- %O ~LET `this^jv 値 ◎ Let O be the this value.
- %arguments ~LET 関数に渡された引数の~list ◎ Let arguments be the list of arguments passed to this function.
- %name ~LET 関数~名 ◎ Let name be the function name.
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, %name, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • an identifier equal to name, and • the type "method".
- ~IF[ %O は %A を実装する~objでない ] ⇒ ~throwTypeError ◎ If O is not an object that implements A, then throw a TypeError.
- %map ~LET %O の `BackingMap^sl `内部~slot$の値である `Map$jt ~obj ◎ Let map be the Map object that is the value of O’s [[BackingMap]] internal slot.
- %function ~LET ? `GetMethod$A( %map, %name ) ◎ Let function be ? GetMethod(map, name).
- ~IF[ %function ~EQ `undefined^jv ] ⇒ ~throwTypeError ◎ If function is undefined, then throw a TypeError.
- ~RET `Call$A( %function, %map, %arguments ) ◎ Return Call(function, map, arguments).
3.6.11.1. `size^jp
%A 用の`~ifc原型~obj$上には,次の特徴を有する `size^jp ~propが存在し~MUST: ◎ There must exist a size property on A’s interface prototype object with the following characteristics:
- 属性 { [[Get]]: %G, [[Enumerable]]: `false^jv, [[Configurable]]: `true^jv } を持つ — ここで %G は、下に定義する`~map~size取得子$である。 ◎ The property has attributes { [[Get]]: G, [[Enumerable]]: false, [[Configurable]]: true }, where G is the interface’s map size getter, defined below.
`~map~size取得子@ は、被呼出時の挙動が次で与えられる,`組込みの関数~obj$である: ◎ The map size getter is a built-in function object whose behavior when invoked is as follows:
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, `size^l, `取得子^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • the identifier "size", and • the type "getter".
- ~RET `Get$A( %map, `size^l ) ◎ Return Get(map, "size").
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `size^l とする。 ◎ The value of the function object’s name property is the String value "size".
3.6.11.2. `entries^jp
%A 用の`~ifc原型~obj$上には、次の特徴を有する `entries^jp ~data-propが存在し~MUST:
- 値は `iterator$jS ~propの値で与えられる`関数~obj$
3.6.11.3. `keys^jp, `values^jp
%A 用の`~ifc原型~obj$上には,次の特徴を有する[ `keys^jp, `values^jp ]~data-propが存在し~MUST。 ◎ For both of keys and values, there must exist a data property with that name on A’s interface prototype object with the following characteristics:
- 属性 `TFT^desc を持つ。 ◎ The property has attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
- 値は `内部~map~objへ回送する$`組込みの関数~obj$。 ◎ The value of the property is a built-in function object that forwards that name to the internal map object.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値による~propの名前( `keys^l / `values^l )とする。 ◎ The value of the function object’s name property is the String value "keys" or "values", correspondingly.
3.6.11.4. `get^jp, `has^jp
%A 用の`~ifc原型~obj$上には,次の特徴を有する[ `get^jp, `has^jp ]~data-propが存在し~MUST。 ◎ For both of get and has, there must exist a data property with that name on A’s interface prototype object with the following characteristics:
-
値は`組込みの関数~obj$であり、被呼出時には次に従って挙動する: ◎ The value of the property is a built-in function object that behaves as follows when invoked:
- %name ~LET ~propの名前( `get^l / `has^l ) ◎ Let name be the name of the property – "get" or "has".
- %keyType ~LET `~maplike 宣言$にて指定された~key型 ◎ Let keyType be the key type specified in the maplike declaration.
- %function ~LET ! `Get$A( %map, %name ) ◎ Let function be ! Get(map, name).
- %keyArg ~LET [ この関数に引数が給されているならば その 1 個目の引数の値 / ~ELSE_ `undefined^jv ] ◎ Let keyArg be the first argument passed to this function, or undefined if not supplied.
- %keyIDL ~LET %keyArg を型 %keyType の`~IDL値に変換-$した結果 ◎ Let keyIDL be the result of converting keyArg to an IDL value of type keyType.
- %key ~LET %keyIDL を`~ES値に変換-$した結果 ◎ Let key be the result of converting keyIDL to an ECMAScript value.
- ~RET `Call$A( %function, %map, « %key » ) ◎ Return Call(function, map, «key»).
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値による~propの名前( `get^l / `has^l )とする。 ◎ The value of the function object’s name property is the String value "get" or "has", correspondingly.
3.6.11.5. `clear^jp
[ %A には 識別子 `clear^l の`~mb$は宣言されていない ]~AND[ %A は 可書~maplike 宣言を伴って宣言されている ]場合、 %A 用の`~ifc原型~obj$上には,次の特徴を有する `clear^jp ~data-propが存在し~MUST: ◎ If A does not declare a member with identifier "clear", and A was declared with a read–write maplike declaration, then a clear data property with the following characteristics must exist on A’s interface prototype object:
- 値は `内部~map~objへ回送する$`組込みの関数~obj$。 ◎ The value of the property is a built-in function object that forwards clear to the internal map object.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `clear^l とする。 ◎ The value of the function object’s name property is the String value "clear".
3.6.11.6. `delete^jp
[ %A には 識別子 `delete^l の`~mb$は宣言されていない ]~AND[ %A は 可書~maplike 宣言を伴って宣言されている ]場合、 %A 用の`~ifc原型~obj$上には,次の特徴を有する `delete^jp ~data-propが存在し~MUST: ◎ If A does not declare a member with identifier "delete", and A was declared with a read–write maplike declaration, then a delete data property with the following characteristics must exist on A’s interface prototype object:
-
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, `delete^l, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • the identifier "delete", and • the type "method".
- %function ~LET `Get$A( %map, `delete^l ) ◎ Let function be ! Get(map, "delete").
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `delete^l とする。 ◎ The value of the function object’s name property is the String value "delete".
3.6.11.7. `set^jp
[ %A には 識別子 `set^l を伴う`~ifc~mb$は宣言されていない ]~AND[ %A は 可書~maplike 宣言を伴って宣言されている ]場合、 %A 用の`~ifc原型~obj$上には,次の特徴を有する `set^jp ~data-propが存在し~MUST: ◎ If A does not declare a member with identifier "set", and A was declared with a read–write maplike declaration, then a set data property with the following characteristics must exist on A’s interface prototype object:
-
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, `set^l, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • the identifier "set", and • the type "method".
- %keyType, %valueType ~LET 順に,`~maplike 宣言$にて指定された~key型, ~value型 ◎ Let keyType and valueType be the key and value types specified in the maplike declaration.
- %function ~LET `Get$A( %map, `set^l ) ◎ Let function be ! Get(map, "set").
- %valueArg ~LET[ この関数に 2 個目の引数が給されているならば その値 / ~ELSE_ `undefined^jv ] ◎ Let valueArg be the second argument passed to this function, or undefined if not supplied.
- %valueIDL ~LET %valueArg を型 %valueType の`~IDL値に変換-$した結果 ◎ Let valueIDL be the result of converting valueArg to an IDL value of type valueType.
- %value ~LET %valueIDL を`~ES値に変換-$した結果 ◎ Let value be the result of converting valueIDL to an ECMAScript value.
- %result ~LET ! `Call$A( %function, %map, « %key, value » ) ◎ ! Call(function, map, «key, value»).
- ~RET %O ◎ Return O.
この`関数~obj$の `length^jp ~propの値は、 `Number^jt 値 `2^jv とする。 ◎ The value of the function object’s length property is the Number value 2.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `set^l とする。 ◎ The value of the function object’s name property is the String value "set".
3.6.12. ~setlike 宣言
`~setlike 宣言$を持つ`~ifc$ — この節を通して, %A と記される — を実装するどの~objも, `BackingSet^sl `内部~slot$を持た~MUST — それは、初期~時には,新たに作成された `Set$jt ~objに設定される。 この `Map$jt ~objの `SetData^sl 内部~slotが,~objの一連の`~set~entry$になる。 ◎ Any object that implements an interface that has a setlike declaration must have a [[BackingSet]] internal slot, which is initially set to a newly created Set object. This Set object’s [[SetData]] internal slot is the object’s set entries.
%A 用の`~ifc原型~obj$上には、いくつかの追加の~propが存在する。 これらの追加の~propは、以下の各 下位~節にて述べられる。 ◎ If an interface A is declared with a setlike declaration, then there exists a number of additional properties on A’s interface prototype object. These additional properties are described in the sub-sections below.
それらの~propのうち一部のものは、以下にて 所与の関数~名に対し, `内部~set~objへ回送する@ ような`組込みの関数~obj$ 値を持つように定義される。 その種の関数は、被呼出時には次に従って挙動する: ◎ Some of the properties below are defined to have a built-in function object value that forwards to the internal set object for a given function name. Such functions behave as follows when invoked:
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, %name, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • an identifier equal to name, and • the type "method".
- %set ~LET %O の `BackingSet^sl `内部~slot$の値である `Set$jt ~obj ◎ Let set be the Set object that is the value of O’s [[BackingSet]] internal slot.
- %function ~LET ? `GetMethod$A( %set, %name ) ◎ Let function be ? GetMethod(set, name).
- ~RET `Call$A( %function, %set, %arguments ) ◎ Return Call(function, set, arguments).
3.6.12.1. `size^jp
%A 用の`~ifc原型~obj$上には,次の特徴を有する `size^jp ~propが存在し~MUST: ◎ A size property must exist on A’s interface prototype object with the following characteristics:
- 属性 { [[Get]]: %G, [[Enumerable]]: `false^jv, [[Configurable]]: `true^jv } を持つ — ここで %G は、下に定義する`~set~size取得子$とする。 ◎ The property has attributes { [[Get]]: G, [[Enumerable]]: false, [[Configurable]]: true }, where G is the interface’s set size getter, defined below.
`~set~size取得子@ は、被呼出時の挙動が次で与えられる,`組込みの関数~obj$である: ◎ The set size getter is a built-in function object whose behavior when invoked is as follows:
- ~RET `Get$A( %set, `size^l ) ◎ Return the result of calling the [[Get]] internal method of set passing "size" and set as arguments.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `size^l とする。 ◎ The value of the function object’s name property is the String value "size".
3.6.12.2. `values^jp
%A 用の`~ifc原型~obj$上には、次の特徴を有する `values^jp ~data-propが存在し~MUST:
- 値は `iterator$jS ~propの値で与えられる`関数~obj$
3.6.12.3. `entries^jp, `keys^jp
%A 用の`~ifc原型~obj$上には,次の特徴を有する[ `entries^jp, `keys^jp ]~data-propが存在し~MUST。 ◎ For both of entries and keys, there must exist a data property with that name on A’s interface prototype object with the following characteristics:
- 値は `内部~set~objへ回送する$`組込みの関数~obj$。 ◎ The value of the property is a built-in function object that forwards that name to the internal set object.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値による~propの名前( `entries^l / `keys^l )とする。 ◎ The value of the function object’s name property is the String value "entries" or "keys", correspondingly.
3.6.12.4. `has^jp
%A 用の`~ifc原型~obj$上には,次の特徴を有する `has^jp ~data-propが存在し~MUST。 ◎ There must exist a has data property on A’s interface prototype object with the following characteristics:
-
- ~IF[ %O は `~platform~obj$である ] ⇒ `保安~検査を遂行する$( %O, `has^l, `~meth^C ) ◎ If O is a platform object, then perform a security check, passing: • the platform object O, • the identifier "has", and • the type "method".
- %type ~LET `~setlike 宣言$にて指定された~value型 ◎ Let type be the value type specified in the setlike declaration.
- %function ~LET ! `Get$A( %set, `has^l ) ◎ Let function be ! Get(set, "has").
- %arg ~LET [ この関数に引数が給されているならば その 1 個目の引数の値 / ~ELSE_ `undefined^jv ] ◎ Let arg be the first argument passed to this function, or undefined if not supplied.
- %~IDL値 ~LET %arg を型 %type の`~IDL値に変換-$した結果 ◎ Let idlValue be the result of converting arg to an IDL value of type type.
- ~RET `Call$A( %function, %set, « %value » ) ◎ Call(function, set, «value»).
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `has^l とする。 ◎ The value of the function object’s name property is the String value "has".
3.6.12.5. `add^jp, `delete^jp
[ %A には 識別子[ `add^l / `delete^l ]を伴う`~mb$は宣言されていない ]~AND[ %A は 可書`~maplike 宣言$を伴って宣言されている ]ならば、 %A 用の`~ifc原型~obj$上には,次の特徴を有する[ `add^jp / `delete^jp ]~data-propが存在し~MUST: ◎ For both of add and delete, if: • A does not declare an member with a matching identifier, and • A was declared with a read–write setlike declaration, ◎ then a data property with that name and the following characteristics must exist on A’s interface prototype object:
-
- %name ~LET ~propの名前( `add^l / `delete^l ) ◎ Let name be the name of the property – "add" or "delete".
- %function ~LET ! `Get$A( %set, %name ) ◎ Let function be ! Get(set, name).
- %result ~LET ! `Call$A( %function, %set, « %value » ) ◎ Let result be ! Call(function, set, «value»).
- ~RET [ %name ~EQ `delete^l ならば %result / ~ELSE_ %O ] ◎ If name is "delete", then return result. ◎ Otherwise, return O.
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値による~propの名前( `add^l / `delete^l )とする。 ◎ The value of the function object’s name property is the String value "add" or "delete", correspondingly.
3.6.12.6. `clear^jp
[ %A には 識別子 `clear^l を伴う`~ifc~mb$は宣言されていない ]~AND[ %A は 可書~setlike 宣言を伴って宣言されている ]場合、 %A 用の`~ifc原型~obj$上には,次の特徴を有する `clear^jp ~data-propが存在し~MUST: ◎ If A does not declare a member with a matching identifier, and A was declared with a read–write setlike declaration, then a clear data property with the following characteristics must exist on A’s interface prototype object:
この`関数~obj$の `name^jp ~propの値は、 `String^jt 値 `clear^l とする。 ◎ The value of the function object’s name property is the String value "clear".
3.7. ~ifcを実装している~platform~obj
どの`~platform~obj$も、`初期~obj$とちょうど同じ様に,大域~環境に属する。 各~platform~objがどの大域~環境に(または、代理を通して,どの大域~objに)属するか,についての言明-は~Web~IDLを利用する仕様が責を負う。 ◎ Every platform object is associated with a global environment, just as the initial objects are. It is the responsibility of specifications using Web IDL to state which global environment (or, by proxy, which global object) each platform object is associated with.
1 個~以上の~ifcを実装する~platform~objの `首~ifc@ とは、それが実装する`~ifc$のうち,継承~階層において最も末端の~ifcである。 ~platform~objの `Prototype^sl `内部~slot$の値は、`~platform~obj$が属する大域~環境に属する,`首~ifc$用の`~ifc原型~obj$である。 ◎ The primary interface of a platform object that implements one or more interfaces is the most-derived interface that it implements. The value of the [[Prototype]] internal slot of the platform object is the interface prototype object of the primary interface from the platform object’s associated global environment.
所与の`~platform~obj$が属する大域~環境は、その作成-後に `変化-@ し得る。 ~platform~objが属する大域~環境が変化した場合、その `Prototype^sl `内部~slot$は,その新たな大域~環境に属する `首~ifc$用の`~ifc原型~obj$に,即時に更新され~MUST。 ◎ The global environment that a given platform object is associated with can change after it has been created. When the global environment associated with a platform object is changed, its [[Prototype]] internal slot must be immediately updated to be the interface prototype object of the primary interface from the platform object’s newly associated global environment.
1 個~以上の~ifcを実装する~platform~objの `~class文字列$は、~platform~objの`首~ifc$の`識別子$で~MUST。 ◎ The class string of a platform object that implements one or more interfaces must be the identifier of the primary interface of the platform object.
`LegacyNamespace$x 拡張属性を伴う~ifcの`~class文字列$は、次の連結で与えられる:
- 拡張属性に指定された~nsの,~class文字列
- `.^l
- この~ifcがこの拡張属性を伴っていなかった場合に有することになる~class文字列
`~platform~obj$は、`platform-object-setprototypeof$secにて定義される `SetPrototypeOf^sl 内部~methを持つ。 ◎ Platform objects have an internal [[SetPrototypeOf]] method as defined in §3.7.1 [[SetPrototypeOf]].
`~Realm$ %~realm の中では、`~platform~obj$ %~obj により実装される ~EACH( `~ifc$ %~ifc ) に対し, %~obj の作成の一環として次の手続きを走らせ~MUST: ◎ Within a Realm realm, for each interface interface implemented by a platform object obj, the following steps must be run as part of obj’s creation:
- `偽装-不能な正則~演算を定義する$( %~ifc, %~obj, %~realm ) ◎ Define the unforgeable regular operations of interface on obj, given realm.
- `偽装-不能な正則~属性を定義する$( %~ifc, %~obj, %~realm ) ◎ Define the unforgeable regular attributes of interface on obj, given realm.
`~Realm$ %~realm の中では、 `~platform~obj$ %~obj は[ `Global$x `拡張属性$を伴って宣言されている~ifc ]を実装するならば、 %~obj が実装する ~EACH( `~ifc$ %~ifc ) に対し, %~obj の作成の一環として次の手続きを走らせ~MUST: ◎ If within a Realm realm a platform object obj implements an interface which is declared with the [Global] extended attribute, then for each interface interface implemented by obj, the following steps must be run as part of obj’s creation:
- `正則~演算を定義する$( %~ifc, %~obj, %~realm ) ◎ Define the regular operations of interface on obj, given realm.
- `正則~属性を定義する$( %~ifc, %~obj, %~realm ) ◎ Define the regular attributes of interface on obj, given realm.
加えて,`~platform~obj$は[ `Global$x `拡張属性$を伴って宣言されている~ifc ]を実装するならば、次に挙げるものから宣言的に~propを取得する ⇒# `es-stringifier$sec, `es-iterators$sec, `es-iterable$sec, `es-maplike$sec, `es-setlike$sec ◎ Additionaly, platform objects which implement an interface which has a [Global] extended attribute get properties declaratively from: • §3.6.8.2 Stringifiers, • §3.6.9 Common iterator behavior, • §3.6.10 Iterable declarations, • §3.6.11 Maplike declarations, and • §3.6.12 Setlike declarations.
3.7.1. `SetPrototypeOf^sl
`Global$x `拡張属性$を伴う`~ifc$を実装する`~platform~obj$ %O の `SetPrototypeOf^sl 内部~methが,~ES言語~値 %V で~callされたときは、次を走らす: ◎ When the internal [[SetPrototypeOf]] method of a platform object O that implements an interface with the [Global] extended attribute is called with ECMAScript language value V, the following step is taken:
注記: `Window$T ~objに対しては、これが実装されているかどうかは観測し得ない — `WindowProxy$T ~objの存在pにより、 `Window^T ~obj上では, `SetPrototypeOf^sl が直に~callされることは決してないことが確保されるので。 しかしながら,他の~大域~objに対しては、このことは必要とされない。 ◎ Note: For Window objects, it is unobservable whether this is implemented, since the presence of the WindowProxy object ensures that [[SetPrototypeOf]] is never called on a Window object directly. For other global objects, however, this is necessary.
3.8. 旧来の~platform~obj
`旧来の~platform~obj$は、[ 自身の[ `有index~prop$, `有名~prop$ ]に対応するような 追加の~prop ]を持つように現れることになる。 これらの~propは,~obj上の “真の” 自前の~propではないが、 `GetOwnProperty^sl 内部~methにより公開されて見えるようにされる。 ◎ Legacy platform objects will appear to have additional properties that correspond to their indexed and named properties. These properties are not “real” own properties on the object, but are made to look like they are by being exposed by the [[GetOwnProperty]] internal method .
~objが`有index~propを~support$するような複数の~ifcを実装することは許可され得る。 しかしながら,そうであって各~ifcによる[ ~objが`~supportする~prop~index$の定義 ]が競合している場合に、[ ~objが持つように現れることになる追加の~prop ]がどれになるか, あるいは[ その有index~propに関する正確な挙動 ]がどうなるか,については、未定義である。 同じことは、有名~propについても該当する。 ◎ It is permissible for an object to implement multiple interfaces that support indexed properties. However, if so, and there are conflicting definitions as to the object’s supported property indices, then it is undefined what additional properties the object will appear to have, or what its exact behavior will be with regard to its indexed properties. The same applies for named properties.
[ 旧来の~platform~objが実装する,継承~階層において最も末端の~ifc ]上で定義される`有index~prop取得子$が、[ ~objに対し,`配列~index$で~index-したときの挙動 ]を定義する。 `有index~prop設定子$に対しても同様になる。 先祖の~ifcによる,これらの特殊~演算の定義は、この仕方で上書きできる。 ◎ The indexed property getter that is defined on the derived-most interface that the legacy platform object implements is the one that defines the behavior when indexing the object with an array index. Similarly for indexed property setters. This way, the definitions of these special operations from ancestor interfaces can be overridden.
所与の~platform~obj %O 上の~prop名は、 %O が次を満たす`~ifc$ %I を実装するならば, `偽装-不能な~prop名@ とされる:
- %I はその~prop名を識別子とする`~ifc~mb$を持つ, かつ
- その~mbは[ %O が実装するいずれかの~ifc ]上で`偽装-不能$である。
`取得子$の~supportは `legacy-platform-object-getownproperty$sec にて取扱われ、`設定子$については `legacy-platform-object-defineownproperty$sec, `legacy-platform-object-set$sec にて取扱われる。 ◎ Support for getters is handled in §3.8.1 [[GetOwnProperty]], and for setters in §3.8.3 [[DefineOwnProperty]] and §3.8.2 [[Set]].
3.8.1. `GetOwnProperty^sl
どの`旧来の~platform~obj$ %O に対しても,その `GetOwnProperty^sl 内部~methは、 ( ~prop名 %P ) を引数に~callされたときには,次に従って挙動し~MUST: ◎ The [[GetOwnProperty]] internal method of every legacy platform object O must behave as follows when called with property name P:
- ~RET `LegacyPlatformObjectGetOwnProperty$A( %O, %P, `false^jv ) ◎ Return LegacyPlatformObjectGetOwnProperty(O, P, false).
3.8.2. `Set^sl
どの`旧来の~platform~obj$ %O に対しても,その `Set^sl 内部~methは、 ( ~prop名 %P, 値 %V, ~ES言語~値 %Receiver ) を引数に~callされたときには,次に従って挙動し~MUST: ◎ The [[Set]] internal method of every legacy platform object O must behave as follows when called with property name P, value V, and ECMAScript language value Receiver:
-
~IF[ %O ~EQ %Receiver ]: ◎ If O and Receiver are the same object, then:
-
~IF[ %O は `有index~propを~support$する ]~AND[ %P は`配列~indexで$ある ]~AND[ %O が実装するある~ifcに,`有index~prop設定子$が伴われている ]: ◎ If O supports indexed properties, P is an array index, and O implements an interface with an indexed property setter, then:
- `有index~prop設定子を呼出す$( %P, %V ) ◎ Invoke the indexed property setter with P and V.
- ~RET `true^jv ◎ Return true.
-
~IF[ %O は `有名~propを~support$する ]~AND[ `Type$A( %P ) ~EQ `String^jt ]~AND[ %P は`配列~indexで$ない ]~AND[ %O が実装するある~ifcに,`有名~prop設定子$が伴われている ]: ◎ If O supports named properties, Type(P) is String, P is not an array index, and O implements an interface with a named property setter, then:
- `有名~prop設定子を呼出す$( %P, %V ) ◎ Invoke the named property setter with P and V.
- ~RET `true^jv ◎ Return true.
-
- %ownDesc ~LET `LegacyPlatformObjectGetOwnProperty$A( %O, %P, `true^jv ) ◎ Let ownDesc be LegacyPlatformObjectGetOwnProperty(O, P, true).
- ? `OrdinarySetWithOwnDescriptor$A( %O, %P, %V, %Receiver, %ownDesc ) ◎ Perform ? OrdinarySetWithOwnDescriptor(O, P, V, Receiver, ownDesc).
3.8.3. `DefineOwnProperty^sl
`旧来の~platform~obj$ %O ]の `DefineOwnProperty^sl 内部~methは,[ ~prop~key %P, `~pdesc$ %Desc ]を伴って~callされたときは、次の手続きに従わ~MUST: ◎ When the [[DefineOwnProperty]] internal method of a legacy platform object O is called with property key P and Property Descriptor Desc, the following steps must be taken:
-
~IF[ %O は `有index~propを~support$する ]~AND[ %P は `配列~indexで$ある ]: ◎ If O supports indexed properties and P is an array index, then:
- ~IF[ `IsDataDescriptor$A( %Desc ) を~callした結果 ~EQ `false^jv ] ⇒ ~RET `false^jv ◎ If the result of calling IsDataDescriptor(Desc) is false, then return false.
- ~IF[ %O が実装する どの~ifcにも,`有index~prop設定子$は伴われていない ] ⇒ ~RET `false^jv ◎ If O does not implement an interface with an indexed property setter, then return false.
- `有index~prop設定子を呼出す$( %P, %Desc.`Value^sl ) ◎ Invoke the indexed property setter with P and Desc.[[Value]].
- ~RET `true^jv ◎ Return true.
-
~IF[ %O は `有名~propを~support$する ]~AND[ %O は `Global$x `拡張属性$を伴う`~ifc$を実装しない ]~AND[ `Type$A( %P ) ~EQ `String^jt ]~AND[ %P は %O の `Unforgeable$x ~prop名でない ]: ◎ If O supports named properties, O does not implement an interface with the [Global] extended attribute, Type(P) is String, and P is not an unforgeable property name of O, then:
- %creating ~LET [ %P は %O が`~supportする~prop名$であるならば ~T / ~ELSE_ ~F ] ◎ Let creating be true if P is not a supported property name, and false otherwise.
-
~IF[ %O が実装するある~ifcに, `OverrideBuiltins$x `拡張属性$が伴われている ]~OR[ %O は 名前 %P の自前の~propを持たない ]: ◎ If O implements an interface with the [OverrideBuiltins] extended attribute or O does not have an own property named P, then:
- ~IF[ %creating ~EQ ~F ]~AND[ %O が実装する どの~ifcにも,`有名~prop設定子$は伴われていない ] ⇒ ~RET `false^jv ◎ If creating is false and O does not implement an interface with a named property setter, then return false.
-
~IF[ %O が実装する ある~ifcに,`有名~prop設定子$が伴われている ]: ◎ If O implements an interface with a named property setter, then:
- `有名~prop設定子を呼出す$( %P, %Desc.`Value^sl ) ◎ Invoke the named property setter with P and Desc.[[Value]].
- ~RET `true^jv ◎ Return true.
- ~IF[ %O は `Global$x `拡張属性$を伴う`~ifc$を実装していない ] ⇒ %Desc.`Configurable^sl ~SET `true^jv ◎ If O does not implement an interface with the [Global] extended attribute, then set Desc.[[Configurable]] to true.
- ~RET `OrdinaryDefineOwnProperty$A( %O, %P, %Desc ) ◎ Return OrdinaryDefineOwnProperty(O, P, Desc).
3.8.4. `Delete^sl
どの`旧来の~platform~obj$ %O においても,その `Delete^sl 内部~methは、~prop名 %P を伴って~callされたときには,次に従って挙動し~MUST。 ◎ The [[Delete]] internal method of every legacy platform object O must behave as follows when called with property name P.
-
- %index ~LET `ToUint32$A( %P ) ◎ Let index be the result of calling ToUint32(P).
- ~IF[ %index は %O が`~supportする~prop~index$でない ] ⇒ ~RET `true^jv ◎ If index is not a supported property index, then return true.
- ~RET `false^jv ◎ Return false.
-
~IF[ %O は `有名~propを~support$する ]~AND[ %O は `Global$x `拡張属性$を伴う`~ifc$を実装しない ]~AND[ `有名~propは可視か?$( %P, %O ) ~EQ ~T ]: ◎ If O supports named properties, O does not implement an interface with the [Global] extended attribute and the result of calling the named property visibility algorithm with property name P and object O is true, then:
- ~IF[ %O が実装する どの~ifcにも,`有名~prop削除子$は伴われていない ] ⇒ ~RET `false^jv ◎ If O does not implement an interface with a named property deleter, then return false.
- %演算 ~LET `有名~prop削除子$の宣言-時に利用された演算 ◎ Let operation be the operation used to declare the named property deleter.
-
~IF[ %演算 は `識別子$を伴わずに定義されている ]: ◎ If operation was defined without an identifier, then:
- 名前 %P を与える下で[ ~ifcの記述に挙げられている,`既存の有名~propを削除する$手続き ]を遂行して,既存の有名~propを削除する ◎ Perform the steps listed in the interface description to delete an existing named property with P as the name.
- ~IF[ 手続きから削除の失敗-が指示された ] ⇒ ~RET `false^jv ◎ If the steps indicated that the deletion failed, then return false.
-
~ELSE : ◎ Otherwise, operation was defined with an identifier:
- ( %P ) を引数に[ %演算 の記述に挙げられている手続き ]を遂行する ◎ Perform the steps listed in the description of operation with P as the only argument value.
- ~IF[ %演算 は `返値型$ `boolean$T を伴って宣言されている ]~AND[ その手続きから `false^V が返された ] ⇒ ~RET `false^jv ◎ If operation was declared with a return type of boolean and the steps returned false, then return false.
- ~RET `true^jv ◎ Return true.
-
~IF[ %O は 名前 %P の自前の~propを持つ ]: ◎ If O has an own property with name P, then:
- ~IF[ その~propは~configure可能でない ] ⇒ ~RET `false^jv ◎ If the property is not configurable, then return false.
- ~ELSE ⇒ その~propを %O から除去する ◎ Otherwise, remove the property from O.
3.8.5. `PreventExtensions^sl
`旧来の~platform~obj$の `PreventExtensions^sl 内部~methが~callされたときは、次を走らす: ◎ When the [[PreventExtensions]] internal method of a legacy platform object is called, the following steps are taken:
- ~RET `false^jv ◎ Return false.
注記: これにより、`旧来の~platform~obj$は 拡張-可能に保たれる — それらに対する `PreventExtensions^sl を失敗させることにより。 ◎ Note: this keeps legacy platform objects extensible by making [[PreventExtensions]] fail for them.
3.8.6. `OwnPropertyKeys^sl
この文書は、`~ifc$を実装している`~platform~obj$(あるいは 例外を表現する~platform~obj )に対しては,完全な~prop列挙~順序は定義しない。 が、`旧来の~platform~obj$に対しては,定義する — 次に与える `OwnPropertyKeys^sl 内部~methを定義することにより。 ◎ This document does not define a complete property enumeration order for platform objects implementing interfaces (or for platform objects representing exceptions). However, it does for legacy platform objects by defining the [[OwnPropertyKeys]] internal method as follows.
`旧来の~platform~obj$ %O の `OwnPropertyKeys^sl 内部~methの~call時には、次を走らす: ◎ When the [[OwnPropertyKeys]] internal method of a legacy platform object O is called, the following steps are taken:
- %~key~list ~LET 新たな空`~list$ — これは、いくつかの~ES[ `String^jt / `Symbol^jt ]値からなる。 ◎ Let keys be a new empty list of ECMAScript String and Symbol values.
- ~IF[ %O は`有index~propを~support$する ] ⇒ ~EACH( %O が`~supportする~prop~index$ %~index ) に対し,昇順に ⇒ %~key~list に ! `ToString$A( %~index ) を`付加する$ ◎ If O supports indexed properties, then for each index of O’s supported property indices, in ascending numerical order, append ! ToString(index) to keys.
- ~IF[ %O は`有名~propを~support$する ] ⇒ ~EACH( %O が`~supportする~prop名$ %P ) に対し 【~prop名の集合を定義する仕様により定義される順序で】 ⇒ ~IF[ `有名~propは可視か?$( %P, %O ) ~EQ ~T ] ⇒ %~key~list に %P を`付加する$ ◎ If O supports named properties, then for each P of O’s supported property names that is visible according to the named property visibility algorithm, append P to keys.
- %O の ~EACH( 自前の~prop~key %P ) に対し,~propを作成した順に ⇒ ~IF[ %P は `String^jt である ] ⇒ %~key~list に %P を`付加する$ ◎ For each P of O’s own property keys that is a String, in ascending chronological order of property creation, append P to keys.
- %O の ~EACH( 自前の~prop~key %P ) に対し,~propを作成した順に ⇒ ~IF[ %P は `Symbol^jt である ] ⇒ %~key~list に %P を`付加する$ ◎ For each P of O’s own property keys that is a Symbol, in ascending chronological order of property creation, append P to keys.
- ~Assert: %~key~list 内には重複する~itemは無い ◎ Assert: keys has no duplicate items.
- ~RET %~key~list ◎ Return keys.
3.8.7. 各種 抽象~演算
所与の~prop名 %P が `配列~indexで@ あるかどうか決定するときは、次の~algoを適用する: ◎ To determine if a property name P is an array index, the following algorithm is applied:
- ~IF[ `Type$A( %P ) ~NEQ `String^jt ] ⇒ ~RET ~F ◎ If Type(P) is not String, then return false.
- %index ~LET ! `CanonicalNumericIndexString$A( %P ) ◎ Let index be ! CanonicalNumericIndexString(P).
- ~IF[ %index ~EQ `undefined^jv ] ⇒ ~RET ~F ◎ If index is undefined, then return false.
- ~IF[ `IsInteger$A(%index) ~EQ `false^jv ] ⇒ ~RET ~F ◎ If IsInteger(index) is false, then return false.
-
~IF[ %index ~EQ −0 ]~OR[ %index ~LT 0 ]~OR[ %index ~GTE 2`32^sup ~MINUS 1 ] ⇒ ~RET ~F ◎ If index is −0, then return false. ◎ If index < 0, then return false. ◎ If index ≥ 232 − 1, then return false.
注記: 2`32^sup ~MINUS 1 は、~ESに許容される最大の配列~長さである。 ◎ Note: 232 − 1 is the maximum array length allowed by ECMAScript.
- ~RET ~T ◎ Return true.
所与の有名~propを~obj上に公開するかどうかは、 `有名~propの可視性判定~algo@ を利用して決定される。 一部の有名~propは、[ `OverrideBuiltins$x `拡張属性$が利用されたかどうか ]に依存して,~obj上に公開されなくなる。 この~algoは、所与の ( ~prop名 %P, ~obj %O ) に対し,次に従って演算する: ◎ The named property visibility algorithm is used to determine if a given named property is exposed on an object. Some named properties are not exposed on an object depending on whether the [OverrideBuiltins] extended attribute was used. The algorithm operates as follows, with property name P and object O:
- ~IF[ %P は %O が`~supportする~prop名$でない ] ⇒ ~RET ~F ◎ If P is not a supported property name of O, then return false.
-
~IF[ %O は名前 %P の自前の~propを持つ ] ⇒ ~RET ~F ◎ If O has an own property named P, then return false.
注記: これには %O が偽装-不能な~propを持つ事例も含まれる — 実施においては、それらは常に %O が~supportする~prop名を持つ前に設定しておかれ,対応する有名~propを不可視にするので。 ◎ Note: This will include cases in which O has unforgeable properties, because in practice those are always set up before objects have any supported property names, and once set up will make the corresponding named properties invisible.
- ~IF[ %O が実装する ある~ifcは, `OverrideBuiltins$x `拡張属性$を持つ ] ⇒ ~RET ~T ◎ If O implements an interface that has the [OverrideBuiltins] extended attribute, then return true.
- %prototype ~LET %O . `GetPrototypeOf^sl() ◎ Let prototype be O.[[GetPrototypeOf]]().
-
~WHILE %prototype ~NEQ `null^jv : ◎ While prototype is not null:
- ~IF[ %prototype は `有名~prop~obj$でない ]~AND[ %prototype は 名前 %P の自前の~propを持つ ] ⇒ ~RET ~F ◎ If prototype is not a named properties object, and prototype has an own property named P, then return false.
- %prototype ~SET %prototype . `GetPrototypeOf^sl() ◎ Set prototype to prototype.[[GetPrototypeOf]]().
- ~RET ~T ◎ Return true.
注記: これにより、有名~propを伴う~objに対する~prop解決は,次の順序で行えるようになる: ◎ This should ensure that for objects with named properties, property resolution is done in the following order:
- 有index~prop ◎ Indexed properties.
- 自前の~prop — 偽装-不能な属性/演算も含め。 ◎ Own properties, including unforgeable attributes and operations.
-
`OverrideBuiltins$x である場合: ◎ Then, if [OverrideBuiltins]:
- 有名~prop ◎ Named properties.
- 原型鎖からの~prop ◎ Properties from the prototype chain.
-
他の場合: ◎ Otherwise, if not [OverrideBuiltins]:
- 原型鎖からの~prop ◎ Properties from the prototype chain.
- 有名~prop ◎ Named properties.
`有index~prop設定子を呼出す@ ときは、所与の ( ~prop~名 %P, ~ES値 %V ) に対し,次の手続きを遂行し~MUST: ◎ To invoke an indexed property setter with property name P and ECMAScript value V, the following steps must be performed:
- %creating ~LET [ %index は 当の~objが`~supportする~prop~index$でないならば ~T / ~ELSE_ ~F ] ◎ Let creating be true if index is not a supported property index, and false otherwise.
- %演算 ~LET `有index~prop設定子$の宣言-時に利用された演算 ◎ Let operation be the operation used to declare the indexed property setter.
- %T ~LET %演算 の 2 個目の引数の型 ◎ Let T be the type of the second argument of operation.
- %value ~LET %V を型 %T の`~IDL値に変換-$した結果 ◎ Let value be the result of converting V to an IDL value of type T.
-
- ~IF[ %creating ~EQ ~T ] ⇒ ( ~index %index, 値 %value ) を与える下で[ ~ifcの記述に挙げられている,`新たな有index~propを設定する$手続き ]を遂行する ◎ If creating is true, then perform the steps listed in the interface description to set the value of a new indexed property with index as the index and value as the value.
- ~ELSE ⇒ ( ~index %index, 値 %value ) を与える下で[ ~ifcの記述に挙げられている,`既存の有index~propを設定する$手続き ]を遂行する ◎ Otherwise, creating is false. Perform the steps listed in the interface description to set the value of an existing indexed property with index as the index and value as the value.
- ~ELSE ⇒ ( %index, %value ) を引数に[ %演算 の記述に挙げられている手続き ]を遂行する ◎ Otherwise, operation was defined with an identifier. Perform the steps listed in the description of operation with index and value as the two argument values.
`有名~prop設定子を呼出す@ ときは、所与の ( ~prop~名 %P, ~ES値 %V ) に対し,次の手続きを遂行し~MUST: ◎ To invoke a named property setter with property name P and ECMAScript value V, the following steps must be performed:
- %creating ~LET [ %P は 当の~objが`~supportする~prop名$であるならば ~T / ~ELSE_ ~F ] ◎ Let creating be true if P is not a supported property name, and false otherwise.
- %演算 ~LET `有名~prop設定子$の宣言-時に利用された演算 ◎ Let operation be the operation used to declare the named property setter.
-
- ~IF[ %creating ~EQ ~T ] ⇒ ( 名前 %P, 値 %value ) を与える下で[ ~ifcの記述に挙げられている,`新たな有名~propを設定する$手続き ]を遂行する ◎ If creating is true, then perform the steps listed in the interface description to set the value of a new named property with P as the name and value as the value.
- ~ELSE ⇒ ( 名前 %P, 値 %value ) を与える下で[ ~ifcの記述に挙げられている,`既存の有名~propを設定する$手続き ]を遂行する ◎ Otherwise, creating is false. Perform the steps listed in the interface description to set the value of an existing named property with P as the name and value as the value.
- ~ELSE ⇒ ( %P, %value ) を引数に[ %演算 の記述に挙げられている手続き ]を遂行する ◎ Otherwise, operation was defined with an identifier. Perform the steps listed in the description of operation with P and value as the two argument values.
抽象~演算 `LegacyPlatformObjectGetOwnProperty@A は、所与の ( ~obj %O, ~prop名 %P, 真偽~値 %有名~propは無視する ) で~callされたとき,次の手続きを遂行する: ◎ The LegacyPlatformObjectGetOwnProperty abstract operation performs the following steps when called with an object O, a property name P, and a boolean ignoreNamedProps value:
-
-
~IF[ %index は %O が`~supportする~prop~index$である ]: ◎ If index is a supported property index, then:
- %演算 ~LET `有index~prop取得子$の宣言-時に利用された演算 ◎ Let operation be the operation used to declare the indexed property getter.
- ~IF[ %演算 は `識別子$を伴わずに定義されている ] ⇒ %value ~SET ~index %index を与える下で[ ~ifcの記述に挙げられている,`有index~propの値を決定する$手続き ]を遂行した結果 ◎ If operation was defined without an identifier, then set value to the result of performing the steps listed in the interface description to determine the value of an indexed property with index as the index.
- ~ELSE ⇒ %value ~SET ( %index ) を引数に[ %演算 の記述に挙げられている手続き ]を遂行した結果 ◎ Otherwise, operation was defined with an identifier. Set value to the result of performing the steps listed in the description of operation with index as the only argument value.
-
`BTT-V^desc — ここで:
- %B は [ %O が実装するある~ifcに,`有index~prop設定子$が伴われている ならば `true^jv / ~ELSE_ `false^jv ]
- %有名~propは無視する ~SET ~T ◎ Set ignoreNamedProps to true.
-
-
~IF[ %O は `有名~propを~support$する ]~AND[ `有名~propは可視か?$( %P, %O ) ~EQ ~T ]~AND[ %有名~propは無視する ~EQ ~F ]: ◎ If O supports named properties, the result of running the named property visibility algorithm with property name P and object O is true, and ignoreNamedProps is false, then:
- %演算 ~LET `有名~prop取得子$の宣言-時に利用された演算 ◎ Let operation be the operation used to declare the named property getter.
-
`BET-V^desc — ここで:
- %B は[ %O が実装するある~ifcに,`有名~prop設定子$が伴われている ならば `true^jv / ~ELSE_ `false^jv ]
- %E は[ %O が実装するある~ifcに, `LegacyUnenumerableNamedProperties$x `拡張属性$が伴われているならば `false^jv / ~ELSE_ `true^jv ]
3.9. 呼戻~ifcを実装する利用元~obj
上の`idl-objects$secに述べたように、`呼戻~ifc$は,~scriptの中で~ES~objにより実装され得る/できる。 どの~ES~obj %O も[ 呼戻~ifc %I を実装している利用元~obj ]と見なされ、どう実装されるかは,次の場合分けにより決定される。 ◎ As described in §2.11 Objects implementing interfaces, callback interfaces can be implemented in script by an ECMAScript object. The following cases determine whether and how a given object is considered to be a user object implementing a callback interface:
-
%I は`単一~演算~呼戻~ifc$である場合、その演算(または多重定義されている演算の集合)の実装は,次で与えられる: ◎ If the interface is a single operation callback interface (defined below) then any object is considered to implement the interface. The implementation of the operation (or set of overloaded operations) is as follows:
- %O は`~callable$である場合、 %O 自身。 ◎ If the object is callable, then the implementation of the operation (or set of overloaded operations) is the callable object itself.
- %O は`~callable$でない場合、その演算の`識別子$を~prop名として, %O 上の `Get^sl 内部~methを呼出した結果。 【例えば `EventListener$T ~ifc — その唯一の~mbの識別子 `handleEvent^c がこの~prop名にあたる。】 ◎ Otherwise, the object is not callable. The implementation of the operation (or set of overloaded operations) is the result of invoking the internal [[Get]] method on the object with a property name that is the identifier of the operation.
- %I は`単一~演算~呼戻~ifc$でない場合、 %I 上に宣言される各~演算の実装は,次で与えられる ⇒ 当の演算の`識別子$を~prop名として,その~obj上の `Get^sl を呼出した結果 ◎ Otherwise, the interface is not a single operation callback interface. Any object is considered to implement the interface. For each operation declared on the interface with a given identifier, the implementation is the result of invoking [[Get]] on the object with a property name that is that identifier.
`~ifc$上に`定数$が宣言されていようが、~ES~objが[ その~ifcを実装している`利用元~obj$と見なされるために,そのような定数に対応する~propを持つ必要 ]はないことに注意。 ◎ Note that ECMAScript objects need not have properties corresponding to constants on them to be considered as user objects implementing interfaces that happen to have constants declared on them.
`単一~演算~呼戻~ifc@ とは、次のすべてを満たす`呼戻~ifc$である: ◎ A single operation callback interface is a callback interface that:
- 別の~ifcを`継承-$するように宣言されていない。 ◎ is not declared to inherit from another interface,
- `属性$を持たない。 ◎ has no attributes, and
- すべてが同じ`識別子$を持つ 1 個~以上の`正則~演算$があり,他のものはない。 ◎ has one or more regular operations that all have the same identifier, and no others.
【 共通の記述を集約するため、この訳では,以下に定義される各種 手続きの中から一部分を抽出して,次の 2 つの手続き "PrepareSettings", "CleanupSettings" に~~分離する: 】
`PrepareSettings@A( %~realm, %value ) は、次を遂行する:
- %関連する設定群 ~LET %~realm の`設定群~obj$
- %格納-済み設定群 ~LET %value の`呼戻~文脈$
- `~scriptを走らすために準備する$( %関連する設定群 )
- `呼戻子を走らすために準備する$( %格納-済み設定群 )
- ~RET 組 ( %関連する設定群, %格納-済み設定群 )
`CleanupSettings@A( %設定群~組, %completion, %T ) は、次を遂行する — ここで:
- %設定群~組 は `PrepareSettings$A で得られた 2 つの設定群の組
- %completion は`完了record$
- %T はある~IDL型
- ( %関連する設定群, %格納-済み設定群 ) ~LET %設定群~組
- `走らせた呼戻子を片付ける$( %格納-済み設定群 )
- `走らせた~scriptを片付ける$( %関連する設定群 )
- ~IF[ %completion は正常完了である ]~OR[ %T は`~promise型$でない ] ⇒ ~RET %completion
- %rejectedPromise ~LET ! `Call$A( `Promise_reject$jI, `Promise$jI, « %completion.`Value^sl » )
- ~RET %rejectedPromise を %T 型の`~IDL値に変換-$した結果
`~Web~IDL引数~list@ は、それぞれが[ ~IDL値または特殊~値 `missing^C ]である一連の値からなる`~list$である。 ◎ A Web IDL arguments list is a list of values each of which is either an IDL value or the special value “missing”, which represents a missing optional argument.
所与の`~Web~IDL引数~list$ %args を `~ES引数~listに変換-@ するときは、次の手続きを遂行する: ◎ To convert a Web IDL arguments list to an ECMAScript arguments list, given a Web IDL arguments list args, perform the following steps:
- %esArgs ~LET 空`~list$ ◎ Let esArgs be an empty list.
- %i ~LET 0 ◎ Let i be 0.
- %count ~LET 0 ◎ Let count be 0.
-
~WHILE %i ~LT %args の`~size$: ◎ While i < args’s size:
- ~IF[ %arg[ %i ] ~EQ 特殊~値 `missing^C ] ⇒ %esArgs に `undefined^jv を`付加する$ ◎ If args[i] is the special value “missing”, then append undefined to esArgs.
-
~ELSE( %arg[ %i ] は~IDL値である): ◎ Otherwise, args[i] is an IDL value:
- %変換-結果 ~LET %arg[ %i ] を`~ES値に変換-$した結果 — 例外は再~投出する ◎ Let convertResult be the result of converting args[i] to an ECMAScript value. Rethrow any exceptions.
- %esArgs に %変換-結果 を付加する ◎ Append convertResult to esArgs.
- %count ~SET %i ~PLUS 1 ◎ Set count to i + 1.
- %esArgs を %count 個の~itemまでに切り詰める ◎ Truncate esArgs to contain count items.
- ~RET %esArgs ◎ Return esArgs.
`利用元~objの演算を~callする@ ときは、所与の ⇒# `~ifc型$の値 %value, 演算~名 %演算~名(場合によっては随意), `~Web~IDL引数~list$ %args, `呼戻 this 値@ %thisArg (随意) ◎終 に対し、次の手続きを遂行する — この手続きは、~IDL値を返すか,例外を投出する。 ◎ To call a user object’s operation, given a callback interface type value value, sometimes-optional operation name opName, Web IDL arguments list args, and optional callback this value thisArg, perform the following steps. These steps will either return an IDL value or throw an exception.
- %completion ~LET 未初期化の変数 ◎ Let completion be an uninitialized variable.
- ~IF[ %thisArg は与えられていない ] ⇒ %thisArg ~LET `undefined^jv ◎ If thisArg was not given, let thisArg be undefined.
- %O ~LET %value に対応している~ES~obj ◎ Let O be the ECMAScript object corresponding to value.
- %~realm ~LET %O が`属する~Realm$ ◎ Let realm be O’s associated Realm.
- %設定群~組 ~LET `PrepareSettings$A( %~realm, %value ) ◎ • Let relevant settings be realm’s settings object. • Let stored settings be value’s callback context. • Prepare to run script with relevant settings. • Prepare to run a callback with stored settings.
- %T ~LET 当の演算の返値型 ◎ ↓
-
当の演算の実装 %X を決定する: ◎ Determine the implementation of the operation, X:
- ~IF[ %value の~ifcは `単一~演算~呼戻~ifc$である ]~AND[ ! `IsCallable$A( %O ) ~EQ ~T ] ⇒ %X ~SET %O ◎ If value’s interface is a single operation callback interface and ! IsCallable(O) is true, then set X to O.
-
~ELSE — %演算~名 は給されてい~MUST: ◎ Otherwise, opName must be supplied:
- %getResult ~LET `Get$A( %O, %演算~名 ) ◎ Let getResult be Get(O, opName).
- ~IF[ %getResult は`中途完了$である: ] ⇒ ~RET `CleanupSettings$A( %設定群~組, %getResult, %T ) ◎ If getResult is an abrupt completion, set completion to getResult and jump to the step labeled return.
- %X ~SET %getResult.`Value^sl ◎ Set X to getResult.[[Value]].
-
~IF[ ! `IsCallable$A( %X ) ~EQ ~F ]:
- %completion ~SET 新たな `Completion$A{ `Type^sl: throw, `Value^sl: 新たな `TypeError^jE ~obj, `Target^sl: 空 }
- ~RET `CleanupSettings$A( %設定群~組, %completion, %T )
- ~IF[ %value の~ifcは `単一~演算~呼戻~ifc$でない ]~OR[ ! `IsCallable$A( %O ) ~EQ ~F ] ⇒ %thisArg ~SET %O (供された値を上書きする) ◎ If value’s interface is not a single operation callback interface, or if ! IsCallable(O) is false, set thisArg to O (overriding the provided value).
-
%esArgs ~LET %args を`~ES引数~listに変換-$した結果 ◎ Let esArgs be the result of converting args to an ECMAScript arguments list.\
~IF[ 変換-時に例外 %E が投出された ] ⇒ ~RET `CleanupSettings$A( %設定群~組, %E, %T ) ◎ If this throws an exception, set completion to the completion value representing the thrown exception and jump to the step labeled return.
- %callResult ~LET `Call$A( %X, %thisArg, %esArgs ) ◎ Let callResult be Call(X, thisArg, esArgs).
- ~IF[ %callResult は`中途完了$である ] ⇒ ~RET `CleanupSettings$A( %設定群~組, %callResult, %T ) ◎ If callResult is an abrupt completion, set completion to callResult and jump to the step labeled return.
- %completion ~SET %callResult.`Value^sl を %T 型の`~IDL値に変換-$した結果 ◎ Set completion to the result of converting callResult.[[Value]] to an IDL value of the same type as the operation’s return type.
-
~RET `CleanupSettings$A( %設定群~組, %completion, %T )
◎ Return: at this point completion will be set to an ECMAScript completion value. • Clean up after running a callback with stored settings. • Clean up after running script with relevant settings. • If completion is a normal completion, return completion. • If completion is an abrupt completion and the operation has a return type that is not a promise type, return completion. • Let rejectedPromise be ! Call(%Promise_reject%, %Promise%, «completion.[[Value]]»). • Return the result of converting rejectedPromise to the operation’s return type.
`利用元~objの属性~値を取得する@ ときは、所与の ( `~ifc型$の値 %object, 属性~名 %属性~名 ) に対し,次の手続きを遂行する — この手続きは、~IDL値を返すか,例外を投出する。 ◎ To get a user object’s attribute value, given a callback interface type value object and attribute name attributeName, perform the following steps. These steps will either return an IDL value or throw an exception.
- %O ~LET %object に対応している~ES~obj ◎ Let O be the ECMAScript object corresponding to object.
- %T ~LET 当の属性の型 ◎ ↓
- %設定群~組 ~LET `PrepareSettings$A( %~realm, %object ) ◎ • Let relevant settings be realm’s settings object. • Let stored settings be object’s callback context. • Prepare to run script with relevant settings. • Prepare to run a callback with stored settings.
- %getResult ~LET `Get$A( %O, %属性~名 ) ◎ Let getResult be Get(O, attributeName).
- %completion ~SET %getResult.`Value^sl を %T 型の`~IDL値に変換-$した結果 ◎ Set completion to the result of converting getResult.[[Value]] to an IDL value of the same type as the attribute’s type.
- ~RET `CleanupSettings$A( %設定群~組, %completion, %T ) ◎ Return: at this point completion will be set to an ECMAScript completion value. • Clean up after running a callback with stored settings. • Clean up after running script with relevant settings. • If completion is a normal completion, return completion. • If completion is an abrupt completion and the attribute’s type is not a promise type, return completion. • Let rejectedPromise be ! Call(%Promise_reject%, %Promise%, «completion.[[Value]]»). • Return the result of converting rejectedPromise to the attribute’s type.
`利用元~objの属性~値を設定する@ ときは、所与の ⇒# `~ifc型$の値 %object, 属性~名 %属性~名, ~IDL値 %value ◎終 に対し,次の手続きを遂行する — この手続きは、何も返さないが,例外を投出し得る。 ◎ To set a user object’s attribute value, given a callback interface type value object, attribute name attributeName, and IDL value value, perform the following steps. These steps will not return anything, but could throw an exception.
- %変換-結果 ~LET %value を`~ES値に変換-$した結果 ◎ Let convertResult be the result of converting value to an ECMAScript value.
- ~IF[ %変換-結果 は`中途完了$である ] ⇒ ~RET `CleanupSettings$A( %設定群~組, %変換-結果, `void$T ) ◎ If convertResult is an abrupt completion, set completion to convertResult and jump to the step labeled return.
- %completion ~SET `Set$A( %O, %属性~名, %変換-結果.`Value^sl, `true^jv ) ◎ Set completion to Set(O, attributeName, convertResult.[[Value]], true).
- %completion ~SET `CleanupSettings$A( %設定群~組, %completion, `void$T ) ◎ Return: at this point completion will be set to an ECMAScript completion value, which is either an abrupt completion or a normal completion for the value true (as returned by Set). • Clean up after running a callback with stored settings. • Clean up after running script with relevant settings.
- ~RET [ %completion は`中途完了$であるならば %completion / ~ELSE_ `NormalCompletion$A( `void$T ) ] ◎ • If completion is an abrupt completion, return completion. • Return NormalCompletion(void).
3.10. 呼戻~関数の呼出し
`呼戻~関数$値として利用されている~ES`~callable$~objの~callのされ方は、前~節で述べた,`利用元~obj$上の`演算$の~callと同様である。 ◎ An ECMAScript callable object that is being used as a callback function value is called in a manner similar to how operations on user objects are called (as described in the previous section).
`呼戻~関数を呼出す@ ときは、所与の ⇒# `呼戻~関数~型$の値 %callable, `~Web~IDL引数~list$ %args, `呼戻 this 値$ %thisArg(随意) ◎終 に対し,次の手続きを遂行する — この手続きは、~IDL値を返すか,例外を投出する。 ◎ To invoke a callback function type value callable with a Web IDL arguments list args and an optional callback this value thisArg, perform the following steps. These steps will either return an IDL value or throw an exception.
- %F ~LET %callable に対応している~ES~obj ◎ Let F be the ECMAScript object corresponding to callable.
- %T ~LET 当の呼戻~関数の返値型 ◎ ↓
-
~IF[ ! `IsCallable$A( %F ) ~EQ ~F ]: ◎ If ! IsCallable(F) is false:
-
~IF[ %T ~EQ `void$T ] ⇒ ~RET ◎ If the callback function’s return type is void, return.
注記: これがアリなのは、 `TreatNonObjectAsNull$x が付与された属性による呼戻~関数に限られる。 ◎ Note: This is only possible when the callback function came from an attribute marked with [TreatNonObjectAsNull].
- ~RET `undefined^jv を %T 型の`~IDL値に変換-$した結果 ◎ Return the result of converting undefined to the callback function’s return type.
-
- %~realm ~LET %F が`属する~Realm$ ◎ Let realm be F’s associated Realm.
- %設定群~組 ~LET `PrepareSettings$A( %~realm, %callable ) ◎ • Let relevant settings be realm’s settings object. • Let stored settings be callable’s callback context. • Prepare to run script with relevant settings. • Prepare to run a callback with stored settings.
- %callResult ~LET `Call$A( %F, %thisArg, %esArgs ) ◎ Let callResult be Call(F, thisArg, esArgs).
- ~RET `CleanupSettings$A( %設定群~組, %completion, %T ) ◎ Return: at this point completion will be set to an ECMAScript completion value. • Clean up after running a callback with stored settings. • Clean up after running script with relevant settings. • If completion is a normal completion, return completion. • If completion is an abrupt completion and the callback function has a return type that is not a promise type, return completion. • Let rejectedPromise be ! Call(%Promise_reject%, %Promise%, «completion.[[Value]]»). • Return the result of converting rejectedPromise to the callback function’s return type.
呼戻~関数には、`構築子$として利用できるものもある。 そのような呼戻~関数の返値型は`~promise型$になっては~MUST_NOT。 ◎ Some callback functions are instead used as constructors. Such callback functions must not have a return type that is a promise type.
`呼戻~関数で構築する@ ときは、所与の ⇒# `呼戻~関数~型$の値 %callable, `~Web~IDL引数~list$ %args ◎終 に対し,次の手続きを遂行する — この手続きは、~IDL値を返すか,例外を投出する: ◎ To construct a callback function type value callable with a Web IDL arguments list args, perform the following steps. These steps will either return an IDL value or throw an exception.
- ~IF[ ! `IsConstructor$A( %F ) ~EQ `false^jv ] ⇒ ~throwTypeError ◎ If ! IsConstructor(F) is false, throw a TypeError exception.
- %T ~LET 当の呼戻~関数の返値型 ◎ ↓
- %callResult ~LET `Construct$A( %F, %esArgs ) ◎ Let callResult be Construct(F, esArgs).
- ~RET `CleanupSettings$A( %設定群~組, %completion, %T ) ◎ Return: at this point completion will be set to an ECMAScript completion value. • Clean up after running a callback with stored settings. • Clean up after running script with relevant settings. • Return completion.
3.11. ~ns
所与の~ES大域~環境 %G にて`公開されて$いる どの`~ns$ %~ns に対しても、 %G の大域~obj上に,次の特徴を有するような 対応する~propが存在し~MUST:
- 名前: %~ns の`識別子$
- 値: `~ns~obj@ と呼ばれる~obj — 詳細は、`namespace-object$secに述べる。
3.11.1. ~ns~obj
`~ns$用の`~ns~obj$は、以下に従って作成される — `~ns~objを作成する@ ときは、所与の ( `~ns$ %~ns, `~Realm$ %~realm ) に対し,次を走らす: ◎ The namespace object for a given namespace namespace and Realm realm is created as follows:
- %~ns~obj ~LET ! `ObjectCreate$A( %~realm.`ObjectPrototype$jIsl ) ◎ Let namespaceObject be ! ObjectCreate(realm.[[Intrinsics]].[[%ObjectPrototype%]]).
- `正則~属性を定義する$( %~ns, %~ns~obj, %~realm ) ◎ Define the regular attributes of namespace on namespaceObject given realm.
- `正則~演算を定義する$( %~ns, %~ns~obj, %~realm ) ◎ Define the regular operations of namespace on namespaceObject given realm.
-
`公開されて$いる, かつ[ %~ns の識別子を引数にとる `LegacyNamespace$x 拡張属性 ]を伴う ~EACH( `~ifc$ %~ifc ) に対し: ◎ For each exposed interface interface which has the [LegacyNamespace] extended attribute with the identifier of this namespace as its argument,
- %I ~LET %~ifc 用の`~ifc~obj$ ◎ Let I be the interface object for interface.
- %新たな記述子 ~LET `TFT-I^desc ◎ Let newDesc be the PropertyDescriptor{[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true, [[Value]]: I}.
- ! `DefinePropertyOrThrow$A( %~ns~obj, %~ifc の`識別子$, %新たな記述子 ) ◎ Perform ! DefinePropertyOrThrow(namespaceObject, interface’s identifier, newDesc).
3.12. 例外
3.12.1. ~DOMException~custom言語束縛
~ES言語束縛における `DOMException$T 用の`~ifc原型~obj$の `Prototype^sl `内部~slot$は、`~ifc原型~objを作成する$抽象~演算に定義されるように,内在的~obj `ErrorPrototype$jI に設定され~MUST。 ◎ In the ECMAScript binding, the interface prototype object for DOMException has its [[Prototype]] internal slot set to the intrinsic object %ErrorPrototype%, as defined in the create an interface prototype object abstract operation.
加えて,実装は、~native `Error$jt ~objに[ 特別な力/標準でない~prop ]を与える場合( `stack^jp ~propなど),それらも `DOMException$T の各~instanceに公開するべきである。 ◎ Additionaly, if an implementation gives native Error objects special powers or nonstandard properties (such as a stack property), it should also expose those on DOMException instances.
3.12.2. 例外~obj
`単純例外$は、対応する型の~native ~ES~objにより表現される。 ◎ Simple exceptions are represented by native ECMAScript objects of the corresponding type.
`DOMException$T は、`DOMException$T ~ifcを実装する`~platform~obj$により表現される。 ◎ A DOMException is represented by a platform object that implements the DOMException interface.
3.12.3. 例外の作成-法と投出-法
`例外を作成する$ときは、所与の:
- `例外~型$ %E — `単純例外$, `DOMException$T のいずれか
- 文字列 %N — `~error名$を与える/ %E は `DOMException$T の場合に限り与えられる
- 文字列 %M — ~UAにより定義される~messageを与える/ 省略時は `undefined^jv
に対し, %E に応じて 次を走らす:
-
`DOMException$T:
- %X ~LET `現在の~Realm$に属する `DOMException$T `~ifc~obj$
- ~RET ! `Construct$A( %X, « %M, %N » )
-
`単純例外$:
- %X ~LET `現在の~Realm$に属する[[ %E に対応している~ES~error ]用の`構築子$ ]
- ~RET ! `Construct$A( %X, « %M » )
`例外を投出する$ときは、所与の[ `例外を作成する$ときに与えるものと同じ %引数たち ]に対し,次を走らす: ◎ To throw a simple exception or DOMException, with a string giving the error name for the DOMException case and optionally a string giving a user agent-defined message:
- `~THROW$ `例外を作成する$( %引数たち ) ◎ Let O be the result of creating an exception with the same arguments. ◎ Throw O.
上の~algoは、`関数~obj$ %F から外へ伝播する 例外を表現する~objを, %F の`~Realm$(すなわち, %F の実行-時における`現在の~Realm$)に属するものに制約する。 例えば、次の~IDLを考える: ◎ The above algorithms restrict objects representing exceptions propagating out of a function object to be ones that are associated with the Realm of that function object (i.e., the current Realm at the time the function executes). For example, consider the IDL:
[Exposed=Window]
interface MathUtils {
/*
%x が負ならば `NotSupportedError$E `DOMException$T を投出する。
◎
If x is negative, throws a "NotSupportedError" DOMException.
*/
double computeSquareRoot(double %x);
};
`computeSquareRoot()^M ~methを異なる`~Realm$に属する `MathUtils^T ~objに適用した場合に投出される例外は、~objではなく,~methの`~Realm$に属する: ◎ If we apply computeSquareRoot to a MathUtils object from a different Realm, then the exception thrown will be from the Realm of the method, not the object it is applied to:
const %myMU = window.getMathUtils(); /* この~Realmに属する `MathUtils^T ◎ A MathUtils object from this Realm */ const %otherMU = otherWindow.getMathUtils(); /* 異なる~Realmに属する `MathUtils^T ◎ A MathUtils object from a different Realm */ %myMU instanceof Object; /* */ %otherMU instanceof Object; /* */ %otherMU instanceof otherWindow.Object; /* */ try { %otherMU.doComputation.call(%myMU, -1); } catch (%e) { console.assert(!(%e instanceof DOMException)); console.assert(%e instanceof otherWindow.DOMException); }
3.12.4. 例外の取扱い
他が指定されない限り、この文書の要件に因り~ES~runtime意味論が呼出され,例外が投出されて終端したときは、その例外は~call元まで(そこで~catchされない場合は更にその~call元まで,等々)伝播し~MUST。 ◎ Unless specified otherwise, whenever ECMAScript runtime semantics are invoked due to requirements in this document and end due to an exception being thrown, that exception must propagate to the caller, and if not caught there, to its caller, and so on.
文書~規約により,この文書に指定される~algoは、[ `例外が投出された@ ときにとる正確な手続きを指定するか, または `中途完了$を明示的に取扱う ]ことにより,投出された例外を~~捕えることもある。 ◎ Per Document conventions, an algorithm specified in this document may intercept thrown exceptions, either by specifying the exact steps to take if an exception was thrown, or by explicitly handling abrupt completions.
次の`~IDL片$は 2 つの`~ifc$と 1 つの`例外$を定義する。 `ExceptionThrower^T 上の `valueOf^M 属性は、その値の取得-が試みられたときに常に例外を投出するように定義されている。 ◎ The following IDL fragment defines two interfaces and an exception. The valueOf attribute on ExceptionThrower is defined to throw an exception whenever an attempt is made to get its value.
[Exposed=Window]
interface Dahut {
attribute DOMString type;
};
[Exposed=Window]
interface ExceptionThrower {
/*
この属性は常に `NotSupportedError$E を投出し,決して値を返さない。
◎
This attribute always throws a NotSupportedError and never returns a value.
*/
attribute long valueOf;
};
~ES実装がこの~ifcを~supportしているとするとき、例外は次の~codeに従って取扱われる: ◎ Assuming an ECMAScript implementation supporting this interface, the following code demonstrates how exceptions are handled:
var %d = getDahut(); /* `Dahut^T の~instanceを得る。 ◎ Obtain an instance of Dahut. */ var %et = getExceptionThrower(); /* `ExceptionThrower^T の~instanceを得る。 ◎ Obtain an instance of ExceptionThrower. */ try { %d.type = { toString: function() { throw "abc"; } }; } catch (%e) { /* 文字列 `abc^l はここで~catchされる。 何故なら、~native~objから文字列への変換の一環として匿名~関数が呼出され, `DefaultValue^sl, ToPrimitive, ToString のいずれの~algoも,例外を~catchするように定義されていないので。 ◎ The string "abc" is caught here, since as part of the conversion from the native object to a string, the anonymous function was invoked, and none of the [[DefaultValue]], ToPrimitive or ToString algorithms are defined to catch the exception. */ } try { %d.type = { toString: { } }; } catch (%e) { /* 例外はここで~catchされる。 toString ~propの値である~native~obj上で `Call^sl の呼出しが試みられるので。 ◎ An exception is caught here, since an attempt is made to invoke [[Call]] on the native object that is the value of toString property. */ } try { %d.type = Symbol(); } catch (%e) { /* 例外はここで~catchされる。 `Symbol^jt 値~上で~ES `ToString$A 抽象~演算を呼出そうと試みられるので。 ◎ An exception is caught here, since an attempt is made to invoke the ECMAScript ToString abstract operation on a Symbol value. */ } %d.type = %et; /* ~catchされなかった `NotSupportedError$E は ここで投出される。 `DefaultValue^sl ~algoは, `ExceptionThrower^T ~obj上の `valueOf^jp ~propの値の取得-を試みるので。 例外はこの~code~blockの外へ伝播する。 ◎ An uncaught "NotSupportedError" DOMException is thrown here, since the [[DefaultValue]] algorithm attempts to get the value of the "valueOf" property on the ExceptionThrower object. The exception propagates out of this block of code. */
4. 共通の定義
この節では、すべての`適合~実装$が~supportし~MUST,いくつかの共通の定義を指定する。 ◎ This section specifies some common definitions that all conforming implementations must support.
4.1. `ArrayBufferView^T
typedef (`Int8Array$T or `Int16Array$T or `Int32Array$T or `Uint8Array$T or `Uint16Array$T or `Uint32Array$T or `Uint8ClampedArray$T or `Float32Array$T or `Float64Array$T or `DataView$T) `ArrayBufferView$;
`ArrayBufferView^T ~typedefは、 `ArrayBuffer$T 上の~viewを供する~objを表現するために利用される。 ◎ The ArrayBufferView typedef is used to represent objects that provide a view on to an ArrayBuffer.
4.2. `BufferSource^T
typedef (`ArrayBufferView$T or `ArrayBuffer$T) `BufferSource$;
`BufferSource^T ~typedefは、 `ArrayBuffer$T ~obj自身, または `ArrayBuffer$T 上の~viewを供する~objを表現するために利用される。 ◎ The BufferSource typedef is used to represent objects that are either themselves an ArrayBuffer or which provide a view on to an ArrayBuffer.
4.3. `DOMException^T
`DOMException$T 型は、次の~IDL片により定義される`~ifc型$である: ◎ The DOMException type is an interface type defined by the following IDL fragment:
[ Exposed=(Window,Worker), Constructor(optional `DOMString$T %message = "", optional `DOMString$T %name = "Error") ] interface `DOMException$T { /* ~ES言語束縛についての下の注記も見よ。 ◎ but see below note about ECMAScript binding */ readonly attribute `DOMString$T `name$M; readonly attribute `DOMString$T `message$M; readonly attribute `unsigned short$T `code$M; const `unsigned short$T `INDEX_SIZE_ERR$Ec = 1; const `unsigned short$T `DOMSTRING_SIZE_ERR$Ec = 2; const `unsigned short$T `HIERARCHY_REQUEST_ERR$Ec = 3; const `unsigned short$T `WRONG_DOCUMENT_ERR$Ec = 4; const `unsigned short$T `INVALID_CHARACTER_ERR$Ec = 5; const `unsigned short$T `NO_DATA_ALLOWED_ERR$Ec = 6; const `unsigned short$T `NO_MODIFICATION_ALLOWED_ERR$Ec = 7; const `unsigned short$T `NOT_FOUND_ERR$Ec = 8; const `unsigned short$T `NOT_SUPPORTED_ERR$Ec = 9; const `unsigned short$T `INUSE_ATTRIBUTE_ERR$Ec = 10; const `unsigned short$T `INVALID_STATE_ERR$Ec = 11; const `unsigned short$T `SYNTAX_ERR$Ec = 12; const `unsigned short$T `INVALID_MODIFICATION_ERR$Ec = 13; const `unsigned short$T `NAMESPACE_ERR$Ec = 14; const `unsigned short$T `INVALID_ACCESS_ERR$Ec = 15; const `unsigned short$T `VALIDATION_ERR$Ec = 16; const `unsigned short$T `TYPE_MISMATCH_ERR$Ec = 17; const `unsigned short$T `SECURITY_ERR$Ec = 18; const `unsigned short$T `NETWORK_ERR$Ec = 19; const `unsigned short$T `ABORT_ERR$Ec = 20; const `unsigned short$T `URL_MISMATCH_ERR$Ec = 21; const `unsigned short$T `QUOTA_EXCEEDED_ERR$Ec = 22; const `unsigned short$T `TIMEOUT_ERR$Ec = 23; const `unsigned short$T `INVALID_NODE_TYPE_ERR$Ec = 24; const `unsigned short$T `DATA_CLONE_ERR$Ec = 25; };
注記: `es-DOMException-specialness$secにて論じたように,~ES言語束縛は `~ifc型$に対する通常のものを超える追加の要件を課す。 ◎ Note: as discussed in §3.12.1 DOMException custom bindings, the ECMAScript binding imposes additional requirements beyond the normal ones for interface types.
各 `DOMException$T ~objには、 `名前@eX, `~message@eX が結付けられる。 いずれも`~JS文字列$とする。 ◎ Each DOMException object has an associated name and message, both JavaScript strings.
DOMException(%message, %name)
-
この構築子の被呼出時には、次を走らせ~MUST: ◎ The DOMException(message, name) constructor, when invoked, must run these steps:
- %e ~LET 新たな `DOMException$T ~obj ◎ Let e be a new DOMException object.
- %e の`名前$eX ~SET %name ◎ Set e’s name to name.
- %e の`~message$eX ~SET %message ◎ Set e’s message to message.
- ~RET %e ◎ Return e.
- `name@M
- 取得子は、この `DOMException$T ~objの`名前$eXを返さ~MUST。 ◎ The name attribute’s getter must return this DOMException object’s name.
- `message@M
- 取得子は、この `DOMException$T ~objの`~message$eXを返さ~MUST。 ◎ The message attribute’s getter must return this DOMException object’s message.
- `code@M
- 取得子は、`~error名~一覧$内に,この `DOMException$T ~objの`名前$eXに対応する旧来の~codeが[ あれば それ / なければ 0 ]を返さ~MUST。 ◎ The code attribute’s getter must return the legacy code indicated in the error names table for this DOMException object’s name, or 0 if no such entry exists in the table.
4.4. `DOMTimeStamp^T
typedef `unsigned long long$T `DOMTimeStamp$;
`DOMTimeStamp^T 型は、ミリ秒数を表現するために利用される。 (何らかの起点に相対的な)絶対的な時間として,または相対的な時間差として。 この型を利用する仕様は、ミリ秒数の解釈-法も定義する必要がある。 ◎ The DOMTimeStamp type is used for representing a number of milliseconds, either as an absolute time (relative to some epoch) or as a relative amount of time. Specifications that use this type will need to define how the number of milliseconds is to be interpreted.
4.5. `Function^T
callback `Function$ = any (any... %arguments);
`Function^T `呼戻~関数$型は、渡される引数や返値の種類に制約のない関数~値を表現するために利用される。 ◎ The Function callback function type is used for representing function values with no restriction on what arguments are passed to it or what kind of value is returned from it.
4.6. `VoidFunction^T
callback `VoidFunction$ = void ();
`VoidFunction^T `呼戻~関数$型は 引数をとらず, 値を返さない関数~値を表現するために利用される。 ◎ The VoidFunction callback function type is used for representing function values that take no arguments and do not return any value.
5. 拡張性
~INFORMATIVE言語束縛の要件に対する拡張は、この文書~内で定義される拡張属性と競合しない`拡張属性$を利用して指定できる。 [ 私的な~projectに特有の利用 ]のための拡張は、他の仕様に現れる`~IDL片$に含められるべきではない。 他の仕様の用途に要求される拡張は、この文書の将来~versionに取り込まれるためには, Web IDL の担当グループ(この文書が書かれた時点では W3C Web Platform Working Group )による~~調整を通すことが推奨される。 ◎ Extensions to language binding requirements can be specified using extended attributes that do not conflict with those defined in this document. Extensions for private, project-specific use should not be included in IDL fragments appearing in other specifications. It is recommended that extensions that are required for use in other specifications be coordinated with the group responsible for work on Web IDL, which at the time of writing is the W3C Web Platform Working Group, for possible inclusion in a future version of this document.
この~IDL言語の他の側面は、拡張しないことが強く奨励される。 ◎ Extensions to any other aspect of the IDL language are strongly discouraged.
6. 旧来の構成子
~INFORMATIVE旧来の~WebIDL構成子が存在するのは、旧来の~Web~platform特色機能を指定できるようにするために限られる。 一般に,それらには、文字列 `Legacy^l が接頭される。 [ 旧来の~Web~platform特色機能の挙動を指定する/ そのような特色機能との整合性を得る ]ことが要求されない限り、旧来の~WebIDL構成子は仕様~内に利用しないことが強く奨励される。 旧来の~WebIDL構成子を利用したいと望む編集者には、先に進む前に `Intent to use a legacy WebIDL construct$fI した上で論交することを,強く勧める。 ◎ Legacy WebIDL constructs exist only so that legacy Web platform features can be specified. They are generally prefixed with the "Legacy" string. It is strongly discouraged to use legacy WebIDL constructs in specifications unless required to specify the behavior of legacy Web platform features, or for consistency with such features. Editors who wish to use legacy WebIDL constructs are strongly advised to discuss this by filing an issue before proceeding.
旧来の構成子とすること自体は、この仕様から除去されつつあることは含意しない。 しかしながら,そのような構成子は、様々な経験則により,その指定-対象である~Web~platform特色機能を[ まるごと除去できる/ 代わりに,旧来のものでない~WebIDL構成子に依拠するよう改変できる ]ことが指示されたときには、将来にこの仕様から除去する良い候補であることを示唆する。 ◎ Marking a construct as legacy does not, in itself, imply that it is about to be removed from this specification. It does suggest however, that it is a good candidate for future removal from this specification, whenever various heuristics indicate that the Web platform features it helps specify can be removed altogether or can be modified to rely on non-legacy WebIDL constructs instead.
7. この仕様を参照するとき
~INFORMATIVE一つ以上の`~IDL片$を利用して~Web~platform~ifcを定義する他の仕様は、この仕様を参照することになるものと期待されている。 それらの仕様には、~IDLが この仕様の記述に従って解釈されることを指示する,次の様な~~文を含ませることを勧める: ◎ It is expected that other specifications that define Web platform interfaces using one or more IDL fragments will reference this specification. It is suggested that those specifications include a sentence such as the following, to indicate that the IDL is to be interpreted as described in this specification:
この仕様における各~IDL片は、この仕様が規範とする参照文献にて定義される~IDL片とともに,[ “~Web~IDL” 仕様に述べられる, `適合~IDL片の集合$ に課される要件 ]に従って、解釈され~MUST。 [WEBIDL] ◎ The IDL fragment in Appendix A of this specification must, in conjunction with the IDL fragments defined in this specification’s normative references, be interpreted as required for conforming sets of IDL fragments, as described in the “Web IDL” specification. [WEBIDL]
加えて、この仕様を参照する仕様における,~UA用の適合性クラスは、この仕様の `適合~実装$クラスを参照することを勧める: ◎ In addition, it is suggested that the conformance class for user agents in referencing specifications be linked to the conforming implementation class from this specification:
適合 FooML ~UAは、 “~Web~IDL” 仕様の記述に則り,この仕様に示されている各~IDL片に対しても `適合~実装$ で~MUST。 [WEBIDL] ◎ A conforming FooML user agent must also be a conforming implementation of the IDL fragment in Appendix A of this specification, as described in the “Web IDL” specification. [WEBIDL]
8. 謝辞
~INFORMATIVE編集者は、この仕様に~~寄与された,次の方々に感謝する:
The editor would like to thank the following people for contributing to this specification: Glenn Adams, David Andersson, L. David Baron, Art Barstow, Nils Barth, Robin Berjon, David Bruant, Jan-Ivar Bruaroey, Marcos Cáceres, Giovanni Campagna, Domenic Denicola, Chris Dumez, Michael Dyck, Brendan Eich, João Eiras, Gorm Haug Eriksen, Sigbjorn Finne, David Flanagan, Aryeh Gregor, Tiancheng “Timothy” Gu, Dimitry Golubovsky, James Graham, Aryeh Gregor, Kartikaya Gupta, Marcin Hanclik, Jed Hartman, Stefan Haustein, Dominique Hazaël-Massieux, Ian Hickson, Björn Höhrmann, Kyle Huey, Lachlan Hunt, Oliver Hunt, Jim Jewett, Wolfgang Keller, Anne van Kesteren, Olav Junker Kjær, Takayoshi Kochi, Magnus Kristiansen, Takeshi Kurosawa, Yves Lafon, Travis Leithead, Jim Ley, Kevin Lindsey, Jens Lindström, Peter Linss, 呂康豪 (Kang-Hao Lu), Kyle Machulis, Mark Miller, Ms2ger, Andrew Oakley, 岡坂 史紀 (Shiki Okasaka), Jason Orendorff, Olli Pettay, Simon Pieters, Andrei Popescu, François Remy, Tim Renouf, Tim Ruffles, Alex Russell, Takashi Sakamoto, Doug Schepers, Jonas Sicking, Garrett Smith, Geoffrey Sneddon, Jungkee Song, Josh Soref, Maciej Stachowiak, Anton Tayanovskyy, Peter Van der Beken, Jeff Walden, Allen Wirfs-Brock, Jeffrey Yasskin and, Collin Xu.
編集者が休みの間、この文書を保守されていた Sam Weinig に特別な謝意を。 ◎ Special thanks also go to Sam Weinig for maintaining this document while the editor was unavailable to do so.
~IDL文法
この節では、開始~記号 `Definitions$g が`~IDL片$全体に合致する, LL(1) 文法を定義する。 ◎ This section defines an LL(1) grammar whose start symbol, Definitions, matches an entire IDL fragment.
文法~内の各~生成規則には、その右側に 1 個~以上の記号の並びが示される:
- ε は、何もなしを指示する。
- 等幅~fontで示される記号は、~literalによる終端記号である。
- 大文字から始まり, 斜体で示される記号は、非~終端記号である。
- 小文字から始まり, 斜体で示される記号は、次に示す正規表現に合致する終端記号である(Perl 5 `PERLRE$r の正規表現~構文を利用)。
- `integer^g
- ~SLASH
-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)
~SLASH - `float^g
- ~SLASH
-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)
~SLASH - `identifier^g
- ~SLASH
_?[A-Za-z][0-9A-Z_a-z-]*
~SLASH - `string^g
- ~SLASH
"[^"]*"
~SLASH - `whitespace^g
- ~SLASH
[\t\n\r ]+
~SLASH - `comment^g
- ~SLASH
\/\/.*|\/\*(.|\n)*?\*\/
~SLASH - `other^g
- ~SLASH
[^\t\n\r 0-9A-Za-z]
~SLASH
~token化は~Unicode文字~並び `UNICODE$r に対し演算する。 ~token化の際には、最長合致が利用され~MUST。 例えば,入力~textが “a1” であるなら、それは 1 個の `identifier$g に~token化され, `identifier$g と `integer$g には分離されない。 最長合致が[ 上に挙げた,名前を持つ終端記号の いずれか ]と[ 文法~内の終端記号 ]のいずれにも合致し得る場合、後者の終端記号に~token化され~MUST。 したがって、入力~text “long” は, `identifier$g `long^l ではなく,引用符で括られた終端記号 `long^sym として~token化され、 “.” は, `other$g ではなく,引用符で括られた終端記号 `.^sym として~token化される。 ◎ The tokenizer operates on a sequence of Unicode characters [UNICODE]. When tokenizing, the longest possible match must be used. For example, if the input text is “a1”, it is tokenized as a single identifier, and not as a separate identifier and integer. If the longest possible match could match one of the above named terminal symbols or one of the other terminal symbols from the grammar, it must be tokenized as the latter. Thus, the input text “long” is tokenized as the quoted terminal symbol long rather than an identifier called "long", and “.” is tokenized as the quoted terminal symbol . rather than an other.
~IDL構文においては、文字の大小は,文法~内で利用される引用符で括られた終端記号と `identifier$g 終端記号に利用される値の,いずれにおいても~~区別される。 したがって、例えば入力~text “Const” は,終端記号 `const^sym ではなく `identifier$g として~token化され、 `識別子$ `A^l を伴う`~ifc$は, `a^l を伴うそれとは別個になり、 また,`拡張属性$ `constructor^x が `Constructor$x 拡張属性に認識されることはない。 ◎ The IDL syntax is case sensitive, both for the quoted terminal symbols used in the grammar and the values used for identifier terminals. Thus, for example, the input text “Const” is tokenized as an identifier rather than the terminal symbol const, an interface with identifier "A" is distinct from one named "a", and an extended attribute [constructor] will not be recognized as the [Constructor] extended attribute.
`whitespace$g や `comment$g からなる任意~個数の終端記号が、構文解析される入力~textにおける,他のどの終端記号の合間にも、暗黙的に許容される。 それらの `whitespace$g や `comment$g は、構文解析-時には無視される。 ◎ Implicitly, any number of whitespace and comment terminals are allowed between every other terminal in the input text being parsed. Such whitespace and comment terminals are ignored while parsing.
次の LL(1) 文法の開始~記号 `Definitions$g が`~IDL片$に合致する: ◎ The following LL(1) grammar, starting with Definitions, matches an IDL fragment:
【 見出しをクリックするとその文法~記号の~~参照元が示される(上の終端記号の表も同様)。 】
注記: 非~終端記号 `Other$g は、 `(^sym, `)^sym, `[^sym, `]^sym, `{^sym, `}^sym, `,^sym を除く,任意の 1 個の終端記号に合致する。 ◎ Note: The Other non-terminal matches any single terminal symbol except for (, ), [, ], {, } and ,.
非~終端記号 `ExtendedAttribute$g は,任意の空でない終端記号の並びに合致するが(丸括弧, 角括弧, 波括弧が対になっていて, かつ `,^sym ~tokenがそのような括弧対の間にのみ現れる限り)、それらが成すアリな並びのうち一部のみが,この仕様で定義される`拡張属性$に利用される — これらの拡張属性に利用される構文については `idl-extended-attributes$sec を見よ。 ◎ While the ExtendedAttribute non-terminal matches any non-empty sequence of terminal symbols (as long as any parentheses, square brackets or braces are balanced, and the , token appears only within those balanced brackets), only a subset of those possible sequences are used by the extended attributes defined in this specification — see §2.13 Extended attributes for the syntaxes that are used by these extended attributes.
表記規約
この文書では、次の表記規約/~styleが利用される: ◎ The following typographic conventions are used in this document:
【 “†” が付与されているものは、この訳による追加の~style。 】
- 用語の定義: `用語例@ ◎ Defining instances of terms: example term
- この文書で定義される用語へのリンク: `用語例$ ◎ Links to terms defined in this document or elsewhere: example term
- 他の文書で定義される用語へのリンク: example term ◎ ↑
- 文法の終端記号(~literal): `sometoken^sym ◎ Grammar terminals: sometoken
- 文法の非~終端記号(先頭は大文字): `ExampleGrammarSymbol^g ◎ Grammar non-terminals: ExampleGrammarNonTerminal
- 文法の終端記号(正規表現による生成規則, 先頭は小文字): `identifier^g ◎ Grammar symbols: identifier
- ~IDL型: `unsigned long^T ◎ IDL types: unsigned long
-
~IDL~ifc~mb†:
`ExampleIDLMember^M,
- ~IDL値†: `ExampleIDLValue^V
- ~ES~class: `Map^jt ◎ ECMAScript classes: Map
- ~ES言語~型: `Object^jt ◎ ECMAScript language types: Object
- ~ES~obj~prop†: `property^jp
- ~ES値†: `undefined^jv
- ~ES内部[~prop/~meth/~slot]†: `ExamplePropertyOrMethodOrSlot^sl
- ~ES抽象~演算†: ExampleAbstractOperation
- ~code片: `a = b + obj.f()^c ◎ Code snippets: a = b + obj.f()
- ~Unicode文字: `0030^U1 ◎ Unicode characters: U+0030 DIGIT ZERO ("0")
- 拡張属性: `ExampleExtendedAttribute^x ◎ Extended attributes: [ExampleExtendedAttribute]
- 注釈文や~algoにおける変数~名: %exampleVariableName ◎ Variable names in prose and algorithms: exampleVariableName.
- 文字列~literal†: `example string literal^l
- モデルを定義するために利用される仮想の定数~値†: `定数~例^C
-
~IDL構文の参考例: ◎ IDL informal syntax examples:
[`extended_attributes^i] interface `identifier^i { /* `interface_members...^mk */ };
(周囲の注釈文の中で論じられている構文は, `<mark>^c 要素で`強調される^mk(~styleは~browserに依存する)。) ◎ (Specific parts of the syntax discussed in surrounding prose are highlighted.)
-
~IDL文法~片: ◎ IDL grammar snippets:
- `ExampleGrammarNonTerminal^g
- `OtherNonTerminal^g `sometoken^sym `other$g `AnotherNonTerminal^g ε // nothing
-
規範的でない注記: ◎ Non-normative notes:
注記: これは注記。 ◎ Note: This is a note.
-
規範的でない例: ◎ Non-normative examples:
これは例。 ◎ This is an example.
-
規範的な警告: ◎ Normative warnings:
これは警告。 ◎ This is a warning.
-
~code~block: ◎ Code blocks:
/* これは~IDL~code~block。 ◎ This is an IDL code block. */ [Exposed=Window] interface Example { attribute long something; };
/* これは~ES~code~block。 ◎ This is an ECMAScript code block. */ window.onload = function() { window.alert("loaded"); };
この文書の~algoでは、次の規約が利用される: ◎ The following conventions are used in the algorithms in this document:
- ~ES`完了record$( `Completion Record^en )による包装を外す( `unwrap^en する)ための "!" や "?" を接頭する記法 も含め, `ECMA-262$r による`~algo規約$を利用する。 【この訳では、その接頭-記法を利用している箇所では,原文の句 “`Perform^en(〜を遂行する)” は省略する。】 ◎ Algorithms use the conventions of the ECMAScript specification, including the ! and ? notation for unwrapping Completion Records.
- ~algoは、[ 値を返す/例外を投出する ]ことと,`完了record$を返すことを交換-可能に扱うこともある。 すなわち、[ ~RET/`~THROW$ を利用する~algo ]は[ `完了record$を返している ]ものと扱われることもあれば、`完了record$を返すものは[ 値を返している/例外を投出している ]ものと扱われることもある。 同様に,例外を~catchする際に、[ 投出された例外を受け入れる挙動を定義すること ]と, [[ `完了record$の `Type^sl ~field ~EQ `throw^i ]かどうか検査すること ]とは、等価になる。 ◎ Algorithms sometimes treat returning/throwing values and returning Completion Records interchangeably. That is, an algorithm that uses return/throw terminology may be treated as returning a Completion Record, while one that returns a Completion Record may be treated as returning a value or throwing an exception. Similarly, to catch exceptions, defining the behavior to adopt when an exception was thrown and checking if the Completion Record’s [[Type]] field is “throw” are equivalent.
- `完了record$は、~Web~IDL値などの~ES値でない値も包含できるよう,拡張された値である。 ◎ Completion Records are extended by allowing them to contain values that are not ECMAScript values, such as Web IDL values.
適合性
【 以下、この節の他の内容は W3C 日本語訳 共通ページ に委譲 】
この仕様では、次に挙げるものが適合性クラスとして定義される: ◎ The following conformance classes are defined by this specification:
- `適合~IDL片の集合@ ◎ conforming set of IDL fragments
- `~IDL片$の集合は、全体として,この仕様にて~IDL片に適用される[ “〜~MUST_NOT” , “要求される” ~levelの判定基準 ]をすべて満たすとき,`適合~IDL片の集合$になる。 ◎ A set of IDL fragments is considered to be a conforming set of IDL fragments if, taken together, they satisfy all of the must-, required- and shall-level criteria in this specification that apply to IDL fragments.
- `適合~実装@ ◎ conforming implementation
- ~UAは、自身が~supportするすべての言語束縛において,この仕様により その実装に適用される,すべての “〜~MUST_NOT” , “要求される” ~levelの判定基準を満たすとき, `適合~IDL片の集合$に対する`適合~実装$であるとされる。 ◎ A user agent is considered to be a conforming implementation relative to a conforming set of IDL fragments if it satisfies all of the must-, required- and shall-level criteria in this specification that apply to implementations for all language bindings that the user agent supports.
- `適合~ES実装@ ◎ conforming ECMAScript implementation
- ~UAは、この仕様にて~ES言語束縛の実装に適用されるすべての “〜~MUST_NOT” , “要求される” ~levelの判定基準を満たすとき, `適合~IDL片の集合$に対する`適合~ES実装$であるとされる。 ◎ A user agent is considered to be a conforming ECMAScript implementation relative to a conforming set of IDL fragments if it satisfies all of the must-, required- and shall-level criteria in this specification that apply to implementations for the ECMAScript language binding.