Skip to content

Commit 4ac1158

Browse files
committed
squash! fix build
1 parent 2ffa854 commit 4ac1158

4 files changed

Lines changed: 27 additions & 15 deletions

File tree

src/inspector/node_string.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ String fromUTF8(const uint8_t* data, size_t length) {
107107
return std::string(reinterpret_cast<const char*>(data), length);
108108
}
109109

110+
String fromUTF16(const uint16_t* data, size_t length) {
111+
icu::UnicodeString utf16(reinterpret_cast<const char16_t*>(data), length);
112+
std::string result;
113+
return utf16.toUTF8String(result);
114+
}
115+
116+
const uint8_t* CharactersUTF8(const String& s) {
117+
return reinterpret_cast<const uint8_t*>(s.data());
118+
}
119+
120+
size_t CharacterCount(const String& s) {
121+
icu::UnicodeString utf16 =
122+
icu::UnicodeString::fromUTF8(icu::StringPiece(s.data(), s.length()));
123+
return utf16.countChar32();
124+
}
125+
110126
} // namespace StringUtil
111127
} // namespace protocol
112128
} // namespace inspector

src/inspector/node_string.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ using String = std::string;
2020
using StringBuilder = std::ostringstream;
2121
using ProtocolMessage = std::string;
2222

23-
class StringUTF8Adapter {
24-
public:
25-
explicit StringUTF8Adapter(const std::string& string) : string_(string) { }
26-
const char* Data() const { return string_.data(); }
27-
size_t length() const { return string_.length(); }
28-
29-
private:
30-
const std::string& string_;
31-
};
32-
3323
namespace StringUtil {
3424
// NOLINTNEXTLINE(runtime/references) This is V8 API...
3525
inline void builderAppend(StringBuilder& builder, char c) {
@@ -82,6 +72,13 @@ std::unique_ptr<Value> parseMessage(const std::string& message, bool binary);
8272
ProtocolMessage jsonToMessage(String message);
8373
ProtocolMessage binaryToMessage(std::vector<uint8_t> message);
8474
String fromUTF8(const uint8_t* data, size_t length);
75+
String fromUTF16(const uint16_t* data, size_t length);
76+
const uint8_t* CharactersUTF8(const String& s);
77+
size_t CharacterCount(const String& s);
78+
79+
// Unimplemented. The generated code will fall back to CharactersUTF8().
80+
inline uint8_t* CharactersLatin1(const String& s) { return nullptr; }
81+
inline const uint16_t* CharactersUTF16(const String& s) { return nullptr; }
8582

8683
extern size_t kNotFound;
8784
} // namespace StringUtil

src/inspector/tracing_agent.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class SendMessageRequest : public Request {
7373
if (frontend_wrapper == nullptr) return;
7474
auto frontend = frontend_wrapper->get();
7575
if (frontend != nullptr) {
76-
frontend->sendRawNotification(message_);
76+
frontend->sendRawJSONNotification(message_);
7777
}
7878
}
7979

tools/inspector_protocol/code_generator.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def unicode(s, *_):
3636

3737
def read_config():
3838
# pylint: disable=W0703
39-
def json_to_object(data, output_base, config_base):
39+
def json_to_object(data, output_base):
4040
def json_object_hook(object_dict):
41-
items = [(k, os.path.join(config_base, v) if k == "path" else v) for (k, v) in object_dict.items()]
41+
items = [(k, os.path.join(output_base, v) if k == "path" else v) for (k, v) in object_dict.items()]
4242
items = [(k, os.path.join(output_base, v) if k == "output" else v) for (k, v) in items]
4343
keys, values = list(zip(*items))
4444
return collections.namedtuple('X', keys)(*values)
@@ -69,7 +69,6 @@ def init_defaults(config_tuple, path, defaults):
6969
jinja_dir = arg_options.jinja_dir
7070
output_base = arg_options.output_base
7171
config_file = arg_options.config
72-
config_base = os.path.dirname(config_file)
7372
config_values = arg_options.config_value
7473
except Exception:
7574
# Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
@@ -80,7 +79,7 @@ def init_defaults(config_tuple, path, defaults):
8079
try:
8180
config_json_file = open(config_file, "r")
8281
config_json_string = config_json_file.read()
83-
config_partial = json_to_object(config_json_string, output_base, config_base)
82+
config_partial = json_to_object(config_json_string, output_base)
8483
config_json_file.close()
8584
defaults = {
8685
".use_snake_file_names": False,

0 commit comments

Comments
 (0)