Skip to content

Commit 33ebf5d

Browse files
joyeecheungtargos
authored andcommittedMay 1, 2021
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: #37112 Refs: #36943 Reviewed-By: Juan José Arboleda <[email protected]>
1 parent 88d9676 commit 33ebf5d

8 files changed

+12
-12
lines changed
 

‎src/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ that state is through the use of `Environment::AddBindingData`, which gives
426426
binding functions access to an object for storing such state.
427427
That object is always a [`BaseObject`][].
428428
429-
Its class needs to have a static `binding_data_name` field based on a
429+
Its class needs to have a static `type_name` field based on a
430430
constant string, in order to disambiguate it from other classes of this type,
431431
and which could e.g. match the binding’s name (in the example above, that would
432432
be `cares_wrap`).
@@ -437,7 +437,7 @@ class BindingData : public BaseObject {
437437
public:
438438
BindingData(Environment* env, Local<Object> obj) : BaseObject(env, obj) {}
439439
440-
static constexpr FastStringKey binding_data_name { "http_parser" };
440+
static constexpr FastStringKey type_name { "http_parser" };
441441
442442
std::vector<char> parser_buffer;
443443
bool parser_buffer_in_use = false;

‎src/env-inl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ inline T* Environment::GetBindingData(v8::Local<v8::Context> context) {
387387
context->GetAlignedPointerFromEmbedderData(
388388
ContextEmbedderIndex::kBindingListIndex));
389389
DCHECK_NOT_NULL(map);
390-
auto it = map->find(T::binding_data_name);
390+
auto it = map->find(T::type_name);
391391
if (UNLIKELY(it == map->end())) return nullptr;
392392
T* result = static_cast<T*>(it->second.get());
393393
DCHECK_NOT_NULL(result);
@@ -406,7 +406,7 @@ inline T* Environment::AddBindingData(
406406
context->GetAlignedPointerFromEmbedderData(
407407
ContextEmbedderIndex::kBindingListIndex));
408408
DCHECK_NOT_NULL(map);
409-
auto result = map->emplace(T::binding_data_name, item);
409+
auto result = map->emplace(T::type_name, item);
410410
CHECK(result.second);
411411
DCHECK_EQ(GetBindingData<T>(context), item.get());
412412
return item.get();

‎src/node_file.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const {
23942394
}
23952395

23962396
// TODO(addaleax): Remove once we're on C++17.
2397-
constexpr FastStringKey BindingData::binding_data_name;
2397+
constexpr FastStringKey BindingData::type_name;
23982398

23992399
void Initialize(Local<Object> target,
24002400
Local<Value> unused,

‎src/node_file.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BindingData : public BaseObject {
2727
std::vector<BaseObjectPtr<FileHandleReadWrap>>
2828
file_handle_read_wrap_freelist;
2929

30-
static constexpr FastStringKey binding_data_name { "fs" };
30+
static constexpr FastStringKey type_name { "fs" };
3131

3232
void MemoryInfo(MemoryTracker* tracker) const override;
3333
SET_SELF_SIZE(BindingData)

‎src/node_http2.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,7 @@ void Http2State::MemoryInfo(MemoryTracker* tracker) const {
29752975
}
29762976

29772977
// TODO(addaleax): Remove once we're on C++17.
2978-
constexpr FastStringKey Http2State::binding_data_name;
2978+
constexpr FastStringKey Http2State::type_name;
29792979

29802980
// Set up the process.binding('http2') binding.
29812981
void Initialize(Local<Object> target,

‎src/node_http2_state.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class Http2State : public BaseObject {
127127
SET_SELF_SIZE(Http2State)
128128
SET_MEMORY_INFO_NAME(Http2State)
129129

130-
static constexpr FastStringKey binding_data_name { "http2" };
130+
static constexpr FastStringKey type_name { "http2" };
131131

132132
private:
133133
struct http2_state_internal {

‎src/node_http_parser.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class BindingData : public BaseObject {
8888
BindingData(Environment* env, Local<Object> obj)
8989
: BaseObject(env, obj) {}
9090

91-
static constexpr FastStringKey binding_data_name { "http_parser" };
91+
static constexpr FastStringKey type_name { "http_parser" };
9292

9393
std::vector<char> parser_buffer;
9494
bool parser_buffer_in_use = false;
@@ -101,7 +101,7 @@ class BindingData : public BaseObject {
101101
};
102102

103103
// TODO(addaleax): Remove once we're on C++17.
104-
constexpr FastStringKey BindingData::binding_data_name;
104+
constexpr FastStringKey BindingData::type_name;
105105

106106
// helper class for the Parser
107107
struct StringPtr {

‎src/node_v8.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class BindingData : public BaseObject {
9595
heap_code_statistics_buffer(env->isolate(),
9696
kHeapCodeStatisticsPropertiesCount) {}
9797

98-
static constexpr FastStringKey binding_data_name { "v8" };
98+
static constexpr FastStringKey type_name { "v8" };
9999

100100
AliasedFloat64Array heap_statistics_buffer;
101101
AliasedFloat64Array heap_space_statistics_buffer;
@@ -113,7 +113,7 @@ class BindingData : public BaseObject {
113113
};
114114

115115
// TODO(addaleax): Remove once we're on C++17.
116-
constexpr FastStringKey BindingData::binding_data_name;
116+
constexpr FastStringKey BindingData::type_name;
117117

118118
void CachedDataVersionTag(const FunctionCallbackInfo<Value>& args) {
119119
Environment* env = Environment::GetCurrent(args);

0 commit comments

Comments
 (0)
Please sign in to comment.