Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to nan@2.10.x - refs #125 #127

Merged
merged 8 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion binding.gyp
Expand Up @@ -112,4 +112,4 @@
}
}
]
}
}
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -18,7 +18,7 @@
"license": "ISC",
"dependencies": {
"mason-js-sdk": "~0.1.4",
"nan": "~2.5.1",
"nan": "~2.10.0",
"node-pre-gyp": "~0.10.0"
},
"bundledDependencies": [
Expand Down
6 changes: 3 additions & 3 deletions src/module_utils.hpp
Expand Up @@ -19,9 +19,9 @@ namespace utils {
* context
*
*/
inline void CallbackError(std::string message,
v8::Local<v8::Function> callback) {
inline void CallbackError(std::string message, v8::Local<v8::Function> func) {
Nan::Callback cb(func);
v8::Local<v8::Value> argv[1] = {Nan::Error(message.c_str())};
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), callback, 1, argv);
Nan::Call(cb, 1, argv);
}
} // namespace utils
10 changes: 6 additions & 4 deletions src/object_async/hello_async.cpp
Expand Up @@ -151,12 +151,14 @@ struct AsyncHelloWorker : Nan::AsyncWorker // NOLINT to disable cppcoreguideline
{

using Base = Nan::AsyncWorker;
// Make this class noncopyable
// We explicitly delete the copy constructor and assignment operator below (even though Nan::Asyncworker)
// already does this in the base class. This allows us to have the `const std::string* name`
// pointer member without the silly g++ warning of "error: ‘struct object_async::AsyncHelloWorker’ has pointer data members [-Werror=effc++]"
AsyncHelloWorker(AsyncHelloWorker const&) = delete;
AsyncHelloWorker& operator=(AsyncHelloWorker const&) = delete;
AsyncHelloWorker(bool louder, const std::string* name,
Nan::Callback* cb)
: Base(cb), louder_{louder}, name_{name} {}
: Base(cb, "skel:object-async-worker"), louder_{louder}, name_{name} {}

// The Execute() function is getting called when the worker starts to run.
// - You only have access to member variables stored in this worker.
Expand Down Expand Up @@ -184,7 +186,7 @@ struct AsyncHelloWorker : Nan::AsyncWorker // NOLINT to disable cppcoreguideline
Nan::Null(), Nan::New<v8::String>(result_).ToLocalChecked()};

// Static cast done here to avoid 'cppcoreguidelines-pro-bounds-array-to-pointer-decay' warning with clang-tidy
callback->Call(argc, static_cast<v8::Local<v8::Value>*>(argv));
callback->Call(argc, static_cast<v8::Local<v8::Value>*>(argv), async_resource);
}

std::string result_{};
Expand Down Expand Up @@ -297,4 +299,4 @@ void HelloObjectAsync::Init(v8::Local<v8::Object> target) {
// after this code block ends.
Nan::Set(target, whoami, fn);
}
} // namespace object_async
} // namespace object_async
5 changes: 2 additions & 3 deletions src/standalone_async/hello_async.cpp
Expand Up @@ -73,7 +73,7 @@ struct AsyncHelloWorker : Nan::AsyncWorker {
using Base = Nan::AsyncWorker;

AsyncHelloWorker(bool louder, Nan::Callback* cb)
: Base(cb), louder_{louder} {}
: Base(cb, "skel:standalone-async-worker"), louder_{louder} {}

// The Execute() function is getting called when the worker starts to run.
// - You only have access to member variables stored in this worker.
Expand Down Expand Up @@ -101,9 +101,8 @@ struct AsyncHelloWorker : Nan::AsyncWorker {
const auto argc = 2u;
v8::Local<v8::Value> argv[argc] = {
Nan::Null(), Nan::New<v8::String>(result_).ToLocalChecked()};

// Static cast done here to avoid 'cppcoreguidelines-pro-bounds-array-to-pointer-decay' warning with clang-tidy
callback->Call(argc, static_cast<v8::Local<v8::Value>*>(argv));
callback->Call(argc, static_cast<v8::Local<v8::Value>*>(argv), async_resource);
}

std::string result_{};
Expand Down