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

Unified Diff: src/api.cc

Issue 6883045: Add CallAsFunction method to the Object class in the API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 months 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 1a521748211bcb72be2c434189b96d0c103dcf79..4a1e22c654e34f8465ebffe4910a46c68e25f457 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3182,6 +3182,38 @@ int v8::Object::GetIndexedPropertiesExternalArrayDataLength() {
}
+Local<v8::Value> Object::Call(v8::Handle<v8::Object> recv, int argc,
+ v8::Handle<v8::Value> argv[]) {
Mads Ager (chromium) 2011/04/28 11:53:05 Indentation is off.
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ ON_BAILOUT(isolate, "v8::Object::Call()", return Local<v8::Value>());
+ LOG_API(isolate, "Object::Call");
+ ENTER_V8(isolate);
+ i::Object* raw_result = NULL;
+ {
+ i::HandleScope scope(isolate);
+ i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
+ i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
+ STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
+ i::Object*** args = reinterpret_cast<i::Object***>(argv);
+ i::Handle<i::JSFunction> fun;
+ if (obj->IsJSFunction()) {
+ fun = i::Handle<i::JSFunction>::cast(obj);
+ } else {
+ fun = i::Handle<i::JSFunction>::cast(
+ i::Execution::GetFunctionDelegate(obj));
+ recv_obj = obj;
+ }
+ EXCEPTION_PREAMBLE(isolate);
+ i::Handle<i::Object> returned =
+ i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);
+ EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
+ raw_result = *returned;
Mads Ager (chromium) 2011/04/28 11:53:05 Please use return scope.Close instead. That will g
+ }
+ i::Handle<i::Object> result(raw_result);
+ return Utils::ToLocal(result);
+}
+
+
Local<v8::Object> Function::NewInstance() const {
return NewInstance(0, NULL);
}

Powered by Google App Engine
This is Rietveld 408576698