Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: src/api.cc

Issue 106763002: Get information about original function from bound function (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: GetBoundFunction returns v8::Undefined if this function is not bound + REBASE Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 02b6be4d3b7a4622a423d2232b9620796177afa7..8ccea845a639fb7fd7ecface45b9a3529769d1b4 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4305,6 +4305,20 @@ int Function::ScriptId() const {
}
+Local<v8::Value> Function::GetBoundFunction() const {
+ i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
+ if (!func->shared()->bound()) {
+ return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate()));
+ }
+ i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>(
+ i::FixedArray::cast(func->function_bindings()));
+ i::Handle<i::Object> original(
+ i::JSReceiver::cast(bound_args->get(i::JSFunction::kBoundFunctionIndex)),
+ i::Isolate::Current());
yurys 2013/12/12 20:20:50 func->GetIsolate())
Alexandra Mikhaylova 2013/12/18 10:00:28 Done.
+ return Utils::ToLocal(i::Handle<i::JSFunction>::cast(original));
yurys 2013/12/12 20:20:50 Is it always safe to cast original to JSFunction h
Alexandra Mikhaylova 2013/12/18 10:00:28 I think it is safe because here we are sure that o
+}
+
+
int String::Length() const {
i::Handle<i::String> str = Utils::OpenHandle(this);
return str->length();
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698