• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "gtest/gtest_prod.h"
20 
21 #define NAPI_ARRAYSIZE(array) \
22   node::arraysize((array))
23 
24 #define NAPI_FIXED_ONE_BYTE_STRING(isolate, string) \
25   node::FIXED_ONE_BYTE_STRING((isolate), (string))
26 
27 #define NAPI_PRIVATE_KEY(context, suffix) \
28   (node::Environment::GetCurrent((context))->napi_ ## suffix())
29 
30 namespace v8impl {
31 
32 template <typename T>
33 using Persistent = v8::Global<T>;
34 
35 using PersistentToLocal = node::PersistentToLocal;
36 
37 }  // end of namespace v8impl
38 
39 #endif  // SRC_JS_NATIVE_API_V8_INTERNALS_H_
40