1 #ifndef SRC_JS_NATIVE_API_V8_INTERNALS_H_ 2 #define SRC_JS_NATIVE_API_V8_INTERNALS_H_ 3 4 // The V8 implementation of N-API, including `js_native_api_v8.h` uses certain 5 // idioms which require definition here. For example, it uses a variant of 6 // persistent references which need not be reset in the constructor. It is the 7 // responsibility of this file to define these idioms. Optionally, this file 8 // may also define `NAPI_VERSION` and set it to the version of N-API to be 9 // exposed. 10 11 // In the case of the Node.js implementation of N-API some of the idioms are 12 // imported directly from Node.js by including `node_internals.h` below. Others 13 // are bridged to remove references to the `node` namespace. `node_version.h`, 14 // included below, defines `NAPI_VERSION`. 15 16 #include "node_version.h" 17 #include "env.h" 18 #include "node_internals.h" 19 20 #define NAPI_ARRAYSIZE(array) \ 21 node::arraysize((array)) 22 23 #define NAPI_FIXED_ONE_BYTE_STRING(isolate, string) \ 24 node::FIXED_ONE_BYTE_STRING((isolate), (string)) 25 26 #define NAPI_PRIVATE_KEY(context, suffix) \ 27 (node::Environment::GetCurrent((context))->napi_ ## suffix()) 28 29 namespace v8impl { 30 31 template <typename T> 32 using Persistent = v8::Global<T>; 33 34 using PersistentToLocal = node::PersistentToLocal; 35 36 } // end of namespace v8impl 37 38 #endif // SRC_JS_NATIVE_API_V8_INTERNALS_H_ 39