22
22
23
23
open Js
24
24
25
- type uint32 = float
26
-
27
25
class type arrayBuffer = object
28
26
method byteLength : int readonly_prop
29
27
@@ -42,7 +40,7 @@ class type arrayBufferView = object
42
40
method byteLength : int readonly_prop
43
41
end
44
42
45
- class type ['a, 'b ] typedArray = object
43
+ class type ['a, 'b, 'c ] typedArray = object
46
44
inherit arrayBufferView
47
45
48
46
method _BYTES_PER_ELEMENT : int readonly_prop
@@ -51,41 +49,61 @@ class type ['a, 'b] typedArray = object
51
49
52
50
method set_fromArray : 'a js_array t -> int -> unit meth
53
51
54
- method set_fromTypedArray : ('a, 'b) typedArray t -> int -> unit meth
52
+ method set_fromTypedArray : ('a, 'b, 'c ) typedArray t -> int -> unit meth
55
53
56
- method subarray : int -> int -> ('a, 'b) typedArray t meth
54
+ method subarray : int -> int -> ('a, 'b, 'c ) typedArray t meth
57
55
58
- method subarray_toEnd : int -> ('a, 'b) typedArray t meth
56
+ method subarray_toEnd : int -> ('a, 'b, 'c ) typedArray t meth
59
57
60
- method slice : int -> int -> ('a, 'b) typedArray t meth
58
+ method slice : int -> int -> ('a, 'b, 'c ) typedArray t meth
61
59
62
- method slice_toEnd : int -> ('a, 'b) typedArray t meth
60
+ method slice_toEnd : int -> ('a, 'b, 'c ) typedArray t meth
63
61
64
- method _content_type_ : 'b optdef readonly_prop
62
+ (* This fake method is needed for typing purposes. Without it, ['b] would not
63
+ be constrained. *)
64
+ method _content_type_ : ('b * 'c) optdef readonly_prop
65
65
end
66
66
67
- type int8Array = (int , Bigarray .int8_signed_elt ) typedArray
67
+ type int8Array = (int , int , Bigarray .int8_signed_elt ) typedArray
68
+
69
+ type uint8Array = (int , int , Bigarray .int8_unsigned_elt ) typedArray
68
70
69
- type uint8Array = (int , Bigarray .int8_unsigned_elt ) typedArray
71
+ type int16Array = (int , int , Bigarray .int16_signed_elt ) typedArray
70
72
71
- type int16Array = (int , Bigarray .int16_signed_elt ) typedArray
73
+ type uint16Array = (int , int , Bigarray .int16_unsigned_elt ) typedArray
72
74
73
- type uint16Array = (int , Bigarray .int16_unsigned_elt ) typedArray
75
+ type int32Array = (number_t , Int32 .t , Bigarray .int32_elt ) typedArray
74
76
75
- type int32Array = (int32 , Bigarray .int32_elt ) typedArray
77
+ type uint32Array = (number_t , Int32 .t , Bigarray .int32_elt ) typedArray
76
78
77
- type uint32Array = (int32 , Bigarray .int32_elt ) typedArray
79
+ type float32Array = (number_t , float , Bigarray .float32_elt ) typedArray
78
80
79
- type float32Array = (float , Bigarray .float32_elt ) typedArray
81
+ type float64Array = (number_t , float , Bigarray .float64_elt ) typedArray
80
82
81
- type float64Array = (float , Bigarray .float64_elt ) typedArray
83
+ (* * The first type parameter is the type of values that can be read and written
84
+ in the {!classtype:typedArray}. The last two type parameters define the
85
+ kind of bigarrays that can be converted to and from the
86
+ {!classtype:typedArray}. See {!type:Bigarray.kind}. *)
87
+ type (_, _, _) kind =
88
+ | Int8_signed : (int , int , Bigarray .int8_signed_elt ) kind
89
+ | Int8_unsigned : (int , int , Bigarray .int8_unsigned_elt ) kind
90
+ | Int16_signed : (int , int , Bigarray .int16_signed_elt ) kind
91
+ | Int16_unsigned : (int , int , Bigarray .int16_unsigned_elt ) kind
92
+ | Int32_signed : (number_t , Int32 .t , Bigarray .int32_elt ) kind
93
+ | Int32_unsigned : (number_t , Int32 .t , Bigarray .int32_elt ) kind
94
+ | Float32 : (number_t , float , Bigarray .float32_elt ) kind
95
+ | Float64 : (number_t , float , Bigarray .float64_elt ) kind
82
96
83
- val kind : ('a , 'b ) typedArray t -> ('a , 'b ) Bigarray .kind
97
+ val kind : ('typed_array , 'bigarray , 'elt ) typedArray t -> ('bigarray , 'elt ) Bigarray .kind
84
98
85
99
val from_genarray :
86
- ('a , 'b , Bigarray .c_layout ) Bigarray.Genarray .t -> ('a , 'b ) typedArray t
100
+ ('typed_array , 'bigarray , 'elt ) kind
101
+ -> ('bigarray , 'elt , Bigarray .c_layout ) Bigarray.Genarray .t
102
+ -> ('typed_array , 'bigarray , 'elt ) typedArray t
87
103
88
- val to_genarray : ('a , 'b ) typedArray t -> ('a , 'b , Bigarray .c_layout ) Bigarray.Genarray .t
104
+ val to_genarray :
105
+ ('typed_array , 'bigarray , 'elt ) typedArray t
106
+ -> ('bigarray , 'elt , Bigarray .c_layout ) Bigarray.Genarray .t
89
107
90
108
val int8Array : (int -> int8Array t ) constr
91
109
@@ -139,7 +157,7 @@ val int32Array_inBuffer : (arrayBuffer t -> int -> int -> int32Array t) constr
139
157
140
158
val uint32Array : (int -> uint32Array t ) constr
141
159
142
- val uint32Array_fromArray : (uint32 js_array t -> uint32Array t ) constr
160
+ val uint32Array_fromArray : (number_t js_array t -> uint32Array t ) constr
143
161
144
162
val uint32Array_fromTypedArray : (uint32Array t -> uint32Array t ) constr
145
163
@@ -167,11 +185,11 @@ val float64Array_fromBuffer : (arrayBuffer t -> float64Array t) constr
167
185
168
186
val float64Array_inBuffer : (arrayBuffer t -> int -> int -> float64Array t ) constr
169
187
170
- val set : ('a , 'b ) typedArray t -> int -> 'a -> unit
188
+ val set : ('a , _ , _ ) typedArray t -> int -> 'a -> unit
171
189
172
- val get : ('a , 'b ) typedArray t -> int -> 'a optdef
190
+ val get : ('a , _ , _ ) typedArray t -> int -> 'a optdef
173
191
174
- val unsafe_get : ('a , 'b ) typedArray t -> int -> 'a
192
+ val unsafe_get : ('a , _ , _ ) typedArray t -> int -> 'a
175
193
176
194
class type dataView = object
177
195
inherit arrayBufferView
@@ -188,13 +206,13 @@ class type dataView = object
188
206
189
207
method getUint16_ : int -> bool t -> int meth
190
208
191
- method getInt32 : int -> int meth
209
+ method getInt32 : int -> number_t meth
192
210
193
- method getInt32_ : int -> bool t -> int meth
211
+ method getInt32_ : int -> bool t -> number_t meth
194
212
195
- method getUint32 : int -> uint32 meth
213
+ method getUint32 : int -> number_t meth
196
214
197
- method getUint32_ : int -> bool t -> uint32 meth
215
+ method getUint32_ : int -> bool t -> number_t meth
198
216
199
217
method getFloat32 : int -> number_t meth
200
218
@@ -216,13 +234,13 @@ class type dataView = object
216
234
217
235
method setUint16_ : int -> int -> bool t -> unit meth
218
236
219
- method setInt32 : int -> int -> unit meth
237
+ method setInt32 : int -> number_t -> unit meth
220
238
221
- method setInt32_ : int -> int -> bool t -> unit meth
239
+ method setInt32_ : int -> number_t -> bool t -> unit meth
222
240
223
- method setUint32 : int -> uint32 -> unit meth
241
+ method setUint32 : int -> number_t -> unit meth
224
242
225
- method setUint32_ : int -> uint32 -> bool t -> unit meth
243
+ method setUint32_ : int -> number_t -> bool t -> unit meth
226
244
227
245
method setFloat32 : int -> number_t -> unit meth
228
246
0 commit comments