@@ -109,10 +109,6 @@ namespace v8impl {
109109
110110// === Conversion between V8 Isolate and napi_env ==========================
111111
112- napi_env JsEnvFromV8Isolate (v8::Isolate* isolate) {
113- return reinterpret_cast <napi_env>(isolate);
114- }
115-
116112v8::Isolate* V8IsolateFromJsEnv (napi_env e) {
117113 return reinterpret_cast <v8::Isolate*>(e);
118114}
@@ -137,26 +133,6 @@ class EscapableHandleScopeWrapper {
137133 v8::EscapableHandleScope scope;
138134};
139135
140- napi_handle_scope JsHandleScopeFromV8HandleScope (HandleScopeWrapper* s) {
141- return reinterpret_cast <napi_handle_scope>(s);
142- }
143-
144- HandleScopeWrapper* V8HandleScopeFromJsHandleScope (napi_handle_scope s) {
145- return reinterpret_cast <HandleScopeWrapper*>(s);
146- }
147-
148- napi_escapable_handle_scope
149- JsEscapableHandleScopeFromV8EscapableHandleScope (
150- EscapableHandleScopeWrapper* s) {
151- return reinterpret_cast <napi_escapable_handle_scope>(s);
152- }
153-
154- EscapableHandleScopeWrapper*
155- V8EscapableHandleScopeFromJsEscapableHandleScope (
156- napi_escapable_handle_scope s) {
157- return reinterpret_cast <EscapableHandleScopeWrapper*>(s);
158- }
159-
160136// === Conversion between V8 Handles and napi_value ========================
161137
162138// This is assuming v8::Local<> will always be implemented with a single
@@ -552,9 +528,6 @@ void napi_module_register_cb(v8::Local<v8::Object> exports,
552528
553529// Registers a NAPI module.
554530void napi_module_register (napi_module* mod) {
555- // NAPI modules always work with the current node version.
556- int module_version = NODE_MODULE_VERSION;
557-
558531 node::node_module* nm = new node::node_module {
559532 -1 ,
560533 mod->nm_flags ,
@@ -652,14 +625,16 @@ NAPI_NO_RETURN void napi_fatal_error(const char* location,
652625 size_t message_len) {
653626 const char * location_string = location;
654627 const char * message_string = message;
655- if (location_len != -1 ) {
628+
629+ if (location_len != NAPI_AUTO_LENGTH) {
656630 char * location_nullterminated = static_cast <char *>(
657631 malloc ((location_len + 1 ) * sizeof (char )));
658632 strncpy (location_nullterminated, location, location_len);
659633 location_nullterminated[location_len] = 0 ;
660634 location_string = location_nullterminated;
661635 }
662- if (message_len != -1 ) {
636+
637+ if (message_len != NAPI_AUTO_LENGTH) {
663638 char * message_nullterminated = static_cast <char *>(
664639 malloc ((message_len + 1 ) * sizeof (char )));
665640 strncpy (message_nullterminated, message, message_len);
@@ -689,7 +664,7 @@ napi_status napi_create_function(napi_env env,
689664 if (utf8name != nullptr ) {
690665 CHECK_JSRT (JsCreateString (
691666 utf8name,
692- length == - 1 ? strlen (utf8name) : length,
667+ length == NAPI_AUTO_LENGTH ? strlen (utf8name) : length,
693668 &name));
694669 }
695670
@@ -1513,9 +1488,17 @@ napi_status napi_get_value_uint32(napi_env env,
15131488napi_status napi_get_value_int64 (napi_env env, napi_value v, int64_t * result) {
15141489 CHECK_ARG (result);
15151490 JsValueRef value = reinterpret_cast <JsValueRef>(v);
1516- int valueInt;
1517- CHECK_JSRT_EXPECTED (JsNumberToInt (value, &valueInt), napi_number_expected);
1518- *result = static_cast <int64_t >(valueInt);
1491+
1492+ double valueDouble;
1493+ CHECK_JSRT_EXPECTED (JsNumberToDouble (value, &valueDouble),
1494+ napi_number_expected);
1495+
1496+ if (std::isnan (valueDouble)) {
1497+ *result = 0 ;
1498+ } else {
1499+ *result = static_cast <int64_t >(valueDouble);
1500+ }
1501+
15191502 return napi_ok;
15201503}
15211504
0 commit comments