Skip to content

Commit

Permalink
tools: update inspector_protocol to e8ba1a7
Browse files Browse the repository at this point in the history
Refs: https://chromium.googlesource.com/deps/inspector_protocol/+log

PR-URL: #39694
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and danielleadams committed Aug 16, 2021
1 parent 8d509d8 commit b9510d2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/inspector_protocol/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ def init_defaults(config_tuple, path, defaults):
".lib": False,
".lib.export_macro": "",
".lib.export_header": False,
# The encoding lib consists of encoding/encoding.h and
# encoding/encoding.cc in its subdirectory, which binaries
# may link / depend on, instead of relying on the
# JINJA2 templates lib/encoding_{h,cc}.template.
# In that case, |header| identifies the include file
# and |namespace| is the namespace it's using. Usually
# inspector_protocol_encoding but for v8's copy it's
# v8_inspector_protocol_encoding.
# TODO(johannes): Migrate away from lib/encoding_{h,cc}.template
# in favor of this.
".encoding_lib": { "header": "", "namespace": []},
}
for key_value in config_values:
parts = key_value.split("=")
Expand Down
28 changes: 28 additions & 0 deletions tools/inspector_protocol/lib/Values_cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

//#include "Values.h"

{% if config.encoding_lib.header %}
#include "{{config.encoding_lib.header}}"
{% endif %}

{% for namespace in config.protocol.namespace %}
namespace {{namespace}} {
{% endfor %}
Expand Down Expand Up @@ -64,6 +68,30 @@ void escapeStringForJSONInternal(const Char* str, unsigned len,
// to this constant.
static constexpr int kStackLimitValues = 1000;

{% if config.encoding_lib.namespace %}
using {{"::".join(config.encoding_lib.namespace)}}::Error;
using {{"::".join(config.encoding_lib.namespace)}}::Status;
using {{"::".join(config.encoding_lib.namespace)}}::span;
namespace cbor {
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::CBORTokenTag;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::CBORTokenizer;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeBinary;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeDouble;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeFalse;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeFromLatin1;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeFromUTF16;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeIndefiniteLengthArrayStart;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeIndefiniteLengthMapStart;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeInt32;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeNull;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeStop;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeString8;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EncodeTrue;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::EnvelopeEncoder;
using {{"::".join(config.encoding_lib.namespace + ['cbor'])}}::InitialByteForEnvelope;
} // namespace cbor
{% endif %}

// Below are three parsing routines for CBOR, which cover enough
// to roundtrip JSON messages.
std::unique_ptr<DictionaryValue> parseMap(int32_t stack_depth, cbor::CBORTokenizer* tokenizer);
Expand Down
3 changes: 3 additions & 0 deletions tools/inspector_protocol/lib/encoding_cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

{% if config.encoding_lib.header == "" %}

#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -2196,3 +2197,5 @@ Status ConvertJSONToCBOR(const Platform& platform,
{% for namespace in config.protocol.namespace %}
} // namespace {{namespace}}
{% endfor %}

{% endif %}
2 changes: 2 additions & 0 deletions tools/inspector_protocol/lib/encoding_h.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

{% if config.encoding_lib.header == "" %}
#ifndef {{"_".join(config.protocol.namespace)}}_encoding_h
#define {{"_".join(config.protocol.namespace)}}_encoding_h

Expand Down Expand Up @@ -518,3 +519,4 @@ Status ConvertJSONToCBOR(const Platform& platform,
} // namespace {{namespace}}
{% endfor %}
#endif // !defined({{"_".join(config.protocol.namespace)}}_encoding_h)
{% endif %}

0 comments on commit b9510d2

Please sign in to comment.