Skip to content

Conversation

@sampsongao
Copy link

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@sampsongao sampsongao requested a review from jasongin August 21, 2017 20:06
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
}

@sampsongao sampsongao force-pushed the remove_is_construct_call branch from 2dc38a9 to 0eda0d6 Compare August 22, 2017 21:16
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but we need to make sure not to land until the corresponding change goes out in an N-API release.

@sampsongao
Copy link
Author

Landed 458f576

@sampsongao sampsongao closed this Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants