Replace napi_is_construct_call with napi_get_new_target#113
Closed
sampsongao wants to merge 5 commits intonodejs:masterfrom
Closed
Replace napi_is_construct_call with napi_get_new_target#113sampsongao wants to merge 5 commits intonodejs:masterfrom
sampsongao wants to merge 5 commits intonodejs:masterfrom
Conversation
addaleax
approved these changes
Aug 21, 2017
Member
addaleax
left a comment
There was a problem hiding this comment.
LGTM
It might be pretty cheap to just introduce a CallbackInfo::NewTarget() method and make IsConstructCall() a small wrapper around it while you’re at it
addaleax
approved these changes
Aug 22, 2017
napi-inl.h
Outdated
| napi_value newTarget; | ||
| napi_status status = napi_get_new_target(_env, _info, &newTarget); | ||
| bool isConstructCall = (new_target != nullptr); | ||
| NAPI_THROW_IF_FAILED(_env, status, false); |
Member
There was a problem hiding this comment.
Shouldn’t this line be part of NewTarget() as well?
By the way, what I had in mind was just replacing IsConstructCall with
inline bool CallbackInfo::IsConstructCall() const {
return !NewTarget().IsEmpty();
}2dc38a9 to
0eda0d6
Compare
mhdawson
approved these changes
Aug 22, 2017
Member
mhdawson
left a comment
There was a problem hiding this comment.
LGTM but we need to make sure not to land until the corresponding change goes out in an N-API release.
added 2 commits
August 22, 2017 18:59
Author
|
Landed 458f576 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For nodejs/node#14698