napi: create napi_env as a real structure
-
We define struct napi_env__ to include the isolate, the last exception, and the info about the last error.
-
We instantiate one struct napi_env__ during module registration and we pass it into the FunctionCallbackInfo for all subsequent entries into N-API when we create functions/accessors/finalizers.
Once module unloading will be supported we shall have to delete the napi_env we create during module init.
There is a clear separation between public and private API wrt. env:
-
Public APIs assert that env is not nullptr as their first action.
-
Private APIs need not validate env. They assume it's not nullptr.
Fixes: https://github.com/nodejs/abi-stable-node/issues/198
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
napi