@@ -121,6 +121,24 @@ must use Node-API exclusively by restricting itself to using
121
121
and by checking, for all external libraries that it uses, that the external
122
122
library makes ABI stability guarantees similar to Node-API.
123
123
124
+ ### Enum values in ABI stability
125
+
126
+ All enum data types defined in Node-API should be considered as a fixed size
127
+ integer value. Bit flag enum type should be explicitly documented, and they work
128
+ with bit operators like bit-OR (`|`) as a bit value. Unless otherwise documented,
129
+ an enum type should be considered to be extensible.
130
+
131
+ For an enum type returned from an Node-API function, or as an out parameter of
132
+ an Node-API function, the value is an integer value and an addon should
133
+ handle unknown values. For example, an addon should have a `default` branch
134
+ when checking `napi_status` in switch statements as new status code will be
135
+ introduced in newer Node.js versions.
136
+
137
+ For an enum type used in an in-parameter, extended values are guarded with
138
+ Node-API version since which version they are introduced. The result of passing
139
+ an unknown integer value to Node-API functions is undefined unless otherwise
140
+ documented.
141
+
124
142
## Building
125
143
126
144
Unlike modules written in JavaScript, developing and deploying Node.js
@@ -2203,7 +2221,7 @@ typedef enum {
2203
2221
} napi_key_filter;
2204
2222
```
2205
2223
2206
- Property filter bits. They can be or'ed to build a composite filter.
2224
+ Property filter bit flag. This works with bit-OR operator to build a composite filter.
2207
2225
2208
2226
#### `napi_key_conversion`
2209
2227
@@ -4419,11 +4437,11 @@ typedef enum {
4419
4437
} napi_property_attributes;
4420
4438
```
4421
4439
4422
- `napi_property_attributes` are flags used to control the behavior of properties
4423
- set on a JavaScript object. Other than `napi_static` they correspond to the
4424
- attributes listed in [Section 6.1.7.1][]
4425
- of the [ECMAScript Language Specification][].
4426
- They can be one or more of the following bitflags :
4440
+ `napi_property_attributes` are bit flags used to control the behavior of
4441
+ properties set on a JavaScript object. This works with bit-OR operator. Other
4442
+ than `napi_static` they correspond to the attributes listed in
4443
+ [Section 6.1.7.1][] of the [ECMAScript Language Specification][].
4444
+ They can be one or more of the following bit flags :
4427
4445
4428
4446
* `napi_default`: No explicit attributes are set on the property. By default, a
4429
4447
property is read only, not enumerable and not configurable.
0 commit comments