PHP 7.4.33
Preview: node_contextify.h Size: 5.37 KB
//usr/include/nodejs/src/node_contextify.h
#ifndef SRC_NODE_CONTEXTIFY_H_
#define SRC_NODE_CONTEXTIFY_H_

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "base_object-inl.h"
#include "node_context_data.h"
#include "node_errors.h"

namespace node {
namespace contextify {

struct ContextOptions {
  v8::Local<v8::String> name;
  v8::Local<v8::String> origin;
  v8::Local<v8::Boolean> allow_code_gen_strings;
  v8::Local<v8::Boolean> allow_code_gen_wasm;
};

class ContextifyContext {
 public:
  enum InternalFields { kSlot, kInternalFieldCount };
  ContextifyContext(Environment* env,
                    v8::Local<v8::Object> sandbox_obj,
                    const ContextOptions& options);
  ~ContextifyContext();
  static void CleanupHook(void* arg);

  v8::MaybeLocal<v8::Object> CreateDataWrapper(Environment* env);
  v8::MaybeLocal<v8::Context> CreateV8Context(Environment* env,
                                              v8::Local<v8::Object> sandbox_obj,
                                              const ContextOptions& options);
  static void Init(Environment* env, v8::Local<v8::Object> target);

  static ContextifyContext* ContextFromContextifiedSandbox(
      Environment* env,
      const v8::Local<v8::Object>& sandbox);

  inline Environment* env() const {
    return env_;
  }

  inline v8::Local<v8::Context> context() const {
    return PersistentToLocal::Default(env()->isolate(), context_);
  }

  inline v8::Local<v8::Object> global_proxy() const {
    return context()->Global();
  }

  inline v8::Local<v8::Object> sandbox() const {
    return v8::Local<v8::Object>::Cast(
        context()->GetEmbedderData(ContextEmbedderIndex::kSandboxObject));
  }


  template <typename T>
  static ContextifyContext* Get(const v8::PropertyCallbackInfo<T>& args);

 private:
  static void MakeContext(const v8::FunctionCallbackInfo<v8::Value>& args);
  static void IsContext(const v8::FunctionCallbackInfo<v8::Value>& args);
  static void CompileFunction(
      const v8::FunctionCallbackInfo<v8::Value>& args);
  static void WeakCallback(
      const v8::WeakCallbackInfo<ContextifyContext>& data);
  static void PropertyGetterCallback(
      v8::Local<v8::Name> property,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void PropertySetterCallback(
      v8::Local<v8::Name> property,
      v8::Local<v8::Value> value,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void PropertyDescriptorCallback(
      v8::Local<v8::Name> property,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void PropertyDefinerCallback(
      v8::Local<v8::Name> property,
      const v8::PropertyDescriptor& desc,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void PropertyDeleterCallback(
      v8::Local<v8::Name> property,
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
  static void PropertyEnumeratorCallback(
      const v8::PropertyCallbackInfo<v8::Array>& args);
  static void IndexedPropertyGetterCallback(
      uint32_t index,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void IndexedPropertySetterCallback(
      uint32_t index,
      v8::Local<v8::Value> value,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void IndexedPropertyDescriptorCallback(
      uint32_t index,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void IndexedPropertyDefinerCallback(
      uint32_t index,
      const v8::PropertyDescriptor& desc,
      const v8::PropertyCallbackInfo<v8::Value>& args);
  static void IndexedPropertyDeleterCallback(
      uint32_t index,
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
  Environment* const env_;
  v8::Global<v8::Context> context_;
};

class ContextifyScript : public BaseObject {
 public:
  SET_NO_MEMORY_INFO()
  SET_MEMORY_INFO_NAME(ContextifyScript)
  SET_SELF_SIZE(ContextifyScript)

  ContextifyScript(Environment* env, v8::Local<v8::Object> object);
  ~ContextifyScript() override;

  static void Init(Environment* env, v8::Local<v8::Object> target);
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
  static bool InstanceOf(Environment* env, const v8::Local<v8::Value>& args);
  static void CreateCachedData(
      const v8::FunctionCallbackInfo<v8::Value>& args);
  static void RunInThisContext(const v8::FunctionCallbackInfo<v8::Value>& args);
  static void RunInContext(const v8::FunctionCallbackInfo<v8::Value>& args);
  static bool EvalMachine(Environment* env,
                          const int64_t timeout,
                          const bool display_errors,
                          const bool break_on_sigint,
                          const bool break_on_first_line,
                          const v8::FunctionCallbackInfo<v8::Value>& args);

  inline uint32_t id() { return id_; }

 private:
  v8::Global<v8::UnboundScript> script_;
  uint32_t id_;
};

class CompiledFnEntry final : public BaseObject {
 public:
  SET_NO_MEMORY_INFO()
  SET_MEMORY_INFO_NAME(CompiledFnEntry)
  SET_SELF_SIZE(CompiledFnEntry)

  CompiledFnEntry(Environment* env,
                  v8::Local<v8::Object> object,
                  uint32_t id,
                  v8::Local<v8::ScriptOrModule> script);
  ~CompiledFnEntry();

 private:
  uint32_t id_;
  v8::Global<v8::ScriptOrModule> script_;

  static void WeakCallback(const v8::WeakCallbackInfo<CompiledFnEntry>& data);
};

}  // namespace contextify
}  // namespace node

#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#endif  // SRC_NODE_CONTEXTIFY_H_

Directory Contents

Dirs: 0 × Files: 108
Name Size Perms Modified Actions
7.91 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.96 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
10.07 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.57 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
10.82 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.83 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.59 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.96 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
686 B lrw-r--r-- 2022-01-10 12:24:37
Edit Download
584 B lrw-r--r-- 2022-01-10 12:24:37
Edit Download
7.36 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
6.44 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
768 B lrw-r--r-- 2022-01-10 12:24:37
Edit Download
40.44 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
65.90 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.98 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.68 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.83 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
609 B lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.88 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.19 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.53 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.53 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.50 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.63 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
28.13 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.14 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
12.23 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.28 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.35 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.50 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.23 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.10 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
43.55 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.41 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.62 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.25 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.60 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.67 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.37 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.14 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
29.59 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
6.22 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.60 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.16 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.48 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
23.04 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.31 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.89 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.89 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
9.81 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
12.20 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
49.14 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.58 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
28.90 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.30 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
13.34 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.05 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.60 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.28 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.96 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.46 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
6.07 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.31 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.33 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.78 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
14.68 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
15.68 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.21 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.99 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.88 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.77 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.35 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.45 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
212.59 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.61 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.56 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.15 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.20 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
6.16 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
6.19 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.69 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.13 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.17 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
11.67 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.67 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.78 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.67 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.40 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.22 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.55 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
6.87 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
9.16 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
15.92 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.15 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
4.03 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.59 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
858 B lrw-r--r-- 2022-01-10 12:24:37
Edit Download
1.50 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
20.92 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
3.65 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.05 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
7.88 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
2.18 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
8.59 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
16.42 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
25.51 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
5.09 KB lrw-r--r-- 2022-01-10 12:24:37
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).