From 79ecc2c586a372e997490a4afd32b80f0b766072 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Fri, 5 Jan 2018 12:19:20 -0500 Subject: [PATCH] doc: updates examples to use NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Examples in the N-API doc used a mix of nullptr and NULL. We should be consistent and because N-API is a 'C' API I believe using NULL is better. This will avoid any potential confusion as to whether N-API can be used with plain C. Backport-PR-URL: https://github.com/nodejs/node/pull/19265 PR-URL: https://github.com/nodejs/node/pull/18008 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen Reviewed-By: Franziska Hinkelmann Reviewed-By: Gireesh Punathil --- doc/api/n-api.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index f9c24fe4a0e2b1..52eb6dbe983cf6 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -905,9 +905,9 @@ napi_value Init(napi_env env, napi_value exports) { napi_status status; napi_property_descriptor desc = {"hello", Method, 0, 0, 0, napi_default, 0}; - if (status != napi_ok) return nullptr; + if (status != napi_ok) return NULL; status = napi_define_properties(env, exports, 1, &desc); - if (status != napi_ok) return nullptr; + if (status != napi_ok) return NULL; return exports; } ``` @@ -919,7 +919,7 @@ napi_value Init(napi_env env, napi_value exports) { napi_value method; napi_status status; status = napi_create_function(env, "exports", Method, NULL, &method)); - if (status != napi_ok) return nullptr; + if (status != napi_ok) return NULL; return method; } ``` @@ -932,21 +932,21 @@ For example, to define a class so that new instances can be created napi_value Init(napi_env env, napi_value exports) { napi_status status; napi_property_descriptor properties[] = { - { "value", nullptr, GetValue, SetValue, 0, napi_default, 0 }, + { "value", NULL, GetValue, SetValue, 0, napi_default, 0 }, DECLARE_NAPI_METHOD("plusOne", PlusOne), DECLARE_NAPI_METHOD("multiply", Multiply), }; napi_value cons; status = - napi_define_class(env, "MyObject", New, nullptr, 3, properties, &cons); - if (status != napi_ok) return nullptr; + napi_define_class(env, "MyObject", New, NULL, 3, properties, &cons); + if (status != napi_ok) return NULL; status = napi_create_reference(env, cons, 1, &constructor); - if (status != napi_ok) return nullptr; + if (status != napi_ok) return NULL; status = napi_set_named_property(env, exports, "MyObject", cons); - if (status != napi_ok) return nullptr; + if (status != napi_ok) return NULL; return exports; } @@ -2364,8 +2364,8 @@ if (status != napi_ok) return status; // Set the properties napi_property_descriptor descriptors[] = { - { "foo", nullptr, 0, 0, 0, fooValue, napi_default, 0 }, - { "bar", nullptr, 0, 0, 0, barValue, napi_default, 0 } + { "foo", NULL, 0, 0, 0, fooValue, napi_default, 0 }, + { "bar", NULL, 0, 0, 0, barValue, napi_default, 0 } } status = napi_define_properties(env, obj, @@ -2876,18 +2876,18 @@ object. A sample module might look as follows: ```C napi_value SayHello(napi_env env, napi_callback_info info) { printf("Hello\n"); - return nullptr; + return NULL; } napi_value Init(napi_env env, napi_value exports) { napi_status status; napi_value fn; - status = napi_create_function(env, nullptr, 0, SayHello, nullptr, &fn); - if (status != napi_ok) return nullptr; + status = napi_create_function(env, NULL, 0, SayHello, nullptr, &fn); + if (status != napi_ok) return NULL; status = napi_set_named_property(env, exports, "sayHello", fn); - if (status != napi_ok) return nullptr; + if (status != napi_ok) return NULL; return exports; } @@ -2952,7 +2952,7 @@ napi_status napi_get_new_target(napi_env env, Returns `napi_ok` if the API succeeded. This API returns the `new.target` of the constructor call. If the current -callback is not a constructor call, the result is `nullptr`. +callback is not a constructor call, the result is `NULL`. ### *napi_new_instance*