Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 bool IsRegExp() const; | 1344 bool IsRegExp() const; |
| 1345 | 1345 |
| 1346 | 1346 |
| 1347 /** | 1347 /** |
| 1348 * Returns true if this value is an ArrayBuffer. | 1348 * Returns true if this value is an ArrayBuffer. |
| 1349 * This is an experimental feature. | 1349 * This is an experimental feature. |
| 1350 */ | 1350 */ |
| 1351 bool IsArrayBuffer() const; | 1351 bool IsArrayBuffer() const; |
| 1352 | 1352 |
| 1353 /** | 1353 /** |
| 1354 * Returns true if this value is a DataView. | |
| 1355 * This is an experimental feature. | |
| 1356 */ | |
| 1357 bool IsDataView() const; | |
| 1358 | |
| 1359 /** | |
| 1354 * Returns true if this value is one of TypedArrays. | 1360 * Returns true if this value is one of TypedArrays. |
| 1355 * This is an experimental feature. | 1361 * This is an experimental feature. |
| 1356 */ | 1362 */ |
| 1357 bool IsTypedArray() const; | 1363 bool IsTypedArray() const; |
| 1358 | 1364 |
| 1359 /** | 1365 /** |
| 1360 * Returns true if this value is an Uint8Array. | 1366 * Returns true if this value is an Uint8Array. |
| 1361 * This is an experimental feature. | 1367 * This is an experimental feature. |
| 1362 */ | 1368 */ |
| 1363 bool IsUint8Array() const; | 1369 bool IsUint8Array() const; |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2397 | 2403 |
| 2398 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; | 2404 static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; |
| 2399 | 2405 |
| 2400 private: | 2406 private: |
| 2401 ArrayBuffer(); | 2407 ArrayBuffer(); |
| 2402 static void CheckCast(Value* obj); | 2408 static void CheckCast(Value* obj); |
| 2403 }; | 2409 }; |
| 2404 | 2410 |
| 2405 | 2411 |
| 2406 /** | 2412 /** |
| 2413 * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). | |
| 2414 * This API is experimental and may change significantly. | |
| 2415 */ | |
| 2416 class V8EXPORT DataView : public Object { | |
| 2417 public: | |
| 2418 /** | |
| 2419 * Returns underlying ArrayBuffer. | |
| 2420 */ | |
| 2421 Local<ArrayBuffer> Buffer(); | |
| 2422 | |
| 2423 /** | |
| 2424 * Byte offset in |Buffer| | |
| 2425 */ | |
| 2426 size_t ByteOffset() const; | |
| 2427 | |
| 2428 /** | |
| 2429 * Size of data view in bytes. | |
| 2430 */ | |
| 2431 size_t ByteLength() const; | |
| 2432 | |
| 2433 /** | |
| 2434 * Raw pointer to the buffer view data. | |
| 2435 */ | |
| 2436 void* Data() const; | |
| 2437 | |
| 2438 static Local<DataView> New(Handle<ArrayBuffer> array_buffer, | |
| 2439 size_t byte_offset, | |
| 2440 size_t byte_length); | |
| 2441 V8_INLINE(static DataView* Cast(Value* obj)); | |
| 2442 | |
| 2443 /** | |
| 2444 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2445 */ | |
| 2446 int8_t GetInt8(size_t byte_offset) const; | |
| 2447 | |
| 2448 /** | |
| 2449 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2450 */ | |
| 2451 uint8_t GetUint8(size_t byte_offset) const; | |
|
bnoordhuis
2013/05/23 22:59:04
I'd be okay with removing these. I added them for
| |
| 2452 | |
| 2453 /** | |
| 2454 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2455 */ | |
| 2456 int16_t GetInt16(size_t byte_offset, bool little_endian = false) const; | |
| 2457 | |
| 2458 /** | |
| 2459 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2460 * Reads a big-endian value unless |little_endian| is true. | |
| 2461 */ | |
| 2462 uint16_t GetUint16(size_t byte_offset, bool little_endian = false) const; | |
| 2463 | |
| 2464 /** | |
| 2465 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2466 * Reads a big-endian value unless |little_endian| is true. | |
| 2467 */ | |
| 2468 int32_t GetInt32(size_t byte_offset, bool little_endian = false) const; | |
| 2469 | |
| 2470 /** | |
| 2471 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2472 * Reads a big-endian value unless |little_endian| is true. | |
| 2473 */ | |
| 2474 uint32_t GetUint32(size_t byte_offset, bool little_endian = false) const; | |
| 2475 | |
| 2476 /** | |
| 2477 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2478 * Reads a big-endian value unless |little_endian| is true. | |
| 2479 */ | |
| 2480 float GetFloat32(size_t byte_offset, bool little_endian = false) const; | |
| 2481 | |
| 2482 /** | |
| 2483 * Return the value at |byte_offset| or 0 if |byte_offset| is out of range. | |
| 2484 * Reads a big-endian value unless |little_endian| is true. | |
| 2485 */ | |
| 2486 double GetFloat64(size_t byte_offset, bool little_endian = false) const; | |
| 2487 | |
| 2488 /** | |
| 2489 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2490 * is out of range. | |
| 2491 */ | |
| 2492 void SetInt8(size_t byte_offset, int8_t value); | |
| 2493 | |
| 2494 /** | |
| 2495 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2496 * is out of range. | |
| 2497 */ | |
| 2498 void SetUint8(size_t byte_offset, uint8_t value); | |
| 2499 | |
| 2500 /** | |
| 2501 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2502 * is out of range. Writes a big-endian value unless |little_endian| is true. | |
| 2503 */ | |
| 2504 void SetInt16(size_t byte_offset, int16_t value, bool little_endian = false); | |
| 2505 | |
| 2506 /** | |
| 2507 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2508 * is out of range. | |
| 2509 */ | |
| 2510 void SetUint16(size_t byte_offset, | |
| 2511 uint16_t value, | |
| 2512 bool little_endian = false); | |
| 2513 | |
| 2514 /** | |
| 2515 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2516 * is out of range. Writes a big-endian value unless |little_endian| is true. | |
| 2517 */ | |
| 2518 void SetInt32(size_t byte_offset, int32_t value, bool little_endian = false); | |
| 2519 | |
| 2520 /** | |
| 2521 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2522 * is out of range. Writes a big-endian value unless |little_endian| is true. | |
| 2523 */ | |
| 2524 void SetUint32(size_t byte_offset, | |
| 2525 uint32_t value, | |
| 2526 bool little_endian = false); | |
| 2527 | |
| 2528 /** | |
| 2529 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2530 * is out of range. Writes a big-endian value unless |little_endian| is true. | |
| 2531 */ | |
| 2532 void SetFloat32(size_t byte_offset, float value, bool little_endian = false); | |
| 2533 | |
| 2534 /** | |
| 2535 * Set the value at |byte_offset| to |value|. Does nothing if |byte_offset| | |
| 2536 * is out of range. Writes a big-endian value unless |little_endian| is true. | |
| 2537 */ | |
| 2538 void SetFloat64(size_t byte_offset, double value, bool little_endian = false); | |
| 2539 | |
| 2540 private: | |
| 2541 DataView(); | |
| 2542 static void CheckCast(Value* obj); | |
| 2543 }; | |
| 2544 | |
| 2545 | |
| 2546 /** | |
| 2407 * A base class for an instance of TypedArray series of constructors | 2547 * A base class for an instance of TypedArray series of constructors |
| 2408 * (ES6 draft 15.13.6). | 2548 * (ES6 draft 15.13.6). |
| 2409 * This API is experimental and may change significantly. | 2549 * This API is experimental and may change significantly. |
| 2410 */ | 2550 */ |
| 2411 class V8EXPORT TypedArray : public Object { | 2551 class V8EXPORT TypedArray : public Object { |
| 2412 public: | 2552 public: |
| 2413 /** | 2553 /** |
| 2414 * Returns underlying ArrayBuffer. | 2554 * Returns underlying ArrayBuffer. |
| 2415 */ | 2555 */ |
| 2416 Local<ArrayBuffer> Buffer(); | 2556 Local<ArrayBuffer> Buffer(); |
| (...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5250 // the implementation of v8. | 5390 // the implementation of v8. |
| 5251 static const int kHeapObjectMapOffset = 0; | 5391 static const int kHeapObjectMapOffset = 0; |
| 5252 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; | 5392 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; |
| 5253 static const int kStringResourceOffset = 3 * kApiPointerSize; | 5393 static const int kStringResourceOffset = 3 * kApiPointerSize; |
| 5254 | 5394 |
| 5255 static const int kOddballKindOffset = 3 * kApiPointerSize; | 5395 static const int kOddballKindOffset = 3 * kApiPointerSize; |
| 5256 static const int kForeignAddressOffset = kApiPointerSize; | 5396 static const int kForeignAddressOffset = kApiPointerSize; |
| 5257 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 5397 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
| 5258 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; | 5398 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; |
| 5259 static const int kContextHeaderSize = 2 * kApiPointerSize; | 5399 static const int kContextHeaderSize = 2 * kApiPointerSize; |
| 5260 static const int kContextEmbedderDataIndex = 64; | 5400 static const int kContextEmbedderDataIndex = 65; |
| 5261 static const int kFullStringRepresentationMask = 0x07; | 5401 static const int kFullStringRepresentationMask = 0x07; |
| 5262 static const int kStringEncodingMask = 0x4; | 5402 static const int kStringEncodingMask = 0x4; |
| 5263 static const int kExternalTwoByteRepresentationTag = 0x02; | 5403 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 5264 static const int kExternalAsciiRepresentationTag = 0x06; | 5404 static const int kExternalAsciiRepresentationTag = 0x06; |
| 5265 | 5405 |
| 5266 static const int kIsolateStateOffset = 0; | 5406 static const int kIsolateStateOffset = 0; |
| 5267 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; | 5407 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; |
| 5268 static const int kIsolateRootsOffset = 3 * kApiPointerSize; | 5408 static const int kIsolateRootsOffset = 3 * kApiPointerSize; |
| 5269 static const int kUndefinedValueRootIndex = 5; | 5409 static const int kUndefinedValueRootIndex = 5; |
| 5270 static const int kNullValueRootIndex = 7; | 5410 static const int kNullValueRootIndex = 7; |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6116 | 6256 |
| 6117 | 6257 |
| 6118 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { | 6258 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { |
| 6119 #ifdef V8_ENABLE_CHECKS | 6259 #ifdef V8_ENABLE_CHECKS |
| 6120 CheckCast(value); | 6260 CheckCast(value); |
| 6121 #endif | 6261 #endif |
| 6122 return static_cast<ArrayBuffer*>(value); | 6262 return static_cast<ArrayBuffer*>(value); |
| 6123 } | 6263 } |
| 6124 | 6264 |
| 6125 | 6265 |
| 6266 DataView* DataView::Cast(v8::Value* value) { | |
| 6267 #ifdef V8_ENABLE_CHECKS | |
| 6268 CheckCast(value); | |
| 6269 #endif | |
| 6270 return static_cast<DataView*>(value); | |
| 6271 } | |
| 6272 | |
| 6273 | |
| 6126 TypedArray* TypedArray::Cast(v8::Value* value) { | 6274 TypedArray* TypedArray::Cast(v8::Value* value) { |
| 6127 #ifdef V8_ENABLE_CHECKS | 6275 #ifdef V8_ENABLE_CHECKS |
| 6128 CheckCast(value); | 6276 CheckCast(value); |
| 6129 #endif | 6277 #endif |
| 6130 return static_cast<TypedArray*>(value); | 6278 return static_cast<TypedArray*>(value); |
| 6131 } | 6279 } |
| 6132 | 6280 |
| 6133 | 6281 |
| 6134 Uint8Array* Uint8Array::Cast(v8::Value* value) { | 6282 Uint8Array* Uint8Array::Cast(v8::Value* value) { |
| 6135 #ifdef V8_ENABLE_CHECKS | 6283 #ifdef V8_ENABLE_CHECKS |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6324 | 6472 |
| 6325 | 6473 |
| 6326 } // namespace v8 | 6474 } // namespace v8 |
| 6327 | 6475 |
| 6328 | 6476 |
| 6329 #undef V8EXPORT | 6477 #undef V8EXPORT |
| 6330 #undef TYPE_CHECK | 6478 #undef TYPE_CHECK |
| 6331 | 6479 |
| 6332 | 6480 |
| 6333 #endif // V8_H_ | 6481 #endif // V8_H_ |
| OLD | NEW |