-
-
Notifications
You must be signed in to change notification settings - Fork 35
Property accessors 6.2.0 #45
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
Conversation
Based on I've learned today I'm aware of at least a couple pieces missing from this PR:
I'm working on these, but meanwhile I'd still appreciate feedback on the rest of the changes. |
On the breaking changes front, agreed we still need to make breaking changes and as you say we need to then update our existing module ports and the add on examples so they continue to work. On that front I'm thinking we might want to set up some ci jobs, I'll think about that a bit more when I get back from vacation. |
Regarding |
I pushed another commit that includes the following changes:
I think it's ready for a full review now. |
Oh, I still need to add/update tests covering these changes under |
Pushed another commit with added/updated tests. |
LGTM |
Waiting for the try-catch PR to be merged, then I will rebase this PR on top of that. |
I squashed and rebased on top of the latest changes. |
- Add support for property descriptors including accessor callbacks - Add a data pointer for function and accessor callbacks - Add API for defining a property using a property descriptor - Update the constructor API to use property descriptors
OK I fixed the problems after rebasing. This is ready now. Waiting for signoff from @boingoing who said he would review this afternoon. |
This looks very good to me. Thanks a lot for doing the work, especially for updating the tests and adding the data pointer to the callback info. |
Yes, we still need |
- Add support for property descriptors including accessor callbacks - Add a data pointer for function and accessor callbacks - Add API for defining a property using a property descriptor - Update the constructor API to use property descriptors
See #44
This change adds a new
napi_set_accessor
API which sets getter and setter accessors for a property on an object. In support of that, I refactored some of the callback-related code: the callback info opaque pointer type is now shared between function callbacks and accessor callbacks, so I renamed it fromnapi_func_cb_info
tonapi_callback_info
, and renamed a few other things accordingly. In the internal implementation, there is a newCallbackInfoWrapper
and subclasses that wrap the v8FunctionCallbackInfo
andPropertyCallbackInfo
classes.I assume we're not too concerned about breaking changes at this point, though of course any existing code using NAPI will need to be updated. I am updating the
abi-stable-node-addon-examples
repo for these changes, along with new examples for using property accessors.