Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index c72857da644eedb55f4ce93002f73ef7e20b29bf..9b02b20a1d806b9f8e3c196242dab3abb3458c29 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -3286,6 +3286,38 @@ Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, |
| } |
| +Local<v8::Object> Object::CallAsConstructor( |
| + int argc, |
| + v8::Handle<v8::Value> argv[]) const { |
| + 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); |
| + HandleScope scope; |
|
Mads Ager (chromium)
2011/05/05 09:03:33
Use the isolate here.
|
| + 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; |
| + i::Handle<i::JSFunction> fun; |
| + EXCEPTION_PREAMBLE(isolate); |
| + if (obj->IsJSFunction()) { |
| + fun = i::Handle<i::JSFunction>::cast(obj); |
| + returned = i::Execution::New(fun, argc, args, &has_pending_exception); |
| + EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
| + } else { |
| + i::Handle<i::Object> delegate = |
| + i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception); |
| + EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
| + 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>()); |
| + } |
| + return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); |
|
Mads Ager (chromium)
2011/05/05 09:03:33
Let's remove the cast to JSObject here. The functi
|
| +} |
| + |
| + |
| Local<v8::Object> Function::NewInstance() const { |
| return NewInstance(0, NULL); |
| } |