Revision: 14506
Author:   [email protected]
Date:     Tue Apr 30 11:02:22 2013
Log:      Fix typo

[email protected]

BUG=

Committed: https://code.google.com/p/v8/source/detail?r=14505

Review URL: https://codereview.chromium.org/13993029
http://code.google.com/p/v8/source/detail?r=14506

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Mon Apr 29 04:09:03 2013
+++ /branches/bleeding_edge/include/v8.h        Tue Apr 30 11:02:22 2013
@@ -1108,6 +1108,67 @@
    */
   bool IsRegExp() const;

+
+  /**
+   * Returns true if this value is an ArrayBuffer.
+   * This is an experimental feature.
+   */
+  bool IsArrayBuffer() const;
+
+  /**
+   * Returns true if this value is one of TypedArrays.
+   * This is an experimental feature.
+   */
+  bool IsTypedArray() const;
+
+  /**
+   * Returns true if this value is an Uint8Array.
+   * This is an experimental feature.
+   */
+  bool IsUint8Array() const;
+
+  /**
+   * Returns true if this value is an Int8Array.
+   * This is an experimental feature.
+   */
+  bool IsInt8Array() const;
+
+  /**
+   * Returns true if this value is an Uint16Array.
+   * This is an experimental feature.
+   */
+  bool IsUint16Array() const;
+
+  /**
+   * Returns true if this value is an Int16Array.
+   * This is an experimental feature.
+   */
+  bool IsInt16Array() const;
+
+  /**
+   * Returns true if this value is an Uint32Array.
+   * This is an experimental feature.
+   */
+  bool IsUint32Array() const;
+
+  /**
+   * Returns true if this value is an Int32Array.
+   * This is an experimental feature.
+   */
+  bool IsInt32Array() const;
+
+  /**
+   * Returns true if this value is a Float32Array.
+   * This is an experimental feature.
+   */
+  bool IsFloat32Array() const;
+
+  /**
+   * Returns true if this value is a Float64Array.
+   * This is an experimental feature.
+   */
+  bool IsFloat64Array() const;
+
   Local<Boolean> ToBoolean() const;
   Local<Number> ToNumber() const;
   Local<String> ToString() const;
=======================================
--- /branches/bleeding_edge/src/api.cc  Mon Apr 29 04:09:03 2013
+++ /branches/bleeding_edge/src/api.cc  Tue Apr 30 11:02:22 2013
@@ -2409,6 +2409,45 @@
 }


+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();
+}
+
+
+#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;
   return Utils::OpenHandle(this)->IsJSObject();
@@ -2776,14 +2815,7 @@
   }


-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

=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Tue Apr 30 06:43:45 2013
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Tue Apr 30 11:02:22 2013
@@ -15173,6 +15173,31 @@
   TypedArrayTestHelper<double, v8::Float64Array, i::ExternalDoubleArray>(
       v8::kExternalDoubleArray, -500, 500);
 }
+
+#define IS_TYPED_ARRAY_TEST(TypedArray) \
+ THREADED_TEST(Is##TypedArray) { \ + i::FLAG_harmony_typed_arrays = true; \ + LocalContext env; \ + v8::Isolate* isolate = env->GetIsolate(); \ + v8::HandleScope handle_scope(isolate); \ + \ + Handle<Value> result = CompileRun( \ + "var ab = new ArrayBuffer(128);" \ + "new " #TypedArray "(ab)"); \ + CHECK(result->Is##TypedArray()); \
+  }
+
+IS_TYPED_ARRAY_TEST(Uint8Array)
+IS_TYPED_ARRAY_TEST(Int8Array)
+IS_TYPED_ARRAY_TEST(Uint16Array)
+IS_TYPED_ARRAY_TEST(Int16Array)
+IS_TYPED_ARRAY_TEST(Uint32Array)
+IS_TYPED_ARRAY_TEST(Int32Array)
+IS_TYPED_ARRAY_TEST(Float32Array)
+IS_TYPED_ARRAY_TEST(Float64Array)
+
+#undef IS_TYPED_ARRAY_TEST
+


 THREADED_TEST(ScriptContextDependence) {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to