Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGerhard Stoebich <18708370+Flarna@users.noreply.github.com>2020-09-16 00:04:48 +0300
committerGerhard Stoebich <18708370+Flarna@users.noreply.github.com>2020-09-18 01:53:16 +0300
commitc9506a8f3e9bc5c679151feb39198023154464ab (patch)
tree90d2ea6d6d2603e0af0ac97fda35a910ad5c7244 /src
parent59ca56eddefc78bab87d7e8e074b3af843ab1bc3 (diff)
n-api: add more property defaults
Add a default value for class method and js like property in enum napi_property_attributes. n-api currently offers only one default which is non configurable, non writable, non enumerable - like Object.defineProperty(). While this is formal correct the usual way to create properties in JS is either by defining a class or use obj.prop = value. The defaults from these variants are now backed into enum values. PR-URL: https://github.com/nodejs/node/pull/35214 Refs: https://github.com/nodejs/node-addon-api/issues/811 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/js_native_api_types.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/js_native_api_types.h b/src/js_native_api_types.h
index 115ccebf261..7011c80e671 100644
--- a/src/js_native_api_types.h
+++ b/src/js_native_api_types.h
@@ -30,6 +30,16 @@ typedef enum {
// Used with napi_define_class to distinguish static properties
// from instance properties. Ignored by napi_define_properties.
napi_static = 1 << 10,
+
+#ifdef NAPI_EXPERIMENTAL
+ // Default for class methods.
+ napi_default_method = napi_writable | napi_configurable,
+
+ // Default for object properties, like in JS obj[prop].
+ napi_default_jsproperty = napi_writable |
+ napi_enumerable |
+ napi_configurable,
+#endif // NAPI_EXPERIMENTAL
} napi_property_attributes;
typedef enum {