Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98d7f25

Browse filesBrowse files
mhdawsonaddaleax
authored andcommitted
doc: fix out of date sections in n-api doc
PR-URL: #13508 Fixes: #13469 Fixes: #13458 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
1 parent 6a696d1 commit 98d7f25
Copy full SHA for 98d7f25

File tree

Expand file treeCollapse file tree

1 file changed

+26
-37
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+26
-37
lines changed
Open diff view settings
Collapse file

‎doc/api/n-api.md‎

Copy file name to clipboardExpand all lines: doc/api/n-api.md
+26-37Lines changed: 26 additions & 37 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1560,25 +1560,6 @@ is passed in it returns `napi_number_expected`.
15601560
This API returns the C int64 primitive equivalent of the given
15611561
JavaScript Number
15621562
1563-
#### *napi_get_value_string_length*
1564-
<!-- YAML
1565-
added: v8.0.0
1566-
-->
1567-
```C
1568-
napi_status napi_get_value_string_length(napi_env env,
1569-
napi_value value,
1570-
int* result)
1571-
```
1572-
1573-
- `[in] env`: The environment that the API is invoked under.
1574-
- `[in] value`: `napi_value` representing JavaScript string.
1575-
- `[out] result`: Number of characters in the given JavaScript string.
1576-
1577-
Returns `napi_ok` if the API succeeded. If a non-String `napi_value`
1578-
is passed in it returns `napi_string_expected`.
1579-
1580-
This API returns the number of characters in the given JavaScript string.
1581-
15821563
#### *napi_get_value_string_utf8*
15831564
<!-- YAML
15841565
added: v8.0.0
@@ -2100,39 +2081,42 @@ if (status != napi_ok) return status;
21002081
```C
21012082
typedef enum {
21022083
napi_default = 0,
2103-
napi_read_only = 1 << 0,
2104-
napi_dont_enum = 1 << 1,
2105-
napi_dont_delete = 1 << 2,
2106-
napi_static_property = 1 << 10,
2084+
napi_writable = 1 << 0,
2085+
napi_enumerable = 1 << 1,
2086+
napi_configurable = 1 << 2,
2087+
2088+
// Used with napi_define_class to distinguish static properties
2089+
// from instance properties. Ignored by napi_define_properties.
2090+
napi_static = 1 << 10,
21072091
} napi_property_attributes;
21082092
```
21092093

21102094
`napi_property_attributes` are flags used to control the behavior of properties
2111-
set on a JavaScript object. They roughly correspond to the attributes listed in
2112-
[Section 6.1.7.1](https://tc39.github.io/ecma262/#table-2) of the
2113-
[ECMAScript Language Specification](https://tc39.github.io/ecma262/). They can
2114-
be one or more of the following bitflags:
2095+
set on a JavaScript object. Other than `napi_static` they correspond to the
2096+
attributes listed in [Section 6.1.7.1](https://tc39.github.io/ecma262/#table-2)
2097+
of the [ECMAScript Language Specification](https://tc39.github.io/ecma262/).
2098+
They can be one or more of the following bitflags:
21152099

21162100
- `napi_default` - Used to indicate that no explicit attributes are set on the
2117-
given property. By default, a property is Writable, Enumerable, and
2118-
Configurable. This is a deviation from the ECMAScript specification,
2119-
where generally the values for a property descriptor attribute default to
2120-
false if they're not provided.
2121-
- `napi_read_only` - Used to indicate that a given property is not Writable.
2122-
- `napi_dont_enum` - Used to indicate that a given property is not Enumerable.
2123-
- `napi_dont_delete` - Used to indicate that a given property is not.
2124-
Configurable, as defined in
2101+
given property. By default, a property is read only, not enumerable and not
2102+
configurable.
2103+
- `napi_writable` - Used to indicate that a given property is writable.
2104+
- `napi_enumerable` - Used to indicate that a given property is enumerable.
2105+
- `napi_configurable` - Used to indicate that a given property is
2106+
configurable, as defined in
21252107
[Section 6.1.7.1](https://tc39.github.io/ecma262/#table-2) of the
21262108
[ECMAScript Language Specification](https://tc39.github.io/ecma262/).
2127-
- `napi_static_property` - Used to indicate that the property will be defined as
2109+
- `napi_static` - Used to indicate that the property will be defined as
21282110
a static property on a class as opposed to an instance property, which is the
21292111
default. This is used only by [`napi_define_class`][]. It is ignored by
21302112
`napi_define_properties`.
21312113

21322114
#### *napi_property_descriptor*
21332115
```C
21342116
typedef struct {
2117+
// One of utf8name or name should be NULL.
21352118
const char* utf8name;
2119+
napi_value name;
21362120

21372121
napi_callback method;
21382122
napi_callback getter;
@@ -2144,7 +2128,12 @@ typedef struct {
21442128
} napi_property_descriptor;
21452129
```
21462130

2147-
- `utf8name`: String describing the key for the property, encoded as UTF8.
2131+
- `utf8name`: Optional String describing the key for the property,
2132+
encoded as UTF8. One of `utf8name` or `name` must be provided for the
2133+
property.
2134+
- `name`: Optional napi_value that points to a JavaScript string or symbol
2135+
to be used as the key for the property. One of `utf8name` or `name` must
2136+
be provided for the property.
21482137
- `value`: The value that's retrieved by a get access of the property if the
21492138
property is a data property. If this is passed in, set `getter`, `setter`,
21502139
`method` and `data` to `NULL` (since these members won't be used).

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.