@@ -551,10 +551,11 @@ NAPI_NO_RETURN void napi_fatal_error(const char* location,
551
551
```
552
552
553
553
- `[in] location`: Optional location at which the error occurred.
554
- - `[in] location_len`: The length of the location in bytes, or -1 if it is
555
- null-terminated.
554
+ - `[in] location_len`: The length of the location in bytes, or
555
+ NAPI_AUTO_LENGTH if it is null-terminated.
556
556
- `[in] message`: The message associated with the error.
557
- - `[in] message_len`: The length of the message in bytes, or -1 if it is
557
+ - `[in] message_len`: The length of the message in bytes, or
558
+ NAPI_AUTO_LENGTH if it is
558
559
null-terminated.
559
560
560
561
The function call does not return, the process will be terminated.
@@ -1256,8 +1257,8 @@ napi_status napi_create_function(napi_env env,
1256
1257
- `[in] env`: The environment that the API is invoked under.
1257
1258
- `[in] utf8name`: A string representing the name of the function encoded as
1258
1259
UTF8.
1259
- - `[in] length`: The length of the utf8name in bytes, or -1 if it is
1260
- null-terminated.
1260
+ - `[in] length`: The length of the utf8name in bytes, or
1261
+ NAPI_AUTO_LENGTH if it is null-terminated.
1261
1262
- `[in] cb`: A function pointer to the native function to be invoked when the
1262
1263
created function is invoked from JavaScript.
1263
1264
- `[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,
1489
1490
1490
1491
- `[in] env`: The environment that the API is invoked under.
1491
1492
- `[in] str`: Character buffer representing a ISO-8859-1-encoded string.
1492
- - `[in] length`: The length of the string in bytes, or -1 if it is
1493
- null-terminated.
1493
+ - `[in] length`: The length of the string in bytes, or
1494
+ NAPI_AUTO_LENGTH if it is null-terminated.
1494
1495
- `[out] result`: A `napi_value` representing a JavaScript String.
1495
1496
1496
1497
Returns `napi_ok` if the API succeeded.
@@ -1514,8 +1515,8 @@ napi_status napi_create_string_utf16(napi_env env,
1514
1515
1515
1516
- `[in] env`: The environment that the API is invoked under.
1516
1517
- `[in] str`: Character buffer representing a UTF16-LE-encoded string.
1517
- - `[in] length`: The length of the string in two-byte code units, or -1 if
1518
- it is null-terminated.
1518
+ - `[in] length`: The length of the string in two-byte code units, or
1519
+ NAPI_AUTO_LENGTH if it is null-terminated.
1519
1520
- `[out] result`: A `napi_value` representing a JavaScript String.
1520
1521
1521
1522
Returns `napi_ok` if the API succeeded.
@@ -1539,8 +1540,8 @@ napi_status napi_create_string_utf8(napi_env env,
1539
1540
1540
1541
- `[in] env`: The environment that the API is invoked under.
1541
1542
- `[in] str`: Character buffer representing a UTF8-encoded string.
1542
- - `[in] length`: The length of the string in bytes, or -1 if it is
1543
- null-terminated.
1543
+ - `[in] length`: The length of the string in bytes, or NAPI_AUTO_LENGTH
1544
+ if it is null-terminated.
1544
1545
- `[out] result`: A `napi_value` representing a JavaScript String.
1545
1546
1546
1547
Returns `napi_ok` if the API succeeded.
@@ -2304,7 +2305,7 @@ status = napi_create_array(env, &arr);
2304
2305
if (status != napi_ok) return status;
2305
2306
2306
2307
// Create a napi_value for 'hello'
2307
- status = napi_create_string_utf8(env, "hello", -1 , &value);
2308
+ status = napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH , &value);
2308
2309
if (status != napi_ok) return status;
2309
2310
2310
2311
// arr[123] = 'hello';
@@ -2993,7 +2994,7 @@ status = napi_get_named_property(env, global, "MyObject", &constructor);
2993
2994
if (status != napi_ok) return;
2994
2995
2995
2996
// const arg = "hello"
2996
- status = napi_create_string_utf8(env, "hello", -1 , &arg);
2997
+ status = napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH , &arg);
2997
2998
if (status != napi_ok) return;
2998
2999
2999
3000
napi_value* argv = &arg;
@@ -3040,8 +3041,8 @@ napi_status napi_define_class(napi_env env,
3040
3041
- `[in] utf8name`: Name of the JavaScript constructor function; this is
3041
3042
not required to be the same as the C++ class name, though it is recommended
3042
3043
for clarity.
3043
- - `[in] length`: The length of the utf8name in bytes, or -1 if it is
3044
- null-terminated.
3044
+ - `[in] length`: The length of the utf8name in bytes, or NAPI_AUTO_LENGTH
3045
+ if it is null-terminated.
3045
3046
- `[in] constructor`: Callback function that handles constructing instances
3046
3047
of the class. (This should be a static method on the class, not an actual
3047
3048
C++ constructor function.)
0 commit comments