-
Notifications
You must be signed in to change notification settings - Fork 461
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
test: add basic tests and doc for scopes #250
Conversation
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.
Hi @mhdawson,
I tried to suggest some corrections and improvements.
doc/object_lifetime_management.md
Outdated
As the methods and classes within the node-addon-api are used, | ||
handles to objects in the heap for the underlying | ||
VM may be created. A handle may be created for any new node-addon-api | ||
Value(and subclasses) created or returned. These handles must hold the |
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.
A handle may be created when any new node-addon-api Value and its subclasses have been created or returned.
doc/handle_scope.md
Outdated
are not collected while native code is using them. A handle may be | ||
created any time a node-addon-api Value(and subclasses) are created | ||
or returned. |
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.
A handle may be created when any new node-addon-api Value and its subclasses have been created or returned.
doc/handle_scope.md
Outdated
|
||
For more details refer to the section title "Object lifetime management". | ||
|
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.
It could be better add the link to "Object lifetime management"
doc/object_lifetime_management.md
Outdated
Value(and subclasses) created or returned. These handles must hold the | ||
objects 'live' until they are no longer required by the native code, | ||
otherwise the objects could be collected before the native code was | ||
finished using them. |
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.
otherwise the objects could be collected by the garbage collector before the native code was finished using them.
doc/escapable_handle_scope.md
Outdated
The EscapableHandleScope class is used to manage the lifetime of object handles | ||
which are created through the use of node-addon-api. These handles | ||
keep an object alive in the heap in order to ensure that the objects | ||
are not collected while native code is using them. A handle may be |
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.
are not collected by garbage collector
doc/escapable_handle_scope.md
Outdated
which allows a single handle to be "promoted" to an outer scope. | ||
|
||
For more details refer to the section title "Object lifetime management". | ||
|
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.
It could be better add the link to "Object lifetime management"
doc/escapable_handle_scope.md
Outdated
- `[in] scope`: pre-existing napi_handle_scope. | ||
|
||
Creates a new EscapableHandleScope instance which wraps the | ||
napi_escapable_handle_scope handle passed in. This can be used |
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.
Remove extra space here: in. This can be used
doc/escapable_handle_scope.md
Outdated
``` | ||
|
||
Deletes the EscapableHandleScope instance and allows any objects/handles created | ||
in the scope to be collected by the garbage collector. There is no |
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.
Remove extra space here: collector. There is no
doc/escapable_handle_scope.md
Outdated
- `[in] escapee`: Napi::Value or napi_env to promote to the outer scope | ||
|
||
Returns Napi:Value which can be used in the outer scope. This method can | ||
be called at most once on a given EscapableHandleScope. If it is called |
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.
Remove extra space here: EscapableHandleScope. If
doc/escapable_handle_scope.md
Outdated
|
||
Returns Napi:Value which can be used in the outer scope. This method can | ||
be called at most once on a given EscapableHandleScope. If it is called | ||
more than once and exception will be thrown. |
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.
If it is called more than once an exception will be thrown.
@NickNaso, thanks for the comments. Pushed commit which should address them. |
doc/escapable_handle_scope.md
Outdated
Creates a new escapable handle scope. | ||
|
||
```cpp | ||
EscapableHandleScope::New(napi_env env, napi_handle_scope scope); |
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.
For consistency does it make sense to include return types?
doc/escapable_handle_scope.md
Outdated
|
||
- `[in] Env`: The environment in which to construct the EscapableHandleScope object. | ||
|
||
Creates a new EscapableHandleScope |
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.
Maybe it makes more sense to use "Returns" for consistency. In working on my documentation it seems like the pattern should be:
- Description/Remarks
- Signature
- Parameters
- Returns
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.
Agreed is should say "Returns" will update
addressed second set of comments will land. |
PR-URL: #250 Reviewed-By: Kyle Farnung <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
Landed as 75086da |
PR-URL: nodejs/node-addon-api#250 Reviewed-By: Kyle Farnung <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
PR-URL: nodejs/node-addon-api#250 Reviewed-By: Kyle Farnung <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
PR-URL: nodejs/node-addon-api#250 Reviewed-By: Kyle Farnung <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
PR-URL: nodejs/node-addon-api#250 Reviewed-By: Kyle Farnung <[email protected]> Reviewed-By: Nicola Del Gobbo <[email protected]>
No description provided.