| 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 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 * returns an instance of this class, populated, with a pointer to data | 2762 * returns an instance of this class, populated, with a pointer to data |
| 2763 * and byte length. | 2763 * and byte length. |
| 2764 * | 2764 * |
| 2765 * The Data pointer of ArrayBuffer::Contents is always allocated with | 2765 * The Data pointer of ArrayBuffer::Contents is always allocated with |
| 2766 * Allocator::Allocate that is set with V8::SetArrayBufferAllocator. | 2766 * Allocator::Allocate that is set with V8::SetArrayBufferAllocator. |
| 2767 * | 2767 * |
| 2768 * This API is experimental and may change significantly. | 2768 * This API is experimental and may change significantly. |
| 2769 */ | 2769 */ |
| 2770 class V8_EXPORT Contents { // NOLINT | 2770 class V8_EXPORT Contents { // NOLINT |
| 2771 public: | 2771 public: |
| 2772 Contents() : data_(NULL), byte_length_(0) {} | 2772 Contents() : data_(NULL), byte_length_(0), shared_(false) {} |
| 2773 | 2773 |
| 2774 void* Data() const { return data_; } | 2774 void* Data() const { return data_; } |
| 2775 size_t ByteLength() const { return byte_length_; } | 2775 size_t ByteLength() const { return byte_length_; } |
| 2776 bool Shared() const { return shared_; } |
| 2776 | 2777 |
| 2777 private: | 2778 private: |
| 2778 void* data_; | 2779 void* data_; |
| 2779 size_t byte_length_; | 2780 size_t byte_length_; |
| 2781 bool shared_; |
| 2780 | 2782 |
| 2781 friend class ArrayBuffer; | 2783 friend class ArrayBuffer; |
| 2782 }; | 2784 }; |
| 2783 | 2785 |
| 2784 | 2786 |
| 2785 /** | 2787 /** |
| 2786 * Data length in bytes. | 2788 * Data length in bytes. |
| 2787 */ | 2789 */ |
| 2788 size_t ByteLength() const; | 2790 size_t ByteLength() const; |
| 2789 | 2791 |
| 2790 /** | 2792 /** |
| 2791 * Create a new ArrayBuffer. Allocate |byte_length| bytes. | 2793 * Create a new ArrayBuffer. Allocate |byte_length| bytes. |
| 2792 * Allocated memory will be owned by a created ArrayBuffer and | 2794 * Allocated memory will be owned by a created ArrayBuffer and |
| 2793 * will be deallocated when it is garbage-collected, | 2795 * will be deallocated when it is garbage-collected, |
| 2794 * unless the object is externalized. | 2796 * unless the object is externalized. |
| 2795 */ | 2797 */ |
| 2796 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); | 2798 static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); |
| 2797 | 2799 |
| 2798 /** | 2800 /** |
| 2799 * Create a new ArrayBuffer over an existing memory block. | 2801 * Create a new ArrayBuffer over an existing memory block. |
| 2800 * The created array buffer is immediately in externalized state. | 2802 * The created array buffer is immediately in externalized state. |
| 2801 * The memory block will not be reclaimed when a created ArrayBuffer | 2803 * The memory block will not be reclaimed when a created ArrayBuffer |
| 2802 * is garbage-collected. | 2804 * is garbage-collected. |
| 2803 */ | 2805 */ |
| 2804 static Local<ArrayBuffer> New(Isolate* isolate, void* data, | 2806 static Local<ArrayBuffer> New(Isolate* isolate, void* data, |
| 2805 size_t byte_length); | 2807 size_t byte_length, bool shared = false); |
| 2806 | 2808 |
| 2807 /** | 2809 /** |
| 2808 * Returns true if ArrayBuffer is extrenalized, that is, does not | 2810 * Returns true if ArrayBuffer is extrenalized, that is, does not |
| 2809 * own its memory block. | 2811 * own its memory block. |
| 2810 */ | 2812 */ |
| 2811 bool IsExternal() const; | 2813 bool IsExternal() const; |
| 2812 | 2814 |
| 2813 /** | 2815 /** |
| 2814 * Neuters this ArrayBuffer and all its views (typed arrays). | 2816 * Neuters this ArrayBuffer and all its views (typed arrays). |
| 2815 * Neutering sets the byte length of the buffer and all typed arrays to zero, | 2817 * Neutering sets the byte length of the buffer and all typed arrays to zero, |
| (...skipping 3870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6686 */ | 6688 */ |
| 6687 | 6689 |
| 6688 | 6690 |
| 6689 } // namespace v8 | 6691 } // namespace v8 |
| 6690 | 6692 |
| 6691 | 6693 |
| 6692 #undef TYPE_CHECK | 6694 #undef TYPE_CHECK |
| 6693 | 6695 |
| 6694 | 6696 |
| 6695 #endif // V8_H_ | 6697 #endif // V8_H_ |
| OLD | NEW |