diff --git a/package-lock.json b/package-lock.json index 5c366e5..74e59f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -174,9 +174,9 @@ "dev": true }, "nan": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", - "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" }, "once": { "version": "1.4.0", diff --git a/package.json b/package.json index c995a95..452a16e 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ "readmeFilename": "README.md", "dependencies": { "bindings": "1.2.x", - "nan": "^2.4.0" + "nan": "^2.14.1" } } diff --git a/src/Int64.cc b/src/Int64.cc index 1d2ea12..c0aa9ec 100644 --- a/src/Int64.cc +++ b/src/Int64.cc @@ -17,9 +17,7 @@ using namespace v8; Nan::Persistent Int64::constructor; -void Int64::Init(Handle exports) { - Nan::HandleScope scope; - +NAN_MODULE_INIT(Int64::Init) { Local tpl = Nan::New(New); tpl->SetClassName(Nan::New("Int64").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); @@ -41,8 +39,8 @@ void Int64::Init(Handle exports) { Nan::SetPrototypeMethod(tpl, "add", Add); Nan::SetPrototypeMethod(tpl, "sub", Sub); - constructor.Reset(tpl->GetFunction()); - exports->Set(Nan::New("Int64").ToLocalChecked(), tpl->GetFunction()); + constructor.Reset(Nan::GetFunction(tpl).ToLocalChecked()); + Nan::Set(target, Nan::New("Int64").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } Int64::Int64() { @@ -50,12 +48,12 @@ Int64::Int64() { } Int64::Int64(const Local& n) { - mValue = static_cast(n->NumberValue()); + mValue = static_cast(Nan::To(n).ToChecked()); } Int64::Int64(const Local& hi, const Local& lo) { - uint32_t highBits = static_cast(hi->NumberValue()); - uint32_t lowBits = static_cast(lo->NumberValue()); + uint32_t highBits = static_cast(Nan::To(hi).ToChecked()); + uint32_t lowBits = static_cast(Nan::To(lo).ToChecked()); mValue = (static_cast(highBits) << 32) | (static_cast(lowBits)); @@ -84,7 +82,7 @@ NAN_METHOD(Int64::New) { if (info[0]->IsNumber()) { obj = new Int64(Nan::To(info[0]).ToLocalChecked()); } else if (info[0]->IsString()) { - obj = new Int64(info[0]->ToString()); + obj = new Int64(Nan::To(info[0]).ToLocalChecked()); } } else if (info.Length() == 2) { if (info[0]->IsNumber() && info[1]->IsNumber()) { @@ -171,7 +169,7 @@ NAN_METHOD(Int64::Equals) { Nan::ThrowTypeError("Object expected"); } Int64* obj = ObjectWrap::Unwrap(info.Holder()); - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); bool isEqual = obj->mValue == otherObj->mValue; info.GetReturnValue().Set(Nan::New(isEqual)); } @@ -184,7 +182,7 @@ NAN_METHOD(Int64::Compare) { Nan::ThrowTypeError("Object expected"); } Int64* obj = ObjectWrap::Unwrap(info.Holder()); - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); int32_t cmp = 0; if (obj->mValue < otherObj->mValue) { cmp = -1; @@ -215,7 +213,7 @@ NAN_METHOD(Int64::ShiftLeft) { } Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t shiftBy = static_cast( - Nan::To(info[0]).ToLocalChecked()->NumberValue() + Nan::To(info[0]).ToChecked() ); uint64_t value = obj->mValue << shiftBy; Local argv[2] = { @@ -238,7 +236,7 @@ NAN_METHOD(Int64::ShiftRight) { } Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t shiftBy = static_cast( - Nan::To(info[0]).ToLocalChecked()->NumberValue() + Nan::To(info[0]).ToChecked() ); uint64_t value = obj->mValue >> shiftBy; Local argv[2] = { @@ -258,9 +256,9 @@ NAN_METHOD(Int64::And) { Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t value; if (info[0]->IsNumber()) { - value = obj->mValue & info[0]->IntegerValue(); + value = obj->mValue & Nan::To(info[0]).ToChecked(); } else if (info[0]->IsObject()) { - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); value = obj->mValue & otherObj->mValue; } else { Nan::ThrowTypeError("Object or number expected"); @@ -283,9 +281,9 @@ NAN_METHOD(Int64::Or) { Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t value; if (info[0]->IsNumber()) { - value = obj->mValue | info[0]->IntegerValue(); + value = obj->mValue | Nan::To(info[0]).ToChecked(); } else if (info[0]->IsObject()) { - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); value = obj->mValue | otherObj->mValue; } else { Nan::ThrowTypeError("Object or number expected"); @@ -308,9 +306,9 @@ NAN_METHOD(Int64::Xor) { Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t value; if (info[0]->IsNumber()) { - value = obj->mValue ^ info[0]->IntegerValue(); + value = obj->mValue ^ Nan::To(info[0]).ToChecked(); } else if (info[0]->IsObject()) { - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); value = obj->mValue ^ otherObj->mValue; } else { Nan::ThrowTypeError("Object or number expected"); @@ -333,9 +331,9 @@ NAN_METHOD(Int64::Add) { Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t value; if (info[0]->IsNumber()) { - value = obj->mValue + info[0]->IntegerValue(); + value = obj->mValue + Nan::To(info[0]).ToChecked(); } else if (info[0]->IsObject()) { - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); value = obj->mValue + otherObj->mValue; } else { Nan::ThrowTypeError("Object or number expected"); @@ -358,9 +356,9 @@ NAN_METHOD(Int64::Sub) { Int64* obj = ObjectWrap::Unwrap(info.Holder()); uint64_t value; if (info[0]->IsNumber()) { - value = obj->mValue - info[0]->IntegerValue(); + value = obj->mValue - Nan::To(info[0]).ToChecked(); } else if (info[0]->IsObject()) { - Int64* otherObj = ObjectWrap::Unwrap(info[0]->ToObject()); + Int64* otherObj = ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked()); value = obj->mValue - otherObj->mValue; } else { Nan::ThrowTypeError("Object or number expected"); diff --git a/src/Int64.h b/src/Int64.h index 9973645..5787f80 100644 --- a/src/Int64.h +++ b/src/Int64.h @@ -10,7 +10,7 @@ using namespace v8; class Int64 : public Nan::ObjectWrap { public: - static void Init(Handle exports); + static NAN_MODULE_INIT(Init); private: Int64(); diff --git a/src/main.cc b/src/main.cc index 4e60d9a..5f4bd10 100644 --- a/src/main.cc +++ b/src/main.cc @@ -10,8 +10,8 @@ using namespace node; using namespace v8; -void InitAll(Handle exports) { - Int64::Init(exports); +NAN_MODULE_INIT(InitAll) { + Int64::Init(target); } NODE_MODULE(Int64, InitAll)