Skip to content

Commit f2315a9

Browse files
committed
n-api: break dep between v8 and napi attributes
The v8 n-api implementation had been depending on a one-to-one relationship between v8 and n-api v8 property attributes. Remove this dependency and fix coverity scan issue 165845.
1 parent 9b05393 commit f2315a9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/node_api.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,19 @@ napi_status napi_define_class(napi_env env,
741741
v8::Local<v8::String> property_name;
742742
CHECK_NEW_FROM_UTF8(isolate, property_name, p->utf8name);
743743

744+
// convert the properties from NAPI to v8 format
745+
unsigned int attribute_flags = v8::None;
746+
if ((p->attributes & napi_read_only)) {
747+
attribute_flags |= v8::ReadOnly;
748+
}
749+
if ((p->attributes & napi_dont_enum)) {
750+
attribute_flags |= v8::DontEnum;
751+
}
752+
if ((p->attributes & napi_dont_delete)) {
753+
attribute_flags |= v8::DontDelete;
754+
}
744755
v8::PropertyAttribute attributes =
745-
static_cast<v8::PropertyAttribute>(p->attributes);
756+
static_cast<v8::PropertyAttribute>(attribute_flags);
746757

747758
// This code is similar to that in napi_define_property(); the
748759
// difference is it applies to a template instead of an object.

0 commit comments

Comments
 (0)