11cb0ef41Sopenharmony_ci#ifndef SRC_NODE_API_INTERNALS_H_ 21cb0ef41Sopenharmony_ci#define SRC_NODE_API_INTERNALS_H_ 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci#include "v8.h" 51cb0ef41Sopenharmony_ci#define JSVM_EXPERIMENTAL 61cb0ef41Sopenharmony_ci#include "env-inl.h" 71cb0ef41Sopenharmony_ci#include "js_native_api_v8.h" 81cb0ef41Sopenharmony_ci#include "jsvm_node_api.h" 91cb0ef41Sopenharmony_ci#include "util-inl.h" 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cistruct node_jsvm_env__ : public JSVM_Env__ { 121cb0ef41Sopenharmony_ci node_jsvm_env__(v8::Local<v8::Context> context, 131cb0ef41Sopenharmony_ci const std::string& module_filename, 141cb0ef41Sopenharmony_ci int32_t module_api_version); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci bool can_call_into_js() const override; 171cb0ef41Sopenharmony_ci void CallFinalizer(JSVM_Finalize cb, void* data, void* hint) override; 181cb0ef41Sopenharmony_ci template <bool enforceUncaughtExceptionPolicy> 191cb0ef41Sopenharmony_ci void CallFinalizer(JSVM_Finalize cb, void* data, void* hint); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci void EnqueueFinalizer(v8impl::RefTracker* finalizer) override; 221cb0ef41Sopenharmony_ci void DrainFinalizerQueue(); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci void trigger_fatal_exception(v8::Local<v8::Value> local_err); 251cb0ef41Sopenharmony_ci template <bool enforceUncaughtExceptionPolicy, typename T> 261cb0ef41Sopenharmony_ci void CallbackIntoModule(T&& call); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci void DeleteMe() override; 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci inline node::Environment* node_env() const { 311cb0ef41Sopenharmony_ci return node::Environment::GetCurrent(context()); 321cb0ef41Sopenharmony_ci } 331cb0ef41Sopenharmony_ci inline const char* GetFilename() const { return filename.c_str(); } 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci std::string filename; 361cb0ef41Sopenharmony_ci bool destructing = false; 371cb0ef41Sopenharmony_ci bool finalization_scheduled = false; 381cb0ef41Sopenharmony_ci}; 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ciusing node_jsvm_env = node_jsvm_env__*; 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci#endif // SRC_NODE_API_INTERNALS_H_ 43