Skip to content

Commit

Permalink
Respond to review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
boingoing committed Apr 9, 2017
1 parent 8f34553 commit 7d899eb
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
14 changes: 7 additions & 7 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class napi_env__ {
auto str_maybe = v8::String::NewFromUtf8( \
(env)->isolate, (str), v8::NewStringType::kInternalized, (len)); \
CHECK_MAYBE_EMPTY((env), str_maybe, napi_generic_failure); \
result = str_maybe.ToLocalChecked(); \
(result) = str_maybe.ToLocalChecked(); \
} while (0)

#define CHECK_NEW_FROM_UTF8(env, result, str) \
Expand Down Expand Up @@ -187,7 +187,7 @@ v8::Local<v8::Value> V8LocalValueFromJsValue(napi_value v) {
return local;
}

napi_status V8NameFromPropertyDescriptor(napi_env env,
static inline napi_status V8NameFromPropertyDescriptor(napi_env env,
const napi_property_descriptor* p,
v8::Local<v8::Name>* result) {
if (p->utf8name != nullptr) {
Expand Down Expand Up @@ -814,14 +814,14 @@ napi_status napi_define_class(napi_env env,

v8::Local<v8::Name> property_name;
napi_status status =
v8impl::V8NameFromPropertyDescriptor(env, p, &property_name);
v8impl::V8NameFromPropertyDescriptor(env, p, &property_name);

if (status != napi_ok) {
return napi_set_last_error(env, status);
}

v8::PropertyAttribute attributes =
v8impl::V8PropertyAttributesFromDescriptor(p);
v8impl::V8PropertyAttributesFromDescriptor(p);

// This code is similar to that in napi_define_properties(); the
// difference is it applies to a template instead of an object.
Expand All @@ -838,7 +838,7 @@ napi_status napi_define_class(napi_env env,
attributes);
} else if (p->method != nullptr) {
v8::Local<v8::Object> cbdata =
v8impl::CreateFunctionCallbackData(env, p->method, p->data);
v8impl::CreateFunctionCallbackData(env, p->method, p->data);

RETURN_STATUS_IF_FALSE(env, !cbdata.IsEmpty(), napi_generic_failure);

Expand Down Expand Up @@ -1116,14 +1116,14 @@ napi_status napi_define_properties(napi_env env,

v8::Local<v8::Name> property_name;
napi_status status =
v8impl::V8NameFromPropertyDescriptor(env, p, &property_name);
v8impl::V8NameFromPropertyDescriptor(env, p, &property_name);

if (status != napi_ok) {
return napi_set_last_error(env, status);
}

v8::PropertyAttribute attributes =
v8impl::V8PropertyAttributesFromDescriptor(p);
v8impl::V8PropertyAttributesFromDescriptor(p);

if (p->getter != nullptr || p->setter != nullptr) {
v8::Local<v8::Object> cbdata = v8impl::CreateAccessorCallbackData(
Expand Down
14 changes: 8 additions & 6 deletions test/addons-napi/6_object_wrap/myobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, nullptr));

if (is_constructor) {
// Invoked as constructor: `new MyObject(...)`
Expand Down Expand Up @@ -79,7 +79,8 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) {

napi_value MyObject::GetValue(napi_env env, napi_callback_info info) {
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, NULL, NULL, &_this, NULL));
NAPI_CALL(env,
napi_get_cb_info(env, info, nullptr, nullptr, &_this, nullptr));

MyObject* obj;
NAPI_CALL(env, napi_unwrap(env, _this, reinterpret_cast<void**>(&obj)));
Expand All @@ -94,19 +95,20 @@ napi_value MyObject::SetValue(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, nullptr));

MyObject* obj;
NAPI_CALL(env, napi_unwrap(env, _this, reinterpret_cast<void**>(&obj)));

NAPI_CALL(env, napi_get_value_double(env, args[0], &obj->value_));

return NULL;
return nullptr;
}

napi_value MyObject::PlusOne(napi_env env, napi_callback_info info) {
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, NULL, NULL, &_this, NULL));
NAPI_CALL(env,
napi_get_cb_info(env, info, nullptr, nullptr, &_this, nullptr));

MyObject* obj;
NAPI_CALL(env, napi_unwrap(env, _this, reinterpret_cast<void**>(&obj)));
Expand All @@ -123,7 +125,7 @@ napi_value MyObject::Multiply(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, nullptr));

double multiple = 1;
if (argc >= 1) {
Expand Down
2 changes: 1 addition & 1 deletion test/addons-napi/7_factory_wrap/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
napi_value CreateObject(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));

napi_value instance;
NAPI_CALL(env, MyObject::NewInstance(env, args[0], &instance));
Expand Down
5 changes: 3 additions & 2 deletions test/addons-napi/7_factory_wrap/myobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, nullptr));

napi_valuetype valuetype;
NAPI_CALL(env, napi_typeof(env, args[0], &valuetype));
Expand Down Expand Up @@ -79,7 +79,8 @@ napi_status MyObject::NewInstance(napi_env env,

napi_value MyObject::PlusOne(napi_env env, napi_callback_info info) {
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, NULL, NULL, &_this, NULL));
NAPI_CALL(env,
napi_get_cb_info(env, info, nullptr, nullptr, &_this, nullptr));

MyObject* obj;
NAPI_CALL(env, napi_unwrap(env, _this, reinterpret_cast<void**>(&obj)));
Expand Down
4 changes: 2 additions & 2 deletions test/addons-napi/8_passing_wrapped/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
napi_value CreateObject(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));

napi_value instance;
NAPI_CALL(env, MyObject::NewInstance(env, args[0], &instance));
Expand All @@ -15,7 +15,7 @@ napi_value CreateObject(napi_env env, napi_callback_info info) {
napi_value Add(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));

MyObject* obj1;
NAPI_CALL(env, napi_unwrap(env, args[0], reinterpret_cast<void**>(&obj1)));
Expand Down
2 changes: 1 addition & 1 deletion test/addons-napi/8_passing_wrapped/myobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ napi_value MyObject::New(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &_this, nullptr));

MyObject* obj = new MyObject();

Expand Down
2 changes: 1 addition & 1 deletion test/addons-napi/test_error/test_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
napi_value checkError(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr));

bool r;
NAPI_CALL(env, napi_is_error(env, args[0], &r));
Expand Down
2 changes: 1 addition & 1 deletion test/addons-napi/test_napi_status/test_napi_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ napi_value createNapiError(napi_env env, napi_callback_info info) {

NAPI_ASSERT(env, status != napi_ok, "Failed to produce error condition");

return NULL;
return nullptr;
}

napi_value testNapiErrorCleanup(napi_env env, napi_callback_info info) {
Expand Down

0 comments on commit 7d899eb

Please sign in to comment.