-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
n-api: support for object freeze/seal #35359
Conversation
Review requested:
|
d45a97d
to
b63a5f1
Compare
Will need more time to review the content but the first thing is that all new APIs need to be added as experimental so they should be added in the section guarded by |
@codebytere , one other question is if isFrozen and isSealed should go along with the freeze and seal or if there is some reason the freeze and seal are needed by native modules by the is methods won't be? |
@codebytere some of the requirements for adding an API - https://github.com/nodejs/node/blob/master/doc/guides/adding-new-napi-api.md. Of that list |
@mhdawson i can definitely add |
@codebytere thanks for the quick response. I'll tag for discussion in the N-API team meeting this friday to see if there is any other feedback/concerns as well. One other thing that would be good for that discussion is the use case that driving the addition. I'm guessing you need them and understanding that need will help the discussion. |
You are also welcome to come to the meeting - from the calendar: Node.js N-API team weekly meeting |
b63a5f1
to
dbd18e7
Compare
@mhdawson i should be there! what time zone is that? Also - the reason I initially didn't add A primary driver for this is passing objects across process boundaries (e.g between renderer & main) with more robust security guarantees. |
dbd18e7
to
7f6ca4e
Compare
@codebytere It works out to be 11:00am Eastern Daylight Time in the US, 8:00am Pacific Daylight Time. YMMV.
|
@jschlight ty, bit of a suffering hour but i should make it 😆 |
5a505af
to
705356e
Compare
@codebytere is there a reason why these APIs take a third parameter that just receives the second parameter back? Is there ever any chance that the object returned will be an object other than the object passed in? If not, then I don't think we need the out parameter. I understand that it can be useful in JS to return the same object that was passed in so one can compose calls, but on the native side we can never chain N-API calls because they all return As an existing example, Edit: linkified some of the text. |
Also, fewer parameters help keep the stack lean for low-memory implementations like IoT.js. |
@gabrielschulhof sounds good to me! There wasn't a specific reason I did it this way to begin with beyond that I was seeking to emulate conventions for similar functions |
705356e
to
e25888c
Compare
@gabrielschulhof i think that should do it - let me know if i missed anything! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after the issue of retrieving and freezing/sealing the object passed from JS is addressed.
e25888c
to
f643771
Compare
dad997a
to
19495c8
Compare
@gabrielschulhof sorry for the churn 🙃 turns out trying to context switch extremely fast between this and doing an LTS release is not the greatest idea in the world - linting should finally be good now. |
@codebytere NP 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
19495c8
to
ce959cf
Compare
Landed in 19f1451 |
PR-URL: #35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: #35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: nodejs#35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This is PR adds support for
Object.freeze()
&Object.seal()
to n-api.cc @gabrielschulhof (not sure who else is best to ping here!)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes