12
12
#include < node_object_wrap.h>
13
13
#include < string.h>
14
14
#include < algorithm>
15
+ #include < cassert>
15
16
#include < cmath>
16
17
#include < vector>
18
+ #include " uv.h"
17
19
#include " node_api.h"
18
- #include " env-inl.h"
19
20
20
21
napi_status napi_set_last_error (napi_env env, napi_status error_code,
21
22
uint32_t engine_error_code = 0 ,
@@ -43,9 +44,9 @@ struct napi_env__ {
43
44
} \
44
45
} while (0 )
45
46
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; \
49
50
}
50
51
51
52
#define CHECK_ARG (env, arg ) \
@@ -570,8 +571,7 @@ class SetterCallbackWrapper
570
571
571
572
/* virtual*/
572
573
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.
575
575
}
576
576
577
577
private:
@@ -730,7 +730,8 @@ napi_status napi_get_last_error_info(napi_env env,
730
730
const napi_extended_error_info** result) {
731
731
CHECK_ENV (env);
732
732
733
- static_assert (node::arraysize (error_messages) == napi_status_last,
733
+ static_assert (
734
+ (sizeof (error_messages) / sizeof (*error_messages)) == napi_status_last,
734
735
" Count of error messages must match count of error values" );
735
736
assert (env->last_error .error_code < napi_status_last);
736
737
@@ -1634,7 +1635,7 @@ napi_status napi_get_value_int32(napi_env env,
1634
1635
1635
1636
v8::Isolate* isolate = env->isolate ;
1636
1637
v8::Local<v8::Context> context = isolate->GetCurrentContext ();
1637
- *result = val->Int32Value (context).ToChecked ();
1638
+ *result = val->Int32Value (context).FromJust ();
1638
1639
1639
1640
return napi_ok;
1640
1641
}
@@ -1653,7 +1654,7 @@ napi_status napi_get_value_uint32(napi_env env,
1653
1654
1654
1655
v8::Isolate* isolate = env->isolate ;
1655
1656
v8::Local<v8::Context> context = isolate->GetCurrentContext ();
1656
- *result = val->Uint32Value (context).ToChecked ();
1657
+ *result = val->Uint32Value (context).FromJust ();
1657
1658
1658
1659
return napi_ok;
1659
1660
}
@@ -1678,7 +1679,7 @@ napi_status napi_get_value_int64(napi_env env,
1678
1679
} else {
1679
1680
v8::Isolate* isolate = env->isolate ;
1680
1681
v8::Local<v8::Context> context = isolate->GetCurrentContext ();
1681
- *result = val->IntegerValue (context).ToChecked ();
1682
+ *result = val->IntegerValue (context).FromJust ();
1682
1683
}
1683
1684
1684
1685
return napi_ok;
@@ -2684,9 +2685,11 @@ napi_status napi_queue_async_work(napi_env env, napi_async_work work) {
2684
2685
CHECK_ENV (env);
2685
2686
CHECK_ARG (env, work);
2686
2687
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 ();
2690
2693
2691
2694
uvimpl::Work* w = reinterpret_cast <uvimpl::Work*>(work);
2692
2695
0 commit comments