diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2019-05-19 10:54:52 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-06-01 10:28:34 +0300 |
commit | 5aaa7fee2e4a075d9123b885f9e8cda3de2a780a (patch) | |
tree | 119e5d320745d7381ab225cd6a55aaaf17606b4b /src/inspector | |
parent | aa8b820aaa4d36085baaf8beb1187b2b9955fffb (diff) |
tools: update inspector_protocol to 0aafd2
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/node/pull/27770
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector')
-rw-r--r-- | src/inspector/node_inspector.gypi | 5 | ||||
-rw-r--r-- | src/inspector/node_string.cc | 16 | ||||
-rw-r--r-- | src/inspector/node_string.h | 17 | ||||
-rw-r--r-- | src/inspector/tracing_agent.cc | 2 |
4 files changed, 28 insertions, 12 deletions
diff --git a/src/inspector/node_inspector.gypi b/src/inspector/node_inspector.gypi index 2ee8cfd7daf..1d1dbefd866 100644 --- a/src/inspector/node_inspector.gypi +++ b/src/inspector/node_inspector.gypi @@ -15,9 +15,12 @@ 'node_protocol_files': [ '<(protocol_tool_path)/lib/Allocator_h.template', '<(protocol_tool_path)/lib/Array_h.template', - '<(protocol_tool_path)/lib/Collections_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', '<(protocol_tool_path)/lib/DispatcherBase_h.template', + '<(protocol_tool_path)/lib/encoding_cpp.template', + '<(protocol_tool_path)/lib/encoding_h.template', '<(protocol_tool_path)/lib/ErrorSupport_cpp.template', '<(protocol_tool_path)/lib/ErrorSupport_h.template', '<(protocol_tool_path)/lib/Forward_h.template', diff --git a/src/inspector/node_string.cc b/src/inspector/node_string.cc index a79df9e817c..0d403c66f01 100644 --- a/src/inspector/node_string.cc +++ b/src/inspector/node_string.cc @@ -107,6 +107,22 @@ String fromUTF8(const uint8_t* data, size_t length) { return std::string(reinterpret_cast<const char*>(data), length); } +String fromUTF16(const uint16_t* data, size_t length) { + icu::UnicodeString utf16(reinterpret_cast<const char16_t*>(data), length); + std::string result; + return utf16.toUTF8String(result); +} + +const uint8_t* CharactersUTF8(const String& s) { + return reinterpret_cast<const uint8_t*>(s.data()); +} + +size_t CharacterCount(const String& s) { + icu::UnicodeString utf16 = + icu::UnicodeString::fromUTF8(icu::StringPiece(s.data(), s.length())); + return utf16.countChar32(); +} + } // namespace StringUtil } // namespace protocol } // namespace inspector diff --git a/src/inspector/node_string.h b/src/inspector/node_string.h index 39545b75aec..1b8560b6fa5 100644 --- a/src/inspector/node_string.h +++ b/src/inspector/node_string.h @@ -20,16 +20,6 @@ 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... inline void builderAppend(StringBuilder& builder, char c) { @@ -82,6 +72,13 @@ 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); +String fromUTF16(const uint16_t* data, size_t length); +const uint8_t* CharactersUTF8(const String& s); +size_t CharacterCount(const String& s); + +// Unimplemented. The generated code will fall back to CharactersUTF8(). +inline uint8_t* CharactersLatin1(const String& s) { return nullptr; } +inline const uint16_t* CharactersUTF16(const String& s) { return nullptr; } extern size_t kNotFound; } // namespace StringUtil diff --git a/src/inspector/tracing_agent.cc b/src/inspector/tracing_agent.cc index 609d70d22f8..14f55d0cac0 100644 --- a/src/inspector/tracing_agent.cc +++ b/src/inspector/tracing_agent.cc @@ -70,7 +70,7 @@ class SendMessageRequest : public Request { if (frontend_wrapper == nullptr) return; auto frontend = frontend_wrapper->get(); if (frontend != nullptr) { - frontend->sendRawNotification(message_); + frontend->sendRawJSONNotification(message_); } } |