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

N-API Callback Return #13562

Closed
1995parham opened this issue Jun 8, 2017 · 3 comments
Closed

N-API Callback Return #13562

1995parham opened this issue Jun 8, 2017 · 3 comments
Assignees
Labels
doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API.

Comments

@1995parham
Copy link

1995parham commented Jun 8, 2017

  • Version: v8.1.0
  • Platform: Linux 4.10.0-21-generic
  • Subsystem:

I think N-API doesn't have any documented way for return something from callbacks. we have just napi_get_cb_info for reading information from napi_callback_info and there is no specific way for write something into them but in documentation mention that it can be used for Set the return value of the callback

@1995parham 1995parham changed the title N-API Function Return N-API Callback Return Jun 8, 2017
@jasongin
Copy link
Member

jasongin commented Jun 8, 2017

The documentation is out of date. You can return a napi_value directly from a function callback. The current definition of napi_callback has a napi_value return type, not void:

typedef napi_value (*napi_callback)(napi_env env, napi_callback_info info);

@jasongin jasongin added doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API. labels Jun 8, 2017
@1995parham
Copy link
Author

Thank you very much @jasongin

@mhdawson
Copy link
Member

mhdawson commented Jun 9, 2017

I'll clarify this in a doc PR next week.

mhdawson added a commit to mhdawson/io.js that referenced this issue Jun 15, 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.

Fixes: nodejs#13555
Fixes: nodejs#13556
Fixes: nodejs#13562
mhdawson added a commit that referenced this issue 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 issue Jun 17, 2017
The earlier version `napi_callback` returns `void` but now is
`napi_value`. The document of this section hasn't been modified.

PR-URL: #13570
Fixes: #12248
Fixes: #13562
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this issue 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 pushed a commit that referenced this issue Jun 21, 2017
The earlier version `napi_callback` returns `void` but now is
`napi_value`. The document of this section hasn't been modified.

PR-URL: #13570
Fixes: #12248
Fixes: #13562
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this issue 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]>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Apr 10, 2018
The earlier version `napi_callback` returns `void` but now is
`napi_value`. The document of this section hasn't been modified.

PR-URL: nodejs#13570
Fixes: nodejs#12248
Fixes: nodejs#13562
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue 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 issue Apr 16, 2018
The earlier version `napi_callback` returns `void` but now is
`napi_value`. The document of this section hasn't been modified.

Backport-PR-URL: #19447
PR-URL: #13570
Fixes: #12248
Fixes: #13562
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jason Ginchereau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this issue 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]>
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 a pull request may close this issue.

3 participants