0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 13:09:21 +01:00

tools: update inspector_protocol to 83b1154

PR-URL: https://github.com/nodejs/node/pull/51309
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
Kohei Ueno 2024-01-11 13:41:26 +09:00 committed by GitHub
parent d0e455044e
commit d102d16e98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 110 additions and 166 deletions

View File

@ -39,7 +39,6 @@
],
'node_protocol_files': [
'<(protocol_tool_path)/lib/Allocator_h.template',
'<(protocol_tool_path)/lib/Array_h.template',
'<(protocol_tool_path)/lib/base_string_adapter_cc.template',
'<(protocol_tool_path)/lib/base_string_adapter_h.template',
'<(protocol_tool_path)/lib/DispatcherBase_cpp.template',

View File

@ -147,8 +147,8 @@ DispatchResponse TracingAgent::start(
std::set<std::string> categories_set;
protocol::Array<std::string>* categories =
traceConfig->getIncludedCategories();
for (size_t i = 0; i < categories->length(); i++)
categories_set.insert(categories->get(i));
for (size_t i = 0; i < categories->size(); i++)
categories_set.insert((*categories)[i]);
if (categories_set.empty())
return DispatchResponse::Error("At least one category should be enabled");
@ -172,29 +172,29 @@ DispatchResponse TracingAgent::stop() {
DispatchResponse TracingAgent::getCategories(
std::unique_ptr<protocol::Array<String>>* categories) {
*categories = Array<String>::create();
*categories = std::make_unique<Array<String>>();
protocol::Array<String>* categories_list = categories->get();
// In alphabetical order
categories_list->addItem("node");
categories_list->addItem("node.async_hooks");
categories_list->addItem("node.bootstrap");
categories_list->addItem("node.console");
categories_list->addItem("node.dns.native");
categories_list->addItem("node.environment");
categories_list->addItem("node.fs.async");
categories_list->addItem("node.fs.sync");
categories_list->addItem("node.fs_dir.async");
categories_list->addItem("node.fs_dir.sync");
categories_list->addItem("node.http");
categories_list->addItem("node.net.native");
categories_list->addItem("node.perf");
categories_list->addItem("node.perf.timerify");
categories_list->addItem("node.perf.usertiming");
categories_list->addItem("node.promises.rejections");
categories_list->addItem("node.threadpoolwork.async");
categories_list->addItem("node.threadpoolwork.sync");
categories_list->addItem("node.vm.script");
categories_list->addItem("v8");
categories_list->emplace_back("node");
categories_list->emplace_back("node.async_hooks");
categories_list->emplace_back("node.bootstrap");
categories_list->emplace_back("node.console");
categories_list->emplace_back("node.dns.native");
categories_list->emplace_back("node.environment");
categories_list->emplace_back("node.fs.async");
categories_list->emplace_back("node.fs.sync");
categories_list->emplace_back("node.fs_dir.async");
categories_list->emplace_back("node.fs_dir.sync");
categories_list->emplace_back("node.http");
categories_list->emplace_back("node.net.native");
categories_list->emplace_back("node.perf");
categories_list->emplace_back("node.perf.timerify");
categories_list->emplace_back("node.perf.usertiming");
categories_list->emplace_back("node.promises.rejections");
categories_list->emplace_back("node.threadpoolwork.async");
categories_list->emplace_back("node.threadpoolwork.sync");
categories_list->emplace_back("node.vm.script");
categories_list->emplace_back("v8");
return DispatchResponse::OK();
}

View File

@ -638,7 +638,6 @@ def main():
"Object_h.template",
"ValueConversions_h.template",
"Maybe_h.template",
"Array_h.template",
"DispatcherBase_h.template",
"Parser_h.template",
"encoding_h.template",

View File

@ -36,7 +36,6 @@ template("inspector_protocol_generate") {
"$inspector_protocol_dir/lib/encoding_h.template",
"$inspector_protocol_dir/lib/encoding_cpp.template",
"$inspector_protocol_dir/lib/Allocator_h.template",
"$inspector_protocol_dir/lib/Array_h.template",
"$inspector_protocol_dir/lib/DispatcherBase_cpp.template",
"$inspector_protocol_dir/lib/DispatcherBase_h.template",
"$inspector_protocol_dir/lib/ErrorSupport_cpp.template",

View File

@ -8,7 +8,6 @@
'lib/encoding_h.template',
'lib/encoding_cpp.template',
'lib/Allocator_h.template',
'lib/Array_h.template',
'lib/DispatcherBase_cpp.template',
'lib/DispatcherBase_h.template',
'lib/ErrorSupport_cpp.template',

View File

@ -1,138 +0,0 @@
// This file is generated by Array_h.template.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef {{"_".join(config.protocol.namespace)}}_Array_h
#define {{"_".join(config.protocol.namespace)}}_Array_h
//#include "ErrorSupport.h"
//#include "Forward.h"
//#include "ValueConversions.h"
//#include "Values.h"
{% for namespace in config.protocol.namespace %}
namespace {{namespace}} {
{% endfor %}
template<typename T>
class Array {
public:
static std::unique_ptr<Array<T>> create()
{
return std::unique_ptr<Array<T>>(new Array<T>());
}
static std::unique_ptr<Array<T>> fromValue(protocol::Value* value, ErrorSupport* errors)
{
protocol::ListValue* array = ListValue::cast(value);
if (!array) {
errors->addError("array expected");
return nullptr;
}
std::unique_ptr<Array<T>> result(new Array<T>());
errors->push();
for (size_t i = 0; i < array->size(); ++i) {
errors->setName(StringUtil::fromInteger(i));
std::unique_ptr<T> item = ValueConversions<T>::fromValue(array->at(i), errors);
result->m_vector.push_back(std::move(item));
}
errors->pop();
if (errors->hasErrors())
return nullptr;
return result;
}
void addItem(std::unique_ptr<T> value)
{
m_vector.push_back(std::move(value));
}
size_t length()
{
return m_vector.size();
}
T* get(size_t index)
{
return m_vector[index].get();
}
std::unique_ptr<protocol::ListValue> toValue()
{
std::unique_ptr<protocol::ListValue> result = ListValue::create();
for (auto& item : m_vector)
result->pushValue(ValueConversions<T>::toValue(item));
return result;
}
private:
std::vector<std::unique_ptr<T>> m_vector;
};
template<typename T>
class ArrayBase {
public:
static std::unique_ptr<Array<T>> create()
{
return std::unique_ptr<Array<T>>(new Array<T>());
}
static std::unique_ptr<Array<T>> fromValue(protocol::Value* value, ErrorSupport* errors)
{
protocol::ListValue* array = ListValue::cast(value);
if (!array) {
errors->addError("array expected");
return nullptr;
}
errors->push();
std::unique_ptr<Array<T>> result(new Array<T>());
for (size_t i = 0; i < array->size(); ++i) {
errors->setName(StringUtil::fromInteger(i));
T item = ValueConversions<T>::fromValue(array->at(i), errors);
result->m_vector.push_back(item);
}
errors->pop();
if (errors->hasErrors())
return nullptr;
return result;
}
void addItem(const T& value)
{
m_vector.push_back(value);
}
size_t length()
{
return m_vector.size();
}
T get(size_t index)
{
return m_vector[index];
}
std::unique_ptr<protocol::ListValue> toValue()
{
std::unique_ptr<protocol::ListValue> result = ListValue::create();
for (auto& item : m_vector)
result->pushValue(ValueConversions<T>::toValue(item));
return result;
}
private:
std::vector<T> m_vector;
};
template<> class Array<String> : public ArrayBase<String> {};
template<> class Array<int> : public ArrayBase<int> {};
template<> class Array<double> : public ArrayBase<double> {};
template<> class Array<bool> : public ArrayBase<bool> {};
{% for namespace in config.protocol.namespace %}
} // namespace {{namespace}}
{% endfor %}
#endif // !defined({{"_".join(config.protocol.namespace)}}_Array_h)

View File

@ -22,7 +22,6 @@
namespace {{namespace}} {
{% endfor %}
template<typename T> class Array;
class DictionaryValue;
class DispatchResponse;
class ErrorSupport;
@ -35,6 +34,26 @@ class StringValue;
class UberDispatcher;
class Value;
namespace detail {
template <typename T>
struct ArrayTypedef { typedef std::vector<std::unique_ptr<T>> type; };
template <>
struct ArrayTypedef<String> { typedef std::vector<String> type; };
template <>
struct ArrayTypedef<int> { typedef std::vector<int> type; };
template <>
struct ArrayTypedef<double> { typedef std::vector<double> type; };
template <>
struct ArrayTypedef<bool> { typedef std::vector<bool> type; };
} // namespace detail
template <typename T>
using Array = typename detail::ArrayTypedef<T>::type;
{% for namespace in config.protocol.namespace %}
} // namespace {{namespace}}
{% endfor %}

View File

@ -128,6 +128,72 @@ struct ValueConversions<Binary> {
}
};
template<typename T>
struct ValueConversions<std::vector<std::unique_ptr<T>>> {
static std::unique_ptr<std::vector<std::unique_ptr<T>>> fromValue(protocol::Value* value, ErrorSupport* errors) {
protocol::ListValue* array = ListValue::cast(value);
if (!array) {
errors->addError("array expected");
return nullptr;
}
errors->push();
std::unique_ptr<std::vector<std::unique_ptr<T>>> result(
new std::vector<std::unique_ptr<T>>());
result->reserve(array->size());
for (size_t i = 0; i < array->size(); ++i) {
errors->setName(StringUtil::fromInteger(i));
auto item = ValueConversions<T>::fromValue(array->at(i), errors);
result->emplace_back(std::move(item));
}
errors->pop();
if (errors->hasErrors())
return nullptr;
return result;
}
static std::unique_ptr<protocol::ListValue> toValue(std::vector<std::unique_ptr<T>>* v)
{
std::unique_ptr<protocol::ListValue> result = ListValue::create();
result->reserve(v->size());
for (auto& item : *v)
result->pushValue(ValueConversions<T>::toValue(item.get()));
return result;
}
};
template<typename T>
struct ValueConversions<std::vector<T>> {
static std::unique_ptr<std::vector<T>> fromValue(protocol::Value* value, ErrorSupport* errors) {
protocol::ListValue* array = ListValue::cast(value);
if (!array) {
errors->addError("array expected");
return nullptr;
}
errors->push();
std::unique_ptr<std::vector<T>> result(new std::vector<T>());
result->reserve(array->size());
for (size_t i = 0; i < array->size(); ++i) {
errors->setName(StringUtil::fromInteger(i));
auto item = ValueConversions<T>::fromValue(array->at(i), errors);
result->emplace_back(std::move(item));
}
errors->pop();
if (errors->hasErrors())
return nullptr;
return result;
}
static std::unique_ptr<protocol::ListValue> toValue(std::vector<T>* v)
{
std::unique_ptr<protocol::ListValue> result = ListValue::create();
result->reserve(v->size());
for (auto& item : *v)
result->pushValue(ValueConversions<T>::toValue(item));
return result;
}
};
template<>
struct ValueConversions<Value> {
static std::unique_ptr<Value> fromValue(protocol::Value* value, ErrorSupport* errors)

View File

@ -271,6 +271,7 @@ public:
Value* at(size_t index);
size_t size() const { return m_data.size(); }
void reserve(size_t capacity) { m_data.reserve(capacity); }
private:
ListValue();