Commit f938b792 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by V8 LUCI CQ

Roll inspector_protocol 6901e556365f74a41bb85b62a70d444d87db639a

Change-Id: Ia8d92151114c674b581ec2fa2b4e3297e9c7cf6f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905927
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Auto-Submit: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83331}
parent 25d6463b
......@@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0
Revision: 134539780e606a77d660d58bf95b5ab55875bc3c
Revision: 6901e556365f74a41bb85b62a70d444d87db639a
License: BSD
License File: LICENSE
Security Critical: no
......
......@@ -279,15 +279,16 @@ def create_any_type_definition():
def create_string_type_definition():
# pylint: disable=W0622
return {
"return_type": "String",
"pass_type": "const String&",
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
"type": "String",
"raw_type": "String",
"raw_pass_type": "const String&",
"raw_return_type": "String",
"return_type": "String",
"pass_type": "const String&",
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
"type": "String",
"raw_type": "String",
"raw_pass_type": "const String&",
"raw_return_type": "String",
"is_primitive": True
}
......@@ -324,19 +325,19 @@ def create_primitive_type_definition(type):
"boolean": "TypeBoolean",
}
return {
"return_type": typedefs[type],
"pass_type": typedefs[type],
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
"type": typedefs[type],
"raw_type": typedefs[type],
"raw_pass_type": typedefs[type],
"raw_return_type": typedefs[type],
"default_value": defaults[type]
"return_type": typedefs[type],
"pass_type": typedefs[type],
"to_pass_type": "%s",
"to_raw_type": "%s",
"to_rvalue": "%s",
"type": typedefs[type],
"raw_type": typedefs[type],
"raw_pass_type": typedefs[type],
"raw_return_type": typedefs[type],
"default_value": defaults[type],
"is_primitive": True
}
def wrap_array_definition(type):
# pylint: disable=W0622
return {
......@@ -424,6 +425,22 @@ class Protocol(object):
refs.add(json["$ref"])
return refs
def check_if_dependency_declared(self, domain, refs):
dependencies = domain.get('dependencies', set())
for ref in refs:
type_definition = self.type_definitions[ref]
if type_definition.get('is_primitive', False):
continue
domain_match = re.match(r'^(.*)[.]', ref)
if domain_match:
referenced_domain_name = domain_match.group(1)
if referenced_domain_name != domain[
'domain'] and not referenced_domain_name in dependencies:
sys.stderr.write((
"Domains [%s] uses type [%s] from domain [%s], but did not declare the dependency\n\n"
) % (domain["domain"], ref, referenced_domain_name))
exit(1)
def generate_used_types(self):
all_refs = set()
for domain in self.json_api["domains"]:
......@@ -431,11 +448,18 @@ class Protocol(object):
if "commands" in domain:
for command in domain["commands"]:
if self.generate_command(domain_name, command["name"]):
all_refs |= self.all_references(command)
all_refs_command = self.all_references(command)
# If the command has a redirect, it is as if it didn't exist on this domain.
if not command.get('redirect', False):
self.check_if_dependency_declared(domain, all_refs_command)
all_refs |= all_refs_command
if "events" in domain:
for event in domain["events"]:
if self.generate_event(domain_name, event["name"]):
all_refs |= self.all_references(event)
all_refs_event = self.all_references(event)
self.check_if_dependency_declared(domain, all_refs_event)
all_refs |= all_refs_event
dependencies = self.generate_type_dependencies()
queue = set(all_refs)
......
......@@ -344,7 +344,7 @@ void EncodeDouble(double value, std::vector<uint8_t>* out) {
void EnvelopeEncoder::EncodeStart(std::vector<uint8_t>* out) {
assert(byte_size_pos_ == 0);
out->push_back(kInitialByteForEnvelope);
// TODO(caseq): encode tag as an additional byte here.
out->push_back(kCBOREnvelopeTag);
out->push_back(kInitialByteFor32BitLengthByteString);
byte_size_pos_ = out->size();
out->resize(out->size() + sizeof(uint32_t));
......
......@@ -727,9 +727,9 @@ TEST(JsonCborRoundtrip, EncodingDecoding) {
span<uint8_t> ascii_in = SpanFrom(json);
json::ParseJSON(ascii_in, encoder.get());
std::vector<uint8_t> expected = {
0xd8, // envelope
0x5a, // byte string with 32 bit length
0, 0, 0, 94, // length is 94 bytes
0xd8, 0x18, // envelope
0x5a, // byte string with 32 bit length
0, 0, 0, 95, // length is 95 bytes
};
expected.push_back(0xbf); // indef length map start
EncodeString8(SpanFrom("string"), &expected);
......@@ -752,7 +752,8 @@ TEST(JsonCborRoundtrip, EncodingDecoding) {
EncodeString8(SpanFrom("null"), &expected);
expected.push_back(7 << 5 | 22); // RFC 7049 Section 2.3, Table 2: null
EncodeString8(SpanFrom("array"), &expected);
expected.push_back(0xd8); // envelope
expected.push_back(0xd8); // envelope (tag first byte)
expected.push_back(0x18); // envelope (tag second byte)
expected.push_back(0x5a); // byte string with 32 bit length
// the length is 5 bytes (that's up to end indef length array below).
for (uint8_t ch : std::array<uint8_t, 4>{{0, 0, 0, 5}})
......
......@@ -267,8 +267,8 @@ TEST(DispatchableTest, FaultyCBORTrailingJunk) {
Dispatchable dispatchable(SpanFrom(cbor));
EXPECT_FALSE(dispatchable.ok());
EXPECT_EQ(DispatchCode::PARSE_ERROR, dispatchable.DispatchError().Code());
EXPECT_EQ(56u, trailing_junk_pos);
EXPECT_EQ("CBOR: trailing junk at position 56",
EXPECT_EQ(57u, trailing_junk_pos);
EXPECT_EQ("CBOR: trailing junk at position 57",
dispatchable.DispatchError().Message());
}
......
......@@ -9,6 +9,7 @@
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include "cbor.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment