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

Unified Diff: include/v8.h

Issue 391068: Add Blob API
Patch Set: Created 11 years, 1 month 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 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]));
}
« 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