GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_contextify.h Lines: 11 14 78.6 %
Date: 2019-03-02 22:23:06 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_CONTEXTIFY_H_
2
#define SRC_NODE_CONTEXTIFY_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "base_object-inl.h"
7
#include "node_context_data.h"
8
#include "node_errors.h"
9
10
namespace node {
11
namespace contextify {
12
13
22835
struct ContextOptions {
14
  v8::Local<v8::String> name;
15
  v8::Local<v8::String> origin;
16
  v8::Local<v8::Boolean> allow_code_gen_strings;
17
  v8::Local<v8::Boolean> allow_code_gen_wasm;
18
};
19
20
8266
class ContextifyContext {
21
 public:
22
  ContextifyContext(Environment* env,
23
                    v8::Local<v8::Object> sandbox_obj,
24
                    const ContextOptions& options);
25
26
  v8::MaybeLocal<v8::Object> CreateDataWrapper(Environment* env);
27
  v8::MaybeLocal<v8::Context> CreateV8Context(Environment* env,
28
                                              v8::Local<v8::Object> sandbox_obj,
29
                                              const ContextOptions& options);
30
  static void Init(Environment* env, v8::Local<v8::Object> target);
31
32
  static ContextifyContext* ContextFromContextifiedSandbox(
33
      Environment* env,
34
      const v8::Local<v8::Object>& sandbox);
35
36
31296244
  inline Environment* env() const {
37
31296244
    return env_;
38
  }
39
40
31291552
  inline v8::Local<v8::Context> context() const {
41
31291552
    return PersistentToLocal::Default(env()->isolate(), context_);
42
  }
43
44
5947842
  inline v8::Local<v8::Object> global_proxy() const {
45
11895684
    return context()->Global();
46
  }
47
48
12661759
  inline v8::Local<v8::Object> sandbox() const {
49
    return v8::Local<v8::Object>::Cast(
50
37985277
        context()->GetEmbedderData(ContextEmbedderIndex::kSandboxObject));
51
  }
52
53
54
  template <typename T>
55
  static ContextifyContext* Get(const v8::PropertyCallbackInfo<T>& args);
56
57
 private:
58
  static void MakeContext(const v8::FunctionCallbackInfo<v8::Value>& args);
59
  static void IsContext(const v8::FunctionCallbackInfo<v8::Value>& args);
60
  static void CompileFunction(
61
      const v8::FunctionCallbackInfo<v8::Value>& args);
62
  static void WeakCallback(
63
      const v8::WeakCallbackInfo<ContextifyContext>& data);
64
  static void WeakCallbackCompileFn(
65
      const v8::WeakCallbackInfo<CompileFnEntry>& data);
66
  static void PropertyGetterCallback(
67
      v8::Local<v8::Name> property,
68
      const v8::PropertyCallbackInfo<v8::Value>& args);
69
  static void PropertySetterCallback(
70
      v8::Local<v8::Name> property,
71
      v8::Local<v8::Value> value,
72
      const v8::PropertyCallbackInfo<v8::Value>& args);
73
  static void PropertyDescriptorCallback(
74
      v8::Local<v8::Name> property,
75
      const v8::PropertyCallbackInfo<v8::Value>& args);
76
  static void PropertyDefinerCallback(
77
      v8::Local<v8::Name> property,
78
      const v8::PropertyDescriptor& desc,
79
      const v8::PropertyCallbackInfo<v8::Value>& args);
80
  static void PropertyDeleterCallback(
81
      v8::Local<v8::Name> property,
82
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
83
  static void PropertyEnumeratorCallback(
84
      const v8::PropertyCallbackInfo<v8::Array>& args);
85
  static void IndexedPropertyGetterCallback(
86
      uint32_t index,
87
      const v8::PropertyCallbackInfo<v8::Value>& args);
88
  static void IndexedPropertySetterCallback(
89
      uint32_t index,
90
      v8::Local<v8::Value> value,
91
      const v8::PropertyCallbackInfo<v8::Value>& args);
92
  static void IndexedPropertyDescriptorCallback(
93
      uint32_t index,
94
      const v8::PropertyCallbackInfo<v8::Value>& args);
95
  static void IndexedPropertyDefinerCallback(
96
      uint32_t index,
97
      const v8::PropertyDescriptor& desc,
98
      const v8::PropertyCallbackInfo<v8::Value>& args);
99
  static void IndexedPropertyDeleterCallback(
100
      uint32_t index,
101
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
102
  Environment* const env_;
103
  Persistent<v8::Context> context_;
104
};
105
106
class ContextifyScript : public BaseObject {
107
 public:
108
  SET_NO_MEMORY_INFO()
109
  SET_MEMORY_INFO_NAME(ContextifyScript)
110
  SET_SELF_SIZE(ContextifyScript)
111
112
  ContextifyScript(Environment* env, v8::Local<v8::Object> object);
113
  ~ContextifyScript() override;
114
115
  static void Init(Environment* env, v8::Local<v8::Object> target);
116
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
117
  static bool InstanceOf(Environment* env, const v8::Local<v8::Value>& args);
118
  static void CreateCachedData(
119
      const v8::FunctionCallbackInfo<v8::Value>& args);
120
  static void RunInThisContext(const v8::FunctionCallbackInfo<v8::Value>& args);
121
  static void RunInContext(const v8::FunctionCallbackInfo<v8::Value>& args);
122
  static bool EvalMachine(Environment* env,
123
                          const int64_t timeout,
124
                          const bool display_errors,
125
                          const bool break_on_sigint,
126
                          const bool break_on_first_line,
127
                          const v8::FunctionCallbackInfo<v8::Value>& args);
128
129
4552
  inline uint32_t id() { return id_; }
130
131
 private:
132
  node::Persistent<v8::UnboundScript> script_;
133
  uint32_t id_;
134
};
135
136
}  // namespace contextify
137
}  // namespace node
138
139
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
140
141
#endif  // SRC_NODE_CONTEXTIFY_H_