diff --git a/nan.h b/nan.h index bd7781d3..9463bd6f 100644 --- a/nan.h +++ b/nan.h @@ -1060,8 +1060,10 @@ class Utf8String { length_(0), str_(str_st_) { HandleScope scope; if (!from.IsEmpty()) { -#if V8_MAJOR_VERSION >= 7 - v8::Local string = from->ToString(v8::Isolate::GetCurrent()); +#if NODE_MAJOR_VERSION >= 10 + v8::Local context = GetCurrentContext(); + v8::Local string = + from->ToString(context).FromMaybe(v8::Local()); #else v8::Local string = from->ToString(); #endif @@ -1074,7 +1076,7 @@ class Utf8String { } const int flags = v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; -#if V8_MAJOR_VERSION >= 7 +#if NODE_MAJOR_VERSION >= 10 length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast(len), 0, flags); #else length_ = string->WriteUtf8(str_, static_cast(len), 0, flags); @@ -1852,36 +1854,41 @@ inline MaybeLocal Call( inline void SaveToPersistent( const char *key, const v8::Local &value) { HandleScope scope; - New(persistentHandle)->Set(New(key).ToLocalChecked(), value); + Set(New(persistentHandle), New(key).ToLocalChecked(), value).FromJust(); } inline void SaveToPersistent( const v8::Local &key, const v8::Local &value) { HandleScope scope; - New(persistentHandle)->Set(key, value); + Set(New(persistentHandle), key, value).FromJust(); } inline void SaveToPersistent( uint32_t index, const v8::Local &value) { HandleScope scope; - New(persistentHandle)->Set(index, value); + Set(New(persistentHandle), index, value).FromJust(); } inline v8::Local GetFromPersistent(const char *key) const { EscapableHandleScope scope; return scope.Escape( - New(persistentHandle)->Get(New(key).ToLocalChecked())); + Get(New(persistentHandle), New(key).ToLocalChecked()) + .FromMaybe(v8::Local())); } inline v8::Local GetFromPersistent(const v8::Local &key) const { EscapableHandleScope scope; - return scope.Escape(New(persistentHandle)->Get(key)); + return scope.Escape( + Get(New(persistentHandle), key) + .FromMaybe(v8::Local())); } inline v8::Local GetFromPersistent(uint32_t index) const { EscapableHandleScope scope; - return scope.Escape(New(persistentHandle)->Get(index)); + return scope.Escape( + Get(New(persistentHandle), index) + .FromMaybe(v8::Local())); } virtual void Execute() = 0; @@ -2375,7 +2382,7 @@ SetMethodAux(T recv, v8::Local name, v8::Local tpl, ...) { - recv->Set(name, GetFunction(tpl).ToLocalChecked()); + Set(recv, name, GetFunction(tpl).ToLocalChecked()); } } // end of namespace imp diff --git a/nan_implementation_12_inl.h b/nan_implementation_12_inl.h index 1bf6e052..6d68ed50 100644 --- a/nan_implementation_12_inl.h +++ b/nan_implementation_12_inl.h @@ -100,9 +100,17 @@ Factory::New( FunctionCallback callback obj->SetInternalField(imp::kDataIndex, val); } - return scope.Escape(v8::Function::New( isolate - , imp::FunctionCallbackWrapper - , obj)); +#if NODE_MAJOR_VERSION >= 10 + v8::Local context = isolate->GetCurrentContext(); + v8::Local function = + v8::Function::New(context, imp::FunctionCallbackWrapper, obj) + .ToLocalChecked(); +#else + v8::Local function = + v8::Function::New(isolate, imp::FunctionCallbackWrapper, obj); +#endif + + return scope.Escape(function); } //=== Function Template ======================================================== @@ -332,12 +340,25 @@ Factory::New(ExternalOneByteStringResource * value) { //=== String Object ============================================================ +// See https://github.com/nodejs/nan/pull/811#discussion_r224594980. +// Disable the warning as there is no way around it. +// TODO(bnoordhuis) Use isolate-based version in Node.js v12. Factory::return_t Factory::New(v8::Local value) { -#if V8_MAJOR_VERSION >= 7 - return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As(); -#else +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4996) +#endif +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif return v8::StringObject::New(value).As(); +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +#ifdef _MSC_VER +#pragma warning(pop) #endif } diff --git a/nan_object_wrap.h b/nan_object_wrap.h index a4d96178..45f43dd3 100644 --- a/nan_object_wrap.h +++ b/nan_object_wrap.h @@ -64,7 +64,10 @@ class ObjectWrap { inline void MakeWeak() { persistent().v8::PersistentBase::SetWeak( this, WeakCallback, v8::WeakCallbackType::kParameter); +#if NODE_MAJOR_VERSION < 10 + // FIXME(bnoordhuis) Probably superfluous in older Node.js versions too. persistent().MarkIndependent(); +#endif } #elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION diff --git a/test/cpp/accessors.cpp b/test/cpp/accessors.cpp index 50edbe5d..5848a409 100644 --- a/test/cpp/accessors.cpp +++ b/test/cpp/accessors.cpp @@ -61,7 +61,8 @@ NAN_MODULE_INIT(SetterGetter::Init) { ); v8::Local createnew = - Nan::New(CreateNew)->GetFunction(); + Nan::GetFunction( + Nan::New(CreateNew)).ToLocalChecked(); Set(target, Nan::New("create").ToLocalChecked(), createnew); } @@ -70,7 +71,8 @@ v8::Local SetterGetter::NewInstance () { v8::Local constructorHandle = Nan::New(settergetter_constructor); v8::Local instance = - Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked(); + Nan::NewInstance( + Nan::GetFunction(constructorHandle).ToLocalChecked()).ToLocalChecked(); return scope.Escape(instance); } diff --git a/test/cpp/accessors2.cpp b/test/cpp/accessors2.cpp index 837ecd5b..f5a2b312 100644 --- a/test/cpp/accessors2.cpp +++ b/test/cpp/accessors2.cpp @@ -49,7 +49,8 @@ NAN_MODULE_INIT(SetterGetter::Init) { tpl->InstanceTemplate()->SetInternalFieldCount(1); SetPrototypeMethod(tpl, "log", SetterGetter::Log); v8::Local createnew = - Nan::New(CreateNew)->GetFunction(); + Nan::GetFunction(Nan::New(CreateNew)) + .ToLocalChecked(); Set(target, Nan::New("create").ToLocalChecked(), createnew); } @@ -58,7 +59,8 @@ v8::Local SetterGetter::NewInstance () { v8::Local constructorHandle = Nan::New(settergetter_constructor); v8::Local instance = - Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked(); + Nan::NewInstance(Nan::GetFunction(constructorHandle).ToLocalChecked()) + .ToLocalChecked(); SetAccessor( instance , Nan::New("prop1").ToLocalChecked() diff --git a/test/cpp/asyncprogressqueueworker.cpp b/test/cpp/asyncprogressqueueworker.cpp index 7b516417..fb3b4bf6 100644 --- a/test/cpp/asyncprogressqueueworker.cpp +++ b/test/cpp/asyncprogressqueueworker.cpp @@ -55,7 +55,7 @@ NAN_METHOD(DoProgress) { NAN_MODULE_INIT(Init) { Set(target , New("doProgress").ToLocalChecked() - , New(DoProgress)->GetFunction()); + , GetFunction(New(DoProgress)).ToLocalChecked()); } NODE_MODULE(asyncprogressqueueworker, Init) diff --git a/test/cpp/asyncprogressqueueworkerstream.cpp b/test/cpp/asyncprogressqueueworkerstream.cpp index b85f14c2..8cd46f88 100644 --- a/test/cpp/asyncprogressqueueworkerstream.cpp +++ b/test/cpp/asyncprogressqueueworkerstream.cpp @@ -74,7 +74,7 @@ NAN_METHOD(DoProgress) { NAN_MODULE_INIT(Init) { Set(target , New("doProgress").ToLocalChecked() - , New(DoProgress)->GetFunction()); + , GetFunction(New(DoProgress)).ToLocalChecked()); } NODE_MODULE(asyncprogressqueueworkerstream, Init) diff --git a/test/cpp/asyncprogressworker.cpp b/test/cpp/asyncprogressworker.cpp index 14d6405b..a8718bad 100644 --- a/test/cpp/asyncprogressworker.cpp +++ b/test/cpp/asyncprogressworker.cpp @@ -61,7 +61,7 @@ NAN_METHOD(DoProgress) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(DoProgress)->GetFunction()); + , GetFunction(New(DoProgress)).ToLocalChecked()); } NODE_MODULE(asyncprogressworker, Init) diff --git a/test/cpp/asyncprogressworkersignal.cpp b/test/cpp/asyncprogressworkersignal.cpp index ed72b374..5d908aba 100644 --- a/test/cpp/asyncprogressworkersignal.cpp +++ b/test/cpp/asyncprogressworkersignal.cpp @@ -59,7 +59,7 @@ NAN_METHOD(DoProgress) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(DoProgress)->GetFunction()); + , GetFunction(New(DoProgress)).ToLocalChecked()); } NODE_MODULE(asyncprogressworkersignal, Init) diff --git a/test/cpp/asyncprogressworkerstream.cpp b/test/cpp/asyncprogressworkerstream.cpp index d08699e0..cc9179c9 100644 --- a/test/cpp/asyncprogressworkerstream.cpp +++ b/test/cpp/asyncprogressworkerstream.cpp @@ -81,7 +81,7 @@ NAN_METHOD(DoProgress) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(DoProgress)->GetFunction()); + , GetFunction(New(DoProgress)).ToLocalChecked()); } NODE_MODULE(asyncprogressworkerstream, Init) diff --git a/test/cpp/asyncworker.cpp b/test/cpp/asyncworker.cpp index ae7074c6..3ed5800d 100644 --- a/test/cpp/asyncworker.cpp +++ b/test/cpp/asyncworker.cpp @@ -36,7 +36,7 @@ NAN_METHOD(DoSleep) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(DoSleep)->GetFunction()); + , GetFunction(New(DoSleep)).ToLocalChecked()); } NODE_MODULE(asyncworker, Init) diff --git a/test/cpp/asyncworkererror.cpp b/test/cpp/asyncworkererror.cpp index 16e2027b..ba0b6be6 100644 --- a/test/cpp/asyncworkererror.cpp +++ b/test/cpp/asyncworkererror.cpp @@ -29,7 +29,7 @@ NAN_METHOD(Work) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(Work)->GetFunction()); + , GetFunction(New(Work)).ToLocalChecked()); } NODE_MODULE(asyncworkererror, Init) diff --git a/test/cpp/buffer.cpp b/test/cpp/buffer.cpp index 723e22df..a1e3adb2 100644 --- a/test/cpp/buffer.cpp +++ b/test/cpp/buffer.cpp @@ -56,19 +56,19 @@ NAN_MODULE_INIT(Init) { } Set(target , New("new1").ToLocalChecked() - , New(New1)->GetFunction() + , GetFunction(New(New1)).ToLocalChecked() ); Set(target , New("new2").ToLocalChecked() - , New(New2)->GetFunction() + , GetFunction(New(New2)).ToLocalChecked() ); Set(target , New("new3").ToLocalChecked() - , New(New3)->GetFunction() + , GetFunction(New(New3)).ToLocalChecked() ); Set(target , New("copy").ToLocalChecked() - , New(Copy)->GetFunction() + , GetFunction(New(Copy)).ToLocalChecked() ); } diff --git a/test/cpp/bufferworkerpersistent.cpp b/test/cpp/bufferworkerpersistent.cpp index 1dd2113a..046509a0 100644 --- a/test/cpp/bufferworkerpersistent.cpp +++ b/test/cpp/bufferworkerpersistent.cpp @@ -61,7 +61,7 @@ NAN_METHOD(DoSleep) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(DoSleep)->GetFunction()); + , GetFunction(New(DoSleep)).ToLocalChecked()); } NODE_MODULE(bufferworkerpersistent, Init) diff --git a/test/cpp/converters.cpp b/test/cpp/converters.cpp index f989b63c..4c75ad86 100644 --- a/test/cpp/converters.cpp +++ b/test/cpp/converters.cpp @@ -75,63 +75,63 @@ NAN_METHOD(Int32Value) { NAN_MODULE_INIT(Init) { Set(target , New("toBoolean").ToLocalChecked() - , New(ToBoolean)->GetFunction() + , GetFunction(New(ToBoolean)).ToLocalChecked() ); Set(target , New("toNumber").ToLocalChecked() - , New(ToNumber)->GetFunction() + , GetFunction(New(ToNumber)).ToLocalChecked() ); Set(target , New("toString").ToLocalChecked() - , New(ToString)->GetFunction() + , GetFunction(New(ToString)).ToLocalChecked() ); Set(target , New("toDetailString").ToLocalChecked() - , New(ToDetailString)->GetFunction() + , GetFunction(New(ToDetailString)).ToLocalChecked() ); Set(target , New("toFunction").ToLocalChecked() - , New(ToFunction)->GetFunction() + , GetFunction(New(ToFunction)).ToLocalChecked() ); Set(target , New("toObject").ToLocalChecked() - , New(ToObject)->GetFunction() + , GetFunction(New(ToObject)).ToLocalChecked() ); Set(target , New("toInteger").ToLocalChecked() - , New(ToInteger)->GetFunction() + , GetFunction(New(ToInteger)).ToLocalChecked() ); Set(target , New("toUint32").ToLocalChecked() - , New(ToUint32)->GetFunction() + , GetFunction(New(ToUint32)).ToLocalChecked() ); Set(target , New("toInt32").ToLocalChecked() - , New(ToInt32)->GetFunction() + , GetFunction(New(ToInt32)).ToLocalChecked() ); Set(target , New("toArrayIndex").ToLocalChecked() - , New(ToArrayIndex)->GetFunction() + , GetFunction(New(ToArrayIndex)).ToLocalChecked() ); Set(target , New("booleanValue").ToLocalChecked() - , New(BooleanValue)->GetFunction() + , GetFunction(New(BooleanValue)).ToLocalChecked() ); Set(target , New("numberValue").ToLocalChecked() - , New(NumberValue)->GetFunction() + , GetFunction(New(NumberValue)).ToLocalChecked() ); Set(target , New("integerValue").ToLocalChecked() - , New(IntegerValue)->GetFunction() + , GetFunction(New(IntegerValue)).ToLocalChecked() ); Set(target , New("uint32Value").ToLocalChecked() - , New(Uint32Value)->GetFunction() + , GetFunction(New(Uint32Value)).ToLocalChecked() ); Set(target , New("int32Value").ToLocalChecked() - , New(Int32Value)->GetFunction() + , GetFunction(New(Int32Value)).ToLocalChecked() ); } diff --git a/test/cpp/error.cpp b/test/cpp/error.cpp index 03bb6868..73dcd676 100644 --- a/test/cpp/error.cpp +++ b/test/cpp/error.cpp @@ -45,7 +45,7 @@ X(TypeError) Nan::Set( \ target \ , Nan::New(#NAME).ToLocalChecked() \ - , Nan::New(NAME)->GetFunction()); + , Nan::GetFunction(New(NAME)).ToLocalChecked()); NAN_MODULE_INIT(Init) { diff --git a/test/cpp/gc.cpp b/test/cpp/gc.cpp index 7110560d..8d4d54e8 100644 --- a/test/cpp/gc.cpp +++ b/test/cpp/gc.cpp @@ -36,11 +36,11 @@ NAN_METHOD(Check) { NAN_MODULE_INIT(Init) { Set(target , New("hook").ToLocalChecked() - , New(Hook)->GetFunction() + , GetFunction(New(Hook)).ToLocalChecked() ); Set(target , New("check").ToLocalChecked() - , New(Check)->GetFunction() + , GetFunction(New(Check)).ToLocalChecked() ); } diff --git a/test/cpp/indexedinterceptors.cpp b/test/cpp/indexedinterceptors.cpp index 4d9fbf90..f2cd97ac 100644 --- a/test/cpp/indexedinterceptors.cpp +++ b/test/cpp/indexedinterceptors.cpp @@ -50,7 +50,8 @@ NAN_MODULE_INIT(IndexedInterceptor::Init) { , IndexedInterceptor::PropertyEnumerator); v8::Local createnew = - Nan::New(CreateNew)->GetFunction(); + Nan::GetFunction(Nan::New(CreateNew)) + .ToLocalChecked(); Set(target, Nan::New("create").ToLocalChecked(), createnew); } @@ -59,7 +60,8 @@ v8::Local IndexedInterceptor::NewInstance () { v8::Local constructorHandle = Nan::New(indexedinterceptors_constructor); v8::Local instance = - Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked(); + Nan::NewInstance(Nan::GetFunction(constructorHandle).ToLocalChecked()) + .ToLocalChecked(); return scope.Escape(instance); } diff --git a/test/cpp/isolatedata.cpp b/test/cpp/isolatedata.cpp index c406faad..8cef7583 100644 --- a/test/cpp/isolatedata.cpp +++ b/test/cpp/isolatedata.cpp @@ -31,7 +31,7 @@ NAN_METHOD(SetAndGet) { NAN_MODULE_INIT(Init) { Set(target , New("setAndGet").ToLocalChecked() - , New(SetAndGet)->GetFunction() + , GetFunction(New(SetAndGet)).ToLocalChecked() ); } diff --git a/test/cpp/json-parse.cpp b/test/cpp/json-parse.cpp index 57aab785..ab1a97e4 100644 --- a/test/cpp/json-parse.cpp +++ b/test/cpp/json-parse.cpp @@ -27,7 +27,7 @@ NAN_METHOD(Parse) { NAN_MODULE_INIT(Init) { Nan::Set(target , Nan::New("parse").ToLocalChecked() - , Nan::New(Parse)->GetFunction() + , Nan::GetFunction(Nan::New(Parse)).ToLocalChecked() ); } diff --git a/test/cpp/json-stringify.cpp b/test/cpp/json-stringify.cpp index afc4dedf..06ac5a1a 100644 --- a/test/cpp/json-stringify.cpp +++ b/test/cpp/json-stringify.cpp @@ -64,7 +64,8 @@ NAN_METHOD(Stringify) { NAN_MODULE_INIT(Init) { Nan::Set(target , Nan::New("stringify").ToLocalChecked() - , Nan::New(Stringify)->GetFunction() + , Nan::GetFunction(Nan::New(Stringify)) + .ToLocalChecked() ); } diff --git a/test/cpp/makecallback.cpp b/test/cpp/makecallback.cpp index 3fe7924c..604fe300 100644 --- a/test/cpp/makecallback.cpp +++ b/test/cpp/makecallback.cpp @@ -42,8 +42,9 @@ NAN_MODULE_INIT(MyObject::Init) { SetPrototypeMethod(tpl, "call_emit", CallEmit); - constructor.Reset(tpl->GetFunction()); - Set(target, Nan::New("MyObject").ToLocalChecked(), tpl->GetFunction()); + v8::Local function = GetFunction(tpl).ToLocalChecked(); + constructor.Reset(function); + Set(target, Nan::New("MyObject").ToLocalChecked(), function); } NAN_METHOD(MyObject::New) { diff --git a/test/cpp/morenews.cpp b/test/cpp/morenews.cpp index 4215310e..47780224 100644 --- a/test/cpp/morenews.cpp +++ b/test/cpp/morenews.cpp @@ -68,36 +68,35 @@ NAN_METHOD(NewExternalAsciiStringResource) { NAN_MODULE_INIT(Init) { Set(target , New("newNumber").ToLocalChecked() - , New(NewNumber)->GetFunction() + , GetFunction(New(NewNumber)).ToLocalChecked() ); Set(target , New("newNegativeInteger").ToLocalChecked() - , New(NewNegativeInteger)->GetFunction() + , GetFunction(New(NewNegativeInteger)).ToLocalChecked() ); Set(target , New("newPositiveInteger").ToLocalChecked() - , New(NewPositiveInteger)->GetFunction() + , GetFunction(New(NewPositiveInteger)).ToLocalChecked() ); Set(target , New("newUtf8String").ToLocalChecked() - , New(NewUtf8String)->GetFunction() + , GetFunction(New(NewUtf8String)).ToLocalChecked() ); Set(target , New("newLatin1String").ToLocalChecked() - , New(NewLatin1String)->GetFunction() + , GetFunction(New(NewLatin1String)).ToLocalChecked() ); Set(target , New("newUcs2String").ToLocalChecked() - , New(NewUcs2String)->GetFunction() + , GetFunction(New(NewUcs2String)).ToLocalChecked() ); Set(target , New("newExternalStringResource").ToLocalChecked() - , New(NewExternalStringResource)->GetFunction() + , GetFunction(New(NewExternalStringResource)).ToLocalChecked() ); Set(target , New("newExternalAsciiStringResource").ToLocalChecked() - , New(NewExternalAsciiStringResource) - ->GetFunction() + , GetFunction(New(NewExternalAsciiStringResource)).ToLocalChecked() ); } diff --git a/test/cpp/multifile1.cpp b/test/cpp/multifile1.cpp index d0a441e5..fce9ca99 100644 --- a/test/cpp/multifile1.cpp +++ b/test/cpp/multifile1.cpp @@ -14,7 +14,7 @@ using namespace Nan; // NOLINT(build/namespaces) NAN_MODULE_INIT(Init) { Set(target , New("r").ToLocalChecked() - , New(ReturnString)->GetFunction() + , GetFunction(New(ReturnString)).ToLocalChecked() ); } diff --git a/test/cpp/namedinterceptors.cpp b/test/cpp/namedinterceptors.cpp index 7a8ad296..8ab5f47d 100644 --- a/test/cpp/namedinterceptors.cpp +++ b/test/cpp/namedinterceptors.cpp @@ -50,7 +50,8 @@ NAN_MODULE_INIT(NamedInterceptor::Init) { , NamedInterceptor::PropertyEnumerator); v8::Local createnew = - Nan::New(CreateNew)->GetFunction(); + Nan::GetFunction(Nan::New(CreateNew)) + .ToLocalChecked(); Set(target, Nan::New("create").ToLocalChecked(), createnew); } @@ -59,7 +60,8 @@ v8::Local NamedInterceptor::NewInstance () { v8::Local constructorHandle = Nan::New(namedinterceptors_constructor); v8::Local instance = - Nan::NewInstance(constructorHandle->GetFunction()).ToLocalChecked(); + Nan::NewInstance(GetFunction(constructorHandle).ToLocalChecked()) + .ToLocalChecked(); return scope.Escape(instance); } diff --git a/test/cpp/nancallback.cpp b/test/cpp/nancallback.cpp index b97ce5a6..eddfcb87 100644 --- a/test/cpp/nancallback.cpp +++ b/test/cpp/nancallback.cpp @@ -37,7 +37,7 @@ NAN_METHOD(CompareCallbacks) { NAN_METHOD(CallDirect) { Callback cb(To(info[0]).ToLocalChecked()); - (*cb)->Call(GetCurrentContext()->Global(), 0, NULL); + Call(*cb, GetCurrentContext()->Global(), 0, NULL); } NAN_METHOD(CallAsFunction) { @@ -58,8 +58,10 @@ NAN_METHOD(ResetSet) { } NAN_METHOD(CallRetval) { + AsyncResource resource("nan:test.nancallback"); Callback callback(To(info[0]).ToLocalChecked()); - v8::Local result = callback.Call(0, NULL); + v8::Local result = + callback.Call(0, NULL, &resource).ToLocalChecked(); if (result->IsNumber()) { info.GetReturnValue().Set(Nan::True()); } else { @@ -70,39 +72,39 @@ NAN_METHOD(CallRetval) { NAN_MODULE_INIT(Init) { Set(target , New("globalContext").ToLocalChecked() - , New(GlobalContext)->GetFunction() + , GetFunction(New(GlobalContext)).ToLocalChecked() ); Set(target , New("specificContext").ToLocalChecked() - , New(SpecificContext)->GetFunction() + , GetFunction(New(SpecificContext)).ToLocalChecked() ); Set(target , New("customReceiver").ToLocalChecked() - , New(CustomReceiver)->GetFunction() + , GetFunction(New(CustomReceiver)).ToLocalChecked() ); Set(target , New("compareCallbacks").ToLocalChecked() - , New(CompareCallbacks)->GetFunction() + , GetFunction(New(CompareCallbacks)).ToLocalChecked() ); Set(target , New("callDirect").ToLocalChecked() - , New(CallDirect)->GetFunction() + , GetFunction(New(CallDirect)).ToLocalChecked() ); Set(target , New("callAsFunction").ToLocalChecked() - , New(CallAsFunction)->GetFunction() + , GetFunction(New(CallAsFunction)).ToLocalChecked() ); Set(target , New("resetUnset").ToLocalChecked() - , New(ResetUnset)->GetFunction() + , GetFunction(New(ResetUnset)).ToLocalChecked() ); Set(target , New("resetSet").ToLocalChecked() - , New(ResetSet)->GetFunction() + , GetFunction(New(ResetSet)).ToLocalChecked() ); Set(target , New("callRetval").ToLocalChecked() - , New(CallRetval)->GetFunction() + , GetFunction(New(CallRetval)).ToLocalChecked() ); } diff --git a/test/cpp/news.cpp b/test/cpp/news.cpp index 3d8f29eb..c0b4b380 100644 --- a/test/cpp/news.cpp +++ b/test/cpp/news.cpp @@ -165,107 +165,107 @@ NAN_METHOD(NewBoolean2) { NAN_MODULE_INIT(Init) { Set(target , New("newNumber").ToLocalChecked() - , New(NewNumber)->GetFunction() + , GetFunction(New(NewNumber)).ToLocalChecked() ); Set(target , New("newNegativeInteger").ToLocalChecked() - , New(NewNegativeInteger)->GetFunction() + , GetFunction(New(NewNegativeInteger)).ToLocalChecked() ); Set(target , New("newPositiveInteger").ToLocalChecked() - , New(NewPositiveInteger)->GetFunction() + , GetFunction(New(NewPositiveInteger)).ToLocalChecked() ); Set(target , New("newUnsignedInteger").ToLocalChecked() - , New(NewUnsignedInteger)->GetFunction() + , GetFunction(New(NewUnsignedInteger)).ToLocalChecked() ); Set(target , New("newInt32FromPositive").ToLocalChecked() - , New(NewInt32FromPositive)->GetFunction() + , GetFunction(New(NewInt32FromPositive)).ToLocalChecked() ); Set(target , New("newInt32FromNegative").ToLocalChecked() - , New(NewInt32FromNegative)->GetFunction() + , GetFunction(New(NewInt32FromNegative)).ToLocalChecked() ); Set(target , New("newUint32FromPositive").ToLocalChecked() - , New(NewUint32FromPositive)->GetFunction() + , GetFunction(New(NewUint32FromPositive)).ToLocalChecked() ); Set(target , New("newUint32FromNegative").ToLocalChecked() - , New(NewUint32FromNegative)->GetFunction() + , GetFunction(New(NewUint32FromNegative)).ToLocalChecked() ); Set(target , New("newUtf8String").ToLocalChecked() - , New(NewUtf8String)->GetFunction() + , GetFunction(New(NewUtf8String)).ToLocalChecked() ); Set(target , New("newLatin1String").ToLocalChecked() - , New(NewLatin1String)->GetFunction() + , GetFunction(New(NewLatin1String)).ToLocalChecked() ); Set(target , New("newUcs2String").ToLocalChecked() - , New(NewUcs2String)->GetFunction() + , GetFunction(New(NewUcs2String)).ToLocalChecked() ); Set(target , New("newStdString").ToLocalChecked() - , New(NewStdString)->GetFunction() + , GetFunction(New(NewStdString)).ToLocalChecked() ); Set(target , New("newRegExp").ToLocalChecked() - , New(NewRegExp)->GetFunction() + , GetFunction(New(NewRegExp)).ToLocalChecked() ); Set(target , New("newStringObject").ToLocalChecked() - , New(NewStringObject)->GetFunction() + , GetFunction(New(NewStringObject)).ToLocalChecked() ); Set(target , New("newNumberObject").ToLocalChecked() - , New(NewNumberObject)->GetFunction() + , GetFunction(New(NewNumberObject)).ToLocalChecked() ); Set(target , New("newBooleanObject").ToLocalChecked() - , New(NewBooleanObject)->GetFunction() + , GetFunction(New(NewBooleanObject)).ToLocalChecked() ); Set(target , New("newExternal").ToLocalChecked() - , New(NewExternal)->GetFunction() + , GetFunction(New(NewExternal)).ToLocalChecked() ); Set(target , New("newSignature").ToLocalChecked() - , New(NewSignature)->GetFunction() + , GetFunction(New(NewSignature)).ToLocalChecked() ); Set(target , New("newScript").ToLocalChecked() - , New(NewScript)->GetFunction() + , GetFunction(New(NewScript)).ToLocalChecked() ); Set(target , New("newScript2").ToLocalChecked() - , New(NewScript2)->GetFunction() + , GetFunction(New(NewScript2)).ToLocalChecked() ); Set(target , New("compileScript").ToLocalChecked() - , New(CompileScript)->GetFunction() + , GetFunction(New(CompileScript)).ToLocalChecked() ); Set(target , New("compileScript2").ToLocalChecked() - , New(CompileScript2)->GetFunction() + , GetFunction(New(CompileScript2)).ToLocalChecked() ); Set(target , New("newDate").ToLocalChecked() - , New(NewDate)->GetFunction() + , GetFunction(New(NewDate)).ToLocalChecked() ); Set(target , New("newArray").ToLocalChecked() - , New(NewArray)->GetFunction() + , GetFunction(New(NewArray)).ToLocalChecked() ); Set(target , New("newBoolean").ToLocalChecked() - , New(NewBoolean)->GetFunction() + , GetFunction(New(NewBoolean)).ToLocalChecked() ); Set(target , New("newBoolean2").ToLocalChecked() - , New(NewBoolean2)->GetFunction() + , GetFunction(New(NewBoolean2)).ToLocalChecked() ); } diff --git a/test/cpp/returnemptystring.cpp b/test/cpp/returnemptystring.cpp index eb60cc80..0ede5191 100644 --- a/test/cpp/returnemptystring.cpp +++ b/test/cpp/returnemptystring.cpp @@ -17,7 +17,7 @@ NAN_METHOD(ReturnEmptyString) { NAN_MODULE_INIT(Init) { Set(target , New("r").ToLocalChecked() - , New(ReturnEmptyString)->GetFunction() + , GetFunction(New(ReturnEmptyString)).ToLocalChecked() ); } diff --git a/test/cpp/returnnull.cpp b/test/cpp/returnnull.cpp index 33faa313..8a974e50 100644 --- a/test/cpp/returnnull.cpp +++ b/test/cpp/returnnull.cpp @@ -15,7 +15,8 @@ NAN_METHOD(ReturnNull) { NAN_MODULE_INIT(Init) { Nan::Set(target , Nan::New("r").ToLocalChecked() - , Nan::New(ReturnNull)->GetFunction() + , Nan::GetFunction(Nan::New(ReturnNull)) + .ToLocalChecked() ); } diff --git a/test/cpp/returnundefined.cpp b/test/cpp/returnundefined.cpp index 10499cfb..d28ce6c3 100644 --- a/test/cpp/returnundefined.cpp +++ b/test/cpp/returnundefined.cpp @@ -17,7 +17,7 @@ NAN_METHOD(ReturnUndefined) { NAN_MODULE_INIT(Init) { Set(target , New("r").ToLocalChecked() - , New(ReturnUndefined)->GetFunction() + , GetFunction(New(ReturnUndefined)).ToLocalChecked() ); } diff --git a/test/cpp/returnvalue.cpp b/test/cpp/returnvalue.cpp index fc08ed00..31e551ab 100644 --- a/test/cpp/returnvalue.cpp +++ b/test/cpp/returnvalue.cpp @@ -39,19 +39,19 @@ NAN_MODULE_INIT(Init) { Set(target , New("r").ToLocalChecked() - , New(ReturnAValue)->GetFunction() + , GetFunction(New(ReturnAValue)).ToLocalChecked() ); Set(target , New("p").ToLocalChecked() - , New(ReturnPrimitive)->GetFunction() + , GetFunction(New(ReturnPrimitive)).ToLocalChecked() ); Set(target , New("q").ToLocalChecked() - , New(ReturnGlobal)->GetFunction() + , GetFunction(New(ReturnGlobal)).ToLocalChecked() ); Set(target , New("u").ToLocalChecked() - , New(ReturnUnsigned)->GetFunction() + , GetFunction(New(ReturnUnsigned)).ToLocalChecked() ); } diff --git a/test/cpp/setcallhandler.cpp b/test/cpp/setcallhandler.cpp index c0eb09bc..b9c1dbcd 100644 --- a/test/cpp/setcallhandler.cpp +++ b/test/cpp/setcallhandler.cpp @@ -33,11 +33,11 @@ NAN_METHOD(CallAsFunctionHandlerSetter) { NAN_MODULE_INIT(Init) { Set(target , New("a").ToLocalChecked() - , New(CallHandlerSetter)->GetFunction() + , GetFunction(New(CallHandlerSetter)).ToLocalChecked() ); Set(target , New("b").ToLocalChecked() - , New(CallAsFunctionHandlerSetter)->GetFunction() + , GetFunction(New(CallAsFunctionHandlerSetter)).ToLocalChecked() ); } diff --git a/test/cpp/settemplate.cpp b/test/cpp/settemplate.cpp index 588aaad1..5ffb1708 100644 --- a/test/cpp/settemplate.cpp +++ b/test/cpp/settemplate.cpp @@ -72,10 +72,11 @@ NAN_MODULE_INIT(MyObject::Init) { , Nan::New("dontDelete").ToLocalChecked() , v8::DontDelete); - constructor.Reset(tpl->GetFunction()); + v8::Local function = Nan::GetFunction(tpl).ToLocalChecked(); + constructor.Reset(function); Set(target , Nan::New("MyObject").ToLocalChecked() - , tpl->GetFunction()); + , function); //=== SetMethod ============================================================== diff --git a/test/cpp/strings.cpp b/test/cpp/strings.cpp index 73f87fbc..95edeac9 100644 --- a/test/cpp/strings.cpp +++ b/test/cpp/strings.cpp @@ -40,20 +40,20 @@ NAN_MODULE_INIT(Init) { returnUtf8String_persistent.Reset(returnUtf8String); - target->Set( - New("returnUtf8String").ToLocalChecked() - , returnUtf8String->GetFunction() - ); + Set(target + , New("returnUtf8String").ToLocalChecked() + , GetFunction(returnUtf8String).ToLocalChecked() + ).FromJust(); v8::Local heapString = New(HeapString); heapString_persistent.Reset(heapString); - target->Set( - New("heapString").ToLocalChecked() - , heapString->GetFunction() - ); + Set(target + , New("heapString").ToLocalChecked() + , GetFunction(heapString).ToLocalChecked() + ).FromJust(); v8::Local encodeHex = New(EncodeHex); @@ -62,8 +62,8 @@ NAN_MODULE_INIT(Init) { Set(target , New("encodeHex").ToLocalChecked() - , encodeHex->GetFunction() - ); + , GetFunction(encodeHex).ToLocalChecked() + ).FromJust(); v8::Local encodeUCS2 = New(EncodeUCS2); @@ -72,8 +72,8 @@ NAN_MODULE_INIT(Init) { Set(target , New("encodeUCS2").ToLocalChecked() - , encodeUCS2->GetFunction() - ); + , GetFunction(encodeUCS2).ToLocalChecked() + ).FromJust(); } NODE_MODULE(strings, Init) diff --git a/test/cpp/threadlocal.cpp b/test/cpp/threadlocal.cpp index 754446d5..a3fc5875 100644 --- a/test/cpp/threadlocal.cpp +++ b/test/cpp/threadlocal.cpp @@ -63,7 +63,7 @@ NAN_METHOD(thread_local_storage) { NAN_MODULE_INIT(Init) { Set(target , New("thread_local_storage").ToLocalChecked() - , New(thread_local_storage)->GetFunction() + , GetFunction(New(thread_local_storage)).ToLocalChecked() ); } diff --git a/test/cpp/trycatch.cpp b/test/cpp/trycatch.cpp index 8ce20c64..e01efbc5 100644 --- a/test/cpp/trycatch.cpp +++ b/test/cpp/trycatch.cpp @@ -24,7 +24,7 @@ NAN_METHOD(TryCatchTest) { NAN_MODULE_INIT(Init) { Set(target , New("r").ToLocalChecked() - , New(TryCatchTest)->GetFunction() + , GetFunction(New(TryCatchTest)).ToLocalChecked() ); } diff --git a/test/cpp/weak.cpp b/test/cpp/weak.cpp index 7516bc28..195d56f0 100644 --- a/test/cpp/weak.cpp +++ b/test/cpp/weak.cpp @@ -50,11 +50,11 @@ NAN_METHOD(WeakExternal) { NAN_MODULE_INIT(Init) { Set(target , New("hustle").ToLocalChecked() - , New(Hustle)->GetFunction() + , GetFunction(New(Hustle)).ToLocalChecked() ); Set(target , New("weakExternal").ToLocalChecked() - , New(WeakExternal)->GetFunction() + , GetFunction(New(WeakExternal)).ToLocalChecked() ); } diff --git a/test/cpp/weak2.cpp b/test/cpp/weak2.cpp index 1599365d..49f9b627 100644 --- a/test/cpp/weak2.cpp +++ b/test/cpp/weak2.cpp @@ -27,7 +27,7 @@ v8::Local wrap() { v8::Local lstring = New("result").ToLocalChecked(); v8::Local otpl = New(); otpl->SetInternalFieldCount(1); - v8::Local obj = otpl->NewInstance(); + v8::Local obj = NewInstance(otpl).ToLocalChecked(); SetInternalFieldPointer(obj, 0, new int(42)); Persistent persistent(obj); persistent.SetWeak( @@ -47,7 +47,7 @@ NAN_METHOD(Hustle) { NAN_MODULE_INIT(Init) { Set(target , New("hustle").ToLocalChecked() - , New(Hustle)->GetFunction() + , GetFunction(New(Hustle)).ToLocalChecked() ); }