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-02-13 22:28:58 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
22615
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
8290
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
35253433
  inline Environment* env() const {
37
35253433
    return env_;
38
  }
39
40
35248784
  inline v8::Local<v8::Context> context() const {
41
35248784
    return PersistentToLocal::Default(env()->isolate(), context_);
42
  }
43
44
6739324
  inline v8::Local<v8::Object> global_proxy() const {
45
13478648
    return context()->Global();
46
  }
47
48
14244720
  inline v8::Local<v8::Object> sandbox() const {
49
    return v8::Local<v8::Object>::Cast(
50
42734160
        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 PropertyGetterCallback(
65
      v8::Local<v8::Name> property,
66
      const v8::PropertyCallbackInfo<v8::Value>& args);
67
  static void PropertySetterCallback(
68
      v8::Local<v8::Name> property,
69
      v8::Local<v8::Value> value,
70
      const v8::PropertyCallbackInfo<v8::Value>& args);
71
  static void PropertyDescriptorCallback(
72
      v8::Local<v8::Name> property,
73
      const v8::PropertyCallbackInfo<v8::Value>& args);
74
  static void PropertyDefinerCallback(
75
      v8::Local<v8::Name> property,
76
      const v8::PropertyDescriptor& desc,
77
      const v8::PropertyCallbackInfo<v8::Value>& args);
78
  static void PropertyDeleterCallback(
79
      v8::Local<v8::Name> property,
80
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
81
  static void PropertyEnumeratorCallback(
82
      const v8::PropertyCallbackInfo<v8::Array>& args);
83
  static void IndexedPropertyGetterCallback(
84
      uint32_t index,
85
      const v8::PropertyCallbackInfo<v8::Value>& args);
86
  static void IndexedPropertySetterCallback(
87
      uint32_t index,
88
      v8::Local<v8::Value> value,
89
      const v8::PropertyCallbackInfo<v8::Value>& args);
90
  static void IndexedPropertyDescriptorCallback(
91
      uint32_t index,
92
      const v8::PropertyCallbackInfo<v8::Value>& args);
93
  static void IndexedPropertyDefinerCallback(
94
      uint32_t index,
95
      const v8::PropertyDescriptor& desc,
96
      const v8::PropertyCallbackInfo<v8::Value>& args);
97
  static void IndexedPropertyDeleterCallback(
98
      uint32_t index,
99
      const v8::PropertyCallbackInfo<v8::Boolean>& args);
100
  Environment* const env_;
101
  Persistent<v8::Context> context_;
102
};
103
104
class ContextifyScript : public BaseObject {
105
 public:
106
  SET_NO_MEMORY_INFO()
107
  SET_MEMORY_INFO_NAME(ContextifyScript)
108
  SET_SELF_SIZE(ContextifyScript)
109
110
  ContextifyScript(Environment* env, v8::Local<v8::Object> object);
111
  ~ContextifyScript();
112
113
  static void Init(Environment* env, v8::Local<v8::Object> target);
114
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
115
  static bool InstanceOf(Environment* env, const v8::Local<v8::Value>& args);
116
  static void CreateCachedData(
117
      const v8::FunctionCallbackInfo<v8::Value>& args);
118
  static void RunInThisContext(const v8::FunctionCallbackInfo<v8::Value>& args);
119
  static void RunInContext(const v8::FunctionCallbackInfo<v8::Value>& args);
120
  static bool EvalMachine(Environment* env,
121
                          const int64_t timeout,
122
                          const bool display_errors,
123
                          const bool break_on_sigint,
124
                          const bool break_on_first_line,
125
                          const v8::FunctionCallbackInfo<v8::Value>& args);
126
127
446216
  inline uint32_t id() { return id_; }
128
129
 private:
130
  node::Persistent<v8::UnboundScript> script_;
131
  uint32_t id_;
132
};
133
134
}  // namespace contextify
135
}  // namespace node
136
137
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
138
139
#endif  // SRC_NODE_CONTEXTIFY_H_