Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

mhdawson
Copy link
Member

  • 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: #13555
Fixes: #13556
Fixes: #13562

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows [commit guidelines]
Affected core subsystem(s)

doc, n-api

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API. labels Jun 13, 2017
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);
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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.

Copy link
Member

@jasongin jasongin left a 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
Copy link
Member

@RReverser RReverser Jun 14, 2017

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
Copy link
Member

Choose a reason for hiding this comment

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

Same typo.

mhdawson added 2 commits June 15, 2017 01:55
- 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
@mhdawson
Copy link
Member Author

@jasongin, @RReverser thanks for the comments. Rebased and pushed commit to address.

@RReverser RReverser self-requested a review June 15, 2017 10:52
@mhdawson
Copy link
Member Author

@mhdawson
Copy link
Member Author

CI run looks ok. Arm failure was unrelated, a problem doing checkout. Going to land.

@mhdawson
Copy link
Member Author

Landed as 62e940d

@mhdawson mhdawson closed this Jun 16, 2017
mhdawson added a commit that referenced this pull request Jun 16, 2017
- 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]>
addaleax pushed a commit that referenced this pull request Jun 17, 2017
- 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]>
@addaleax addaleax mentioned this pull request Jun 17, 2017
addaleax pushed a commit that referenced this pull request Jun 21, 2017
- 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]>
@addaleax addaleax mentioned this pull request Jun 21, 2017
@mhdawson mhdawson deleted the napi-doc20 branch June 28, 2017 19:23
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 10, 2018
- 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]>
MylesBorins pushed a commit that referenced this pull request Apr 16, 2018
- 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]>
@MylesBorins MylesBorins mentioned this pull request Apr 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants