diff --git a/.travis.yml b/.travis.yml index 682ca1cf9..e1d7ff047 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ env: - TARGET_ARCH="ia32" node_js: + - "12" - "10" - "8" diff --git a/appveyor.yml b/appveyor.yml index 46fc6a1b5..891225fd7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,6 +26,7 @@ environment: GYP_MSVS_VERSION: 2015 matrix: # Node.js + - nodejs_version: "12" - nodejs_version: "10" - nodejs_version: "8" diff --git a/generate/templates/manual/clone/clone.cc b/generate/templates/manual/clone/clone.cc index 144be221d..a7ac262dc 100644 --- a/generate/templates/manual/clone/clone.cc +++ b/generate/templates/manual/clone/clone.cc @@ -33,7 +33,7 @@ NAN_METHOD(GitClone::Clone) { // start convert_from_v8 block const char *from_url = NULL; - String::Utf8Value url(info[0]->ToString()); + Nan::Utf8String url(Nan::To(info[0]).ToLocalChecked()); // malloc with one extra byte so we can add the terminating null character // C-strings expect: from_url = (const char *)malloc(url.length() + 1); @@ -50,7 +50,7 @@ NAN_METHOD(GitClone::Clone) { // start convert_from_v8 block const char *from_local_path = NULL; - String::Utf8Value local_path(info[1]->ToString()); + Nan::Utf8String local_path(Nan::To(info[1]).ToLocalChecked()); // malloc with one extra byte so we can add the terminating null character // C-strings expect: from_local_path = (const char *)malloc(local_path.length() + 1); @@ -67,7 +67,7 @@ NAN_METHOD(GitClone::Clone) { // start convert_from_v8 block const git_clone_options *from_options = NULL; if (info[2]->IsObject()) { - from_options = Nan::ObjectWrap::Unwrap(info[2]->ToObject()) + from_options = Nan::ObjectWrap::Unwrap(Nan::To(info[2]).ToLocalChecked()) ->GetValue(); } else { from_options = 0; @@ -80,11 +80,11 @@ NAN_METHOD(GitClone::Clone) { CloneWorker *worker = new CloneWorker(baton, callback); if (!info[0]->IsUndefined() && !info[0]->IsNull()) - worker->SaveToPersistent("url", info[0]->ToObject()); + worker->SaveToPersistent("url", Nan::To(info[0]).ToLocalChecked()); if (!info[1]->IsUndefined() && !info[1]->IsNull()) - worker->SaveToPersistent("local_path", info[1]->ToObject()); + worker->SaveToPersistent("local_path", Nan::To(info[1]).ToLocalChecked()); if (!info[2]->IsUndefined() && !info[2]->IsNull()) - worker->SaveToPersistent("options", info[2]->ToObject()); + worker->SaveToPersistent("options", Nan::To(info[2]).ToLocalChecked()); AsyncLibgit2QueueWorker(worker); return; @@ -140,12 +140,12 @@ void GitClone::CloneWorker::HandleOKCallback() { if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method clone has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method clone has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Clone.clone").ToLocalChecked()); v8::Local argv[1] = {err}; callback->Call(1, argv, async_resource); @@ -168,24 +168,24 @@ void GitClone::CloneWorker::HandleOKCallback() { continue; } - v8::Local nodeObj = node->ToObject(); + v8::Local nodeObj = Nan::To(node).ToLocalChecked(); v8::Local checkValue = GetPrivate( nodeObj, Nan::New("NodeGitPromiseError").ToLocalChecked()); if (!checkValue.IsEmpty() && !checkValue->IsNull() && !checkValue->IsUndefined()) { - v8::Local argv[1] = {checkValue->ToObject()}; + v8::Local argv[1] = {Nan::To(checkValue).ToLocalChecked()}; callback->Call(1, argv, async_resource); callbackFired = true; break; } - v8::Local properties = nodeObj->GetPropertyNames(); + v8::Local properties = Nan::GetPropertyNames(nodeObj).ToLocalChecked(); for (unsigned int propIndex = 0; propIndex < properties->Length(); ++propIndex) { v8::Local propName = - properties->Get(propIndex)->ToString(); - v8::Local nodeToQueue = nodeObj->Get(propName); + Nan::To(Nan::Get(properties, propIndex).ToLocalChecked()).ToLocalChecked(); + v8::Local nodeToQueue = Nan::Get(nodeObj, propName).ToLocalChecked(); if (!nodeToQueue->IsUndefined()) { workerArguments.push(nodeToQueue); } @@ -194,10 +194,10 @@ void GitClone::CloneWorker::HandleOKCallback() { if (!callbackFired) { v8::Local err = - Nan::Error("Method clone has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), + Nan::To(Nan::Error("Method clone has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Clone.clone").ToLocalChecked()); v8::Local argv[1] = {err}; callback->Call(1, argv, async_resource); diff --git a/generate/templates/manual/commit/extract_signature.cc b/generate/templates/manual/commit/extract_signature.cc index c17749539..e96d0cc7f 100644 --- a/generate/templates/manual/commit/extract_signature.cc +++ b/generate/templates/manual/commit/extract_signature.cc @@ -28,11 +28,11 @@ NAN_METHOD(GitCommit::ExtractSignature) baton->error = NULL; baton->signature = GIT_BUF_INIT_CONST(NULL, 0); baton->signed_data = GIT_BUF_INIT_CONST(NULL, 0); - baton->repo = Nan::ObjectWrap::Unwrap(info[0]->ToObject())->GetValue(); + baton->repo = Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked())->GetValue(); // baton->commit_id if (info[1]->IsString()) { - String::Utf8Value oidString(info[1]->ToString()); + Nan::Utf8String oidString(Nan::To(info[1]).ToLocalChecked()); baton->commit_id = (git_oid *)malloc(sizeof(git_oid)); if (git_oid_fromstr(baton->commit_id, (const char *)strdup(*oidString)) != GIT_OK) { free(baton->commit_id); @@ -44,12 +44,12 @@ NAN_METHOD(GitCommit::ExtractSignature) } } } else { - baton->commit_id = Nan::ObjectWrap::Unwrap(info[1]->ToObject())->GetValue(); + baton->commit_id = Nan::ObjectWrap::Unwrap(Nan::To(info[1]).ToLocalChecked())->GetValue(); } // baton->field if (info[2]->IsString()) { - String::Utf8Value field(info[2]->ToString()); + Nan::Utf8String field(Nan::To(info[2]).ToLocalChecked()); baton->field = (char *)malloc(field.length() + 1); memcpy((void *)baton->field, *field, field.length()); baton->field[field.length()] = 0; @@ -65,8 +65,8 @@ NAN_METHOD(GitCommit::ExtractSignature) } ExtractSignatureWorker *worker = new ExtractSignatureWorker(baton, callback); - worker->SaveToPersistent("repo", info[0]->ToObject()); - worker->SaveToPersistent("commit_id", info[1]->ToObject()); + worker->SaveToPersistent("repo", Nan::To(info[0]).ToLocalChecked()); + worker->SaveToPersistent("commit_id", Nan::To(info[1]).ToLocalChecked()); Nan::AsyncQueueWorker(worker); return; } @@ -132,9 +132,9 @@ void GitCommit::ExtractSignatureWorker::HandleOKCallback() } else if (baton->error_code < 0) { - Local err = Nan::Error("Extract Signature has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Commit.extractSignature").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Extract Signature has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Commit.extractSignature").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/filter_list/load.cc b/generate/templates/manual/filter_list/load.cc index 6075fd59c..fd02a44e6 100644 --- a/generate/templates/manual/filter_list/load.cc +++ b/generate/templates/manual/filter_list/load.cc @@ -47,14 +47,14 @@ NAN_METHOD(GitFilterList::Load) { // start convert_from_v8 block git_repository *from_repo = NULL; from_repo = - Nan::ObjectWrap::Unwrap(info[0]->ToObject())->GetValue(); + Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked())->GetValue(); // end convert_from_v8 block baton->repo = from_repo; // start convert_from_v8 block git_blob *from_blob = NULL; if (info[1]->IsObject()) { from_blob = - Nan::ObjectWrap::Unwrap(info[1]->ToObject())->GetValue(); + Nan::ObjectWrap::Unwrap(Nan::To(info[1]).ToLocalChecked())->GetValue(); } else { from_blob = 0; } @@ -63,7 +63,7 @@ NAN_METHOD(GitFilterList::Load) { // start convert_from_v8 block const char *from_path = NULL; - String::Utf8Value path(info[2]->ToString()); + Nan::Utf8String path(Nan::To(info[2]).ToLocalChecked()); // malloc with one extra byte so we can add the terminating null character // C-strings expect: from_path = (const char *)malloc(path.length() + 1); @@ -93,15 +93,15 @@ NAN_METHOD(GitFilterList::Load) { LoadWorker *worker = new LoadWorker(baton, callback); if (!info[0]->IsUndefined() && !info[0]->IsNull()) - worker->SaveToPersistent("repo", info[0]->ToObject()); + worker->SaveToPersistent("repo", Nan::To(info[0]).ToLocalChecked()); if (!info[1]->IsUndefined() && !info[1]->IsNull()) - worker->SaveToPersistent("blob", info[1]->ToObject()); + worker->SaveToPersistent("blob", Nan::To(info[1]).ToLocalChecked()); if (!info[2]->IsUndefined() && !info[2]->IsNull()) - worker->SaveToPersistent("path", info[2]->ToObject()); + worker->SaveToPersistent("path", Nan::To(info[2]).ToLocalChecked()); if (!info[3]->IsUndefined() && !info[3]->IsNull()) - worker->SaveToPersistent("mode", info[3]->ToObject()); + worker->SaveToPersistent("mode", Nan::To(info[3]).ToLocalChecked()); if (!info[4]->IsUndefined() && !info[4]->IsNull()) - worker->SaveToPersistent("flags", info[4]->ToObject()); + worker->SaveToPersistent("flags", Nan::To(info[4]).ToLocalChecked()); AsyncLibgit2QueueWorker(worker); return; @@ -134,17 +134,17 @@ void GitFilterList::LoadWorker::HandleOKCallback() { // GitFilterList baton->filters v8::Local owners = Nan::New(0); v8::Local filterRegistry = Nan::New(GitFilterRegistry::persistentHandle); - v8::Local propertyNames = filterRegistry->GetPropertyNames(); + v8::Local propertyNames = Nan::GetPropertyNames(filterRegistry).ToLocalChecked(); Nan::Set( owners, Nan::New(0), - this->GetFromPersistent("repo")->ToObject() + Nan::To(this->GetFromPersistent("repo")).ToLocalChecked() ); for (uint32_t index = 0; index < propertyNames->Length(); ++index) { - v8::Local propertyName = propertyNames->Get(index)->ToString(); - String::Utf8Value propertyNameAsUtf8Value(propertyName); + v8::Local propertyName = Nan::To(Nan::Get(propertyNames, index).ToLocalChecked()).ToLocalChecked(); + Nan::Utf8String propertyNameAsUtf8Value(propertyName); const char *propertyNameAsCString = *propertyNameAsUtf8Value; bool isNotMethodOnRegistry = strcmp("register", propertyNameAsCString) @@ -153,12 +153,12 @@ void GitFilterList::LoadWorker::HandleOKCallback() { Nan::Set( owners, Nan::New(owners->Length()), - filterRegistry->Get(propertyName) + Nan::Get(filterRegistry, propertyName).ToLocalChecked() ); } } - to = GitFilterList::New(baton->filters, true, owners->ToObject()); + to = GitFilterList::New(baton->filters, true, Nan::To(owners).ToLocalChecked()); } else { to = Nan::Null(); } @@ -172,12 +172,12 @@ void GitFilterList::LoadWorker::HandleOKCallback() { if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method load has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method load has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterList.load").ToLocalChecked()); v8::Local argv[1] = {err}; callback->Call(1, argv, async_resource); @@ -202,24 +202,24 @@ void GitFilterList::LoadWorker::HandleOKCallback() { continue; } - v8::Local nodeObj = node->ToObject(); + v8::Local nodeObj = Nan::To(node).ToLocalChecked(); v8::Local checkValue = GetPrivate( nodeObj, Nan::New("NodeGitPromiseError").ToLocalChecked()); if (!checkValue.IsEmpty() && !checkValue->IsNull() && !checkValue->IsUndefined()) { - v8::Local argv[1] = {checkValue->ToObject()}; + v8::Local argv[1] = {Nan::To(checkValue).ToLocalChecked()}; callback->Call(1, argv, async_resource); callbackFired = true; break; } - v8::Local properties = nodeObj->GetPropertyNames(); + v8::Local properties = Nan::GetPropertyNames(nodeObj).ToLocalChecked(); for (unsigned int propIndex = 0; propIndex < properties->Length(); ++propIndex) { v8::Local propName = - properties->Get(propIndex)->ToString(); - v8::Local nodeToQueue = nodeObj->Get(propName); + Nan::To(Nan::Get(properties, propIndex).ToLocalChecked()).ToLocalChecked(); + v8::Local nodeToQueue = Nan::Get(nodeObj, propName).ToLocalChecked(); if (!nodeToQueue->IsUndefined()) { workerArguments.push(nodeToQueue); } @@ -228,10 +228,10 @@ void GitFilterList::LoadWorker::HandleOKCallback() { if (!callbackFired) { v8::Local err = - Nan::Error("Method load has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), + Nan::To(Nan::Error("Method load has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterList.load").ToLocalChecked()); v8::Local argv[1] = {err}; callback->Call(1, argv, async_resource); diff --git a/generate/templates/manual/filter_source/repo.cc b/generate/templates/manual/filter_source/repo.cc index cf9c1a833..57c2a07f7 100644 --- a/generate/templates/manual/filter_source/repo.cc +++ b/generate/templates/manual/filter_source/repo.cc @@ -60,12 +60,12 @@ void GitFilterSource::RepoWorker::HandleOKCallback() { if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method repo has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method repo has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterSource.repo").ToLocalChecked()); v8::Local argv[1] = {err}; callback->Call(1, argv, async_resource); @@ -74,10 +74,10 @@ void GitFilterSource::RepoWorker::HandleOKCallback() { free((void *)baton->error); } else if (baton->error_code < 0) { v8::Local err = - Nan::Error("Method repo has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), + Nan::To(Nan::Error("Method repo has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterSource.repo").ToLocalChecked()); v8::Local argv[1] = {err}; callback->Call(1, argv, async_resource); diff --git a/generate/templates/manual/include/str_array_converter.h b/generate/templates/manual/include/str_array_converter.h index 37f1bcc1d..26a82479d 100644 --- a/generate/templates/manual/include/str_array_converter.h +++ b/generate/templates/manual/include/str_array_converter.h @@ -14,8 +14,8 @@ class StrArrayConverter { static git_strarray *Convert (v8::Local val); private: - static git_strarray *ConvertArray(Array *val); - static git_strarray *ConvertString(v8::Local val); + static git_strarray *ConvertArray(v8::Local val); + static git_strarray *ConvertString(v8::Local val); static git_strarray *AllocStrArray(const size_t count); static git_strarray *ConstructStrArray(int argc, char** argv); }; diff --git a/generate/templates/manual/patches/convenient_patches.cc b/generate/templates/manual/patches/convenient_patches.cc index cc108a8ae..795dca506 100644 --- a/generate/templates/manual/patches/convenient_patches.cc +++ b/generate/templates/manual/patches/convenient_patches.cc @@ -12,7 +12,7 @@ NAN_METHOD(GitPatch::ConvenientFromDiff) { baton->error_code = GIT_OK; baton->error = NULL; - baton->diff = Nan::ObjectWrap::Unwrap(info[0]->ToObject())->GetValue(); + baton->diff = Nan::ObjectWrap::Unwrap(Nan::To(info[0]).ToLocalChecked())->GetValue(); baton->out = new std::vector; baton->out->reserve(git_diff_num_deltas(baton->diff)); @@ -97,12 +97,12 @@ void GitPatch::ConvenientFromDiffWorker::HandleOKCallback() { if (baton->error) { Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method convenientFromDiff has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method convenientFromDiff has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Patch.convenientFromDiff").ToLocalChecked()); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Patch.convenientFromDiff").ToLocalChecked()); Local argv[1] = { err }; @@ -118,9 +118,9 @@ void GitPatch::ConvenientFromDiffWorker::HandleOKCallback() { } if (baton->error_code < 0) { - Local err = Nan::Error("method convenientFromDiff has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Patch.convenientFromDiff").ToLocalChecked()); + Local err = Nan::To(Nan::Error("method convenientFromDiff has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Patch.convenientFromDiff").ToLocalChecked()); Local argv[1] = { err }; @@ -129,5 +129,5 @@ void GitPatch::ConvenientFromDiffWorker::HandleOKCallback() { return; } - callback->Call(0, NULL); + Nan::Call(*callback, 0, NULL); } diff --git a/generate/templates/manual/remote/ls.cc b/generate/templates/manual/remote/ls.cc index f81728256..8816e0150 100644 --- a/generate/templates/manual/remote/ls.cc +++ b/generate/templates/manual/remote/ls.cc @@ -85,9 +85,9 @@ void GitRemote::ReferenceListWorker::HandleOKCallback() } else if (baton->error_code < 0) { - Local err = Nan::Error("Reference List has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Remote.referenceList").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Reference List has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Remote.referenceList").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/repository/get_references.cc b/generate/templates/manual/repository/get_references.cc index d0e4fd987..8f03d60e1 100644 --- a/generate/templates/manual/repository/get_references.cc +++ b/generate/templates/manual/repository/get_references.cc @@ -90,7 +90,7 @@ void GitRepository::GetReferencesWorker::HandleOKCallback() GitRefs::New( reference, true, - GitRepository::New(git_reference_owner(reference), true)->ToObject() + Nan::To(GitRepository::New(git_reference_owner(reference), true)).ToLocalChecked() ) ); } @@ -118,9 +118,9 @@ void GitRepository::GetReferencesWorker::HandleOKCallback() } else if (baton->error_code < 0) { - Local err = Nan::Error("Repository getReferences has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.getReferences").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Repository getReferences has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.getReferences").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/repository/get_remotes.cc b/generate/templates/manual/repository/get_remotes.cc index e16f1131c..9cad189a2 100644 --- a/generate/templates/manual/repository/get_remotes.cc +++ b/generate/templates/manual/repository/get_remotes.cc @@ -91,7 +91,7 @@ void GitRepository::GetRemotesWorker::HandleOKCallback() GitRemote::New( remote, true, - GitRepository::New(git_remote_owner(remote), true)->ToObject() + Nan::To(GitRepository::New(git_remote_owner(remote), true)).ToLocalChecked() ) ); } @@ -119,9 +119,9 @@ void GitRepository::GetRemotesWorker::HandleOKCallback() } else if (baton->error_code < 0) { - Local err = Nan::Error("Repository refreshRemotes has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.refreshRemotes").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Repository refreshRemotes has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.refreshRemotes").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/repository/get_submodules.cc b/generate/templates/manual/repository/get_submodules.cc index d51d0a0fd..71de6948c 100644 --- a/generate/templates/manual/repository/get_submodules.cc +++ b/generate/templates/manual/repository/get_submodules.cc @@ -72,7 +72,7 @@ void GitRepository::GetSubmodulesWorker::HandleOKCallback() GitSubmodule::New( submodule, true, - GitRepository::New(git_submodule_owner(submodule), true)->ToObject() + Nan::To(GitRepository::New(git_submodule_owner(submodule), true)).ToLocalChecked() ) ); } @@ -100,9 +100,9 @@ void GitRepository::GetSubmodulesWorker::HandleOKCallback() } else if (baton->error_code < 0) { - Local err = Nan::Error("Repository getSubmodules has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.getSubmodules").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Repository getSubmodules has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.getSubmodules").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/repository/refresh_references.cc b/generate/templates/manual/repository/refresh_references.cc index 65548812c..8d0fe36d6 100644 --- a/generate/templates/manual/repository/refresh_references.cc +++ b/generate/templates/manual/repository/refresh_references.cc @@ -206,7 +206,7 @@ class RefreshedRefModel { // the destructor didn't double free, but that still segfaulted internally in Node. v8::Local buffer = Nan::CopyBuffer(tagOdbBuffer, tagOdbBufferLength).ToLocalChecked(); v8::Local toStringProp = Nan::Get(buffer, Nan::New("toString").ToLocalChecked()).ToLocalChecked(); - v8::Local jsTagOdbObjectString = Nan::CallAsFunction(toStringProp->ToObject(), buffer, 0, NULL).ToLocalChecked()->ToObject(); + v8::Local jsTagOdbObjectString = Nan::To(Nan::CallAsFunction(Nan::To(toStringProp).ToLocalChecked(), buffer, 0, NULL).ToLocalChecked()).ToLocalChecked(); v8::Local _signatureRegexesBySignatureType = Nan::New(signatureRegexesBySignatureType); v8::Local signatureRegexes = v8::Local::Cast(Nan::Get(_signatureRegexesBySignatureType, signatureType).ToLocalChecked()); @@ -217,9 +217,9 @@ class RefreshedRefModel { }; v8::Local matchProp = Nan::Get(jsTagOdbObjectString, Nan::New("match").ToLocalChecked()).ToLocalChecked(); - v8::Local match = Nan::CallAsFunction(matchProp->ToObject(), jsTagOdbObjectString, 1, argv).ToLocalChecked(); + v8::Local match = Nan::CallAsFunction(Nan::To(matchProp).ToLocalChecked(), jsTagOdbObjectString, 1, argv).ToLocalChecked(); if (match->IsArray()) { - jsTagSignature = Nan::Get(match->ToObject(), 0).ToLocalChecked(); + jsTagSignature = Nan::Get(Nan::To(match).ToLocalChecked(), 0).ToLocalChecked(); break; } } @@ -379,7 +379,7 @@ NAN_METHOD(GitRepository::RefreshReferences) return Nan::ThrowError("Signature type must be \"gpgsig\" or \"x509\"."); } - v8::Local signatureTypeParam = info[0]->ToString(); + v8::Local signatureTypeParam = Nan::To(info[0]).ToLocalChecked(); if ( Nan::Equals(signatureTypeParam, Nan::New("gpgsig").ToLocalChecked()) != Nan::Just(true) && Nan::Equals(signatureTypeParam, Nan::New("x509").ToLocalChecked()) != Nan::Just(true) @@ -611,7 +611,7 @@ void GitRepository::RefreshReferencesWorker::HandleOKCallback() Nan::New(refreshData->headRefFullName).ToLocalChecked() ); - v8::Local signatureType = GetFromPersistent("signatureType")->ToString(); + v8::Local signatureType = Nan::To(GetFromPersistent("signatureType")).ToLocalChecked(); unsigned int numRefs = refreshData->refs.size(); v8::Local refs = Nan::New(numRefs); @@ -672,9 +672,9 @@ void GitRepository::RefreshReferencesWorker::HandleOKCallback() } else if (baton->error_code < 0) { - Local err = Nan::Error("Repository refreshReferences has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.refreshReferences").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Repository refreshReferences has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Repository.refreshReferences").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/revwalk/commit_walk.cc b/generate/templates/manual/revwalk/commit_walk.cc index af0ff112a..91fe7f38c 100644 --- a/generate/templates/manual/revwalk/commit_walk.cc +++ b/generate/templates/manual/revwalk/commit_walk.cc @@ -87,7 +87,7 @@ void GitRevwalk::CommitWalkWorker::HandleOKCallback() { GitCommit::New( commit, true, - GitRepository::New(git_commit_owner(commit), true)->ToObject() + Nan::To(GitRepository::New(git_commit_owner(commit), true)).ToLocalChecked() ) ); } @@ -110,9 +110,9 @@ void GitRevwalk::CommitWalkWorker::HandleOKCallback() { free((void *)baton->error); } else if (baton->error_code < 0) { - Local err = Nan::Error("Revwalk commitWalk has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.commitWalk").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Revwalk commitWalk has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.commitWalk").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/revwalk/fast_walk.cc b/generate/templates/manual/revwalk/fast_walk.cc index fbf5c09b5..002251852 100644 --- a/generate/templates/manual/revwalk/fast_walk.cc +++ b/generate/templates/manual/revwalk/fast_walk.cc @@ -90,12 +90,12 @@ void GitRevwalk::FastWalkWorker::HandleOKCallback() { Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method fastWalk has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method fastWalk has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fastWalk").ToLocalChecked()); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fastWalk").ToLocalChecked()); Local argv[1] = { err }; @@ -131,24 +131,24 @@ void GitRevwalk::FastWalkWorker::HandleOKCallback() continue; } - Local nodeObj = node->ToObject(); + Local nodeObj = Nan::To(node).ToLocalChecked(); Local checkValue = GetPrivate(nodeObj, Nan::New("NodeGitPromiseError").ToLocalChecked()); if (!checkValue.IsEmpty() && !checkValue->IsNull() && !checkValue->IsUndefined()) { Local argv[1] = { - checkValue->ToObject() + Nan::To(checkValue).ToLocalChecked() }; callback->Call(1, argv, async_resource); callbackFired = true; break; } - Local properties = nodeObj->GetPropertyNames(); + Local properties = Nan::GetPropertyNames(nodeObj).ToLocalChecked(); for (unsigned int propIndex = 0; propIndex < properties->Length(); ++propIndex) { - Local propName = properties->Get(propIndex)->ToString(); - Local nodeToQueue = nodeObj->Get(propName); + Local propName = Nan::To(Nan::Get(properties, propIndex).ToLocalChecked()).ToLocalChecked(); + Local nodeToQueue = Nan::Get(nodeObj, propName).ToLocalChecked(); if (!nodeToQueue->IsUndefined()) { workerArguments.push(nodeToQueue); @@ -158,9 +158,9 @@ void GitRevwalk::FastWalkWorker::HandleOKCallback() if (!callbackFired) { - Local err = Nan::Error("Method next has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fastWalk").ToLocalChecked()); + Local err = Nan::To(Nan::Error("Method next has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fastWalk").ToLocalChecked()); Local argv[1] = { err }; diff --git a/generate/templates/manual/revwalk/file_history_walk.cc b/generate/templates/manual/revwalk/file_history_walk.cc index 49c23445e..d8d2935df 100644 --- a/generate/templates/manual/revwalk/file_history_walk.cc +++ b/generate/templates/manual/revwalk/file_history_walk.cc @@ -34,10 +34,10 @@ class FileHistoryEvent { Nan::Set( owners, Nan::New(owners->Length()), - GitRepository::New( + Nan::To(GitRepository::New( git_commit_owner(commit), true - )->ToObject() + )).ToLocalChecked() ); Nan::Set(historyEntry, Nan::New("commit").ToLocalChecked(), GitCommit::New(commit, true, owners)); commit = NULL; @@ -196,7 +196,7 @@ NAN_METHOD(GitRevwalk::FileHistoryWalk) baton->error_code = GIT_OK; baton->error = NULL; - String::Utf8Value from_js_file_path(info[0]->ToString()); + Nan::Utf8String from_js_file_path(Nan::To(info[0]).ToLocalChecked()); baton->file_path = strdup(*from_js_file_path); baton->max_count = Nan::To(info[1]).FromJust(); baton->out = new std::vector; @@ -444,12 +444,12 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback() if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method fileHistoryWalk has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method fileHistoryWalk has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fileHistoryWalk").ToLocalChecked()); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fileHistoryWalk").ToLocalChecked()); v8::Local argv[1] = { err }; @@ -464,9 +464,9 @@ void GitRevwalk::FileHistoryWalkWorker::HandleOKCallback() } if (baton->error_code < 0) { - v8::Local err = Nan::Error("Method next has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fileHistoryWalk").ToLocalChecked()); + v8::Local err = Nan::To(Nan::Error("Method next has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("Revwalk.fileHistoryWalk").ToLocalChecked()); v8::Local argv[1] = { err }; diff --git a/generate/templates/manual/src/filter_registry.cc b/generate/templates/manual/src/filter_registry.cc index 410255289..67e958d03 100644 --- a/generate/templates/manual/src/filter_registry.cc +++ b/generate/templates/manual/src/filter_registry.cc @@ -54,8 +54,8 @@ NAN_METHOD(GitFilterRegistry::GitFilterRegister) { FilterRegisterBaton *baton = new FilterRegisterBaton; - baton->filter = Nan::ObjectWrap::Unwrap(info[1]->ToObject())->GetValue(); - String::Utf8Value name(info[0]->ToString()); + baton->filter = Nan::ObjectWrap::Unwrap(Nan::To(info[1]).ToLocalChecked())->GetValue(); + Nan::Utf8String name(Nan::To(info[0]).ToLocalChecked()); baton->filter_name = (char *)malloc(name.length() + 1); memcpy((void *)baton->filter_name, *name, name.length()); @@ -64,13 +64,13 @@ NAN_METHOD(GitFilterRegistry::GitFilterRegister) { baton->error_code = GIT_OK; baton->filter_priority = Nan::To(info[2]).FromJust(); - Nan::New(GitFilterRegistry::persistentHandle)->Set(info[0]->ToString(), info[1]->ToObject()); + Nan::Set(Nan::New(GitFilterRegistry::persistentHandle), Nan::To(info[0]).ToLocalChecked(), Nan::To(info[1]).ToLocalChecked()); Nan::Callback *callback = new Nan::Callback(Local::Cast(info[3])); RegisterWorker *worker = new RegisterWorker(baton, callback); - worker->SaveToPersistent("filter_name", info[0]->ToObject()); - worker->SaveToPersistent("filter_priority", info[2]->ToObject()); + worker->SaveToPersistent("filter_name", Nan::To(info[0]).ToLocalChecked()); + worker->SaveToPersistent("filter_priority", Nan::To(info[2]).ToLocalChecked()); AsyncLibgit2QueueWorker(worker); return; @@ -102,12 +102,12 @@ void GitFilterRegistry::RegisterWorker::HandleOKCallback() { else if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method register has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method register has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.register").ToLocalChecked()); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.register").ToLocalChecked()); v8::Local argv[1] = { err }; @@ -117,9 +117,9 @@ void GitFilterRegistry::RegisterWorker::HandleOKCallback() { free((void *)baton->error); } else if (baton->error_code < 0) { - v8::Local err = Nan::Error("Method register has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.register").ToLocalChecked()); + v8::Local err = Nan::To(Nan::Error("Method register has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.register").ToLocalChecked()); v8::Local argv[1] = { err }; @@ -144,7 +144,7 @@ NAN_METHOD(GitFilterRegistry::GitFilterUnregister) { } FilterUnregisterBaton *baton = new FilterUnregisterBaton; - String::Utf8Value name(info[0]->ToString()); + Nan::Utf8String name(Nan::To(info[0]).ToLocalChecked()); baton->filter_name = (char *)malloc(name.length() + 1); memcpy((void *)baton->filter_name, *name, name.length()); @@ -188,12 +188,12 @@ void GitFilterRegistry::UnregisterWorker::HandleOKCallback() { else if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method register has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method register has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.unregister").ToLocalChecked()); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.unregister").ToLocalChecked()); v8::Local argv[1] = { err }; @@ -203,9 +203,9 @@ void GitFilterRegistry::UnregisterWorker::HandleOKCallback() { free((void *)baton->error); } else if (baton->error_code < 0) { - v8::Local err = Nan::Error("Method unregister has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.unregister").ToLocalChecked()); + v8::Local err = Nan::To(Nan::Error("Method unregister has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("FilterRegistry.unregister").ToLocalChecked()); v8::Local argv[1] = { err }; diff --git a/generate/templates/manual/src/git_buf_converter.cc b/generate/templates/manual/src/git_buf_converter.cc index 0c1969504..1558d39fe 100644 --- a/generate/templates/manual/src/git_buf_converter.cc +++ b/generate/templates/manual/src/git_buf_converter.cc @@ -10,7 +10,7 @@ using namespace node; git_buf *GitBufConverter::Convert(Local val) { if (val->IsString() || val->IsStringObject()) { - v8::String::Utf8Value param1(val->ToString()); + Nan::Utf8String param1(Nan::To(val).ToLocalChecked()); std::string v8String = std::string(*param1); const size_t size = sizeof(git_buf); diff --git a/generate/templates/manual/src/nodegit_wrapper.cc b/generate/templates/manual/src/nodegit_wrapper.cc index 26ead60da..69aed4f94 100644 --- a/generate/templates/manual/src/nodegit_wrapper.cc +++ b/generate/templates/manual/src/nodegit_wrapper.cc @@ -67,7 +67,7 @@ NAN_METHOD(NodeGitWrapper::JSNewFunction) { instance = new cppClass(static_cast( Local::Cast(info[0])->Value()), Nan::To(info[1]).FromJust(), - info.Length() >= 3 && !info[2].IsEmpty() && info[2]->IsObject() ? info[2]->ToObject() : Local() + info.Length() >= 3 && !info[2].IsEmpty() && info[2]->IsObject() ? Nan::To(info[2]).ToLocalChecked() : Local() ); } diff --git a/generate/templates/manual/src/promise_completion.cc b/generate/templates/manual/src/promise_completion.cc index fd34dfa77..22203b41d 100644 --- a/generate/templates/manual/src/promise_completion.cc +++ b/generate/templates/manual/src/promise_completion.cc @@ -9,10 +9,10 @@ Nan::Persistent PromiseCompletion::promiseRejected; void PromiseCompletion::InitializeComponent() { v8::Local newTemplate = Nan::New(New); newTemplate->InstanceTemplate()->SetInternalFieldCount(1); - newFn.Reset(newTemplate->GetFunction()); + newFn.Reset(Nan::GetFunction(newTemplate).ToLocalChecked()); - promiseFulfilled.Reset(Nan::New(PromiseFulfilled)->GetFunction()); - promiseRejected.Reset(Nan::New(PromiseRejected)->GetFunction()); + promiseFulfilled.Reset(Nan::GetFunction(Nan::New(PromiseFulfilled)).ToLocalChecked()); + promiseRejected.Reset(Nan::GetFunction(Nan::New(PromiseRejected)).ToLocalChecked()); } bool PromiseCompletion::ForwardIfPromise(v8::Local result, AsyncBaton *baton, Callback callback) @@ -21,7 +21,7 @@ bool PromiseCompletion::ForwardIfPromise(v8::Local result, AsyncBaton // check if the result is a promise if (!result.IsEmpty() && result->IsObject()) { - Nan::MaybeLocal maybeThenProp = Nan::Get(result->ToObject(), Nan::New("then").ToLocalChecked()); + Nan::MaybeLocal maybeThenProp = Nan::Get(Nan::To(result).ToLocalChecked(), Nan::New("then").ToLocalChecked()); if (!maybeThenProp.IsEmpty()) { v8::Local thenProp = maybeThenProp.ToLocalChecked(); if(thenProp->IsFunction()) { @@ -54,7 +54,7 @@ void PromiseCompletion::Setup(v8::Local thenFn, v8::Localcallback = callback; this->baton = baton; - v8::Local promise = result->ToObject(); + v8::Local promise = Nan::To(result).ToLocalChecked(); v8::Local thisHandle = handle(); @@ -64,7 +64,7 @@ void PromiseCompletion::Setup(v8::Local thenFn, v8::Local PromiseCompletion::Bind(Nan::Persistent &func v8::Local argv[1] = { object }; - return scope.Escape(bind->Call(Nan::New(function), 1, argv)); + return scope.Escape(Nan::Call(bind, Nan::To(Nan::New(function)).ToLocalChecked(), 1, argv).ToLocalChecked()); } // calls the callback stored in the PromiseCompletion, passing the baton that @@ -90,7 +90,7 @@ void PromiseCompletion::CallCallback(bool isFulfilled, const Nan::FunctionCallba resultOfPromise = info[0]; } - PromiseCompletion *promiseCompletion = ObjectWrap::Unwrap(info.This()->ToObject()); + PromiseCompletion *promiseCompletion = ObjectWrap::Unwrap(Nan::To(info.This()).ToLocalChecked()); (*promiseCompletion->callback)(isFulfilled, promiseCompletion->baton, resultOfPromise); } diff --git a/generate/templates/manual/src/str_array_converter.cc b/generate/templates/manual/src/str_array_converter.cc index c66f901c3..eb75aa41d 100644 --- a/generate/templates/manual/src/str_array_converter.cc +++ b/generate/templates/manual/src/str_array_converter.cc @@ -9,15 +9,15 @@ using namespace v8; using namespace node; -git_strarray *StrArrayConverter::Convert(Local val) { - if (!val->BooleanValue()) { +git_strarray *StrArrayConverter::Convert(v8::Local val) { + if (!Nan::To(val).FromJust()) { return NULL; } else if (val->IsArray()) { - return ConvertArray(Array::Cast(*val)); + return ConvertArray(v8::Local::Cast(val)); } else if (val->IsString() || val->IsStringObject()) { - return ConvertString(val->ToString()); + return ConvertString(Nan::To(val).ToLocalChecked()); } else { return NULL; @@ -33,18 +33,18 @@ git_strarray * StrArrayConverter::AllocStrArray(const size_t count) { return result; } -git_strarray *StrArrayConverter::ConvertArray(Array *val) { +git_strarray *StrArrayConverter::ConvertArray(v8::Local val) { git_strarray *result = AllocStrArray(val->Length()); for(size_t i = 0; i < result->count; i++) { - Nan::Utf8String entry(val->Get(i)); + Nan::Utf8String entry(Nan::Get(val, i).ToLocalChecked()); result->strings[i] = strdup(*entry); } return result; } -git_strarray* StrArrayConverter::ConvertString(Local val) { +git_strarray* StrArrayConverter::ConvertString(v8::Local val) { char *strings[1]; Nan::Utf8String utf8String(val); diff --git a/generate/templates/partials/async_function.cc b/generate/templates/partials/async_function.cc index 2fe854bec..9a1ce26fe 100644 --- a/generate/templates/partials/async_function.cc +++ b/generate/templates/partials/async_function.cc @@ -69,7 +69,7 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) { worker->SaveToPersistent("{{ arg.name }}", info.This()); {%elsif not arg.isCallbackFunction %} if (!info[{{ arg.jsArg }}]->IsUndefined() && !info[{{ arg.jsArg }}]->IsNull()) - worker->SaveToPersistent("{{ arg.name }}", info[{{ arg.jsArg }}]->ToObject()); + worker->SaveToPersistent("{{ arg.name }}", Nan::To(info[{{ arg.jsArg }}]).ToLocalChecked()); {%endif%} {%endif%} {%endeach%} @@ -163,12 +163,12 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() { if (baton->error) { v8::Local err; if (baton->error->message) { - err = Nan::Error(baton->error->message)->ToObject(); + err = Nan::To(Nan::Error(baton->error->message)).ToLocalChecked(); } else { - err = Nan::Error("Method {{ jsFunctionName }} has thrown an error.")->ToObject(); + err = Nan::To(Nan::Error("Method {{ jsFunctionName }} has thrown an error.")).ToLocalChecked(); } - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("{{ jsClassName }}.{{ jsFunctionName }}").ToLocalChecked()); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("{{ jsClassName }}.{{ jsFunctionName }}").ToLocalChecked()); v8::Local argv[1] = { err }; @@ -205,22 +205,22 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() { continue; } - v8::Local nodeObj = node->ToObject(); + v8::Local nodeObj = Nan::To(node).ToLocalChecked(); v8::Local checkValue = GetPrivate(nodeObj, Nan::New("NodeGitPromiseError").ToLocalChecked()); if (!checkValue.IsEmpty() && !checkValue->IsNull() && !checkValue->IsUndefined()) { v8::Local argv[1] = { - checkValue->ToObject() + Nan::To(checkValue).ToLocalChecked() }; callback->Call(1, argv, async_resource); callbackFired = true; break; } - v8::Local properties = nodeObj->GetPropertyNames(); + v8::Local properties = Nan::GetPropertyNames(nodeObj).ToLocalChecked(); for (unsigned int propIndex = 0; propIndex < properties->Length(); ++propIndex) { - v8::Local propName = properties->Get(propIndex)->ToString(); - v8::Local nodeToQueue = nodeObj->Get(propName); + v8::Local propName = Nan::To(Nan::Get(properties, propIndex).ToLocalChecked()).ToLocalChecked(); + v8::Local nodeToQueue = Nan::Get(nodeObj, propName).ToLocalChecked(); if (!nodeToQueue->IsUndefined()) { workerArguments.push(nodeToQueue); } @@ -228,9 +228,9 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() { } if (!callbackFired) { - v8::Local err = Nan::Error("Method {{ jsFunctionName }} has thrown an error.")->ToObject(); - err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); - err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("{{ jsClassName }}.{{ jsFunctionName }}").ToLocalChecked()); + v8::Local err = Nan::To(Nan::Error("Method {{ jsFunctionName }} has thrown an error.")).ToLocalChecked(); + Nan::Set(err, Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + Nan::Set(err, Nan::New("errorFunction").ToLocalChecked(), Nan::New("{{ jsClassName }}.{{ jsFunctionName }}").ToLocalChecked()); v8::Local argv[1] = { err }; diff --git a/generate/templates/partials/callback_helpers.cc b/generate/templates/partials/callback_helpers.cc index 7a40aed25..c3810371c 100644 --- a/generate/templates/partials/callback_helpers.cc +++ b/generate/templates/partials/callback_helpers.cc @@ -66,7 +66,7 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_async(void } else if (!result->IsNull() && !result->IsUndefined()) { {% if _return.isOutParam %} - {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject()); + {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(Nan::To(result).ToLocalChecked()); wrapper->selfFreeing = false; *baton->{{ _return.name }} = wrapper->GetValue(); @@ -100,7 +100,7 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_promiseComp } else if (!result->IsNull() && !result->IsUndefined()) { {% if _return.isOutParam %} - {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject()); + {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(Nan::To(result).ToLocalChecked()); wrapper->selfFreeing = false; *baton->{{ _return.name }} = wrapper->GetValue(); diff --git a/generate/templates/partials/convert_from_v8.cc b/generate/templates/partials/convert_from_v8.cc index c1486d5a6..7fc74a29b 100644 --- a/generate/templates/partials/convert_from_v8.cc +++ b/generate/templates/partials/convert_from_v8.cc @@ -19,7 +19,7 @@ {%endif%} {%if cppClassName == 'String'%} - String::Utf8Value {{ name }}(info[{{ jsArg }}]->ToString()); + Nan::Utf8String {{ name }}(Nan::To(info[{{ jsArg }}]).ToLocalChecked()); // malloc with one extra byte so we can add the terminating null character C-strings expect: from_{{ name }} = ({{ cType }}) malloc({{ name }}.length() + 1); // copy the characters from the nodejs string into our C-string (used instead of strdup or strcpy because nulls in @@ -36,7 +36,7 @@ from_{{ name }} = GitBufConverter::Convert(info[{{ jsArg }}]); {%elsif cppClassName == 'Wrapper'%} - String::Utf8Value {{ name }}(info[{{ jsArg }}]->ToString()); + Nan::Utf8String {{ name }}(Nan::To(info[{{ jsArg }}]).ToLocalChecked()); // malloc with one extra byte so we can add the terminating null character C-strings expect: from_{{ name }} = ({{ cType }}) malloc({{ name }}.length() + 1); // copy the characters from the nodejs string into our C-string (used instead of strdup or strcpy because nulls in @@ -47,18 +47,18 @@ memset((void *)(((char *)from_{{ name }}) + {{ name }}.length()), 0, 1); {%elsif cppClassName == 'Array'%} - Array *tmp_{{ name }} = Array::Cast(*info[{{ jsArg }}]); + v8::Local tmp_{{ name }} = v8::Local::Cast(info[{{ jsArg }}]); from_{{ name }} = ({{ cType }})malloc(tmp_{{ name }}->Length() * sizeof({{ cType|replace '**' '*' }})); for (unsigned int i = 0; i < tmp_{{ name }}->Length(); i++) { {%-- // FIXME: should recursively call convertFromv8. --%} - from_{{ name }}[i] = Nan::ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(tmp_{{ name }}->Get(Nan::New(static_cast(i)))->ToObject())->GetValue(); + from_{{ name }}[i] = Nan::ObjectWrap::Unwrap<{{ arrayElementCppClassName }}>(Nan::To(Nan::Get(tmp_{{ name }}, Nan::New(static_cast(i))).ToLocalChecked()).ToLocalChecked())->GetValue(); } {%elsif cppClassName == 'Function'%} {%elsif cppClassName == 'Buffer'%} - from_{{ name }} = Buffer::Data(info[{{ jsArg }}]->ToObject()); + from_{{ name }} = Buffer::Data(Nan::To(info[{{ jsArg }}]).ToLocalChecked()); {%elsif cppClassName|isV8Value %} {%if cType|isPointer %} @@ -69,7 +69,7 @@ {%elsif cppClassName == 'GitOid'%} if (info[{{ jsArg }}]->IsString()) { // Try and parse in a string to a git_oid - String::Utf8Value oidString(info[{{ jsArg }}]->ToString()); + Nan::Utf8String oidString(Nan::To(info[{{ jsArg }}]).ToLocalChecked()); git_oid *oidOut = (git_oid *)malloc(sizeof(git_oid)); if (git_oid_fromstr(oidOut, (const char *) strdup(*oidString)) != GIT_OK) { @@ -89,10 +89,10 @@ {%endif%} } else { - {%if cType|isDoublePointer %}*{%endif%}from_{{ name }} = Nan::ObjectWrap::Unwrap<{{ cppClassName }}>(info[{{ jsArg }}]->ToObject())->GetValue(); + {%if cType|isDoublePointer %}*{%endif%}from_{{ name }} = Nan::ObjectWrap::Unwrap<{{ cppClassName }}>(Nan::To(info[{{ jsArg }}]).ToLocalChecked())->GetValue(); } {%else%} - {%if cType|isDoublePointer %}*{%endif%}from_{{ name }} = Nan::ObjectWrap::Unwrap<{{ cppClassName }}>(info[{{ jsArg }}]->ToObject())->GetValue(); + {%if cType|isDoublePointer %}*{%endif%}from_{{ name }} = Nan::ObjectWrap::Unwrap<{{ cppClassName }}>(Nan::To(info[{{ jsArg }}]).ToLocalChecked())->GetValue(); {%endif%} {%if isBoolean %} diff --git a/generate/templates/partials/convert_to_v8.cc b/generate/templates/partials/convert_to_v8.cc index 1227932a6..a7a251938 100644 --- a/generate/templates/partials/convert_to_v8.cc +++ b/generate/templates/partials/convert_to_v8.cc @@ -79,11 +79,11 @@ {% if isAsync %} {% each ownedBy as owner %} {%-- If the owner of this object is "this" in an async method, it will be stored in the persistent handle by name. --%} - Nan::Set(owners, Nan::New(owners->Length()), this->GetFromPersistent("{{= owner =}}")->ToObject()); + Nan::Set(owners, Nan::New(owners->Length()), Nan::To(this->GetFromPersistent("{{= owner =}}")).ToLocalChecked()); {% endeach %} {% else %} {% each ownedByIndices as ownedByIndex %} - Nan::Set(owners, Nan::New(owners->Length()), info[{{= ownedByIndex =}}]->ToObject()); + Nan::Set(owners, Nan::New(owners->Length()), Nan::To(info[{{= ownedByIndex =}}]).ToLocalChecked()); {% endeach %} {% endif %} {% endif %} @@ -96,10 +96,10 @@ Nan::Set( owners, Nan::New(owners->Length()), - {{= ownerFn.singletonCppClassName =}}::New( + Nan::To({{= ownerFn.singletonCppClassName =}}::New( {{= ownerFn.name =}}({{ cType|asElementPointer parsedName }}), true - )->ToObject() + )).ToLocalChecked() ); {% endif %} {% endif %} diff --git a/generate/templates/partials/field_accessors.cc b/generate/templates/partials/field_accessors.cc index 222034150..35b583bdc 100644 --- a/generate/templates/partials/field_accessors.cc +++ b/generate/templates/partials/field_accessors.cc @@ -39,11 +39,11 @@ } {% elsif field.isLibgitType %} - v8::Local {{ field.name }}(value->ToObject()); + v8::Local {{ field.name }}(Nan::To(value).ToLocalChecked()); wrapper->{{ field.name }}.Reset({{ field.name }}); - wrapper->raw->{{ field.name }} = {% if not field.cType | isPointer %}*{% endif %}{% if field.cppClassName == 'GitStrarray' %}StrArrayConverter::Convert({{ field.name }}->ToObject()){% else %}Nan::ObjectWrap::Unwrap<{{ field.cppClassName }}>({{ field.name }}->ToObject())->GetValue(){% endif %}; + wrapper->raw->{{ field.name }} = {% if not field.cType | isPointer %}*{% endif %}{% if field.cppClassName == 'GitStrarray' %}StrArrayConverter::Convert(Nan::To({{ field.name }}).ToLocalChecked()){% else %}Nan::ObjectWrap::Unwrap<{{ field.cppClassName }}>(Nan::To({{ field.name }}).ToLocalChecked())->GetValue(){% endif %}; {% elsif field.isCallbackFunction %} Nan::Callback *callback = NULL; @@ -72,7 +72,7 @@ Nan::MaybeLocal maybeObjectWaitForResult = Nan::Get(object, Nan::New("waitForResult").ToLocalChecked()); if(!maybeObjectWaitForResult.IsEmpty()) { Local objectWaitForResult = maybeObjectWaitForResult.ToLocalChecked(); - waitForResult = (bool)objectWaitForResult->BooleanValue(); + waitForResult = Nan::To(objectWaitForResult).FromJust(); } } } @@ -92,7 +92,7 @@ if (wrapper->GetValue()->{{ field.name }}) { } - String::Utf8Value str(value); + Nan::Utf8String str(value); wrapper->GetValue()->{{ field.name }} = strdup(*str); {% elsif field.isCppClassIntType %} @@ -225,7 +225,7 @@ } else if (!result->IsNull() && !result->IsUndefined()) { {% if _return.isOutParam %} - {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject()); + {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(Nan::To(result).ToLocalChecked()); wrapper->selfFreeing = false; *baton->{{ _return.name }} = wrapper->GetValue(); @@ -261,7 +261,7 @@ } else if (!result->IsNull() && !result->IsUndefined()) { {% if _return.isOutParam %} - {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject()); + {{ _return.cppClassName }}* wrapper = Nan::ObjectWrap::Unwrap<{{ _return.cppClassName }}>(Nan::To(result).ToLocalChecked()); wrapper->selfFreeing = false; *baton->{{ _return.name }} = wrapper->GetValue(); diff --git a/generate/templates/partials/sync_function.cc b/generate/templates/partials/sync_function.cc index 89bb2e2dc..4a76463ed 100644 --- a/generate/templates/partials/sync_function.cc +++ b/generate/templates/partials/sync_function.cc @@ -17,7 +17,7 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) { {%if not arg.isReturn %} {%partial convertFromV8 arg %} {%if arg.saveArg %} - v8::Local {{ arg.name }}(info[{{ arg.jsArg }}]->ToObject()); + v8::Local {{ arg.name }}(Nan::To(info[{{ arg.jsArg }}]).ToLocalChecked()); {{ cppClassName }} *thisObj = Nan::ObjectWrap::Unwrap<{{ cppClassName }}>(info.This()); thisObj->{{ cppFunctionName }}_{{ arg.name }}.Reset({{ arg.name }}); diff --git a/generate/templates/templates/nodegit.cc b/generate/templates/templates/nodegit.cc index c1eddd328..6a3fa8ef4 100644 --- a/generate/templates/templates/nodegit.cc +++ b/generate/templates/templates/nodegit.cc @@ -26,14 +26,11 @@ #if (NODE_MODULE_VERSION > 48) v8::Local GetPrivate(v8::Local object, v8::Local key) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Local context = isolate->GetCurrentContext(); - v8::Local privateKey = v8::Private::ForApi(isolate, key); v8::Local value; - v8::Maybe result = object->HasPrivate(context, privateKey); + Nan::Maybe result = Nan::HasPrivate(object, key); if (!(result.IsJust() && result.FromJust())) return v8::Local(); - if (object->GetPrivate(context, privateKey).ToLocal(&value)) + if (Nan::GetPrivate(object, key).ToLocal(&value)) return value; return v8::Local(); } @@ -43,10 +40,7 @@ v8::Local value) { if (value.IsEmpty()) return; - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Local context = isolate->GetCurrentContext(); - v8::Local privateKey = v8::Private::ForApi(isolate, key); - object->SetPrivate(context, privateKey, value); + Nan::SetPrivate(object, key, value); } #else v8::Local GetPrivate(v8::Local object, @@ -70,7 +64,7 @@ void LockMasterSetStatus(const FunctionCallbackInfo& info) { // convert the first argument to Status if(info.Length() >= 0 && info[0]->IsNumber()) { - v8::Local value = info[0]->ToInt32(v8::Isolate::GetCurrent()); + v8::Local value = Nan::To(info[0]).ToLocalChecked(); LockMaster::Status status = static_cast(value->Value()); if(status >= LockMaster::Disabled && status <= LockMaster::Enabled) { LockMaster::SetStatus(status); @@ -91,7 +85,7 @@ void LockMasterGetDiagnostics(const FunctionCallbackInfo& info) { // return a plain JS object with properties v8::Local result = Nan::New(); - result->Set(Nan::New("storedMutexesCount").ToLocalChecked(), Nan::New(diagnostics.storedMutexesCount)); + Nan::Set(result, Nan::New("storedMutexesCount").ToLocalChecked(), Nan::New(diagnostics.storedMutexesCount)); info.GetReturnValue().Set(result); } @@ -149,11 +143,11 @@ extern "C" void init(v8::Local target) { NODE_SET_METHOD(target, "getThreadSafetyDiagnostics", LockMasterGetDiagnostics); v8::Local threadSafety = Nan::New(); - threadSafety->Set(Nan::New("DISABLED").ToLocalChecked(), Nan::New((int)LockMaster::Disabled)); - threadSafety->Set(Nan::New("ENABLED_FOR_ASYNC_ONLY").ToLocalChecked(), Nan::New((int)LockMaster::EnabledForAsyncOnly)); - threadSafety->Set(Nan::New("ENABLED").ToLocalChecked(), Nan::New((int)LockMaster::Enabled)); + Nan::Set(threadSafety, Nan::New("DISABLED").ToLocalChecked(), Nan::New((int)LockMaster::Disabled)); + Nan::Set(threadSafety, Nan::New("ENABLED_FOR_ASYNC_ONLY").ToLocalChecked(), Nan::New((int)LockMaster::EnabledForAsyncOnly)); + Nan::Set(threadSafety, Nan::New("ENABLED").ToLocalChecked(), Nan::New((int)LockMaster::Enabled)); - target->Set(Nan::New("THREAD_SAFETY").ToLocalChecked(), threadSafety); + Nan::Set(target, Nan::New("THREAD_SAFETY").ToLocalChecked(), threadSafety); LockMaster::Initialize(); } diff --git a/generate/templates/templates/struct_content.cc b/generate/templates/templates/struct_content.cc index 0c7b9e4f1..0450447ac 100644 --- a/generate/templates/templates/struct_content.cc +++ b/generate/templates/templates/struct_content.cc @@ -80,10 +80,10 @@ void {{ cppClassName }}::ConstructFields() { {% if not field.ignore %} {% if not field.isEnum %} {% if field.hasConstructor |or field.isLibgitType %} - v8::Local {{ field.name }}Temp = {{ field.cppClassName }}::New( + v8::Local {{ field.name }}Temp = Nan::To({{ field.cppClassName }}::New( {%if not field.cType|isPointer %}&{%endif%}this->raw->{{ field.name }}, false - )->ToObject(); + )).ToLocalChecked(); this->{{ field.name }}.Reset({{ field.name }}Temp); {% elsif field.isCallbackFunction %} diff --git a/package.json b/package.json index a2ab166b5..c071d62c7 100644 --- a/package.json +++ b/package.json @@ -41,9 +41,9 @@ "fs-extra": "^7.0.0", "json5": "^2.1.0", "lodash": "^4.17.11", - "nan": "^2.11.1", + "nan": "^2.14.0", "node-gyp": "^4.0.0", - "node-pre-gyp": "^0.11.0", + "node-pre-gyp": "^0.13.0", "promisify-node": "~0.3.0", "ramda": "^0.25.0", "request-promise-native": "^1.0.5",