Revision: 17323
Author:   [email protected]
Date:     Tue Oct 22 14:50:20 2013 UTC
Log:      Expose v8::Function::IsBuiltin to public API.

This will be used by DevTools so that we could generate a better preview in console. Namely, we could assume that a preview of an object is lossless if all its member functions are builtin.

We also may want to expose this to DevTools users via remote debugging protocol in Debugger.FunctionDetails struct.

BUG=chromium:261470
[email protected], [email protected], [email protected], yurys

Review URL: https://codereview.chromium.org/27701002

Patch from Andrey Adaikin <[email protected]>.
http://code.google.com/p/v8/source/detail?r=17323

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 Oct 17 11:48:03 2013 UTC
+++ /branches/bleeding_edge/include/v8.h        Tue Oct 22 14:50:20 2013 UTC
@@ -2489,6 +2489,11 @@
    */
   int GetScriptColumnNumber() const;

+  /**
+   * Tells whether this function is builtin.
+   */
+  bool IsBuiltin() const;
+
   /**
    * Returns scriptId object.
    */
=======================================
--- /branches/bleeding_edge/src/api.cc  Fri Oct 18 12:52:07 2013 UTC
+++ /branches/bleeding_edge/src/api.cc  Tue Oct 22 14:50:20 2013 UTC
@@ -4146,6 +4146,12 @@
   }
   return kLineOffsetNotFound;
 }
+
+
+bool Function::IsBuiltin() const {
+  i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
+  return func->IsBuiltin();
+}


 Handle<Value> Function::GetScriptId() const {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Thu Oct 17 11:48:03 2013 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Tue Oct 22 14:50:20 2013 UTC
@@ -17535,6 +17535,23 @@
   CHECK_EQ(14, foo->GetScriptColumnNumber());
   CHECK_EQ(17, bar->GetScriptColumnNumber());
 }
+
+
+THREADED_TEST(FunctionIsBuiltin) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+  v8::Local<v8::Function> f;
+  f = v8::Local<v8::Function>::Cast(CompileRun("Math.floor"));
+  CHECK(f->IsBuiltin());
+  f = v8::Local<v8::Function>::Cast(CompileRun("Object"));
+  CHECK(f->IsBuiltin());
+  f = v8::Local<v8::Function>::Cast(CompileRun("Object.__defineSetter__"));
+  CHECK(f->IsBuiltin());
+ f = v8::Local<v8::Function>::Cast(CompileRun("Array.prototype.toString"));
+  CHECK(f->IsBuiltin());
+  f = v8::Local<v8::Function>::Cast(CompileRun("function a() {}; a;"));
+  CHECK(!f->IsBuiltin());
+}


 THREADED_TEST(FunctionGetScriptId) {

--
--
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