v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-typed-array.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_TYPED_ARRAY_H_
6#define INCLUDE_V8_TYPED_ARRAY_H_
7
8#include "v8-array-buffer.h" // NOLINT(build/include_directory)
9#include "v8-local-handle.h" // NOLINT(build/include_directory)
10#include "v8config.h" // NOLINT(build/include_directory)
11
12namespace v8 {
13
14class SharedArrayBuffer;
15
21 public:
22 /*
23 * The largest typed array size that can be constructed using New.
24 */
25 static constexpr size_t kMaxLength =
26 internal::kApiSystemPointerSize == 4
27 ? internal::kSmiMaxValue
28 : static_cast<size_t>(uint64_t{1} << 32);
29
34 size_t Length();
35
36 V8_INLINE static TypedArray* Cast(Value* value) {
37#ifdef V8_ENABLE_CHECKS
38 CheckCast(value);
39#endif
40 return static_cast<TypedArray*>(value);
41 }
42
43 private:
44 TypedArray();
45 static void CheckCast(Value* obj);
46};
47
52 public:
54 size_t byte_offset, size_t length);
56 size_t byte_offset, size_t length);
57 V8_INLINE static Uint8Array* Cast(Value* value) {
58#ifdef V8_ENABLE_CHECKS
59 CheckCast(value);
60#endif
61 return static_cast<Uint8Array*>(value);
62 }
63
64 private:
65 Uint8Array();
66 static void CheckCast(Value* obj);
67};
68
73 public:
75 size_t byte_offset, size_t length);
77 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset,
78 size_t length);
80#ifdef V8_ENABLE_CHECKS
81 CheckCast(value);
82#endif
83 return static_cast<Uint8ClampedArray*>(value);
84 }
85
86 private:
88 static void CheckCast(Value* obj);
89};
90
95 public:
97 size_t byte_offset, size_t length);
98 static Local<Int8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
99 size_t byte_offset, size_t length);
100 V8_INLINE static Int8Array* Cast(Value* value) {
101#ifdef V8_ENABLE_CHECKS
102 CheckCast(value);
103#endif
104 return static_cast<Int8Array*>(value);
105 }
106
107 private:
108 Int8Array();
109 static void CheckCast(Value* obj);
110};
111
116 public:
118 size_t byte_offset, size_t length);
120 size_t byte_offset, size_t length);
121 V8_INLINE static Uint16Array* Cast(Value* value) {
122#ifdef V8_ENABLE_CHECKS
123 CheckCast(value);
124#endif
125 return static_cast<Uint16Array*>(value);
126 }
127
128 private:
129 Uint16Array();
130 static void CheckCast(Value* obj);
131};
132
137 public:
139 size_t byte_offset, size_t length);
141 size_t byte_offset, size_t length);
142 V8_INLINE static Int16Array* Cast(Value* value) {
143#ifdef V8_ENABLE_CHECKS
144 CheckCast(value);
145#endif
146 return static_cast<Int16Array*>(value);
147 }
148
149 private:
150 Int16Array();
151 static void CheckCast(Value* obj);
152};
153
158 public:
160 size_t byte_offset, size_t length);
162 size_t byte_offset, size_t length);
163 V8_INLINE static Uint32Array* Cast(Value* value) {
164#ifdef V8_ENABLE_CHECKS
165 CheckCast(value);
166#endif
167 return static_cast<Uint32Array*>(value);
168 }
169
170 private:
171 Uint32Array();
172 static void CheckCast(Value* obj);
173};
174
179 public:
181 size_t byte_offset, size_t length);
183 size_t byte_offset, size_t length);
184 V8_INLINE static Int32Array* Cast(Value* value) {
185#ifdef V8_ENABLE_CHECKS
186 CheckCast(value);
187#endif
188 return static_cast<Int32Array*>(value);
189 }
190
191 private:
192 Int32Array();
193 static void CheckCast(Value* obj);
194};
195
200 public:
202 size_t byte_offset, size_t length);
204 size_t byte_offset, size_t length);
206#ifdef V8_ENABLE_CHECKS
207 CheckCast(value);
208#endif
209 return static_cast<Float32Array*>(value);
210 }
211
212 private:
213 Float32Array();
214 static void CheckCast(Value* obj);
215};
216
221 public:
223 size_t byte_offset, size_t length);
225 size_t byte_offset, size_t length);
227#ifdef V8_ENABLE_CHECKS
228 CheckCast(value);
229#endif
230 return static_cast<Float64Array*>(value);
231 }
232
233 private:
234 Float64Array();
235 static void CheckCast(Value* obj);
236};
237
242 public:
244 size_t byte_offset, size_t length);
246 size_t byte_offset, size_t length);
248#ifdef V8_ENABLE_CHECKS
249 CheckCast(value);
250#endif
251 return static_cast<BigInt64Array*>(value);
252 }
253
254 private:
256 static void CheckCast(Value* obj);
257};
258
263 public:
265 size_t byte_offset, size_t length);
267 size_t byte_offset, size_t length);
269#ifdef V8_ENABLE_CHECKS
270 CheckCast(value);
271#endif
272 return static_cast<BigUint64Array*>(value);
273 }
274
275 private:
277 static void CheckCast(Value* obj);
278};
279
280} // namespace v8
281
282#endif // INCLUDE_V8_TYPED_ARRAY_H_
static Local< BigInt64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static V8_INLINE BigInt64Array * Cast(Value *value)
static Local< BigInt64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static V8_INLINE BigUint64Array * Cast(Value *value)
static Local< BigUint64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< BigUint64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Float32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Float32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Float32Array * Cast(Value *value)
static V8_INLINE Float64Array * Cast(Value *value)
static Local< Float64Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Float64Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Int16Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Int16Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Int16Array * Cast(Value *value)
static V8_INLINE Int32Array * Cast(Value *value)
static Local< Int32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Int32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Int8Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Int8Array * Cast(Value *value)
static Local< Int8Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static V8_INLINE TypedArray * Cast(Value *value)
size_t Length()
static Local< Uint16Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Uint16Array * Cast(Value *value)
static Local< Uint16Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Uint32Array * Cast(Value *value)
static Local< Uint32Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Uint32Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Uint8Array * Cast(Value *value)
static Local< Uint8Array > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static Local< Uint8Array > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Uint8ClampedArray > New(Local< SharedArrayBuffer > shared_array_buffer, size_t byte_offset, size_t length)
static Local< Uint8ClampedArray > New(Local< ArrayBuffer > array_buffer, size_t byte_offset, size_t length)
static V8_INLINE Uint8ClampedArray * Cast(Value *value)
#define V8_EXPORT
Definition v8config.h:578
#define V8_INLINE
Definition v8config.h:425