22 #ifndef SRC_BASE_OBJECT_INL_H_ 23 #define SRC_BASE_OBJECT_INL_H_ 25 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 36 inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> handle)
37 : persistent_handle_(env->isolate(), handle),
39 CHECK_EQ(
false, handle.IsEmpty());
42 if (handle->InternalFieldCount() > 0)
43 handle->SetAlignedPointerInInternalField(0,
nullptr);
47 inline BaseObject::~BaseObject() {
48 CHECK(persistent_handle_.IsEmpty());
52 inline v8::Persistent<v8::Object>& BaseObject::persistent() {
53 return persistent_handle_;
57 inline v8::Local<v8::Object> BaseObject::object() {
58 return PersistentToLocal(
env_->isolate(), persistent_handle_);
62 inline Environment* BaseObject::env()
const {
67 template <
typename Type>
68 inline void BaseObject::WeakCallback(
69 const v8::WeakCallbackInfo<Type>&
data) {
70 Type*
self = data.GetParameter();
71 self->persistent().Reset();
76 template <
typename Type>
77 inline void BaseObject::MakeWeak(Type* ptr) {
78 v8::HandleScope scope(
env_->isolate());
79 v8::Local<v8::Object> handle = object();
80 CHECK_GT(handle->InternalFieldCount(), 0);
82 persistent_handle_.MarkIndependent();
83 persistent_handle_.SetWeak<Type>(ptr, WeakCallback<Type>,
84 v8::WeakCallbackType::kParameter);
88 inline void BaseObject::ClearWeak() {
89 persistent_handle_.ClearWeak();
94 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 96 #endif // SRC_BASE_OBJECT_INL_H_
union node::cares_wrap::@8::CaresAsyncData::@0 data