| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
|
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 #ifdef NAPI_EXPERIMENTAL in js_native_api.h |
Sorry, something went wrong.
|
@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? |
Sorry, something went wrong.
|
@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 A new API addition should be simultaneously implemented in at least one other VM implementation of Node.js. and The API must be implemented in a Node.js implementation with an alternate VM. have not been enforced since Chakra core is no longer an option for implementation and we should probably update that. |
Sorry, something went wrong.
|
@mhdawson i can definitely add isFrozen/isSealed - there's no specific reason i didn't! |
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
|
You are also welcome to come to the meeting - from the calendar: Node.js N-API team weekly meeting |
Sorry, something went wrong.
|
@mhdawson i should be there! what time zone is that? Also - the reason I initially didn't add isFrozen and/or isSealed i recall now is bc V8 doesn't really provide a good approach to that. They check this themselves by compiling some JS and running which doesn't necessarily feel like an approach we'd want to emulate. A primary driver for this is passing objects across process boundaries (e.g between renderer & main) with more robust security guarantees. |
Sorry, something went wrong.
|
@codebytere It works out to be 11:00am Eastern Daylight Time in the US, 8:00am Pacific Daylight Time. YMMV.
|
Sorry, something went wrong.
|
@jschlight ty, bit of a suffering hour but i should make it 😆 |
Sorry, something went wrong.
|
@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 napi_status. Our C++ wrappers can implement this composably even without the out parameter. As an existing example, napi_detach_arraybuffer also modifies the napi_value containing an array buffer without returning it. Since the detach API implements directly an abstract operation as defined in the spec, and since both freeze and seal look like convenience methods around the SetIntegrityLevel abstract operation, I think it's OK to drop the out parameter, because then we're basically implementing the abstract operation, but without the need to introduce a corresponding enum of { napi_frozen, napi_sealed }. Edit: linkified some of the text. |
Sorry, something went wrong.
|
Also, fewer parameters help keep the stack lean for low-memory implementations like IoT.js. |
Sorry, something went wrong.
|
@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 |
Sorry, something went wrong.
|
@gabrielschulhof i think that should do it - let me know if i missed anything! |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM after the issue of retrieving and freezing/sealing the object passed from JS is addressed.
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
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>
| Back | FazBrowse Home | New Git URL |
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