Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index c72857da644eedb55f4ce93002f73ef7e20b29bf..ace04135abc6171509494a167847afc6e5b4e05b 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -3262,7 +3262,7 @@ Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, |
return Local<v8::Value>()); |
LOG_API(isolate, "Object::CallAsFunction"); |
ENTER_V8(isolate); |
- HandleScope scope; |
+ 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**)); |
@@ -3282,7 +3282,42 @@ Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, |
i::Handle<i::Object> returned = |
i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
- return scope.Close(Utils::ToLocal(returned)); |
+ return Utils::ToLocal(scope.CloseAndEscape(returned)); |
+} |
+ |
+ |
+Local<v8::Value> Object::CallAsConstructor(int argc, |
+ v8::Handle<v8::Value> argv[]) { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
+ ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", |
+ return Local<v8::Object>()); |
+ LOG_API(isolate, "Object::CallAsConstructor"); |
+ ENTER_V8(isolate); |
+ i::HandleScope scope(isolate); |
+ i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
+ STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
+ i::Object*** args = reinterpret_cast<i::Object***>(argv); |
+ i::Handle<i::Object> returned; |
Mads Ager (chromium)
2011/05/06 10:41:47
I would move these to where they are used. I'll ta
|
+ i::Handle<i::JSFunction> fun; |
+ if (obj->IsJSFunction()) { |
+ EXCEPTION_PREAMBLE(isolate); |
+ fun = i::Handle<i::JSFunction>::cast(obj); |
+ returned = i::Execution::New(fun, argc, args, &has_pending_exception); |
+ EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
+ return Utils::ToLocal(scope.CloseAndEscape( |
+ i::Handle<i::JSObject>::cast(returned))); |
Mads Ager (chromium)
2011/05/06 10:41:47
I would format this differently. I'll take care of
|
+ } |
+ EXCEPTION_PREAMBLE(isolate); |
+ i::Handle<i::Object> delegate = |
+ i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception); |
+ if (!delegate->IsUndefined()) { |
+ fun = i::Handle<i::JSFunction>::cast(delegate); |
+ returned = |
+ i::Execution::Call(fun, obj, argc, args, &has_pending_exception); |
+ } |
+ EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
+ ASSERT(!delegate->IsUndefined()); |
+ return Utils::ToLocal(scope.CloseAndEscape(returned)); |
} |