summaryrefslogtreecommitdiff
path: root/src/inspector
diff options
context:
space:
mode:
Diffstat (limited to 'src/inspector')
-rw-r--r--src/inspector/node_inspector.gypi8
-rw-r--r--src/inspector/node_string.cc22
-rw-r--r--src/inspector/node_string.h32
3 files changed, 58 insertions, 4 deletions
diff --git a/src/inspector/node_inspector.gypi b/src/inspector/node_inspector.gypi
index 9483a0712e..a59727f191 100644
--- a/src/inspector/node_inspector.gypi
+++ b/src/inspector/node_inspector.gypi
@@ -34,7 +34,7 @@
'<(protocol_tool_path)/templates/Imported_h.template',
'<(protocol_tool_path)/templates/TypeBuilder_cpp.template',
'<(protocol_tool_path)/templates/TypeBuilder_h.template',
- '<(protocol_tool_path)/CodeGenerator.py',
+ '<(protocol_tool_path)/code_generator.py',
]
},
'defines': [
@@ -87,7 +87,7 @@
],
'action': [
'python',
- 'tools/inspector_protocol/ConvertProtocolToJSON.py',
+ 'tools/inspector_protocol/convert_protocol_to_json.py',
'<@(_inputs)',
'<@(_outputs)',
],
@@ -105,7 +105,7 @@
'process_outputs_as_sources': 1,
'action': [
'python',
- 'tools/inspector_protocol/CodeGenerator.py',
+ 'tools/inspector_protocol/code_generator.py',
'--jinja_dir', '<@(protocol_tool_path)/..',
'--output_base', '<(SHARED_INTERMEDIATE_DIR)/src/',
'--config', '<(SHARED_INTERMEDIATE_DIR)/node_protocol_config.json',
@@ -123,7 +123,7 @@
],
'action': [
'python',
- 'tools/inspector_protocol/ConcatenateProtocols.py',
+ 'tools/inspector_protocol/concatenate_protocols.py',
'<@(_inputs)',
'<@(_outputs)',
],
diff --git a/src/inspector/node_string.cc b/src/inspector/node_string.cc
index cb9e90c20e..a79df9e817 100644
--- a/src/inspector/node_string.cc
+++ b/src/inspector/node_string.cc
@@ -85,6 +85,28 @@ double toDouble(const char* buffer, size_t length, bool* ok) {
return d;
}
+std::unique_ptr<Value> parseMessage(const std::string& message, bool binary) {
+ if (binary) {
+ return Value::parseBinary(
+ reinterpret_cast<const uint8_t*>(message.data()),
+ message.length());
+ }
+ return parseJSON(message);
+}
+
+ProtocolMessage jsonToMessage(String message) {
+ return message;
+}
+
+ProtocolMessage binaryToMessage(std::vector<uint8_t> message) {
+ return std::string(reinterpret_cast<const char*>(message.data()),
+ message.size());
+}
+
+String fromUTF8(const uint8_t* data, size_t length) {
+ return std::string(reinterpret_cast<const char*>(data), length);
+}
+
} // namespace StringUtil
} // namespace protocol
} // namespace inspector
diff --git a/src/inspector/node_string.h b/src/inspector/node_string.h
index 5047988536..39545b75ae 100644
--- a/src/inspector/node_string.h
+++ b/src/inspector/node_string.h
@@ -18,6 +18,17 @@ class Value;
using String = std::string;
using StringBuilder = std::ostringstream;
+using ProtocolMessage = std::string;
+
+class StringUTF8Adapter {
+ public:
+ explicit StringUTF8Adapter(const std::string& string) : string_(string) { }
+ const char* Data() const { return string_.data(); }
+ size_t length() const { return string_.length(); }
+
+ private:
+ const std::string& string_;
+};
namespace StringUtil {
// NOLINTNEXTLINE(runtime/references) This is V8 API...
@@ -67,8 +78,29 @@ void builderAppendQuotedString(StringBuilder& builder, const String&);
std::unique_ptr<Value> parseJSON(const String&);
std::unique_ptr<Value> parseJSON(v8_inspector::StringView view);
+std::unique_ptr<Value> parseMessage(const std::string& message, bool binary);
+ProtocolMessage jsonToMessage(String message);
+ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
+String fromUTF8(const uint8_t* data, size_t length);
+
extern size_t kNotFound;
} // namespace StringUtil
+
+// A read-only sequence of uninterpreted bytes with reference-counted storage.
+// Though the templates for generating the protocol bindings reference
+// this type, js_protocol.pdl doesn't have a field of type 'binary', so
+// therefore it's unnecessary to provide an implementation here.
+class Binary {
+ public:
+ const uint8_t* data() const { UNREACHABLE(); }
+ size_t size() const { UNREACHABLE(); }
+ String toBase64() const { UNREACHABLE(); }
+ static Binary fromBase64(const String& base64, bool* success) {
+ UNREACHABLE();
+ }
+ static Binary fromSpan(const uint8_t* data, size_t size) { UNREACHABLE(); }
+};
+
} // namespace protocol
} // namespace inspector
} // namespace node