From 286979e03b2ca04f6f62aed6ff7321a7976493a7 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Fri, 9 Jun 2017 18:14:22 +0800 Subject: [PATCH 1/2] 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. Fixes: https://github.com/nodejs/node/pull/12248 --- doc/api/n-api.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 668e3fab18f8a5..3a4a950a0d1bfa 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -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); ``` #### *napi_finalize* @@ -2521,8 +2521,9 @@ In order to expose a function as part of the add-on's module exports, set the newly created function on the exports object. A sample module might look as follows: ```C -void SayHello(napi_env env, napi_callback_info info) { +napi_value SayHello(napi_env env, napi_callback_info info) { printf("Hello\n"); + return nullptr; } void Init(napi_env env, napi_value exports, napi_value module, void* priv) { From 3ffd672cbf7ac1b6a0123e3da32d9fe5947a8263 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Sat, 10 Jun 2017 19:40:22 +0800 Subject: [PATCH 2/2] change the doc of napi_callback_info --- doc/api/n-api.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 3a4a950a0d1bfa..cb585c7c4fcd6d 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -161,11 +161,9 @@ For more details, review the [Object Lifetime Management][]. ### N-API Callback types #### *napi_callback_info* -Opaque datatype that is passed to a callback function. It can be used for two -purposes: -- Get additional information about the context in which the callback was - invoked. -- Set the return value of the callback. +Opaque datatype that is passed to a callback function. It can be used for +getting additional information about the context in which the callback was +invoked. #### *napi_callback* Function pointer type for user-provided native functions which are to be