Commit c52bb1f0 authored by jochen's avatar jochen Committed by Commit bot

Introduce a maybe-version of Function::New

Internally, it invokes GetFunction() which returns a MaybeLocal<>

BUG=4134
R=vogelheim@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/1156693003

Cr-Commit-Position: refs/heads/master@{#28600}
parent 17d2f3b1
...@@ -3063,10 +3063,14 @@ class V8_EXPORT Function : public Object { ...@@ -3063,10 +3063,14 @@ class V8_EXPORT Function : public Object {
* Create a function in the current execution context * Create a function in the current execution context
* for a given FunctionCallback. * for a given FunctionCallback.
*/ */
static Local<Function> New(Isolate* isolate, static MaybeLocal<Function> New(Local<Context> context,
FunctionCallback callback, FunctionCallback callback,
Local<Value> data = Local<Value>(), Local<Value> data = Local<Value>(),
int length = 0); int length = 0);
static V8_DEPRECATE_SOON(
"Use maybe version",
Local<Function> New(Isolate* isolate, FunctionCallback callback,
Local<Value> data = Local<Value>(), int length = 0));
V8_DEPRECATE_SOON("Use maybe version", V8_DEPRECATE_SOON("Use maybe version",
Local<Object> NewInstance(int argc, Handle<Value> argv[]) Local<Object> NewInstance(int argc, Handle<Value> argv[])
......
...@@ -4299,16 +4299,21 @@ Local<v8::Value> Object::CallAsConstructor(int argc, ...@@ -4299,16 +4299,21 @@ Local<v8::Value> Object::CallAsConstructor(int argc,
} }
Local<Function> Function::New(Isolate* v8_isolate, MaybeLocal<Function> Function::New(Local<Context> context,
FunctionCallback callback, FunctionCallback callback, Local<Value> data,
Local<Value> data, int length) {
int length) { i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
LOG_API(isolate, "Function::New"); LOG_API(isolate, "Function::New");
ENTER_V8(isolate); ENTER_V8(isolate);
return FunctionTemplateNew( return FunctionTemplateNew(isolate, callback, data, Local<Signature>(),
isolate, callback, data, Local<Signature>(), length, true)-> length, true)->GetFunction(context);
GetFunction(); }
Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
Local<Value> data, int length) {
return Function::New(v8_isolate->GetCurrentContext(), callback, data, length)
.FromMaybe(Local<Function>());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment