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

Fixed missing void*data usage in PropertyDescriptors #374

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions napi-inl.deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(const char* utf8name,
void* /*data*/) {
typedef details::AccessorCallbackData<Getter, Setter> CbData;
// TODO: Delete when the function is destroyed
auto callbackData = new CbData({ getter, setter });
auto callbackData = new CbData({ getter, setter, nullptr });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmartorella why not pass the void* from the arguments here?
void* /data/ becomes void* data
auto callbackData = new CbData({ getter, setter, data });
?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Usually deprecated APIs doesn't receive fixes/enhancements, especially if the new API already covers the functionality. Don't know the situation of testing about the deprecated API. You can try to enable it in the deprecated API as well, but honestly it can be better to move to the up-to-date API instead.
Thanks. L


return PropertyDescriptor({
utf8name,
Expand Down Expand Up @@ -104,7 +104,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(napi_value name,
void* /*data*/) {
typedef details::AccessorCallbackData<Getter, Setter> CbData;
// TODO: Delete when the function is destroyed
auto callbackData = new CbData({ getter, setter });
auto callbackData = new CbData({ getter, setter, nullptr });

return PropertyDescriptor({
nullptr,
Expand Down
12 changes: 4 additions & 8 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2608,8 +2608,7 @@ PropertyDescriptor::Accessor(Napi::Env env,
napi_property_attributes attributes,
void* data) {
typedef details::CallbackData<Getter, Napi::Value> CbData;
auto callbackData = new CbData({ getter, nullptr });
callbackData->data = data;
auto callbackData = new CbData({ getter, data });

napi_status status = AttachData(env, object, callbackData);
NAPI_THROW_IF_FAILED(env, status, napi_property_descriptor());
Expand Down Expand Up @@ -2644,8 +2643,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(Napi::Env env,
napi_property_attributes attributes,
void* data) {
typedef details::CallbackData<Getter, Napi::Value> CbData;
auto callbackData = new CbData({ getter, nullptr });
callbackData->data = data;
auto callbackData = new CbData({ getter, data });

napi_status status = AttachData(env, object, callbackData);
NAPI_THROW_IF_FAILED(env, status, napi_property_descriptor());
Expand All @@ -2671,8 +2669,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(Napi::Env env,
napi_property_attributes attributes,
void* data) {
typedef details::AccessorCallbackData<Getter, Setter> CbData;
auto callbackData = new CbData({ getter, setter });
callbackData->data = data;
auto callbackData = new CbData({ getter, setter, data });

napi_status status = AttachData(env, object, callbackData);
NAPI_THROW_IF_FAILED(env, status, napi_property_descriptor());
Expand Down Expand Up @@ -2709,8 +2706,7 @@ inline PropertyDescriptor PropertyDescriptor::Accessor(Napi::Env env,
napi_property_attributes attributes,
void* data) {
typedef details::AccessorCallbackData<Getter, Setter> CbData;
auto callbackData = new CbData({ getter, setter });
callbackData->data = data;
auto callbackData = new CbData({ getter, setter, data });

napi_status status = AttachData(env, object, callbackData);
NAPI_THROW_IF_FAILED(env, status, napi_property_descriptor());
Expand Down