mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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>
This commit is contained in:
1 parent
88d9676e74
commit
33ebf5d9ef
8 files changed
+12
-12
No files matched your search
+2
-2
@@ -426,7 +426,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`).
|
||||
@@ -437,7 +437,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;
|
||||
|
||||
+2
-2
@@ -387,7 +387,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);
|
||||
@@ -406,7 +406,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();
|
||||
|
||||
+1
-1
@@ -2394,7 +2394,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,
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -2975,7 +2975,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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user