GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#ifndef SRC_BASE_OBJECT_INL_H_ |
||
2 |
#define SRC_BASE_OBJECT_INL_H_ |
||
3 |
|||
4 |
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
||
5 |
|||
6 |
#include "base-object.h" |
||
7 |
#include "env.h" |
||
8 |
#include "env-inl.h" |
||
9 |
#include "util.h" |
||
10 |
#include "util-inl.h" |
||
11 |
#include "v8.h" |
||
12 |
|||
13 |
namespace node { |
||
14 |
|||
15 |
125721 |
inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> handle) |
|
16 |
: persistent_handle_(env->isolate(), handle), |
||
17 |
251442 |
env_(env) { |
|
18 |
✗✓ | 125721 |
CHECK_EQ(false, handle.IsEmpty()); |
19 |
// The zero field holds a pointer to the handle. Immediately set it to |
||
20 |
// nullptr in case it's accessed by the user before construction is complete. |
||
21 |
✓✗ | 125721 |
if (handle->InternalFieldCount() > 0) |
22 |
125721 |
handle->SetAlignedPointerInInternalField(0, nullptr); |
|
23 |
125721 |
} |
|
24 |
|||
25 |
|||
26 |
346626 |
inline BaseObject::~BaseObject() { |
|
27 |
✗✓✗✓ ✗✗✗✗ ✗✓✗✓ ✗✗✗✓ ✗✓✗✓ ✗✓✗✗ ✗✗✗✗ ✗✗ |
231084 |
CHECK(persistent_handle_.IsEmpty()); |
28 |
} |
||
29 |
|||
30 |
|||
31 |
inline v8::Persistent<v8::Object>& BaseObject::persistent() { |
||
32 |
return persistent_handle_; |
||
33 |
} |
||
34 |
|||
35 |
|||
36 |
inline v8::Local<v8::Object> BaseObject::object() { |
||
37 |
472251 |
return PersistentToLocal(env_->isolate(), persistent_handle_); |
|
38 |
} |
||
39 |
|||
40 |
|||
41 |
inline Environment* BaseObject::env() const { |
||
42 |
return env_; |
||
43 |
} |
||
44 |
|||
45 |
|||
46 |
template <typename Type> |
||
47 |
71120 |
inline void BaseObject::WeakCallback( |
|
48 |
const v8::WeakCallbackInfo<Type>& data) { |
||
49 |
71120 |
Type* self = data.GetParameter(); |
|
50 |
142240 |
self->persistent().Reset(); |
|
51 |
✓✗✓✗ ✗✗✗✗ ✓✗✓✗ ✓✗✗✗ ✓✗ |
71120 |
delete self; |
52 |
71120 |
} |
|
53 |
|||
54 |
|||
55 |
template <typename Type> |
||
56 |
77877 |
inline void BaseObject::MakeWeak(Type* ptr) { |
|
57 |
155754 |
v8::HandleScope scope(env_->isolate()); |
|
58 |
77877 |
v8::Local<v8::Object> handle = object(); |
|
59 |
✗✓✗✓ ✗✗✓✓ ✓✗✗✓ ✗✓✗✓ ✗✓ |
77877 |
CHECK_GT(handle->InternalFieldCount(), 0); |
60 |
77877 |
Wrap(handle, ptr); |
|
61 |
155754 |
persistent_handle_.MarkIndependent(); |
|
62 |
155754 |
persistent_handle_.SetWeak<Type>(ptr, WeakCallback<Type>, |
|
63 |
v8::WeakCallbackType::kParameter); |
||
64 |
77877 |
} |
|
65 |
|||
66 |
|||
67 |
inline void BaseObject::ClearWeak() { |
||
68 |
430 |
persistent_handle_.ClearWeak(); |
|
69 |
} |
||
70 |
|||
71 |
} // namespace node |
||
72 |
|||
73 |
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |
||
74 |
|||
75 |
#endif // SRC_BASE_OBJECT_INL_H_ |
Generated by: GCOVR (Version 3.3) |