Skip to content

Commit 54d36b0

Browse files
joyeecheungdanielleadams
authored andcommitted
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 <soyjuanarbol@gmail.com>
1 parent 3079a78 commit 54d36b0

8 files changed

+12
-12
lines changed

src/README.md

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

src/env-inl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ inline T* Environment::GetBindingData(v8::Local<v8::Context> context) {
358358
context->GetAlignedPointerFromEmbedderData(
359359
ContextEmbedderIndex::kBindingListIndex));
360360
DCHECK_NOT_NULL(map);
361-
auto it = map->find(T::binding_data_name);
361+
auto it = map->find(T::type_name);
362362
if (UNLIKELY(it == map->end())) return nullptr;
363363
T* result = static_cast<T*>(it->second.get());
364364
DCHECK_NOT_NULL(result);
@@ -377,7 +377,7 @@ inline T* Environment::AddBindingData(
377377
context->GetAlignedPointerFromEmbedderData(
378378
ContextEmbedderIndex::kBindingListIndex));
379379
DCHECK_NOT_NULL(map);
380-
auto result = map->emplace(T::binding_data_name, item);
380+
auto result = map->emplace(T::type_name, item);
381381
CHECK(result.second);
382382
DCHECK_EQ(GetBindingData<T>(context), item.get());
383383
return item.get();

src/node_file.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,7 @@ void BindingData::MemoryInfo(MemoryTracker* tracker) const {
23992399
}
24002400

24012401
// TODO(addaleax): Remove once we're on C++17.
2402-
constexpr FastStringKey BindingData::binding_data_name;
2402+
constexpr FastStringKey BindingData::type_name;
24032403

24042404
void Initialize(Local<Object> target,
24052405
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
@@ -3001,7 +3001,7 @@ void Http2State::MemoryInfo(MemoryTracker* tracker) const {
30013001
}
30023002

30033003
// TODO(addaleax): Remove once we're on C++17.
3004-
constexpr FastStringKey Http2State::binding_data_name;
3004+
constexpr FastStringKey Http2State::type_name;
30053005

30063006
// Set up the process.binding('http2') binding.
30073007
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)