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

Conversation

lmartorella
Copy link
Contributor

Currently the "data" argument in all PropertyDescriptor::Accessor overload is not taken in account in any code path, and hence not retrievable in the callback function from CbData.
Added the right implementation and some test.
Thanks!
Luciano

@mhdawson
Copy link
Member

Would like @gabrielschulhof to take a look since he recently tweaked the usage of data (If I remember correctly)

Copy link
Contributor

@gabrielschulhof gabrielschulhof left a comment

Choose a reason for hiding this comment

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

LGTM

@lmartorella
Copy link
Contributor Author

Thanks, fixes done in a temp commit because not had time to test locally, but everything works.
I've just realized that there are some deprecated APIs that could be fixed as well with the same type of fix.
Do you prefer to have these calls fixed as well, or just ignore it? Usually deprecated calls shouldn't be changed, but I don't know how long you prefer to maintain these APIs in this project.
Luciano

@mhdawson
Copy link
Member

My first thought is that we can leave the deprecated APIs as is. If the new functionality is needed code would be being updated anyway and the newer APIs can be used.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

@gabrielschulhof
Copy link
Contributor

@lmartorella I ran the test suite for this PR, but the object tests fail to build:

https://ci.nodejs.org/job/node-test-node-addon-api/1199/MACHINE=debian8-64/console

@lmartorella
Copy link
Contributor Author

Sorry, now the code is fixed and properly initialize all fields inline.
Microsoft VC compiler seems to be less strict about it. Now tested on Debian too.
Thanks, L

gabrielschulhof pushed a commit that referenced this pull request Dec 28, 2018
PR-URL: #374
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
@gabrielschulhof
Copy link
Contributor

Landed in c1ff293.

@@ -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

kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#374
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#374
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#374
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#374
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants