summaryrefslogtreecommitdiff
path: root/src/node_shadow_realm.h
blob: 58d6581938522c4a5b72a566ee642cbe67e26c95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef SRC_NODE_SHADOW_REALM_H_
#define SRC_NODE_SHADOW_REALM_H_

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node_realm.h"
#include "v8.h"

namespace node {
namespace shadow_realm {

class ShadowRealm : public Realm {
 public:
  static ShadowRealm* New(Environment* env);

  SET_MEMORY_INFO_NAME(ShadowRealm)
  SET_SELF_SIZE(ShadowRealm)

  v8::Local<v8::Context> context() const override;

#define V(PropertyName, TypeName)                                              \
  v8::Local<TypeName> PropertyName() const override;                           \
  void set_##PropertyName(v8::Local<TypeName> value) override;
  PER_REALM_STRONG_PERSISTENT_VALUES(V)
#undef V

  void OnEnvironmentDestruct();

 protected:
  v8::MaybeLocal<v8::Value> BootstrapRealm() override;

 private:
  static void WeakCallback(const v8::WeakCallbackInfo<ShadowRealm>& data);

  explicit ShadowRealm(Environment* env);
  ~ShadowRealm();
};

v8::MaybeLocal<v8::Context> HostCreateShadowRealmContextCallback(
    v8::Local<v8::Context> initiator_context);

}  // namespace shadow_realm
}  // namespace node

#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#endif  // SRC_NODE_SHADOW_REALM_H_