Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
n-api: add napi_get_own_property_names#28944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
himself65 commented Aug 2, 2019 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
addaleax commented Aug 2, 2019
@nodejs/n-api I feel like this approach kind of leads to questions like “what if we also want symbols/inherited properties/no indices/…”, and we might want to come up with something that has flexibility which is similar to the V8 API? |
e5c0692 to 2e62342CompareUh oh!
There was an error while loading. Please reload this page.
mhdawson commented Aug 14, 2019
+1 to making it more flexible as long as the options supported are part of the standard and will be supported by all engines. |
Trott commented Aug 25, 2019
@addaleax@mhdawson @nodejs/n-api Are we likely to land this? If not, I'd like to close it. If we're likely to land it, I'd like to nudge it forward. /ping @himself65! Or maybe reviewers can perhaps push fixup changes to the branch to get it where it needs to go and expedite things a bit? |
addaleax commented Aug 25, 2019
@Trott Yes, but @mhdawson’s comment need to be addressed and we do need somebody (e.g. @himself65) to figure out in what way we expose the other option flags, if we do so. |
himself65 commented Aug 26, 2019
I will push fixed changes later :) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
gabrielschulhof left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is good, but we really need to return napi_pending_exception whenever there is the possibility that an exception has occurred on the JS side.
Uh oh!
There was an error while loading. Please reload this page.
ffd2f2e to b505c1dCompareUh oh!
There was an error while loading. Please reload this page.
2564901 to d596434Comparenodejs-github-bot commented Oct 16, 2019
Trott commented Oct 16, 2019
addaleax left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, code-wise this LGTM, but I still feel like the API should expose flags similar to the ones we get from V8, otherwise this just begs for Yet Another Function That Does The Same Thing.
Uh oh!
There was an error while loading. Please reload this page.
gabrielschulhof commented Oct 16, 2019
@himself65 can you please check whether other engines, such as JerryScript, have the facilities to retrieve property names as selectively as V8? That is, could the kind of flexibility that V8 provides (skipping/not skipping symbols, rendering as string/leaving as number) be implemented
if needed? |
addaleax commented Oct 16, 2019
@gabrielschulhof From a look at JerryScript’s API docs, the API only exposes a way to get enumerable properties. But I wouldn’t care too much for that here – any spec-compatible JS implementation needs to have a way to provide all properties, because it could always be implemented in terms of JS builtin functions. |
devsnek commented Oct 16, 2019
the js spec has operations that ask for a filtered subset of own properties, so I think it's reasonable that we can provide something similar here. Even if a napi wrapper has to do the work instead of the engine. |
gabrielschulhof commented Oct 16, 2019
@devsnek@addaleax sounds like we can safely expose the full flexibility provided by V8 because on other engines this same flexibility can be implemented by either filtering after then engine's native API returns, or calling a spec-compliant JS API if the native API is incapable of returning unfiltered results. Similarly, I guess we can use type coercion in post-processing to address the flexibility in the second parameter. @himself65 would you mind exposing the two parameters provided by V8? I suppose we'll have to add a Honestly, I'm not sure whether we shouldn't just go with typedefenum{napi_key_own, napi_key_all } napi_key_collection_mode; typedefenum{napi_key_strings = 1, napi_key_symbols = 1 << 1 } napi_key_types; typedefenum{napi_keep_numbers, napi_numbers_to_strings } napi_key_coercion; napi_status napi_get_all_property_names(napi_env env, napi_value object, napi_key_collection_mode key_mode, napi_key_types key_types, napi_key_coercion key_coercion, napi_value* result);and basically expose We can then re-implement |
legendecas commented Oct 17, 2019
Would filter |
gabrielschulhof commented Oct 17, 2019
@legendecas right, we need one more enum for one more flag to the method. |
himself65 commented Oct 17, 2019
I will open a new pull request about that later 🤔 |
fhinkel commented Nov 1, 2019
ping @himself65 |
himself65 commented Nov 17, 2019
How to implement that? 🤔 |
legendecas commented Nov 17, 2019
himself65 commented Nov 17, 2019
@legendecas Fixed and this pr should after #30006 for now |
876d845 to ad4a54aCompare9bf1126 to d93c285Comparegabrielschulhof commented Jan 10, 2020
IINM this PR is superseded by #30006, so I will close it. Please re-open if I am mistaken. |
fix#28942, and this pr should after #30006
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes