Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 78b46136fd252b2734bdd538fb70a883e1485b72..b64c67943faef7fac5fb44ab021b9241bd817d0f 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -113,6 +113,7 @@ class Array; |
class Int32; |
class Uint32; |
class External; |
+class Blob; |
class Primitive; |
class Boolean; |
class Integer; |
@@ -724,6 +725,11 @@ class V8EXPORT Value : public Data { |
bool IsExternal() const; |
/** |
+ * Returns true if this value is blob. |
+ */ |
+ bool IsBlob() const; |
+ |
+ /** |
* Returns true if this value is a 32-bit signed integer. |
*/ |
bool IsInt32() const; |
@@ -1381,6 +1387,28 @@ class V8EXPORT External : public Value { |
}; |
+/** |
+ * A JavaScript value that wraps a ByteArray. |
+ */ |
+class V8EXPORT Blob : public Value { |
+ public: |
+ // Create a Blob with room for 'length' bytes. |
+ static Local<Blob> New(int length); |
+ static inline Blob* Cast(Value* obj); |
+ |
+ // Read the index'th byte integer |
+ uint8_t GetByte(int index); |
+ // Write the index'th byte |
+ void SetByte(int index, uint8_t value); |
+ // Get access to the raw memory |
+ uint8_t* GetAddress(); |
+ int ByteCount(); |
+ private: |
+ Blob(); |
+ static void CheckCast(v8::Value* obj); |
+}; |
+ |
+ |
// --- T e m p l a t e s --- |
@@ -3177,6 +3205,14 @@ External* External::Cast(v8::Value* value) { |
} |
+Blob* Blob::Cast(v8::Value* value) { |
+#ifdef V8_ENABLE_CHECKS |
+ CheckCast(value); |
+#endif |
+ return static_cast<Blob*>(value); |
+} |
+ |
+ |
Local<Value> AccessorInfo::Data() const { |
return Local<Value>(reinterpret_cast<Value*>(&args_[-3])); |
} |