@@ -199,19 +199,23 @@ class EscapableHandleScopeWrapper {
199
199
bool escape_called_;
200
200
};
201
201
202
+ static
202
203
napi_handle_scope JsHandleScopeFromV8HandleScope (HandleScopeWrapper* s) {
203
204
return reinterpret_cast <napi_handle_scope>(s);
204
205
}
205
206
207
+ static
206
208
HandleScopeWrapper* V8HandleScopeFromJsHandleScope (napi_handle_scope s) {
207
209
return reinterpret_cast <HandleScopeWrapper*>(s);
208
210
}
209
211
212
+ static
210
213
napi_escapable_handle_scope JsEscapableHandleScopeFromV8EscapableHandleScope (
211
214
EscapableHandleScopeWrapper* s) {
212
215
return reinterpret_cast <napi_escapable_handle_scope>(s);
213
216
}
214
217
218
+ static
215
219
EscapableHandleScopeWrapper*
216
220
V8EscapableHandleScopeFromJsEscapableHandleScope (
217
221
napi_escapable_handle_scope s) {
@@ -225,18 +229,22 @@ V8EscapableHandleScopeFromJsEscapableHandleScope(
225
229
static_assert (sizeof (v8::Local<v8::Value>) == sizeof (napi_value),
226
230
" Cannot convert between v8::Local<v8::Value> and napi_value" );
227
231
232
+ static
228
233
napi_deferred JsDeferredFromV8Persistent (v8::Persistent<v8::Value>* local) {
229
234
return reinterpret_cast <napi_deferred>(local);
230
235
}
231
236
237
+ static
232
238
v8::Persistent<v8::Value>* V8PersistentFromJsDeferred (napi_deferred local) {
233
239
return reinterpret_cast <v8::Persistent<v8::Value>*>(local);
234
240
}
235
241
242
+ static
236
243
napi_value JsValueFromV8LocalValue (v8::Local<v8::Value> local) {
237
244
return reinterpret_cast <napi_value>(*local);
238
245
}
239
246
247
+ static
240
248
v8::Local<v8::Value> V8LocalValueFromJsValue (napi_value v) {
241
249
v8::Local<v8::Value> local;
242
250
memcpy (&local, &v, sizeof (v));
@@ -639,6 +647,7 @@ class SetterCallbackWrapper
639
647
640
648
// Creates an object to be made available to the static function callback
641
649
// wrapper, used to retrieve the native callback function and data pointer.
650
+ static
642
651
v8::Local<v8::Object> CreateFunctionCallbackData (napi_env env,
643
652
napi_callback cb,
644
653
void * data) {
@@ -664,6 +673,7 @@ v8::Local<v8::Object> CreateFunctionCallbackData(napi_env env,
664
673
// Creates an object to be made available to the static getter/setter
665
674
// callback wrapper, used to retrieve the native getter/setter callback
666
675
// function and data pointer.
676
+ static
667
677
v8::Local<v8::Object> CreateAccessorCallbackData (napi_env env,
668
678
napi_callback getter,
669
679
napi_callback setter,
@@ -706,6 +716,7 @@ const char napi_wrap_name[] = "N-API Wrapper";
706
716
// Search the object's prototype chain for the wrapper object. Usually the
707
717
// wrapper would be the first in the chain, but it is OK for other objects to
708
718
// be inserted in the prototype chain.
719
+ static
709
720
bool FindWrapper (v8::Local<v8::Object> obj,
710
721
v8::Local<v8::Object>* result = nullptr ,
711
722
v8::Local<v8::Object>* parent = nullptr ) {
@@ -739,6 +750,7 @@ static void DeleteEnv(napi_env env, void* data, void* hint) {
739
750
delete env;
740
751
}
741
752
753
+ static
742
754
napi_env GetEnv (v8::Local<v8::Context> context) {
743
755
napi_env result;
744
756
@@ -774,6 +786,7 @@ napi_env GetEnv(v8::Local<v8::Context> context) {
774
786
return result;
775
787
}
776
788
789
+ static
777
790
napi_status Unwrap (napi_env env,
778
791
napi_value js_object,
779
792
void ** result,
@@ -797,6 +810,7 @@ napi_status Unwrap(napi_env env,
797
810
return napi_ok;
798
811
}
799
812
813
+ static
800
814
napi_status ConcludeDeferred (napi_env env,
801
815
napi_deferred deferred,
802
816
napi_value result,
@@ -856,12 +870,8 @@ void napi_module_register_cb(v8::Local<v8::Object> exports,
856
870
857
871
// Registers a NAPI module.
858
872
void napi_module_register (napi_module* mod) {
859
- int module_version = -1 ;
860
- #ifdef EXTERNAL_NAPI
861
- module_version = NODE_MODULE_VERSION;
862
- #endif // EXTERNAL_NAPI
863
873
node::node_module* nm = new node::node_module {
864
- module_version ,
874
+ - 1 ,
865
875
mod->nm_flags ,
866
876
nullptr ,
867
877
mod->nm_filename ,
@@ -875,6 +885,7 @@ void napi_module_register(napi_module* mod) {
875
885
}
876
886
877
887
// Warning: Keep in-sync with napi_status enum
888
+ static
878
889
const char * error_messages[] = {nullptr ,
879
890
" Invalid argument" ,
880
891
" An object was expected" ,
@@ -1211,10 +1222,10 @@ napi_status napi_delete_property(napi_env env,
1211
1222
return GET_RETURN_STATUS (env);
1212
1223
}
1213
1224
1214
- NAPI_EXTERN napi_status napi_has_own_property (napi_env env,
1215
- napi_value object,
1216
- napi_value key,
1217
- bool * result) {
1225
+ napi_status napi_has_own_property (napi_env env,
1226
+ napi_value object,
1227
+ napi_value key,
1228
+ bool * result) {
1218
1229
NAPI_PREAMBLE (env);
1219
1230
CHECK_ARG (env, key);
1220
1231
@@ -3239,6 +3250,7 @@ napi_status napi_adjust_external_memory(napi_env env,
3239
3250
return napi_clear_last_error (env);
3240
3251
}
3241
3252
3253
+ namespace {
3242
3254
namespace uvimpl {
3243
3255
3244
3256
static napi_status ConvertUVErrorCode (int code) {
@@ -3337,6 +3349,7 @@ class Work : public node::AsyncResource {
3337
3349
};
3338
3350
3339
3351
} // end of namespace uvimpl
3352
+ } // end of anonymous namespace
3340
3353
3341
3354
#define CALL_UV (env, condition ) \
3342
3355
do { \
@@ -3419,9 +3432,9 @@ napi_status napi_cancel_async_work(napi_env env, napi_async_work work) {
3419
3432
return napi_clear_last_error (env);
3420
3433
}
3421
3434
3422
- NAPI_EXTERN napi_status napi_create_promise (napi_env env,
3423
- napi_deferred* deferred,
3424
- napi_value* promise) {
3435
+ napi_status napi_create_promise (napi_env env,
3436
+ napi_deferred* deferred,
3437
+ napi_value* promise) {
3425
3438
NAPI_PREAMBLE (env);
3426
3439
CHECK_ARG (env, deferred);
3427
3440
CHECK_ARG (env, promise);
@@ -3438,21 +3451,21 @@ NAPI_EXTERN napi_status napi_create_promise(napi_env env,
3438
3451
return GET_RETURN_STATUS (env);
3439
3452
}
3440
3453
3441
- NAPI_EXTERN napi_status napi_resolve_deferred (napi_env env,
3442
- napi_deferred deferred,
3443
- napi_value resolution) {
3454
+ napi_status napi_resolve_deferred (napi_env env,
3455
+ napi_deferred deferred,
3456
+ napi_value resolution) {
3444
3457
return v8impl::ConcludeDeferred (env, deferred, resolution, true );
3445
3458
}
3446
3459
3447
- NAPI_EXTERN napi_status napi_reject_deferred (napi_env env,
3448
- napi_deferred deferred,
3449
- napi_value resolution) {
3460
+ napi_status napi_reject_deferred (napi_env env,
3461
+ napi_deferred deferred,
3462
+ napi_value resolution) {
3450
3463
return v8impl::ConcludeDeferred (env, deferred, resolution, false );
3451
3464
}
3452
3465
3453
- NAPI_EXTERN napi_status napi_is_promise (napi_env env,
3454
- napi_value promise,
3455
- bool * is_promise) {
3466
+ napi_status napi_is_promise (napi_env env,
3467
+ napi_value promise,
3468
+ bool * is_promise) {
3456
3469
CHECK_ENV (env);
3457
3470
CHECK_ARG (env, promise);
3458
3471
CHECK_ARG (env, is_promise);
@@ -3462,9 +3475,9 @@ NAPI_EXTERN napi_status napi_is_promise(napi_env env,
3462
3475
return napi_clear_last_error (env);
3463
3476
}
3464
3477
3465
- NAPI_EXTERN napi_status napi_run_script (napi_env env,
3466
- napi_value script,
3467
- napi_value* result) {
3478
+ napi_status napi_run_script (napi_env env,
3479
+ napi_value script,
3480
+ napi_value* result) {
3468
3481
NAPI_PREAMBLE (env);
3469
3482
CHECK_ARG (env, script);
3470
3483
CHECK_ARG (env, result);
0 commit comments