Skip to content

Commit

Permalink
src: Fix warnings when running npm test
Browse files Browse the repository at this point in the history
The warnings occur due to a bug in gcc(<5.1.1)[1]. To fix this issue,
we can use constructor initializer instead of empty braces initializer.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61489

Fixes: nodejs/node-addon-api#164
PR-URL: nodejs/node-addon-api#166
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
John French committed Nov 1, 2017
1 parent 5bf04df commit f1369ed
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2475,7 +2475,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::StaticMethod(
// TODO: Delete when the class is destroyed
StaticVoidMethodCallbackData* callbackData = new StaticVoidMethodCallbackData({ method, data });

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.method = T::StaticVoidMethodCallbackWrapper;
desc.data = callbackData;
Expand All @@ -2492,7 +2492,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::StaticMethod(
// TODO: Delete when the class is destroyed
StaticMethodCallbackData* callbackData = new StaticMethodCallbackData({ method, data });

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.method = T::StaticMethodCallbackWrapper;
desc.data = callbackData;
Expand All @@ -2511,7 +2511,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::StaticAccessor(
StaticAccessorCallbackData* callbackData =
new StaticAccessorCallbackData({ getter, setter, data });

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.getter = getter != nullptr ? T::StaticGetterCallbackWrapper : nullptr;
desc.setter = setter != nullptr ? T::StaticSetterCallbackWrapper : nullptr;
Expand All @@ -2530,7 +2530,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceMethod(
InstanceVoidMethodCallbackData* callbackData =
new InstanceVoidMethodCallbackData({ method, data});

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.method = T::InstanceVoidMethodCallbackWrapper;
desc.data = callbackData;
Expand All @@ -2547,7 +2547,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceMethod(
// TODO: Delete when the class is destroyed
InstanceMethodCallbackData* callbackData = new InstanceMethodCallbackData({ method, data });

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.method = T::InstanceMethodCallbackWrapper;
desc.data = callbackData;
Expand All @@ -2565,7 +2565,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceMethod(
InstanceVoidMethodCallbackData* callbackData =
new InstanceVoidMethodCallbackData({ method, data});

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.name = name;
desc.method = T::InstanceVoidMethodCallbackWrapper;
desc.data = callbackData;
Expand All @@ -2582,7 +2582,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceMethod(
// TODO: Delete when the class is destroyed
InstanceMethodCallbackData* callbackData = new InstanceMethodCallbackData({ method, data });

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.name = name;
desc.method = T::InstanceMethodCallbackWrapper;
desc.data = callbackData;
Expand All @@ -2601,7 +2601,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceAccessor(
InstanceAccessorCallbackData* callbackData =
new InstanceAccessorCallbackData({ getter, setter, data });

napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.getter = getter != nullptr ? T::InstanceGetterCallbackWrapper : nullptr;
desc.setter = setter != nullptr ? T::InstanceSetterCallbackWrapper : nullptr;
Expand All @@ -2613,7 +2613,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceAccessor(
template <typename T>
inline ClassPropertyDescriptor<T> ObjectWrap<T>::StaticValue(const char* utf8name,
Napi::Value value, napi_property_attributes attributes) {
napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.value = value;
desc.attributes = static_cast<napi_property_attributes>(attributes | napi_static);
Expand All @@ -2625,7 +2625,7 @@ inline ClassPropertyDescriptor<T> ObjectWrap<T>::InstanceValue(
const char* utf8name,
Napi::Value value,
napi_property_attributes attributes) {
napi_property_descriptor desc = {};
napi_property_descriptor desc = napi_property_descriptor();
desc.utf8name = utf8name;
desc.value = value;
desc.attributes = attributes;
Expand Down

0 comments on commit f1369ed

Please sign in to comment.