| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 412d27b commit 8059764
28 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -342,7 +342,6 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate( | |||
| 342 | 342 | tmpl = NewFunctionTemplate(isolate, nullptr); | |
| 343 | 343 | tmpl->SetClassName( | |
| 344 | 344 | FIXED_ONE_BYTE_STRING(isolate_data->isolate(), "AsyncWrap")); | |
| 345 | - tmpl->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); | ||
| 346 | 345 | SetProtoMethod(isolate, tmpl, "getAsyncId", AsyncWrap::GetAsyncId); | |
| 347 | 346 | SetProtoMethod(isolate, tmpl, "asyncReset", AsyncWrap::AsyncReset); | |
| 348 | 347 | SetProtoMethod( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,12 +38,6 @@ BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> object) | |||
| 38 | 38 | // while allowing to create a BaseObject in a vm context. | |
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | - // static | ||
| 42 | - v8::Local<v8::FunctionTemplate> BaseObject::GetConstructorTemplate( | ||
| 43 | - Environment* env) { | ||
| 44 | - return BaseObject::GetConstructorTemplate(env->isolate_data()); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | 41 | void BaseObject::Detach() { | |
| 48 | 42 | CHECK_GT(pointer_data()->strong_ptr_count, 0); | |
| 49 | 43 | pointer_data()->is_detached = true; | |
@@ -76,14 +70,23 @@ Realm* BaseObject::realm() const { | |||
| 76 | 70 | return realm_; | |
| 77 | 71 | } | |
| 78 | 72 | ||
| 79 | - void BaseObject::TagNodeObject(v8::Local<v8::Object> object) { | ||
| 73 | + bool BaseObject::IsBaseObject(v8::Local<v8::Object> obj) { | ||
| 74 | + if (obj->InternalFieldCount() < BaseObject::kInternalFieldCount) { | ||
| 75 | + return false; | ||
| 76 | + } | ||
| 77 | + void* ptr = | ||
| 78 | + obj->GetAlignedPointerFromInternalField(BaseObject::kEmbedderType); | ||
| 79 | + return ptr == &kNodeEmbedderId; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + void BaseObject::TagBaseObject(v8::Local<v8::Object> object) { | ||
| 80 | 83 | DCHECK_GE(object->InternalFieldCount(), BaseObject::kInternalFieldCount); | |
| 81 | 84 | object->SetAlignedPointerInInternalField(BaseObject::kEmbedderType, | |
| 82 | 85 | &kNodeEmbedderId); | |
| 83 | 86 | } | |
| 84 | 87 | ||
| 85 | 88 | void BaseObject::SetInternalFields(v8::Local<v8::Object> object, void* slot) { | |
| 86 | - TagNodeObject(object); | ||
| 89 | + TagBaseObject(object); | ||
| 87 | 90 | object->SetAlignedPointerInInternalField(BaseObject::kSlot, slot); | |
| 88 | 91 | } | |
| 89 | 92 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,7 +89,6 @@ Local<FunctionTemplate> BaseObject::MakeLazilyInitializedJSTemplate( | |||
| 89 | 89 | IsolateData* isolate_data) { | |
| 90 | 90 | Local<FunctionTemplate> t = NewFunctionTemplate( | |
| 91 | 91 | isolate_data->isolate(), LazilyInitializedJSTemplateConstructor); | |
| 92 | - t->Inherit(BaseObject::GetConstructorTemplate(isolate_data)); | ||
| 93 | 92 | t->InstanceTemplate()->SetInternalFieldCount(BaseObject::kInternalFieldCount); | |
| 94 | 93 | return t; | |
| 95 | 94 | } | |
@@ -145,18 +144,6 @@ bool BaseObject::IsRootNode() const { | |||
| 145 | 144 | return !persistent_handle_.IsWeak(); | |
| 146 | 145 | } | |
| 147 | 146 | ||
| 148 | - Local<FunctionTemplate> BaseObject::GetConstructorTemplate( | ||
| 149 | - IsolateData* isolate_data) { | ||
| 150 | - Local<FunctionTemplate> tmpl = isolate_data->base_object_ctor_template(); | ||
| 151 | - if (tmpl.IsEmpty()) { | ||
| 152 | - tmpl = NewFunctionTemplate(isolate_data->isolate(), nullptr); | ||
| 153 | - tmpl->SetClassName( | ||
| 154 | - FIXED_ONE_BYTE_STRING(isolate_data->isolate(), "BaseObject")); | ||
| 155 | - isolate_data->set_base_object_ctor_template(tmpl); | ||
| 156 | - } | ||
| 157 | - return tmpl; | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | 147 | bool BaseObject::IsNotIndicativeOfMemoryLeakAtExit() const { | |
| 161 | 148 | return IsWeakOrDetached(); | |
| 162 | 149 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,8 @@ class BaseObject : public MemoryRetainer { | |||
| 76 | 76 | // e.g. when the JS object used `MakeLazilyInitializedJSTemplate`. | |
| 77 | 77 | static inline void SetInternalFields(v8::Local<v8::Object> object, | |
| 78 | 78 | void* slot); | |
| 79 | - static inline void TagNodeObject(v8::Local<v8::Object> object); | ||
| 79 | + static inline bool IsBaseObject(v8::Local<v8::Object> object); | ||
| 80 | + static inline void TagBaseObject(v8::Local<v8::Object> object); | ||
| 80 | 81 | static void LazilyInitializedJSTemplateConstructor( | |
| 81 | 82 | const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 82 | 83 | static inline BaseObject* FromJSObject(v8::Local<v8::Value> object); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,9 +277,7 @@ void CipherBase::Initialize(Environment* env, Local<Object> target) { | |||
| 277 | 277 | ||
| 278 | 278 | Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New); | |
| 279 | 279 | ||
| 280 | - t->InstanceTemplate()->SetInternalFieldCount( | ||
| 281 | - CipherBase::kInternalFieldCount); | ||
| 282 | - t->Inherit(BaseObject::GetConstructorTemplate(env)); | ||
| 280 | + t->InstanceTemplate()->SetInternalFieldCount(CipherBase::kInternalFieldCount); | ||
| 283 | 281 | ||
| 284 | 282 | SetProtoMethod(isolate, t, "init", Init); | |
| 285 | 283 | SetProtoMethod(isolate, t, "initiv", InitIv); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -268,7 +268,6 @@ Local<FunctionTemplate> SecureContext::GetConstructorTemplate( | |||
| 268 | 268 | tmpl = NewFunctionTemplate(isolate, New); | |
| 269 | 269 | tmpl->InstanceTemplate()->SetInternalFieldCount( | |
| 270 | 270 | SecureContext::kInternalFieldCount); | |
| 271 | - tmpl->Inherit(BaseObject::GetConstructorTemplate(env)); | ||
| 272 | 271 | tmpl->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "SecureContext")); | |
| 273 | 272 | ||
| 274 | 273 | SetProtoMethod(isolate, tmpl, "init", Init); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,7 +69,6 @@ void DiffieHellman::Initialize(Environment* env, Local<Object> target) { | |||
| 69 | 69 | ||
| 70 | 70 | t->InstanceTemplate()->SetInternalFieldCount( | |
| 71 | 71 | DiffieHellman::kInternalFieldCount); | |
| 72 | - t->Inherit(BaseObject::GetConstructorTemplate(env)); | ||
| 73 | 72 | ||
| 74 | 73 | SetProtoMethod(isolate, t, "generateKeys", GenerateKeys); | |
| 75 | 74 | SetProtoMethod(isolate, t, "computeSecret", ComputeSecret); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,6 @@ void ECDH::Initialize(Environment* env, Local<Object> target) { | |||
| 66 | 66 | Local<Context> context = env->context(); | |
| 67 | 67 | ||
| 68 | 68 | Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New); | |
| 69 | - t->Inherit(BaseObject::GetConstructorTemplate(env)); | ||
| 70 | 69 | ||
| 71 | 70 | t->InstanceTemplate()->SetInternalFieldCount(ECDH::kInternalFieldCount); | |
| 72 | 71 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,9 +57,7 @@ void Hash::Initialize(Environment* env, Local<Object> target) { | |||
| 57 | 57 | Local<Context> context = env->context(); | |
| 58 | 58 | Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New); | |
| 59 | 59 | ||
| 60 | - t->InstanceTemplate()->SetInternalFieldCount( | ||
| 61 | - Hash::kInternalFieldCount); | ||
| 62 | - t->Inherit(BaseObject::GetConstructorTemplate(env)); | ||
| 60 | + t->InstanceTemplate()->SetInternalFieldCount(Hash::kInternalFieldCount); | ||
| 63 | 61 | ||
| 64 | 62 | SetProtoMethod(isolate, t, "update", HashUpdate); | |
| 65 | 63 | SetProtoMethod(isolate, t, "digest", HashDigest); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,9 +41,7 @@ void Hmac::Initialize(Environment* env, Local<Object> target) { | |||
| 41 | 41 | Isolate* isolate = env->isolate(); | |
| 42 | 42 | Local<FunctionTemplate> t = NewFunctionTemplate(isolate, New); | |
| 43 | 43 | ||
| 44 | - t->InstanceTemplate()->SetInternalFieldCount( | ||
| 45 | - Hmac::kInternalFieldCount); | ||
| 46 | - t->Inherit(BaseObject::GetConstructorTemplate(env)); | ||
| 44 | + t->InstanceTemplate()->SetInternalFieldCount(Hmac::kInternalFieldCount); | ||
| 47 | 45 | ||
| 48 | 46 | SetProtoMethod(isolate, t, "init", HmacInit); | |
| 49 | 47 | SetProtoMethod(isolate, t, "update", HmacUpdate); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments