-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
doc: fix a few n-api doc issues #13650
Conversation
doc/api/n-api.md
Outdated
@@ -172,7 +172,7 @@ Function pointer type for user-provided native functions which are to be | |||
exposed to JavaScript via N-API. Callback functions should satisfy the | |||
following signature: | |||
```C | |||
typedef void (*napi_callback)(napi_env, napi_callback_info); | |||
typedef napi_value (*napi_callback)(napi_env, napi_callback_info); |
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.
This was already fixed in #13570. You'll need to rebase.
doc/api/n-api.md
Outdated
for the lifetime of the outer scope. | ||
|
||
This API promotes the handle to the JavaScript object so that it is valid | ||
for the lifetime of the outer scope. It can only be called once. If it |
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.
once per scope ?
doc/api/n-api.md
Outdated
@@ -1325,7 +1354,7 @@ napi_status napi_create_string_utf8(napi_env env, | |||
``` | |||
|
|||
- `[in] env`: The environment that the API is invoked under. | |||
- `[in] s`: Character buffer representing a UTF8-encoded string. | |||
- `[in] str`: Character buffer representing a UTF8-encoded string. | |||
- `[in] length`: The length of the string in characters, or -1 if it is |
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.
Just noticed - this should say length in bytes, not characters.
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.
Also fix the doc for the length
parameter of napi_create_string_utf16
. That length is in two-byte code units, not characters. (GitHub won't let me put a comment on that line.)
doc/api/n-api.md
Outdated
|
||
- `[in] env`: The environment that the API is invoked under. | ||
- `[in] str`: Character buffer representing a latin1-encoded string. | ||
- `[in] length`: The length of the string in characters, or -1 if it is |
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.
Length in bytes. While in the case of Latin1 a character is always one byte, I think bytes is clearer in case someone is not familiar with the encoding.
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.
Left some comments.
doc/api/n-api.md
Outdated
napi_value* result); | ||
``` | ||
- `[in] env`: The environment that the API is invoked under. | ||
- `[in] msg`: C string representing the text to be associated with. | ||
- `[in] msg`: napi_value that referneces a JavaScript String to 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.
typo: "references"
doc/api/n-api.md
Outdated
@@ -447,7 +449,8 @@ NODE_EXTERN napi_status napi_create_range_error(napi_env env, | |||
napi_value* result); | |||
``` | |||
- `[in] env`: The environment that the API is invoked under. | |||
- `[in] msg`: C string representing the text to be associated with. | |||
- `[in] msg`: napi_value that referneces a JavaScript String to 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.
Same typo.
- Add doc for napi_create_string_latin1(). - Fix signatures where c string was specified instead of napi_value. - Fix return type of napi_callback. - Update to specify that napi_escape_handle() can only be called once for a given scope. Fixes: nodejs#13555 Fixes: nodejs#13556 Fixes: nodejs#13562
@jasongin, @RReverser thanks for the comments. Rebased and pushed commit to address. |
CI run looks ok. Arm failure was unrelated, a problem doing checkout. Going to land. |
Landed as 62e940d |
- Add doc for napi_create_string_latin1(). - Fix signatures where c string was specified instead of napi_value. - Fix return type of napi_callback. - Update to specify that napi_escape_handle() can only be called once for a given scope. PR-URL: #13650 Fixes: #13555 Fixes: #13556 Fixes: #13562 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: Ingvar Stepanyan <[email protected]>
- Add doc for napi_create_string_latin1(). - Fix signatures where c string was specified instead of napi_value. - Fix return type of napi_callback. - Update to specify that napi_escape_handle() can only be called once for a given scope. PR-URL: #13650 Fixes: #13555 Fixes: #13556 Fixes: #13562 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: Ingvar Stepanyan <[email protected]>
- Add doc for napi_create_string_latin1(). - Fix signatures where c string was specified instead of napi_value. - Fix return type of napi_callback. - Update to specify that napi_escape_handle() can only be called once for a given scope. PR-URL: #13650 Fixes: #13555 Fixes: #13556 Fixes: #13562 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: Ingvar Stepanyan <[email protected]>
- Add doc for napi_create_string_latin1(). - Fix signatures where c string was specified instead of napi_value. - Fix return type of napi_callback. - Update to specify that napi_escape_handle() can only be called once for a given scope. PR-URL: nodejs#13650 Fixes: nodejs#13555 Fixes: nodejs#13556 Fixes: nodejs#13562 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: Ingvar Stepanyan <[email protected]>
- Add doc for napi_create_string_latin1(). - Fix signatures where c string was specified instead of napi_value. - Fix return type of napi_callback. - Update to specify that napi_escape_handle() can only be called once for a given scope. Backport-PR-URL: #19447 PR-URL: #13650 Fixes: #13555 Fixes: #13556 Fixes: #13562 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]> Reviewed-By: Ingvar Stepanyan <[email protected]>
for a given scope.
Fixes: #13555
Fixes: #13556
Fixes: #13562
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
doc, n-api