summaryrefslogtreecommitdiffstats
path: root/contrib/dom/idl/TypedArray.idl
blob: 17df5c30f83fe7fcb4638e17012bca2c7773c41d (plain)
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
 * typedarray.idl
 *
 * TypedArray IDL definitions scraped from the Khronos specification.
 *
 * Original Khronos Working Draft:
 *
 *   https://www.khronos.org/registry/typedarray/specs/latest/
 */

[ Constructor(unsigned long length) ]
interface ArrayBuffer {
    readonly attribute unsigned long byteLength;
    ArrayBuffer slice(long begin, optional long end);
    static boolean isView(any value);
};

[NoInterfaceObject]
interface ArrayBufferView {
    readonly attribute ArrayBuffer buffer;
    readonly attribute unsigned long byteOffset;
    readonly attribute unsigned long byteLength;
};


// The 'byte' type does not currently exist in Web IDL.
// In this IDL, it should be a signed 8 bit type.
[
    Constructor(unsigned long length),
    Constructor(Int8Array array),
    Constructor(byte[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Int8Array {
    const long BYTES_PER_ELEMENT = 1;

    readonly attribute unsigned long length;
    
    getter byte get(unsigned long index);
    setter void set(unsigned long index, byte value);
    void set(Int8Array array, optional unsigned long offset);
    void set(byte[] array, optional unsigned long offset);
    Int8Array subarray(long start, long end);
};
Int8Array implements ArrayBufferView;


// The 'unsigned byte' type does not currently exist in Web IDL, though
// 'octet' is equivalent.
[
    Constructor(unsigned long length),
    Constructor(Uint8Array array),
    Constructor(octet[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Uint8Array {
    const long BYTES_PER_ELEMENT = 1;
    
    readonly attribute unsigned long length;
    
    getter octet get(unsigned long index);
    setter void set(unsigned long index, octet value);
    void set(Uint8Array array, optional unsigned long offset);
    void set(octet[] array, optional unsigned long offset);
    Uint8Array subarray(long start, long end);
};
Uint8Array implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Uint8ClampedArray array),
    Constructor(octet[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Uint8ClampedArray {
    const long BYTES_PER_ELEMENT = 1;
    
    readonly attribute unsigned long length;

    getter octet get(unsigned long index);
    setter void set(unsigned long index, [Clamp] octet value);
    void set(Uint8ClampedArray array, optional unsigned long offset);
    void set(octet[] array, optional unsigned long offset);
    Uint8ClampedArray subarray(long start, long end);
};
Uint8ClampedArray implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Int16Array array),
    Constructor(short[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Int16Array {
    const long BYTES_PER_ELEMENT = 2;
    
    readonly attribute unsigned long length;
    
    getter short get(unsigned long index);
    setter void set(unsigned long index, short value);
    void set(Int16Array array, optional unsigned long offset);
    void set(short[] array, optional unsigned long offset);
    Int16Array subarray(long start, long end);
};
Int16Array implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Uint16Array array),
    Constructor(unsigned short[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Uint16Array {
    const long BYTES_PER_ELEMENT = 2;
    
    readonly attribute unsigned long length;
    
    getter unsigned short get(unsigned long index);
    setter void set(unsigned long index, unsigned short value);
    void set(Uint16Array array, optional unsigned long offset);
    void set(unsigned short[] array, optional unsigned long offset);
    Uint16Array subarray(long start, long end);
};
Uint16Array implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Int32Array array),
    Constructor(long[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Int32Array {
    const long BYTES_PER_ELEMENT = 4;
    
    readonly attribute unsigned long length;
    
    getter long get(unsigned long index);
    setter void set(unsigned long index, long value);
    void set(Int32Array array, optional unsigned long offset);
    void set(long[] array, optional unsigned long offset);
    Int32Array subarray(long start, long end);
};
Int32Array implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Uint32Array array),
    Constructor(unsigned long[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Uint32Array {
    const long BYTES_PER_ELEMENT = 4;
    
    readonly attribute unsigned long length;
    
    getter unsigned long get(unsigned long index);
    setter void set(unsigned long index, unsigned long value);
    void set(Uint32Array array, optional unsigned long offset);
    void set(unsigned long[] array, optional unsigned long offset);
    Uint32Array subarray(long start, long end);
};
Uint32Array implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Float32Array array),
    Constructor(float[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Float32Array {
    const long BYTES_PER_ELEMENT = 4;
    
    readonly attribute unsigned long length;
    
    getter float get(unsigned long index);
    setter void set(unsigned long index, float value);
    void set(Float32Array array, optional unsigned long offset);
    void set(float[] array, optional unsigned long offset);
    Float32Array subarray(long start, long end);
};
Float32Array implements ArrayBufferView;


[
    Constructor(unsigned long length),
    Constructor(Float64Array array),
    Constructor(double[] array),
    Constructor(ArrayBuffer buffer, 
                optional unsigned long byteOffset, optional unsigned long length)
]
interface Float64Array {
    const long BYTES_PER_ELEMENT = 8;
    
    readonly attribute unsigned long length;
    
    getter double get(unsigned long index);
    setter void set(unsigned long index, double value);
    void set(Float64Array array, optional unsigned long offset);
    void set(double[] array, optional unsigned long offset);
    Float64Array subarray(long start, long end);
};
Float64Array implements ArrayBufferView;


[
  Constructor(ArrayBuffer buffer,
              optional unsigned long byteOffset,
              optional unsigned long byteLength)
]
interface DataView {
    // Gets the value of the given type at the specified byte offset
    // from the start of the view. There is no alignment constraint;
    // multi-byte values may be fetched from any offset.
    //
    // For multi-byte values, the optional littleEndian argument
    // indicates whether a big-endian or little-endian value should be
    // read. If false or undefined, a big-endian value is read.
    //
    // These methods raise an INDEX_SIZE_ERR exception if they would read
    // beyond the end of the view.
    byte getInt8(unsigned long byteOffset);
    octet getUint8(unsigned long byteOffset);
    short getInt16(unsigned long byteOffset,
                   optional boolean littleEndian);
    unsigned short getUint16(unsigned long byteOffset,
                             optional boolean littleEndian);
    long getInt32(unsigned long byteOffset,
                  optional boolean littleEndian);
    unsigned long getUint32(unsigned long byteOffset,
                            optional boolean littleEndian);
    float getFloat32(unsigned long byteOffset,
                                  optional boolean littleEndian);
    double getFloat64(unsigned long byteOffset,
                                   optional boolean littleEndian);

    // Stores a value of the given type at the specified byte offset
    // from the start of the view. There is no alignment constraint;
    // multi-byte values may be stored at any offset.
    //
    // For multi-byte values, the optional littleEndian argument
    // indicates whether the value should be stored in big-endian or
    // little-endian byte order. If false or undefined, the value is
    // stored in big-endian byte order.
    //
    // These methods throw exceptions if they would write beyond the end
    // of the view.
    void setInt8(unsigned long byteOffset,
                 byte value);
    void setUint8(unsigned long byteOffset,
                  octet value);
    void setInt16(unsigned long byteOffset,
                  short value,
                  optional boolean littleEndian);
    void setUint16(unsigned long byteOffset,
                   unsigned short value,
                   optional boolean littleEndian);
    void setInt32(unsigned long byteOffset,
                  long value,
                  optional boolean littleEndian);
    void setUint32(unsigned long byteOffset,
                   unsigned long value,
                   optional boolean littleEndian);
    void setFloat32(unsigned long byteOffset,
                    float value,
                    optional boolean littleEndian);
    void setFloat64(unsigned long byteOffset,
                    double value,
                    optional boolean littleEndian);
};
DataView implements ArrayBufferView;