Skip to content

Commit a4f9fa8

Browse files
deps: update inspector_protocol to c0045057ce801744c5e88596a2f1bab1802e
1 parent e97c75e commit a4f9fa8

15 files changed

Lines changed: 727 additions & 228 deletions

‎deps/inspector_protocol/README.node‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: inspector protocol
22
Short Name: inspector_protocol
33
URL: https://chromium.googlesource.com/deps/inspector_protocol/
44
Version: 0
5-
Revision: 1b1bcbbe060e8c8cd8704f00f78978c50991b307
5+
Revision: c0045057ce801744c5e88596a2f1bab1802e39f0
66
License: BSD
77
License File: LICENSE
88
Security Critical: no

‎deps/inspector_protocol/code_generator.py‎

Lines changed: 94 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -101,35 +101,35 @@ def init_defaults(config_tuple, path, defaults):
101101
config_base)
102102
config_json_file.close()
103103
defaults = {
104-
".use_snake_file_names": False,
105-
".use_title_case_methods": False,
106-
".use_embedder_types": False,
107-
".imported": False,
108-
".imported.export_macro": "",
109-
".imported.export_header": False,
110-
".imported.header": False,
111-
".imported.package": False,
112-
".imported.options": False,
113-
".protocol.export_macro": "",
114-
".protocol.export_header": False,
115-
".protocol.options": False,
116-
".protocol.file_name_prefix": "",
117-
".exported": False,
118-
".exported.export_macro": "",
119-
".exported.export_header": False,
120-
".lib": False,
121-
".lib.export_macro": "",
122-
".lib.export_header": False,
123-
".crdtp": False,
124-
".crdtp.dir": os.path.join(inspector_protocol_dir, "crdtp"),
125-
".crdtp.namespace": "crdtp",
104+
".use_snake_file_names": False,
105+
".use_title_case_methods": False,
106+
".use_embedder_types": False,
107+
".imported": False,
108+
".imported.export_macro": "",
109+
".imported.export_header": False,
110+
".imported.header": False,
111+
".imported.package": False,
112+
".imported.options": False,
113+
".protocol.export_macro": "",
114+
".protocol.export_header": False,
115+
".protocol.options": False,
116+
".protocol.file_name_prefix": "",
117+
".exported": False,
118+
".exported.export_macro": "",
119+
".exported.export_header": False,
120+
".lib": False,
121+
".lib.export_macro": "",
122+
".lib.export_header": False,
123+
".crdtp": False,
124+
".crdtp.dir": os.path.join(inspector_protocol_dir, "crdtp"),
125+
".crdtp.namespace": "crdtp",
126126
}
127127
for key_value in config_values:
128128
parts = key_value.split("=")
129129
if len(parts) == 2:
130130
defaults["." + parts[0]] = parts[1]
131-
return (jinja_dir, config_file, init_defaults(config_partial, "", defaults),
132-
depfile, stamp)
131+
return (jinja_dir, config_file, init_defaults(config_partial, "",
132+
defaults), depfile, stamp)
133133
except Exception:
134134
# Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.html
135135
exc = sys.exc_info()[1]
@@ -286,32 +286,32 @@ def create_any_type_definition():
286286
def create_string_type_definition():
287287
# pylint: disable=W0622
288288
return {
289-
"return_type": "String",
290-
"pass_type": "const String&",
291-
"to_pass_type": "%s",
292-
"to_raw_type": "%s",
293-
"to_rvalue": "%s",
294-
"type": "String",
295-
"raw_type": "String",
296-
"raw_pass_type": "const String&",
297-
"raw_return_type": "String",
298-
"is_primitive": True
289+
"return_type": "String",
290+
"pass_type": "const String&",
291+
"to_pass_type": "%s",
292+
"to_raw_type": "%s",
293+
"to_rvalue": "%s",
294+
"type": "String",
295+
"raw_type": "String",
296+
"raw_pass_type": "const String&",
297+
"raw_return_type": "String",
298+
"is_primitive": True
299299
}
300300

301301

302302
def create_binary_type_definition():
303303
# pylint: disable=W0622
304304
return {
305-
"return_type": "Binary",
306-
"pass_type": "const Binary&",
307-
"to_pass_type": "%s",
308-
"to_raw_type": "%s",
309-
"to_rvalue": "%s",
310-
"type": "Binary",
311-
"raw_type": "Binary",
312-
"raw_pass_type": "const Binary&",
313-
"raw_return_type": "Binary",
314-
"is_primitive": True
305+
"return_type": "Binary",
306+
"pass_type": "const Binary&",
307+
"to_pass_type": "%s",
308+
"to_raw_type": "%s",
309+
"to_rvalue": "%s",
310+
"type": "Binary",
311+
"raw_type": "Binary",
312+
"raw_pass_type": "const Binary&",
313+
"raw_return_type": "Binary",
314+
"is_primitive": True
315315
}
316316

317317

@@ -333,17 +333,17 @@ def create_primitive_type_definition(type):
333333
"boolean": "TypeBoolean",
334334
}
335335
return {
336-
"return_type": typedefs[type],
337-
"pass_type": typedefs[type],
338-
"to_pass_type": "%s",
339-
"to_raw_type": "%s",
340-
"to_rvalue": "%s",
341-
"type": typedefs[type],
342-
"raw_type": typedefs[type],
343-
"raw_pass_type": typedefs[type],
344-
"raw_return_type": typedefs[type],
345-
"default_value": defaults[type],
346-
"is_primitive": True
336+
"return_type": typedefs[type],
337+
"pass_type": typedefs[type],
338+
"to_pass_type": "%s",
339+
"to_raw_type": "%s",
340+
"to_rvalue": "%s",
341+
"type": typedefs[type],
342+
"raw_type": typedefs[type],
343+
"raw_pass_type": typedefs[type],
344+
"raw_return_type": typedefs[type],
345+
"default_value": defaults[type],
346+
"is_primitive": True
347347
}
348348

349349
def wrap_array_definition(type):
@@ -444,10 +444,12 @@ def check_if_dependency_declared(self, domain, refs):
444444
domain_match = re.match(r'^(.*)[.]', ref)
445445
if domain_match:
446446
referenced_domain_name = domain_match.group(1)
447-
if referenced_domain_name != domain['domain'] and not referenced_domain_name in dependencies:
448-
sys.stderr.write(("Domains [%s] uses type [%s] from domain [%s], but did not declare the dependency\n\n"
449-
) % (domain["domain"], ref, referenced_domain_name))
450-
exit(1)
447+
if referenced_domain_name != domain[
448+
'domain'] and not referenced_domain_name in dependencies:
449+
sys.stderr.write((
450+
"Domains [%s] uses type [%s] from domain [%s], but did not declare the dependency\n\n"
451+
) % (domain["domain"], ref, referenced_domain_name))
452+
exit(1)
451453

452454
def generate_used_types(self):
453455
all_refs = set()
@@ -552,10 +554,10 @@ def resolve_type(self, prop):
552554
return self.type_definitions[prop["type"]]
553555

554556
def optional_type(self, prop):
555-
type = self.resolve_type(prop)
556-
template = ("std::optional<{}>" if type.get('is_primitive', False)
557-
else "std::unique_ptr<{}>")
558-
return template.format(type.get("raw_type"))
557+
type = self.resolve_type(prop)
558+
template = ("std::optional<{}>"
559+
if type.get('is_primitive', False) else "std::unique_ptr<{}>")
560+
return template.format(type.get("raw_type"))
559561

560562
def generate_command(self, domain, command):
561563
if not self.config.protocol.options:
@@ -572,6 +574,12 @@ def generate_event(self, domain, event):
572574
def generate_type(self, domain, typename):
573575
return domain + "." + typename in self.used_types
574576

577+
def should_pass_associated_data(self, domain, command):
578+
if not self.config.protocol.options:
579+
return False
580+
return self.check_options(self.config.protocol.options, domain, command,
581+
"pass_associated_data", None, False)
582+
575583
def is_async_command(self, domain, command):
576584
if not self.config.protocol.options:
577585
return False
@@ -658,25 +666,23 @@ def main():
658666
}
659667

660668
if domain["domain"] in protocol.generate_domains:
661-
output_h = os.path.join(config.protocol.output, to_file_name(
662-
config, file_name + ".h"))
669+
output_h = os.path.join(config.protocol.output,
670+
to_file_name(config, file_name + ".h"))
663671
outputs[output_h] = h_template.render(template_context)
664672
source_set.add(h_template.filename)
665-
output_cpp = os.path.join(config.protocol.output, to_file_name(
666-
config, file_name + ".cpp"))
673+
output_cpp = os.path.join(config.protocol.output,
674+
to_file_name(config, file_name + ".cpp"))
667675
outputs[output_cpp] = cpp_template.render(template_context)
668676
source_set.add(cpp_template.filename)
669677
if domain["domain"] in protocol.exported_domains:
670-
output_export_h = os.path.join(config.exported.output, to_file_name(
671-
config, file_name + ".h"))
672-
outputs[output_export_h] = exported_template.render(
673-
template_context)
678+
output_export_h = os.path.join(config.exported.output,
679+
to_file_name(config, file_name + ".h"))
680+
outputs[output_export_h] = exported_template.render(template_context)
674681
source_set.add(exported_template.filename)
675682
if domain["domain"] in protocol.imported_domains:
676-
output_import_h = os.path.join(config.protocol.output, to_file_name(
677-
config, file_name + ".h"))
678-
outputs[output_import_h] = imported_template.render(
679-
template_context)
683+
output_import_h = os.path.join(config.protocol.output,
684+
to_file_name(config, file_name + ".h"))
685+
outputs[output_import_h] = imported_template.render(template_context)
680686
source_set.add(imported_template.filename)
681687

682688
if config.lib:
@@ -699,19 +705,19 @@ def main():
699705

700706
if not config.use_embedder_types:
701707
protocol_h_templates += [
702-
"Values_h.template",
703-
"Object_h.template",
704-
"ValueConversions_h.template",
708+
"Values_h.template",
709+
"Object_h.template",
710+
"ValueConversions_h.template",
705711
]
706712
protocol_cpp_templates += [
707-
"Protocol_cpp.template",
708-
"Values_cpp.template",
709-
"Object_cpp.template",
710-
"ValueConversions_cpp.template",
713+
"Protocol_cpp.template",
714+
"Values_cpp.template",
715+
"Object_cpp.template",
716+
"ValueConversions_cpp.template",
711717
]
712718
else:
713719
protocol_h_templates += [
714-
"Forward_h.template",
720+
"Forward_h.template",
715721
]
716722

717723
def generate_lib_file(file_name, template_files):
@@ -729,8 +735,9 @@ def generate_lib_file(file_name, template_files):
729735
config, "Protocol.h")), protocol_h_templates)
730736

731737
if not config.use_embedder_types:
732-
generate_lib_file(os.path.join(config.lib.output, to_file_name(
733-
config, "Protocol.cpp")), protocol_cpp_templates)
738+
generate_lib_file(
739+
os.path.join(config.lib.output, to_file_name(config, "Protocol.cpp")),
740+
protocol_cpp_templates)
734741

735742
if stamp_filename:
736743
with open(stamp_filename, "w"):
@@ -748,8 +755,8 @@ def generate_lib_file(file_name, template_files):
748755
if deps_filename:
749756
assert stamp_filename
750757
with open(deps_filename, "w") as deps_file:
751-
deps_file.write("%s: %s\n" % (
752-
stamp_filename, " ".join(sorted(source_set))))
758+
deps_file.write("%s: %s\n" %
759+
(stamp_filename, " ".join(sorted(source_set))))
753760

754761

755762
if __name__ == "__main__":

‎deps/inspector_protocol/concatenate_protocols.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def main(argv):
5858
if deps_filename:
5959
assert stamp_filename
6060
with open(deps_filename, "w") as deps_file:
61-
deps_file.write("%s: %s\n" % (
62-
stamp_filename, " ".join(sorted(source_set))))
61+
deps_file.write("%s: %s\n" %
62+
(stamp_filename, " ".join(sorted(source_set))))
6363

6464

6565
if __name__ == '__main__':

‎deps/inspector_protocol/crdtp/cbor.cc‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,5 +1074,97 @@ Status AppendString8EntryToCBORMap(span<uint8_t> string8_key,
10741074
*(out) = new_envelope_size & 0xff;
10751075
return Status();
10761076
}
1077+
1078+
span<uint8_t> GetString8ValueFromMap(span<uint8_t> message,
1079+
span<uint8_t> string8_key) {
1080+
CBORTokenizer tokenizer(message);
1081+
if (tokenizer.TokenTag() != CBORTokenTag::ENVELOPE) {
1082+
return {};
1083+
}
1084+
tokenizer.EnterEnvelope();
1085+
if (tokenizer.TokenTag() != CBORTokenTag::MAP_START) {
1086+
return {};
1087+
}
1088+
tokenizer.Next();
1089+
span<uint8_t> result;
1090+
bool found_key = false;
1091+
bool found_value = false;
1092+
bool is_key = true;
1093+
while (tokenizer.TokenTag() != CBORTokenTag::STOP &&
1094+
tokenizer.TokenTag() != CBORTokenTag::DONE &&
1095+
tokenizer.TokenTag() != CBORTokenTag::ERROR_VALUE) {
1096+
if (tokenizer.TokenTag() == CBORTokenTag::MAP_START ||
1097+
tokenizer.TokenTag() == CBORTokenTag::ARRAY_START) {
1098+
return {};
1099+
}
1100+
if (is_key) {
1101+
if (tokenizer.TokenTag() == CBORTokenTag::STRING8 &&
1102+
SpanEquals(tokenizer.GetString8(), string8_key)) {
1103+
if (found_key) {
1104+
return {}; // Duplicate key
1105+
}
1106+
found_key = true;
1107+
}
1108+
} else if (found_key && !found_value) {
1109+
if (tokenizer.TokenTag() == CBORTokenTag::STRING8) {
1110+
result = tokenizer.GetString8();
1111+
}
1112+
found_value = true;
1113+
}
1114+
tokenizer.Next();
1115+
is_key = !is_key;
1116+
}
1117+
if (tokenizer.TokenTag() != CBORTokenTag::STOP) {
1118+
return {};
1119+
}
1120+
return result;
1121+
}
1122+
1123+
bool HasKeyInMap(span<uint8_t> message, span<uint8_t> key) {
1124+
CBORTokenizer tokenizer(message);
1125+
if (tokenizer.TokenTag() != CBORTokenTag::ENVELOPE) {
1126+
return false;
1127+
}
1128+
tokenizer.EnterEnvelope();
1129+
if (tokenizer.TokenTag() != CBORTokenTag::MAP_START) {
1130+
return false;
1131+
}
1132+
tokenizer.Next();
1133+
bool is_key = true;
1134+
size_t nested_depth = 0;
1135+
while (tokenizer.TokenTag() != CBORTokenTag::DONE &&
1136+
tokenizer.TokenTag() != CBORTokenTag::ERROR_VALUE) {
1137+
if (tokenizer.TokenTag() == CBORTokenTag::STOP) {
1138+
if (nested_depth == 0) {
1139+
break;
1140+
}
1141+
nested_depth--;
1142+
if (nested_depth == 0) {
1143+
is_key = !is_key;
1144+
}
1145+
tokenizer.Next();
1146+
continue;
1147+
}
1148+
if (tokenizer.TokenTag() == CBORTokenTag::MAP_START ||
1149+
tokenizer.TokenTag() == CBORTokenTag::ARRAY_START) {
1150+
nested_depth++;
1151+
tokenizer.Next();
1152+
continue;
1153+
}
1154+
if (nested_depth > 0) {
1155+
tokenizer.Next();
1156+
continue;
1157+
}
1158+
if (is_key) {
1159+
if (tokenizer.TokenTag() == CBORTokenTag::STRING8 &&
1160+
SpanEquals(tokenizer.GetString8(), key)) {
1161+
return true;
1162+
}
1163+
}
1164+
tokenizer.Next();
1165+
is_key = !is_key;
1166+
}
1167+
return false;
1168+
}
10771169
} // namespace cbor
10781170
} // namespace crdtp

0 commit comments

Comments
 (0)