n-api: Update property attrs enum to match JS spec#12240
n-api: Update property attrs enum to match JS spec#12240jasongin wants to merge 3 commits intonodejs:masterfrom
Conversation
|
@mhdawson @TimothyGu please review |
There was a problem hiding this comment.
The accessorValue is not actually referenced in the JS layer. You should also find a way to make certain the getters/setters are actually called when getting/setting the property.
Also, tests that cover the normalization logic fully should be added.
src/node_api.cc
Outdated
There was a problem hiding this comment.
Your call, but I think it might be better if this is factored out?
There was a problem hiding this comment.
Yeah I sort of wanted to do that, but it didn't seem right to put it in v8impl::V8PropertyAttributesFromAttributes() because the logic depends on the kind of property descriptor. I'll consider further what to do with this.
src/node_api.cc
Outdated
There was a problem hiding this comment.
Slightly off-topic and basic, but are the C NULL and the C++ nullptr interoperable?
There was a problem hiding this comment.
Slightly off-topic and basic, but are the C
NULLand the C++nullptrinteroperable?
Yup. :) The different names are just historical oddities because C++ NULL is not defined the same way as C NULL, so C++11 introduced nullptr as a direct equivalent to C NULL.
The napi_property_attributes enum used names and values from v8::PropertyAttribute, but those negative flag names were outdated along with the default behavior of a property being writable, enumerable, and configurable unless otherwise specified. To match the ES5 standard property descriptor those attributes should be positive flags and should default to false unless otherwise specified. Fixes: nodejs/abi-stable-node#221
d878c51 to
05586f4
Compare
|
@TimothyGu I pushed a commit to address your feedback, and also rebased. |
src/node_api.cc
Outdated
| @@ -1,4 +1,4 @@ | |||
| /****************************************************************************** | |||
| /****************************************************************************** | |||
There was a problem hiding this comment.
Do you have an idea what this is?
There was a problem hiding this comment.
It's a UTF-8 BOM. VS 2017 likes to insert those for some reason. Fixed.
src/node_api.cc
Outdated
| attribute_flags |= (descriptor->setter == nullptr ? | ||
| v8::PropertyAttribute::ReadOnly : v8::PropertyAttribute::None); | ||
| } | ||
| else if ((descriptor->attributes & napi_writable) == 0) { |
There was a problem hiding this comment.
nit: coalesce the right brace with else
|
CI green, landing. |
|
Landed as 8460284 |
The napi_property_attributes enum used names and values from v8::PropertyAttribute, but those negative flag names were outdated along with the default behavior of a property being writable, enumerable, and configurable unless otherwise specified. To match the ES5 standard property descriptor those attributes should be positive flags and should default to false unless otherwise specified. PR-URL: #12240 Fixes: nodejs/abi-stable-node#221 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
|
Guys I suspect you have a failing test on windows |
|
this is the diff between the PR and 8460284 |
The napi_property_attributes enum used names and values from v8::PropertyAttribute, but those negative flag names were outdated along with the default behavior of a property being writable, enumerable, and configurable unless otherwise specified. To match the ES5 standard property descriptor those attributes should be positive flags and should default to false unless otherwise specified. PR-URL: nodejs#12240 Fixes: nodejs/abi-stable-node#221 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
The napi_property_attributes enum used names and values from v8::PropertyAttribute, but those negative flag names were outdated along with the default behavior of a property being writable, enumerable, and configurable unless otherwise specified. To match the ES5 standard property descriptor those attributes should be positive flags and should default to false unless otherwise specified. Backport-PR-URL: #19447 PR-URL: #12240 Fixes: nodejs/abi-stable-node#221 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
The
napi_property_attributesenum used names and values fromv8::PropertyAttribute, but those negative flag names were outdatedalong with the default behavior of a property being writable,
enumerable, and configurable unless otherwise specified. To match the
ES5 standard property descriptor those attributes should be positive
flags and should default to false unless otherwise specified.
Fixes: nodejs/abi-stable-node#221
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
N-API