@@ -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 ,
@@ -651,14 +624,16 @@ NAPI_NO_RETURN void napi_fatal_error(const char* location,
651624 size_t message_len) {
652625 const char * location_string = location;
653626 const char * message_string = message;
654- if (location_len != -1 ) {
627+
628+ if (location_len != NAPI_AUTO_LENGTH) {
655629 char * location_nullterminated = static_cast <char *>(
656630 malloc ((location_len + 1 ) * sizeof (char )));
657631 strncpy (location_nullterminated, location, location_len);
658632 location_nullterminated[location_len] = 0 ;
659633 location_string = location_nullterminated;
660634 }
661- if (message_len != -1 ) {
635+
636+ if (message_len != NAPI_AUTO_LENGTH) {
662637 char * message_nullterminated = static_cast <char *>(
663638 malloc ((message_len + 1 ) * sizeof (char )));
664639 strncpy (message_nullterminated, message, message_len);
@@ -688,7 +663,7 @@ napi_status napi_create_function(napi_env env,
688663 if (utf8name != nullptr ) {
689664 CHECK_JSRT (JsCreateString (
690665 utf8name,
691- length == - 1 ? strlen (utf8name) : length,
666+ length == NAPI_AUTO_LENGTH ? strlen (utf8name) : length,
692667 &name));
693668 }
694669
@@ -1512,9 +1487,17 @@ napi_status napi_get_value_uint32(napi_env env,
15121487napi_status napi_get_value_int64 (napi_env env, napi_value v, int64_t * result) {
15131488 CHECK_ARG (result);
15141489 JsValueRef value = reinterpret_cast <JsValueRef>(v);
1515- int valueInt;
1516- CHECK_JSRT_EXPECTED (JsNumberToInt (value, &valueInt), napi_number_expected);
1517- *result = static_cast <int64_t >(valueInt);
1490+
1491+ double valueDouble;
1492+ CHECK_JSRT_EXPECTED (JsNumberToDouble (value, &valueDouble),
1493+ napi_number_expected);
1494+
1495+ if (std::isnan (valueDouble)) {
1496+ *result = 0 ;
1497+ } else {
1498+ *result = static_cast <int64_t >(valueDouble);
1499+ }
1500+
15181501 return napi_ok;
15191502}
15201503
0 commit comments