Skip to content

Commit cc92231

Browse files
XadillaXaddaleax
authored andcommitted
doc: fix out of date napi_callback doc
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]>
1 parent 5cb3fac commit cc92231

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

doc/api/n-api.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,16 @@ For more details, review the [Object Lifetime Management][].
161161

162162
### N-API Callback types
163163
#### *napi_callback_info*
164-
Opaque datatype that is passed to a callback function. It can be used for two
165-
purposes:
166-
- Get additional information about the context in which the callback was
167-
invoked.
168-
- Set the return value of the callback.
164+
Opaque datatype that is passed to a callback function. It can be used for
165+
getting additional information about the context in which the callback was
166+
invoked.
169167

170168
#### *napi_callback*
171169
Function pointer type for user-provided native functions which are to be
172170
exposed to JavaScript via N-API. Callback functions should satisfy the
173171
following signature:
174172
```C
175-
typedef void (*napi_callback)(napi_env, napi_callback_info);
173+
typedef napi_value (*napi_callback)(napi_env, napi_callback_info);
176174
```
177175
178176
#### *napi_finalize*
@@ -2516,8 +2514,9 @@ In order to expose a function as part of the
25162514
add-on's module exports, set the newly created function on the exports
25172515
object. A sample module might look as follows:
25182516
```C
2519-
void SayHello(napi_env env, napi_callback_info info) {
2517+
napi_value SayHello(napi_env env, napi_callback_info info) {
25202518
printf("Hello\n");
2519+
return nullptr;
25212520
}
25222521
25232522
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {

0 commit comments

Comments
 (0)