Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nan_implementation_12_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,16 @@ Factory<v8::Function>::New( FunctionCallback callback
obj->SetInternalField(imp::kDataIndex, val);
}

#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
return scope.Escape(v8::Function::New( isolate
, imp::FunctionCallbackWrapper
, obj));
#else
return Factory<v8::Function>::return_t(scope.Escape(v8::Function::New( isolate
, imp::FunctionCallbackWrapper
, obj)));
#endif
}

//=== Function Template ========================================================
Expand Down
4 changes: 2 additions & 2 deletions nan_implementation_pre_12_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ Factory<v8::External>::New(void * value) {
Factory<v8::Function>::return_t
Factory<v8::Function>::New( FunctionCallback callback
, v8::Local<v8::Value> data) {
return Factory<v8::FunctionTemplate>::New( callback
return Factory<v8::Function>::return_t(Factory<v8::FunctionTemplate>::New( callback
, data
, v8::Local<v8::Signature>()
)->GetFunction();
)->GetFunction());
}


Expand Down
2 changes: 1 addition & 1 deletion nan_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct Factory<v8::External> : FactoryBase<v8::External> {
};

template <>
struct Factory<v8::Function> : FactoryBase<v8::Function> {
struct Factory<v8::Function> : MaybeFactoryBase<v8::Function> {
static inline
return_t
New( FunctionCallback callback
Expand Down
6 changes: 3 additions & 3 deletions test/cpp/nannew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ NAN_METHOD(testFunction) {
Tap t(info[0]);
t.plan(2);

t.ok(_( assertType<Function>(New<Function>(testFunction))));
t.ok(_( assertType<Function>(New<Function>(testFunction).ToLocalChecked())));
v8::Local<String> data = New("plonk").ToLocalChecked();
t.ok(_( assertType<Function>(New<Function>(testFunction, data))));
t.ok(_( assertType<Function>(New<Function>(testFunction, data).ToLocalChecked())));

info.GetReturnValue().SetUndefined();
}
Expand Down Expand Up @@ -416,7 +416,7 @@ NAN_METHOD(testRegression242) {
// These lines must *compile*. Not much to test at runtime.
Local<FunctionTemplate> ft = New<FunctionTemplate>(overloaded);
(void)ft; // not unused
Local<Function> f = New<Function>(overloaded);
Local<Function> f = New<Function>(overloaded).ToLocalChecked();
(void)f; // not unused

t.plan(1);
Expand Down