Skip to content

Commit

Permalink
Merge pull request #127 from mapbox/latest-nan
Browse files Browse the repository at this point in the history
Upgrade to [email protected] - refs #125
  • Loading branch information
springmeyer authored Jun 23, 2018
2 parents d330a9f + 7fd4309 commit a1105dd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit a1105dd

Please sign in to comment.