Reviewers: dcarney, Michael Starzinger, yurys,
Description:
Expose v8::Function::IsBuiltin to public API.
BUG=chromium:261470
R=yurys,[email protected],[email protected]
Please review this at https://codereview.chromium.org/27701002/
SVN Base: git://github.com/v8/v8.git@master
Affected files (+28, -0 lines):
M include/v8.h
M src/api.cc
M test/cctest/test-api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
61aadc63a93df93c20275cf46580719bb9fef61f..77684bf7909cb48762f8747f38a8a73c2323d3c7
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2490,6 +2490,11 @@ class V8_EXPORT Function : public Object {
int GetScriptColumnNumber() const;
/**
+ * Tells whether this function is builtin.
+ */
+ bool IsBuiltin() const;
+
+ /**
* Returns scriptId object.
*/
V8_DEPRECATED("Use ScriptId instead", Handle<Value> GetScriptId()) const;
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
e498b438b09f028e0104863bd829980d6b952423..c2c7dcb0cafecbd66d8d0e17426344e2f0ab27a0
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4150,6 +4150,12 @@ int Function::GetScriptColumnNumber() const {
}
+bool Function::IsBuiltin() const {
+ i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
+ return func->IsBuiltin();
+}
+
+
Handle<Value> Function::GetScriptId() const {
i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
i::Isolate* isolate = func->GetIsolate();
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
6e955bd9787b7e4f58149dbadb72cd02c1f0aebd..38ca9f59adf0c5480578368f89c406b486282244
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -17537,6 +17537,23 @@ THREADED_TEST(ScriptColumnNumber) {
}
+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) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
--
--
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.