diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2021-01-28 18:22:18 +0300 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2021-02-16 17:12:48 +0300 |
commit | 54d36b00afa66102d55c6353a2f6c00459b97242 (patch) | |
tree | 47df7eb95f8571fbff296cc3a0666f1b1ef8019f /src | |
parent | 3079a78428ccf0f5a0c8dabb2c93f888caead247 (diff) |
src: rename binding_data_name to type_name in BindingData
Previously, this was a per-class string constant for BindingData
which is used as keys for identifying these objects in the binding
data map. These are just type names of the BindingData.
This patch renames the variable to type_name so that
we can generalize this constant for other BaseObjects and use
it for debugging and logging the types of other BaseObjects.
PR-URL: https://github.com/nodejs/node/pull/37112
Refs: https://github.com/nodejs/node/pull/36943
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/README.md | 4 | ||||
-rw-r--r-- | src/env-inl.h | 4 | ||||
-rw-r--r-- | src/node_file.cc | 2 | ||||
-rw-r--r-- | src/node_file.h | 2 | ||||
-rw-r--r-- | src/node_http2.cc | 2 | ||||
-rw-r--r-- | src/node_http2_state.h | 2 | ||||
-rw-r--r-- | src/node_http_parser.cc | 4 | ||||
-rw-r--r-- | src/node_v8.cc | 4 |
8 files changed, 12 insertions, 12 deletions
diff --git a/src/README.md b/src/README.md index aec56e7a7ba..a3b54416a0d 100644 --- a/src/README.md +++ b/src/README.md @@ -422,7 +422,7 @@ that state is through the use of `Environment::AddBindingData`, which gives binding functions access to an object for storing such state. That object is always a [`BaseObject`][]. -Its class needs to have a static `binding_data_name` field based on a +Its class needs to have a static `type_name` field based on a constant string, in order to disambiguate it from other classes of this type, and which could e.g. match the binding’s name (in the example above, that would be `cares_wrap`). @@ -433,7 +433,7 @@ class BindingData : public BaseObject { public: BindingData(Environment* env, Local<Object> obj) : BaseObject(env, obj) {} - static constexpr FastStringKey binding_data_name { "http_parser" }; + static constexpr FastStringKey type_name { "http_parser" }; std::vector<char> parser_buffer; bool parser_buffer_in_use = false; diff --git a/src/env-inl.h b/src/env-inl.h index 95b818373b9..93d2423580a 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -358,7 +358,7 @@ inline T* Environment::GetBindingData(v8::Local<v8::Context> context) { context->GetAlignedPointerFromEmbedderData( ContextEmbedderIndex::kBindingListIndex)); DCHECK_NOT_NULL(map); - auto it = map->find(T::binding_data_name); + auto it = map->find(T::type_name); if (UNLIKELY(it == map->end())) return nullptr; T* result = static_cast<T*>(it->second.get()); DCHECK_NOT_NULL(result); @@ -377,7 +377,7 @@ inline T* Environment::AddBindingData( context->GetAlignedPointerFromEmbedderData( ContextEmbedderIndex::kBindingListIndex)); DCHECK_NOT_NULL(map); - auto result = map->emplace(T::binding_data_name, item); + auto result = map->emplace(T::type_name, item); CHECK(result.second); DCHECK_EQ(GetBindingData<T>(context), item.get()); return item.get(); diff --git a/src/node_file.cc b/src/node_file.cc index 8c1ea9053f3..31494e8d2e8 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2399,7 +2399,7 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const { } // TODO(addaleax): Remove once we're on C++17. -constexpr FastStringKey BindingData::binding_data_name; +constexpr FastStringKey BindingData::type_name; void Initialize(Local<Object> target, Local<Value> unused, diff --git a/src/node_file.h b/src/node_file.h index 95a68b5d89a..9e652dc7a4a 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -27,7 +27,7 @@ class BindingData : public BaseObject { std::vector<BaseObjectPtr<FileHandleReadWrap>> file_handle_read_wrap_freelist; - static constexpr FastStringKey binding_data_name { "fs" }; + static constexpr FastStringKey type_name { "fs" }; void MemoryInfo(MemoryTracker* tracker) const override; SET_SELF_SIZE(BindingData) diff --git a/src/node_http2.cc b/src/node_http2.cc index 930167418e1..a4b8e4d2ac7 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -3001,7 +3001,7 @@ void Http2State::MemoryInfo(MemoryTracker* tracker) const { } // TODO(addaleax): Remove once we're on C++17. -constexpr FastStringKey Http2State::binding_data_name; +constexpr FastStringKey Http2State::type_name; // Set up the process.binding('http2') binding. void Initialize(Local<Object> target, diff --git a/src/node_http2_state.h b/src/node_http2_state.h index cd29b207498..7cf40ff1017 100644 --- a/src/node_http2_state.h +++ b/src/node_http2_state.h @@ -127,7 +127,7 @@ class Http2State : public BaseObject { SET_SELF_SIZE(Http2State) SET_MEMORY_INFO_NAME(Http2State) - static constexpr FastStringKey binding_data_name { "http2" }; + static constexpr FastStringKey type_name { "http2" }; private: struct http2_state_internal { diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index b2841772aa3..dfe0273d06f 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -88,7 +88,7 @@ class BindingData : public BaseObject { BindingData(Environment* env, Local<Object> obj) : BaseObject(env, obj) {} - static constexpr FastStringKey binding_data_name { "http_parser" }; + static constexpr FastStringKey type_name { "http_parser" }; std::vector<char> parser_buffer; bool parser_buffer_in_use = false; @@ -101,7 +101,7 @@ class BindingData : public BaseObject { }; // TODO(addaleax): Remove once we're on C++17. -constexpr FastStringKey BindingData::binding_data_name; +constexpr FastStringKey BindingData::type_name; // helper class for the Parser struct StringPtr { diff --git a/src/node_v8.cc b/src/node_v8.cc index 4ab87dce326..d66b5e03b86 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -95,7 +95,7 @@ class BindingData : public BaseObject { heap_code_statistics_buffer(env->isolate(), kHeapCodeStatisticsPropertiesCount) {} - static constexpr FastStringKey binding_data_name { "v8" }; + static constexpr FastStringKey type_name { "v8" }; AliasedFloat64Array heap_statistics_buffer; AliasedFloat64Array heap_space_statistics_buffer; @@ -113,7 +113,7 @@ class BindingData : public BaseObject { }; // TODO(addaleax): Remove once we're on C++17. -constexpr FastStringKey BindingData::binding_data_name; +constexpr FastStringKey BindingData::type_name; void CachedDataVersionTag(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); |