11cb0ef41Sopenharmony_ci#ifndef SRC_JS_NATIVE_API_V8_INTERNALS_H_
21cb0ef41Sopenharmony_ci#define SRC_JS_NATIVE_API_V8_INTERNALS_H_
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// The V8 implementation of N-API, including `js_native_api_v8.h` uses certain
51cb0ef41Sopenharmony_ci// idioms which require definition here. For example, it uses a variant of
61cb0ef41Sopenharmony_ci// persistent references which need not be reset in the constructor. It is the
71cb0ef41Sopenharmony_ci// responsibility of this file to define these idioms. Optionally, this file
81cb0ef41Sopenharmony_ci// may also define `NAPI_VERSION` and set it to the version of N-API to be
91cb0ef41Sopenharmony_ci// exposed.
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci// In the case of the Node.js implementation of N-API some of the idioms are
121cb0ef41Sopenharmony_ci// imported directly from Node.js by including `node_internals.h` below. Others
131cb0ef41Sopenharmony_ci// are bridged to remove references to the `node` namespace. `node_version.h`,
141cb0ef41Sopenharmony_ci// included below, defines `NAPI_VERSION`.
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci#include "node_version.h"
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci#include "env.h"
191cb0ef41Sopenharmony_ci#include "gtest/gtest_prod.h"
201cb0ef41Sopenharmony_ci#include "node_errors.h"
211cb0ef41Sopenharmony_ci#include "node_internals.h"
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci#define JSVM_ARRAYSIZE(array) node::arraysize((array))
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci#define JSVM_FIXED_ONE_BYTE_STRING(isolate, string)                            \
261cb0ef41Sopenharmony_ci  node::FIXED_ONE_BYTE_STRING((isolate), (string))
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci#define JSVM_PRIVATE_KEY(isolate, suffix)                                      \
291cb0ef41Sopenharmony_ci    (v8impl::GetIsolateData(isolate)->jsvm_##suffix##_key.Get(isolate))
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_cinamespace v8impl {
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_citemplate <typename T>
341cb0ef41Sopenharmony_ciusing Persistent = v8::Global<T>;
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ciusing PersistentToLocal = node::PersistentToLocal;
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci[[noreturn]] inline void OnFatalError(const char* location,
391cb0ef41Sopenharmony_ci                                      const char* message) {
401cb0ef41Sopenharmony_ci  node::OnFatalError(location, message);
411cb0ef41Sopenharmony_ci}
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci}  // end of namespace v8impl
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci#endif  // SRC_JS_NATIVE_API_V8_INTERNALS_H_
46