@@ -121,6 +121,24 @@ must use Node-API exclusively by restricting itself to using
121121and by checking, for all external libraries that it uses, that the external
122122library makes ABI stability guarantees similar to Node-API.
123123
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 types should be explicitly documented, and they
128+ work with bit operators like bit-OR (`|`) as a bit value. Unless otherwise
129+ documented, 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 codes can 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 of 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+
124142## Building
125143
126144Unlike modules written in JavaScript, developing and deploying Node.js
@@ -2203,7 +2221,7 @@ typedef enum {
22032221} napi_key_filter;
22042222```
22052223
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.
22072225
22082226#### `napi_key_conversion`
22092227
@@ -4419,11 +4437,11 @@ typedef enum {
44194437} napi_property_attributes;
44204438```
44214439
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 :
44274445
44284446* `napi_default`: No explicit attributes are set on the property. By default, a
44294447 property is read only, not enumerable and not configurable.
0 commit comments