Skip to content

Commit

Permalink
n-api: improve consistency of how we get context
Browse files Browse the repository at this point in the history
Refs: nodejs/node-addon-api#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: #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>
  • Loading branch information
mhdawson authored and BethGriggs committed Dec 15, 2020
1 parent 402e29a commit dde727e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dde727e

Please sign in to comment.