[1] [[Web IDL]]/[[DOM]] の[DFN[[RUBYB[[[型]]]@en[type]]]]の一覧です。

* 仕様書

[REFS[
- [3] [CITE[Web IDL (Second Edition)]] ([TIME[2014-02-10 21:45:38 +09:00]] 版) <http://heycam.github.io/webidl/#idl-types>
]REFS]

* WebIDL 基本的な型

[FIG(short list)[
- [CODE(DOMi)@en[[[any]]]]
- [CODE(DOMi)@en[[[byte]]]]
- [CODE(DOMi)@en[[[octet]]]]
- [CODE(DOMi)@en[[[boolean]]]]
- [CODE(DOMi)@en[[[short]]]]
- [CODE(DOMi)@en[[[unsigned short]]]]
- [CODE(DOMi)@en[[[long]]]]
- [CODE(DOMi)@en[[[unsigned long]]]]
- [CODE(DOMi)@en[[[long long]]]]
- [CODE(DOMi)@en[[[unsigned long]]]]
- [CODE(DOMi)@en[[[float]]]]
- [CODE(DOMi)@en[[[unrestricted float]]]]
- [CODE(DOMi)@en[[[double]]]]
- [CODE(DOMi)@en[[[unrestricted double]]]]
- [CODE(DOMi)@en[[[DOMString]]]]
- [CODE(DOMi)@en[[[USVString]]]]
- [CODE(DOMi)@en[[[ByteString]]]]
- [CODE(DOMi)@en[[[object]]]]
- [CODE(DOMi)@en[[[Date]]]]
- [CODE(DOMi)@en[[[RegExp]]]]
- [CODE(DOMi)@en[[[Function]]]]
- [CODE(DOMi)@en[[[Int8Array]]]]
- [CODE(DOMi)@en[[[Int16Array]]]]
- [CODE(DOMi)@en[[[Int32Array]]]]
- [CODE(DOMi)@en[[[Uint8Array]]]]
- [CODE(DOMi)@en[[[Uint16Array]]]]
- [CODE(DOMi)@en[[[Uint32Array]]]]
- [CODE(DOMi)@en[[[Uint8ClampedArray]]]]
- [CODE(DOMi)@en[[[Float32Array]]]]
- [CODE(DOMi)@en[[[Float64Array]]]]
- [CODE(DOMi)@en[[[ArrayBuffer]]]]
- [CODE(DOMi)@en[[[DataView]]]]
- [CODE(DOMi)@en[[[Error]]]]
- [CODE(DOMi)@en[[[DOMException]]]]
- [CODE(DOMi)@en[symbol][symbol (JavaScript)]]
]FIG]

* IDL 素片により定義される型

[FIG(short list)[
- [CODE(DOMi)@en[[[interface]]]]
- [CODE(DOMi)@en[[[dictionary]]]]
- [CODE(DOMi)@en[[[enum]]]]
- [CODE(DOMi)@en[[[callback]]]]

[HISTORY[
- [CODE(DOMi)@en[class][クラス (JavaScript)]]
]HISTORY]
]FIG]

[2] [[DOMインターフェイスの一覧]]、[[型定義]]も参照。

* 組み合わせの型

[FIG(short list)[
- [CODE(DOMi)@en[[[?]]]]
- [CODE(DOMi)@en[[[sequence<>]]]]
- [CODE(DOMi)@en[[[union]]]]
- [CODE(IDL)@en[[[Promise<>]]]]
- [CODE(IDL)@en[[[FrozenArray<>]]]]
- [CODE(IDL)@en[record<>]]
]FIG]

* 歴史的な型

[HISTORY[
[14] 
[FIG(short list)[
- [CODE(DOMi)@en[[['''['''''']''']]]]
- [CODE(DOMi)@en[[[exception]]]]
- [CODE(DOMi)@en[[[ScalarValueString]]]]
- [CODE(DOMi)@en[[[ArrayBufferData]]]]
- DOM3 Core
-- [CODE(DOMi)@en[[[DOMObject]]]]
-- [CODE(DOMi)@en[[[DOMUserData]]]]
-- [CODE(DOMi)@en[UserDataHandler]]
- DOM LS
-- [CODE(DOMi)@en[[[LSInputStream]]]]
-- [CODE(DOMi)@en[[[LSOutputStream]]]]
-- [CODE(DOMi)@en[[[LSReader]]]]
-- [CODE(DOMi)@en[[[LSWriter]]]]
- XML Schema API
-- [CODE(DOMi)@en[[[GenericString]]]]
-- [CODE(DOMi)@en[[[GenericObject]]]]
-- @@ XXX
- WebCGM DOM
-- [CODE(DOMi)@en[[[WebCGMString]]]]
]FIG]
]HISTORY]

* 分類

[4] [[Web IDL]] では次のような分類が定義されています [SRC[>>3]]。
[FIG(short list)[
- [[整数型]]
- [[数値型]]
- [[文字列型]]
- [[primitive型]]
- [[型付き配列型]]
- [[バッファー源型]]
- [[オブジェクト型]]
]FIG]

* 識別子

[5] [[Web IDL]] 上では、組み込みの型は予約語 (の組み合わせ) により、
[[IDL素片]]により定義される型は[[識別子]]により、
組み合わせの型はそれらと [[Web IDL]] の構文の組み合わせによって表現されます。

[6] それぞれの[[型]]に対しては[[型名]]が定義されています [SRC[>>3]]。
ただし[[型名]]は衝突することがありますから、[[型]]を識別する目的では使えません。

* 型に関する概念

[7] [CODE(IDL)@en[[[any]]]] や[[union型]]において実際の値の[[型]]のことを、
[[特定型]]といいます。

[13] [[配列型]]や[[列型]]において構成要素の[[型]]のことを、[[要素型]]といいます。

[9] [[union型]]を構成する[[型]]を[[メンバー型]]といいます。

[8] [[null可能型]]に対して元の[[型]]のことを[[内側型]]といいます。

* 型指定の制約

[HISTORY[
@@ [16] この表は古くなっています。

[12] [[型]]は、指定されてる対象によって、次のような制約があります。
[FIG[
,        ,[CODE(IDL)@en[[[any]]]],[[primitive型]],[CODE(IDL)@en[[[object]]]],[[インターフェイス]],[[辞書]],[[列挙]],[[コールバック関数]],[CODE(IDL)@en[[[Date]]]],[CODE(IDL)@en[[[RegExp]]]],[CODE(IDL)@en[[[void]]]]
,[[定数]]の[[型]],×,○?t,×,×,×,×,×,×,×
,[[属性]]の[[型]],○?tau,○?tau,○?tau,○?tau,×,○?tau,○?tau,○?tau,○?tau
,[[返し型]],○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○
,[[引数]]の[[型]],○?taus,○?taus,○?taus,○?taus,○taus,○?taus,○?taus,○?taus,○?taus
,[[辞書メンバー]]の[[型]],○?taus,○?taus,○?taus,○?taus,※taus,○?taus,○?taus,○?taus,○?taus
,[[例外フィールド]]の[[型]],○?tau,○?tau,○?tau,○?tau,×,○?tau,○?tau,○?tau,○?tau
,[[直列化可能型]],×,○?tus,×,※?tus,※?tus,○?tus,×,○?tus,×
,[CODE(IDL)@en[[[typedef]]]] の[[型]],○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus
,[[union]]の[[メンバー型]],×,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus
,[[null可能型]]の[[内側型]],×,○taus,○taus,○taus,○taus,○taus,○taus,○taus,○taus
,[CODE(IDL)@en[[[sequence<>]]]] の[[内側型]],○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus
,[[配列]]の[[内側型]],○?tau,○?tau,○?tau,○?tau,×,○?tau,○?tau,○?tau,○?tau
,[CODE(IDL)@en[[[Promise]]]] の[[内側型]],○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○?taus,○

- ?・・・[[null可能型]]も可能
- t・・・[CODE(IDL)[[[typdef]]]] も可能
- a・・・[[配列]]も可能
- u・・・[[union]]も可能
- s・・・[CODE(IDL)@en[[[sequence]]]] も可能
]FIG]
]HISTORY]

* 演算

[FIG(short list)[ [10] [[Web IDL値]]の[[演算]]
- [[変換][変換 (Web IDL)]]
- [[構造化クローン]]
]FIG]

* 関連

[SEE[ [[Infra値]], [[JavaScript値]] ]]

* 歴史

[11] [CITE@en[Make quality an explicit argument for canvas image conversion]]
([[domenic]]著, [TIME[2016-08-27 03:42:08 +09:00]])
<https://github.com/whatwg/html/commit/7d25c4c2452b705220417ffb951c9b89e04ba50b>

[15] [CITE@en[Reword the distinguishability algorithm.]]
([[jyasskin]]著, [TIME[2016-10-18 10:06:41 +09:00]])
<https://github.com/heycam/webidl/commit/ab1756ece27426128adaa7b9ea809a7a615d6f40>

[17] [CITE@en['''['''geometry''']''' Use union instead of overload for DOMMatrix/DOMMatrixReadO…]]
([[zcorpan]]著, [TIME[2017-05-03 16:51:55 +09:00]])
<https://github.com/w3c/fxtf-drafts/commit/2e04b5db67698e01f5852d66b300d45fe6d10387>

[18] [CITE@en[Allow extended attributes to apply to types (#286)]]
([[domenic]]著, [TIME[2017-03-31 01:20:11 +09:00]])
<https://github.com/heycam/webidl/commit/faaaaa9ffb548a303db362a09e4b1504c4605e0c>

[19] >>18 これが前からあれば [CODE(IDL)@en[USVString]] は要らなかったんだがなw

[20] [CITE@en[Fix Web IDL extended attribute usage for recent changes]]
([[domenic]]著, [TIME[2017-04-25 08:22:53 +09:00]])
<https://github.com/whatwg/html/commit/793ace83447c9420a4dbc14f9bb14d3c35550f0a>

[21] [CITE@en[Clarify value vs type in distinguishability categories (#413)]]
([[TimothyGu]]著, [TIME[2017-08-17 07:46:17 +09:00]])
<https://github.com/heycam/webidl/commit/b0ab1c0abb63ee47b30aaf502140a5c18c3e0573>

[22] [CITE@en[Fix grammar conflicts]]
([[tobie]]著, [TIME[2017-10-11 05:54:31 +09:00]])
<https://github.com/heycam/webidl/commit/76c51928d97b2cd09083120c64056ba4b7adc20c>

[23] [CITE@en[Check grammar is LL(1) as part of Travis builds by tobie · Pull Request #458 · heycam/webidl]]
([TIME[2017-10-12 17:11:36 +09:00]])
<https://github.com/heycam/webidl/pull/458>

[24] [CITE@en[Maybe we should think about Interface.isInterface functions again]]
([[Boris Zbarsky]]著, [TIME[2013-07-20 12:46:30 +09:00]])
<https://lists.w3.org/Archives/Public/public-script-coord/2013JulSep/0105.html>

[25] [CITE@en[24413 – consider adding Interface.isInterface() functions]]
([TIME[2017-12-08 16:10:12 +09:00]])
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=24413>

[26] [CITE@en[Editorial: refer to the correct types in integer conversion algorithms]]
([[Ms2ger]]著, [TIME[2019-01-15 22:27:50 +09:00]])
<https://github.com/heycam/webidl/commit/107e981e86919291e9e99b605751173e669f7eb5>

[27] [CITE@en[Integer type conversions seem to return wrong type for unsigned types and long long · Issue #579 · heycam/webidl]]
([TIME[2019-06-18 15:18:18 +09:00]])
<https://github.com/heycam/webidl/issues/579>

[28] [CITE@en[Editorial: Refer to the correct types in integer conversion algorithms. by Ms2ger · Pull Request #613 · heycam/webidl]]
([TIME[2019-06-18 15:18:33 +09:00]])
<https://github.com/heycam/webidl/pull/613>