Revision: 23105
Author:   [email protected]
Date:     Wed Aug 13 13:06:30 2014 UTC
Log:      Expose Value::IsArgumentsObject in V8 API.

[email protected], [email protected], yangguo

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

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        Thu Aug  7 08:55:49 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Wed Aug 13 13:06:30 2014 UTC
@@ -1423,6 +1423,11 @@
    */
   bool IsDate() const;

+  /**
+   * Returns true if this value is an Arguments object.
+   */
+  bool IsArgumentsObject() const;
+
   /**
    * Returns true if this value is a Boolean object.
    */
=======================================
--- /branches/bleeding_edge/src/api.cc  Tue Aug 12 13:33:35 2014 UTC
+++ /branches/bleeding_edge/src/api.cc  Wed Aug 13 13:06:30 2014 UTC
@@ -2381,6 +2381,14 @@
 bool Value::IsNumber() const {
   return Utils::OpenHandle(this)->IsNumber();
 }
+
+
+bool Value::IsArgumentsObject() const {
+  i::Handle<i::Object> obj = Utils::OpenHandle(this);
+  if (!obj->IsHeapObject()) return false;
+  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
+  return obj->HasSpecificClassOf(isolate->heap()->Arguments_string());
+}


 bool Value::IsBoolean() const {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Tue Aug 12 13:33:35 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Wed Aug 13 13:06:30 2014 UTC
@@ -1539,6 +1539,19 @@
   v8::Handle<Value> not_object = CompileRun("42");
   CHECK(!not_object->IsNativeError());
 }
+
+
+THREADED_TEST(ArgumentsObject) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+  v8::Handle<Value> arguments_object =
+ CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;");
+  CHECK(arguments_object->IsArgumentsObject());
+  v8::Handle<Value> array = CompileRun("[1,2,3]");
+  CHECK(!array->IsArgumentsObject());
+  v8::Handle<Value> object = CompileRun("{a:42}");
+  CHECK(!object->IsArgumentsObject());
+}


 THREADED_TEST(StringObject) {

--
--
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/d/optout.

Reply via email to