@@ -109,10 +109,6 @@ namespace v8impl {
109
109
110
110
// === Conversion between V8 Isolate and napi_env ==========================
111
111
112
- napi_env JsEnvFromV8Isolate (v8::Isolate* isolate) {
113
- return reinterpret_cast <napi_env>(isolate);
114
- }
115
-
116
112
v8::Isolate* V8IsolateFromJsEnv (napi_env e) {
117
113
return reinterpret_cast <v8::Isolate*>(e);
118
114
}
@@ -137,26 +133,6 @@ class EscapableHandleScopeWrapper {
137
133
v8::EscapableHandleScope scope;
138
134
};
139
135
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
-
160
136
// === Conversion between V8 Handles and napi_value ========================
161
137
162
138
// 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,
552
528
553
529
// Registers a NAPI module.
554
530
void napi_module_register (napi_module* mod) {
555
- // NAPI modules always work with the current node version.
556
- int module_version = NODE_MODULE_VERSION;
557
-
558
531
node::node_module* nm = new node::node_module {
559
532
-1 ,
560
533
mod->nm_flags ,
@@ -652,14 +625,16 @@ NAPI_NO_RETURN void napi_fatal_error(const char* location,
652
625
size_t message_len) {
653
626
const char * location_string = location;
654
627
const char * message_string = message;
655
- if (location_len != -1 ) {
628
+
629
+ if (location_len != NAPI_AUTO_LENGTH) {
656
630
char * location_nullterminated = static_cast <char *>(
657
631
malloc ((location_len + 1 ) * sizeof (char )));
658
632
strncpy (location_nullterminated, location, location_len);
659
633
location_nullterminated[location_len] = 0 ;
660
634
location_string = location_nullterminated;
661
635
}
662
- if (message_len != -1 ) {
636
+
637
+ if (message_len != NAPI_AUTO_LENGTH) {
663
638
char * message_nullterminated = static_cast <char *>(
664
639
malloc ((message_len + 1 ) * sizeof (char )));
665
640
strncpy (message_nullterminated, message, message_len);
@@ -689,7 +664,7 @@ napi_status napi_create_function(napi_env env,
689
664
if (utf8name != nullptr ) {
690
665
CHECK_JSRT (JsCreateString (
691
666
utf8name,
692
- length == - 1 ? strlen (utf8name) : length,
667
+ length == NAPI_AUTO_LENGTH ? strlen (utf8name) : length,
693
668
&name));
694
669
}
695
670
@@ -1513,9 +1488,17 @@ napi_status napi_get_value_uint32(napi_env env,
1513
1488
napi_status napi_get_value_int64 (napi_env env, napi_value v, int64_t * result) {
1514
1489
CHECK_ARG (result);
1515
1490
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
+
1519
1502
return napi_ok;
1520
1503
}
1521
1504
0 commit comments