Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 00b590f3ebf0dc92d4e659a421afc88256114246..8756c0beda039e329544b58606a631192b7220ad 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -1516,6 +1516,12 @@ bool Value::IsExternal() const { |
} |
+bool Value::IsBlob() const { |
+ if (IsDeadCheck("v8::Value::IsBlob()")) return false; |
+ return Utils::OpenHandle(this)->IsByteArray(); |
+} |
+ |
+ |
bool Value::IsInt32() const { |
if (IsDeadCheck("v8::Value::IsInt32()")) return false; |
i::Handle<i::Object> obj = Utils::OpenHandle(this); |
@@ -1643,6 +1649,15 @@ void External::CheckCast(v8::Value* that) { |
} |
+void Blob::CheckCast(v8::Value* that) { |
+ if (IsDeadCheck("v8::Blob::Cast()")) return; |
+ i::Handle<i::Object> obj = Utils::OpenHandle(that); |
+ ApiCheck(obj->IsByteArray(), |
+ "v8::Blob::Cast()", |
+ "Could not convert to external"); |
Christian Plesner Hansen
2009/11/16 12:12:22
I expect you mean "...to blob".
|
+} |
+ |
+ |
void v8::Object::CheckCast(Value* that) { |
if (IsDeadCheck("v8::Object::Cast()")) return; |
i::Handle<i::Object> obj = Utils::OpenHandle(that); |
@@ -2954,6 +2969,42 @@ void* External::Value() const { |
} |
+Local<Blob> v8::Blob::New(int length) { |
+ LOG_API("Blob::New"); |
+ EnsureInitialized("v8::Blob::New()"); |
+ ENTER_V8; |
+ return Utils::ToLocal(i::Factory::NewByteArray(length)); |
+} |
+ |
+ |
+int Blob::ByteCount() { |
+ if (IsDeadCheck("v8::Blob::ByteCount()")) return 0; |
+ i::Handle<i::Object> obj = Utils::OpenHandle(this); |
Christian Plesner Hansen
2009/11/16 12:12:22
Doesn't OpenHandle give you back a ByteArray that
|
+ return i::ByteArray::cast(*obj)->length(); |
+} |
+ |
+ |
+uint8_t Blob::GetByte(int index) { |
+ if (IsDeadCheck("v8::Blob::GetByte()")) return 0; |
+ i::Handle<i::Object> obj = Utils::OpenHandle(this); |
+ return i::ByteArray::cast(*obj)->get(index); |
+} |
+ |
+ |
+void Blob::SetByte(int index, uint8_t value) { |
+ if (IsDeadCheck("v8::Blob::SetByte()")) return; |
+ i::Handle<i::Object> obj = Utils::OpenHandle(this); |
+ i::ByteArray::cast(*obj)->set(index, value); |
+} |
+ |
+ |
+uint8_t* Blob::GetAddress() { |
+ if (IsDeadCheck("v8::Blob::GetAddress()")) return NULL; |
+ i::Handle<i::Object> obj = Utils::OpenHandle(this); |
+ return i::ByteArray::cast(*obj)->GetDataStartAddress(); |
Christian Plesner Hansen
2009/11/16 12:12:22
Danger danger! This will give you a derived point
|
+} |
+ |
+ |
Local<String> v8::String::Empty() { |
EnsureInitialized("v8::String::Empty()"); |
LOG_API("String::Empty()"); |