Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
68ea642
doc: Add initial documentation for N-API
mhdawson Apr 19, 2017
049c9b6
squash: address first set of comments
mhdawson Apr 21, 2017
67c7191
squash: address more comments
mhdawson Apr 21, 2017
f4417ef
squash: address next set of comments
mhdawson Apr 24, 2017
d32ce36
squash: e ->env where appropriate
mhdawson Apr 24, 2017
250bbe1
squash: update initial references to functions in Exceptions
mhdawson Apr 24, 2017
65e5865
squash: replace references to functions with links - Object lifetime
mhdawson Apr 24, 2017
f1b2a4d
squash: remove sub headings for API function sections
mhdawson Apr 24, 2017
cb616df
squash: misc cleanup
mhdawson Apr 24, 2017
2e4f2fd
squash: more cleanup
mhdawson Apr 24, 2017
e00bae1
squash: add in when added metadata
mhdawson Apr 24, 2017
13aeecd
squash: make references to functions links in Async section
mhdawson Apr 24, 2017
942a250
squash: one more cleanup pass
mhdawson Apr 24, 2017
017ed87
squash: add information about truncation of 32 bit ints
mhdawson Apr 24, 2017
a60ce7c
squash: address new linter failures
mhdawson Apr 25, 2017
0ec57fd
squash: remove double spaces in [in/out]
mhdawson Apr 25, 2017
eaea6c0
squash: remove low level headers in struct definitions
mhdawson Apr 25, 2017
a9702e7
squash: Make parameter descriptions use regular grammar
mhdawson Apr 25, 2017
5bb5431
squash: fix problems visible in html version of docs
mhdawson Apr 25, 2017
3332195
squash: address additional comment
mhdawson Apr 25, 2017
6a461c0
squash: fix up formating of structure member definitions
mhdawson Apr 25, 2017
0225b29
squash: address latest comments
mhdawson Apr 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
squash: replace references to functions with links - Object lifetime
  • Loading branch information
mhdawson committed Apr 25, 2017
commit 65e5865ed5ee64f77b40d42c0d6616b1ee72484e
33 changes: 12 additions & 21 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,21 +525,17 @@ kept alive since they all share the same scope.
To handle this case, N-API provides the ability to establish a new 'scope' to
which newly created handles will be associated. Once those handles
are no longer required, the scope can be 'closed' and any handles associated
with the scope are invalidated. The methods available to open/close scopes are:

```C
napi_open_handle_scope()
napi_close_handle_scope()
```
with the scope are invalidated. The methods available to open/close scopes are
[`napi_open_handle_scope`][] and [`napi_close_handle_scope`][].

N-API only supports a single nested hiearchy of scopes. There is only one
active scope at any time, and all new handles will be associated with that
scope while it is active. Scopes must be closed in the reverse order from
which they are opened. In addition, all scopes created within a native method
must be closed before returning from that method.

Taking the earlier example, adding calls to `napi_open_handle_scope()` and
`napi_close_handle_scope()` would ensure that at most a single handle
Taking the earlier example, adding calls to [`napi_open_handle_scope`][] and
[`napi_close_handle_scope`][] would ensure that at most a single handle
is valid throughout the execution of the loop:

```C
Expand Down Expand Up @@ -569,19 +565,10 @@ allows one or more handles to be 'promoted' so that they 'escape' the
current scope and the lifespan of the handle(s) changes from the current
scope to that of the outer scope.

The methods available to open/close escapable scopes are:

```C
napi_open_escapable_handle_scope()
napi_close_escapable_handle_scope()
```

The request to promote a handle is made through the `napi_escape_handle`
function:
The methods available to open/close escapable scopes are
[`napi_open_escapable_handle_scope`][] and [`napi_close_escapable_handle_scope`][].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing backticks above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

```C
napi_escape_handle()
```
The request to promote a handle is made through the [`napi_escape_handle`][].

#### napi_open_handle_scope
##### Signature
Expand Down Expand Up @@ -3167,10 +3154,14 @@ callback invocation, even when it was cancelled.

[`napi_get_and_clear_last_exception`]: #n_api_napi_get_and_clear_last_exception
[`napi_is_exception_pending`]: #n_api_napi_is_exception_pending

[`napi_throw_error`]: #n_api_napi_throw_error
[`napi_throw_range_error`]: #n_api_napi_throw_range_error
[`napi_is_error`]: #n_api_napi_is_error
[`napi_create_error`: #n_api_napi_create_error
[`napi_create_type_error`]: #n_api_napi_create_type_error
[`napi_create_range_error`]: #n_api_napi_create_range_error
[`napi_open_handle_scope`]: #n_api_napi_open_handle_scope
[`napi_close_handle_scope`]: #n_api_napi_close_handle_scope
[`napi_open_escapable_handle_scope`]: #n_api_napi_open_escapable_handle_scope
[`napi_close_escapable_handle_scope`]: #n_api_napi_close_escapable_handle_scope
[`napi_escape_handle`]: #n_api_napi_escape_handle