Factor out field listener annotation processing into a separate file.

This is part of the Printer::Emit() migration, since it allows us to drop some relatively complex logic out of ClassVars/FieldVars, which is an impediment to further migration of message.cc.

The factored-out logic is not the prettiest, but cleaning it up further will require more refactors throughout the compiler.

This CL also changes std::initializer_lists in Printer's interface into absl::Spans, which were not available when the new Printer API was designed, but which are necessary for the new API to work with Printer.

PiperOrigin-RevId: 496441433
pull/11361/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 353b96cf61
commit cdb362c50a
  1. 67
      src/file_lists.cmake
  2. 15
      src/google/protobuf/compiler/cpp/BUILD.bazel
  3. 186
      src/google/protobuf/compiler/cpp/field.cc
  4. 135
      src/google/protobuf/compiler/cpp/message.cc
  5. 339
      src/google/protobuf/compiler/cpp/tracker.cc
  6. 58
      src/google/protobuf/compiler/cpp/tracker.h
  7. 20
      src/google/protobuf/compiler/plugin.pb.cc
  8. 135
      src/google/protobuf/descriptor.pb.cc
  9. 153
      src/google/protobuf/descriptor.pb.h
  10. 2
      src/google/protobuf/io/printer.cc
  11. 33
      src/google/protobuf/io/printer.h

@ -1,4 +1,4 @@
# Auto-generated by @//pkg:gen_src_file_lists_cmake
# Auto-generated by //pkg:gen_src_file_lists_cmake
#
# This file contains lists of sources based on Bazel rules. It should
# be included from a hand-written CMake file that defines targets.
@ -9,7 +9,7 @@ if(${CMAKE_VERSION} VERSION_GREATER 3.10 OR ${CMAKE_VERSION} VERSION_EQUAL 3.10)
include_guard()
endif()
# @//pkg:protobuf
# //pkg:protobuf
set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.cc
@ -85,7 +85,7 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc
)
# @//pkg:protobuf
# //pkg:protobuf
set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/any.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/api.pb.h
@ -192,7 +192,7 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h
)
# @//pkg:protobuf_lite
# //pkg:protobuf_lite
set(libprotobuf_lite_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/any_lite.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.cc
@ -220,7 +220,7 @@ set(libprotobuf_lite_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc
)
# @//pkg:protobuf_lite
# //pkg:protobuf_lite
set(libprotobuf_lite_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/any.h
${protobuf_SOURCE_DIR}/src/google/protobuf/arena.h
@ -270,7 +270,7 @@ set(libprotobuf_lite_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h
)
# @//pkg:protoc
# //pkg:protoc
set(libprotoc_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.cc
@ -289,6 +289,7 @@ set(libprotoc_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/primitive_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/service.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/string_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/tracker.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_enum.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
@ -365,7 +366,7 @@ set(libprotoc_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/zip_writer.cc
)
# @//pkg:protoc
# //pkg:protoc
set(libprotoc_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.h
@ -468,7 +469,7 @@ set(libprotoc_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/zip_writer.h
)
# @//src/google/protobuf:well_known_type_protos
# //src/google/protobuf:well_known_type_protos
set(wkt_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/any.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/api.proto
@ -482,68 +483,68 @@ set(wkt_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/wrappers.proto
)
# @//src/google/protobuf:descriptor_proto
# //src/google/protobuf:descriptor_proto
set(descriptor_proto_proto_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.proto
)
# @//src/google/protobuf:descriptor_proto
# //src/google/protobuf:descriptor_proto
set(descriptor_proto_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.proto.pb.cc
)
# @//src/google/protobuf:descriptor_proto
# //src/google/protobuf:descriptor_proto
set(descriptor_proto_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor.proto.pb.h
)
# @//src/google/protobuf:descriptor_proto
# //src/google/protobuf:descriptor_proto
set(descriptor_proto_files
${protobuf_SOURCE_DIR}/src/google/protobuf/descriptor_proto-descriptor-set.proto.bin
)
# @//src/google/protobuf/compiler:plugin_proto
# //src/google/protobuf/compiler:plugin_proto
set(plugin_proto_proto_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.proto
)
# @//src/google/protobuf/compiler:plugin_proto
# //src/google/protobuf/compiler:plugin_proto
set(plugin_proto_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.proto.pb.cc
)
# @//src/google/protobuf/compiler:plugin_proto
# //src/google/protobuf/compiler:plugin_proto
set(plugin_proto_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin.proto.pb.h
)
# @//src/google/protobuf/compiler:plugin_proto
# //src/google/protobuf/compiler:plugin_proto
set(plugin_proto_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/plugin_proto-descriptor-set.proto.bin
)
# @//pkg:common_test
# //pkg:common_test
set(common_test_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/googletest.cc
)
# @//pkg:common_test
# //pkg:common_test
set(common_test_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.h
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/file.h
${protobuf_SOURCE_DIR}/src/google/protobuf/testing/googletest.h
)
# @//pkg:lite_test_util
# //pkg:lite_test_util
set(lite_test_util_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util_lite.cc
)
# @//pkg:lite_test_util
# //pkg:lite_test_util
set(lite_test_util_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_test_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_test_util.h
@ -554,14 +555,14 @@ set(lite_test_util_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util_lite.h
)
# @//pkg:test_util
# //pkg:test_util
set(test_util_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/annotation_test_util.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/reflection_tester.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_util.cc
)
# @//pkg:test_util
# //pkg:test_util
set(test_util_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/annotation_test_util.h
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/unittest.h
@ -576,7 +577,7 @@ set(test_util_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.inc
)
# @//src/google/protobuf:full_test_srcs
# //src/google/protobuf:full_test_srcs
set(protobuf_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/any_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/arena_align_test.cc
@ -608,7 +609,7 @@ set(protobuf_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_unittest.cc
)
# @//src/google/protobuf:test_proto_srcs
# //src/google/protobuf:test_proto_srcs
set(protobuf_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/any_test.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/map_proto2_unittest.proto
@ -641,13 +642,13 @@ set(protobuf_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_well_known_types.proto
)
# @//src/google/protobuf:lite_test_srcs
# //src/google/protobuf:lite_test_srcs
set(protobuf_lite_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/lite_arena_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/lite_unittest.cc
)
# @//src/google/protobuf:lite_test_proto_srcs
# //src/google/protobuf:lite_test_proto_srcs
set(protobuf_lite_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/map_lite_unittest.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_import_lite.proto
@ -655,7 +656,7 @@ set(protobuf_lite_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/unittest_lite.proto
)
# @//src/google/protobuf/compiler:test_srcs
# //src/google/protobuf/compiler:test_srcs
set(compiler_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/bootstrap_unittest.cc
@ -678,18 +679,18 @@ set(compiler_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc
)
# @//src/google/protobuf/compiler:test_proto_srcs
# //src/google/protobuf/compiler:test_proto_srcs
set(compiler_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/test_bad_identifiers.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/cpp/test_large_enum_value.proto
)
# @//src/google/protobuf/compiler:test_plugin_srcs
# //src/google/protobuf/compiler:test_plugin_srcs
set(test_plugin_files
${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/test_plugin.cc
)
# @//src/google/protobuf/io:test_srcs
# //src/google/protobuf/io:test_srcs
set(io_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/io/coded_stream_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/io/io_win32_unittest.cc
@ -700,7 +701,7 @@ set(io_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_unittest.cc
)
# @//src/google/protobuf/util:test_srcs
# //src/google/protobuf/util:test_srcs
set(util_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util_test.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/field_comparator_test.cc
@ -710,14 +711,14 @@ set(util_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/util/type_resolver_util_test.cc
)
# @//src/google/protobuf/util:test_proto_srcs
# //src/google/protobuf/util:test_proto_srcs
set(util_test_protos_files
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/json_format_proto3.proto
${protobuf_SOURCE_DIR}/src/google/protobuf/util/message_differencer_unittest.proto
)
# @//src/google/protobuf/stubs:test_srcs
# //src/google/protobuf/stubs:test_srcs
set(stubs_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common_unittest.cc
)

@ -15,27 +15,27 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":names_internal",
"//src/google/protobuf/compiler:code_generator",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
],
)
cc_library(
name = "names_internal",
srcs = [
"helpers.cc",
],
hdrs = [
"helpers.h",
"names.h",
"options.h",
],
srcs = [
"helpers.cc",
],
copts = COPTS,
include_prefix = "google/protobuf/compiler/cpp",
visibility = ["//pkg:__pkg__"],
deps = [
"//src/google/protobuf/compiler:code_generator",
"//src/google/protobuf:protobuf_nowkt",
"//src/google/protobuf/compiler:code_generator",
],
)
@ -56,6 +56,7 @@ cc_library(
"primitive_field.cc",
"service.cc",
"string_field.cc",
"tracker.cc",
],
hdrs = [
"enum.h",
@ -73,6 +74,7 @@ cc_library(
"primitive_field.h",
"service.h",
"string_field.h",
"tracker.h",
],
copts = COPTS,
include_prefix = "google/protobuf/compiler/cpp",
@ -82,9 +84,8 @@ cc_library(
"@io_kythe//kythe/cxx/tools:__subpackages__",
],
deps = [
":names_internal",
":names",
"//src/google/protobuf:protobuf_nowkt",
":names_internal",
"//src/google/protobuf/compiler:code_generator",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:btree",

@ -58,183 +58,8 @@ namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
using internal::WireFormat;
namespace {
void MaySetAnnotationVariable(
const Options& options, absl::string_view annotation_name,
absl::string_view substitute_template_prefix,
absl::string_view prepared_template, int field_index,
absl::string_view access_type,
absl::flat_hash_map<absl::string_view, std::string>* variables) {
if (options.field_listener_options.forbidden_field_listener_events.contains(
annotation_name))
return;
(*variables)[absl::StrCat("annotate_", annotation_name)] = absl::Substitute(
absl::StrCat(substitute_template_prefix, prepared_template, ");\n"),
field_index, access_type);
}
std::string GenerateTemplateForOneofString(const FieldDescriptor* descriptor,
absl::string_view proto_ns,
absl::string_view field_member) {
std::string field_name = google::protobuf::compiler::cpp::FieldName(descriptor);
std::string field_pointer =
descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
? "$0.UnsafeGetPointer()"
: "$0";
std::string has_field = absl::StrFormat(
"%s_case() == k%s", descriptor->containing_oneof()->name(),
UnderscoresToCamelCase(descriptor->name(), true));
if (descriptor->default_value_string().empty()) {
return absl::Substitute(
absl::StrCat(has_field, " ? ", field_pointer, ": nullptr"),
field_member);
}
if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING_PIECE) {
return absl::Substitute(
absl::StrCat(has_field, " ? ", field_pointer, ": nullptr"),
field_member);
}
std::string default_value_pointer =
descriptor->options().ctype() == google::protobuf::FieldOptions::STRING
? "&$1.get()"
: "&$1";
return absl::Substitute(absl::StrCat(has_field, " ? ", field_pointer, " : ",
default_value_pointer),
field_member, MakeDefaultFieldName(descriptor));
}
std::string GenerateTemplateForSingleString(const FieldDescriptor* descriptor,
absl::string_view field_member) {
if (descriptor->default_value_string().empty()) {
return absl::StrCat("&", field_member);
}
if (descriptor->options().ctype() == google::protobuf::FieldOptions::STRING) {
return absl::Substitute(
"$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()", field_member,
MakeDefaultFieldName(descriptor));
}
return absl::StrCat("&", field_member);
}
} // namespace
void AddAccessorAnnotations(
const FieldDescriptor* descriptor, const Options& options,
absl::flat_hash_map<absl::string_view, std::string>* variables) {
// Can be expanded to include more specific calls, for example, for arena or
// clear calls.
static constexpr const char* kAccessorsAnnotations[] = {
"annotate_add", "annotate_get", "annotate_has",
"annotate_list", "annotate_mutable", "annotate_mutable_list",
"annotate_release", "annotate_set", "annotate_size",
"annotate_clear", "annotate_add_mutable",
};
for (size_t i = 0; i < ABSL_ARRAYSIZE(kAccessorsAnnotations); ++i) {
(*variables)[kAccessorsAnnotations[i]] = "";
}
if (options.annotate_accessor) {
for (size_t i = 0; i < ABSL_ARRAYSIZE(kAccessorsAnnotations); ++i) {
(*variables)[kAccessorsAnnotations[i]] = absl::StrCat(
" ", FieldName(descriptor), "_AccessedNoStrip = true;\n");
}
}
if (!options.field_listener_options.inject_field_listener_events) {
return;
}
if (descriptor->file()->options().optimize_for() ==
google::protobuf::FileOptions::LITE_RUNTIME) {
return;
}
std::string field_member = (*variables)["field"];
const google::protobuf::OneofDescriptor* oneof_member =
descriptor->real_containing_oneof();
const std::string substitute_template_prefix =
absl::StrCat(" ", (*variables)["tracker"], ".$1<$0>(this, ");
std::string prepared_template;
// Flat template is needed if the prepared one is introspecting the values
// inside the returned values, for example, for repeated fields and maps.
std::string prepared_flat_template;
std::string prepared_add_template;
// TODO(b/190614678): Support fields with type Message or Map.
if (descriptor->is_repeated() && !descriptor->is_map()) {
if (descriptor->type() != FieldDescriptor::TYPE_MESSAGE &&
descriptor->type() != FieldDescriptor::TYPE_GROUP) {
prepared_template = absl::Substitute("&$0.Get(index)", field_member);
prepared_add_template =
absl::Substitute("&$0.Get($0.size() - 1)", field_member);
} else {
prepared_template = "nullptr";
prepared_add_template = "nullptr";
}
} else if (descriptor->is_map()) {
prepared_template = "nullptr";
} else if (descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&
!IsExplicitLazy(descriptor)) {
prepared_template = "nullptr";
} else if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
if (oneof_member) {
prepared_template = GenerateTemplateForOneofString(
descriptor, ProtobufNamespace(options), field_member);
} else {
prepared_template =
GenerateTemplateForSingleString(descriptor, field_member);
}
} else {
prepared_template = absl::StrCat("&", field_member);
}
if (descriptor->is_repeated() && !descriptor->is_map() &&
descriptor->type() != FieldDescriptor::TYPE_MESSAGE &&
descriptor->type() != FieldDescriptor::TYPE_GROUP) {
prepared_flat_template = absl::StrCat("&", field_member);
} else {
prepared_flat_template = prepared_template;
}
MaySetAnnotationVariable(options, "get", substitute_template_prefix,
prepared_template, descriptor->index(), "OnGet",
variables);
MaySetAnnotationVariable(options, "set", substitute_template_prefix,
prepared_template, descriptor->index(), "OnSet",
variables);
MaySetAnnotationVariable(options, "has", substitute_template_prefix,
prepared_template, descriptor->index(), "OnHas",
variables);
MaySetAnnotationVariable(options, "mutable", substitute_template_prefix,
prepared_template, descriptor->index(), "OnMutable",
variables);
MaySetAnnotationVariable(options, "release", substitute_template_prefix,
prepared_template, descriptor->index(), "OnRelease",
variables);
MaySetAnnotationVariable(options, "clear", substitute_template_prefix,
prepared_flat_template, descriptor->index(),
"OnClear", variables);
MaySetAnnotationVariable(options, "size", substitute_template_prefix,
prepared_flat_template, descriptor->index(),
"OnSize", variables);
MaySetAnnotationVariable(options, "list", substitute_template_prefix,
prepared_flat_template, descriptor->index(),
"OnList", variables);
MaySetAnnotationVariable(options, "mutable_list", substitute_template_prefix,
prepared_flat_template, descriptor->index(),
"OnMutableList", variables);
MaySetAnnotationVariable(options, "add", substitute_template_prefix,
prepared_add_template, descriptor->index(), "OnAdd",
variables);
MaySetAnnotationVariable(options, "add_mutable", substitute_template_prefix,
prepared_add_template, descriptor->index(),
"OnAddMutable", variables);
}
absl::flat_hash_map<absl::string_view, std::string> FieldVars(
const FieldDescriptor* desc, const Options& opts) {
bool split = ShouldSplit(desc, opts);
@ -262,17 +87,6 @@ absl::flat_hash_map<absl::string_view, std::string> FieldVars(
{"}", ""},
};
// TODO(b/245791219): Refactor AddAccessorAnnotations to avoid this
// workaround.
absl::flat_hash_map<absl::string_view, std::string> workaround = {
{"field", vars["field"]},
{"tracker", "Impl_::_tracker_"},
};
AddAccessorAnnotations(desc, opts, &workaround);
for (auto& pair : workaround) {
vars.emplace(pair);
}
return vars;
}

@ -67,6 +67,7 @@
#include "google/protobuf/compiler/cpp/names.h"
#include "google/protobuf/compiler/cpp/padding_optimizer.h"
#include "google/protobuf/compiler/cpp/parse_function_generator.h"
#include "google/protobuf/compiler/cpp/tracker.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/io/printer.h"
#include "google/protobuf/wire_format.h"
@ -493,18 +494,6 @@ bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* p) {
return true;
}
void AnnotationVar(const Descriptor* desc, const Options& options,
absl::flat_hash_map<absl::string_view, std::string>& vars,
absl::string_view name, absl::string_view val) {
if (!HasTracker(desc, options) ||
options.field_listener_options.forbidden_field_listener_events.contains(
absl::StripPrefix(name, "annotate_"))) {
val = "";
}
vars.emplace(name, absl::StrCat(absl::StripAsciiWhitespace(val), "\n"));
}
absl::flat_hash_map<absl::string_view, std::string> ClassVars(
const Descriptor* desc, Options opts) {
absl::flat_hash_map<absl::string_view, std::string> vars = MessageVars(desc);
@ -524,107 +513,6 @@ absl::flat_hash_map<absl::string_view, std::string> ClassVars(
vars.emplace(pair);
}
AnnotationVar(desc, opts, vars, "annotate_serialize", R"cc(
Impl_::_tracker_.OnSerialize(this);
)cc");
AnnotationVar(desc, opts, vars, "annotate_deserialize", R"cc(
Impl_::_tracker_.OnDeserialize(this);
)cc");
// TODO(danilak): Ideally annotate_reflection should not exist and we need
// to annotate all reflective calls on our own, however, as this is a cause
// for side effects, i.e. reading values dynamically, we want the users know
// that dynamic access can happen.
AnnotationVar(desc, opts, vars, "annotate_reflection", R"cc(
Impl_::_tracker_.OnGetMetadata();
)cc");
AnnotationVar(desc, opts, vars, "annotate_bytesize", R"cc(
Impl_::_tracker_.OnByteSize(this);
)cc");
AnnotationVar(desc, opts, vars, "annotate_mergefrom", R"cc(
Impl_::_tracker_.OnMergeFrom(_this, &from);
)cc");
static constexpr std::array<std::pair<absl::string_view, absl::string_view>,
14>
kVarToHook = {{
{"annotate_extension_has", "OnHasExtension"},
{"annotate_extension_clear", "OnClearExtension"},
{"annotate_extension_repeated_size", "OnExtensionSize"},
{"annotate_extension_get", "OnGetExtension"},
{"annotate_extension_mutable", "OnMutableExtension"},
{"annotate_extension_set", "OnSetExtension"},
{"annotate_extension_release", "OnReleaseExtension"},
{"annotate_repeated_extension_get", "OnGetExtension"},
{"annotate_repeated_extension_mutable", "OnMutableExtension"},
{"annotate_repeated_extension_set", "OnSetExtension"},
{"annotate_repeated_extension_add", "OnAddExtension"},
{"annotate_repeated_extension_add_mutable", "OnAddMutableExtension"},
{"annotate_repeated_extension_list", "OnListExtension"},
{"annotate_repeated_extension_list_mutable",
"OnMutableListExtension"},
}};
for (const auto& annotation : kVarToHook) {
vars[annotation.first] = "";
}
if (!HasTracker(desc, opts)) {
return vars;
}
absl::string_view extensions = vars["extensions"];
for (const auto& annotation : kVarToHook) {
absl::string_view name = annotation.first;
absl::string_view call = annotation.second;
if (!absl::StrContains(name, "repeated") &&
!absl::StrContains(name, "size") && !absl::StrContains(name, "clear")) {
// Primitive fields accessors.
// "Has" is here as users calling "has" on a repeated field is a mistake.
vars[name] = std::string(absl::StripAsciiWhitespace(absl::Substitute(
R"cc(
Impl_::_tracker_.$0(this, id.number(),
_proto_TypeTraits::GetPtr(
id.number(), $1, id.default_value_ref()));
)cc",
call, extensions)));
continue;
}
if (absl::StrContains(name, "repeated") &&
!absl::StrContains(name, "list") && !absl::StrContains(name, "size")) {
// Repeated index accessors.
std::string str_index = "index";
if (absl::StrContains(name, "add")) {
str_index = absl::StrCat(extensions, ".ExtensionSize(id.number()) - 1");
}
vars[name] = std::string(absl::StripAsciiWhitespace(absl::Substitute(
R"cc(
Impl_::_tracker_.$0(this, id.number(),
_proto_TypeTraits::GetPtr(id.number(), $1, $2));
)cc",
call, extensions, str_index)));
continue;
}
if (absl::StrContains(name, "list") || absl::StrContains(name, "size")) {
// Repeated full accessors.
vars[name] = std::string(absl::StripAsciiWhitespace(absl::Substitute(
R"cc(
Impl_::_tracker_.$0(this, id.number(),
_proto_TypeTraits::GetRepeatedPtr(id.number(),
$1));
)cc",
call, extensions)));
continue;
}
// Generic accessors such as "clear".
// TODO(b/190614678): Generalize clear from both repeated and non repeated
// calls, currently their underlying memory interfaces are very different.
// Or think of removing clear callback as no usages are needed and no
// memory exist after calling clear().
}
return vars;
}
@ -803,6 +691,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* p) {
auto name = FieldName(field);
auto v = p->WithVars(FieldVars(field, options_));
auto t = p->WithVars(MakeTrackerCalls(field, options_));
p->Emit(
{{"field_comment", FieldComment(field)},
Sub("const_impl", !stripped ? "const;" : "const { __builtin_trap(); }")
@ -1084,6 +973,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* p) {
void MessageGenerator::GenerateSingularFieldHasBits(
const FieldDescriptor* field, io::Printer* p) {
auto t = p->WithVars(MakeTrackerCalls(field, options_));
Formatter format(p);
if (IsFieldStripped(field, options_)) {
format(
@ -1163,6 +1053,7 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* p) {
void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
io::Printer* p) {
auto v = p->WithVars(OneofFieldVars(field));
auto t = p->WithVars(MakeTrackerCalls(field, options_));
Formatter format(p);
if (IsFieldStripped(field, options_)) {
if (HasHasMethod(field)) {
@ -1202,6 +1093,7 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
bool is_inline, io::Printer* p) {
auto t = p->WithVars(MakeTrackerCalls(field, options_));
Formatter format(p);
if (IsFieldStripped(field, options_)) {
format("void $classname$::clear_$name$() { __builtin_trap(); }\n");
@ -1220,6 +1112,7 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
// Clear this field only if it is the active field in this oneof,
// otherwise ignore
auto v = p->WithVars(OneofFieldVars(field));
auto t = p->WithVars(MakeTrackerCalls(field, options_));
format("if ($has_field$) {\n");
format.Indent();
field_generators_.get(field).GenerateClearingCode(p);
@ -1254,6 +1147,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* p) {
}
auto v = p->WithVars(FieldVars(field, options_));
auto t = p->WithVars(MakeTrackerCalls(field, options_));
// Generate has_$name$() or $name$_size().
if (field->is_repeated()) {
if (IsFieldStripped(field, options_)) {
@ -1298,6 +1192,7 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* p) {
void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
if (IsMapEntryMessage(descriptor_)) {
@ -2000,6 +1895,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
void MessageGenerator::GenerateInlineMethods(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
if (IsMapEntryMessage(descriptor_)) return;
GenerateFieldAccessorDefinitions(p);
@ -2024,6 +1920,7 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* p) {
void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
int has_offset) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)
? offset + has_offset
@ -2042,6 +1939,7 @@ void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
void MessageGenerator::GenerateClassMethods(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
if (IsMapEntryMessage(descriptor_)) {
format(
@ -2111,6 +2009,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
" PROTOBUF_FIELD_OFFSET($classtype$, $oneof_case$);\n");
}
for (auto field : FieldRange(descriptor_)) {
auto t = p->WithVars(MakeTrackerCalls(field, options_));
field_generators_.get(field).GenerateInternalAccessorDeclarations(p);
if (IsFieldStripped(field, options_)) {
continue;
@ -2148,10 +2047,12 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
if (IsFieldStripped(field, options_)) {
continue;
}
auto v = p->WithVars(FieldVars(field, options_));
auto t = p->WithVars(MakeTrackerCalls(field, options_));
field_generators_.get(field).GenerateNonInlineAccessorDefinitions(p);
if (IsCrossFileMaybeMap(field)) {
auto v1 = p->WithVars(FieldVars(field, options_));
auto v2 = p->WithVars(OneofFieldVars(field));
auto v = p->WithVars(OneofFieldVars(field));
GenerateFieldClear(field, false, p);
}
}
@ -2250,6 +2151,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* p) {
std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) {
@ -2498,6 +2400,7 @@ void MessageGenerator::GenerateInitDefaultSplitInstance(io::Printer* p) {
if (!ShouldSplit(descriptor_, options_)) return;
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
const char* field_sep = " ";
const auto put_sep = [&] {
@ -2630,6 +2533,7 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* p) {
void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
if (IsMapEntryMessage(descriptor_) || !HasImplData(descriptor_, options_)) {
@ -3019,6 +2923,7 @@ void MessageGenerator::GenerateStructors(io::Printer* p) {
void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* p) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
format(
"template<> "

@ -0,0 +1,339 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2022 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "google/protobuf/compiler/cpp/tracker.h"
#include <string>
#include <utility>
#include <vector>
#include "google/protobuf/descriptor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/strings/substitute.h"
#include "absl/types/optional.h"
#include "google/protobuf/compiler/cpp/helpers.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
namespace {
using Sub = ::google::protobuf::io::Printer::Sub;
constexpr absl::string_view kTracker = "Impl_::_tracker_";
constexpr absl::string_view kVarPrefix = "annotate_";
constexpr absl::string_view kTypeTraits = "_proto_TypeTraits";
struct Call {
Call(absl::string_view var, absl::string_view call) : var(var), call(call) {}
Call(absl::optional<int> field_index, absl::string_view var,
absl::string_view call)
: var(var), call(call), field_index(field_index) {}
Call This(absl::optional<absl::string_view> thiz) && {
this->thiz = thiz;
return std::move(*this);
}
template <typename... SubArgs>
Call Arg(absl::string_view format, const SubArgs&... args) && {
this->args.emplace_back(absl::Substitute(format, args...));
return std::move(*this);
}
Call Suppressed() && {
suppressed = true;
return std::move(*this);
}
absl::string_view var;
absl::string_view call;
absl::optional<int> field_index;
absl::optional<absl::string_view> thiz = "this";
std::vector<std::string> args;
bool suppressed = false;
};
std::vector<Sub> GenerateTrackerCalls(
const Options& opts, const Descriptor* message,
absl::optional<std::string> alt_annotation, absl::Span<const Call> calls) {
bool enable_tracking = HasTracker(message, opts);
const auto& forbidden =
opts.field_listener_options.forbidden_field_listener_events;
std::vector<Sub> subs;
for (const auto& call : calls) {
std::string call_str;
if (enable_tracking && !call.suppressed && !forbidden.contains(call.var)) {
absl::SubstituteAndAppend(&call_str, "$0.$1", kTracker, call.call);
if (call.field_index.has_value()) {
absl::SubstituteAndAppend(&call_str, "<$0>", *call.field_index);
}
absl::StrAppend(&call_str, "(");
absl::string_view arg_sep = "";
if (call.thiz.has_value()) {
absl::StrAppend(&call_str, *call.thiz);
arg_sep = ", ";
}
for (const auto& arg : call.args) {
absl::StrAppend(&call_str, arg_sep, arg);
arg_sep = ", ";
}
absl::StrAppend(&call_str, ");");
} else if (opts.annotate_accessor && alt_annotation.has_value()) {
call_str = *alt_annotation;
}
if (!call_str.empty()) {
// TODO(b/245791219): Until we migrate all of the C++ backend to use
// Emit(), we need to include a newline here so that the line that follows
// the annotation is on its own line.
call_str.push_back('\n');
}
subs.push_back(
Sub(absl::StrCat(kVarPrefix, call.var), call_str).WithSuffix(";"));
}
return subs;
}
} // namespace
std::vector<Sub> MakeTrackerCalls(const Descriptor* message,
const Options& opts) {
absl::string_view extns =
IsMapEntryMessage(message) ? "_extensions_" : "_impl_._extensions_";
auto primitive_extn_accessor = [extns](absl::string_view var,
absl::string_view call) {
return Call(var, call)
.Arg("id.number()")
.Arg("$0::GetPtr(id.number(), $1, id.default_value_ref())", kTypeTraits,
extns);
};
auto index_extn_accessor = [extns](absl::string_view var,
absl::string_view call) {
return Call(var, call)
.Arg("id.number()")
.Arg("$0::GetPtr(id.number(), $1, index)", kTypeTraits, extns);
};
auto add_extn_accessor = [extns](absl::string_view var,
absl::string_view call) {
return Call(var, call)
.Arg("id.number()")
.Arg("$0::GetPtr(id.number(), $1, $1.ExtensionSize(id.number()) - 1)",
kTypeTraits, extns);
};
auto list_extn_accessor = [extns](absl::string_view var,
absl::string_view call) {
return Call(var, call)
.Arg("id.number()")
.Arg("$0::GetRepeatedPtr(id.number(), $1)", kTypeTraits, extns);
};
return GenerateTrackerCalls(
opts, message, absl::nullopt,
{
Call("serialize", "OnSerialize"),
Call("deserialize", "OnDeserialize"),
// TODO(danilak): Ideally annotate_reflection should not exist and we
// need to annotate all reflective calls on our own, however, as this
// is a cause for side effects, i.e. reading values dynamically, we
// want the users know that dynamic access can happen.
Call("reflection", "OnGetMetadata").This(absl::nullopt),
Call("bytesize", "OnByteSize"),
Call("mergefrom", "OnMergeFrom").This("_this").Arg("&from"),
// "Has" is here as users calling "has" on a repeated field is a
// mistake.
primitive_extn_accessor("extension_has", "OnHasExtension"),
primitive_extn_accessor("extension_get", "OnGetExtension"),
primitive_extn_accessor("extension_mutable", "OnMutableExtension"),
primitive_extn_accessor("extension_set", "OnSetExtension"),
primitive_extn_accessor("extension_release", "OnReleaseExtension"),
index_extn_accessor("repeated_extension_get", "OnGetExtension"),
index_extn_accessor("repeated_extension_mutable",
"OnMutableExtension"),
index_extn_accessor("repeated_extension_set", "OnSetExtension"),
add_extn_accessor("repeated_extension_add", "OnAddExtension"),
add_extn_accessor("repeated_extension_add_mutable",
"OnAddMutableExtension"),
list_extn_accessor("extension_repeated_size", "OnExtensionSize"),
list_extn_accessor("repeated_extension_list", "OnListExtension"),
list_extn_accessor("repeated_extension_list_mutable",
"OnMutableListExtension"),
// Generic accessors such as "clear".
// TODO(b/190614678): Generalize clear from both repeated and non
// repeated calls, currently their underlying memory interfaces are
// very different. Or think of removing clear callback as no usages
// are needed and no memory exist
Call("extension_clear", "OnClearExtension").Suppressed(),
});
}
namespace {
struct Getters {
std::string base = "nullptr";
std::string for_last = "nullptr";
std::string for_flat = "nullptr";
};
Getters RepeatedFieldGetters(const FieldDescriptor* field,
const Options& opts) {
std::string member = FieldMemberName(field, ShouldSplit(field, opts));
Getters getters;
if (!field->is_map() &&
field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
getters.base = absl::Substitute("&$0.Get(index)", member);
getters.for_last = absl::Substitute("&$0.Get($0.size() - 1)", member);
getters.for_flat = absl::StrCat("&", member);
}
return getters;
}
Getters StringFieldGetters(const FieldDescriptor* field, const Options& opts) {
std::string member = FieldMemberName(field, ShouldSplit(field, opts));
bool is_std_string = field->options().ctype() == FieldOptions::STRING;
Getters getters;
if (is_std_string && !field->default_value_string().empty()) {
getters.base =
absl::Substitute("$0.IsDefault() ? &$1.get() : $0.UnsafeGetPointer()",
member, MakeDefaultFieldName(field));
} else {
getters.base = absl::StrCat("&", member);
}
getters.for_flat = getters.base;
return getters;
}
Getters StringOneofGetters(const FieldDescriptor* field,
const OneofDescriptor* oneof, const Options& opts) {
GOOGLE_ABSL_CHECK(oneof != nullptr);
std::string member = FieldMemberName(field, ShouldSplit(field, opts));
bool is_std_string = field->options().ctype() == FieldOptions::STRING;
std::string field_ptr = member;
if (is_std_string) {
field_ptr = absl::Substitute("$0.UnsafeGetPointer()", member);
}
std::string has =
absl::Substitute("$0_case() == k$1", oneof->name(),
UnderscoresToCamelCase(field->name(), true));
std::string default_field = MakeDefaultFieldName(field);
if (is_std_string) {
absl::StrAppend(&default_field, ".get()");
}
Getters getters;
if (field->default_value_string().empty() ||
field->options().ctype() == FieldOptions::STRING_PIECE) {
getters.base = absl::Substitute("$0 ? $1 : nullptr", has, field_ptr);
} else {
getters.base =
absl::Substitute("$0 ? $1 : &$2", has, field_ptr, default_field);
}
getters.for_flat = getters.base;
return getters;
}
Getters SingularFieldGetters(const FieldDescriptor* field,
const Options& opts) {
std::string member = FieldMemberName(field, ShouldSplit(field, opts));
Getters getters;
getters.base = absl::StrCat("&", member);
if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {
getters.for_flat = absl::StrCat("&", member);
}
return getters;
}
} // namespace
std::vector<Sub> MakeTrackerCalls(const FieldDescriptor* field,
const Options& opts) {
Getters getters;
if (field->is_repeated()) {
getters = RepeatedFieldGetters(field, opts);
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
const auto* oneof = field->real_containing_oneof();
if (oneof != nullptr) {
getters = StringOneofGetters(field, oneof, opts);
} else {
getters = StringFieldGetters(field, opts);
}
} else if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE ||
IsExplicitLazy(field)) {
getters = SingularFieldGetters(field, opts);
}
auto index = field->index();
return GenerateTrackerCalls(
opts, field->containing_type(),
absl::Substitute("$0_AccessedNoStrip = true;", FieldName(field)),
{
Call(index, "get", "OnGet").Arg(getters.base),
Call(index, "set", "OnSet").Arg(getters.base),
Call(index, "has", "OnHas").Arg(getters.base),
Call(index, "mutable", "OnMutable").Arg(getters.base),
Call(index, "release", "OnRelease").Arg(getters.base),
Call(index, "clear", "OnClear").Arg(getters.for_flat),
Call(index, "size", "OnSize").Arg(getters.for_flat),
Call(index, "list", "OnList").Arg(getters.for_flat),
Call(index, "mutable_list", "OnMutableList").Arg(getters.for_flat),
Call(index, "add", "OnAdd").Arg(getters.for_last),
Call(index, "add_mutable", "OnAddMutable").Arg(getters.for_last),
});
}
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google

@ -0,0 +1,58 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2022 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_TRACKER_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_TRACKER_H__
#include <vector>
#include "google/protobuf/descriptor.h"
#include "google/protobuf/compiler/cpp/options.h"
#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
// Generates printer substitutions for message-level tracker callbacks.
std::vector<google::protobuf::io::Printer::Sub> MakeTrackerCalls(
const google::protobuf::Descriptor* message, const Options& opts);
// Generates printer substitutions for field-specific tracker callbacks.
std::vector<google::protobuf::io::Printer::Sub> MakeTrackerCalls(
const google::protobuf::FieldDescriptor* field, const Options& opts);
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_CPP_TRACKER_H__

@ -371,7 +371,6 @@ void Version::Clear() {
}
const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -447,7 +446,6 @@ failure:
::uint8_t* Version::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -490,7 +488,6 @@ failure:
}
::size_t Version::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version)
::size_t total_size = 0;
@ -536,7 +533,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Version::GetClassData() const
void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<Version*>(&to_msg);
auto& from = static_cast<const Version&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -591,7 +587,6 @@ void Version::InternalSwap(Version* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]);
@ -710,7 +705,6 @@ void CodeGeneratorRequest::Clear() {
}
const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -797,7 +791,6 @@ failure:
::uint8_t* CodeGeneratorRequest::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -847,7 +840,6 @@ failure:
}
::size_t CodeGeneratorRequest::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest)
::size_t total_size = 0;
@ -900,7 +892,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorRequest::GetClass
void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<CodeGeneratorRequest*>(&to_msg);
auto& from = static_cast<const CodeGeneratorRequest&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -950,7 +941,6 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]);
@ -1104,7 +1094,6 @@ void CodeGeneratorResponse_File::Clear() {
}
const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -1185,7 +1174,6 @@ failure:
::uint8_t* CodeGeneratorResponse_File::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -1237,7 +1225,6 @@ failure:
}
::size_t CodeGeneratorResponse_File::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File)
::size_t total_size = 0;
@ -1289,7 +1276,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorResponse_File::Ge
void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<CodeGeneratorResponse_File*>(&to_msg);
auto& from = static_cast<const CodeGeneratorResponse_File&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -1347,7 +1333,6 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]);
@ -1446,7 +1431,6 @@ void CodeGeneratorResponse::Clear() {
}
const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -1516,7 +1500,6 @@ failure:
::uint8_t* CodeGeneratorResponse::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -1555,7 +1538,6 @@ failure:
}
::size_t CodeGeneratorResponse::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse)
::size_t total_size = 0;
@ -1598,7 +1580,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*CodeGeneratorResponse::GetClas
void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<CodeGeneratorResponse*>(&to_msg);
auto& from = static_cast<const CodeGeneratorResponse&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -1644,7 +1625,6 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]);

@ -1546,7 +1546,6 @@ void FileDescriptorSet::Clear() {
}
const char* FileDescriptorSet::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::uint32_t tag;
@ -1591,7 +1590,6 @@ failure:
::uint8_t* FileDescriptorSet::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -1613,7 +1611,6 @@ failure:
}
::size_t FileDescriptorSet::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet)
::size_t total_size = 0;
@ -1641,7 +1638,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FileDescriptorSet::GetClassDat
void FileDescriptorSet::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<FileDescriptorSet*>(&to_msg);
auto& from = static_cast<const FileDescriptorSet&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -1671,7 +1667,6 @@ void FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorSet::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]);
@ -1888,7 +1883,6 @@ void FileDescriptorProto::Clear() {
}
const char* FileDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -2099,7 +2093,6 @@ failure:
::uint8_t* FileDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -2222,7 +2215,6 @@ failure:
}
::size_t FileDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto)
::size_t total_size = 0;
@ -2342,7 +2334,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FileDescriptorProto::GetClassD
void FileDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<FileDescriptorProto*>(&to_msg);
auto& from = static_cast<const FileDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -2441,7 +2432,6 @@ void FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FileDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]);
@ -2544,7 +2534,6 @@ void DescriptorProto_ExtensionRange::Clear() {
}
const char* DescriptorProto_ExtensionRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -2606,7 +2595,6 @@ failure:
::uint8_t* DescriptorProto_ExtensionRange::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -2640,7 +2628,6 @@ failure:
}
::size_t DescriptorProto_ExtensionRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange)
::size_t total_size = 0;
@ -2681,7 +2668,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DescriptorProto_ExtensionRange
void DescriptorProto_ExtensionRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<DescriptorProto_ExtensionRange*>(&to_msg);
auto& from = static_cast<const DescriptorProto_ExtensionRange&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -2731,7 +2717,6 @@ void DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange
}
::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]);
@ -2807,7 +2792,6 @@ void DescriptorProto_ReservedRange::Clear() {
}
const char* DescriptorProto_ReservedRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -2860,7 +2844,6 @@ failure:
::uint8_t* DescriptorProto_ReservedRange::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -2887,7 +2870,6 @@ failure:
}
::size_t DescriptorProto_ReservedRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange)
::size_t total_size = 0;
@ -2921,7 +2903,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DescriptorProto_ReservedRange:
void DescriptorProto_ReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<DescriptorProto_ReservedRange*>(&to_msg);
auto& from = static_cast<const DescriptorProto_ReservedRange&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -2964,7 +2945,6 @@ void DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange*
}
::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto_ReservedRange::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]);
@ -3104,7 +3084,6 @@ void DescriptorProto::Clear() {
}
const char* DescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -3275,7 +3254,6 @@ failure:
::uint8_t* DescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -3373,7 +3351,6 @@ failure:
}
::size_t DescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto)
::size_t total_size = 0;
@ -3468,7 +3445,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DescriptorProto::GetClassData(
void DescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<DescriptorProto*>(&to_msg);
auto& from = static_cast<const DescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -3543,7 +3519,6 @@ void DescriptorProto::InternalSwap(DescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata DescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]);
@ -3612,7 +3587,6 @@ void ExtensionRangeOptions::Clear() {
}
const char* ExtensionRangeOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::uint32_t tag;
@ -3662,7 +3636,6 @@ failure:
::uint8_t* ExtensionRangeOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ExtensionRangeOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -3688,7 +3661,6 @@ failure:
}
::size_t ExtensionRangeOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ExtensionRangeOptions)
::size_t total_size = 0;
@ -3718,7 +3690,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ExtensionRangeOptions::GetClas
void ExtensionRangeOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<ExtensionRangeOptions*>(&to_msg);
auto& from = static_cast<const ExtensionRangeOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ExtensionRangeOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -3754,7 +3725,6 @@ void ExtensionRangeOptions::InternalSwap(ExtensionRangeOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ExtensionRangeOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]);
@ -3984,7 +3954,6 @@ void FieldDescriptorProto::Clear() {
}
const char* FieldDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -4149,7 +4118,6 @@ failure:
::uint8_t* FieldDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -4253,7 +4221,6 @@ failure:
}
::size_t FieldDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto)
::size_t total_size = 0;
@ -4348,7 +4315,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FieldDescriptorProto::GetClass
void FieldDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<FieldDescriptorProto*>(&to_msg);
auto& from = static_cast<const FieldDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -4447,7 +4413,6 @@ void FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FieldDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]);
@ -4555,7 +4520,6 @@ void OneofDescriptorProto::Clear() {
}
const char* OneofDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -4610,7 +4574,6 @@ failure:
::uint8_t* OneofDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -4642,7 +4605,6 @@ failure:
}
::size_t OneofDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto)
::size_t total_size = 0;
@ -4680,7 +4642,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*OneofDescriptorProto::GetClass
void OneofDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<OneofDescriptorProto*>(&to_msg);
auto& from = static_cast<const OneofDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -4727,7 +4688,6 @@ void OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata OneofDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]);
@ -4803,7 +4763,6 @@ void EnumDescriptorProto_EnumReservedRange::Clear() {
}
const char* EnumDescriptorProto_EnumReservedRange::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -4856,7 +4815,6 @@ failure:
::uint8_t* EnumDescriptorProto_EnumReservedRange::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -4883,7 +4841,6 @@ failure:
}
::size_t EnumDescriptorProto_EnumReservedRange::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
::size_t total_size = 0;
@ -4917,7 +4874,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumDescriptorProto_EnumReserv
void EnumDescriptorProto_EnumReservedRange::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<EnumDescriptorProto_EnumReservedRange*>(&to_msg);
auto& from = static_cast<const EnumDescriptorProto_EnumReservedRange&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto.EnumReservedRange)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -4960,7 +4916,6 @@ void EnumDescriptorProto_EnumReservedRange::InternalSwap(EnumDescriptorProto_Enu
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto_EnumReservedRange::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]);
@ -5080,7 +5035,6 @@ void EnumDescriptorProto::Clear() {
}
const char* EnumDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -5181,7 +5135,6 @@ failure:
::uint8_t* EnumDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -5239,7 +5192,6 @@ failure:
}
::size_t EnumDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto)
::size_t total_size = 0;
@ -5299,7 +5251,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumDescriptorProto::GetClassD
void EnumDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<EnumDescriptorProto*>(&to_msg);
auto& from = static_cast<const EnumDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -5354,7 +5305,6 @@ void EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]);
@ -5469,7 +5419,6 @@ void EnumValueDescriptorProto::Clear() {
}
const char* EnumValueDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -5534,7 +5483,6 @@ failure:
::uint8_t* EnumValueDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -5572,7 +5520,6 @@ failure:
}
::size_t EnumValueDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto)
::size_t total_size = 0;
@ -5615,7 +5562,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumValueDescriptorProto::GetC
void EnumValueDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<EnumValueDescriptorProto*>(&to_msg);
auto& from = static_cast<const EnumValueDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -5671,7 +5617,6 @@ void EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumValueDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]);
@ -5783,7 +5728,6 @@ void ServiceDescriptorProto::Clear() {
}
const char* ServiceDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -5852,7 +5796,6 @@ failure:
::uint8_t* ServiceDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -5892,7 +5835,6 @@ failure:
}
::size_t ServiceDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto)
::size_t total_size = 0;
@ -5937,7 +5879,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ServiceDescriptorProto::GetCla
void ServiceDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<ServiceDescriptorProto*>(&to_msg);
auto& from = static_cast<const ServiceDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -5988,7 +5929,6 @@ void ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ServiceDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]);
@ -6154,7 +6094,6 @@ void MethodDescriptorProto::Clear() {
}
const char* MethodDescriptorProto::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -6255,7 +6194,6 @@ failure:
::uint8_t* MethodDescriptorProto::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -6319,7 +6257,6 @@ failure:
}
::size_t MethodDescriptorProto::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto)
::size_t total_size = 0;
@ -6381,7 +6318,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MethodDescriptorProto::GetClas
void MethodDescriptorProto::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<MethodDescriptorProto*>(&to_msg);
auto& from = static_cast<const MethodDescriptorProto&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -6454,7 +6390,6 @@ void MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata MethodDescriptorProto::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]);
@ -6809,7 +6744,6 @@ void FileOptions::Clear() {
}
const char* FileOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -7095,7 +7029,6 @@ failure:
::uint8_t* FileOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -7283,7 +7216,6 @@ failure:
}
::size_t FileOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions)
::size_t total_size = 0;
@ -7441,7 +7373,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FileOptions::GetClassData() co
void FileOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<FileOptions*>(&to_msg);
auto& from = static_cast<const FileOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -7595,7 +7526,6 @@ void FileOptions::InternalSwap(FileOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FileOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]);
@ -7704,7 +7634,6 @@ void MessageOptions::Clear() {
}
const char* MessageOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -7806,7 +7735,6 @@ failure:
::uint8_t* MessageOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -7863,7 +7791,6 @@ failure:
}
::size_t MessageOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions)
::size_t total_size = 0;
@ -7921,7 +7848,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MessageOptions::GetClassData()
void MessageOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<MessageOptions*>(&to_msg);
auto& from = static_cast<const MessageOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -7983,7 +7909,6 @@ void MessageOptions::InternalSwap(MessageOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata MessageOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]);
@ -8107,7 +8032,6 @@ void FieldOptions::Clear() {
}
const char* FieldOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -8247,7 +8171,6 @@ failure:
::uint8_t* FieldOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -8324,7 +8247,6 @@ failure:
}
::size_t FieldOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions)
::size_t total_size = 0;
@ -8399,7 +8321,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*FieldOptions::GetClassData() c
void FieldOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<FieldOptions*>(&to_msg);
auto& from = static_cast<const FieldOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -8470,7 +8391,6 @@ void FieldOptions::InternalSwap(FieldOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata FieldOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]);
@ -8539,7 +8459,6 @@ void OneofOptions::Clear() {
}
const char* OneofOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::uint32_t tag;
@ -8589,7 +8508,6 @@ failure:
::uint8_t* OneofOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -8615,7 +8533,6 @@ failure:
}
::size_t OneofOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions)
::size_t total_size = 0;
@ -8645,7 +8562,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*OneofOptions::GetClassData() c
void OneofOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<OneofOptions*>(&to_msg);
auto& from = static_cast<const OneofOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -8681,7 +8597,6 @@ void OneofOptions::InternalSwap(OneofOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata OneofOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]);
@ -8777,7 +8692,6 @@ void EnumOptions::Clear() {
}
const char* EnumOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -8859,7 +8773,6 @@ failure:
::uint8_t* EnumOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -8904,7 +8817,6 @@ failure:
}
::size_t EnumOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions)
::size_t total_size = 0;
@ -8952,7 +8864,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumOptions::GetClassData() co
void EnumOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<EnumOptions*>(&to_msg);
auto& from = static_cast<const EnumOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -9008,7 +8919,6 @@ void EnumOptions::InternalSwap(EnumOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]);
@ -9090,7 +9000,6 @@ void EnumValueOptions::Clear() {
}
const char* EnumValueOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -9152,7 +9061,6 @@ failure:
::uint8_t* EnumValueOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -9185,7 +9093,6 @@ failure:
}
::size_t EnumValueOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions)
::size_t total_size = 0;
@ -9221,7 +9128,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*EnumValueOptions::GetClassData
void EnumValueOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<EnumValueOptions*>(&to_msg);
auto& from = static_cast<const EnumValueOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -9262,7 +9168,6 @@ void EnumValueOptions::InternalSwap(EnumValueOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata EnumValueOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]);
@ -9344,7 +9249,6 @@ void ServiceOptions::Clear() {
}
const char* ServiceOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -9406,7 +9310,6 @@ failure:
::uint8_t* ServiceOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -9439,7 +9342,6 @@ failure:
}
::size_t ServiceOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions)
::size_t total_size = 0;
@ -9475,7 +9377,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*ServiceOptions::GetClassData()
void ServiceOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<ServiceOptions*>(&to_msg);
auto& from = static_cast<const ServiceOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -9516,7 +9417,6 @@ void ServiceOptions::InternalSwap(ServiceOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata ServiceOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]);
@ -9610,7 +9510,6 @@ void MethodOptions::Clear() {
}
const char* MethodOptions::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -9686,7 +9585,6 @@ failure:
::uint8_t* MethodOptions::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -9726,7 +9624,6 @@ failure:
}
::size_t MethodOptions::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions)
::size_t total_size = 0;
@ -9770,7 +9667,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*MethodOptions::GetClassData()
void MethodOptions::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<MethodOptions*>(&to_msg);
auto& from = static_cast<const MethodOptions&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -9823,7 +9719,6 @@ void MethodOptions::InternalSwap(MethodOptions* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata MethodOptions::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]);
@ -9921,7 +9816,6 @@ void UninterpretedOption_NamePart::Clear() {
}
const char* UninterpretedOption_NamePart::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -9977,7 +9871,6 @@ failure:
::uint8_t* UninterpretedOption_NamePart::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -10026,7 +9919,6 @@ failure:
return total_size;
}
::size_t UninterpretedOption_NamePart::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart)
::size_t total_size = 0;
@ -10059,7 +9951,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UninterpretedOption_NamePart::
void UninterpretedOption_NamePart::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<UninterpretedOption_NamePart*>(&to_msg);
auto& from = static_cast<const UninterpretedOption_NamePart&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -10104,7 +9995,6 @@ void UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* ot
}
::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption_NamePart::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]);
@ -10263,7 +10153,6 @@ void UninterpretedOption::Clear() {
}
const char* UninterpretedOption::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -10376,7 +10265,6 @@ failure:
::uint8_t* UninterpretedOption::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -10443,7 +10331,6 @@ failure:
}
::size_t UninterpretedOption::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption)
::size_t total_size = 0;
@ -10510,7 +10397,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*UninterpretedOption::GetClassD
void UninterpretedOption::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<UninterpretedOption*>(&to_msg);
auto& from = static_cast<const UninterpretedOption&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -10583,7 +10469,6 @@ void UninterpretedOption::InternalSwap(UninterpretedOption* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata UninterpretedOption::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]);
@ -10710,7 +10595,6 @@ void SourceCodeInfo_Location::Clear() {
}
const char* SourceCodeInfo_Location::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -10811,7 +10695,6 @@ failure:
::uint8_t* SourceCodeInfo_Location::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -10874,7 +10757,6 @@ failure:
}
::size_t SourceCodeInfo_Location::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location)
::size_t total_size = 0;
@ -10946,7 +10828,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeInfo_Location::GetCl
void SourceCodeInfo_Location::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<SourceCodeInfo_Location*>(&to_msg);
auto& from = static_cast<const SourceCodeInfo_Location&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -10998,7 +10879,6 @@ void SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo_Location::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]);
@ -11062,7 +10942,6 @@ void SourceCodeInfo::Clear() {
}
const char* SourceCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::uint32_t tag;
@ -11107,7 +10986,6 @@ failure:
::uint8_t* SourceCodeInfo::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -11129,7 +11007,6 @@ failure:
}
::size_t SourceCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo)
::size_t total_size = 0;
@ -11157,7 +11034,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeInfo::GetClassData()
void SourceCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<SourceCodeInfo*>(&to_msg);
auto& from = static_cast<const SourceCodeInfo&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -11185,7 +11061,6 @@ void SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeInfo::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]);
@ -11302,7 +11177,6 @@ void GeneratedCodeInfo_Annotation::Clear() {
}
const char* GeneratedCodeInfo_Annotation::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
@ -11394,7 +11268,6 @@ failure:
::uint8_t* GeneratedCodeInfo_Annotation::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -11447,7 +11320,6 @@ failure:
}
::size_t GeneratedCodeInfo_Annotation::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation)
::size_t total_size = 0;
@ -11507,7 +11379,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GeneratedCodeInfo_Annotation::
void GeneratedCodeInfo_Annotation::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<GeneratedCodeInfo_Annotation*>(&to_msg);
auto& from = static_cast<const GeneratedCodeInfo_Annotation&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -11564,7 +11435,6 @@ void GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* ot
}
::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]);
@ -11628,7 +11498,6 @@ void GeneratedCodeInfo::Clear() {
}
const char* GeneratedCodeInfo::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
::uint32_t tag;
@ -11673,7 +11542,6 @@ failure:
::uint8_t* GeneratedCodeInfo::_InternalSerialize(
::uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo)
::uint32_t cached_has_bits = 0;
(void) cached_has_bits;
@ -11695,7 +11563,6 @@ failure:
}
::size_t GeneratedCodeInfo::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo)
::size_t total_size = 0;
@ -11723,7 +11590,6 @@ const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GeneratedCodeInfo::GetClassDat
void GeneratedCodeInfo::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
auto* const _this = static_cast<GeneratedCodeInfo*>(&to_msg);
auto& from = static_cast<const GeneratedCodeInfo&>(from_msg);
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo)
GOOGLE_ABSL_DCHECK_NE(&from, _this);
::uint32_t cached_has_bits = 0;
@ -11751,7 +11617,6 @@ void GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {
}
::PROTOBUF_NAMESPACE_ID::Metadata GeneratedCodeInfo::GetMetadata() const {
return ::_pbi::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once,
file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]);

File diff suppressed because it is too large Load Diff

@ -325,7 +325,7 @@ void Printer::Outdent() {
indent_ -= options_.spaces_per_indent;
}
void Printer::Emit(std::initializer_list<Sub> vars, absl::string_view format,
void Printer::Emit(absl::Span<const Sub> vars, absl::string_view format,
SourceLocation loc) {
PrintOptions opts;
opts.strip_raw_string_indentation = true;

@ -499,13 +499,17 @@ class PROTOBUF_EXPORT Printer {
//
// Returns an RAII object that pops the lookup frame.
template <typename Map = absl::flat_hash_map<std::string, std::string>,
typename = std::enable_if_t<!std::is_pointer<Map>::value>>
typename = std::enable_if_t<!std::is_pointer<Map>::value>,
// Prefer the more specific span impl if this could be turned into
// a span.
typename = std::enable_if_t<
!std::is_convertible<Map, absl::Span<const Sub>>::value>>
auto WithVars(Map&& vars);
// Pushes a new variable lookup frame that stores `vars` by value.
//
// Returns an RAII object that pops the lookup frame.
auto WithVars(std::initializer_list<Sub> vars);
auto WithVars(absl::Span<const Sub> vars);
// Looks up a variable set with WithVars().
//
@ -551,7 +555,7 @@ class PROTOBUF_EXPORT Printer {
// documentation for more details.
//
// `format` MUST be a string constant.
void Emit(std::initializer_list<Sub> vars, absl::string_view format,
void Emit(absl::Span<const Sub> vars, absl::string_view format,
SourceLocation loc = SourceLocation::current());
// Write a string directly to the underlying output, performing no formatting
@ -694,7 +698,7 @@ class PROTOBUF_EXPORT Printer {
void PrintCodegenTrace(absl::optional<SourceLocation> loc);
// The core implementation for "fully-elaborated" variable definitions.
auto WithDefs(std::initializer_list<Sub> vars, bool allow_callbacks);
auto WithDefs(absl::Span<const Sub> vars, bool allow_callbacks);
// Returns the start and end of the value that was substituted in place of
// the variable `varname` in the last call to PrintImpl() (with
@ -915,6 +919,15 @@ class Printer::Sub {
return std::move(*this);
}
absl::string_view key() const { return key_; }
absl::string_view value() const {
const auto* str = value_.AsString();
GOOGLE_ABSL_CHECK(str != nullptr)
<< "could not find " << key() << "; found callback instead";
return *str;
}
private:
friend class Printer;
@ -936,7 +949,7 @@ auto Printer::WithVars(const Map* vars) {
return absl::MakeCleanup([this] { var_lookups_.pop_back(); });
}
template <typename Map, typename /*Sfinae*/>
template <typename Map, typename, typename /*Sfinae*/>
auto Printer::WithVars(Map&& vars) {
var_lookups_.emplace_back(
[vars = std::forward<Map>(vars)](
@ -977,12 +990,6 @@ auto Printer::WithAnnotations(Map&& vars) {
return absl::MakeCleanup([this] { annotation_lookups_.pop_back(); });
}
// In GCC older than GCC 9, this code (which constructs an empty
// std::initializer_list<Sub>) incorrectly fails to compile if it does not
// follow the definition of the type Sub; this is the only reason it is
// out-of-line.
//
// See https://godbolt.org/z/e4KnM3PE7.
inline void Printer::Emit(absl::string_view format, SourceLocation loc) {
Emit({}, format, loc);
}
@ -1037,7 +1044,7 @@ void Printer::FormatInternal(absl::Span<const std::string> args,
PrintImpl(format, args, opts);
}
inline auto Printer::WithDefs(std::initializer_list<Sub> vars,
inline auto Printer::WithDefs(absl::Span<const Sub> vars,
bool allow_callbacks) {
absl::flat_hash_map<std::string, Value> var_map;
var_map.reserve(vars.size());
@ -1086,7 +1093,7 @@ inline auto Printer::WithDefs(std::initializer_list<Sub> vars,
});
}
inline auto Printer::WithVars(std::initializer_list<Sub> vars) {
inline auto Printer::WithVars(absl::Span<const Sub> vars) {
return WithDefs(vars, /*allow_callbacks=*/false);
}
} // namespace io

Loading…
Cancel
Save