1212#include < node_object_wrap.h>
1313#include < string.h>
1414#include < algorithm>
15+ #include < cassert>
1516#include < cmath>
1617#include < vector>
18+ #include " uv.h"
1719#include " node_api.h"
18- #include " env-inl.h"
1920
2021napi_status napi_set_last_error (napi_env env, napi_status error_code,
2122 uint32_t engine_error_code = 0 ,
@@ -43,9 +44,9 @@ struct napi_env__ {
4344 } \
4445 } while (0 )
4546
46- #define CHECK_ENV (env ) \
47- if ((env) == nullptr ) { \
48- node::FatalError (__func__, " environment(env) must not be null " ); \
47+ #define CHECK_ENV (env ) \
48+ if ((env) == nullptr ) { \
49+ return napi_invalid_arg; \
4950 }
5051
5152#define CHECK_ARG (env, arg ) \
@@ -570,8 +571,7 @@ class SetterCallbackWrapper
570571
571572 /* virtual*/
572573 void SetReturnValue (napi_value value) override {
573- node::FatalError (" napi_set_return_value" ,
574- " Cannot return a value from a setter callback." );
574+ // Ignore any value returned from a setter callback.
575575 }
576576
577577 private:
@@ -730,7 +730,8 @@ napi_status napi_get_last_error_info(napi_env env,
730730 const napi_extended_error_info** result) {
731731 CHECK_ENV (env);
732732
733- static_assert (node::arraysize (error_messages) == napi_status_last,
733+ static_assert (
734+ (sizeof (error_messages) / sizeof (*error_messages)) == napi_status_last,
734735 " Count of error messages must match count of error values" );
735736 assert (env->last_error .error_code < napi_status_last);
736737
@@ -1634,7 +1635,7 @@ napi_status napi_get_value_int32(napi_env env,
16341635
16351636 v8::Isolate* isolate = env->isolate ;
16361637 v8::Local<v8::Context> context = isolate->GetCurrentContext ();
1637- *result = val->Int32Value (context).ToChecked ();
1638+ *result = val->Int32Value (context).FromJust ();
16381639
16391640 return napi_ok;
16401641}
@@ -1653,7 +1654,7 @@ napi_status napi_get_value_uint32(napi_env env,
16531654
16541655 v8::Isolate* isolate = env->isolate ;
16551656 v8::Local<v8::Context> context = isolate->GetCurrentContext ();
1656- *result = val->Uint32Value (context).ToChecked ();
1657+ *result = val->Uint32Value (context).FromJust ();
16571658
16581659 return napi_ok;
16591660}
@@ -1678,7 +1679,7 @@ napi_status napi_get_value_int64(napi_env env,
16781679 } else {
16791680 v8::Isolate* isolate = env->isolate ;
16801681 v8::Local<v8::Context> context = isolate->GetCurrentContext ();
1681- *result = val->IntegerValue (context).ToChecked ();
1682+ *result = val->IntegerValue (context).FromJust ();
16821683 }
16831684
16841685 return napi_ok;
@@ -2684,9 +2685,11 @@ napi_status napi_queue_async_work(napi_env env, napi_async_work work) {
26842685 CHECK_ENV (env);
26852686 CHECK_ARG (env, work);
26862687
2687- // Consider: Encapsulate the uv_loop_t into an opaque pointer parameter
2688- uv_loop_t * event_loop =
2689- node::Environment::GetCurrent (env->isolate )->event_loop ();
2688+ // Consider: Encapsulate the uv_loop_t into an opaque pointer parameter.
2689+ // Currently the environment event loop is the same as the UV default loop.
2690+ // Someday (if node ever supports multiple isolates), it may be better to get
2691+ // the loop from node::Environment::GetCurrent(env->isolate)->event_loop();
2692+ uv_loop_t * event_loop = uv_default_loop ();
26902693
26912694 uvimpl::Work* w = reinterpret_cast <uvimpl::Work*>(work);
26922695
0 commit comments