• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SRC_NODE_API_INTERNALS_H_
2 #define SRC_NODE_API_INTERNALS_H_
3 
4 #include "v8.h"
5 #define JSVM_EXPERIMENTAL
6 #include "env-inl.h"
7 #include "js_native_api_v8.h"
8 #include "jsvm_node_api.h"
9 #include "util-inl.h"
10 
11 struct node_jsvm_env__ : public JSVM_Env__ {
12   node_jsvm_env__(v8::Local<v8::Context> context,
13                   const std::string& module_filename,
14                   int32_t module_api_version);
15 
16   bool can_call_into_js() const override;
17   void CallFinalizer(JSVM_Finalize cb, void* data, void* hint) override;
18   template <bool enforceUncaughtExceptionPolicy>
19   void CallFinalizer(JSVM_Finalize cb, void* data, void* hint);
20 
21   void EnqueueFinalizer(v8impl::RefTracker* finalizer) override;
22   void DrainFinalizerQueue();
23 
24   void trigger_fatal_exception(v8::Local<v8::Value> local_err);
25   template <bool enforceUncaughtExceptionPolicy, typename T>
26   void CallbackIntoModule(T&& call);
27 
28   void DeleteMe() override;
29 
node_envnode_jsvm_env__30   inline node::Environment* node_env() const {
31     return node::Environment::GetCurrent(context());
32   }
GetFilenamenode_jsvm_env__33   inline const char* GetFilename() const { return filename.c_str(); }
34 
35   std::string filename;
36   bool destructing = false;
37   bool finalization_scheduled = false;
38 };
39 
40 using node_jsvm_env = node_jsvm_env__*;
41 
42 #endif  // SRC_NODE_API_INTERNALS_H_
43