Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/node/v8-typed-array.h
$ cat -n /usr/include/node/v8-typed-array.h 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
9 10 #include "v8-array-buffer.h" // NOLINT(build/include_directory) 11 #include "v8-local-handle.h" // NOLINT(build/include_directory) 12 #include "v8config.h" // NOLINT(build/include_directory) 13 14 namespace v8 { 15 16 /** 17 * A base class for an instance of TypedArray series of constructors 18 * (ES6 draft 15.13.6). 19 */ 20 class V8_EXPORT TypedArray : public ArrayBufferView { 21 public: 22 /* 23 * The largest supported typed array byte size. Each subclass defines a 24 * type-specific kMaxLength for the maximum length that can be passed to New. 25 */ 26 #if V8_ENABLE_SANDBOX 27 static constexpr size_t kMaxByteLength = 28 internal::kMaxSafeBufferSizeForSandbox; 29 #elif V8_HOST_ARCH_32_BIT 30 static constexpr size_t kMaxByteLength = std::numeric_limits
::max(); 31 #else 32 // The maximum safe integer (2^53 - 1). 33 static constexpr size_t kMaxByteLength = 34 static_cast
((uint64_t{1} << 53) - 1); 35 #endif 36 37 /** 38 * Number of elements in this typed array 39 * (e.g. for Int16Array, |ByteLength|/2). 40 */ 41 size_t Length(); 42 43 V8_INLINE static TypedArray* Cast(Value* value) { 44 #ifdef V8_ENABLE_CHECKS 45 CheckCast(value); 46 #endif 47 return static_cast
(value); 48 } 49 50 private: 51 TypedArray(); 52 static void CheckCast(Value* obj); 53 }; 54 55 /** 56 * An instance of Uint8Array constructor (ES6 draft 15.13.6). 57 */ 58 class V8_EXPORT Uint8Array : public TypedArray { 59 public: 60 /* 61 * The largest Uint8Array size that can be constructed using New. 62 */ 63 static constexpr size_t kMaxLength = 64 TypedArray::kMaxByteLength / sizeof(uint8_t); 65 static_assert(sizeof(uint8_t) == 1); 66 67 static Local
New(Local
array_buffer, 68 size_t byte_offset, size_t length); 69 static Local
New(Local
shared_array_buffer, 70 size_t byte_offset, size_t length); 71 V8_INLINE static Uint8Array* Cast(Value* value) { 72 #ifdef V8_ENABLE_CHECKS 73 CheckCast(value); 74 #endif 75 return static_cast
(value); 76 } 77 78 private: 79 Uint8Array(); 80 static void CheckCast(Value* obj); 81 }; 82 83 /** 84 * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6). 85 */ 86 class V8_EXPORT Uint8ClampedArray : public TypedArray { 87 public: 88 /* 89 * The largest Uint8ClampedArray size that can be constructed using New. 90 */ 91 static constexpr size_t kMaxLength = 92 TypedArray::kMaxByteLength / sizeof(uint8_t); 93 static_assert(sizeof(uint8_t) == 1); 94 95 static Local
New(Local
array_buffer, 96 size_t byte_offset, size_t length); 97 static Local
New( 98 Local
shared_array_buffer, size_t byte_offset, 99 size_t length); 100 V8_INLINE static Uint8ClampedArray* Cast(Value* value) { 101 #ifdef V8_ENABLE_CHECKS 102 CheckCast(value); 103 #endif 104 return static_cast
(value); 105 } 106 107 private: 108 Uint8ClampedArray(); 109 static void CheckCast(Value* obj); 110 }; 111 112 /** 113 * An instance of Int8Array constructor (ES6 draft 15.13.6). 114 */ 115 class V8_EXPORT Int8Array : public TypedArray { 116 public: 117 /* 118 * The largest Int8Array size that can be constructed using New. 119 */ 120 static constexpr size_t kMaxLength = 121 TypedArray::kMaxByteLength / sizeof(int8_t); 122 static_assert(sizeof(int8_t) == 1); 123 124 static Local
New(Local
array_buffer, 125 size_t byte_offset, size_t length); 126 static Local
New(Local
shared_array_buffer, 127 size_t byte_offset, size_t length); 128 V8_INLINE static Int8Array* Cast(Value* value) { 129 #ifdef V8_ENABLE_CHECKS 130 CheckCast(value); 131 #endif 132 return static_cast
(value); 133 } 134 135 private: 136 Int8Array(); 137 static void CheckCast(Value* obj); 138 }; 139 140 /** 141 * An instance of Uint16Array constructor (ES6 draft 15.13.6). 142 */ 143 class V8_EXPORT Uint16Array : public TypedArray { 144 public: 145 /* 146 * The largest Uint16Array size that can be constructed using New. 147 */ 148 static constexpr size_t kMaxLength = 149 TypedArray::kMaxByteLength / sizeof(uint16_t); 150 static_assert(sizeof(uint16_t) == 2); 151 152 static Local
New(Local
array_buffer, 153 size_t byte_offset, size_t length); 154 static Local
New(Local
shared_array_buffer, 155 size_t byte_offset, size_t length); 156 V8_INLINE static Uint16Array* Cast(Value* value) { 157 #ifdef V8_ENABLE_CHECKS 158 CheckCast(value); 159 #endif 160 return static_cast
(value); 161 } 162 163 private: 164 Uint16Array(); 165 static void CheckCast(Value* obj); 166 }; 167 168 /** 169 * An instance of Int16Array constructor (ES6 draft 15.13.6). 170 */ 171 class V8_EXPORT Int16Array : public TypedArray { 172 public: 173 /* 174 * The largest Int16Array size that can be constructed using New. 175 */ 176 static constexpr size_t kMaxLength = 177 TypedArray::kMaxByteLength / sizeof(int16_t); 178 static_assert(sizeof(int16_t) == 2); 179 180 static Local
New(Local
array_buffer, 181 size_t byte_offset, size_t length); 182 static Local
New(Local
shared_array_buffer, 183 size_t byte_offset, size_t length); 184 V8_INLINE static Int16Array* Cast(Value* value) { 185 #ifdef V8_ENABLE_CHECKS 186 CheckCast(value); 187 #endif 188 return static_cast
(value); 189 } 190 191 private: 192 Int16Array(); 193 static void CheckCast(Value* obj); 194 }; 195 196 /** 197 * An instance of Uint32Array constructor (ES6 draft 15.13.6). 198 */ 199 class V8_EXPORT Uint32Array : public TypedArray { 200 public: 201 /* 202 * The largest Uint32Array size that can be constructed using New. 203 */ 204 static constexpr size_t kMaxLength = 205 TypedArray::kMaxByteLength / sizeof(uint32_t); 206 static_assert(sizeof(uint32_t) == 4); 207 208 static Local
New(Local
array_buffer, 209 size_t byte_offset, size_t length); 210 static Local
New(Local
shared_array_buffer, 211 size_t byte_offset, size_t length); 212 V8_INLINE static Uint32Array* Cast(Value* value) { 213 #ifdef V8_ENABLE_CHECKS 214 CheckCast(value); 215 #endif 216 return static_cast
(value); 217 } 218 219 private: 220 Uint32Array(); 221 static void CheckCast(Value* obj); 222 }; 223 224 /** 225 * An instance of Int32Array constructor (ES6 draft 15.13.6). 226 */ 227 class V8_EXPORT Int32Array : public TypedArray { 228 public: 229 /* 230 * The largest Int32Array size that can be constructed using New. 231 */ 232 static constexpr size_t kMaxLength = 233 TypedArray::kMaxByteLength / sizeof(int32_t); 234 static_assert(sizeof(int32_t) == 4); 235 236 static Local
New(Local
array_buffer, 237 size_t byte_offset, size_t length); 238 static Local
New(Local
shared_array_buffer, 239 size_t byte_offset, size_t length); 240 V8_INLINE static Int32Array* Cast(Value* value) { 241 #ifdef V8_ENABLE_CHECKS 242 CheckCast(value); 243 #endif 244 return static_cast
(value); 245 } 246 247 private: 248 Int32Array(); 249 static void CheckCast(Value* obj); 250 }; 251 252 /** 253 * An instance of Float16Array constructor. 254 */ 255 class V8_EXPORT Float16Array : public TypedArray { 256 static constexpr size_t kMaxLength = 257 TypedArray::kMaxByteLength / sizeof(uint16_t); 258 259 public: 260 static Local
New(Local
array_buffer, 261 size_t byte_offset, size_t length); 262 static Local
New(Local
shared_array_buffer, 263 size_t byte_offset, size_t length); 264 V8_INLINE static Float16Array* Cast(Value* value) { 265 #ifdef V8_ENABLE_CHECKS 266 CheckCast(value); 267 #endif 268 return static_cast
(value); 269 } 270 271 private: 272 Float16Array(); 273 static void CheckCast(Value* obj); 274 }; 275 276 /** 277 * An instance of Float32Array constructor (ES6 draft 15.13.6). 278 */ 279 class V8_EXPORT Float32Array : public TypedArray { 280 public: 281 /* 282 * The largest Float32Array size that can be constructed using New. 283 */ 284 static constexpr size_t kMaxLength = 285 TypedArray::kMaxByteLength / sizeof(float); 286 static_assert(sizeof(float) == 4); 287 288 static Local
New(Local
array_buffer, 289 size_t byte_offset, size_t length); 290 static Local
New(Local
shared_array_buffer, 291 size_t byte_offset, size_t length); 292 V8_INLINE static Float32Array* Cast(Value* value) { 293 #ifdef V8_ENABLE_CHECKS 294 CheckCast(value); 295 #endif 296 return static_cast
(value); 297 } 298 299 private: 300 Float32Array(); 301 static void CheckCast(Value* obj); 302 }; 303 304 /** 305 * An instance of Float64Array constructor (ES6 draft 15.13.6). 306 */ 307 class V8_EXPORT Float64Array : public TypedArray { 308 public: 309 /* 310 * The largest Float64Array size that can be constructed using New. 311 */ 312 static constexpr size_t kMaxLength = 313 TypedArray::kMaxByteLength / sizeof(double); 314 static_assert(sizeof(double) == 8); 315 316 static Local
New(Local
array_buffer, 317 size_t byte_offset, size_t length); 318 static Local
New(Local
shared_array_buffer, 319 size_t byte_offset, size_t length); 320 V8_INLINE static Float64Array* Cast(Value* value) { 321 #ifdef V8_ENABLE_CHECKS 322 CheckCast(value); 323 #endif 324 return static_cast
(value); 325 } 326 327 private: 328 Float64Array(); 329 static void CheckCast(Value* obj); 330 }; 331 332 /** 333 * An instance of BigInt64Array constructor. 334 */ 335 class V8_EXPORT BigInt64Array : public TypedArray { 336 public: 337 /* 338 * The largest BigInt64Array size that can be constructed using New. 339 */ 340 static constexpr size_t kMaxLength = 341 TypedArray::kMaxByteLength / sizeof(int64_t); 342 static_assert(sizeof(int64_t) == 8); 343 344 static Local
New(Local
array_buffer, 345 size_t byte_offset, size_t length); 346 static Local
New(Local
shared_array_buffer, 347 size_t byte_offset, size_t length); 348 V8_INLINE static BigInt64Array* Cast(Value* value) { 349 #ifdef V8_ENABLE_CHECKS 350 CheckCast(value); 351 #endif 352 return static_cast
(value); 353 } 354 355 private: 356 BigInt64Array(); 357 static void CheckCast(Value* obj); 358 }; 359 360 /** 361 * An instance of BigUint64Array constructor. 362 */ 363 class V8_EXPORT BigUint64Array : public TypedArray { 364 public: 365 /* 366 * The largest BigUint64Array size that can be constructed using New. 367 */ 368 static constexpr size_t kMaxLength = 369 TypedArray::kMaxByteLength / sizeof(uint64_t); 370 static_assert(sizeof(uint64_t) == 8); 371 372 static Local
New(Local
array_buffer, 373 size_t byte_offset, size_t length); 374 static Local
New(Local
shared_array_buffer, 375 size_t byte_offset, size_t length); 376 V8_INLINE static BigUint64Array* Cast(Value* value) { 377 #ifdef V8_ENABLE_CHECKS 378 CheckCast(value); 379 #endif 380 return static_cast
(value); 381 } 382 383 private: 384 BigUint64Array(); 385 static void CheckCast(Value* obj); 386 }; 387 388 } // namespace v8 389 390 #endif // INCLUDE_V8_TYPED_ARRAY_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™