Skip to content

Commit

Permalink
n-api: create napi_env as a real structure
Browse files Browse the repository at this point in the history
1. We define struct napi_env__ to include the isolate, the last
exception, and the info about the last error.

2. 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:

1. Public APIs assert that env is not nullptr as their first action.

2. Private APIs need not validate env. They assume it's not nullptr.

Backport-PR-URL: #19447
PR-URL: #12195
Fixes: nodejs/abi-stable-node#198
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
Gabriel Schulhof authored and MylesBorins committed Apr 16, 2018
1 parent 9b36811 commit 1e6d3bb
Show file tree
Hide file tree
Showing 4 changed files with 498 additions and 399 deletions.

0 comments on commit 1e6d3bb

Please sign in to comment.