GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: node_realm-inl.h Lines: 9 9 100.0 %
Date: 2022-09-22 04:22:24 Branches: 0 0 - %

Line Branch Exec Source
1
#ifndef SRC_NODE_REALM_INL_H_
2
#define SRC_NODE_REALM_INL_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "node_realm.h"
7
8
namespace node {
9
10
inline Realm* Realm::GetCurrent(v8::Isolate* isolate) {
11
  if (UNLIKELY(!isolate->InContext())) return nullptr;
12
  v8::HandleScope handle_scope(isolate);
13
  return GetCurrent(isolate->GetCurrentContext());
14
}
15
16
inline Realm* Realm::GetCurrent(v8::Local<v8::Context> context) {
17
  if (UNLIKELY(!ContextEmbedderTag::IsNodeContext(context))) return nullptr;
18
  return static_cast<Realm*>(
19
      context->GetAlignedPointerFromEmbedderData(ContextEmbedderIndex::kRealm));
20
}
21
22
inline Realm* Realm::GetCurrent(
23
    const v8::FunctionCallbackInfo<v8::Value>& info) {
24
  return GetCurrent(info.GetIsolate()->GetCurrentContext());
25
}
26
27
template <typename T>
28
inline Realm* Realm::GetCurrent(const v8::PropertyCallbackInfo<T>& info) {
29
  return GetCurrent(info.GetIsolate()->GetCurrentContext());
30
}
31
32
12631
inline Environment* Realm::env() const {
33
12631
  return env_;
34
}
35
36
287277
inline v8::Isolate* Realm::isolate() const {
37
287277
  return isolate_;
38
}
39
40
1578756
inline bool Realm::has_run_bootstrapping_code() const {
41
1578756
  return has_run_bootstrapping_code_;
42
}
43
44
#define V(PropertyName, TypeName)                                              \
45
  inline v8::Local<TypeName> Realm::PropertyName() const {                     \
46
    return PersistentToLocal::Strong(PropertyName##_);                         \
47
  }                                                                            \
48
  inline void Realm::set_##PropertyName(v8::Local<TypeName> value) {           \
49
    PropertyName##_.Reset(isolate(), value);                                   \
50
  }
51
10024000
PER_REALM_STRONG_PERSISTENT_VALUES(V)
52
#undef V
53
54
9330693
v8::Local<v8::Context> Realm::context() const {
55
9330693
  return PersistentToLocal::Strong(context_);
56
}
57
58
}  // namespace node
59
60
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
61
62
#endif  // SRC_NODE_REALM_INL_H_