From 574f09e48668032f451386c288f8c100895613c4 Mon Sep 17 00:00:00 2001 From: Sampson Gao Date: Tue, 8 Aug 2017 16:21:56 -0400 Subject: [PATCH] n-api: napi_is_construct_call->napi_get_new_target Remove napi_is_construct_call and introduce napi_get_new_target. PR-URL: https://github.com/nodejs/node/pull/14698 Reviewed-By: Jason Ginchereau Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Kyle Farnung --- doc/api/n-api.md | 17 ++++++++-------- src/node_api.cc | 23 ++++++++++++---------- src/node_api.h | 6 +++--- test/addons-napi/6_object_wrap/myobject.cc | 5 +++-- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 1d9b405c78a07e..4797e62fd97d46 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2928,25 +2928,24 @@ Returns `napi_ok` if the API succeeded. This method is used within a callback function to retrieve details about the call like the arguments and the `this` pointer from a given callback info. -### *napi_is_construct_call* +### *napi_get_new_target* ```C -napi_status napi_is_construct_call(napi_env env, - napi_callback_info cbinfo, - bool* result) +napi_status napi_get_new_target(napi_env env, + napi_callback_info cbinfo, + napi_value* result) ``` - `[in] env`: The environment that the API is invoked under. - `[in] cbinfo`: The callback info passed into the callback function. -- `[out] result`: Whether the native function is being invoked as -a constructor call. +- `[out] result`: The `new.target` of the constructor call. Returns `napi_ok` if the API succeeded. -This API checks if the the current callback was due to a -consructor call. +This API returns the `new.target` of the constructor call. If the current +callback is not a constructor call, the result is `nullptr`. ### *napi_new_instance*