/
994.txt
195 lines (159 loc) · 7.3 KB
/
994.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
[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]
* 型変換
[10] [[変換][変換 (Web IDL)]]を参照。
* 歴史
[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>