Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1555)

Unified Diff: include/v8.h

Issue 17155014: API for DataView. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« 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 ae35e9f28db7771165b2b06dde1088d7ad270bf7..82585f50c930a6565876f171772cfcf0d387c3b7 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1362,6 +1362,12 @@ class V8EXPORT Value : public Data {
bool IsArrayBuffer() const;
/**
+ * Returns true if this value is an ArrayBufferView.
+ * This is an experimental feature.
+ */
+ bool IsArrayBufferView() const;
+
+ /**
* Returns true if this value is one of TypedArrays.
* This is an experimental feature.
*/
@@ -1421,6 +1427,12 @@ class V8EXPORT Value : public Data {
*/
bool IsFloat64Array() const;
+ /**
+ * Returns true if this value is a DataView.
+ * This is an experimental feature.
+ */
+ bool IsDataView() const;
+
Local<Boolean> ToBoolean() const;
Local<Number> ToNumber() const;
Local<String> ToString() const;
@@ -2459,33 +2471,51 @@ class V8EXPORT ArrayBuffer : public Object {
/**
- * A base class for an instance of TypedArray series of constructors
- * (ES6 draft 15.13.6).
+ * A base class for an instance of one of "views" over ArrayBuffer,
+ * including TypedArrays and DataView (ES6 draft 15.13).
+ *
* This API is experimental and may change significantly.
*/
-class V8EXPORT TypedArray : public Object {
+class V8EXPORT ArrayBufferView : public Object {
public:
/**
* Returns underlying ArrayBuffer.
*/
Local<ArrayBuffer> Buffer();
/**
- * Byte offset in |Buffer|
+ * Byte offset in |Buffer|.
*/
size_t ByteOffset();
/**
- * Numbe of elements in this typed array.
- */
- size_t Length();
- /**
- * Size of typed array in bytes (e.g. for Int16Array, 2*|Length|).
+ * Size of a view in bytes.
*/
size_t ByteLength();
/**
- * Base address of typed array.
+ * Base address of a view.
*/
void* BaseAddress();
+ V8_INLINE(static ArrayBufferView* Cast(Value* obj));
+
+ private:
+ ArrayBufferView();
+ static void CheckCast(Value* obj);
+};
+
+
+/**
+ * A base class for an instance of TypedArray series of constructors
+ * (ES6 draft 15.13.6).
+ * This API is experimental and may change significantly.
+ */
+class V8EXPORT TypedArray : public ArrayBufferView {
+ public:
+ /**
+ * Number of elements in this typed array
+ * (e.g. for Int16Array, |ByteLength|/2).
+ */
+ size_t Length();
+
V8_INLINE(static TypedArray* Cast(Value* obj));
private:
@@ -2638,6 +2668,22 @@ class V8EXPORT Float64Array : public TypedArray {
/**
+ * An instance of DataView constructor (ES6 draft 15.13.7).
+ * This API is experimental and may change significantly.
+ */
+class V8EXPORT DataView : public ArrayBufferView {
+ public:
+ static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
+ size_t byte_offset, size_t length);
+ V8_INLINE(static DataView* Cast(Value* obj));
+
+ private:
+ DataView();
+ static void CheckCast(Value* obj);
+};
+
+
+/**
* An instance of the built-in Date constructor (ECMA-262, 15.9).
*/
class V8EXPORT Date : public Object {
@@ -6163,6 +6209,14 @@ ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
}
+ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<ArrayBufferView*>(value);
+}
+
+
TypedArray* TypedArray::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
@@ -6243,6 +6297,14 @@ Uint8ClampedArray* Uint8ClampedArray::Cast(v8::Value* value) {
}
+DataView* DataView::Cast(v8::Value* value) {
+#ifdef V8_ENABLE_CHECKS
+ CheckCast(value);
+#endif
+ return static_cast<DataView*>(value);
+}
+
+
Function* Function::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
« no previous file with comments | « no previous file | src/api.h » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698