summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Dawson <mdawson@devrus.com>2020-11-10 10:20:28 -0500
committerBeth Griggs <bgriggs@redhat.com>2020-12-15 20:15:22 +0000
commitdde727e72f9b06f3287d9940d5bb14763d12e08f (patch)
tree833e55298966ee17a750a363dcd6bb7a5168e2c4
parent402e29a87c6261f54d1f6d22110f82e4137551f1 (diff)
downloadnode-new-dde727e72f9b06f3287d9940d5bb14763d12e08f.tar.gz
n-api: improve consistency of how we get context
Refs: https://github.com/nodejs/node-addon-api/issues/764 Improve the consistency of how we get a context when needed. We generally used env->context() in N-API but there were are few exceptions that this PR addresses. Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/36068 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
-rw-r--r--src/js_native_api_v8.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc
index 0a3494ce70..64e4298e12 100644
--- a/src/js_native_api_v8.cc
+++ b/src/js_native_api_v8.cc
@@ -169,7 +169,7 @@ inline static napi_status ConcludeDeferred(napi_env env,
NAPI_PREAMBLE(env);
CHECK_ARG(env, result);
- v8::Local<v8::Context> context = env->isolate->GetCurrentContext();
+ v8::Local<v8::Context> context = env->context();
v8impl::Persistent<v8::Value>* deferred_ref =
NodePersistentFromJsDeferred(deferred);
v8::Local<v8::Value> v8_deferred =
@@ -385,8 +385,7 @@ inline static napi_status Unwrap(napi_env env,
CHECK_ARG(env, result);
}
- v8::Isolate* isolate = env->isolate;
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Context> context = env->context();
v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(js_object);
RETURN_STATUS_IF_FALSE(env, value->IsObject(), napi_invalid_arg);