Skip to content
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

n-api: make changes for source compatibility #16102

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ class CallbackWrapper {
CallbackWrapper(napi_value this_arg, size_t args_length, void* data)
: _this(this_arg), _args_length(args_length), _data(data) {}

virtual napi_value NewTarget() = 0;
virtual napi_value GetNewTarget() = 0;
virtual void Args(napi_value* buffer, size_t bufferlength) = 0;
virtual void SetReturnValue(napi_value value) = 0;

Expand Down Expand Up @@ -484,7 +484,7 @@ class CallbackWrapperBase : public CallbackWrapper {
->Value();
}

napi_value NewTarget() override { return nullptr; }
napi_value GetNewTarget() override { return nullptr; }

protected:
void InvokeCallback() {
Expand Down Expand Up @@ -532,7 +532,7 @@ class FunctionCallbackWrapper
const v8::FunctionCallbackInfo<v8::Value>& cbinfo)
: CallbackWrapperBase(cbinfo, cbinfo.Length()) {}

napi_value NewTarget() override {
napi_value GetNewTarget() override {
if (_cbinfo.IsConstructCall()) {
return v8impl::JsValueFromV8LocalValue(_cbinfo.NewTarget());
} else {
Expand Down Expand Up @@ -854,8 +854,12 @@ void napi_module_register_cb(v8::Local<v8::Object> exports,

// Registers a NAPI module.
void napi_module_register(napi_module* mod) {
int module_version = -1;
#ifdef EXTERNAL_NAPI
module_version = NODE_MODULE_VERSION;
#endif // EXTERNAL_NAPI
node::node_module* nm = new node::node_module {
-1,
module_version,
mod->nm_flags,
nullptr,
mod->nm_filename,
Expand Down Expand Up @@ -1908,7 +1912,7 @@ napi_status napi_get_new_target(napi_env env,
v8impl::CallbackWrapper* info =
reinterpret_cast<v8impl::CallbackWrapper*>(cbinfo);

*result = info->NewTarget();
*result = info->GetNewTarget();
return napi_clear_last_error(env);
}

Expand Down Expand Up @@ -3335,7 +3339,7 @@ class Work : public node::AsyncResource {
void* data = nullptr)
: AsyncResource(env->isolate,
async_resource,
async_resource_name),
*v8::String::Utf8Value(async_resource_name)),
_env(env),
_data(data),
_execute(execute),
Expand Down