Coverage Report

Created: 2026-01-21 08:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/node/src/aliased_struct.h
Line
Count
Source
1
#ifndef SRC_ALIASED_STRUCT_H_
2
#define SRC_ALIASED_STRUCT_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "node_internals.h"
7
#include "v8.h"
8
#include <memory>
9
10
namespace node {
11
12
// AliasedStruct is a utility that allows uses a V8 Backing Store
13
// to be exposed to the C++/C side as a struct and to the
14
// JavaScript side as an ArrayBuffer to efficiently share
15
// data without marshalling. It is similar in nature to
16
// AliasedBuffer.
17
//
18
//   struct Foo { int x; }
19
//
20
//   AliasedStruct<Foo> foo;
21
//   foo->x = 1;
22
//
23
//   Local<ArrayBuffer> ab = foo.GetArrayBuffer();
24
template <typename T>
25
class AliasedStruct final {
26
 public:
27
  template <typename... Args>
28
  explicit AliasedStruct(v8::Isolate* isolate, Args&&... args);
29
30
  inline AliasedStruct(const AliasedStruct& that);
31
32
  inline ~AliasedStruct();
33
34
  inline AliasedStruct& operator=(AliasedStruct&& that) noexcept;
35
36
0
  v8::Local<v8::ArrayBuffer> GetArrayBuffer() const {
37
0
    return buffer_.Get(isolate_);
38
0
  }
Unexecuted instantiation: node::AliasedStruct<node::http2::SessionJSFields>::GetArrayBuffer() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Endpoint::State>::GetArrayBuffer() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Endpoint::Stats>::GetArrayBuffer() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Session::Stats>::GetArrayBuffer() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Session::State>::GetArrayBuffer() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Stream::State>::GetArrayBuffer() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Stream::Stats>::GetArrayBuffer() const
39
40
  const T* Data() const { return ptr_; }
41
42
0
  T* Data() { return ptr_; }
Unexecuted instantiation: node::AliasedStruct<node::quic::Endpoint::Stats>::Data()
Unexecuted instantiation: node::AliasedStruct<node::quic::Session::Stats>::Data()
Unexecuted instantiation: node::AliasedStruct<node::quic::Stream::Stats>::Data()
43
44
  const T& operator*() const { return *ptr_; }
45
46
  T& operator*()  { return *ptr_; }
47
48
0
  const T* operator->() const { return ptr_; }
Unexecuted instantiation: node::AliasedStruct<node::quic::Endpoint::State>::operator->() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Session::State>::operator->() const
Unexecuted instantiation: node::AliasedStruct<node::quic::Stream::State>::operator->() const
49
50
0
  T* operator->() { return ptr_; }
Unexecuted instantiation: node::AliasedStruct<node::http2::SessionJSFields>::operator->()
Unexecuted instantiation: node::AliasedStruct<node::quic::Endpoint::State>::operator->()
Unexecuted instantiation: node::AliasedStruct<node::quic::Session::State>::operator->()
Unexecuted instantiation: node::AliasedStruct<node::quic::Stream::State>::operator->()
Unexecuted instantiation: node::AliasedStruct<node::quic::Stream::Stats>::operator->()
51
52
 private:
53
  v8::Isolate* isolate_;
54
  std::shared_ptr<v8::BackingStore> store_;
55
  T* ptr_;
56
  v8::Global<v8::ArrayBuffer> buffer_;
57
};
58
59
}  // namespace node
60
61
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
62
63
#endif  // SRC_ALIASED_STRUCT_H_