Chromium Code Reviews

Unified Diff: include/v8.h

Issue 13958007: First cut at API for ES6 ArrayBuffers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added delete[] Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | src/api.h » ('j') | src/api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 8efb7c33c532f714277680ab503f4025fe233d80..99b88a88f07caa84defb79d02e4da8125e6d6bcf 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1969,6 +1969,41 @@ class V8EXPORT Function : public Object {
static void CheckCast(Value* obj);
};
rossberg 2013/04/25 11:00:55 Style: add empty line
Dmitry Lomov (no reviews) 2013/04/25 11:48:01 Done.
+/**
+ * An instance of the built-in ArrayBuffer construnctor (ES6 draft 15.13.5).
rossberg 2013/04/25 11:00:55 Add a comment that this is still "experimental".
Dmitry Lomov (no reviews) 2013/04/25 11:48:01 Done.
+ */
+class V8EXPORT ArrayBuffer : public Object {
+ public:
+ /**
+ * Data length in bytes.
+ */
+ size_t ByteLength() const;
+ /**
+ * Raw pointer to the array buffer data
+ */
+ void* Data() const;
+
+ /**
+ * Create a new ArrayBuffer. Allocate |byte_length| bytes.
+ * Allocated memory will be owned by a created ArrayBuffer and
+ * will be deallocated when it is garbage-collected.
+ */
+ static Local<ArrayBuffer> New(size_t byte_length);
+
+ /**
+ * Create a new ArrayBuffer over existing memory block.
rossberg 2013/04/25 11:00:55 Nit: "over an existing..."
Dmitry Lomov (no reviews) 2013/04/25 11:48:01 Done.
+ * The memory block will not be reclaimed when a created ArrayBuffer
+ * is garbage-collected.
+ */
+ static Local<ArrayBuffer> New(void* data, size_t byte_length);
+
+ V8_INLINE(static ArrayBuffer* Cast(Value* obj));
+
+ private:
+ ArrayBuffer();
+ static void CheckCast(Value* obj);
+};
+
/**
* An instance of the built-in Date constructor (ECMA-262, 15.9).
@@ -4429,7 +4464,7 @@ class Internals {
static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize;
- static const int kContextEmbedderDataIndex = 55;
+ static const int kContextEmbedderDataIndex = 56;
static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02;
@@ -5101,6 +5136,13 @@ Array* Array::Cast(v8::Value* value) {
return static_cast<Array*>(value);
}
rossberg 2013/04/25 11:00:55 STyle: add empty line
Dmitry Lomov (no reviews) 2013/04/25 11:48:01 Done.
+ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<ArrayBuffer*>(value);
+}
+
Function* Function::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
« no previous file with comments | « no previous file | src/api.h » ('j') | src/api.cc » ('J')

Powered by Google App Engine