Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 4352ef3301e2f56a44689bc27459219b8cf1961e..c2ae74f64c73e7bcbfb46b8fb2bab0bd9e51bd0b 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2408,6 +2408,43 @@ bool Value::IsArray() const { |
return Utils::OpenHandle(this)->IsJSArray(); |
} |
rossberg
2013/04/30 13:46:48
Nit: extra line
|
+bool Value::IsArrayBuffer() const { |
+ if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()")) |
+ return false; |
+ return Utils::OpenHandle(this)->IsJSArrayBuffer(); |
+} |
+ |
+ |
+bool Value::IsTypedArray() const { |
+ if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()")) |
+ return false; |
+ return Utils::OpenHandle(this)->IsJSTypedArray(); |
+} |
+ |
rossberg
2013/04/30 13:46:48
Same here
|
+#define TYPED_ARRAY_LIST(F) \ |
+F(Uint8Array, kExternalUnsignedByteArray) \ |
+F(Int8Array, kExternalByteArray) \ |
+F(Uint16Array, kExternalUnsignedShortArray) \ |
+F(Int16Array, kExternalShortArray) \ |
+F(Uint32Array, kExternalUnsignedIntArray) \ |
+F(Int32Array, kExternalIntArray) \ |
+F(Float32Array, kExternalFloatArray) \ |
+F(Float64Array, kExternalDoubleArray) |
+ |
+ |
+#define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ |
+ bool Value::Is##TypedArray() const { \ |
+ if (IsDeadCheck(i::Isolate::Current(), "v8::Value::Is" #TypedArray "()")) \ |
+ return false; \ |
+ i::Handle<i::Object> obj = Utils::OpenHandle(this); \ |
+ if (!obj->IsJSTypedArray()) return false; \ |
+ return i::JSTypedArray::cast(*obj)->type() == type_const; \ |
+ } |
+ |
+TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) |
+ |
+#undef VALUE_IS_TYPED_ARRAY |
+ |
bool Value::IsObject() const { |
if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false; |
@@ -2776,14 +2813,7 @@ void v8::TypedArray::CheckCast(Value* that) { |
} |
-CHECK_TYPED_ARRAY_CAST(Uint8Array, kExternalUnsignedByteArray) |
-CHECK_TYPED_ARRAY_CAST(Int8Array, kExternalByteArray) |
-CHECK_TYPED_ARRAY_CAST(Uint16Array, kExternalUnsignedShortArray) |
-CHECK_TYPED_ARRAY_CAST(Int16Array, kExternalShortArray) |
-CHECK_TYPED_ARRAY_CAST(Uint32Array, kExternalUnsignedIntArray) |
-CHECK_TYPED_ARRAY_CAST(Int32Array, kExternalIntArray) |
-CHECK_TYPED_ARRAY_CAST(Float32Array, kExternalFloatArray) |
-CHECK_TYPED_ARRAY_CAST(Float64Array, kExternalDoubleArray) |
+TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) |
#undef CHECK_TYPED_ARRAY_CAST |