* Create a function in the current execution context
* for a given FunctionCallback.
*/
- static Local<Function> New(Isolate* isolate,
- FunctionCallback callback,
- Local<Value> data = Local<Value>(),
- int length = 0);
+ static MaybeLocal<Function> New(Local<Context> context,
+ FunctionCallback callback,
+ Local<Value> data = Local<Value>(),
+ 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",
Local<Object> NewInstance(int argc, Handle<Value> argv[])
}
-Local<Function> Function::New(Isolate* v8_isolate,
- FunctionCallback callback,
- Local<Value> data,
- int length) {
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
+MaybeLocal<Function> Function::New(Local<Context> context,
+ FunctionCallback callback, Local<Value> data,
+ int length) {
+ i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
LOG_API(isolate, "Function::New");
ENTER_V8(isolate);
- return FunctionTemplateNew(
- isolate, callback, data, Local<Signature>(), length, true)->
- GetFunction();
+ return FunctionTemplateNew(isolate, callback, data, Local<Signature>(),
+ length, true)->GetFunction(context);
+}
+
+
+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>());
}