diff options
author | Michael Dawson <michael_dawson@ca.ibm.com> | 2017-10-13 20:11:10 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2017-10-18 09:34:43 +0300 |
commit | 3e7945ad3ab2ed91fa34c4c9709c4ae7b04feab3 (patch) | |
tree | 9bccc8d7893bf8f24bf00e92c2cd2d685e5531a3 /doc | |
parent | 8a172cb085ea79ca986a420e3a36563b28146720 (diff) |
doc: update to use NAPI_AUTO_LENGTH
Update so that doc says to use NAPI_AUTO_LENGTH instead
of -1 to indicate null terminate string.
PR-URL: https://github.com/nodejs/node/pull/16187
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/n-api.md | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 7bd20c60b60..e023d756103 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -551,10 +551,11 @@ NAPI_NO_RETURN void napi_fatal_error(const char* location, ``` - `[in] location`: Optional location at which the error occurred. -- `[in] location_len`: The length of the location in bytes, or -1 if it is -null-terminated. +- `[in] location_len`: The length of the location in bytes, or +NAPI_AUTO_LENGTH if it is null-terminated. - `[in] message`: The message associated with the error. -- `[in] message_len`: The length of the message in bytes, or -1 if it is +- `[in] message_len`: The length of the message in bytes, or +NAPI_AUTO_LENGTH if it is null-terminated. The function call does not return, the process will be terminated. @@ -1256,8 +1257,8 @@ napi_status napi_create_function(napi_env env, - `[in] env`: The environment that the API is invoked under. - `[in] utf8name`: A string representing the name of the function encoded as UTF8. -- `[in] length`: The length of the utf8name in bytes, or -1 if it is -null-terminated. +- `[in] length`: The length of the utf8name in bytes, or +NAPI_AUTO_LENGTH if it is null-terminated. - `[in] cb`: A function pointer to the native function to be invoked when the created function is invoked from JavaScript. - `[in] data`: Optional arbitrary context data to be passed into the native @@ -1489,8 +1490,8 @@ napi_status napi_create_string_latin1(napi_env env, - `[in] env`: The environment that the API is invoked under. - `[in] str`: Character buffer representing a ISO-8859-1-encoded string. -- `[in] length`: The length of the string in bytes, or -1 if it is -null-terminated. +- `[in] length`: The length of the string in bytes, or +NAPI_AUTO_LENGTH if it is null-terminated. - `[out] result`: A `napi_value` representing a JavaScript String. Returns `napi_ok` if the API succeeded. @@ -1514,8 +1515,8 @@ napi_status napi_create_string_utf16(napi_env env, - `[in] env`: The environment that the API is invoked under. - `[in] str`: Character buffer representing a UTF16-LE-encoded string. -- `[in] length`: The length of the string in two-byte code units, or -1 if -it is null-terminated. +- `[in] length`: The length of the string in two-byte code units, or +NAPI_AUTO_LENGTH if it is null-terminated. - `[out] result`: A `napi_value` representing a JavaScript String. Returns `napi_ok` if the API succeeded. @@ -1539,8 +1540,8 @@ napi_status napi_create_string_utf8(napi_env env, - `[in] env`: The environment that the API is invoked under. - `[in] str`: Character buffer representing a UTF8-encoded string. -- `[in] length`: The length of the string in bytes, or -1 if it is -null-terminated. +- `[in] length`: The length of the string in bytes, or NAPI_AUTO_LENGTH +if it is null-terminated. - `[out] result`: A `napi_value` representing a JavaScript String. Returns `napi_ok` if the API succeeded. @@ -2304,7 +2305,7 @@ status = napi_create_array(env, &arr); if (status != napi_ok) return status; // Create a napi_value for 'hello' -status = napi_create_string_utf8(env, "hello", -1, &value); +status = napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH, &value); if (status != napi_ok) return status; // arr[123] = 'hello'; @@ -2993,7 +2994,7 @@ status = napi_get_named_property(env, global, "MyObject", &constructor); if (status != napi_ok) return; // const arg = "hello" -status = napi_create_string_utf8(env, "hello", -1, &arg); +status = napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH, &arg); if (status != napi_ok) return; napi_value* argv = &arg; @@ -3040,8 +3041,8 @@ napi_status napi_define_class(napi_env env, - `[in] utf8name`: Name of the JavaScript constructor function; this is not required to be the same as the C++ class name, though it is recommended for clarity. - - `[in] length`: The length of the utf8name in bytes, or -1 if it is -null-terminated. + - `[in] length`: The length of the utf8name in bytes, or NAPI_AUTO_LENGTH +if it is null-terminated. - `[in] constructor`: Callback function that handles constructing instances of the class. (This should be a static method on the class, not an actual C++ constructor function.) |