summaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf/compiler/cpp
diff options
context:
space:
mode:
authorRuslan Kovalev <[email protected]>2022-02-10 16:46:44 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:46:44 +0300
commit59e19371de37995fcb36beb16cd6ec030af960bc (patch)
treefa68e36093ebff8b805462e9e6d331fe9d348214 /contrib/libs/protoc/src/google/protobuf/compiler/cpp
parent89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff)
Restoring authorship annotation for Ruslan Kovalev <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/cpp')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc284
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h170
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc332
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h210
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc226
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h148
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc226
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h310
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc532
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h210
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc258
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h130
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc712
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h338
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc276
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h114
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc1432
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h240
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc440
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h210
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h100
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc334
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h208
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc270
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h210
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc380
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h214
27 files changed, 4257 insertions, 4257 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
index e0c80fc1c62..b0160ef1495 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc
@@ -1,66 +1,66 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_enum.h>
#include <cstdint>
#include <limits>
-#include <map>
-
+#include <map>
+
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_names.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-// The GOOGLE_ARRAYSIZE constant is the max enum value plus 1. If the max enum value
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+namespace {
+// The GOOGLE_ARRAYSIZE constant is the max enum value plus 1. If the max enum value
// is kint32max, GOOGLE_ARRAYSIZE will overflow. In such cases we should omit the
-// generation of the GOOGLE_ARRAYSIZE constant.
-bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {
+// generation of the GOOGLE_ARRAYSIZE constant.
+bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {
int32_t max_value = descriptor->value(0)->number();
- for (int i = 0; i < descriptor->value_count(); i++) {
- if (descriptor->value(i)->number() > max_value) {
- max_value = descriptor->value(i)->number();
- }
- }
+ for (int i = 0; i < descriptor->value_count(); i++) {
+ if (descriptor->value(i)->number() > max_value) {
+ max_value = descriptor->value(i)->number();
+ }
+ }
return max_value != std::numeric_limits<int32_t>::max();
-}
+}
// Returns the number of unique numeric enum values. This is less than
// descriptor->value_count() when there are aliased values.
@@ -72,11 +72,11 @@ int CountUniqueValues(const EnumDescriptor* descriptor) {
return values.size();
}
-} // namespace
-
-EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
+} // namespace
+
+EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& vars,
- const Options& options)
+ const Options& options)
: descriptor_(descriptor),
classname_(ClassName(descriptor, false)),
options_(options),
@@ -89,54 +89,54 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
variables_["resolved_name"] = ResolveKeyword(descriptor_->name());
variables_["prefix"] =
(descriptor_->containing_type() == NULL) ? "" : classname_ + "_";
-}
-
-EnumGenerator::~EnumGenerator() {}
-
-void EnumGenerator::GenerateDefinition(io::Printer* printer) {
+}
+
+EnumGenerator::~EnumGenerator() {}
+
+void EnumGenerator::GenerateDefinition(io::Printer* printer) {
Formatter format(printer, variables_);
format("enum ${1$$classname$$}$ {\n", descriptor_);
format.Indent();
-
- const EnumValueDescriptor* min_value = descriptor_->value(0);
- const EnumValueDescriptor* max_value = descriptor_->value(0);
-
- for (int i = 0; i < descriptor_->value_count(); i++) {
+
+ const EnumValueDescriptor* min_value = descriptor_->value(0);
+ const EnumValueDescriptor* max_value = descriptor_->value(0);
+
+ for (int i = 0; i < descriptor_->value_count(); i++) {
auto format_value = format;
format_value.Set("name", EnumValueName(descriptor_->value(i)));
- // In C++, an value of -2147483648 gets interpreted as the negative of
- // 2147483648, and since 2147483648 can't fit in an integer, this produces a
- // compiler warning. This works around that issue.
+ // In C++, an value of -2147483648 gets interpreted as the negative of
+ // 2147483648, and since 2147483648 can't fit in an integer, this produces a
+ // compiler warning. This works around that issue.
format_value.Set("number", Int32ToString(descriptor_->value(i)->number()));
format_value.Set("deprecation",
DeprecatedAttribute(options_, descriptor_->value(i)));
-
+
if (i > 0) format_value(",\n");
format_value("${1$$prefix$$name$$}$ $deprecation$= $number$",
descriptor_->value(i));
-
- if (descriptor_->value(i)->number() < min_value->number()) {
- min_value = descriptor_->value(i);
- }
- if (descriptor_->value(i)->number() > max_value->number()) {
- max_value = descriptor_->value(i);
- }
- }
-
+
+ if (descriptor_->value(i)->number() < min_value->number()) {
+ min_value = descriptor_->value(i);
+ }
+ if (descriptor_->value(i)->number() > max_value->number()) {
+ max_value = descriptor_->value(i);
+ }
+ }
+
if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
- // For new enum semantics: generate min and max sentinel values equal to
- // INT32_MIN and INT32_MAX
+ // For new enum semantics: generate min and max sentinel values equal to
+ // INT32_MIN and INT32_MAX
if (descriptor_->value_count() > 0) format(",\n");
format(
"$classname$_$prefix$INT_MIN_SENTINEL_DO_NOT_USE_ = "
"std::numeric_limits<$int32$>::min(),\n"
"$classname$_$prefix$INT_MAX_SENTINEL_DO_NOT_USE_ = "
"std::numeric_limits<$int32$>::max()");
- }
-
+ }
+
format.Outdent();
format("\n};\n");
-
+
format(
"$dllexport_decl $bool $classname$_IsValid(int value);\n"
"constexpr $classname$ ${1$$prefix$$short_name$_MIN$}$ = "
@@ -144,25 +144,25 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
"constexpr $classname$ ${1$$prefix$$short_name$_MAX$}$ = "
"$prefix$$3$;\n",
descriptor_, EnumValueName(min_value), EnumValueName(max_value));
-
+
if (generate_array_size_) {
format(
"constexpr int ${1$$prefix$$short_name$_ARRAYSIZE$}$ = "
"$prefix$$short_name$_MAX + 1;\n\n",
descriptor_);
- }
-
+ }
+
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"$dllexport_decl $const ::$proto_ns$::EnumDescriptor* "
"$classname$_descriptor();\n");
}
-
+
// The _Name and _Parse functions. The lite implementation is table-based, so
// we make sure to keep the tables hidden in the .cc file.
if (!HasDescriptorMethods(descriptor_->file(), options_)) {
format("const TProtoStringType& $classname$_Name($classname$ value);\n");
- }
+ }
// The _Name() function accepts the enum type itself but also any integral
// type.
format(
@@ -180,8 +180,8 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
" return $classname$_Name(static_cast<$classname$>(enum_t_value));\n");
}
format("}\n");
-
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"inline bool $classname$_Parse(\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, $classname$* "
@@ -189,35 +189,35 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
"{\n"
" return ::$proto_ns$::internal::ParseNamedEnum<$classname$>(\n"
" $classname$_descriptor(), name, value);\n"
- "}\n");
+ "}\n");
} else {
format(
"bool $classname$_Parse(\n"
" ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, $classname$* "
"value);\n");
- }
-}
-
+ }
+}
+
void EnumGenerator::GenerateGetEnumDescriptorSpecializations(
io::Printer* printer) {
Formatter format(printer, variables_);
format(
"template <> struct is_proto_enum< $classtype$> : ::std::true_type "
"{};\n");
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"template <>\n"
"inline const EnumDescriptor* GetEnumDescriptor< $classtype$>() {\n"
" return $classtype$_descriptor();\n"
"}\n");
- }
-}
-
+ }
+}
+
void EnumGenerator::GenerateSymbolImports(io::Printer* printer) const {
Formatter format(printer, variables_);
format("typedef $classname$ $resolved_name$;\n");
-
- for (int j = 0; j < descriptor_->value_count(); j++) {
+
+ for (int j = 0; j < descriptor_->value_count(); j++) {
TProtoStringType deprecated_attr =
DeprecatedAttribute(options_, descriptor_->value(j));
format(
@@ -225,8 +225,8 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) const {
" $classname$_$3$;\n",
deprecated_attr, descriptor_->value(j),
EnumValueName(descriptor_->value(j)));
- }
-
+ }
+
format(
"static inline bool $nested_name$_IsValid(int value) {\n"
" return $classname$_IsValid(value);\n"
@@ -236,14 +236,14 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) const {
"static constexpr $resolved_name$ ${1$$nested_name$_MAX$}$ =\n"
" $classname$_$nested_name$_MAX;\n",
descriptor_);
- if (generate_array_size_) {
+ if (generate_array_size_) {
format(
"static constexpr int ${1$$nested_name$_ARRAYSIZE$}$ =\n"
" $classname$_$nested_name$_ARRAYSIZE;\n",
descriptor_);
- }
-
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ }
+
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"static inline const ::$proto_ns$::EnumDescriptor*\n"
"$nested_name$_descriptor() {\n"
@@ -258,45 +258,45 @@ void EnumGenerator::GenerateSymbolImports(io::Printer* printer) const {
" ::std::is_integral<T>::value,\n"
" \"Incorrect type passed to function $nested_name$_Name.\");\n"
" return $classname$_Name(enum_t_value);\n"
- "}\n");
+ "}\n");
format(
"static inline bool "
"$nested_name$_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,\n"
" $resolved_name$* value) {\n"
- " return $classname$_Parse(name, value);\n"
- "}\n");
-}
-
+ " return $classname$_Parse(name, value);\n"
+ "}\n");
+}
+
void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
Formatter format(printer, variables_);
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"const ::$proto_ns$::EnumDescriptor* $classname$_descriptor() {\n"
" ::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n"
" return $file_level_enum_descriptors$[$1$];\n"
"}\n",
idx);
- }
-
+ }
+
format(
"bool $classname$_IsValid(int value) {\n"
" switch (value) {\n");
-
- // Multiple values may have the same number. Make sure we only cover
- // each number once by first constructing a set containing all valid
- // numbers, then printing a case statement for each element.
-
+
+ // Multiple values may have the same number. Make sure we only cover
+ // each number once by first constructing a set containing all valid
+ // numbers, then printing a case statement for each element.
+
std::set<int> numbers;
- for (int j = 0; j < descriptor_->value_count(); j++) {
- const EnumValueDescriptor* value = descriptor_->value(j);
- numbers.insert(value->number());
- }
-
+ for (int j = 0; j < descriptor_->value_count(); j++) {
+ const EnumValueDescriptor* value = descriptor_->value(j);
+ numbers.insert(value->number());
+ }
+
for (std::set<int>::iterator iter = numbers.begin(); iter != numbers.end();
++iter) {
format(" case $1$:\n", Int32ToString(*iter));
- }
-
+ }
+
format(
" return true;\n"
" default:\n"
@@ -304,7 +304,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
" }\n"
"}\n"
"\n");
-
+
if (!HasDescriptorMethods(descriptor_->file(), options_)) {
// In lite mode (where descriptors are unavailable), we generate separate
// tables for mapping between enum names and numbers. The _entries table
@@ -405,7 +405,7 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
descriptor_->value_count());
}
- if (descriptor_->containing_type() != NULL) {
+ if (descriptor_->containing_type() != NULL) {
TProtoStringType parent = ClassName(descriptor_->containing_type(), false);
// Before C++17, we must define the static constants which were
// declared in the header, to give the linker a place to put them.
@@ -413,26 +413,26 @@ void EnumGenerator::GenerateMethods(int idx, io::Printer* printer) {
format(
"#if (__cplusplus < 201703) && "
"(!defined(_MSC_VER) || _MSC_VER >= 1900)\n");
-
- for (int i = 0; i < descriptor_->value_count(); i++) {
+
+ for (int i = 0; i < descriptor_->value_count(); i++) {
format("constexpr $classname$ $1$::$2$;\n", parent,
EnumValueName(descriptor_->value(i)));
- }
+ }
format(
"constexpr $classname$ $1$::$nested_name$_MIN;\n"
"constexpr $classname$ $1$::$nested_name$_MAX;\n",
parent);
- if (generate_array_size_) {
+ if (generate_array_size_) {
format("constexpr int $1$::$nested_name$_ARRAYSIZE;\n", parent);
- }
-
+ }
+
format(
"#endif // (__cplusplus < 201703) && "
"(!defined(_MSC_VER) || _MSC_VER >= 1900)\n");
- }
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ }
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
index 43f1e5f4a5c..0a12e18fedf 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h
@@ -1,105 +1,105 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
-
-#include <map>
-#include <set>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
+
+#include <map>
+#include <set>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class EnumGenerator {
- public:
- // See generator.cc for the meaning of dllexport_decl.
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class EnumGenerator {
+ public:
+ // See generator.cc for the meaning of dllexport_decl.
EnumGenerator(const EnumDescriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& vars,
const Options& options);
- ~EnumGenerator();
-
- // Generate header code defining the enum. This code should be placed
- // within the enum's package namespace, but NOT within any class, even for
- // nested enums.
- void GenerateDefinition(io::Printer* printer);
-
- // Generate specialization of GetEnumDescriptor<MyEnum>().
- // Precondition: in ::google::protobuf namespace.
- void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);
-
- // For enums nested within a message, generate code to import all the enum's
- // symbols (e.g. the enum type name, all its values, etc.) into the class's
- // namespace. This should be placed inside the class definition in the
- // header.
+ ~EnumGenerator();
+
+ // Generate header code defining the enum. This code should be placed
+ // within the enum's package namespace, but NOT within any class, even for
+ // nested enums.
+ void GenerateDefinition(io::Printer* printer);
+
+ // Generate specialization of GetEnumDescriptor<MyEnum>().
+ // Precondition: in ::google::protobuf namespace.
+ void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);
+
+ // For enums nested within a message, generate code to import all the enum's
+ // symbols (e.g. the enum type name, all its values, etc.) into the class's
+ // namespace. This should be placed inside the class definition in the
+ // header.
void GenerateSymbolImports(io::Printer* printer) const;
-
- // Source file stuff.
-
- // Generate non-inline methods related to the enum, such as IsValidValue().
+
+ // Source file stuff.
+
+ // Generate non-inline methods related to the enum, such as IsValidValue().
// Goes in the .cc file. EnumDescriptors are stored in an array, idx is
// the index in this array that corresponds with this enum.
void GenerateMethods(int idx, io::Printer* printer);
-
- private:
- const EnumDescriptor* descriptor_;
+
+ private:
+ const EnumDescriptor* descriptor_;
const TProtoStringType classname_;
- const Options& options_;
- // whether to generate the *_ARRAYSIZE constant.
- const bool generate_array_size_;
-
+ const Options& options_;
+ // whether to generate the *_ARRAYSIZE constant.
+ const bool generate_array_size_;
+
std::map<TProtoStringType, TProtoStringType> variables_;
friend class FileGenerator;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index ce2a0e45911..f3148613428 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -1,77 +1,77 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_enum_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-
-void SetEnumVariables(const FieldDescriptor* descriptor,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+namespace {
+
+void SetEnumVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
- const EnumValueDescriptor* default_value = descriptor->default_value_enum();
+ const Options& options) {
+ SetCommonFieldVariables(descriptor, variables, options);
+ const EnumValueDescriptor* default_value = descriptor->default_value_enum();
(*variables)["type"] = QualifiedClassName(descriptor->enum_type(), options);
- (*variables)["default"] = Int32ToString(default_value->number());
- (*variables)["full_name"] = descriptor->full_name();
-}
-
-} // namespace
-
-// ===================================================================
-
-EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
+ (*variables)["default"] = Int32ToString(default_value->number());
+ (*variables)["full_name"] = descriptor->full_name();
+}
+
+} // namespace
+
+// ===================================================================
+
+EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options)
: FieldGenerator(descriptor, options) {
- SetEnumVariables(descriptor, &variables_, options);
-}
-
-EnumFieldGenerator::~EnumFieldGenerator() {}
-
+ SetEnumVariables(descriptor, &variables_, options);
+}
+
+EnumFieldGenerator::~EnumFieldGenerator() {}
+
void EnumFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
format("int $name$_;\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -83,8 +83,8 @@ void EnumFieldGenerator::GenerateAccessorDeclarations(
"void ${1$_internal_set_$name$$}$($type$ value);\n"
"public:\n",
descriptor_);
-}
-
+}
+
void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -100,7 +100,7 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void $classname$::_internal_set_$name$($type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
format(" assert($type$_IsValid(value));\n");
- }
+ }
format(
" $set_hasbit$\n"
" $name$_ = value;\n"
@@ -110,28 +110,28 @@ void EnumFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_ = $default$;\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("_internal_set_$name$(from._internal_$name$());\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("swap($name$_, other->$name$_);\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_ = $default$;\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -145,8 +145,8 @@ void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
"target = stream->EnsureSpace(target);\n"
"target = ::$proto_ns$::internal::WireFormatLite::WriteEnumToArray(\n"
" $number$, this->_internal_$name$(), target);\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
@@ -154,24 +154,24 @@ void EnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
" "
"::$proto_ns$::internal::WireFormatLite::EnumSize(this->_internal_$name$("
"));\n");
-}
-
+}
+
void EnumFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_($default$)\n");
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
EnumOneofFieldGenerator::EnumOneofFieldGenerator(
const FieldDescriptor* descriptor, const Options& options)
: EnumFieldGenerator(descriptor, options) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
-}
-
-EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}
-
+ SetCommonOneofFieldVariables(descriptor, &variables_);
+}
+
+EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}
+
void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -190,7 +190,7 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void $classname$::_internal_set_$name$($type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
format(" assert($type$_IsValid(value));\n");
- }
+ }
format(
" if (!_internal_has_$name$()) {\n"
" clear_$oneof_name$();\n"
@@ -203,43 +203,43 @@ void EnumOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
-}
-
+}
+
void EnumOneofFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$field_member$ = $default$;\n");
-}
-
+}
+
void EnumOneofFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
+ // Don't print any swapping code. Swapping the union will swap this field.
+}
+
void EnumOneofFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$ns$::_$classname$_default_instance_.$name$_ = $default$;\n");
-}
-
-// ===================================================================
-
-RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
+}
+
+// ===================================================================
+
+RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
+ const FieldDescriptor* descriptor, const Options& options)
: FieldGenerator(descriptor, options) {
- SetEnumVariables(descriptor, &variables_, options);
-}
-
-RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
-
+ SetEnumVariables(descriptor, &variables_, options);
+}
+
+RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
+
void RepeatedEnumFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("::$proto_ns$::RepeatedField<int> $name$_;\n");
- if (descriptor_->is_packed() &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
+ if (descriptor_->is_packed() &&
+ HasGeneratedMethods(descriptor_->file(), options_)) {
format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
- }
-}
-
+ }
+}
+
void RepeatedEnumFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -258,8 +258,8 @@ void RepeatedEnumFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$::$proto_ns$::RepeatedField<int>* "
"${1$mutable_$name$$}$();\n",
descriptor_);
-}
-
+}
+
void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -275,7 +275,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void $classname$::set_$name$(int index, $type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
format(" assert($type$_IsValid(value));\n");
- }
+ }
format(
" $name$_.Set(index, value);\n"
"$annotate_set$"
@@ -284,7 +284,7 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
"inline void $classname$::_internal_add_$name$($type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_)) {
format(" assert($type$_IsValid(value));\n");
- }
+ }
format(
" $name$_.Add(value);\n"
"}\n"
@@ -309,35 +309,35 @@ void RepeatedEnumFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
" return _internal_mutable_$name$();\n"
"}\n");
-}
-
+}
+
void RepeatedEnumFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.Clear();\n");
-}
-
+}
+
void RepeatedEnumFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n");
-}
-
+}
+
void RepeatedEnumFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
+}
+
void RepeatedEnumFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
+ // Not needed for repeated fields.
+}
+
void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStream(
io::Printer* printer) const {
Formatter format(printer, variables_);
- // Don't use ReadRepeatedPrimitive here so that the enum can be validated.
+ // Don't use ReadRepeatedPrimitive here so that the enum can be validated.
format(
"int value = 0;\n"
"DO_((::$proto_ns$::internal::WireFormatLite::ReadPrimitive<\n"
@@ -345,30 +345,30 @@ void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStream(
" input, &value)));\n");
if (HasPreservingUnknownEnumSemantics(descriptor_)) {
format("add_$name$(static_cast< $type$ >(value));\n");
- } else {
+ } else {
format(
"if ($type$_IsValid(value)) {\n"
" add_$name$(static_cast< $type$ >(value));\n");
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
+ if (UseUnknownFieldSet(descriptor_->file(), options_)) {
format(
"} else {\n"
" mutable_unknown_fields()->AddVarint(\n"
" $number$, static_cast<$uint64$>(value));\n");
- } else {
+ } else {
format(
"} else {\n"
" unknown_fields_stream.WriteVarint32(tag);\n"
" unknown_fields_stream.WriteVarint32(\n"
" static_cast<$uint32$>(value));\n");
- }
+ }
format("}\n");
- }
-}
-
+ }
+}
+
void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStreamWithPacking(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (!descriptor_->is_packed()) {
+ if (!descriptor_->is_packed()) {
// This path is rarely executed, so we use a non-inlined implementation.
if (HasPreservingUnknownEnumSemantics(descriptor_)) {
format(
@@ -379,7 +379,7 @@ void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStreamWithPacking(
" nullptr,\n"
" nullptr,\n"
" this->_internal_mutable_$name$())));\n");
- } else if (UseUnknownFieldSet(descriptor_->file(), options_)) {
+ } else if (UseUnknownFieldSet(descriptor_->file(), options_)) {
format(
"DO_((::$proto_ns$::internal::WireFormat::"
"ReadPackedEnumPreserveUnknowns(\n"
@@ -388,7 +388,7 @@ void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStreamWithPacking(
" $type$_IsValid,\n"
" mutable_unknown_fields(),\n"
" this->_internal_mutable_$name$())));\n");
- } else {
+ } else {
format(
"DO_((::$proto_ns$::internal::"
"WireFormatLite::ReadPackedEnumPreserveUnknowns(\n"
@@ -397,8 +397,8 @@ void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStreamWithPacking(
" $type$_IsValid,\n"
" &unknown_fields_stream,\n"
" this->_internal_mutable_$name$())));\n");
- }
- } else {
+ }
+ } else {
format(
"$uint32$ length;\n"
"DO_(input->ReadVarint32(&length));\n"
@@ -411,34 +411,34 @@ void RepeatedEnumFieldGenerator::GenerateMergeFromCodedStreamWithPacking(
" input, &value)));\n");
if (HasPreservingUnknownEnumSemantics(descriptor_)) {
format(" add_$name$(static_cast< $type$ >(value));\n");
- } else {
+ } else {
format(
" if ($type$_IsValid(value)) {\n"
" _internal_add_$name$(static_cast< $type$ >(value));\n"
" } else {\n");
- if (UseUnknownFieldSet(descriptor_->file(), options_)) {
+ if (UseUnknownFieldSet(descriptor_->file(), options_)) {
format(
" mutable_unknown_fields()->AddVarint(\n"
" $number$, static_cast<$uint64$>(value));\n");
- } else {
+ } else {
format(
" unknown_fields_stream.WriteVarint32(tag);\n"
" unknown_fields_stream.WriteVarint32(\n"
" static_cast<$uint32$>(value));\n");
- }
+ }
format(" }\n");
- }
+ }
format(
"}\n"
"input->PopLimit(limit);\n");
- }
-}
-
+ }
+}
+
void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (descriptor_->is_packed()) {
- // Write the tag and the size.
+ if (descriptor_->is_packed()) {
+ // Write the tag and the size.
format(
"{\n"
" int byte_size = "
@@ -448,16 +448,16 @@ void RepeatedEnumFieldGenerator::GenerateSerializeWithCachedSizesToArray(
" $number$, $name$_, byte_size, target);\n"
" }\n"
"}\n");
- } else {
+ } else {
format(
"for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n"
" target = stream->EnsureSpace(target);\n"
" target = ::$proto_ns$::internal::WireFormatLite::WriteEnumToArray(\n"
" $number$, this->_internal_$name$(i), target);\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
@@ -470,9 +470,9 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
"for (unsigned int i = 0; i < count; i++) {\n"
" data_size += ::$proto_ns$::internal::WireFormatLite::EnumSize(\n"
" this->_internal_$name$(static_cast<int>(i)));\n"
- "}\n");
-
- if (descriptor_->is_packed()) {
+ "}\n");
+
+ if (descriptor_->is_packed()) {
format(
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
@@ -483,13 +483,13 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const {
"_$name$_cached_byte_size_.store(cached_size,\n"
" std::memory_order_relaxed);\n"
"total_size += data_size;\n");
- } else {
+ } else {
format("total_size += ($tag_size$UL * count) + data_size;\n");
- }
+ }
format.Outdent();
format("}\n");
-}
-
+}
+
void RepeatedEnumFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -500,7 +500,7 @@ void RepeatedEnumFieldGenerator::GenerateConstinitInitializer(
}
}
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
index 3fa64a86405..311248d8a37 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h
@@ -1,115 +1,115 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
-
-#include <map>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class EnumFieldGenerator : public FieldGenerator {
- public:
- EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
- ~EnumFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class EnumFieldGenerator : public FieldGenerator {
+ public:
+ EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
+ ~EnumFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
-};
-
-class EnumOneofFieldGenerator : public EnumFieldGenerator {
- public:
- EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~EnumOneofFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);
+};
+
+class EnumOneofFieldGenerator : public EnumFieldGenerator {
+ public:
+ EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~EnumOneofFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator);
-};
-
-class RepeatedEnumFieldGenerator : public FieldGenerator {
- public:
- RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~RepeatedEnumFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator);
+};
+
+class RepeatedEnumFieldGenerator : public FieldGenerator {
+ public:
+ RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~RepeatedEnumFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const {}
- void GenerateMergeFromCodedStream(io::Printer* printer) const;
- void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateMergeFromCodedStream(io::Printer* printer) const;
+ void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
index 9b0fcb02da6..7f34672e284 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.cc
@@ -1,91 +1,91 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_extension.h>
-#include <map>
+#include <map>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-
-// Returns the fully-qualified class name of the message that this field
-// extends. This function is used in the Google-internal code to handle some
-// legacy cases.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+namespace {
+
+// Returns the fully-qualified class name of the message that this field
+// extends. This function is used in the Google-internal code to handle some
+// legacy cases.
TProtoStringType ExtendeeClassName(const FieldDescriptor* descriptor) {
- const Descriptor* extendee = descriptor->containing_type();
- return ClassName(extendee, true);
-}
-
-} // anonymous namespace
-
-ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
- const Options& options)
+ const Descriptor* extendee = descriptor->containing_type();
+ return ClassName(extendee, true);
+}
+
+} // anonymous namespace
+
+ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
+ const Options& options)
: descriptor_(descriptor), options_(options) {
- // Construct type_traits_.
- if (descriptor_->is_repeated()) {
- type_traits_ = "Repeated";
- }
-
- switch (descriptor_->cpp_type()) {
- case FieldDescriptor::CPPTYPE_ENUM:
- type_traits_.append("EnumTypeTraits< ");
- type_traits_.append(ClassName(descriptor_->enum_type(), true));
- type_traits_.append(", ");
- type_traits_.append(ClassName(descriptor_->enum_type(), true));
- type_traits_.append("_IsValid>");
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- type_traits_.append("StringTypeTraits");
- break;
- case FieldDescriptor::CPPTYPE_MESSAGE:
- type_traits_.append("MessageTypeTraits< ");
- type_traits_.append(ClassName(descriptor_->message_type(), true));
- type_traits_.append(" >");
- break;
- default:
- type_traits_.append("PrimitiveTypeTraits< ");
+ // Construct type_traits_.
+ if (descriptor_->is_repeated()) {
+ type_traits_ = "Repeated";
+ }
+
+ switch (descriptor_->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_ENUM:
+ type_traits_.append("EnumTypeTraits< ");
+ type_traits_.append(ClassName(descriptor_->enum_type(), true));
+ type_traits_.append(", ");
+ type_traits_.append(ClassName(descriptor_->enum_type(), true));
+ type_traits_.append("_IsValid>");
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ type_traits_.append("StringTypeTraits");
+ break;
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ type_traits_.append("MessageTypeTraits< ");
+ type_traits_.append(ClassName(descriptor_->message_type(), true));
+ type_traits_.append(" >");
+ break;
+ default:
+ type_traits_.append("PrimitiveTypeTraits< ");
type_traits_.append(PrimitiveTypeName(options_, descriptor_->cpp_type()));
- type_traits_.append(" >");
- break;
- }
+ type_traits_.append(" >");
+ break;
+ }
SetCommonVars(options, &variables_);
variables_["extendee"] = ExtendeeClassName(descriptor_);
variables_["type_traits"] = type_traits_;
@@ -101,39 +101,39 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["scope"] = scope;
variables_["scoped_name"] = ExtensionName(descriptor_);
variables_["number"] = StrCat(descriptor_->number());
-}
-
-ExtensionGenerator::~ExtensionGenerator() {}
-
+}
+
+ExtensionGenerator::~ExtensionGenerator() {}
+
bool ExtensionGenerator::IsScoped() const {
return descriptor_->extension_scope() != nullptr;
}
-
+
void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) const {
Formatter format(printer, variables_);
- // If this is a class member, it needs to be declared "static". Otherwise,
- // it needs to be "extern". In the latter case, it also needs the DLL
- // export/import specifier.
+ // If this is a class member, it needs to be declared "static". Otherwise,
+ // it needs to be "extern". In the latter case, it also needs the DLL
+ // export/import specifier.
TProtoStringType qualifier;
if (!IsScoped()) {
qualifier = "extern";
- if (!options_.dllexport_decl.empty()) {
+ if (!options_.dllexport_decl.empty()) {
qualifier = options_.dllexport_decl + " " + qualifier;
- }
- } else {
+ }
+ } else {
qualifier = "static";
- }
-
+ }
+
format(
"static const int $constant_name$ = $number$;\n"
"$1$ ::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
" ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$ >\n"
" ${2$$name$$}$;\n",
qualifier, descriptor_);
-}
-
-void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
+}
+
+void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
// If we are building for lite with implicit weak fields, we want to skip over
// any custom options (i.e. extensions of messages from descriptor.proto).
// This prevents the creation of any unnecessary linker references to the
@@ -146,12 +146,12 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
Formatter format(printer, variables_);
TProtoStringType default_str;
- // If this is a class member, it needs to be declared in its class scope.
- if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
- // We need to declare a global string which will contain the default value.
- // We cannot declare it at class scope because that would require exposing
- // it in the header which would be annoying for other reasons. So we
- // replace :: with _ in the name and declare it as a global.
+ // If this is a class member, it needs to be declared in its class scope.
+ if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
+ // We need to declare a global string which will contain the default value.
+ // We cannot declare it at class scope because that would require exposing
+ // it in the header which would be annoying for other reasons. So we
+ // replace :: with _ in the name and declare it as a global.
default_str =
StringReplace(variables_["scoped_name"], "::", "_", true) + "_default";
format("const TProtoStringType $1$($2$);\n", default_str,
@@ -163,25 +163,25 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
FieldMessageTypeName(descriptor_, options_) + "::default_instance()";
} else {
default_str = DefaultValue(options_, descriptor_);
- }
-
- // Likewise, class members need to declare the field constant variable.
+ }
+
+ // Likewise, class members need to declare the field constant variable.
if (IsScoped()) {
format(
"#if !defined(_MSC_VER) || _MSC_VER >= 1900\n"
"const int $scope$$constant_name$;\n"
"#endif\n");
- }
-
+ }
+
format(
"PROTOBUF_ATTRIBUTE_INIT_PRIORITY "
"::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
" ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$ >\n"
" $scoped_name$($constant_name$, $1$);\n",
default_str);
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h
index 88c7dafbc39..c80550fd805 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_extension.h
@@ -1,91 +1,91 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
+
#include <map>
#include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FieldDescriptor; // descriptor.h
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-// Generates code for an extension, which may be within the scope of some
-// message or may be at file scope. This is much simpler than FieldGenerator
-// since extensions are just simple identifiers with interesting types.
-class ExtensionGenerator {
- public:
- // See generator.cc for the meaning of dllexport_decl.
- explicit ExtensionGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~ExtensionGenerator();
-
- // Header stuff.
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+// Generates code for an extension, which may be within the scope of some
+// message or may be at file scope. This is much simpler than FieldGenerator
+// since extensions are just simple identifiers with interesting types.
+class ExtensionGenerator {
+ public:
+ // See generator.cc for the meaning of dllexport_decl.
+ explicit ExtensionGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~ExtensionGenerator();
+
+ // Header stuff.
void GenerateDeclaration(io::Printer* printer) const;
-
- // Source file stuff.
- void GenerateDefinition(io::Printer* printer);
-
+
+ // Source file stuff.
+ void GenerateDefinition(io::Printer* printer);
+
bool IsScoped() const;
-
- private:
- const FieldDescriptor* descriptor_;
+
+ private:
+ const FieldDescriptor* descriptor_;
TProtoStringType type_traits_;
- Options options_;
-
+ Options options_;
+
std::map<TProtoStringType, TProtoStringType> variables_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
index 09261aaddc0..17d1f13ea40 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc
@@ -1,43 +1,43 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <cstdint>
-#include <memory>
+#include <memory>
#include <string>
-
+
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
#include <google/protobuf/compiler/cpp/cpp_string_field.h>
@@ -51,14 +51,14 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-using internal::WireFormat;
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+using internal::WireFormat;
+
namespace {
TProtoStringType GenerateAnnotation(StringPiece substitute_template_prefix,
@@ -262,31 +262,31 @@ void AddAccessorAnnotations(const FieldDescriptor* descriptor,
lambda_flat_args, "kAddMutable");
}
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
+void SetCommonFieldVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
+ const Options& options) {
SetCommonVars(options, variables);
(*variables)["ns"] = Namespace(descriptor, options);
- (*variables)["name"] = FieldName(descriptor);
+ (*variables)["name"] = FieldName(descriptor);
(*variables)["index"] = StrCat(descriptor->index());
(*variables)["number"] = StrCat(descriptor->number());
- (*variables)["classname"] = ClassName(FieldScope(descriptor), false);
- (*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
+ (*variables)["classname"] = ClassName(FieldScope(descriptor), false);
+ (*variables)["declared_type"] = DeclaredTypeMethodName(descriptor->type());
(*variables)["field_member"] = FieldName(descriptor) + "_";
-
+
(*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), descriptor->type()));
(*variables)["deprecated_attr"] = DeprecatedAttribute(options, descriptor);
-
+
(*variables)["set_hasbit"] = "";
(*variables)["clear_hasbit"] = "";
if (HasHasbit(descriptor)) {
(*variables)["set_hasbit_io"] =
"_Internal::set_has_" + FieldName(descriptor) + "(&_has_bits_);";
- } else {
+ } else {
(*variables)["set_hasbit_io"] = "";
- }
-
+ }
+
AddAccessorAnnotations(descriptor, options, variables);
// These variables are placeholders to pick out the beginning and ends of
@@ -295,8 +295,8 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
// empty string.
(*variables)["{"] = "";
(*variables)["}"] = "";
-}
-
+}
+
void FieldGenerator::SetHasBitIndex(int32_t has_bit_index) {
if (!HasHasbit(descriptor_)) {
GOOGLE_CHECK_EQ(has_bit_index, -1);
@@ -314,24 +314,24 @@ void SetCommonOneofFieldVariables(
const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables) {
const TProtoStringType prefix = descriptor->containing_oneof()->name() + "_.";
- (*variables)["oneof_name"] = descriptor->containing_oneof()->name();
+ (*variables)["oneof_name"] = descriptor->containing_oneof()->name();
(*variables)["field_member"] =
- StrCat(prefix, (*variables)["name"], "_");
-}
-
-FieldGenerator::~FieldGenerator() {}
-
-FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,
+ StrCat(prefix, (*variables)["name"], "_");
+}
+
+FieldGenerator::~FieldGenerator() {}
+
+FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer)
: descriptor_(descriptor), field_generators_(descriptor->field_count()) {
- // Construct all the FieldGenerators.
- for (int i = 0; i < descriptor->field_count(); i++) {
+ // Construct all the FieldGenerators.
+ for (int i = 0; i < descriptor->field_count(); i++) {
field_generators_[i].reset(
MakeGenerator(descriptor->field(i), options, scc_analyzer));
- }
-}
-
+ }
+}
+
FieldGenerator* FieldGeneratorMap::MakeGoogleInternalGenerator(
const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer) {
@@ -348,56 +348,56 @@ FieldGenerator* FieldGeneratorMap::MakeGenerator(
return generator;
}
- if (field->is_repeated()) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
- if (field->is_map()) {
- return new MapFieldGenerator(field, options);
- } else {
+ if (field->is_repeated()) {
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ if (field->is_map()) {
+ return new MapFieldGenerator(field, options);
+ } else {
return new RepeatedMessageFieldGenerator(field, options,
scc_analyzer);
- }
- case FieldDescriptor::CPPTYPE_STRING:
+ }
+ case FieldDescriptor::CPPTYPE_STRING:
return new RepeatedStringFieldGenerator(field, options);
- case FieldDescriptor::CPPTYPE_ENUM:
- return new RepeatedEnumFieldGenerator(field, options);
- default:
- return new RepeatedPrimitiveFieldGenerator(field, options);
- }
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return new RepeatedEnumFieldGenerator(field, options);
+ default:
+ return new RepeatedPrimitiveFieldGenerator(field, options);
+ }
} else if (field->real_containing_oneof()) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
return new MessageOneofFieldGenerator(field, options, scc_analyzer);
- case FieldDescriptor::CPPTYPE_STRING:
+ case FieldDescriptor::CPPTYPE_STRING:
return new StringOneofFieldGenerator(field, options);
- case FieldDescriptor::CPPTYPE_ENUM:
- return new EnumOneofFieldGenerator(field, options);
- default:
- return new PrimitiveOneofFieldGenerator(field, options);
- }
- } else {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return new EnumOneofFieldGenerator(field, options);
+ default:
+ return new PrimitiveOneofFieldGenerator(field, options);
+ }
+ } else {
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
return new MessageFieldGenerator(field, options, scc_analyzer);
- case FieldDescriptor::CPPTYPE_STRING:
+ case FieldDescriptor::CPPTYPE_STRING:
return new StringFieldGenerator(field, options);
- case FieldDescriptor::CPPTYPE_ENUM:
- return new EnumFieldGenerator(field, options);
- default:
- return new PrimitiveFieldGenerator(field, options);
- }
- }
-}
-
-FieldGeneratorMap::~FieldGeneratorMap() {}
-
-const FieldGenerator& FieldGeneratorMap::get(
- const FieldDescriptor* field) const {
- GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
- return *field_generators_[field->index()];
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return new EnumFieldGenerator(field, options);
+ default:
+ return new PrimitiveFieldGenerator(field, options);
+ }
+ }
+}
+
+FieldGeneratorMap::~FieldGeneratorMap() {}
+
+const FieldGenerator& FieldGeneratorMap::get(
+ const FieldDescriptor* field) const {
+ GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
+ return *field_generators_[field->index()];
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
index b05f2d93faf..51d697963dc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h
@@ -1,107 +1,107 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
+
#include <cstdint>
-#include <map>
-#include <memory>
+#include <map>
+#include <memory>
#include <string>
-
+
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-// Helper function: set variables in the map that are the same for all
-// field code generators.
-// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',
-// 'deprecation'].
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+// Helper function: set variables in the map that are the same for all
+// field code generators.
+// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',
+// 'deprecation'].
+void SetCommonFieldVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options);
-
+ const Options& options);
+
void SetCommonOneofFieldVariables(
const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables);
-
-class FieldGenerator {
- public:
+
+class FieldGenerator {
+ public:
explicit FieldGenerator(const FieldDescriptor* descriptor,
const Options& options)
: descriptor_(descriptor), options_(options) {}
- virtual ~FieldGenerator();
+ virtual ~FieldGenerator();
virtual void GenerateSerializeWithCachedSizes(
io::Printer* printer) const final{};
- // Generate lines of code declaring members fields of the message class
- // needed to represent this field. These are placed inside the message
- // class.
- virtual void GeneratePrivateMembers(io::Printer* printer) const = 0;
-
- // Generate static default variable for this field. These are placed inside
- // the message class. Most field types don't need this, so the default
- // implementation is empty.
- virtual void GenerateStaticMembers(io::Printer* /*printer*/) const {}
-
- // Generate prototypes for all of the accessor functions related to this
- // field. These are placed inside the class definition.
- virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0;
-
- // Generate inline definitions of accessor functions for this field.
- // These are placed inside the header after all class definitions.
- virtual void GenerateInlineAccessorDefinitions(
+ // Generate lines of code declaring members fields of the message class
+ // needed to represent this field. These are placed inside the message
+ // class.
+ virtual void GeneratePrivateMembers(io::Printer* printer) const = 0;
+
+ // Generate static default variable for this field. These are placed inside
+ // the message class. Most field types don't need this, so the default
+ // implementation is empty.
+ virtual void GenerateStaticMembers(io::Printer* /*printer*/) const {}
+
+ // Generate prototypes for all of the accessor functions related to this
+ // field. These are placed inside the class definition.
+ virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0;
+
+ // Generate inline definitions of accessor functions for this field.
+ // These are placed inside the header after all class definitions.
+ virtual void GenerateInlineAccessorDefinitions(
io::Printer* printer) const = 0;
-
- // Generate definitions of accessors that aren't inlined. These are
- // placed somewhere in the .cc file.
- // Most field types don't need this, so the default implementation is empty.
- virtual void GenerateNonInlineAccessorDefinitions(
+
+ // Generate definitions of accessors that aren't inlined. These are
+ // placed somewhere in the .cc file.
+ // Most field types don't need this, so the default implementation is empty.
+ virtual void GenerateNonInlineAccessorDefinitions(
io::Printer* /*printer*/) const {}
-
+
// Generate declarations of accessors that are for internal purposes only.
// Most field types don't need this, so the default implementation is empty.
virtual void GenerateInternalAccessorDefinitions(
@@ -112,10 +112,10 @@ class FieldGenerator {
virtual void GenerateInternalAccessorDeclarations(
io::Printer* /*printer*/) const {}
- // Generate lines of code (statements, not declarations) which clear the
+ // Generate lines of code (statements, not declarations) which clear the
// field. This is used to define the clear_$name$() method
- virtual void GenerateClearingCode(io::Printer* printer) const = 0;
-
+ virtual void GenerateClearingCode(io::Printer* printer) const = 0;
+
// Generate lines of code (statements, not declarations) which clear the
// field as part of the Clear() method for the whole message. For message
// types which have field presence bits, MessageGenerator::GenerateClear
@@ -127,103 +127,103 @@ class FieldGenerator {
GenerateClearingCode(printer);
}
- // Generate lines of code (statements, not declarations) which merges the
- // contents of the field from the current message to the target message,
- // which is stored in the generated code variable "from".
- // This is used to fill in the MergeFrom method for the whole message.
- // Details of this usage can be found in message.cc under the
- // GenerateMergeFrom method.
- virtual void GenerateMergingCode(io::Printer* printer) const = 0;
-
+ // Generate lines of code (statements, not declarations) which merges the
+ // contents of the field from the current message to the target message,
+ // which is stored in the generated code variable "from".
+ // This is used to fill in the MergeFrom method for the whole message.
+ // Details of this usage can be found in message.cc under the
+ // GenerateMergeFrom method.
+ virtual void GenerateMergingCode(io::Printer* printer) const = 0;
+
// Generates a copy constructor
virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0;
- // Generate lines of code (statements, not declarations) which swaps
- // this field and the corresponding field of another message, which
- // is stored in the generated code variable "other". This is used to
- // define the Swap method. Details of usage can be found in
- // message.cc under the GenerateSwap method.
- virtual void GenerateSwappingCode(io::Printer* printer) const = 0;
-
- // Generate initialization code for private members declared by
- // GeneratePrivateMembers(). These go into the message class's SharedCtor()
- // method, invoked by each of the generated constructors.
- virtual void GenerateConstructorCode(io::Printer* printer) const = 0;
-
- // Generate any code that needs to go in the class's SharedDtor() method,
- // invoked by the destructor.
- // Most field types don't need this, so the default implementation is empty.
- virtual void GenerateDestructorCode(io::Printer* /*printer*/) const {}
-
- // Generate a manual destructor invocation for use when the message is on an
- // arena. The code that this method generates will be executed inside a
+ // Generate lines of code (statements, not declarations) which swaps
+ // this field and the corresponding field of another message, which
+ // is stored in the generated code variable "other". This is used to
+ // define the Swap method. Details of usage can be found in
+ // message.cc under the GenerateSwap method.
+ virtual void GenerateSwappingCode(io::Printer* printer) const = 0;
+
+ // Generate initialization code for private members declared by
+ // GeneratePrivateMembers(). These go into the message class's SharedCtor()
+ // method, invoked by each of the generated constructors.
+ virtual void GenerateConstructorCode(io::Printer* printer) const = 0;
+
+ // Generate any code that needs to go in the class's SharedDtor() method,
+ // invoked by the destructor.
+ // Most field types don't need this, so the default implementation is empty.
+ virtual void GenerateDestructorCode(io::Printer* /*printer*/) const {}
+
+ // Generate a manual destructor invocation for use when the message is on an
+ // arena. The code that this method generates will be executed inside a
// shared-for-the-whole-message-class method registered with
// OwnDestructor(). The method should return |true| if it generated any code
// that requires a call; this allows the message generator to eliminate the
// OwnDestructor() registration if no fields require it.
- virtual bool GenerateArenaDestructorCode(io::Printer* printer) const {
- return false;
- }
-
+ virtual bool GenerateArenaDestructorCode(io::Printer* printer) const {
+ return false;
+ }
+
// Generate initialization code for private members declared by
// GeneratePrivateMembers(), specifically for the constexpr constructor.
// These go into the constructor's initializer list and must follow that
// syntax (eg `field_(args)`). Does not include `:` or `,` separators.
virtual void GenerateConstinitInitializer(io::Printer* printer) const {}
-
- // Generate lines to serialize this field directly to the array "target",
- // which are placed within the message's SerializeWithCachedSizesToArray()
- // method. This must also advance "target" past the written bytes.
- virtual void GenerateSerializeWithCachedSizesToArray(
- io::Printer* printer) const = 0;
-
- // Generate lines to compute the serialized size of this field, which
- // are placed in the message's ByteSize() method.
- virtual void GenerateByteSize(io::Printer* printer) const = 0;
-
+
+ // Generate lines to serialize this field directly to the array "target",
+ // which are placed within the message's SerializeWithCachedSizesToArray()
+ // method. This must also advance "target" past the written bytes.
+ virtual void GenerateSerializeWithCachedSizesToArray(
+ io::Printer* printer) const = 0;
+
+ // Generate lines to compute the serialized size of this field, which
+ // are placed in the message's ByteSize() method.
+ virtual void GenerateByteSize(io::Printer* printer) const = 0;
+
void SetHasBitIndex(int32_t has_bit_index);
- protected:
+ protected:
const FieldDescriptor* descriptor_;
- const Options& options_;
+ const Options& options_;
std::map<TProtoStringType, TProtoStringType> variables_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
-};
-
-// Convenience class which constructs FieldGenerators for a Descriptor.
-class FieldGeneratorMap {
- public:
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);
+};
+
+// Convenience class which constructs FieldGenerators for a Descriptor.
+class FieldGeneratorMap {
+ public:
FieldGeneratorMap(const Descriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
- ~FieldGeneratorMap();
-
- const FieldGenerator& get(const FieldDescriptor* field) const;
-
+ ~FieldGeneratorMap();
+
+ const FieldGenerator& get(const FieldDescriptor* field) const;
+
void SetHasBitIndices(const std::vector<int>& has_bit_indices_) {
for (int i = 0; i < descriptor_->field_count(); ++i) {
field_generators_[i]->SetHasBitIndex(has_bit_indices_[i]);
}
}
- private:
- const Descriptor* descriptor_;
+ private:
+ const Descriptor* descriptor_;
std::vector<std::unique_ptr<FieldGenerator>> field_generators_;
-
+
static FieldGenerator* MakeGoogleInternalGenerator(
const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
- static FieldGenerator* MakeGenerator(const FieldDescriptor* field,
+ static FieldGenerator* MakeGenerator(const FieldDescriptor* field,
const Options& options,
MessageSCCAnalyzer* scc_analyzer);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
index 6218cfa8b5d..f0940f5d21f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -1,47 +1,47 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_file.h>
#include <iostream>
-#include <map>
-#include <memory>
-#include <set>
+#include <map>
+#include <memory>
+#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
-
+
#include <google/protobuf/compiler/cpp/cpp_enum.h>
#include <google/protobuf/compiler/cpp/cpp_extension.h>
#include <google/protobuf/compiler/cpp/cpp_field.h>
@@ -52,17 +52,17 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
+
// Must be last.
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
namespace {
-
+
// When we forward-declare things, we want to create a sorted order so our
// output is deterministic and minimizes namespace changes.
template <class T>
@@ -89,7 +89,7 @@ std::vector<const T*> Sorted(const std::unordered_set<const T*>& vals) {
} // namespace
-FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
+FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
: file_(file), options_(options), scc_analyzer_(options) {
// These variables are the same on a file level
SetCommonVars(options, &variables_);
@@ -104,7 +104,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
UniqueName("file_level_service_descriptors", file_, options_);
variables_["filename"] = file_->name();
variables_["package_ns"] = Namespace(file_, options);
-
+
std::vector<const Descriptor*> msgs = FlattenMessagesInFile(file);
for (int i = 0; i < msgs.size(); i++) {
// Deleted in destructor
@@ -112,33 +112,33 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
new MessageGenerator(msgs[i], variables_, i, options, &scc_analyzer_);
message_generators_.emplace_back(msg_gen);
msg_gen->AddGenerators(&enum_generators_, &extension_generators_);
- }
-
- for (int i = 0; i < file->enum_type_count(); i++) {
+ }
+
+ for (int i = 0; i < file->enum_type_count(); i++) {
enum_generators_.emplace_back(
new EnumGenerator(file->enum_type(i), variables_, options));
- }
-
- for (int i = 0; i < file->service_count(); i++) {
+ }
+
+ for (int i = 0; i < file->service_count(); i++) {
service_generators_.emplace_back(
new ServiceGenerator(file->service(i), variables_, options));
- }
+ }
if (HasGenericServices(file_, options_)) {
for (int i = 0; i < service_generators_.size(); i++) {
service_generators_[i]->index_in_metadata_ = i;
}
}
- for (int i = 0; i < file->extension_count(); i++) {
+ for (int i = 0; i < file->extension_count(); i++) {
extension_generators_.emplace_back(
new ExtensionGenerator(file->extension(i), options));
- }
+ }
for (int i = 0; i < file->weak_dependency_count(); ++i) {
weak_deps_.insert(file->weak_dependency(i));
}
-}
-
+}
+
FileGenerator::~FileGenerator() = default;
-
+
void FileGenerator::GenerateMacroUndefs(io::Printer* printer) {
Formatter format(printer, variables_);
// Only do this for protobuf's own types. There are some google3 protos using
@@ -172,12 +172,12 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* printer) {
void FileGenerator::GenerateHeader(io::Printer* printer) {
Formatter format(printer, variables_);
-
+
// port_def.inc must be included after all other includes.
IncludeFile("net/proto2/public/port_def.inc", printer);
format("#define $1$$ dllexport_decl$\n", FileDllExport(file_, options_));
GenerateMacroUndefs(printer);
-
+
// For Any support with lite protos, we need to friend AnyMetadata, so we
// forward-declare it here.
format(
@@ -186,53 +186,53 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
"class AnyMetadata;\n"
"} // namespace internal\n"
"PROTOBUF_NAMESPACE_CLOSE\n");
-
- GenerateGlobalStateFunctionDeclarations(printer);
-
+
+ GenerateGlobalStateFunctionDeclarations(printer);
+
GenerateForwardDeclarations(printer);
-
+
{
NamespaceOpener ns(Namespace(file_, options_), format);
-
+
format("\n");
-
+
GenerateEnumDefinitions(printer);
-
+
format(kThickSeparator);
format("\n");
-
+
GenerateMessageDefinitions(printer);
-
+
format("\n");
format(kThickSeparator);
format("\n");
-
+
GenerateServiceDefinitions(printer);
-
+
GenerateExtensionIdentifiers(printer);
-
+
format("\n");
format(kThickSeparator);
format("\n");
-
+
GenerateInlineFunctionDefinitions(printer);
-
+
format(
"\n"
"// @@protoc_insertion_point(namespace_scope)\n"
"\n");
}
- // We need to specialize some templates in the ::google::protobuf namespace:
- GenerateProto2NamespaceEnumSpecializations(printer);
-
+ // We need to specialize some templates in the ::google::protobuf namespace:
+ GenerateProto2NamespaceEnumSpecializations(printer);
+
format(
"\n"
"// @@protoc_insertion_point(global_scope)\n"
"\n");
IncludeFile("net/proto2/public/port_undef.inc", printer);
}
-
+
void FileGenerator::GenerateProtoHeader(io::Printer* printer,
const TProtoStringType& info_path) {
Formatter format(printer, variables_);
@@ -269,23 +269,23 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer,
GenerateHeader(printer);
GenerateBottomHeaderGuard(printer, false);
-}
-
-void FileGenerator::GeneratePBHeader(io::Printer* printer,
+}
+
+void FileGenerator::GeneratePBHeader(io::Printer* printer,
const TProtoStringType& info_path) {
Formatter format(printer, variables_);
GenerateTopHeaderGuard(printer, true);
-
- if (options_.proto_h) {
+
+ if (options_.proto_h) {
TProtoStringType target_basename = StripProto(file_->name());
if (!options_.opensource_runtime) {
GetBootstrapBasename(options_, target_basename, &target_basename);
}
format("#include \"$1$.proto.h\" // IWYU pragma: export\n",
target_basename);
- } else {
- GenerateLibraryIncludes(printer);
- }
+ } else {
+ GenerateLibraryIncludes(printer);
+ }
if (options_.transitive_pb_h) {
GenerateDependencyIncludes(printer);
@@ -296,9 +296,9 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer,
// TODO(gerbens) remove this.
format("// @@protoc_insertion_point(includes)\n");
- GenerateMetadataPragma(printer, info_path);
-
- if (!options_.proto_h) {
+ GenerateMetadataPragma(printer, info_path);
+
+ if (!options_.proto_h) {
GenerateHeader(printer);
} else {
{
@@ -312,10 +312,10 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer,
"// @@protoc_insertion_point(global_scope)\n"
"\n");
}
-
+
GenerateBottomHeaderGuard(printer, true);
}
-
+
void FileGenerator::DoIncludeFile(const TProtoStringType& google3_name,
bool do_export, io::Printer* printer) {
Formatter format(printer, variables_);
@@ -336,20 +336,20 @@ void FileGenerator::DoIncludeFile(const TProtoStringType& google3_name,
}
} else {
format("#include \"$1$\"", google3_name);
- }
-
+ }
+
if (do_export) {
format(" // IWYU pragma: export");
}
format("\n");
-}
-
+}
+
TProtoStringType FileGenerator::CreateHeaderInclude(const TProtoStringType& basename,
const FileDescriptor* file) {
bool use_system_include = false;
TProtoStringType name = basename;
-
+
if (options_.opensource_runtime) {
if (IsWellKnownMessage(file)) {
if (options_.runtime_include_base.empty()) {
@@ -391,27 +391,27 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) {
IncludeFile("net/proto2/public/extension_set.h", printer);
IncludeFile("net/proto2/public/wire_format_lite.h", printer);
- // Unknown fields implementation in lite mode uses StringOutputStream
+ // Unknown fields implementation in lite mode uses StringOutputStream
if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) {
IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", printer);
- }
-
- if (HasDescriptorMethods(file_, options_)) {
+ }
+
+ if (HasDescriptorMethods(file_, options_)) {
IncludeFile("net/proto2/public/descriptor.h", printer);
IncludeFile("net/proto2/public/generated_message_reflection.h", printer);
IncludeFile("net/proto2/public/reflection_ops.h", printer);
IncludeFile("net/proto2/public/wire_format.h", printer);
- }
-
+ }
+
if (HasGeneratedMethods(file_, options_) &&
options_.tctable_mode != Options::kTCTableNever) {
IncludeFile("net/proto2/public/generated_message_tctable_impl.h", printer);
}
- if (options_.proto_h) {
- // Use the smaller .proto.h files.
- for (int i = 0; i < file_->dependency_count(); i++) {
- const FileDescriptor* dep = file_->dependency(i);
+ if (options_.proto_h) {
+ // Use the smaller .proto.h files.
+ for (int i = 0; i < file_->dependency_count(); i++) {
+ const FileDescriptor* dep = file_->dependency(i);
// Do not import weak deps.
if (!options_.opensource_runtime && IsDepWeak(dep)) continue;
TProtoStringType basename = StripProto(dep->name());
@@ -419,23 +419,23 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) {
GetBootstrapBasename(options_, basename, &basename);
}
format("#include \"$1$.proto.h\"\n", basename);
- }
- }
+ }
+ }
if (HasCordFields(file_, options_)) {
format(
"#include \"third_party/absl/strings/internal/string_constant.h\"\n");
}
-
+
format("// @@protoc_insertion_point(includes)\n");
IncludeFile("net/proto2/public/port_def.inc", printer);
-
+
// For MSVC builds, we use #pragma init_seg to move the initialization of our
// libraries to happen before the user code.
// This worksaround the fact that MSVC does not do constant initializers when
// required by the standard.
format("\nPROTOBUF_PRAGMA_INIT_SEG\n");
}
-
+
void FileGenerator::GenerateSourceDefaultInstance(int idx,
io::Printer* printer) {
Formatter format(printer, variables_);
@@ -531,21 +531,21 @@ void FileGenerator::GenerateInternalForwardDeclarations(
DefaultInstanceType(instance, options_),
DefaultInstanceName(instance, options_));
}
- }
+ }
}
-
+
for (auto file : Sorted(refs.weak_reflection_files)) {
format(
"extern __attribute__((weak)) const "
"::$proto_ns$::internal::DescriptorTable $1$;\n",
DescriptorTableName(file, options_));
- }
+ }
}
-
+
void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) {
Formatter format(printer, variables_);
GenerateSourceIncludes(printer);
-
+
CrossFileReferences refs;
ForEachField(message_generators_[idx]->descriptor_,
[this, &refs](const FieldDescriptor* field) {
@@ -594,43 +594,43 @@ void FileGenerator::GenerateGlobalSource(io::Printer* printer) {
NamespaceOpener ns(Namespace(file_, options_), format);
- // Generate enums.
+ // Generate enums.
for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->GenerateMethods(i, printer);
- }
-
+ }
+
// Define extensions.
for (int i = 0; i < extension_generators_.size(); i++) {
extension_generators_[i]->GenerateDefinition(printer);
- }
-
- if (HasGenericServices(file_, options_)) {
- // Generate services.
+ }
+
+ if (HasGenericServices(file_, options_)) {
+ // Generate services.
for (int i = 0; i < service_generators_.size(); i++) {
if (i == 0) format("\n");
format(kThickSeparator);
format("\n");
- service_generators_[i]->GenerateImplementation(printer);
- }
- }
+ service_generators_[i]->GenerateImplementation(printer);
+ }
+ }
}
-
+
void FileGenerator::GenerateSource(io::Printer* printer) {
Formatter format(printer, variables_);
GenerateSourceIncludes(printer);
CrossFileReferences refs;
GetCrossFileReferencesForFile(file_, &refs);
GenerateInternalForwardDeclarations(refs, printer);
-
+
{
NamespaceOpener ns(Namespace(file_, options_), format);
-
+
// Define default instances
for (int i = 0; i < message_generators_.size(); i++) {
GenerateSourceDefaultInstance(i, printer);
- }
- }
-
+ }
+ }
+
{
GenerateTables(printer);
@@ -638,18 +638,18 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
// Define the code to initialize reflection. This code uses a global
// constructor to register reflection data with the runtime pre-main.
GenerateReflectionInitializationCode(printer);
- }
- }
-
+ }
+ }
+
{
NamespaceOpener ns(Namespace(file_, options_), format);
-
+
// Actually implement the protos
// Generate enums.
for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->GenerateMethods(i, printer);
- }
+ }
// Generate classes.
for (int i = 0; i < message_generators_.size(); i++) {
@@ -657,7 +657,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
format(kThickSeparator);
format("\n");
message_generators_[i]->GenerateClassMethods(printer);
- }
+ }
if (HasGenericServices(file_, options_)) {
// Generate services.
@@ -667,25 +667,25 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
format("\n");
service_generators_[i]->GenerateImplementation(printer);
}
- }
-
+ }
+
// Define extensions.
for (int i = 0; i < extension_generators_.size(); i++) {
extension_generators_[i]->GenerateDefinition(printer);
}
-
+
format(
"\n"
"// @@protoc_insertion_point(namespace_scope)\n");
}
-
+
{
NamespaceOpener proto_ns(ProtobufNamespace(options_), format);
for (int i = 0; i < message_generators_.size(); i++) {
message_generators_[i]->GenerateSourceInProto2Namespace(printer);
}
}
-
+
format(
"\n"
"// @@protoc_insertion_point(global_scope)\n");
@@ -1004,12 +1004,12 @@ void FileGenerator::GenerateTables(io::Printer* printer) {
"\n");
}
}
-
+
class FileGenerator::ForwardDeclarations {
public:
void AddMessage(const Descriptor* d) { classes_[ClassName(d)] = d; }
void AddEnum(const EnumDescriptor* d) { enums_[ClassName(d)] = d; }
-
+
void Print(const Formatter& format, const Options& options) const {
for (const auto& p : enums_) {
const TProtoStringType& enumname = p.first;
@@ -1030,7 +1030,7 @@ class FileGenerator::ForwardDeclarations {
DefaultInstanceName(class_desc, options));
}
}
-
+
void PrintTopLevelDecl(const Formatter& format,
const Options& options) const {
for (const auto& pair : classes_) {
@@ -1039,21 +1039,21 @@ class FileGenerator::ForwardDeclarations {
"$1$* Arena::CreateMaybeMessage<$1$>(Arena*);\n",
QualifiedClassName(pair.second, options));
}
- }
-
+ }
+
private:
std::map<TProtoStringType, const Descriptor*> classes_;
std::map<TProtoStringType, const EnumDescriptor*> enums_;
};
-
+
static void PublicImportDFS(const FileDescriptor* fd,
std::unordered_set<const FileDescriptor*>* fd_set) {
for (int i = 0; i < fd->public_dependency_count(); i++) {
const FileDescriptor* dep = fd->public_dependency(i);
if (fd_set->insert(dep).second) PublicImportDFS(dep, fd_set);
- }
+ }
}
-
+
void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
Formatter format(printer, variables_);
std::vector<const Descriptor*> classes;
@@ -1069,15 +1069,15 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
classes.push_back(fields[i]->containing_type());
classes.push_back(fields[i]->message_type());
enums.push_back(fields[i]->enum_type());
- }
+ }
ListAllTypesForServices(file_, &classes);
- }
-
+ }
+
// Calculate the set of files whose definitions we get through include.
// No need to forward declare types that are defined in these.
std::unordered_set<const FileDescriptor*> public_set;
PublicImportDFS(file_, &public_set);
-
+
std::map<TProtoStringType, ForwardDeclarations> decls;
for (int i = 0; i < classes.size(); i++) {
const Descriptor* d = classes[i];
@@ -1088,29 +1088,29 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {
const EnumDescriptor* d = enums[i];
if (d && !public_set.count(d->file()))
decls[Namespace(d, options_)].AddEnum(d);
- }
-
+ }
+
{
NamespaceOpener ns(format);
for (const auto& pair : decls) {
ns.ChangeTo(pair.first);
pair.second.Print(format, options_);
}
- }
+ }
format("PROTOBUF_NAMESPACE_OPEN\n");
for (const auto& pair : decls) {
pair.second.PrintTopLevelDecl(format, options_);
- }
+ }
format("PROTOBUF_NAMESPACE_CLOSE\n");
-}
-
+}
+
void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h) {
Formatter format(printer, variables_);
- // Generate top of header.
+ // Generate top of header.
format(
- "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "// source: $filename$\n"
- "\n"
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "// source: $filename$\n"
+ "\n"
"#ifndef $1$\n"
"#define $1$\n"
"\n"
@@ -1122,15 +1122,15 @@ void FileGenerator::GenerateTopHeaderGuard(io::Printer* printer, bool pb_h) {
format("#include <type_traits>\n");
}
format("\n");
-}
-
+}
+
void FileGenerator::GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h) {
Formatter format(printer, variables_);
format("#endif // $GOOGLE_PROTOBUF$_INCLUDED_$1$\n",
IncludeGuard(file_, pb_h, options_));
-}
-
-void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
+}
+
+void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
Formatter format(printer, variables_);
if (UsingImplicitWeakFields(file_, options_)) {
IncludeFile("net/proto2/public/implicit_weak_message.h", printer);
@@ -1143,7 +1143,7 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
GOOGLE_CHECK(!options_.opensource_runtime);
IncludeFile("net/proto2/public/lazy_field.h", printer);
}
-
+
if (options_.opensource_runtime) {
// Verify the protobuf library header version is compatible with the protoc
// version before going any further.
@@ -1165,8 +1165,8 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
PROTOBUF_VERSION); // 2
IncludeFile("net/proto2/public/port_undef.inc", printer);
}
-
- // OK, it's now safe to #include other files.
+
+ // OK, it's now safe to #include other files.
IncludeFile("net/proto2/io/public/coded_stream.h", printer);
IncludeFile("net/proto2/public/arena.h", printer);
IncludeFile("net/proto2/public/arenastring.h", printer);
@@ -1183,12 +1183,12 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
}
if (!message_generators_.empty()) {
- if (HasDescriptorMethods(file_, options_)) {
+ if (HasDescriptorMethods(file_, options_)) {
IncludeFile("net/proto2/public/message.h", printer);
- } else {
+ } else {
IncludeFile("net/proto2/public/message_lite.h", printer);
- }
- }
+ }
+ }
if (options_.opensource_runtime) {
// Open-source relies on unconditional includes of these.
IncludeFileAndExport("net/proto2/public/repeated_field.h", printer);
@@ -1208,68 +1208,68 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
format("#include \"third_party/absl/strings/cord.h\"\n");
}
}
- if (HasMapFields(file_)) {
+ if (HasMapFields(file_)) {
IncludeFileAndExport("net/proto2/public/map.h", printer);
- if (HasDescriptorMethods(file_, options_)) {
+ if (HasDescriptorMethods(file_, options_)) {
IncludeFile("net/proto2/public/map_entry.h", printer);
IncludeFile("net/proto2/public/map_field_inl.h", printer);
- } else {
+ } else {
IncludeFile("net/proto2/public/map_entry_lite.h", printer);
IncludeFile("net/proto2/public/map_field_lite.h", printer);
- }
- }
-
- if (HasEnumDefinitions(file_)) {
- if (HasDescriptorMethods(file_, options_)) {
+ }
+ }
+
+ if (HasEnumDefinitions(file_)) {
+ if (HasDescriptorMethods(file_, options_)) {
IncludeFile("net/proto2/public/generated_enum_reflection.h", printer);
- } else {
+ } else {
IncludeFile("net/proto2/public/generated_enum_util.h", printer);
- }
- }
-
- if (HasGenericServices(file_, options_)) {
+ }
+ }
+
+ if (HasGenericServices(file_, options_)) {
IncludeFile("net/proto2/public/service.h", printer);
- }
-
+ }
+
if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) {
IncludeFile("net/proto2/public/unknown_field_set.h", printer);
- }
-}
-
-void FileGenerator::GenerateMetadataPragma(io::Printer* printer,
+ }
+}
+
+void FileGenerator::GenerateMetadataPragma(io::Printer* printer,
const TProtoStringType& info_path) {
Formatter format(printer, variables_);
- if (!info_path.empty() && !options_.annotation_pragma_name.empty() &&
- !options_.annotation_guard_name.empty()) {
+ if (!info_path.empty() && !options_.annotation_pragma_name.empty() &&
+ !options_.annotation_guard_name.empty()) {
format.Set("guard", options_.annotation_guard_name);
format.Set("pragma", options_.annotation_pragma_name);
format.Set("info_path", info_path);
format(
- "#ifdef $guard$\n"
- "#pragma $pragma$ \"$info_path$\"\n"
+ "#ifdef $guard$\n"
+ "#pragma $pragma$ \"$info_path$\"\n"
"#endif // $guard$\n");
- }
-}
-
-void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) {
+ }
+}
+
+void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) {
Formatter format(printer, variables_);
- for (int i = 0; i < file_->dependency_count(); i++) {
+ for (int i = 0; i < file_->dependency_count(); i++) {
TProtoStringType basename = StripProto(file_->dependency(i)->name());
-
+
// Do not import weak deps.
if (IsDepWeak(file_->dependency(i))) continue;
-
+
if (IsBootstrapProto(options_, file_)) {
GetBootstrapBasename(options_, basename, &basename);
}
format("#include $1$\n",
CreateHeaderInclude(basename + ".pb.h", file_->dependency(i)));
- }
-}
-
-void FileGenerator::GenerateGlobalStateFunctionDeclarations(
- io::Printer* printer) {
+ }
+}
+
+void FileGenerator::GenerateGlobalStateFunctionDeclarations(
+ io::Printer* printer) {
Formatter format(printer, variables_);
// Forward-declare the DescriptorTable because this is referenced by .pb.cc
// files depending on this file.
@@ -1301,57 +1301,57 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
"$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable "
"$desc_table$;\n");
}
-}
-
-void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) {
+}
+
+void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) {
Formatter format(printer, variables_);
- // Generate class definitions.
+ // Generate class definitions.
for (int i = 0; i < message_generators_.size(); i++) {
- if (i > 0) {
+ if (i > 0) {
format("\n");
format(kThinSeparator);
format("\n");
- }
- message_generators_[i]->GenerateClassDefinition(printer);
- }
-}
-
-void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) {
- // Generate enum definitions.
+ }
+ message_generators_[i]->GenerateClassDefinition(printer);
+ }
+}
+
+void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) {
+ // Generate enum definitions.
for (int i = 0; i < enum_generators_.size(); i++) {
- enum_generators_[i]->GenerateDefinition(printer);
- }
-}
-
-void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) {
+ enum_generators_[i]->GenerateDefinition(printer);
+ }
+}
+
+void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) {
Formatter format(printer, variables_);
- if (HasGenericServices(file_, options_)) {
- // Generate service definitions.
+ if (HasGenericServices(file_, options_)) {
+ // Generate service definitions.
for (int i = 0; i < service_generators_.size(); i++) {
- if (i > 0) {
+ if (i > 0) {
format("\n");
format(kThinSeparator);
format("\n");
- }
- service_generators_[i]->GenerateDeclarations(printer);
- }
-
+ }
+ service_generators_[i]->GenerateDeclarations(printer);
+ }
+
format("\n");
format(kThickSeparator);
format("\n");
- }
-}
-
-void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) {
+ }
+}
+
+void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) {
// Declare extension identifiers. These are in global scope and so only
// the global scope extensions.
for (auto& extension_generator : extension_generators_) {
if (extension_generator->IsScoped()) continue;
extension_generator->GenerateDeclaration(printer);
- }
-}
-
-void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {
+ }
+}
+
+void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {
Formatter format(printer, variables_);
// TODO(gerbens) remove pragmas when gcc is no longer used. Current version
// of gcc fires a bogus error when compiled with strict-aliasing.
@@ -1360,32 +1360,32 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {
" #pragma GCC diagnostic push\n"
" #pragma GCC diagnostic ignored \"-Wstrict-aliasing\"\n"
"#endif // __GNUC__\n");
- // Generate class inline methods.
+ // Generate class inline methods.
for (int i = 0; i < message_generators_.size(); i++) {
- if (i > 0) {
+ if (i > 0) {
format(kThinSeparator);
format("\n");
- }
+ }
message_generators_[i]->GenerateInlineMethods(printer);
- }
+ }
format(
"#ifdef __GNUC__\n"
" #pragma GCC diagnostic pop\n"
"#endif // __GNUC__\n");
-
+
for (int i = 0; i < message_generators_.size(); i++) {
- if (i > 0) {
+ if (i > 0) {
format(kThinSeparator);
format("\n");
- }
- }
-}
-
-void FileGenerator::GenerateProto2NamespaceEnumSpecializations(
- io::Printer* printer) {
+ }
+ }
+}
+
+void FileGenerator::GenerateProto2NamespaceEnumSpecializations(
+ io::Printer* printer) {
Formatter format(printer, variables_);
- // Emit GetEnumDescriptor specializations into google::protobuf namespace:
- if (HasEnumDefinitions(file_)) {
+ // Emit GetEnumDescriptor specializations into google::protobuf namespace:
+ if (HasEnumDefinitions(file_)) {
format("\n");
{
NamespaceOpener proto_ns(ProtobufNamespace(options_), format);
@@ -1394,11 +1394,11 @@ void FileGenerator::GenerateProto2NamespaceEnumSpecializations(
enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);
}
format("\n");
- }
- }
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ }
+ }
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
index 41e39073910..fa8a8769473 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -1,76 +1,76 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
+
#include <algorithm>
-#include <memory>
+#include <memory>
#include <set>
#include <string>
-#include <vector>
+#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/compiler/scc.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FileDescriptor; // descriptor.h
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
class EnumGenerator; // enum.h
class MessageGenerator; // message.h
class ServiceGenerator; // service.h
class ExtensionGenerator; // extension.h
-
-class FileGenerator {
- public:
- // See generator.cc for the meaning of dllexport_decl.
- FileGenerator(const FileDescriptor* file, const Options& options);
- ~FileGenerator();
-
+
+class FileGenerator {
+ public:
+ // See generator.cc for the meaning of dllexport_decl.
+ FileGenerator(const FileDescriptor* file, const Options& options);
+ ~FileGenerator();
+
// Shared code between the two header generators below.
void GenerateHeader(io::Printer* printer);
@@ -80,18 +80,18 @@ class FileGenerator {
// info_path, if non-empty, should be the path (relative to printer's
// output) to the metadata file describing this PB header.
void GeneratePBHeader(io::Printer* printer, const TProtoStringType& info_path);
- void GenerateSource(io::Printer* printer);
-
+ void GenerateSource(io::Printer* printer);
+
int NumMessages() const { return message_generators_.size(); }
// Similar to GenerateSource but generates only one message
void GenerateSourceForMessage(int idx, io::Printer* printer);
void GenerateGlobalSource(io::Printer* printer);
- private:
- // Internal type used by GenerateForwardDeclarations (defined in file.cc).
- class ForwardDeclarations;
+ private:
+ // Internal type used by GenerateForwardDeclarations (defined in file.cc).
+ class ForwardDeclarations;
struct CrossFileReferences;
-
+
void IncludeFile(const TProtoStringType& google3_name, io::Printer* printer) {
DoIncludeFile(google3_name, false, printer);
}
@@ -101,7 +101,7 @@ class FileGenerator {
}
void DoIncludeFile(const TProtoStringType& google3_name, bool do_export,
io::Printer* printer);
-
+
TProtoStringType CreateHeaderInclude(const TProtoStringType& basename,
const FileDescriptor* file);
void GetCrossFileReferencesForField(const FieldDescriptor* field,
@@ -112,47 +112,47 @@ class FileGenerator {
io::Printer* printer);
void GenerateSourceIncludes(io::Printer* printer);
void GenerateSourceDefaultInstance(int idx, io::Printer* printer);
-
+
void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs,
io::Printer* printer);
void GenerateTables(io::Printer* printer);
void GenerateReflectionInitializationCode(io::Printer* printer);
- // For other imports, generates their forward-declarations.
- void GenerateForwardDeclarations(io::Printer* printer);
-
- // Generates top or bottom of a header file.
+ // For other imports, generates their forward-declarations.
+ void GenerateForwardDeclarations(io::Printer* printer);
+
+ // Generates top or bottom of a header file.
void GenerateTopHeaderGuard(io::Printer* printer, bool pb_h);
void GenerateBottomHeaderGuard(io::Printer* printer, bool pb_h);
-
- // Generates #include directives.
- void GenerateLibraryIncludes(io::Printer* printer);
- void GenerateDependencyIncludes(io::Printer* printer);
-
- // Generate a pragma to pull in metadata using the given info_path (if
- // non-empty). info_path should be relative to printer's output.
+
+ // Generates #include directives.
+ void GenerateLibraryIncludes(io::Printer* printer);
+ void GenerateDependencyIncludes(io::Printer* printer);
+
+ // Generate a pragma to pull in metadata using the given info_path (if
+ // non-empty). info_path should be relative to printer's output.
void GenerateMetadataPragma(io::Printer* printer,
const TProtoStringType& info_path);
-
- // Generates a couple of different pieces before definitions:
- void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);
-
- // Generates types for classes.
- void GenerateMessageDefinitions(io::Printer* printer);
-
- void GenerateEnumDefinitions(io::Printer* printer);
-
- // Generates generic service definitions.
- void GenerateServiceDefinitions(io::Printer* printer);
-
- // Generates extension identifiers.
- void GenerateExtensionIdentifiers(io::Printer* printer);
-
+
+ // Generates a couple of different pieces before definitions:
+ void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);
+
+ // Generates types for classes.
+ void GenerateMessageDefinitions(io::Printer* printer);
+
+ void GenerateEnumDefinitions(io::Printer* printer);
+
+ // Generates generic service definitions.
+ void GenerateServiceDefinitions(io::Printer* printer);
+
+ // Generates extension identifiers.
+ void GenerateExtensionIdentifiers(io::Printer* printer);
+
// Generates inline function definitions.
- void GenerateInlineFunctionDefinitions(io::Printer* printer);
-
- void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);
-
+ void GenerateInlineFunctionDefinitions(io::Printer* printer);
+
+ void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);
+
// Sometimes the names we use in a .proto file happen to be defined as
// macros on some platforms (e.g., macro/minor used in plugin.proto are
// defined as macros in sys/types.h on FreeBSD and a few other platforms).
@@ -172,9 +172,9 @@ class FileGenerator {
std::set<const FileDescriptor*> weak_deps_;
- const FileDescriptor* file_;
- const Options options_;
-
+ const FileDescriptor* file_;
+ const Options options_;
+
MessageSCCAnalyzer scc_analyzer_;
std::map<TProtoStringType, TProtoStringType> variables_;
@@ -185,13 +185,13 @@ class FileGenerator {
std::vector<std::unique_ptr<EnumGenerator>> enum_generators_;
std::vector<std::unique_ptr<ServiceGenerator>> service_generators_;
std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
index 1e2d01d147b..dcaa1ef9f6a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -1,101 +1,101 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_generator.h>
-
-#include <memory>
-#include <utility>
+
+#include <memory>
+#include <utility>
#include <vector>
-
+
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/compiler/cpp/cpp_file.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-CppGenerator::CppGenerator() {}
-CppGenerator::~CppGenerator() {}
-
-bool CppGenerator::Generate(const FileDescriptor* file,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+CppGenerator::CppGenerator() {}
+CppGenerator::~CppGenerator() {}
+
+bool CppGenerator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
- GeneratorContext* generator_context,
+ GeneratorContext* generator_context,
TProtoStringType* error) const {
std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
- ParseGeneratorParameter(parameter, &options);
-
- // -----------------------------------------------------------------
- // parse generator options
-
- // If the dllexport_decl option is passed to the compiler, we need to write
- // it in front of every symbol that should be exported if this .proto is
- // compiled into a Windows DLL. E.g., if the user invokes the protocol
- // compiler as:
- // protoc --cpp_out=dllexport_decl=FOO_EXPORT:outdir foo.proto
- // then we'll define classes like this:
- // class FOO_EXPORT Foo {
- // ...
- // }
- // FOO_EXPORT is a macro which should expand to __declspec(dllexport) or
- // __declspec(dllimport) depending on what is being compiled.
- //
- Options file_options;
-
+ ParseGeneratorParameter(parameter, &options);
+
+ // -----------------------------------------------------------------
+ // parse generator options
+
+ // If the dllexport_decl option is passed to the compiler, we need to write
+ // it in front of every symbol that should be exported if this .proto is
+ // compiled into a Windows DLL. E.g., if the user invokes the protocol
+ // compiler as:
+ // protoc --cpp_out=dllexport_decl=FOO_EXPORT:outdir foo.proto
+ // then we'll define classes like this:
+ // class FOO_EXPORT Foo {
+ // ...
+ // }
+ // FOO_EXPORT is a macro which should expand to __declspec(dllexport) or
+ // __declspec(dllimport) depending on what is being compiled.
+ //
+ Options file_options;
+
file_options.opensource_runtime = opensource_runtime_;
file_options.runtime_include_base = runtime_include_base_;
- for (int i = 0; i < options.size(); i++) {
- if (options[i].first == "dllexport_decl") {
- file_options.dllexport_decl = options[i].second;
- } else if (options[i].first == "safe_boundary_check") {
- file_options.safe_boundary_check = true;
- } else if (options[i].first == "annotate_headers") {
- file_options.annotate_headers = true;
- } else if (options[i].first == "annotation_pragma_name") {
- file_options.annotation_pragma_name = options[i].second;
- } else if (options[i].first == "annotation_guard_name") {
- file_options.annotation_guard_name = options[i].second;
+ for (int i = 0; i < options.size(); i++) {
+ if (options[i].first == "dllexport_decl") {
+ file_options.dllexport_decl = options[i].second;
+ } else if (options[i].first == "safe_boundary_check") {
+ file_options.safe_boundary_check = true;
+ } else if (options[i].first == "annotate_headers") {
+ file_options.annotate_headers = true;
+ } else if (options[i].first == "annotation_pragma_name") {
+ file_options.annotation_pragma_name = options[i].second;
+ } else if (options[i].first == "annotation_guard_name") {
+ file_options.annotation_guard_name = options[i].second;
} else if (options[i].first == "speed") {
file_options.enforce_mode = EnforceOptimizeMode::kSpeed;
} else if (options[i].first == "code_size") {
file_options.enforce_mode = EnforceOptimizeMode::kCodeSize;
- } else if (options[i].first == "lite") {
+ } else if (options[i].first == "lite") {
file_options.enforce_mode = EnforceOptimizeMode::kLiteRuntime;
} else if (options[i].first == "lite_implicit_weak_fields") {
file_options.enforce_mode = EnforceOptimizeMode::kLiteRuntime;
@@ -128,12 +128,12 @@ bool CppGenerator::Generate(const FileDescriptor* file,
options[i].second;
return false;
}
- } else {
- *error = "Unknown generator option: " + options[i].first;
- return false;
- }
- }
-
+ } else {
+ *error = "Unknown generator option: " + options[i].first;
+ return false;
+ }
+ }
+
// The safe_boundary_check option controls behavior for Google-internal
// protobuf APIs.
if (file_options.safe_boundary_check && file_options.opensource_runtime) {
@@ -142,57 +142,57 @@ bool CppGenerator::Generate(const FileDescriptor* file,
return false;
}
- // -----------------------------------------------------------------
-
-
+ // -----------------------------------------------------------------
+
+
TProtoStringType basename = StripProto(file->name());
-
+
if (MaybeBootstrap(file_options, generator_context, file_options.bootstrap,
&basename)) {
return true;
}
- FileGenerator file_generator(file, file_options);
-
- // Generate header(s).
- if (file_options.proto_h) {
+ FileGenerator file_generator(file, file_options);
+
+ // Generate header(s).
+ if (file_options.proto_h) {
std::unique_ptr<io::ZeroCopyOutputStream> output(
- generator_context->Open(basename + ".proto.h"));
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
+ generator_context->Open(basename + ".proto.h"));
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
TProtoStringType info_path = basename + ".proto.h.meta";
io::Printer printer(
output.get(), '$',
file_options.annotate_headers ? &annotation_collector : NULL);
- file_generator.GenerateProtoHeader(
- &printer, file_options.annotate_headers ? info_path : "");
- if (file_options.annotate_headers) {
+ file_generator.GenerateProtoHeader(
+ &printer, file_options.annotate_headers ? info_path : "");
+ if (file_options.annotate_headers) {
std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- generator_context->Open(info_path));
- annotations.SerializeToZeroCopyStream(info_output.get());
- }
- }
-
- {
+ generator_context->Open(info_path));
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ }
+ }
+
+ {
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(basename + ".pb.h"));
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
TProtoStringType info_path = basename + ".pb.h.meta";
io::Printer printer(
output.get(), '$',
file_options.annotate_headers ? &annotation_collector : NULL);
- file_generator.GeneratePBHeader(
- &printer, file_options.annotate_headers ? info_path : "");
- if (file_options.annotate_headers) {
+ file_generator.GeneratePBHeader(
+ &printer, file_options.annotate_headers ? info_path : "");
+ if (file_options.annotate_headers) {
std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- generator_context->Open(info_path));
- annotations.SerializeToZeroCopyStream(info_output.get());
- }
- }
-
+ generator_context->Open(info_path));
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ }
+ }
+
// Generate cc file(s).
if (UsingImplicitWeakFields(file, file_options)) {
{
@@ -226,14 +226,14 @@ bool CppGenerator::Generate(const FileDescriptor* file,
} else {
std::unique_ptr<io::ZeroCopyOutputStream> output(
generator_context->Open(basename + ".pb.cc"));
- io::Printer printer(output.get(), '$');
- file_generator.GenerateSource(&printer);
- }
-
- return true;
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ io::Printer printer(output.get(), '$');
+ file_generator.GenerateSource(&printer);
+ }
+
+ return true;
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
index 235d02325f0..413b39f139f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.h
@@ -1,61 +1,61 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Generates C++ code for a given .proto file.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Generates C++ code for a given .proto file.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
+
#include <string>
#include <google/protobuf/compiler/code_generator.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-// CodeGenerator implementation which generates a C++ source file and
-// header. If you create your own protocol compiler binary and you want
-// it to support C++ output, you can do so by registering an instance of this
-// CodeGenerator with the CommandLineInterface in your main() function.
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+// CodeGenerator implementation which generates a C++ source file and
+// header. If you create your own protocol compiler binary and you want
+// it to support C++ output, you can do so by registering an instance of this
+// CodeGenerator with the CommandLineInterface in your main() function.
class PROTOC_EXPORT CppGenerator : public CodeGenerator {
- public:
- CppGenerator();
- ~CppGenerator();
-
+ public:
+ CppGenerator();
+ ~CppGenerator();
+
enum class Runtime {
kGoogle3, // Use the internal google3 runtime.
kOpensource, // Use the open-source runtime.
@@ -79,28 +79,28 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
runtime_include_base_ = base;
}
- // implements CodeGenerator ----------------------------------------
+ // implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
- GeneratorContext* generator_context,
+ GeneratorContext* generator_context,
TProtoStringType* error) const override;
-
+
uint64_t GetSupportedFeatures() const override {
// We don't fully support this yet, but this is needed to unblock the tests,
// and we will have full support before the experimental flag is removed.
return FEATURE_PROTO3_OPTIONAL;
}
- private:
+ private:
bool opensource_runtime_ = true;
TProtoStringType runtime_include_base_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index 0f9660d2374..d0bb537b925 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -1,47 +1,47 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <cstdint>
#include <functional>
-#include <limits>
-#include <map>
+#include <limits>
+#include <map>
#include <queue>
#include <unordered_set>
-#include <vector>
-
+#include <vector>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
@@ -57,23 +57,23 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/hash.h>
-
+
#include <google/protobuf/port_def.inc>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-
-static const char kAnyMessageName[] = "Any";
-static const char kAnyProtoFile[] = "google/protobuf/any.proto";
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+namespace {
+
+static const char kAnyMessageName[] = "Any";
+static const char kAnyProtoFile[] = "google/protobuf/any.proto";
+
TProtoStringType DotsToColons(const TProtoStringType& name) {
- return StringReplace(name, ".", "::", true);
-}
-
+ return StringReplace(name, ".", "::", true);
+}
+
static const char* const kKeywordList[] = { //
"NULL",
"alignas",
@@ -158,17 +158,17 @@ static const char* const kKeywordList[] = { //
"while",
"xor",
"xor_eq"};
-
+
static std::unordered_set<TProtoStringType>* MakeKeywordsMap() {
auto* result = new std::unordered_set<TProtoStringType>();
for (const auto keyword : kKeywordList) {
result->emplace(keyword);
- }
- return result;
-}
-
+ }
+ return result;
+}
+
static std::unordered_set<TProtoStringType>& kKeywords = *MakeKeywordsMap();
-
+
// Encode [0..63] as 'A'-'Z', 'a'-'z', '0'-'9', '_'
char Base63Char(int value) {
GOOGLE_CHECK_GE(value, 0);
@@ -189,7 +189,7 @@ TProtoStringType Base63(I n, int k) {
while (k-- > 0) {
res += Base63Char(static_cast<int>(n % 63));
n /= 63;
- }
+ }
return res;
}
@@ -198,9 +198,9 @@ TProtoStringType IntTypeName(const Options& options, const TProtoStringType& typ
return "::PROTOBUF_NAMESPACE_ID::" + type;
} else {
return "::" + type;
- }
-}
-
+ }
+}
+
void SetIntVar(const Options& options, const TProtoStringType& type,
std::map<TProtoStringType, TProtoStringType>* variables) {
(*variables)[type] = IntTypeName(options, type);
@@ -211,8 +211,8 @@ bool IsEagerlyVerifiedLazyImpl(const FieldDescriptor* field,
return false;
}
-} // namespace
-
+} // namespace
+
bool IsLazy(const FieldDescriptor* field, const Options& options,
MessageSCCAnalyzer* scc_analyzer) {
return IsLazilyVerifiedLazy(field, options) ||
@@ -284,34 +284,34 @@ void SetUnknownFieldsVariable(const Descriptor* descriptor,
TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
bool cap_next_letter) {
TProtoStringType result;
- // Note: I distrust ctype.h due to locales.
- for (int i = 0; i < input.size(); i++) {
- if ('a' <= input[i] && input[i] <= 'z') {
- if (cap_next_letter) {
- result += input[i] + ('A' - 'a');
- } else {
- result += input[i];
- }
- cap_next_letter = false;
- } else if ('A' <= input[i] && input[i] <= 'Z') {
- // Capital letters are left as-is.
- result += input[i];
- cap_next_letter = false;
- } else if ('0' <= input[i] && input[i] <= '9') {
- result += input[i];
- cap_next_letter = true;
- } else {
- cap_next_letter = true;
- }
- }
- return result;
-}
-
-const char kThickSeparator[] =
+ // Note: I distrust ctype.h due to locales.
+ for (int i = 0; i < input.size(); i++) {
+ if ('a' <= input[i] && input[i] <= 'z') {
+ if (cap_next_letter) {
+ result += input[i] + ('A' - 'a');
+ } else {
+ result += input[i];
+ }
+ cap_next_letter = false;
+ } else if ('A' <= input[i] && input[i] <= 'Z') {
+ // Capital letters are left as-is.
+ result += input[i];
+ cap_next_letter = false;
+ } else if ('0' <= input[i] && input[i] <= '9') {
+ result += input[i];
+ cap_next_letter = true;
+ } else {
+ cap_next_letter = true;
+ }
+ }
+ return result;
+}
+
+const char kThickSeparator[] =
"// ===================================================================\n";
-const char kThinSeparator[] =
+const char kThinSeparator[] =
"// -------------------------------------------------------------------\n";
-
+
bool CanInitializeByZeroing(const FieldDescriptor* field) {
if (field->is_repeated() || field->is_extension()) return false;
switch (field->cpp_type()) {
@@ -335,7 +335,7 @@ bool CanInitializeByZeroing(const FieldDescriptor* field) {
return false;
}
}
-
+
TProtoStringType ClassName(const Descriptor* descriptor) {
const Descriptor* parent = descriptor->containing_type();
TProtoStringType res;
@@ -344,16 +344,16 @@ TProtoStringType ClassName(const Descriptor* descriptor) {
if (IsMapEntryMessage(descriptor)) res += "_DoNotUse";
return ResolveKeyword(res);
}
-
+
TProtoStringType ClassName(const EnumDescriptor* enum_descriptor) {
if (enum_descriptor->containing_type() == nullptr) {
return ResolveKeyword(enum_descriptor->name());
- } else {
+ } else {
return ClassName(enum_descriptor->containing_type()) + "_" +
enum_descriptor->name();
- }
-}
-
+ }
+}
+
TProtoStringType QualifiedClassName(const Descriptor* d, const Options& options) {
return QualifiedFileLevelSymbol(d->file(), ClassName(d), options);
}
@@ -401,32 +401,32 @@ TProtoStringType Namespace(const FileDescriptor* d, const Options& options) {
"::google::"
"protobuf",
"PROTOBUF_NAMESPACE_ID", false);
- }
+ }
return ret;
-}
-
+}
+
TProtoStringType Namespace(const Descriptor* d, const Options& options) {
return Namespace(d->file(), options);
}
-
+
TProtoStringType Namespace(const FieldDescriptor* d, const Options& options) {
return Namespace(d->file(), options);
-}
-
+}
+
TProtoStringType Namespace(const EnumDescriptor* d, const Options& options) {
return Namespace(d->file(), options);
-}
-
+}
+
TProtoStringType DefaultInstanceType(const Descriptor* descriptor,
const Options& options) {
return ClassName(descriptor) + "DefaultTypeInternal";
-}
-
+}
+
TProtoStringType DefaultInstanceName(const Descriptor* descriptor,
const Options& options) {
return "_" + ClassName(descriptor, false) + "_default_instance_";
-}
-
+}
+
TProtoStringType DefaultInstancePtr(const Descriptor* descriptor,
const Options& options) {
return DefaultInstanceName(descriptor, options) + "ptr_";
@@ -468,28 +468,28 @@ TProtoStringType ResolveKeyword(const TProtoStringType& name) {
TProtoStringType FieldName(const FieldDescriptor* field) {
TProtoStringType result = field->name();
- LowerString(&result);
- if (kKeywords.count(result) > 0) {
- result.append("_");
- }
- return result;
-}
-
+ LowerString(&result);
+ if (kKeywords.count(result) > 0) {
+ result.append("_");
+ }
+ return result;
+}
+
TProtoStringType EnumValueName(const EnumValueDescriptor* enum_value) {
TProtoStringType result = enum_value->name();
- if (kKeywords.count(result) > 0) {
- result.append("_");
- }
- return result;
-}
-
+ if (kKeywords.count(result) > 0) {
+ result.append("_");
+ }
+ return result;
+}
+
int EstimateAlignmentSize(const FieldDescriptor* field) {
if (field == nullptr) return 0;
if (field->is_repeated()) return 8;
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_BOOL:
return 1;
-
+
case FieldDescriptor::CPPTYPE_INT32:
case FieldDescriptor::CPPTYPE_UINT32:
case FieldDescriptor::CPPTYPE_ENUM:
@@ -511,33 +511,33 @@ TProtoStringType FieldConstantName(const FieldDescriptor* field) {
TProtoStringType field_name = UnderscoresToCamelCase(field->name(), true);
TProtoStringType result = "k" + field_name + "FieldNumber";
- if (!field->is_extension() &&
- field->containing_type()->FindFieldByCamelcaseName(
+ if (!field->is_extension() &&
+ field->containing_type()->FindFieldByCamelcaseName(
field->camelcase_name()) != field) {
- // This field's camelcase name is not unique. As a hack, add the field
- // number to the constant name. This makes the constant rather useless,
- // but what can we do?
+ // This field's camelcase name is not unique. As a hack, add the field
+ // number to the constant name. This makes the constant rather useless,
+ // but what can we do?
result += "_" + StrCat(field->number());
- }
-
- return result;
-}
-
+ }
+
+ return result;
+}
+
TProtoStringType FieldMessageTypeName(const FieldDescriptor* field,
const Options& options) {
// Note: The Google-internal version of Protocol Buffers uses this function
// as a hook point for hacks to support legacy code.
return QualifiedClassName(field->message_type(), options);
-}
-
+}
+
TProtoStringType StripProto(const TProtoStringType& filename) {
/*
* TODO(github/georgthegreat) remove this proxy method
* once Google's internal codebase will become ready
*/
return compiler::StripProto(filename);
-}
-
+}
+
const char* PrimitiveTypeName(FieldDescriptor::CppType type) {
switch (type) {
case FieldDescriptor::CPPTYPE_INT32:
@@ -560,18 +560,18 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type) {
return "TProtoStringType";
case FieldDescriptor::CPPTYPE_MESSAGE:
return nullptr;
-
+
// No default because we want the compiler to complain if any new
// CppTypes are added.
- }
+ }
GOOGLE_LOG(FATAL) << "Can't get here.";
return nullptr;
-}
-
+}
+
TProtoStringType PrimitiveTypeName(const Options& options,
FieldDescriptor::CppType type) {
- switch (type) {
+ switch (type) {
case FieldDescriptor::CPPTYPE_INT32:
return IntTypeName(options, "int32");
case FieldDescriptor::CPPTYPE_INT64:
@@ -592,17 +592,17 @@ TProtoStringType PrimitiveTypeName(const Options& options,
return "TProtoStringType";
case FieldDescriptor::CPPTYPE_MESSAGE:
return "";
-
+
// No default because we want the compiler to complain if any new
// CppTypes are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
return "";
-}
-
-const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
- switch (type) {
+}
+
+const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
+ switch (type) {
case FieldDescriptor::TYPE_INT32:
return "Int32";
case FieldDescriptor::TYPE_INT64:
@@ -627,12 +627,12 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
return "Float";
case FieldDescriptor::TYPE_DOUBLE:
return "Double";
-
+
case FieldDescriptor::TYPE_BOOL:
return "Bool";
case FieldDescriptor::TYPE_ENUM:
return "Enum";
-
+
case FieldDescriptor::TYPE_STRING:
return "String";
case FieldDescriptor::TYPE_BYTES:
@@ -641,33 +641,33 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type) {
return "Group";
case FieldDescriptor::TYPE_MESSAGE:
return "Message";
-
+
// No default because we want the compiler to complain if any new
// types are added.
- }
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return "";
-}
-
+ }
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return "";
+}
+
TProtoStringType Int32ToString(int number) {
if (number == std::numeric_limits<int32_t>::min()) {
// This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
return StrCat(number + 1, " - 1");
- } else {
+ } else {
return StrCat(number);
- }
-}
-
+ }
+}
+
static TProtoStringType Int64ToString(int64_t number) {
if (number == std::numeric_limits<int64_t>::min()) {
// This needs to be special-cased, see explanation here:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661
return StrCat("int64_t{", number + 1, "} - 1");
- }
+ }
return StrCat("int64_t{", number, "}");
-}
-
+}
+
static TProtoStringType UInt64ToString(uint64_t number) {
return StrCat("uint64_t{", number, "u}");
}
@@ -677,27 +677,27 @@ TProtoStringType DefaultValue(const FieldDescriptor* field) {
}
TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* field) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- return Int32ToString(field->default_value_int32());
- case FieldDescriptor::CPPTYPE_UINT32:
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ return Int32ToString(field->default_value_int32());
+ case FieldDescriptor::CPPTYPE_UINT32:
return StrCat(field->default_value_uint32()) + "u";
- case FieldDescriptor::CPPTYPE_INT64:
+ case FieldDescriptor::CPPTYPE_INT64:
return Int64ToString(field->default_value_int64());
- case FieldDescriptor::CPPTYPE_UINT64:
+ case FieldDescriptor::CPPTYPE_UINT64:
return UInt64ToString(field->default_value_uint64());
- case FieldDescriptor::CPPTYPE_DOUBLE: {
- double value = field->default_value_double();
+ case FieldDescriptor::CPPTYPE_DOUBLE: {
+ double value = field->default_value_double();
if (value == std::numeric_limits<double>::infinity()) {
return "std::numeric_limits<double>::infinity()";
} else if (value == -std::numeric_limits<double>::infinity()) {
return "-std::numeric_limits<double>::infinity()";
- } else if (value != value) {
+ } else if (value != value) {
return "std::numeric_limits<double>::quiet_NaN()";
- } else {
- return SimpleDtoa(value);
- }
- }
+ } else {
+ return SimpleDtoa(value);
+ }
+ }
case FieldDescriptor::CPPTYPE_FLOAT: {
float value = field->default_value_float();
if (value == std::numeric_limits<float>::infinity()) {
@@ -713,96 +713,96 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie
// literal.
if (float_value.find_first_of(".eE") != TProtoStringType::npos) {
float_value.push_back('f');
- }
+ }
return float_value;
- }
+ }
}
- case FieldDescriptor::CPPTYPE_BOOL:
- return field->default_value_bool() ? "true" : "false";
- case FieldDescriptor::CPPTYPE_ENUM:
- // Lazy: Generate a static_cast because we don't have a helper function
- // that constructs the full name of an enum value.
- return strings::Substitute(
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field->default_value_bool() ? "true" : "false";
+ case FieldDescriptor::CPPTYPE_ENUM:
+ // Lazy: Generate a static_cast because we don't have a helper function
+ // that constructs the full name of an enum value.
+ return strings::Substitute(
"static_cast< $0 >($1)", ClassName(field->enum_type(), true),
- Int32ToString(field->default_value_enum()->number()));
- case FieldDescriptor::CPPTYPE_STRING:
+ Int32ToString(field->default_value_enum()->number()));
+ case FieldDescriptor::CPPTYPE_STRING:
return "\"" +
EscapeTrigraphs(CEscape(field->default_value_string())) +
"\"";
- case FieldDescriptor::CPPTYPE_MESSAGE:
+ case FieldDescriptor::CPPTYPE_MESSAGE:
return "*" + FieldMessageTypeName(field, options) +
"::internal_default_instance()";
- }
- // Can't actually get here; make compiler happy. (We could add a default
- // case above but then we wouldn't get the nice compiler warning when a
- // new type is added.)
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return "";
-}
-
-// Convert a file name into a valid identifier.
+ }
+ // Can't actually get here; make compiler happy. (We could add a default
+ // case above but then we wouldn't get the nice compiler warning when a
+ // new type is added.)
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return "";
+}
+
+// Convert a file name into a valid identifier.
TProtoStringType FilenameIdentifier(const TProtoStringType& filename) {
TProtoStringType result;
- for (int i = 0; i < filename.size(); i++) {
- if (ascii_isalnum(filename[i])) {
- result.push_back(filename[i]);
- } else {
- // Not alphanumeric. To avoid any possibility of name conflicts we
- // use the hex code for the character.
+ for (int i = 0; i < filename.size(); i++) {
+ if (ascii_isalnum(filename[i])) {
+ result.push_back(filename[i]);
+ } else {
+ // Not alphanumeric. To avoid any possibility of name conflicts we
+ // use the hex code for the character.
StrAppend(&result, "_",
strings::Hex(static_cast<uint8_t>(filename[i])));
- }
- }
- return result;
-}
-
+ }
+ }
+ return result;
+}
+
TProtoStringType UniqueName(const TProtoStringType& name, const TProtoStringType& filename,
const Options& options) {
return name + "_" + FilenameIdentifier(filename);
-}
-
-// Return the qualified C++ name for a file level symbol.
+}
+
+// Return the qualified C++ name for a file level symbol.
TProtoStringType QualifiedFileLevelSymbol(const FileDescriptor* file,
const TProtoStringType& name,
const Options& options) {
if (file->package().empty()) {
- return StrCat("::", name);
- }
+ return StrCat("::", name);
+ }
return StrCat(Namespace(file, options), "::", name);
-}
-
-// Escape C++ trigraphs by escaping question marks to \?
+}
+
+// Escape C++ trigraphs by escaping question marks to \?
TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape) {
- return StringReplace(to_escape, "?", "\\?", true);
-}
-
-// Escaped function name to eliminate naming conflict.
+ return StringReplace(to_escape, "?", "\\?", true);
+}
+
+// Escaped function name to eliminate naming conflict.
TProtoStringType SafeFunctionName(const Descriptor* descriptor,
const FieldDescriptor* field,
const TProtoStringType& prefix) {
- // Do not use FieldName() since it will escape keywords.
+ // Do not use FieldName() since it will escape keywords.
TProtoStringType name = field->name();
- LowerString(&name);
+ LowerString(&name);
TProtoStringType function_name = prefix + name;
- if (descriptor->FindFieldByName(function_name)) {
- // Single underscore will also make it conflicting with the private data
- // member. We use double underscore to escape function names.
- function_name.append("__");
- } else if (kKeywords.count(name) > 0) {
- // If the field name is a keyword, we append the underscore back to keep it
- // consistent with other function names.
- function_name.append("_");
- }
- return function_name;
-}
-
+ if (descriptor->FindFieldByName(function_name)) {
+ // Single underscore will also make it conflicting with the private data
+ // member. We use double underscore to escape function names.
+ function_name.append("__");
+ } else if (kKeywords.count(name) > 0) {
+ // If the field name is a keyword, we append the underscore back to keep it
+ // consistent with other function names.
+ function_name.append("_");
+ }
+ return function_name;
+}
+
static bool HasLazyFields(const Descriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer) {
for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) {
if (IsLazy(descriptor->field(field_idx), options, scc_analyzer)) {
return true;
}
- }
+ }
for (int idx = 0; idx < descriptor->extension_count(); idx++) {
if (IsLazy(descriptor->extension(idx), options, scc_analyzer)) {
return true;
@@ -846,7 +846,7 @@ static bool HasRepeatedFields(const Descriptor* descriptor) {
}
bool HasRepeatedFields(const FileDescriptor* file) {
- for (int i = 0; i < file->message_type_count(); ++i) {
+ for (int i = 0; i < file->message_type_count(); ++i) {
if (HasRepeatedFields(file->message_type(i))) return true;
}
return false;
@@ -904,12 +904,12 @@ static bool HasExtensionsOrExtendableMessage(const Descriptor* descriptor) {
if (descriptor->extension_count() > 0) return true;
for (int i = 0; i < descriptor->nested_type_count(); ++i) {
if (HasExtensionsOrExtendableMessage(descriptor->nested_type(i))) {
- return true;
- }
- }
- return false;
-}
-
+ return true;
+ }
+ }
+ return false;
+}
+
bool HasExtensionsOrExtendableMessage(const FileDescriptor* file) {
if (file->extension_count() > 0) return true;
for (int i = 0; i < file->message_type_count(); ++i) {
@@ -917,65 +917,65 @@ bool HasExtensionsOrExtendableMessage(const FileDescriptor* file) {
}
return false;
}
-
-static bool HasMapFields(const Descriptor* descriptor) {
- for (int i = 0; i < descriptor->field_count(); ++i) {
- if (descriptor->field(i)->is_map()) {
- return true;
- }
- }
- for (int i = 0; i < descriptor->nested_type_count(); ++i) {
- if (HasMapFields(descriptor->nested_type(i))) return true;
- }
- return false;
-}
-
-bool HasMapFields(const FileDescriptor* file) {
- for (int i = 0; i < file->message_type_count(); ++i) {
- if (HasMapFields(file->message_type(i))) return true;
- }
- return false;
-}
-
-static bool HasEnumDefinitions(const Descriptor* message_type) {
- if (message_type->enum_type_count() > 0) return true;
- for (int i = 0; i < message_type->nested_type_count(); ++i) {
- if (HasEnumDefinitions(message_type->nested_type(i))) return true;
- }
- return false;
-}
-
-bool HasEnumDefinitions(const FileDescriptor* file) {
- if (file->enum_type_count() > 0) return true;
- for (int i = 0; i < file->message_type_count(); ++i) {
- if (HasEnumDefinitions(file->message_type(i))) return true;
- }
- return false;
-}
-
-bool IsStringOrMessage(const FieldDescriptor* field) {
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- case FieldDescriptor::CPPTYPE_INT64:
- case FieldDescriptor::CPPTYPE_UINT32:
- case FieldDescriptor::CPPTYPE_UINT64:
- case FieldDescriptor::CPPTYPE_DOUBLE:
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_BOOL:
- case FieldDescriptor::CPPTYPE_ENUM:
- return false;
- case FieldDescriptor::CPPTYPE_STRING:
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return true;
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return false;
-}
-
+
+static bool HasMapFields(const Descriptor* descriptor) {
+ for (int i = 0; i < descriptor->field_count(); ++i) {
+ if (descriptor->field(i)->is_map()) {
+ return true;
+ }
+ }
+ for (int i = 0; i < descriptor->nested_type_count(); ++i) {
+ if (HasMapFields(descriptor->nested_type(i))) return true;
+ }
+ return false;
+}
+
+bool HasMapFields(const FileDescriptor* file) {
+ for (int i = 0; i < file->message_type_count(); ++i) {
+ if (HasMapFields(file->message_type(i))) return true;
+ }
+ return false;
+}
+
+static bool HasEnumDefinitions(const Descriptor* message_type) {
+ if (message_type->enum_type_count() > 0) return true;
+ for (int i = 0; i < message_type->nested_type_count(); ++i) {
+ if (HasEnumDefinitions(message_type->nested_type(i))) return true;
+ }
+ return false;
+}
+
+bool HasEnumDefinitions(const FileDescriptor* file) {
+ if (file->enum_type_count() > 0) return true;
+ for (int i = 0; i < file->message_type_count(); ++i) {
+ if (HasEnumDefinitions(file->message_type(i))) return true;
+ }
+ return false;
+}
+
+bool IsStringOrMessage(const FieldDescriptor* field) {
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ case FieldDescriptor::CPPTYPE_INT64:
+ case FieldDescriptor::CPPTYPE_UINT32:
+ case FieldDescriptor::CPPTYPE_UINT64:
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ case FieldDescriptor::CPPTYPE_BOOL:
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return false;
+ case FieldDescriptor::CPPTYPE_STRING:
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return true;
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return false;
+}
+
FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
const Options& options) {
- GOOGLE_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);
+ GOOGLE_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);
if (options.opensource_runtime) {
// Open-source protobuf release only supports STRING ctype.
return FieldOptions::STRING;
@@ -983,17 +983,17 @@ FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
// Google-internal supports all ctypes.
return field->options().ctype();
}
-}
-
+}
+
bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options) {
- return descriptor->name() == kAnyProtoFile;
-}
-
+ return descriptor->name() == kAnyProtoFile;
+}
+
bool IsAnyMessage(const Descriptor* descriptor, const Options& options) {
- return descriptor->name() == kAnyMessageName &&
+ return descriptor->name() == kAnyMessageName &&
IsAnyMessage(descriptor->file(), options);
-}
-
+}
+
bool IsWellKnownMessage(const FileDescriptor* file) {
static const std::unordered_set<TProtoStringType> well_known_files{
"google/protobuf/any.proto",
@@ -1010,95 +1010,95 @@ bool IsWellKnownMessage(const FileDescriptor* file) {
"google/protobuf/wrappers.proto",
};
return well_known_files.find(file->name()) != well_known_files.end();
-}
-
+}
+
static bool FieldEnforceUtf8(const FieldDescriptor* field,
const Options& options) {
return true;
}
-
+
static bool FileUtf8Verification(const FileDescriptor* file,
const Options& options) {
return true;
}
-// Which level of UTF-8 enforcemant is placed on this file.
+// Which level of UTF-8 enforcemant is placed on this file.
Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,
const Options& options) {
if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
FieldEnforceUtf8(field, options)) {
return Utf8CheckMode::kStrict;
- } else if (GetOptimizeFor(field->file(), options) !=
+ } else if (GetOptimizeFor(field->file(), options) !=
FileOptions::LITE_RUNTIME &&
FileUtf8Verification(field->file(), options)) {
return Utf8CheckMode::kVerify;
- } else {
+ } else {
return Utf8CheckMode::kNone;
- }
-}
-
-static void GenerateUtf8CheckCode(const FieldDescriptor* field,
- const Options& options, bool for_parse,
- const char* parameters,
- const char* strict_function,
- const char* verify_function,
+ }
+}
+
+static void GenerateUtf8CheckCode(const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ const char* parameters,
+ const char* strict_function,
+ const char* verify_function,
const Formatter& format) {
- switch (GetUtf8CheckMode(field, options)) {
+ switch (GetUtf8CheckMode(field, options)) {
case Utf8CheckMode::kStrict: {
- if (for_parse) {
+ if (for_parse) {
format("DO_(");
- }
+ }
format("::$proto_ns$::internal::WireFormatLite::$1$(\n", strict_function);
format.Indent();
format(parameters);
- if (for_parse) {
+ if (for_parse) {
format("::$proto_ns$::internal::WireFormatLite::PARSE,\n");
- } else {
+ } else {
format("::$proto_ns$::internal::WireFormatLite::SERIALIZE,\n");
- }
+ }
format("\"$1$\")", field->full_name());
- if (for_parse) {
+ if (for_parse) {
format(")");
- }
+ }
format(";\n");
format.Outdent();
- break;
- }
+ break;
+ }
case Utf8CheckMode::kVerify: {
format("::$proto_ns$::internal::WireFormat::$1$(\n", verify_function);
format.Indent();
format(parameters);
- if (for_parse) {
+ if (for_parse) {
format("::$proto_ns$::internal::WireFormat::PARSE,\n");
- } else {
+ } else {
format("::$proto_ns$::internal::WireFormat::SERIALIZE,\n");
- }
+ }
format("\"$1$\");\n", field->full_name());
format.Outdent();
- break;
- }
+ break;
+ }
case Utf8CheckMode::kNone:
- break;
- }
-}
-
-void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
- const Options& options, bool for_parse,
- const char* parameters,
+ break;
+ }
+}
+
+void GenerateUtf8CheckCodeForString(const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ const char* parameters,
const Formatter& format) {
GenerateUtf8CheckCode(field, options, for_parse, parameters,
- "VerifyUtf8String", "VerifyUTF8StringNamedField",
+ "VerifyUtf8String", "VerifyUTF8StringNamedField",
format);
-}
-
-void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
- const Options& options, bool for_parse,
- const char* parameters,
+}
+
+void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
+ const Options& options, bool for_parse,
+ const char* parameters,
const Formatter& format) {
GenerateUtf8CheckCode(field, options, for_parse, parameters, "VerifyUtf8Cord",
"VerifyUTF8CordNamedField", format);
-}
-
+}
+
namespace {
void Flatten(const Descriptor* descriptor,
@@ -1481,7 +1481,7 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
return FileOptions::SPEED;
}
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
index 1cc9329c86f..866b2019e9e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -1,44 +1,44 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
+
#include <algorithm>
#include <cstdint>
#include <iterator>
-#include <map>
+#include <map>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_options.h>
@@ -50,23 +50,23 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/port.h>
#include <google/protobuf/stubs/strutil.h>
-
+
// Must be included last.
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
+namespace google {
+namespace protobuf {
namespace compiler {
namespace cpp {
-
+
inline TProtoStringType ProtobufNamespace(const Options& /* options */) {
return "PROTOBUF_NAMESPACE_ID";
-}
-
+}
+
inline TProtoStringType MacroPrefix(const Options& options) {
return options.opensource_runtime ? "GOOGLE_PROTOBUF" : "GOOGLE_PROTOBUF";
}
-
+
inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
const FieldDescriptor* d) {
return d->options().deprecated() ? "PROTOBUF_DEPRECATED " : "";
@@ -77,11 +77,11 @@ inline TProtoStringType DeprecatedAttribute(const Options& /* options */,
return d->options().deprecated() ? "PROTOBUF_DEPRECATED_ENUM " : "";
}
-// Commonly-used separator comments. Thick is a line of '=', thin is a line
-// of '-'.
-extern const char kThickSeparator[];
-extern const char kThinSeparator[];
-
+// Commonly-used separator comments. Thick is a line of '=', thin is a line
+// of '-'.
+extern const char kThickSeparator[];
+extern const char kThinSeparator[];
+
void SetCommonVars(const Options& options,
std::map<TProtoStringType, TProtoStringType>* variables);
@@ -118,19 +118,19 @@ TProtoStringType QualifiedClassName(const EnumDescriptor* d);
// DEPRECATED just use ClassName or QualifiedClassName, a boolean is very
// unreadable at the callsite.
-// Returns the non-nested type name for the given type. If "qualified" is
-// true, prefix the type with the full namespace. For example, if you had:
-// package foo.bar;
-// message Baz { message Qux {} }
-// Then the qualified ClassName for Qux would be:
-// ::foo::bar::Baz_Qux
-// While the non-qualified version would be:
-// Baz_Qux
+// Returns the non-nested type name for the given type. If "qualified" is
+// true, prefix the type with the full namespace. For example, if you had:
+// package foo.bar;
+// message Baz { message Qux {} }
+// Then the qualified ClassName for Qux would be:
+// ::foo::bar::Baz_Qux
+// While the non-qualified version would be:
+// Baz_Qux
inline TProtoStringType ClassName(const Descriptor* descriptor, bool qualified) {
return qualified ? QualifiedClassName(descriptor, Options())
: ClassName(descriptor);
}
-
+
inline TProtoStringType ClassName(const EnumDescriptor* descriptor, bool qualified) {
return qualified ? QualifiedClassName(descriptor, Options())
: ClassName(descriptor);
@@ -164,15 +164,15 @@ TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor,
// Fully qualified name of the default instance pointer.
TProtoStringType QualifiedDefaultInstancePtr(const Descriptor* descriptor,
const Options& options);
-
+
// DescriptorTable variable name.
TProtoStringType DescriptorTableName(const FileDescriptor* file,
const Options& options);
-
+
// When declaring symbol externs from another file, this macro will supply the
// dllexport needed for the target file, if any.
TProtoStringType FileDllExport(const FileDescriptor* file, const Options& options);
-
+
// Name of the base class: google::protobuf::Message or google::protobuf::MessageLite.
TProtoStringType SuperClassName(const Descriptor* descriptor,
const Options& options);
@@ -180,55 +180,55 @@ TProtoStringType SuperClassName(const Descriptor* descriptor,
// Adds an underscore if necessary to prevent conflicting with a keyword.
TProtoStringType ResolveKeyword(const TProtoStringType& name);
-// Get the (unqualified) name that should be used for this field in C++ code.
-// The name is coerced to lower-case to emulate proto1 behavior. People
-// should be using lowercase-with-underscores style for proto field names
-// anyway, so normally this just returns field->name().
+// Get the (unqualified) name that should be used for this field in C++ code.
+// The name is coerced to lower-case to emulate proto1 behavior. People
+// should be using lowercase-with-underscores style for proto field names
+// anyway, so normally this just returns field->name().
TProtoStringType FieldName(const FieldDescriptor* field);
-
+
// Returns an estimate of the compiler's alignment for the field. This
// can't guarantee to be correct because the generated code could be compiled on
// different systems with different alignment rules. The estimates below assume
// 64-bit pointers.
int EstimateAlignmentSize(const FieldDescriptor* field);
-// Get the unqualified name that should be used for a field's field
-// number constant.
+// Get the unqualified name that should be used for a field's field
+// number constant.
TProtoStringType FieldConstantName(const FieldDescriptor* field);
-
-// Returns the scope where the field was defined (for extensions, this is
-// different from the message type to which the field applies).
-inline const Descriptor* FieldScope(const FieldDescriptor* field) {
+
+// Returns the scope where the field was defined (for extensions, this is
+// different from the message type to which the field applies).
+inline const Descriptor* FieldScope(const FieldDescriptor* field) {
return field->is_extension() ? field->extension_scope()
: field->containing_type();
-}
-
-// Returns the fully-qualified type name field->message_type(). Usually this
-// is just ClassName(field->message_type(), true);
+}
+
+// Returns the fully-qualified type name field->message_type(). Usually this
+// is just ClassName(field->message_type(), true);
TProtoStringType FieldMessageTypeName(const FieldDescriptor* field,
const Options& options);
-
-// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
-const char* PrimitiveTypeName(FieldDescriptor::CppType type);
+
+// Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.).
+const char* PrimitiveTypeName(FieldDescriptor::CppType type);
TProtoStringType PrimitiveTypeName(const Options& options,
FieldDescriptor::CppType type);
-
-// Get the declared type name in CamelCase format, as is used e.g. for the
-// methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
-const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
-
-// Return the code that evaluates to the number when compiled.
+
+// Get the declared type name in CamelCase format, as is used e.g. for the
+// methods of WireFormat. For example, TYPE_INT32 becomes "Int32".
+const char* DeclaredTypeMethodName(FieldDescriptor::Type type);
+
+// Return the code that evaluates to the number when compiled.
TProtoStringType Int32ToString(int number);
-
-// Get code that evaluates to the field's default value.
+
+// Get code that evaluates to the field's default value.
TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* field);
-
+
// Compatibility function for callers outside proto2.
TProtoStringType DefaultValue(const FieldDescriptor* field);
-// Convert a file name into a valid identifier.
+// Convert a file name into a valid identifier.
TProtoStringType FilenameIdentifier(const TProtoStringType& filename);
-
+
// For each .proto file generates a unique name. To prevent collisions of
// symbols in the global namespace
TProtoStringType UniqueName(const TProtoStringType& name, const TProtoStringType& filename,
@@ -250,7 +250,7 @@ inline TProtoStringType UniqueName(const TProtoStringType& name,
const Options& options) {
return UniqueName(name, d->file(), options);
}
-
+
// Versions for call sites that only support the internal runtime (like proto1
// support).
inline Options InternalRuntimeOptions() {
@@ -278,35 +278,35 @@ inline TProtoStringType UniqueName(const TProtoStringType& name,
return UniqueName(name, d->file(), InternalRuntimeOptions());
}
-// Return the qualified C++ name for a file level symbol.
+// Return the qualified C++ name for a file level symbol.
TProtoStringType QualifiedFileLevelSymbol(const FileDescriptor* file,
const TProtoStringType& name,
const Options& options);
-
-// Escape C++ trigraphs by escaping question marks to \?
+
+// Escape C++ trigraphs by escaping question marks to \?
TProtoStringType EscapeTrigraphs(const TProtoStringType& to_escape);
-
-// Escaped function name to eliminate naming conflict.
+
+// Escaped function name to eliminate naming conflict.
TProtoStringType SafeFunctionName(const Descriptor* descriptor,
const FieldDescriptor* field,
const TProtoStringType& prefix);
-
+
// Returns true if generated messages have public unknown fields accessors
inline bool PublicUnknownFieldsAccessors(const Descriptor* message) {
- return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
-}
-
-// Returns the optimize mode for <file>, respecting <options.enforce_lite>.
+ return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;
+}
+
+// Returns the optimize mode for <file>, respecting <options.enforce_lite>.
FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
const Options& options);
-
+
// Determines whether unknown fields will be stored in an UnknownFieldSet or
// a string.
-inline bool UseUnknownFieldSet(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
-}
-
+inline bool UseUnknownFieldSet(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
+}
+
inline bool IsWeak(const FieldDescriptor* field, const Options& options) {
if (field->options().weak()) {
GOOGLE_CHECK(!options.opensource_runtime);
@@ -314,7 +314,7 @@ inline bool IsWeak(const FieldDescriptor* field, const Options& options) {
}
return false;
}
-
+
// For a string field, returns the effective ctype. If the actual ctype is
// not supported, returns the default of STRING.
FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
@@ -382,34 +382,34 @@ bool HasStringPieceFields(const FileDescriptor* file, const Options& options);
// include extensions, since ctype is ignored for extensions.
bool HasCordFields(const FileDescriptor* file, const Options& options);
-// Does the file have any map fields, necessitating the file to include
-// map_field_inl.h and map.h.
-bool HasMapFields(const FileDescriptor* file);
-
-// Does this file have any enum type definitions?
-bool HasEnumDefinitions(const FileDescriptor* file);
-
-// Does this file have generated parsing, serialization, and other
-// standard methods for which reflection-based fallback implementations exist?
-inline bool HasGeneratedMethods(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options) != FileOptions::CODE_SIZE;
-}
-
-// Do message classes in this file have descriptor and reflection methods?
-inline bool HasDescriptorMethods(const FileDescriptor* file,
- const Options& options) {
- return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
-}
-
-// Should we generate generic services for this file?
-inline bool HasGenericServices(const FileDescriptor* file,
- const Options& options) {
- return file->service_count() > 0 &&
- GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME &&
- file->options().cc_generic_services();
-}
-
+// Does the file have any map fields, necessitating the file to include
+// map_field_inl.h and map.h.
+bool HasMapFields(const FileDescriptor* file);
+
+// Does this file have any enum type definitions?
+bool HasEnumDefinitions(const FileDescriptor* file);
+
+// Does this file have generated parsing, serialization, and other
+// standard methods for which reflection-based fallback implementations exist?
+inline bool HasGeneratedMethods(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options) != FileOptions::CODE_SIZE;
+}
+
+// Do message classes in this file have descriptor and reflection methods?
+inline bool HasDescriptorMethods(const FileDescriptor* file,
+ const Options& options) {
+ return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;
+}
+
+// Should we generate generic services for this file?
+inline bool HasGenericServices(const FileDescriptor* file,
+ const Options& options) {
+ return file->service_count() > 0 &&
+ GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME &&
+ file->options().cc_generic_services();
+}
+
inline bool IsProto2MessageSet(const Descriptor* descriptor,
const Options& options) {
return !options.opensource_runtime &&
@@ -417,22 +417,22 @@ inline bool IsProto2MessageSet(const Descriptor* descriptor,
!options.lite_implicit_weak_fields &&
descriptor->options().message_set_wire_format() &&
descriptor->full_name() == "google.protobuf.bridge.MessageSet";
-}
-
-inline bool IsMapEntryMessage(const Descriptor* descriptor) {
- return descriptor->options().map_entry();
-}
-
-// Returns true if the field's CPPTYPE is string or message.
-bool IsStringOrMessage(const FieldDescriptor* field);
-
+}
+
+inline bool IsMapEntryMessage(const Descriptor* descriptor) {
+ return descriptor->options().map_entry();
+}
+
+// Returns true if the field's CPPTYPE is string or message.
+bool IsStringOrMessage(const FieldDescriptor* field);
+
TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
bool cap_next_letter);
-
+
inline bool IsProto3(const FileDescriptor* file) {
return file->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
+}
+
inline bool HasHasbit(const FieldDescriptor* field) {
// This predicate includes proto3 message fields only if they have "optional".
// Foo submsg1 = 1; // HasHasbit() == false
@@ -449,34 +449,34 @@ inline bool HasHasbit(const FieldDescriptor* field) {
!field->options().weak();
}
-// Returns true if 'enum' semantics are such that unknown values are preserved
-// in the enum field itself, rather than going to the UnknownFieldSet.
+// Returns true if 'enum' semantics are such that unknown values are preserved
+// in the enum field itself, rather than going to the UnknownFieldSet.
inline bool HasPreservingUnknownEnumSemantics(const FieldDescriptor* field) {
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
+}
+
inline bool IsCrossFileMessage(const FieldDescriptor* field) {
return field->type() == FieldDescriptor::TYPE_MESSAGE &&
field->message_type()->file() != field->file();
-}
-
+}
+
inline TProtoStringType MakeDefaultName(const FieldDescriptor* field) {
return "_i_give_permission_to_break_this_code_default_" + FieldName(field) +
"_";
-}
-
+}
+
bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
bool IsAnyMessage(const Descriptor* descriptor, const Options& options);
-
-bool IsWellKnownMessage(const FileDescriptor* descriptor);
-
+
+bool IsWellKnownMessage(const FileDescriptor* descriptor);
+
inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
const Options& options) {
// If we are generating a .pb.h file and the proto_h option is enabled, then
// the .pb.h gets an extra suffix.
TProtoStringType filename_identifier = FilenameIdentifier(
file->name() + (pb_h && options.proto_h ? ".pb.h" : ""));
-
+
if (IsWellKnownMessage(file)) {
// For well-known messages we need third_party/protobuf and net/proto2 to
// have distinct include guards, because some source files include both and
@@ -493,7 +493,7 @@ inline TProtoStringType IncludeGuard(const FileDescriptor* file, bool pb_h,
return "GOOGLE_PROTOBUF_INCLUDED_" + filename_identifier;
}
}
-
+
// Returns the OptimizeMode for this file, furthermore it updates a status
// bool if has_opt_codesize_extension is non-null. If this status bool is true
// it means this file contains an extension that itself is defined as
@@ -504,7 +504,7 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
inline FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file,
const Options& options) {
return GetOptimizeFor(file, options, nullptr);
-}
+}
inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file,
const Options& options) {
bool has_opt_codesize_extension;
@@ -522,7 +522,7 @@ inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file,
return false;
}
}
-
+
// This orders the messages in a .pb.cc as it's outputted by file.cc
void FlattenMessagesInFile(const FileDescriptor* file,
std::vector<const Descriptor*>* result);
@@ -886,11 +886,11 @@ PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
inline bool EnableMessageOwnedArena(const Descriptor* /* desc */ ) { return false; }
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index f8e1c380ccf..e521d4797ae 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -1,96 +1,96 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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/cpp_map_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
+
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-bool IsProto3Field(const FieldDescriptor* field_descriptor) {
- const FileDescriptor* file_descriptor = field_descriptor->file();
- return file_descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
-void SetMessageVariables(const FieldDescriptor* descriptor,
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+bool IsProto3Field(const FieldDescriptor* field_descriptor) {
+ const FileDescriptor* file_descriptor = field_descriptor->file();
+ return file_descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;
+}
+
+void SetMessageVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
+ const Options& options) {
+ SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = ClassName(descriptor->message_type(), false);
- (*variables)["full_name"] = descriptor->full_name();
-
- const FieldDescriptor* key =
- descriptor->message_type()->FindFieldByName("key");
- const FieldDescriptor* val =
- descriptor->message_type()->FindFieldByName("value");
+ (*variables)["full_name"] = descriptor->full_name();
+
+ const FieldDescriptor* key =
+ descriptor->message_type()->FindFieldByName("key");
+ const FieldDescriptor* val =
+ descriptor->message_type()->FindFieldByName("value");
(*variables)["key_cpp"] = PrimitiveTypeName(options, key->cpp_type());
- switch (val->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
+ switch (val->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
(*variables)["val_cpp"] = FieldMessageTypeName(val, options);
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
- (*variables)["val_cpp"] = ClassName(val->enum_type(), true);
- break;
- default:
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ (*variables)["val_cpp"] = ClassName(val->enum_type(), true);
+ break;
+ default:
(*variables)["val_cpp"] = PrimitiveTypeName(options, val->cpp_type());
- }
- (*variables)["key_wire_type"] =
+ }
+ (*variables)["key_wire_type"] =
"TYPE_" + ToUpper(DeclaredTypeMethodName(key->type()));
- (*variables)["val_wire_type"] =
+ (*variables)["val_wire_type"] =
"TYPE_" + ToUpper(DeclaredTypeMethodName(val->type()));
- (*variables)["map_classname"] = ClassName(descriptor->message_type(), false);
+ (*variables)["map_classname"] = ClassName(descriptor->message_type(), false);
(*variables)["number"] = StrCat(descriptor->number());
(*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
-
- if (HasDescriptorMethods(descriptor->file(), options)) {
- (*variables)["lite"] = "";
- } else {
- (*variables)["lite"] = "Lite";
- }
-}
-
-MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
+
+ if (HasDescriptorMethods(descriptor->file(), options)) {
+ (*variables)["lite"] = "";
+ } else {
+ (*variables)["lite"] = "Lite";
+ }
+}
+
+MapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options)
: FieldGenerator(descriptor, options) {
- SetMessageVariables(descriptor, &variables_, options);
-}
-
-MapFieldGenerator::~MapFieldGenerator() {}
-
+ SetMessageVariables(descriptor, &variables_, options);
+}
+
+MapFieldGenerator::~MapFieldGenerator() {}
+
void MapFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
@@ -100,8 +100,8 @@ void MapFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
" ::$proto_ns$::internal::WireFormatLite::$key_wire_type$,\n"
" ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> "
"$name$_;\n");
-}
-
+}
+
void MapFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -117,8 +117,8 @@ void MapFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
" ${1$mutable_$name$$}$();\n",
descriptor_);
-}
-
+}
+
void MapFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -128,38 +128,38 @@ void MapFieldGenerator::GenerateInlineAccessorDefinitions(
" return $name$_.GetMap();\n"
"}\n"
"inline const ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >&\n"
- "$classname$::$name$() const {\n"
+ "$classname$::$name$() const {\n"
"$annotate_get$"
- " // @@protoc_insertion_point(field_map:$full_name$)\n"
+ " // @@protoc_insertion_point(field_map:$full_name$)\n"
" return _internal_$name$();\n"
- "}\n"
+ "}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
"$classname$::_internal_mutable_$name$() {\n"
" return $name$_.MutableMap();\n"
"}\n"
"inline ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >*\n"
- "$classname$::mutable_$name$() {\n"
+ "$classname$::mutable_$name$() {\n"
"$annotate_mutable$"
- " // @@protoc_insertion_point(field_mutable_map:$full_name$)\n"
+ " // @@protoc_insertion_point(field_mutable_map:$full_name$)\n"
" return _internal_mutable_$name$();\n"
- "}\n");
-}
-
+ "}\n");
+}
+
void MapFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.Clear();\n");
-}
-
+}
+
void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n");
-}
-
+}
+
void MapFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
+}
+
void MapFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
GenerateConstructorCode(printer);
@@ -174,98 +174,98 @@ static void GenerateSerializationLoop(const Formatter& format, bool string_key,
format("for (size_type i = 0; i < n; i++) {\n");
ptr = string_key ? "items[static_cast<ptrdiff_t>(i)]"
: "items[static_cast<ptrdiff_t>(i)].second";
- } else {
+ } else {
format(
"for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n"
" it = this->_internal_$name$().begin();\n"
" it != this->_internal_$name$().end(); ++it) {\n");
ptr = "it";
- }
+ }
format.Indent();
-
+
format(
"target = $map_classname$::Funcs::InternalSerialize($number$, "
"$1$->first, $1$->second, target, stream);\n",
ptr);
-
+
if (string_key || string_value) {
// ptr is either an actual pointer or an iterator, either way we can
// create a pointer by taking the address after de-referencing it.
format("Utf8Check::Check(&(*$1$));\n", ptr);
- }
-
+ }
+
format.Outdent();
format("}\n");
-}
-
+}
+
void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("if (!this->_internal_$name$().empty()) {\n");
format.Indent();
- const FieldDescriptor* key_field =
- descriptor_->message_type()->FindFieldByName("key");
- const FieldDescriptor* value_field =
- descriptor_->message_type()->FindFieldByName("value");
- const bool string_key = key_field->type() == FieldDescriptor::TYPE_STRING;
- const bool string_value = value_field->type() == FieldDescriptor::TYPE_STRING;
-
+ const FieldDescriptor* key_field =
+ descriptor_->message_type()->FindFieldByName("key");
+ const FieldDescriptor* value_field =
+ descriptor_->message_type()->FindFieldByName("value");
+ const bool string_key = key_field->type() == FieldDescriptor::TYPE_STRING;
+ const bool string_value = value_field->type() == FieldDescriptor::TYPE_STRING;
+
format(
"typedef ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_pointer\n"
- " ConstPtr;\n");
- if (string_key) {
+ " ConstPtr;\n");
+ if (string_key) {
format(
- "typedef ConstPtr SortItem;\n"
+ "typedef ConstPtr SortItem;\n"
"typedef ::$proto_ns$::internal::"
- "CompareByDerefFirst<SortItem> Less;\n");
- } else {
+ "CompareByDerefFirst<SortItem> Less;\n");
+ } else {
format(
"typedef ::$proto_ns$::internal::SortItem< $key_cpp$, ConstPtr > "
- "SortItem;\n"
+ "SortItem;\n"
"typedef ::$proto_ns$::internal::CompareByFirstField<SortItem> "
"Less;\n");
- }
+ }
bool utf8_check = string_key || string_value;
if (utf8_check) {
format(
- "struct Utf8Check {\n"
+ "struct Utf8Check {\n"
" static void Check(ConstPtr p) {\n"
// p may be unused when GetUtf8CheckMode evaluates to kNone,
// thus disabling the validation.
" (void)p;\n");
format.Indent();
format.Indent();
- if (string_key) {
+ if (string_key) {
GenerateUtf8CheckCodeForString(
key_field, options_, false,
"p->first.data(), static_cast<int>(p->first.length()),\n", format);
- }
- if (string_value) {
+ }
+ if (string_value) {
GenerateUtf8CheckCodeForString(
value_field, options_, false,
"p->second.data(), static_cast<int>(p->second.length()),\n", format);
- }
+ }
format.Outdent();
format.Outdent();
format(
- " }\n"
- "};\n");
- }
-
+ " }\n"
+ "};\n");
+ }
+
format(
- "\n"
+ "\n"
"if (stream->IsSerializationDeterministic() &&\n"
" this->_internal_$name$().size() > 1) {\n"
" ::std::unique_ptr<SortItem[]> items(\n"
" new SortItem[this->_internal_$name$().size()]);\n"
" typedef ::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::size_type "
"size_type;\n"
- " size_type n = 0;\n"
+ " size_type n = 0;\n"
" for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n"
" it = this->_internal_$name$().begin();\n"
" it != this->_internal_$name$().end(); ++it, ++n) {\n"
" items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n"
- " }\n"
+ " }\n"
" ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n");
format.Indent();
GenerateSerializationLoop(format, string_key, string_value, true);
@@ -277,8 +277,8 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray(
format("}\n");
format.Outdent();
format("}\n");
-}
-
+}
+
void MapFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
@@ -292,7 +292,7 @@ void MapFieldGenerator::GenerateByteSize(io::Printer* printer) const {
"it->second);\n"
"}\n");
}
-
+
void MapFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -300,9 +300,9 @@ void MapFieldGenerator::GenerateConstinitInitializer(
format("$name$_(::$proto_ns$::internal::ConstantInitialized{})");
} else {
format("$name$_()");
- }
-}
-
+ }
+}
+
bool MapFieldGenerator::GenerateArenaDestructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -316,7 +316,7 @@ bool MapFieldGenerator::GenerateArenaDestructorCode(
}
}
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
index 5ea04290e61..f3c75f858f2 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.h
@@ -1,52 +1,52 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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_MAP_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__
-
-#include <map>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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_MAP_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/compiler/cpp/cpp_message_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class MapFieldGenerator : public FieldGenerator {
- public:
- MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
- ~MapFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class MapFieldGenerator : public FieldGenerator {
+ public:
+ MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options);
+ ~MapFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
void GeneratePrivateMembers(io::Printer* printer) const override;
void GenerateAccessorDeclarations(io::Printer* printer) const override;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const override;
@@ -60,14 +60,14 @@ class MapFieldGenerator : public FieldGenerator {
void GenerateByteSize(io::Printer* printer) const override;
void GenerateConstinitInitializer(io::Printer* printer) const override;
bool GenerateArenaDestructorCode(io::Printer* printer) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
index cb890d51564..1cba0ff3d54 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -1,47 +1,47 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_message.h>
-#include <algorithm>
+#include <algorithm>
#include <cstdint>
#include <functional>
-#include <map>
-#include <memory>
+#include <map>
+#include <memory>
#include <unordered_map>
-#include <utility>
-#include <vector>
+#include <utility>
+#include <vector>
#include <google/protobuf/compiler/cpp/cpp_enum.h>
#include <google/protobuf/compiler/cpp/cpp_extension.h>
@@ -59,21 +59,21 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/hash.h>
-
-
+
+
// Must be included last.
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-namespace {
-
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+namespace {
+
static constexpr int kNoHasbit = -1;
// Create an expression that evaluates to
@@ -98,8 +98,8 @@ TProtoStringType ConditionalToCheckBitmasks(
? parts[0]
: StrCat("(", Join(parts, "\n | "), ")");
return result + (return_success ? " == 0" : " != 0");
-}
-
+}
+
void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field,
const std::vector<int>& has_bit_indices,
io::Printer* printer, int* cached_has_word_index) {
@@ -118,46 +118,46 @@ void PrintPresenceCheck(const Formatter& format, const FieldDescriptor* field,
format.Indent();
}
-struct FieldOrderingByNumber {
- inline bool operator()(const FieldDescriptor* a,
- const FieldDescriptor* b) const {
- return a->number() < b->number();
- }
-};
-
-// Sort the fields of the given Descriptor by number into a new[]'d array
-// and return it.
+struct FieldOrderingByNumber {
+ inline bool operator()(const FieldDescriptor* a,
+ const FieldDescriptor* b) const {
+ return a->number() < b->number();
+ }
+};
+
+// Sort the fields of the given Descriptor by number into a new[]'d array
+// and return it.
std::vector<const FieldDescriptor*> SortFieldsByNumber(
const Descriptor* descriptor) {
std::vector<const FieldDescriptor*> fields(descriptor->field_count());
- for (int i = 0; i < descriptor->field_count(); i++) {
- fields[i] = descriptor->field(i);
- }
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ fields[i] = descriptor->field(i);
+ }
std::sort(fields.begin(), fields.end(), FieldOrderingByNumber());
- return fields;
-}
-
-// Functor for sorting extension ranges by their "start" field number.
-struct ExtensionRangeSorter {
- bool operator()(const Descriptor::ExtensionRange* left,
- const Descriptor::ExtensionRange* right) const {
- return left->start < right->start;
- }
-};
-
+ return fields;
+}
+
+// Functor for sorting extension ranges by their "start" field number.
+struct ExtensionRangeSorter {
+ bool operator()(const Descriptor::ExtensionRange* left,
+ const Descriptor::ExtensionRange* right) const {
+ return left->start < right->start;
+ }
+};
+
bool IsPOD(const FieldDescriptor* field) {
if (field->is_repeated() || field->is_extension()) return false;
- switch (field->cpp_type()) {
+ switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_ENUM:
- case FieldDescriptor::CPPTYPE_INT32:
+ case FieldDescriptor::CPPTYPE_INT32:
case FieldDescriptor::CPPTYPE_INT64:
- case FieldDescriptor::CPPTYPE_UINT32:
+ case FieldDescriptor::CPPTYPE_UINT32:
case FieldDescriptor::CPPTYPE_UINT64:
- case FieldDescriptor::CPPTYPE_FLOAT:
- case FieldDescriptor::CPPTYPE_DOUBLE:
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ case FieldDescriptor::CPPTYPE_DOUBLE:
case FieldDescriptor::CPPTYPE_BOOL:
return true;
- case FieldDescriptor::CPPTYPE_STRING:
+ case FieldDescriptor::CPPTYPE_STRING:
return false;
default:
return false;
@@ -196,33 +196,33 @@ RunMap FindRuns(const std::vector<const FieldDescriptor*>& fields,
if (last_start == nullptr) {
last_start = field;
}
-
+
runs[last_start]++;
} else {
last_start = nullptr;
- }
- }
+ }
+ }
return runs;
-}
-
-// Emits an if-statement with a condition that evaluates to true if |field| is
-// considered non-default (will be sent over the wire), for message types
-// without true field presence. Should only be called if
+}
+
+// Emits an if-statement with a condition that evaluates to true if |field| is
+// considered non-default (will be sent over the wire), for message types
+// without true field presence. Should only be called if
// !HasHasbit(field).
-bool EmitFieldNonDefaultCondition(io::Printer* printer,
+bool EmitFieldNonDefaultCondition(io::Printer* printer,
const TProtoStringType& prefix,
- const FieldDescriptor* field) {
+ const FieldDescriptor* field) {
GOOGLE_CHECK(!HasHasbit(field));
Formatter format(printer);
format.Set("prefix", prefix);
format.Set("name", FieldName(field));
- // Merge and serialize semantics: primitive fields are merged/serialized only
- // if non-zero (numeric) or non-empty (string).
- if (!field->is_repeated() && !field->containing_oneof()) {
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
+ // Merge and serialize semantics: primitive fields are merged/serialized only
+ // if non-zero (numeric) or non-empty (string).
+ if (!field->is_repeated() && !field->containing_oneof()) {
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {
format("if (!$prefix$_internal_$name$().empty()) {\n");
- } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- // Message fields still have has_$name$() methods.
+ } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
+ // Message fields still have has_$name$() methods.
format("if ($prefix$_internal_has_$name$()) {\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE ||
field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) {
@@ -230,63 +230,63 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
format(
"if (!($prefix$_internal_$name$() <= 0 && $prefix$_internal_$name$() "
">= 0)) {\n");
- } else {
+ } else {
format("if ($prefix$_internal_$name$() != 0) {\n");
- }
+ }
format.Indent();
- return true;
+ return true;
} else if (field->real_containing_oneof()) {
format("if (_internal_has_$name$()) {\n");
format.Indent();
- return true;
- }
- return false;
-}
-
-// Does the given field have a has_$name$() method?
-bool HasHasMethod(const FieldDescriptor* field) {
+ return true;
+ }
+ return false;
+}
+
+// Does the given field have a has_$name$() method?
+bool HasHasMethod(const FieldDescriptor* field) {
if (!IsProto3(field->file())) {
- // In proto1/proto2, every field has a has_$name$() method.
- return true;
- }
- // For message types without true field presence, only fields with a message
+ // In proto1/proto2, every field has a has_$name$() method.
+ return true;
+ }
+ // For message types without true field presence, only fields with a message
// type or inside an one-of have a has_$name$() method.
return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
field->has_optional_keyword() || field->real_containing_oneof();
-}
-
-// Collects map entry message type information.
+}
+
+// Collects map entry message type information.
void CollectMapInfo(const Options& options, const Descriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables) {
- GOOGLE_CHECK(IsMapEntryMessage(descriptor));
+ GOOGLE_CHECK(IsMapEntryMessage(descriptor));
std::map<TProtoStringType, TProtoStringType>& vars = *variables;
- const FieldDescriptor* key = descriptor->FindFieldByName("key");
- const FieldDescriptor* val = descriptor->FindFieldByName("value");
+ const FieldDescriptor* key = descriptor->FindFieldByName("key");
+ const FieldDescriptor* val = descriptor->FindFieldByName("value");
vars["key_cpp"] = PrimitiveTypeName(options, key->cpp_type());
- switch (val->cpp_type()) {
- case FieldDescriptor::CPPTYPE_MESSAGE:
+ switch (val->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_MESSAGE:
vars["val_cpp"] = FieldMessageTypeName(val, options);
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
vars["val_cpp"] = ClassName(val->enum_type(), true);
- break;
- default:
+ break;
+ default:
vars["val_cpp"] = PrimitiveTypeName(options, val->cpp_type());
- }
+ }
vars["key_wire_type"] =
"TYPE_" + ToUpper(DeclaredTypeMethodName(key->type()));
vars["val_wire_type"] =
"TYPE_" + ToUpper(DeclaredTypeMethodName(val->type()));
-}
-
-// Does the given field have a private (internal helper only) has_$name$()
-// method?
-bool HasPrivateHasMethod(const FieldDescriptor* field) {
- // Only for oneofs in message types with no field presence. has_$name$(),
- // based on the oneof case, is still useful internally for generated code.
+}
+
+// Does the given field have a private (internal helper only) has_$name$()
+// method?
+bool HasPrivateHasMethod(const FieldDescriptor* field) {
+ // Only for oneofs in message types with no field presence. has_$name$(),
+ // based on the oneof case, is still useful internally for generated code.
return IsProto3(field->file()) && field->real_containing_oneof();
-}
-
+}
+
// TODO(ckennelly): Cull these exclusions if/when these protos do not have
// their methods overridden by subclasses.
@@ -553,18 +553,18 @@ bool ColdChunkSkipper::OnEndChunk(int chunk, io::Printer* printer) {
return true;
}
-} // anonymous namespace
-
-// ===================================================================
-
+} // anonymous namespace
+
+// ===================================================================
+
MessageGenerator::MessageGenerator(
const Descriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& vars, int index_in_file_messages,
const Options& options, MessageSCCAnalyzer* scc_analyzer)
- : descriptor_(descriptor),
+ : descriptor_(descriptor),
index_in_file_messages_(index_in_file_messages),
- classname_(ClassName(descriptor, false)),
- options_(options),
+ classname_(ClassName(descriptor, false)),
+ options_(options),
field_generators_(descriptor, options, scc_analyzer),
max_has_bit_index_(0),
num_weak_fields_(0),
@@ -644,38 +644,38 @@ MessageGenerator::MessageGenerator(
if (!has_bit_indices_.empty()) {
field_generators_.SetHasBitIndices(has_bit_indices_);
- }
-
- num_required_fields_ = 0;
- for (int i = 0; i < descriptor->field_count(); i++) {
- if (descriptor->field(i)->is_required()) {
- ++num_required_fields_;
- }
- }
+ }
+
+ num_required_fields_ = 0;
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ if (descriptor->field(i)->is_required()) {
+ ++num_required_fields_;
+ }
+ }
table_driven_ =
TableDrivenParsingEnabled(descriptor_, options_, scc_analyzer_);
parse_function_generator_.reset(new ParseFunctionGenerator(
descriptor_, max_has_bit_index_, has_bit_indices_, options_,
scc_analyzer_, variables_));
-}
-
+}
+
MessageGenerator::~MessageGenerator() = default;
-
+
size_t MessageGenerator::HasBitsSize() const {
return (max_has_bit_index_ + 31) / 32;
}
-
+
int MessageGenerator::HasBitIndex(const FieldDescriptor* field) const {
return has_bit_indices_.empty() ? kNoHasbit
: has_bit_indices_[field->index()];
-}
-
+}
+
int MessageGenerator::HasByteIndex(const FieldDescriptor* field) const {
int hasbit = HasBitIndex(field);
return hasbit == kNoHasbit ? kNoHasbit : hasbit / 8;
-}
-
+}
+
int MessageGenerator::HasWordIndex(const FieldDescriptor* field) const {
int hasbit = HasBitIndex(field);
return hasbit == kNoHasbit ? kNoHasbit : hasbit / 32;
@@ -684,18 +684,18 @@ int MessageGenerator::HasWordIndex(const FieldDescriptor* field) const {
void MessageGenerator::AddGenerators(
std::vector<std::unique_ptr<EnumGenerator>>* enum_generators,
std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators) {
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
+ for (int i = 0; i < descriptor_->enum_type_count(); i++) {
enum_generators->emplace_back(
new EnumGenerator(descriptor_->enum_type(i), variables_, options_));
enum_generators_.push_back(enum_generators->back().get());
- }
+ }
for (int i = 0; i < descriptor_->extension_count(); i++) {
extension_generators->emplace_back(
new ExtensionGenerator(descriptor_->extension(i), options_));
extension_generators_.push_back(extension_generators->back().get());
}
-}
-
+}
+
void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
Formatter format(printer, variables_);
// optimized_fields_ does not contain fields where
@@ -717,7 +717,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
}
ordered_fields.push_back(field);
}
-
+
if (!ordered_fields.empty()) {
format("enum : int {\n");
for (auto field : ordered_fields) {
@@ -732,14 +732,14 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
}
for (auto field : ordered_fields) {
PrintFieldComment(format, field);
-
+
Formatter::SaveState save(&format);
std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
+ SetCommonFieldVariables(field, &vars, options_);
format.AddMap(vars);
-
- if (field->is_repeated()) {
+
+ if (field->is_repeated()) {
format("$deprecated_attr$int ${1$$name$_size$}$() const$2$\n", field,
!IsFieldStripped(field, options_) ? ";" : " {__builtin_trap();}");
if (!IsFieldStripped(field, options_)) {
@@ -749,7 +749,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
"public:\n",
field);
}
- } else if (HasHasMethod(field)) {
+ } else if (HasHasMethod(field)) {
format("$deprecated_attr$bool ${1$has_$name$$}$() const$2$\n", field,
!IsFieldStripped(field, options_) ? ";" : " {__builtin_trap();}");
if (!IsFieldStripped(field, options_)) {
@@ -758,7 +758,7 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
"bool _internal_has_$name$() const;\n"
"public:\n");
}
- } else if (HasPrivateHasMethod(field)) {
+ } else if (HasPrivateHasMethod(field)) {
if (!IsFieldStripped(field, options_)) {
format(
"private:\n"
@@ -766,19 +766,19 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
"public:\n",
field);
}
- }
+ }
format("$deprecated_attr$void ${1$clear_$name$$}$()$2$\n", field,
!IsFieldStripped(field, options_) ? ";" : "{__builtin_trap();}");
-
- // Generate type-specific accessor declarations.
- field_generators_.get(field).GenerateAccessorDeclarations(printer);
-
+
+ // Generate type-specific accessor declarations.
+ field_generators_.get(field).GenerateAccessorDeclarations(printer);
+
format("\n");
- }
-
- if (descriptor_->extension_range_count() > 0) {
- // Generate accessors for extensions. We just call a macro located in
- // extension_set.h since the accessors about 80 lines of static code.
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ // Generate accessors for extensions. We just call a macro located in
+ // extension_set.h since the accessors about 80 lines of static code.
format("$GOOGLE_PROTOBUF$_EXTENSION_ACCESSORS($classname$)\n");
// Generate MessageSet specific APIs for proto2 MessageSet.
// For testing purposes we don't check for bridge.MessageSet, so
@@ -788,19 +788,19 @@ void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) {
// Special-case MessageSet
format("GOOGLE_PROTOBUF_EXTENSION_MESSAGE_SET_ACCESSORS($classname$)\n");
}
- }
-
+ }
+
for (auto oneof : OneOfRange(descriptor_)) {
Formatter::SaveState saver(&format);
format.Set("oneof_name", oneof->name());
format.Set("camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true));
format(
"void ${1$clear_$oneof_name$$}$();\n"
- "$camel_oneof_name$Case $oneof_name$_case() const;\n",
+ "$camel_oneof_name$Case $oneof_name$_case() const;\n",
oneof);
- }
-}
-
+ }
+}
+
void MessageGenerator::GenerateSingularFieldHasBits(
const FieldDescriptor* field, Formatter format) {
if (IsFieldStripped(field, options_)) {
@@ -808,7 +808,7 @@ void MessageGenerator::GenerateSingularFieldHasBits(
"inline bool $classname$::has_$name$() const { "
"__builtin_trap(); }\n");
return;
- }
+ }
if (field->options().weak()) {
format(
"inline bool $classname$::has_$name$() const {\n"
@@ -845,27 +845,27 @@ void MessageGenerator::GenerateSingularFieldHasBits(
" return _internal_has_$name$();\n"
"}\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
- // Message fields have a has_$name$() method.
+ // Message fields have a has_$name$() method.
if (IsLazy(field, options_, scc_analyzer_)) {
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
- " return !$name$_.IsCleared();\n"
- "}\n");
+ " return !$name$_.IsCleared();\n"
+ "}\n");
} else {
format(
"inline bool $classname$::_internal_has_$name$() const {\n"
" return this != internal_default_instance() "
"&& $name$_ != nullptr;\n"
"}\n");
- }
+ }
format(
"inline bool $classname$::has_$name$() const {\n"
"$annotate_has$"
" return _internal_has_$name$();\n"
"}\n");
- }
-}
-
+ }
+}
+
void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
Formatter format(printer, variables_);
for (auto oneof : OneOfRange(descriptor_)) {
@@ -874,14 +874,14 @@ void MessageGenerator::GenerateOneofHasBits(io::Printer* printer) {
format.Set("cap_oneof_name", ToUpper(oneof->name()));
format(
"inline bool $classname$::has_$oneof_name$() const {\n"
- " return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n"
- "}\n"
+ " return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\n"
+ "}\n"
"inline void $classname$::clear_has_$oneof_name$() {\n"
- " _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n"
- "}\n");
- }
-}
-
+ " _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\n"
+ "}\n");
+ }
+}
+
void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
const Formatter& format) {
if (IsFieldStripped(field, options_)) {
@@ -895,12 +895,12 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
"}\n");
return;
}
- // Singular field in a oneof
- // N.B.: Without field presence, we do not use has-bits or generate
- // has_$name$() methods, but oneofs still have set_has_$name$().
- // Oneofs also have has_$name$() but only as a private helper
- // method, so that generated code is slightly cleaner (vs. comparing
- // _oneof_case_[index] against a constant everywhere).
+ // Singular field in a oneof
+ // N.B.: Without field presence, we do not use has-bits or generate
+ // has_$name$() methods, but oneofs still have set_has_$name$().
+ // Oneofs also have has_$name$() but only as a private helper
+ // method, so that generated code is slightly cleaner (vs. comparing
+ // _oneof_case_[index] against a constant everywhere).
//
// If has_$name$() is private, there is no need to add an internal accessor.
// Only annotate public accessors.
@@ -925,33 +925,33 @@ void MessageGenerator::GenerateOneofMemberHasBits(const FieldDescriptor* field,
"inline void $classname$::set_has_$name$() {\n"
" _oneof_case_[$oneof_index$] = k$field_name$;\n"
"}\n");
-}
-
+}
+
void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
bool is_inline, Formatter format) {
if (IsFieldStripped(field, options_)) {
format("void $classname$::clear_$name$() { __builtin_trap(); }\n");
return;
}
-
+
// Generate clear_$name$().
if (is_inline) {
format("inline ");
}
format("void $classname$::clear_$name$() {\n");
-
+
format.Indent();
if (field->real_containing_oneof()) {
- // Clear this field only if it is the active field in this oneof,
- // otherwise ignore
+ // Clear this field only if it is the active field in this oneof,
+ // otherwise ignore
format("if (_internal_has_$name$()) {\n");
format.Indent();
field_generators_.get(field).GenerateClearingCode(format.printer());
format("clear_has_$oneof_name$();\n");
format.Outdent();
format("}\n");
- } else {
+ } else {
field_generators_.get(field).GenerateClearingCode(format.printer());
if (HasHasbit(field)) {
int has_bit_index = HasBitIndex(field);
@@ -959,32 +959,32 @@ void MessageGenerator::GenerateFieldClear(const FieldDescriptor* field,
format.Set("has_mask",
strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8));
format("_has_bits_[$has_array_index$] &= ~0x$has_mask$u;\n");
- }
- }
+ }
+ }
format("$annotate_clear$");
format.Outdent();
format("}\n");
-}
-
+}
+
void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
Formatter format(printer, variables_);
format("// $classname$\n\n");
-
+
for (auto field : FieldRange(descriptor_)) {
PrintFieldComment(format, field);
-
+
if (IsFieldStripped(field, options_)) {
continue;
}
-
+
std::map<TProtoStringType, TProtoStringType> vars;
- SetCommonFieldVariables(field, &vars, options_);
-
+ SetCommonFieldVariables(field, &vars, options_);
+
Formatter::SaveState saver(&format);
format.AddMap(vars);
- // Generate has_$name$() or $name$_size().
- if (field->is_repeated()) {
+ // Generate has_$name$() or $name$_size().
+ if (field->is_repeated()) {
if (IsFieldStripped(field, options_)) {
format(
"inline int $classname$::$name$_size() const { "
@@ -1002,34 +1002,34 @@ void MessageGenerator::GenerateFieldAccessorDefinitions(io::Printer* printer) {
field->message_type()
? ".weak"
: "");
- }
+ }
} else if (field->real_containing_oneof()) {
format.Set("field_name", UnderscoresToCamelCase(field->name(), true));
format.Set("oneof_name", field->containing_oneof()->name());
format.Set("oneof_index",
StrCat(field->containing_oneof()->index()));
GenerateOneofMemberHasBits(field, format);
- } else {
- // Singular field.
+ } else {
+ // Singular field.
GenerateSingularFieldHasBits(field, format);
- }
-
+ }
+
if (!IsCrossFileMaybeMap(field)) {
GenerateFieldClear(field, true, format);
- }
-
- // Generate type-specific accessors.
+ }
+
+ // Generate type-specific accessors.
if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateInlineAccessorDefinitions(printer);
}
-
+
format("\n");
- }
-
+ }
+
// Generate has_$name$() and clear_has_$name$() functions for oneofs.
GenerateOneofHasBits(printer);
-}
-
+}
+
void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
Formatter format(printer, variables_);
format.Set("class_final",
@@ -1127,9 +1127,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" ::$proto_ns$::Metadata GetMetadata() const final;\n");
}
format("};\n");
- return;
- }
-
+ return;
+ }
+
format(
"class $dllexport_decl $${1$$classname$$}$$ class_final$ :\n"
" public $superclass$ /* @@protoc_insertion_point("
@@ -1137,7 +1137,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
descriptor_);
format(" public:\n");
format.Indent();
-
+
if (EnableMessageOwnedArena(descriptor_)) {
format(
"inline $classname$() : $classname$("
@@ -1188,17 +1188,17 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" return $mutable_unknown_fields$;\n"
"}\n"
"\n");
- }
-
- // Only generate this member if it's not disabled.
- if (HasDescriptorMethods(descriptor_->file(), options_) &&
- !descriptor_->options().no_standard_descriptor_accessor()) {
+ }
+
+ // Only generate this member if it's not disabled.
+ if (HasDescriptorMethods(descriptor_->file(), options_) &&
+ !descriptor_->options().no_standard_descriptor_accessor()) {
format(
"static const ::$proto_ns$::Descriptor* descriptor() {\n"
" return GetDescriptor();\n"
"}\n");
- }
-
+ }
+
if (HasDescriptorMethods(descriptor_->file(), options_)) {
// These shadow non-static methods of the same names in Message. We
// redefine them here because calls directly on the generated class can be
@@ -1217,14 +1217,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" return default_instance().GetMetadata().reflection;\n"
"}\n");
}
-
+
format(
"static const $classname$& default_instance() {\n"
" return *internal_default_instance();\n"
"}\n");
- // Generate enum values for every field in oneofs. One list is generated for
- // each oneof with an additional *_NOT_SET value.
+ // Generate enum values for every field in oneofs. One list is generated for
+ // each oneof with an additional *_NOT_SET value.
for (auto oneof : OneOfRange(descriptor_)) {
format("enum $1$Case {\n", UnderscoresToCamelCase(oneof->name(), true));
format.Indent();
@@ -1233,14 +1233,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
UnderscoresToCamelCase(field->name(), true);
format("k$1$ = $2$,\n", oneof_enum_case_field_name, // 1
field->number()); // 2
- }
+ }
format("$1$_NOT_SET = 0,\n", ToUpper(oneof->name()));
format.Outdent();
format(
- "};\n"
- "\n");
- }
-
+ "};\n"
+ "\n");
+ }
+
// TODO(gerbens) make this private, while still granting other protos access.
format(
"static inline const $classname$* internal_default_instance() {\n"
@@ -1251,7 +1251,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" $1$;\n"
"\n",
index_in_file_messages_);
-
+
if (IsAnyMessage(descriptor_, options_)) {
format(
"// implements Any -----------------------------------------------\n"
@@ -1317,8 +1317,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"static bool ParseAnyTypeUrl(::PROTOBUF_NAMESPACE_ID::ConstStringParam "
"type_url,\n"
" TProtoStringType* full_type_name);\n");
- }
-
+ }
+
format(
"friend void swap($classname$& a, $classname$& b) {\n"
" a.Swap(&b);\n"
@@ -1343,25 +1343,25 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"}\n");
format(
- "\n"
+ "\n"
"// implements Message ----------------------------------------------\n"
"\n"
"inline $classname$* New() const final {\n"
" return new $classname$();\n"
- "}\n"
+ "}\n"
"\n"
"$classname$* New(::$proto_ns$::Arena* arena) const final {\n"
" return CreateMaybeMessage<$classname$>(arena);\n"
"}\n");
-
+
// For instances that derive from Message (rather than MessageLite), some
// methods are virtual and should be marked as final.
format.Set("full_final", HasDescriptorMethods(descriptor_->file(), options_)
? "final"
: "");
- if (HasGeneratedMethods(descriptor_->file(), options_)) {
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ if (HasGeneratedMethods(descriptor_->file(), options_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
// Use Message's built-in MergeFrom and CopyFrom when the passed-in
// argument is a generic Message instance, and only define the custom
@@ -1378,14 +1378,14 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"static void MergeImpl(::$proto_ns$::Message*to, const "
"::$proto_ns$::Message&from);\n"
"public:\n");
- } else {
+ } else {
format(
"void CheckTypeAndMergeFrom(const ::$proto_ns$::MessageLite& from)"
" final;\n"
"void CopyFrom(const $classname$& from);\n"
"void MergeFrom(const $classname$& from);\n");
- }
-
+ }
+
format.Set("clear_final",
ShouldMarkClearAsFinal(descriptor_, options_) ? "final" : "");
@@ -1402,13 +1402,13 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
"const final;\n");
- // DiscardUnknownFields() is implemented in message.cc using reflections. We
- // need to implement this function in generated code for messages.
- if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
+ // DiscardUnknownFields() is implemented in message.cc using reflections. We
+ // need to implement this function in generated code for messages.
+ if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
format("void DiscardUnknownFields()$ full_final$;\n");
- }
- }
-
+ }
+ }
+
format(
"int GetCachedSize() const final { return _cached_size_.Get(); }"
"\n\nprivate:\n"
@@ -1430,18 +1430,18 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
// TODO(gerbens) Make this private! Currently people are deriving from
// protos to give access to this constructor, breaking the invariants
// we rely on.
- "protected:\n"
+ "protected:\n"
"explicit $classname$(::$proto_ns$::Arena* arena,\n"
" bool is_message_owned = false);\n"
- "private:\n"
- "static void ArenaDtor(void* object);\n"
+ "private:\n"
+ "static void ArenaDtor(void* object);\n"
"inline void RegisterArenaDtor(::$proto_ns$::Arena* arena);\n");
-
+
format(
- "public:\n"
- "\n");
-
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ "public:\n"
+ "\n");
+
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
if (HasGeneratedMethods(descriptor_->file(), options_)) {
format(
"static const ClassData _class_data_;\n"
@@ -1452,149 +1452,149 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
format(
"::$proto_ns$::Metadata GetMetadata() const final;\n"
"\n");
- } else {
+ } else {
format(
"TProtoStringType GetTypeName() const final;\n"
"\n");
- }
-
+ }
+
format(
"// nested types ----------------------------------------------------\n"
"\n");
-
- // Import all nested message classes into this class's scope with typedefs.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- const Descriptor* nested_type = descriptor_->nested_type(i);
- if (!IsMapEntryMessage(nested_type)) {
+
+ // Import all nested message classes into this class's scope with typedefs.
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ const Descriptor* nested_type = descriptor_->nested_type(i);
+ if (!IsMapEntryMessage(nested_type)) {
format.Set("nested_full_name", ClassName(nested_type, false));
format.Set("nested_name", ResolveKeyword(nested_type->name()));
format("typedef ${1$$nested_full_name$$}$ ${1$$nested_name$$}$;\n",
nested_type);
- }
- }
-
- if (descriptor_->nested_type_count() > 0) {
+ }
+ }
+
+ if (descriptor_->nested_type_count() > 0) {
format("\n");
- }
-
- // Import all nested enums and their values into this class's scope with
- // typedefs and constants.
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- enum_generators_[i]->GenerateSymbolImports(printer);
+ }
+
+ // Import all nested enums and their values into this class's scope with
+ // typedefs and constants.
+ for (int i = 0; i < descriptor_->enum_type_count(); i++) {
+ enum_generators_[i]->GenerateSymbolImports(printer);
format("\n");
- }
-
+ }
+
format(
"// accessors -------------------------------------------------------\n"
"\n");
-
- // Generate accessor methods for all fields.
- GenerateFieldAccessorDeclarations(printer);
-
- // Declare extension identifiers.
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- extension_generators_[i]->GenerateDeclaration(printer);
- }
-
-
+
+ // Generate accessor methods for all fields.
+ GenerateFieldAccessorDeclarations(printer);
+
+ // Declare extension identifiers.
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ extension_generators_[i]->GenerateDeclaration(printer);
+ }
+
+
format("// @@protoc_insertion_point(class_scope:$full_name$)\n");
-
- // Generate private members.
+
+ // Generate private members.
format.Outdent();
format(" private:\n");
format.Indent();
// TODO(seongkim): Remove hack to track field access and remove this class.
format("class _Internal;\n");
-
+
for (auto field : FieldRange(descriptor_)) {
// set_has_***() generated in all oneofs.
if (!field->is_repeated() && !field->options().weak() &&
field->real_containing_oneof()) {
format("void set_has_$1$();\n", FieldName(field));
- }
- }
+ }
+ }
format("\n");
-
- // Generate oneof function declarations
+
+ // Generate oneof function declarations
for (auto oneof : OneOfRange(descriptor_)) {
format(
"inline bool has_$1$() const;\n"
"inline void clear_has_$1$();\n\n",
oneof->name());
- }
-
- if (HasGeneratedMethods(descriptor_->file(), options_) &&
- !descriptor_->options().message_set_wire_format() &&
- num_required_fields_ > 1) {
+ }
+
+ if (HasGeneratedMethods(descriptor_->file(), options_) &&
+ !descriptor_->options().message_set_wire_format() &&
+ num_required_fields_ > 1) {
format(
"// helper for ByteSizeLong()\n"
"size_t RequiredFieldsByteSizeFallback() const;\n\n");
- }
-
+ }
+
if (HasGeneratedMethods(descriptor_->file(), options_)) {
parse_function_generator_->GenerateDataDecls(printer);
}
- // Prepare decls for _cached_size_ and _has_bits_. Their position in the
- // output will be determined later.
-
- bool need_to_emit_cached_size = true;
+ // Prepare decls for _cached_size_ and _has_bits_. Their position in the
+ // output will be determined later.
+
+ bool need_to_emit_cached_size = true;
const TProtoStringType cached_size_decl =
"mutable ::$proto_ns$::internal::CachedSize _cached_size_;\n";
-
+
const size_t sizeof_has_bits = HasBitsSize();
const TProtoStringType has_bits_decl =
sizeof_has_bits == 0 ? ""
: StrCat("::$proto_ns$::internal::HasBits<",
sizeof_has_bits, "> _has_bits_;\n");
-
- // To minimize padding, data members are divided into three sections:
- // (1) members assumed to align to 8 bytes
- // (2) members corresponding to message fields, re-ordered to optimize
- // alignment.
- // (3) members assumed to align to 4 bytes.
-
- // Members assumed to align to 8 bytes:
-
- if (descriptor_->extension_range_count() > 0) {
+
+ // To minimize padding, data members are divided into three sections:
+ // (1) members assumed to align to 8 bytes
+ // (2) members corresponding to message fields, re-ordered to optimize
+ // alignment.
+ // (3) members assumed to align to 4 bytes.
+
+ // Members assumed to align to 8 bytes:
+
+ if (descriptor_->extension_range_count() > 0) {
format(
"::$proto_ns$::internal::ExtensionSet _extensions_;\n"
"\n");
- }
-
+ }
+
format(
"template <typename T> friend class "
"::$proto_ns$::Arena::InternalHelper;\n"
- "typedef void InternalArenaConstructable_;\n"
- "typedef void DestructorSkippable_;\n");
-
+ "typedef void InternalArenaConstructable_;\n"
+ "typedef void DestructorSkippable_;\n");
+
if (!has_bit_indices_.empty()) {
- // _has_bits_ is frequently accessed, so to reduce code size and improve
+ // _has_bits_ is frequently accessed, so to reduce code size and improve
// speed, it should be close to the start of the object. Placing
// _cached_size_ together with _has_bits_ improves cache locality despite
// potential alignment padding.
format(has_bits_decl.c_str());
format(cached_size_decl.c_str());
need_to_emit_cached_size = false;
- }
-
- // Field members:
-
- // Emit some private and static members
+ }
+
+ // Field members:
+
+ // Emit some private and static members
for (auto field : optimized_order_) {
- const FieldGenerator& generator = field_generators_.get(field);
- generator.GenerateStaticMembers(printer);
- generator.GeneratePrivateMembers(printer);
- }
-
- // For each oneof generate a union
+ const FieldGenerator& generator = field_generators_.get(field);
+ generator.GenerateStaticMembers(printer);
+ generator.GeneratePrivateMembers(printer);
+ }
+
+ // For each oneof generate a union
for (auto oneof : OneOfRange(descriptor_)) {
TProtoStringType camel_oneof_name = UnderscoresToCamelCase(oneof->name(), true);
format("union $1$Union {\n", camel_oneof_name);
format.Indent();
format(
- // explicit empty constructor is needed when union contains
- // ArenaStringPtr members for string fields.
+ // explicit empty constructor is needed when union contains
+ // ArenaStringPtr members for string fields.
"constexpr $1$Union() : _constinit_{} {}\n"
" ::$proto_ns$::internal::ConstantInitialized _constinit_;\n",
camel_oneof_name);
@@ -1602,53 +1602,53 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GeneratePrivateMembers(printer);
}
- }
+ }
format.Outdent();
format("} $1$_;\n", oneof->name());
for (auto field : FieldRange(oneof)) {
if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateStaticMembers(printer);
}
- }
- }
-
- // Members assumed to align to 4 bytes:
-
- if (need_to_emit_cached_size) {
+ }
+ }
+
+ // Members assumed to align to 4 bytes:
+
+ if (need_to_emit_cached_size) {
format(cached_size_decl.c_str());
- need_to_emit_cached_size = false;
- }
-
- // Generate _oneof_case_.
+ need_to_emit_cached_size = false;
+ }
+
+ // Generate _oneof_case_.
if (descriptor_->real_oneof_decl_count() > 0) {
format(
"$uint32$ _oneof_case_[$1$];\n"
"\n",
descriptor_->real_oneof_decl_count());
- }
-
+ }
+
if (num_weak_fields_) {
format("::$proto_ns$::internal::WeakFieldMap _weak_field_map_;\n");
}
- // Generate _any_metadata_ for the Any type.
+ // Generate _any_metadata_ for the Any type.
if (IsAnyMessage(descriptor_, options_)) {
format("::$proto_ns$::internal::AnyMetadata _any_metadata_;\n");
- }
-
+ }
+
// The TableStruct struct needs access to the private parts, in order to
// construct the offsets of all members.
format("friend struct ::$tablename$;\n");
-
+
format.Outdent();
format("};");
- GOOGLE_DCHECK(!need_to_emit_cached_size);
+ GOOGLE_DCHECK(!need_to_emit_cached_size);
} // NOLINT(readability/fn_size)
-
+
void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
if (IsMapEntryMessage(descriptor_)) return;
GenerateFieldAccessorDefinitions(printer);
-
- // Generate oneof_case() functions.
+
+ // Generate oneof_case() functions.
for (auto oneof : OneOfRange(descriptor_)) {
Formatter format(printer, variables_);
format.Set("camel_oneof_name", UnderscoresToCamelCase(oneof->name(), true));
@@ -1658,12 +1658,12 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) {
"inline $classname$::$camel_oneof_name$Case $classname$::"
"${1$$oneof_name$_case$}$() const {\n"
" return $classname$::$camel_oneof_name$Case("
- "_oneof_case_[$oneof_index$]);\n"
+ "_oneof_case_[$oneof_index$]);\n"
"}\n",
oneof);
- }
-}
-
+ }
+}
+
bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
size_t aux_offset) {
Formatter format(printer, variables_);
@@ -1731,10 +1731,10 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)
? offset + has_offset
: -1;
-
+
format("{ $1$, $2$, sizeof($classtype$)},\n", offset, has_offset);
-}
-
+}
+
namespace {
// We need to calculate for each field what function the table driven code
@@ -1966,7 +1966,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
}
return;
}
-
+
if (IsAnyMessage(descriptor_, options_)) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
@@ -1986,8 +1986,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
" full_type_name);\n"
"}\n"
"\n");
- }
-
+ }
+
format(
"class $classname$::_Internal {\n"
" public:\n");
@@ -2027,9 +2027,9 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
if (!IsFieldStripped(field, options_)) {
field_generators_.get(field).GenerateInternalAccessorDefinitions(printer);
}
- }
-
- // Generate non-inline field definitions.
+ }
+
+ // Generate non-inline field definitions.
for (auto field : FieldRange(descriptor_)) {
if (IsFieldStripped(field, options_)) {
continue;
@@ -2045,47 +2045,47 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
format.AddMap(vars);
GenerateFieldClear(field, false, format);
}
- }
-
- GenerateStructors(printer);
+ }
+
+ GenerateStructors(printer);
format("\n");
-
+
if (descriptor_->real_oneof_decl_count() > 0) {
- GenerateOneofClear(printer);
+ GenerateOneofClear(printer);
format("\n");
- }
-
- if (HasGeneratedMethods(descriptor_->file(), options_)) {
- GenerateClear(printer);
+ }
+
+ if (HasGeneratedMethods(descriptor_->file(), options_)) {
+ GenerateClear(printer);
format("\n");
-
+
parse_function_generator_->GenerateMethodImpls(printer);
format("\n");
-
+
parse_function_generator_->GenerateDataDefinitions(printer);
GenerateSerializeWithCachedSizesToArray(printer);
format("\n");
-
- GenerateByteSize(printer);
+
+ GenerateByteSize(printer);
format("\n");
-
- GenerateMergeFrom(printer);
+
+ GenerateMergeFrom(printer);
format("\n");
-
+
GenerateClassSpecificMergeFrom(printer);
format("\n");
- GenerateCopyFrom(printer);
+ GenerateCopyFrom(printer);
format("\n");
-
- GenerateIsInitialized(printer);
+
+ GenerateIsInitialized(printer);
format("\n");
- }
-
- GenerateSwap(printer);
+ }
+
+ GenerateSwap(printer);
format("\n");
-
+
if (options_.table_driven_serialization) {
format(
"const void* $classname$::InternalGetTable() const {\n"
@@ -2094,7 +2094,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
"\n",
index_in_file_messages_);
}
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
format(
"::$proto_ns$::Metadata $classname$::GetMetadata() const {\n"
" return ::$proto_ns$::internal::AssignDescriptors(\n"
@@ -2102,16 +2102,16 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
" $file_level_metadata$[$1$]);\n"
"}\n",
index_in_file_messages_);
- } else {
+ } else {
format(
"TProtoStringType $classname$::GetTypeName() const {\n"
" return \"$full_name$\";\n"
"}\n"
"\n");
- }
-
-}
-
+ }
+
+}
+
size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) {
Formatter format(printer, variables_);
@@ -2304,7 +2304,7 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
io::Printer* printer) {
Formatter format(printer, variables_);
-
+
if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) {
format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n");
} else {
@@ -2341,9 +2341,9 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
// Mark the field to prevent unintentional access through reflection.
// Don't use the top bit because that is for unused fields.
format("::$proto_ns$::internal::kInvalidFieldOffsetTag");
- } else {
+ } else {
format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_)", FieldName(field));
- }
+ }
if (!IsFieldUsed(field, options_)) {
format(" | 0x80000000u, // unused\n");
@@ -2352,15 +2352,15 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
} else {
format(",\n");
}
- }
-
+ }
+
int count = 0;
for (auto oneof : OneOfRange(descriptor_)) {
format("PROTOBUF_FIELD_OFFSET($classtype$, $1$_),\n", oneof->name());
count++;
- }
+ }
GOOGLE_CHECK_EQ(count, descriptor_->real_oneof_decl_count());
-
+
if (IsMapEntryMessage(descriptor_)) {
entries += 2;
format(
@@ -2376,44 +2376,44 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
}
return std::make_pair(entries, offsets);
-}
-
+}
+
void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) {
Formatter format(printer, variables_);
-
+
format("void $classname$::SharedCtor() {\n");
-
+
std::vector<bool> processed(optimized_order_.size(), false);
GenerateConstructorBody(printer, processed, false);
for (auto oneof : OneOfRange(descriptor_)) {
format("clear_has_$1$();\n", oneof->name());
- }
-
+ }
+
format("}\n\n");
-}
-
+}
+
void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
Formatter format(printer, variables_);
-
+
format("inline void $classname$::SharedDtor() {\n");
format.Indent();
format("$DCHK$(GetArenaForAllocation() == nullptr);\n");
- // Write the destructors for each field except oneof members.
+ // Write the destructors for each field except oneof members.
// optimized_order_ does not contain oneof fields.
for (auto field : optimized_order_) {
field_generators_.get(field).GenerateDestructorCode(printer);
- }
-
- // Generate code to destruct oneofs. Clearing should do the work.
+ }
+
+ // Generate code to destruct oneofs. Clearing should do the work.
for (auto oneof : OneOfRange(descriptor_)) {
format(
"if (has_$1$()) {\n"
" clear_$1$();\n"
- "}\n",
+ "}\n",
oneof->name());
- }
-
+ }
+
if (num_weak_fields_) {
format("_weak_field_map_.ClearAll();\n");
}
@@ -2421,32 +2421,32 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) {
format(
"}\n"
"\n");
-}
-
+}
+
void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
Formatter format(printer, variables_);
- // Generate the ArenaDtor() method. Track whether any fields actually produced
- // code that needs to be called.
+ // Generate the ArenaDtor() method. Track whether any fields actually produced
+ // code that needs to be called.
format("void $classname$::ArenaDtor(void* object) {\n");
format.Indent();
-
- // This code is placed inside a static method, rather than an ordinary one,
- // since that simplifies Arena's destructor list (ordinary function pointers
- // rather than member function pointers). _this is the object being
- // destructed.
+
+ // This code is placed inside a static method, rather than an ordinary one,
+ // since that simplifies Arena's destructor list (ordinary function pointers
+ // rather than member function pointers). _this is the object being
+ // destructed.
format(
- "$classname$* _this = reinterpret_cast< $classname$* >(object);\n"
- // avoid an "unused variable" warning in case no fields have dtor code.
+ "$classname$* _this = reinterpret_cast< $classname$* >(object);\n"
+ // avoid an "unused variable" warning in case no fields have dtor code.
"(void)_this;\n");
-
- bool need_registration = false;
+
+ bool need_registration = false;
// Process non-oneof fields first.
for (auto field : optimized_order_) {
if (field_generators_.get(field).GenerateArenaDestructorCode(printer)) {
- need_registration = true;
- }
- }
+ need_registration = true;
+ }
+ }
// Process oneof fields.
//
@@ -2463,22 +2463,22 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) {
format.Outdent();
format("}\n");
-
- if (need_registration) {
+
+ if (need_registration) {
format(
"inline void $classname$::RegisterArenaDtor(::$proto_ns$::Arena* "
"arena) {\n"
" if (arena != nullptr) {\n"
- " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
- " }\n"
+ " arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\n"
+ " }\n"
"}\n");
- } else {
+ } else {
format(
"void $classname$::RegisterArenaDtor(::$proto_ns$::Arena*) {\n"
"}\n");
- }
-}
-
+ }
+}
+
void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) {
Formatter format(printer, variables_);
@@ -2578,16 +2578,16 @@ void MessageGenerator::GenerateConstructorBody(io::Printer* printer,
void MessageGenerator::GenerateStructors(io::Printer* printer) {
Formatter format(printer, variables_);
-
+
TProtoStringType superclass;
superclass = SuperClassName(descriptor_, options_);
TProtoStringType initializer_with_arena = superclass + "(arena, is_message_owned)";
- if (descriptor_->extension_range_count() > 0) {
- initializer_with_arena += ",\n _extensions_(arena)";
- }
-
- // Initialize member variables with arena constructor.
+ if (descriptor_->extension_range_count() > 0) {
+ initializer_with_arena += ",\n _extensions_(arena)";
+ }
+
+ // Initialize member variables with arena constructor.
for (auto field : optimized_order_) {
GOOGLE_DCHECK(!IsFieldStripped(field, options_));
bool has_arena_constructor = field->is_repeated();
@@ -2596,44 +2596,44 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
IsStringPiece(field, options_))) {
has_arena_constructor = true;
}
- if (has_arena_constructor) {
+ if (has_arena_constructor) {
initializer_with_arena +=
TProtoStringType(",\n ") + FieldName(field) + TProtoStringType("_(arena)");
- }
- }
-
+ }
+ }
+
if (IsAnyMessage(descriptor_, options_)) {
initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)";
- }
+ }
if (num_weak_fields_ > 0) {
initializer_with_arena += ", _weak_field_map_(arena)";
}
-
+
TProtoStringType initializer_null = superclass + "()";
if (IsAnyMessage(descriptor_, options_)) {
- initializer_null += ", _any_metadata_(&type_url_, &value_)";
- }
+ initializer_null += ", _any_metadata_(&type_url_, &value_)";
+ }
if (num_weak_fields_ > 0) {
initializer_null += ", _weak_field_map_(nullptr)";
}
-
+
format(
"$classname$::$classname$(::$proto_ns$::Arena* arena,\n"
" bool is_message_owned)\n"
" : $1$ {\n"
- " SharedCtor();\n"
+ " SharedCtor();\n"
" if (!is_message_owned) {\n"
" RegisterArenaDtor(arena);\n"
" }\n"
" // @@protoc_insertion_point(arena_constructor:$full_name$)\n"
- "}\n",
+ "}\n",
initializer_with_arena);
-
+
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
-
- // Generate the copy constructor.
+
+ // Generate the copy constructor.
if (UsingImplicitWeakFields(descriptor_->file(), options_)) {
// If we are in lite mode and using implicit weak fields, we generate a
// one-liner copy constructor that delegates to MergeFrom. This saves some
@@ -2722,10 +2722,10 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
"\n");
}
- // Generate the shared constructor code.
- GenerateSharedConstructorCode(printer);
-
- // Generate the destructor.
+ // Generate the shared constructor code.
+ GenerateSharedConstructorCode(printer);
+
+ // Generate the destructor.
format(
"$classname$::~$classname$() {\n"
" // @@protoc_insertion_point(destructor:$full_name$)\n"
@@ -2734,20 +2734,20 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) {
" _internal_metadata_.Delete<$unknown_fields_type$>();\n"
"}\n"
"\n");
-
- // Generate the shared destructor code.
- GenerateSharedDestructorCode(printer);
-
- // Generate the arena-specific destructor code.
+
+ // Generate the shared destructor code.
+ GenerateSharedDestructorCode(printer);
+
+ // Generate the arena-specific destructor code.
GenerateArenaDestructorCode(printer);
-
- // Generate SetCachedSize.
+
+ // Generate SetCachedSize.
format(
"void $classname$::SetCachedSize(int size) const {\n"
" _cached_size_.Set(size);\n"
"}\n");
-}
-
+}
+
void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
Formatter format(printer, variables_);
format(
@@ -2756,8 +2756,8 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) {
"$classtype$* Arena::CreateMaybeMessage< $classtype$ >(Arena* arena) {\n"
" return Arena::CreateMessageInternal< $classtype$ >(arena);\n"
"}\n");
-}
-
+}
+
void MessageGenerator::GenerateClear(io::Printer* printer) {
Formatter format(printer, variables_);
@@ -2766,10 +2766,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
const int kMaxUnconditionalPrimitiveBytesClear = 4;
format(
- "void $classname$::Clear() {\n"
+ "void $classname$::Clear() {\n"
"// @@protoc_insertion_point(message_clear_start:$full_name$)\n");
format.Indent();
-
+
format(
// TODO(jwb): It would be better to avoid emitting this if it is not used,
// rather than emitting a workaround for the resulting warning.
@@ -2777,10 +2777,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
"// Prevent compiler warnings about cached_has_bits being unused\n"
"(void) cached_has_bits;\n\n");
- if (descriptor_->extension_range_count() > 0) {
+ if (descriptor_->extension_range_count() > 0) {
format("_extensions_.Clear();\n");
- }
-
+ }
+
// Collect fields into chunks. Each chunk may have an if() condition that
// checks all hasbits in the chunk and skips it if none are set.
int zero_init_bytes = 0;
@@ -2791,7 +2791,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
}
bool merge_zero_init = zero_init_bytes > kMaxUnconditionalPrimitiveBytesClear;
int chunk_count = 0;
-
+
std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields(
optimized_order_,
[&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool {
@@ -2823,11 +2823,11 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
GOOGLE_CHECK(!saw_non_zero_init);
if (!memset_start) memset_start = field;
memset_end = field;
- } else {
+ } else {
saw_non_zero_init = true;
- }
- }
-
+ }
+ }
+
// Whether we wrap this chunk in:
// if (cached_has_bits & <chunk hasbits) { /* chunk. */ }
// We can omit the if() for chunk size 1, or if our fields do not have
@@ -2836,13 +2836,13 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
const bool have_outer_if = HasBitIndex(chunk.front()) != kNoHasbit &&
chunk.size() > 1 &&
(memset_end != chunk.back() || merge_zero_init);
-
+
if (have_outer_if) {
// Emit an if() that will let us skip the whole chunk if none are set.
uint32_t chunk_mask = GenChunkMask(chunk, has_bit_indices_);
TProtoStringType chunk_mask_str =
StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
-
+
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
@@ -2855,8 +2855,8 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
}
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format.Indent();
- }
-
+ }
+
if (memset_start) {
if (memset_start == memset_end) {
// For clarity, do not memset a single field.
@@ -2869,8 +2869,8 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
" reinterpret_cast<char*>(&$1$_)) + sizeof($2$_));\n",
FieldName(memset_start), FieldName(memset_end));
}
- }
-
+ }
+
// Clear all non-zero-initializable fields in the chunk.
for (const auto& field : chunk) {
if (CanInitializeByZeroing(field)) continue;
@@ -2882,11 +2882,11 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
HasBitIndex(field) != kNoHasbit &&
(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||
field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);
-
+
if (have_enclosing_if) {
PrintPresenceCheck(format, field, has_bit_indices_, printer,
&cached_has_word_index);
- }
+ }
field_generators_.get(field).GenerateMessageClearingCode(printer);
@@ -2904,39 +2904,39 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
if (cold_skipper.OnEndChunk(chunk_index, printer)) {
// Reset here as it may have been updated in just closed if statement.
cached_has_word_index = -1;
- }
- }
-
- // Step 4: Unions.
+ }
+ }
+
+ // Step 4: Unions.
for (auto oneof : OneOfRange(descriptor_)) {
format("clear_$1$();\n", oneof->name());
- }
-
+ }
+
if (num_weak_fields_) {
format("_weak_field_map_.ClearAll();\n");
}
if (!has_bit_indices_.empty()) {
- // Step 5: Everything else.
+ // Step 5: Everything else.
format("_has_bits_.Clear();\n");
- }
-
+ }
+
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
format("_internal_metadata_.Clear<$unknown_fields_type$>();\n");
-
+
format.Outdent();
format("}\n");
-}
-
+}
+
void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
- // Generated function clears the active field and union case (e.g. foo_case_).
+ // Generated function clears the active field and union case (e.g. foo_case_).
int i = 0;
for (auto oneof : OneOfRange(descriptor_)) {
Formatter format(printer, variables_);
format.Set("oneofname", oneof->name());
-
+
format(
"void $classname$::clear_$oneofname$() {\n"
"// @@protoc_insertion_point(one_of_clear_start:$full_name$)\n");
@@ -2946,46 +2946,46 @@ void MessageGenerator::GenerateOneofClear(io::Printer* printer) {
for (auto field : FieldRange(oneof)) {
format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true));
format.Indent();
- // We clear only allocated objects in oneofs
+ // We clear only allocated objects in oneofs
if (!IsStringOrMessage(field) || IsFieldStripped(field, options_)) {
format("// No need to clear\n");
- } else {
- field_generators_.get(field).GenerateClearingCode(printer);
- }
+ } else {
+ field_generators_.get(field).GenerateClearingCode(printer);
+ }
format("break;\n");
format.Outdent();
format("}\n");
- }
+ }
format(
"case $1$_NOT_SET: {\n"
- " break;\n"
- "}\n",
+ " break;\n"
+ "}\n",
ToUpper(oneof->name()));
format.Outdent();
format(
- "}\n"
+ "}\n"
"_oneof_case_[$1$] = $2$_NOT_SET;\n",
i, ToUpper(oneof->name()));
format.Outdent();
format(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
i++;
- }
-}
-
+ }
+}
+
void MessageGenerator::GenerateSwap(io::Printer* printer) {
Formatter format(printer, variables_);
-
+
format("void $classname$::InternalSwap($classname$* other) {\n");
format.Indent();
format("using std::swap;\n");
-
- if (HasGeneratedMethods(descriptor_->file(), options_)) {
+
+ if (HasGeneratedMethods(descriptor_->file(), options_)) {
if (descriptor_->extension_range_count() > 0) {
format("_extensions_.InternalSwap(&other->_extensions_);\n");
- }
-
+ }
+
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
@@ -2995,8 +2995,8 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
for (int i = 0; i < HasBitsSize(); ++i) {
format("swap(_has_bits_[$1$], other->_has_bits_[$1$]);\n", i);
}
- }
-
+ }
+
// If possible, we swap several fields at once, including padding.
const RunMap runs =
FindRuns(optimized_order_, [this](const FieldDescriptor* field) {
@@ -3032,31 +3032,31 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) {
// ++i at the top of the loop.
} else {
field_generators_.get(field).GenerateSwappingCode(printer);
- }
- }
-
+ }
+ }
+
for (auto oneof : OneOfRange(descriptor_)) {
format("swap($1$_, other->$1$_);\n", oneof->name());
}
-
+
for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
format("swap(_oneof_case_[$1$], other->_oneof_case_[$1$]);\n", i);
- }
+ }
if (num_weak_fields_) {
format("_weak_field_map_.UnsafeArenaSwap(&other->_weak_field_map_);\n");
}
- } else {
+ } else {
format("GetReflection()->Swap(this, other);");
- }
-
+ }
+
format.Outdent();
format("}\n");
-}
-
+}
+
void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
Formatter format(printer, variables_);
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
// We don't override the generalized MergeFrom (aka that which
// takes in the Message base class as a parameter); instead we just
// let the base Message::MergeFrom take care of it. The base MergeFrom
@@ -3065,7 +3065,7 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
// the fast MergeFrom overload. Most callers avoid all this by passing
// a "from" message that is the same type as the message being merged
// into, rather than a generic Message.
-
+
format(
"const ::$proto_ns$::Message::ClassData "
"$classname$::_class_data_ = {\n"
@@ -3081,31 +3081,31 @@ void MessageGenerator::GenerateMergeFrom(io::Printer* printer) {
" static_cast<const $classname$ &>(from));\n"
"}\n"
"\n");
- } else {
- // Generate CheckTypeAndMergeFrom().
+ } else {
+ // Generate CheckTypeAndMergeFrom().
format(
"void $classname$::CheckTypeAndMergeFrom(\n"
" const ::$proto_ns$::MessageLite& from) {\n"
" MergeFrom(*::$proto_ns$::internal::DownCast<const $classname$*>(\n"
" &from));\n"
"}\n");
- }
+ }
}
-
+
void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
- // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast.
+ // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast.
Formatter format(printer, variables_);
format(
- "void $classname$::MergeFrom(const $classname$& from) {\n"
- "// @@protoc_insertion_point(class_specific_merge_from_start:"
- "$full_name$)\n"
+ "void $classname$::MergeFrom(const $classname$& from) {\n"
+ "// @@protoc_insertion_point(class_specific_merge_from_start:"
+ "$full_name$)\n"
" $DCHK$_NE(&from, this);\n");
format.Indent();
-
+
format(
"$uint32$ cached_has_bits = 0;\n"
"(void) cached_has_bits;\n\n");
-
+
std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields(
optimized_order_,
[&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool {
@@ -3212,9 +3212,9 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
// Reset here as it may have been updated in just closed if statement.
cached_has_word_index = -1;
}
- }
-
- // Merge oneof fields. Oneof field requires oneof case check.
+ }
+
+ // Merge oneof fields. Oneof field requires oneof case check.
for (auto oneof : OneOfRange(descriptor_)) {
format("switch (from.$1$_case()) {\n", oneof->name());
format.Indent();
@@ -3227,19 +3227,19 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
format("break;\n");
format.Outdent();
format("}\n");
- }
+ }
format(
"case $1$_NOT_SET: {\n"
- " break;\n"
- "}\n",
+ " break;\n"
+ "}\n",
ToUpper(oneof->name()));
format.Outdent();
format("}\n");
- }
+ }
if (num_weak_fields_) {
format("_weak_field_map_.MergeFrom(from._weak_field_map_);\n");
}
-
+
// Merging of extensions and unknown fields is done last, to maximize
// the opportunity for tail calls.
if (descriptor_->extension_range_count() > 0) {
@@ -3252,11 +3252,11 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) {
format.Outdent();
format("}\n");
-}
-
+}
+
void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
Formatter format(printer, variables_);
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
// We don't override the generalized CopyFrom (aka that which
// takes in the Message base class as a parameter); instead we just
// let the base Message::CopyFrom take care of it. The base MergeFrom
@@ -3267,17 +3267,17 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
// when in debug builds.
// Most callers avoid this by passing a "from" message that is the same
// type as the message being merged into, rather than a generic Message.
- }
-
- // Generate the class-specific CopyFrom.
+ }
+
+ // Generate the class-specific CopyFrom.
format(
- "void $classname$::CopyFrom(const $classname$& from) {\n"
- "// @@protoc_insertion_point(class_specific_copy_from_start:"
+ "void $classname$::CopyFrom(const $classname$& from) {\n"
+ "// @@protoc_insertion_point(class_specific_copy_from_start:"
"$full_name$)\n");
format.Indent();
-
+
format("if (&from == this) return;\n");
-
+
if (!options_.opensource_runtime) {
// This check is disabled in the opensource release because we're
// concerned that many users do not define NDEBUG in their release builds.
@@ -3299,8 +3299,8 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) {
format.Outdent();
format("}\n");
-}
-
+}
+
void MessageGenerator::GenerateSerializeOneofFields(
io::Printer* printer, const std::vector<const FieldDescriptor*>& fields) {
Formatter format(printer, variables_);
@@ -3337,8 +3337,8 @@ void MessageGenerator::GenerateSerializeOneField(io::Printer* printer,
// For weakfields, PrintFieldComment is called during iteration.
PrintFieldComment(format, field);
}
-
- bool have_enclosing_if = false;
+
+ bool have_enclosing_if = false;
if (field->options().weak()) {
} else if (HasHasbit(field)) {
// Attempt to use the state of cached_has_bits, if possible.
@@ -3353,21 +3353,21 @@ void MessageGenerator::GenerateSerializeOneField(io::Printer* printer,
}
format.Indent();
- have_enclosing_if = true;
+ have_enclosing_if = true;
} else if (field->is_optional() && !HasHasbit(field)) {
- have_enclosing_if = EmitFieldNonDefaultCondition(printer, "this->", field);
- }
-
+ have_enclosing_if = EmitFieldNonDefaultCondition(printer, "this->", field);
+ }
+
field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(printer);
-
- if (have_enclosing_if) {
+
+ if (have_enclosing_if) {
format.Outdent();
format("}\n");
- }
+ }
format("\n");
-}
-
-void MessageGenerator::GenerateSerializeOneExtensionRange(
+}
+
+void MessageGenerator::GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range) {
std::map<TProtoStringType, TProtoStringType> vars = variables_;
vars["start"] = StrCat(range->start);
@@ -3377,13 +3377,13 @@ void MessageGenerator::GenerateSerializeOneExtensionRange(
format(
"target = _extensions_._InternalSerialize(\n"
" $start$, $end$, target, stream);\n\n");
-}
-
+}
+
void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) {
Formatter format(printer, variables_);
- if (descriptor_->options().message_set_wire_format()) {
- // Special-case MessageSet.
+ if (descriptor_->options().message_set_wire_format()) {
+ // Special-case MessageSet.
format(
"$uint8$* $classname$::_InternalSerialize(\n"
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
@@ -3401,46 +3401,46 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray(
format(
" return target;\n"
"}\n");
- return;
- }
-
+ return;
+ }
+
format(
"$uint8$* $classname$::_InternalSerialize(\n"
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
"const {\n"
"$annotate_serialize$");
format.Indent();
-
+
format("// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n");
-
+
if (!ShouldSerializeInOrder(descriptor_, options_)) {
format.Outdent();
format("#ifdef NDEBUG\n");
format.Indent();
}
-
+
GenerateSerializeWithCachedSizesBody(printer);
-
+
if (!ShouldSerializeInOrder(descriptor_, options_)) {
format.Outdent();
format("#else // NDEBUG\n");
format.Indent();
-
+
GenerateSerializeWithCachedSizesBodyShuffled(printer);
format.Outdent();
format("#endif // !NDEBUG\n");
format.Indent();
- }
-
+ }
+
format("// @@protoc_insertion_point(serialize_to_array_end:$full_name$)\n");
-
+
format.Outdent();
format(
" return target;\n"
"}\n");
-}
-
+}
+
void MessageGenerator::GenerateSerializeWithCachedSizesBody(
io::Printer* printer) {
Formatter format(printer, variables_);
@@ -3456,7 +3456,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
format_(printer),
eager_(IsProto3(mg->descriptor_->file())),
cached_has_bit_index_(kNoHasbit) {}
-
+
~LazySerializerEmitter() { Flush(); }
// If conditions allow, try to accumulate a run of fields from the same
@@ -3582,22 +3582,22 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
sorted_extensions.reserve(descriptor_->extension_range_count());
- for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
- sorted_extensions.push_back(descriptor_->extension_range(i));
- }
- std::sort(sorted_extensions.begin(), sorted_extensions.end(),
- ExtensionRangeSorter());
+ for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
+ sorted_extensions.push_back(descriptor_->extension_range(i));
+ }
+ std::sort(sorted_extensions.begin(), sorted_extensions.end(),
+ ExtensionRangeSorter());
if (num_weak_fields_) {
format(
"::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer("
"_weak_field_map_);\n");
}
-
+
format(
"$uint32$ cached_has_bits = 0;\n"
"(void) cached_has_bits;\n\n");
- // Merge the fields and the extension ranges, both sorted by field number.
+ // Merge the fields and the extension ranges, both sorted by field number.
{
LazySerializerEmitter e(this, printer);
LazyExtensionRangeEmitter re(this, printer);
@@ -3625,11 +3625,11 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody(
e.Flush();
re.AddToRange(sorted_extensions[j++]);
}
- }
+ }
re.Flush();
e.EmitIfNotNull(largest_weak_field.Release());
- }
-
+ }
+
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
@@ -3737,11 +3737,11 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled(
format(
"target = stream->WriteRaw($unknown_fields$.data(),\n"
" static_cast<int>($unknown_fields$.size()), target);\n");
- }
+ }
format.Outdent();
format("}\n");
-}
-
+}
+
std::vector<uint32_t> MessageGenerator::RequiredFieldsBitMask() const {
const int array_size = HasBitsSize();
std::vector<uint32_t> masks(array_size, 0);
@@ -3749,20 +3749,20 @@ std::vector<uint32_t> MessageGenerator::RequiredFieldsBitMask() const {
for (auto field : FieldRange(descriptor_)) {
if (!field->is_required()) {
continue;
- }
+ }
const int has_bit_index = has_bit_indices_[field->index()];
masks[has_bit_index / 32] |= static_cast<uint32_t>(1)
<< (has_bit_index % 32);
- }
+ }
return masks;
-}
-
+}
+
void MessageGenerator::GenerateByteSize(io::Printer* printer) {
Formatter format(printer, variables_);
-
- if (descriptor_->options().message_set_wire_format()) {
- // Special-case MessageSet.
+
+ if (descriptor_->options().message_set_wire_format()) {
+ // Special-case MessageSet.
std::map<TProtoStringType, TProtoStringType> vars;
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
@@ -3780,38 +3780,38 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
" SetCachedSize(cached_size);\n"
" return total_size;\n"
"}\n");
- return;
- }
-
+ return;
+ }
+
if (num_required_fields_ > 1) {
- // Emit a function (rarely used, we hope) that handles the required fields
- // by checking for each one individually.
+ // Emit a function (rarely used, we hope) that handles the required fields
+ // by checking for each one individually.
format(
"size_t $classname$::RequiredFieldsByteSizeFallback() const {\n"
- "// @@protoc_insertion_point(required_fields_byte_size_fallback_start:"
+ "// @@protoc_insertion_point(required_fields_byte_size_fallback_start:"
"$full_name$)\n");
format.Indent();
format("size_t total_size = 0;\n");
for (auto field : optimized_order_) {
- if (field->is_required()) {
+ if (field->is_required()) {
format(
"\n"
"if (_internal_has_$1$()) {\n",
FieldName(field));
format.Indent();
PrintFieldComment(format, field);
- field_generators_.get(field).GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(printer);
format.Outdent();
format("}\n");
- }
- }
+ }
+ }
format(
"\n"
"return total_size;\n");
format.Outdent();
format("}\n");
- }
-
+ }
+
format(
"size_t $classname$::ByteSizeLong() const {\n"
"$annotate_bytesize$"
@@ -3820,7 +3820,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
format(
"size_t total_size = 0;\n"
"\n");
-
+
if (descriptor_->extension_range_count() > 0) {
format(
"total_size += _extensions_.ByteSize();\n"
@@ -3831,11 +3831,11 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
SetUnknownFieldsVariable(descriptor_, options_, &vars);
format.AddMap(vars);
- // Handle required fields (if any). We expect all of them to be
- // present, so emit one conditional that checks for that. If they are all
- // present then the fast path executes; otherwise the slow path executes.
+ // Handle required fields (if any). We expect all of them to be
+ // present, so emit one conditional that checks for that. If they are all
+ // present then the fast path executes; otherwise the slow path executes.
if (num_required_fields_ > 1) {
- // The fast path works if all required fields are present.
+ // The fast path works if all required fields are present.
const std::vector<uint32_t> masks_for_has_bits = RequiredFieldsBitMask();
format("if ($1$) { // All required fields are present.\n",
ConditionalToCheckBitmasks(masks_for_has_bits));
@@ -3843,29 +3843,29 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// Oneof fields cannot be required, so optimized_order_ contains all of the
// fields that we need to potentially emit.
for (auto field : optimized_order_) {
- if (!field->is_required()) continue;
+ if (!field->is_required()) continue;
PrintFieldComment(format, field);
- field_generators_.get(field).GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(printer);
format("\n");
- }
+ }
format.Outdent();
format(
"} else {\n" // the slow path
" total_size += RequiredFieldsByteSizeFallback();\n"
"}\n");
- } else {
- // num_required_fields_ <= 1: no need to be tricky
+ } else {
+ // num_required_fields_ <= 1: no need to be tricky
for (auto field : optimized_order_) {
- if (!field->is_required()) continue;
+ if (!field->is_required()) continue;
PrintFieldComment(format, field);
format("if (_internal_has_$1$()) {\n", FieldName(field));
format.Indent();
- field_generators_.get(field).GenerateByteSize(printer);
+ field_generators_.get(field).GenerateByteSize(printer);
format.Outdent();
format("}\n");
- }
- }
-
+ }
+ }
+
std::vector<std::vector<const FieldDescriptor*>> chunks = CollectFields(
optimized_order_,
[&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool {
@@ -3875,27 +3875,27 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// Remove chunks with required fields.
chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired),
chunks.end());
-
+
ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio);
int cached_has_word_index = -1;
-
+
format(
"$uint32$ cached_has_bits = 0;\n"
"// Prevent compiler warnings about cached_has_bits being unused\n"
"(void) cached_has_bits;\n\n");
-
+
for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) {
const std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index];
const bool have_outer_if =
chunk.size() > 1 && HasWordIndex(chunk[0]) != kNoHasbit;
cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", printer);
-
+
if (have_outer_if) {
// Emit an if() that will let us skip the whole chunk if none are set.
uint32_t chunk_mask = GenChunkMask(chunk, has_bit_indices_);
TProtoStringType chunk_mask_str =
StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8));
-
+
// Check (up to) 8 has_bits at a time if we have more than one field in
// this chunk. Due to field layout ordering, we may check
// _has_bits_[last_chunk * 8 / 32] multiple times.
@@ -3905,20 +3905,20 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (cached_has_word_index != HasWordIndex(chunk.front())) {
cached_has_word_index = HasWordIndex(chunk.front());
format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index);
- }
+ }
format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str);
format.Indent();
- }
-
+ }
+
// Go back and emit checks for each of the fields we processed.
for (int j = 0; j < chunk.size(); j++) {
const FieldDescriptor* field = chunk[j];
const FieldGenerator& generator = field_generators_.get(field);
bool have_enclosing_if = false;
bool need_extra_newline = false;
-
+
PrintFieldComment(format, field);
-
+
if (field->is_repeated()) {
// No presence check is required.
need_extra_newline = true;
@@ -3944,7 +3944,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
if (need_extra_newline) {
format("\n");
}
- }
+ }
if (have_outer_if) {
format.Outdent();
@@ -3955,10 +3955,10 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
// Reset here as it may have been updated in just closed if statement.
cached_has_word_index = -1;
}
- }
-
- // Fields inside a oneof don't use _has_bits_ so we count them in a separate
- // pass.
+ }
+
+ // Fields inside a oneof don't use _has_bits_ so we count them in a separate
+ // pass.
for (auto oneof : OneOfRange(descriptor_)) {
format("switch ($1$_case()) {\n", oneof->name());
format.Indent();
@@ -3972,16 +3972,16 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
format("break;\n");
format.Outdent();
format("}\n");
- }
+ }
format(
"case $1$_NOT_SET: {\n"
- " break;\n"
- "}\n",
+ " break;\n"
+ "}\n",
ToUpper(oneof->name()));
format.Outdent();
format("}\n");
- }
-
+ }
+
if (num_weak_fields_) {
// TagSize + MessageSize
format("total_size += _weak_field_map_.ByteSizeLong();\n");
@@ -3999,7 +3999,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
format(" total_size += $unknown_fields$.size();\n");
}
format("}\n");
-
+
// We update _cached_size_ even though this is a const method. Because
// const methods might be called concurrently this needs to be atomic
// operations or the program is undefined. In practice, since any concurrent
@@ -4015,13 +4015,13 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) {
format.Outdent();
format("}\n");
-}
-
+}
+
void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
Formatter format(printer, variables_);
format("bool $classname$::IsInitialized() const {\n");
format.Indent();
-
+
if (descriptor_->extension_range_count() > 0) {
format(
"if (!_extensions_.IsInitialized()) {\n"
@@ -4033,15 +4033,15 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
format(
"if (_Internal::MissingRequiredFields(_has_bits_))"
" return false;\n");
- }
-
+ }
+
// Now check that all non-oneof embedded messages are initialized.
for (auto field : optimized_order_) {
// TODO(ckennelly): Push this down into a generator?
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- !ShouldIgnoreRequiredFieldCheck(field, options_) &&
+ if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
+ !ShouldIgnoreRequiredFieldCheck(field, options_) &&
scc_analyzer_->HasRequiredFields(field->message_type())) {
- if (field->is_repeated()) {
+ if (field->is_repeated()) {
if (IsImplicitWeakField(field, options_, scc_analyzer_)) {
format(
"if "
@@ -4064,7 +4064,7 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
" if (!$1$().IsInitialized()) return false;\n"
"}\n",
FieldName(field));
- } else {
+ } else {
GOOGLE_CHECK(!field->real_containing_oneof());
format(
"if (_internal_has_$1$()) {\n"
@@ -4108,19 +4108,19 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
GOOGLE_CHECK(!(field->options().weak() || !field->real_containing_oneof()));
if (field->options().weak()) {
// Just skip.
- } else {
+ } else {
format(
"if (has_$1$()) {\n"
" if (!this->$1$().IsInitialized()) return false;\n"
"}\n",
FieldName(field));
- }
- }
+ }
+ }
format("break;\n");
format.Outdent();
format("}\n");
- }
+ }
format(
"case $1$_NOT_SET: {\n"
" break;\n"
@@ -4128,17 +4128,17 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) {
ToUpper(oneof->name()));
format.Outdent();
format("}\n");
- }
-
+ }
+
format.Outdent();
format(
" return true;\n"
"}\n");
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
index 904a98acfec..31abe51ee8f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -1,43 +1,43 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
+
#include <cstdint>
-#include <memory>
-#include <set>
+#include <memory>
+#include <set>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_field.h>
@@ -45,57 +45,57 @@
#include <google/protobuf/compiler/cpp/cpp_message_layout_helper.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/compiler/cpp/cpp_parse_function_generator.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
class EnumGenerator; // enum.h
class ExtensionGenerator; // extension.h
-
-class MessageGenerator {
- public:
- // See generator.cc for the meaning of dllexport_decl.
+
+class MessageGenerator {
+ public:
+ // See generator.cc for the meaning of dllexport_decl.
MessageGenerator(const Descriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& vars,
int index_in_file_messages, const Options& options,
MessageSCCAnalyzer* scc_analyzer);
- ~MessageGenerator();
-
+ ~MessageGenerator();
+
// Append the two types of nested generators to the corresponding vector.
void AddGenerators(
std::vector<std::unique_ptr<EnumGenerator>>* enum_generators,
std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators);
- // Generate definitions for this class and all its nested types.
- void GenerateClassDefinition(io::Printer* printer);
-
- // Generate definitions of inline methods (placed at the end of the header
- // file).
+ // Generate definitions for this class and all its nested types.
+ void GenerateClassDefinition(io::Printer* printer);
+
+ // Generate definitions of inline methods (placed at the end of the header
+ // file).
void GenerateInlineMethods(io::Printer* printer);
-
- // Source file stuff.
-
- // Generate all non-inline methods for this class.
- void GenerateClassMethods(io::Printer* printer);
-
+
+ // Source file stuff.
+
+ // Generate all non-inline methods for this class.
+ void GenerateClassMethods(io::Printer* printer);
+
// Generate source file code that should go outside any namespace.
void GenerateSourceInProto2Namespace(io::Printer* printer);
- private:
- // Generate declarations and definitions of accessors for fields.
- void GenerateFieldAccessorDeclarations(io::Printer* printer);
+ private:
+ // Generate declarations and definitions of accessors for fields.
+ void GenerateFieldAccessorDeclarations(io::Printer* printer);
void GenerateFieldAccessorDefinitions(io::Printer* printer);
-
+
// Generate the table-driven parsing array. Returns the number of entries
// generated.
size_t GenerateParseOffsets(io::Printer* printer);
@@ -112,66 +112,66 @@ class MessageGenerator {
// For each field generates a table entry describing the field for the
// table driven serializer.
int GenerateFieldMetadata(io::Printer* printer);
-
- // Generate constructors and destructor.
- void GenerateStructors(io::Printer* printer);
-
- // The compiler typically generates multiple copies of each constructor and
- // destructor: http://gcc.gnu.org/bugs.html#nonbugs_cxx
- // Placing common code in a separate method reduces the generated code size.
- //
- // Generate the shared constructor code.
- void GenerateSharedConstructorCode(io::Printer* printer);
- // Generate the shared destructor code.
- void GenerateSharedDestructorCode(io::Printer* printer);
- // Generate the arena-specific destructor code.
- void GenerateArenaDestructorCode(io::Printer* printer);
-
+
+ // Generate constructors and destructor.
+ void GenerateStructors(io::Printer* printer);
+
+ // The compiler typically generates multiple copies of each constructor and
+ // destructor: http://gcc.gnu.org/bugs.html#nonbugs_cxx
+ // Placing common code in a separate method reduces the generated code size.
+ //
+ // Generate the shared constructor code.
+ void GenerateSharedConstructorCode(io::Printer* printer);
+ // Generate the shared destructor code.
+ void GenerateSharedDestructorCode(io::Printer* printer);
+ // Generate the arena-specific destructor code.
+ void GenerateArenaDestructorCode(io::Printer* printer);
+
// Generate the constexpr constructor for constant initialization of the
// default instance.
void GenerateConstexprConstructor(io::Printer* printer);
- // Generate standard Message methods.
- void GenerateClear(io::Printer* printer);
- void GenerateOneofClear(io::Printer* printer);
- void GenerateSerializeWithCachedSizes(io::Printer* printer);
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);
+ // Generate standard Message methods.
+ void GenerateClear(io::Printer* printer);
+ void GenerateOneofClear(io::Printer* printer);
+ void GenerateSerializeWithCachedSizes(io::Printer* printer);
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);
void GenerateSerializeWithCachedSizesBody(io::Printer* printer);
void GenerateSerializeWithCachedSizesBodyShuffled(io::Printer* printer);
- void GenerateByteSize(io::Printer* printer);
- void GenerateMergeFrom(io::Printer* printer);
+ void GenerateByteSize(io::Printer* printer);
+ void GenerateMergeFrom(io::Printer* printer);
void GenerateClassSpecificMergeFrom(io::Printer* printer);
- void GenerateCopyFrom(io::Printer* printer);
- void GenerateSwap(io::Printer* printer);
- void GenerateIsInitialized(io::Printer* printer);
-
- // Helpers for GenerateSerializeWithCachedSizes().
+ void GenerateCopyFrom(io::Printer* printer);
+ void GenerateSwap(io::Printer* printer);
+ void GenerateIsInitialized(io::Printer* printer);
+
+ // Helpers for GenerateSerializeWithCachedSizes().
//
// cached_has_bit_index maintains that:
// cached_has_bits = _has_bits_[cached_has_bit_index]
// for cached_has_bit_index >= 0
- void GenerateSerializeOneField(io::Printer* printer,
- const FieldDescriptor* field,
+ void GenerateSerializeOneField(io::Printer* printer,
+ const FieldDescriptor* field,
int cached_has_bits_index);
// Generate a switch statement to serialize 2+ fields from the same oneof.
// Or, if fields.size() == 1, just call GenerateSerializeOneField().
void GenerateSerializeOneofFields(
io::Printer* printer, const std::vector<const FieldDescriptor*>& fields);
- void GenerateSerializeOneExtensionRange(
+ void GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range);
-
- // Generates has_foo() functions and variables for singular field has-bits.
- void GenerateSingularFieldHasBits(const FieldDescriptor* field,
+
+ // Generates has_foo() functions and variables for singular field has-bits.
+ void GenerateSingularFieldHasBits(const FieldDescriptor* field,
Formatter format);
- // Generates has_foo() functions and variables for oneof field has-bits.
+ // Generates has_foo() functions and variables for oneof field has-bits.
void GenerateOneofHasBits(io::Printer* printer);
- // Generates has_foo_bar() functions for oneof members.
- void GenerateOneofMemberHasBits(const FieldDescriptor* field,
+ // Generates has_foo_bar() functions for oneof members.
+ void GenerateOneofMemberHasBits(const FieldDescriptor* field,
const Formatter& format);
- // Generates the clear_foo() method for a field.
+ // Generates the clear_foo() method for a field.
void GenerateFieldClear(const FieldDescriptor* field, bool is_inline,
Formatter format);
-
+
void GenerateConstructorBody(io::Printer* printer,
std::vector<bool> already_processed,
bool copy_constructor) const;
@@ -183,11 +183,11 @@ class MessageGenerator {
bool SameHasByte(const FieldDescriptor* a, const FieldDescriptor* b) const;
std::vector<uint32_t> RequiredFieldsBitMask() const;
- const Descriptor* descriptor_;
+ const Descriptor* descriptor_;
int index_in_file_messages_;
TProtoStringType classname_;
- Options options_;
- FieldGeneratorMap field_generators_;
+ Options options_;
+ FieldGeneratorMap field_generators_;
// optimized_order_ is the order we layout the message's fields in the
// class. This is reused to initialize the fields in-order for cache
// efficiency.
@@ -198,11 +198,11 @@ class MessageGenerator {
int max_has_bit_index_;
std::vector<const EnumGenerator*> enum_generators_;
std::vector<const ExtensionGenerator*> extension_generators_;
- int num_required_fields_;
+ int num_required_fields_;
int num_weak_fields_;
// table_driven_ indicates the generated message uses table-driven parsing.
bool table_driven_;
-
+
std::unique_ptr<MessageLayoutHelper> message_layout_helper_;
std::unique_ptr<ParseFunctionGenerator> parse_function_generator_;
@@ -211,12 +211,12 @@ class MessageGenerator {
std::map<TProtoStringType, TProtoStringType> variables_;
friend class FileGenerator;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
index 720ce273bd7..f8ce78945b3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc
@@ -1,49 +1,49 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_message_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+namespace {
TProtoStringType ReinterpretCast(const TProtoStringType& type,
const TProtoStringType& expression,
bool implicit_weak_field) {
@@ -53,11 +53,11 @@ TProtoStringType ReinterpretCast(const TProtoStringType& type,
return expression;
}
}
-
-void SetMessageVariables(const FieldDescriptor* descriptor,
+
+void SetMessageVariables(const FieldDescriptor* descriptor,
const Options& options, bool implicit_weak,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, variables, options);
+ SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = FieldMessageTypeName(descriptor, options);
(*variables)["casted_member"] = ReinterpretCast(
(*variables)["type"] + "*", (*variables)["name"] + "_", implicit_weak);
@@ -71,28 +71,28 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
(*variables)["type"] + "&>(\n" +
(*variables)["type_default_instance"] + "));\n")
: "";
- // NOTE: Escaped here to unblock proto1->proto2 migration.
- // TODO(liujisi): Extend this to apply for other conflicting methods.
- (*variables)["release_name"] =
+ // NOTE: Escaped here to unblock proto1->proto2 migration.
+ // TODO(liujisi): Extend this to apply for other conflicting methods.
+ (*variables)["release_name"] =
SafeFunctionName(descriptor->containing_type(), descriptor, "release_");
- (*variables)["full_name"] = descriptor->full_name();
-}
-
-} // namespace
-
-// ===================================================================
-
-MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
+ (*variables)["full_name"] = descriptor->full_name();
+}
+
+} // namespace
+
+// ===================================================================
+
+MessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer)
: FieldGenerator(descriptor, options),
implicit_weak_field_(
IsImplicitWeakField(descriptor, options, scc_analyzer)) {
SetMessageVariables(descriptor, options, implicit_weak_field_, &variables_);
-}
-
-MessageFieldGenerator::~MessageFieldGenerator() {}
-
+}
+
+MessageFieldGenerator::~MessageFieldGenerator() {}
+
void MessageFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
if (implicit_weak_field_) {
@@ -100,8 +100,8 @@ void MessageFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
} else {
format("$type$* $name$_;\n");
}
-}
-
+}
+
void MessageFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -122,8 +122,8 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$() { "
"__builtin_trap(); }\n",
descriptor_);
- return;
- }
+ return;
+ }
format(
"$deprecated_attr$const $type$& ${1$$name$$}$() const;\n"
"PROTOBUF_MUST_USE_RESULT $deprecated_attr$$type$* "
@@ -139,17 +139,17 @@ void MessageFieldGenerator::GenerateAccessorDeclarations(
"$type$* ${1$_internal_mutable_$name$$}$();\n"
"public:\n",
descriptor_);
- }
+ }
format(
"$deprecated_attr$void "
"${1$unsafe_arena_set_allocated_$name$$}$(\n"
" $type$* $name$);\n"
"$deprecated_attr$$type$* ${1$unsafe_arena_release_$name$$}$();\n",
descriptor_);
-}
-
-void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(
- io::Printer* printer) const {
+}
+
+void MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(
+ io::Printer* printer) const {
}
void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
@@ -161,18 +161,18 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" const $type$* p = $casted_member$;\n"
" return p != nullptr ? *p : reinterpret_cast<const $type$&>(\n"
" $type_default_instance$);\n"
- "}\n"
+ "}\n"
"inline const $type$& $classname$::$name$() const {\n"
"$annotate_get$"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" return _internal_$name$();\n"
- "}\n");
+ "}\n");
format(
"inline void $classname$::unsafe_arena_set_allocated_$name$(\n"
- " $type$* $name$) {\n"
- // If we're not on an arena, free whatever we were holding before.
- // (If we are on arena, we can just forget the earlier pointer.)
+ " $type$* $name$) {\n"
+ // If we're not on an arena, free whatever we were holding before.
+ // (If we are on arena, we can just forget the earlier pointer.)
" if (GetArenaForAllocation() == nullptr) {\n"
" delete reinterpret_cast<::$proto_ns$::MessageLite*>($name$_);\n"
" }\n");
@@ -184,20 +184,20 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(" $name$_ = $name$;\n");
}
format(
- " if ($name$) {\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
- " }\n"
+ " if ($name$) {\n"
+ " $set_hasbit$\n"
+ " } else {\n"
+ " $clear_hasbit$\n"
+ " }\n"
"$annotate_set$"
- " // @@protoc_insertion_point(field_unsafe_arena_set_allocated"
- ":$full_name$)\n"
- "}\n");
+ " // @@protoc_insertion_point(field_unsafe_arena_set_allocated"
+ ":$full_name$)\n"
+ "}\n");
format(
"inline $type$* $classname$::$release_name$() {\n"
"$type_reference_function$"
"$annotate_release$"
- " $clear_hasbit$\n"
+ " $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n"
"#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE\n"
@@ -207,24 +207,24 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
"#else // PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" if (GetArenaForAllocation() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
- " }\n"
+ " }\n"
"#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE\n"
" return temp;\n"
- "}\n"
+ "}\n"
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n"
"$annotate_release$"
- " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
"$type_reference_function$"
- " $clear_hasbit$\n"
+ " $clear_hasbit$\n"
" $type$* temp = $casted_member$;\n"
" $name$_ = nullptr;\n"
- " return temp;\n"
- "}\n");
-
+ " return temp;\n"
+ "}\n");
+
format(
"inline $type$* $classname$::_internal_mutable_$name$() {\n"
"$type_reference_function$"
- " $set_hasbit$\n"
+ " $set_hasbit$\n"
" if ($name$_ == nullptr) {\n"
" auto* p = CreateMaybeMessage<$type$>(GetArenaForAllocation());\n");
if (implicit_weak_field_) {
@@ -233,13 +233,13 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(" $name$_ = p;\n");
}
format(
- " }\n"
+ " }\n"
" return $casted_member$;\n"
"}\n"
"inline $type$* $classname$::mutable_$name$() {\n"
" $type$* _msg = _internal_mutable_$name$();\n"
"$annotate_mutable$"
- " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
+ " // @@protoc_insertion_point(field_mutable:$full_name$)\n"
" return _msg;\n"
"}\n");
@@ -256,7 +256,7 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
format(" delete $name$_;\n");
}
format(
- " }\n"
+ " }\n"
" if ($name$) {\n");
if (IsCrossFileMessage(descriptor_)) {
// We have to read the arena through the virtual method, because the type
@@ -278,9 +278,9 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
" $name$ = ::$proto_ns$::internal::GetOwnedMessage(\n"
" message_arena, $name$, submessage_arena);\n"
" }\n"
- " $set_hasbit$\n"
- " } else {\n"
- " $clear_hasbit$\n"
+ " $set_hasbit$\n"
+ " } else {\n"
+ " $clear_hasbit$\n"
" }\n");
if (implicit_weak_field_) {
format(" $name$_ = reinterpret_cast<MessageLite*>($name$);\n");
@@ -289,8 +289,8 @@ void MessageFieldGenerator::GenerateInlineAccessorDefinitions(
}
format(
"$annotate_set$"
- " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
- "}\n");
+ " // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
+ "}\n");
}
void MessageFieldGenerator::GenerateInternalAccessorDeclarations(
@@ -302,11 +302,11 @@ void MessageFieldGenerator::GenerateInternalAccessorDeclarations(
"const $classname$* msg);\n"
"static ::$proto_ns$::MessageLite* mutable_$name$("
"$classname$* msg);\n");
- } else {
+ } else {
format("static const $type$& $name$(const $classname$* msg);\n");
}
}
-
+
void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
io::Printer* printer) const {
// In theory, these accessors could be inline in _Internal. However, in
@@ -335,7 +335,7 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
"$classname$::_Internal::mutable_$name$($classname$* msg) {\n");
if (HasHasbit(descriptor_)) {
format(" msg->$set_hasbit$\n");
- }
+ }
format(
" if (msg->$name$_ == nullptr) {\n"
" if ($type_default_instance_ptr$ == nullptr) {\n"
@@ -360,26 +360,26 @@ void MessageFieldGenerator::GenerateInternalAccessorDefinitions(
"$classname$::_Internal::$name$(const $classname$* msg) {\n"
" return *msg->$field_member$;\n"
"}\n");
- }
-}
-
+ }
+}
+
void MessageFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
if (!HasHasbit(descriptor_)) {
- // If we don't have has-bits, message presence is indicated only by ptr !=
- // NULL. Thus on clear, we need to delete the object.
+ // If we don't have has-bits, message presence is indicated only by ptr !=
+ // NULL. Thus on clear, we need to delete the object.
format(
"if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n"
" delete $name$_;\n"
"}\n"
"$name$_ = nullptr;\n");
- } else {
+ } else {
format("if ($name$_ != nullptr) $name$_->Clear();\n");
- }
-}
-
+ }
+}
+
void MessageFieldGenerator::GenerateMessageClearingCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -402,7 +402,7 @@ void MessageFieldGenerator::GenerateMessageClearingCode(
void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
+
Formatter format(printer, variables_);
if (implicit_weak_field_) {
format(
@@ -413,8 +413,8 @@ void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
"_internal_mutable_$name$()->$type$::MergeFrom(from._internal_$name$())"
";\n");
}
-}
-
+}
+
void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -435,8 +435,8 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
format("if (this != internal_default_instance()) ");
}
format("delete $name$_;\n");
-}
-
+}
+
void MessageFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -456,8 +456,8 @@ void MessageFieldGenerator::GenerateCopyConstructorCode(
"} else {\n"
" $name$_ = nullptr;\n"
"}\n");
-}
-
+}
+
void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -468,8 +468,8 @@ void MessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
"target = ::$proto_ns$::internal::WireFormatLite::\n"
" InternalWrite$declared_type$(\n"
" $number$, _Internal::$name$(this), target, stream);\n");
-}
-
+}
+
void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -478,25 +478,25 @@ void MessageFieldGenerator::GenerateByteSize(io::Printer* printer) const {
"total_size += $tag_size$ +\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" *$field_member$);\n");
-}
-
+}
+
void MessageFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_(nullptr)");
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
MessageOneofFieldGenerator::MessageOneofFieldGenerator(
const FieldDescriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer)
: MessageFieldGenerator(descriptor, options, scc_analyzer) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
-}
-
-MessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}
-
+ SetCommonOneofFieldVariables(descriptor, &variables_);
+}
+
+MessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}
+
void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -519,7 +519,7 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
" ::$proto_ns$::Arena* submessage_arena =\n"
" ::$proto_ns$::Arena::InternalHelper<"
"$type$>::GetOwningArena($name$);\n");
- }
+ }
format(
" if (message_arena != submessage_arena) {\n"
" $name$ = ::$proto_ns$::internal::GetOwnedMessage(\n"
@@ -531,34 +531,34 @@ void MessageOneofFieldGenerator::GenerateNonInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
-}
-
+}
+
void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"inline $type$* $classname$::$release_name$() {\n"
"$annotate_release$"
- " // @@protoc_insertion_point(field_release:$full_name$)\n"
+ " // @@protoc_insertion_point(field_release:$full_name$)\n"
" if (_internal_has_$name$()) {\n"
" clear_has_$oneof_name$();\n"
" $type$* temp = $field_member$;\n"
" if (GetArenaForAllocation() != nullptr) {\n"
" temp = ::$proto_ns$::internal::DuplicateIfNonNull(temp);\n"
- " }\n"
+ " }\n"
" $field_member$ = nullptr;\n"
" return temp;\n"
- " } else {\n"
+ " } else {\n"
" return nullptr;\n"
- " }\n"
+ " }\n"
"}\n");
-
+
format(
"inline const $type$& $classname$::_internal_$name$() const {\n"
" return _internal_has_$name$()\n"
" ? *$field_member$\n"
" : reinterpret_cast< $type$&>($type_default_instance$);\n"
- "}\n"
+ "}\n"
"inline const $type$& $classname$::$name$() const {\n"
"$annotate_get$"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
@@ -566,30 +566,30 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"}\n"
"inline $type$* $classname$::unsafe_arena_release_$name$() {\n"
"$annotate_release$"
- " // @@protoc_insertion_point(field_unsafe_arena_release"
- ":$full_name$)\n"
+ " // @@protoc_insertion_point(field_unsafe_arena_release"
+ ":$full_name$)\n"
" if (_internal_has_$name$()) {\n"
- " clear_has_$oneof_name$();\n"
+ " clear_has_$oneof_name$();\n"
" $type$* temp = $field_member$;\n"
" $field_member$ = nullptr;\n"
- " return temp;\n"
- " } else {\n"
+ " return temp;\n"
+ " } else {\n"
" return nullptr;\n"
- " }\n"
- "}\n"
+ " }\n"
+ "}\n"
"inline void $classname$::unsafe_arena_set_allocated_$name$"
- "($type$* $name$) {\n"
+ "($type$* $name$) {\n"
// We rely on the oneof clear method to free the earlier contents of
// this oneof. We can directly use the pointer we're given to set the
// new value.
- " clear_$oneof_name$();\n"
- " if ($name$) {\n"
- " set_has_$name$();\n"
+ " clear_$oneof_name$();\n"
+ " if ($name$) {\n"
+ " set_has_$name$();\n"
" $field_member$ = $name$;\n"
- " }\n"
+ " }\n"
"$annotate_set$"
- " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
- "$full_name$)\n"
+ " // @@protoc_insertion_point(field_unsafe_arena_set_allocated:"
+ "$full_name$)\n"
"}\n"
"inline $type$* $classname$::_internal_mutable_$name$() {\n"
" if (!_internal_has_$name$()) {\n"
@@ -597,17 +597,17 @@ void MessageOneofFieldGenerator::GenerateInlineAccessorDefinitions(
" set_has_$name$();\n"
" $field_member$ = CreateMaybeMessage< $type$ "
">(GetArenaForAllocation());\n"
- " }\n"
- " return $field_member$;\n"
- "}\n"
+ " }\n"
+ " return $field_member$;\n"
+ "}\n"
"inline $type$* $classname$::mutable_$name$() {\n"
" $type$* _msg = _internal_mutable_$name$();\n"
"$annotate_mutable$"
" // @@protoc_insertion_point(field_mutable:$full_name$)\n"
" return _msg;\n"
- "}\n");
-}
-
+ "}\n");
+}
+
void MessageOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -616,9 +616,9 @@ void MessageOneofFieldGenerator::GenerateClearingCode(
format(
"if (GetArenaForAllocation() == nullptr) {\n"
" delete $field_member$;\n"
- "}\n");
-}
-
+ "}\n");
+}
+
void MessageOneofFieldGenerator::GenerateMessageClearingCode(
io::Printer* printer) const {
GenerateClearingCode(printer);
@@ -626,9 +626,9 @@ void MessageOneofFieldGenerator::GenerateMessageClearingCode(
void MessageOneofFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
+ // Don't print any swapping code. Swapping the union will swap this field.
+}
+
void MessageOneofFieldGenerator::GenerateDestructorCode(
io::Printer* printer) const {
// We inherit from MessageFieldGenerator, so we need to override the default
@@ -637,23 +637,23 @@ void MessageOneofFieldGenerator::GenerateDestructorCode(
void MessageOneofFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
- // Don't print any constructor code. The field is in a union. We allocate
- // space only when this field is used.
-}
-
-// ===================================================================
-
-RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
+ // Don't print any constructor code. The field is in a union. We allocate
+ // space only when this field is used.
+}
+
+// ===================================================================
+
+RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
const FieldDescriptor* descriptor, const Options& options,
MessageSCCAnalyzer* scc_analyzer)
: FieldGenerator(descriptor, options),
implicit_weak_field_(
IsImplicitWeakField(descriptor, options, scc_analyzer)) {
SetMessageVariables(descriptor, options, implicit_weak_field_, &variables_);
-}
-
-RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
-
+}
+
+RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
+
void RepeatedMessageFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -661,9 +661,9 @@ void RepeatedMessageFieldGenerator::GeneratePrivateMembers(
format("::$proto_ns$::WeakRepeatedPtrField< $type$ > $name$_;\n");
} else {
format("::$proto_ns$::RepeatedPtrField< $type$ > $name$_;\n");
- }
-}
-
+ }
+}
+
void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -681,7 +681,7 @@ void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations(
" ${1$$name$$}$() const { __builtin_trap(); }\n",
descriptor_);
return;
- }
+ }
format(
"$deprecated_attr$$type$* ${1$mutable_$name$$}$(int index);\n"
"$deprecated_attr$::$proto_ns$::RepeatedPtrField< $type$ >*\n"
@@ -694,20 +694,20 @@ void RepeatedMessageFieldGenerator::GenerateAccessorDeclarations(
"$type$* ${1$_internal_add_$name$$}$();\n"
"public:\n",
descriptor_);
- }
+ }
format(
"$deprecated_attr$const $type$& ${1$$name$$}$(int index) const;\n"
"$deprecated_attr$$type$* ${1$add_$name$$}$();\n"
"$deprecated_attr$const ::$proto_ns$::RepeatedPtrField< $type$ >&\n"
" ${1$$name$$}$() const;\n",
descriptor_);
-}
-
+}
+
void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
format.Set("weak", implicit_weak_field_ ? ".weak" : "");
-
+
format(
"inline $type$* $classname$::mutable_$name$(int index) {\n"
"$annotate_mutable$"
@@ -722,8 +722,8 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
"$type_reference_function$"
" return &$name$_$weak$;\n"
- "}\n");
-
+ "}\n");
+
if (options_.safe_boundary_check) {
format(
"inline const $type$& $classname$::_internal_$name$(int index) const "
@@ -738,63 +738,63 @@ void RepeatedMessageFieldGenerator::GenerateInlineAccessorDefinitions(
"$type_reference_function$"
" return $name$_$weak$.Get(index);\n"
"}\n");
- }
-
+ }
+
format(
"inline const $type$& $classname$::$name$(int index) const {\n"
"$annotate_get$"
- " // @@protoc_insertion_point(field_get:$full_name$)\n"
+ " // @@protoc_insertion_point(field_get:$full_name$)\n"
" return _internal_$name$(index);\n"
- "}\n"
+ "}\n"
"inline $type$* $classname$::_internal_add_$name$() {\n"
" return $name$_$weak$.Add();\n"
"}\n"
"inline $type$* $classname$::add_$name$() {\n"
" $type$* _add = _internal_add_$name$();\n"
"$annotate_add_mutable$"
- " // @@protoc_insertion_point(field_add:$full_name$)\n"
+ " // @@protoc_insertion_point(field_add:$full_name$)\n"
" return _add;\n"
- "}\n");
-
+ "}\n");
+
format(
"inline const ::$proto_ns$::RepeatedPtrField< $type$ >&\n"
- "$classname$::$name$() const {\n"
+ "$classname$::$name$() const {\n"
"$annotate_list$"
- " // @@protoc_insertion_point(field_list:$full_name$)\n"
+ " // @@protoc_insertion_point(field_list:$full_name$)\n"
"$type_reference_function$"
" return $name$_$weak$;\n"
- "}\n");
-}
-
+ "}\n");
+}
+
void RepeatedMessageFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
format("$name$_.Clear();\n");
-}
-
+}
+
void RepeatedMessageFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n");
-}
-
+}
+
void RepeatedMessageFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
+}
+
void RepeatedMessageFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
+ // Not needed for repeated fields.
+}
+
void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
@@ -808,7 +808,7 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
" target = ::$proto_ns$::internal::WireFormatLite::\n"
" InternalWrite$declared_type$($number$, **it, target, stream);\n"
"}\n");
- } else {
+ } else {
format(
"for (unsigned int i = 0,\n"
" n = static_cast<unsigned int>(this->_internal_$name$_size()); i < "
@@ -819,13 +819,13 @@ void RepeatedMessageFieldGenerator::GenerateSerializeWithCachedSizesToArray(
" InternalWrite$declared_type$($number$, "
"this->_internal_$name$(i), target, stream);\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedMessageFieldGenerator::GenerateByteSize(
io::Printer* printer) const {
GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_));
-
+
Formatter format(printer, variables_);
format(
"total_size += $tag_size$UL * this->_internal_$name$_size();\n"
@@ -833,15 +833,15 @@ void RepeatedMessageFieldGenerator::GenerateByteSize(
" total_size +=\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(msg);\n"
"}\n");
-}
-
+}
+
void RepeatedMessageFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_()");
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
index 4b4b8ea59b0..4d7b21db8ed 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h
@@ -1,134 +1,134 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
-
-#include <map>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class MessageFieldGenerator : public FieldGenerator {
- public:
- MessageFieldGenerator(const FieldDescriptor* descriptor,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class MessageFieldGenerator : public FieldGenerator {
+ public:
+ MessageFieldGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer);
- ~MessageFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+ ~MessageFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
+ void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateInternalAccessorDeclarations(io::Printer* printer) const;
void GenerateInternalAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
void GenerateMessageClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
void GenerateDestructorCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- protected:
+
+ protected:
const bool implicit_weak_field_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
-};
-
-class MessageOneofFieldGenerator : public MessageFieldGenerator {
- public:
- MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
+};
+
+class MessageOneofFieldGenerator : public MessageFieldGenerator {
+ public:
+ MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer);
- ~MessageOneofFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
+ ~MessageOneofFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
// MessageFieldGenerator, from which we inherit, overrides this so we need to
// override it as well.
void GenerateMessageClearingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
void GenerateDestructorCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
-};
-
-class RepeatedMessageFieldGenerator : public FieldGenerator {
- public:
- RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
+ void GenerateConstructorCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
+};
+
+class RepeatedMessageFieldGenerator : public FieldGenerator {
+ public:
+ RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
const Options& options,
MessageSCCAnalyzer* scc_analyzer);
- ~RepeatedMessageFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+ ~RepeatedMessageFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const {}
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
+
+ private:
const bool implicit_weak_field_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
index ed5cd0b0462..205e6587cc0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_options.h
@@ -1,48 +1,48 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Jeffrey Rennie)
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Jeffrey Rennie)
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
+
#include <string>
#include <google/protobuf/stubs/port.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
class AccessInfoMap;
-namespace cpp {
-
+namespace cpp {
+
enum class EnforceOptimizeMode {
kNoEnforcement, // Use the runtime specified by the file specific options.
kSpeed, // Full runtime with a generated code implementation.
@@ -50,8 +50,8 @@ enum class EnforceOptimizeMode {
kLiteRuntime,
};
-// Generator options (see generator.cc for a description of each):
-struct Options {
+// Generator options (see generator.cc for a description of each):
+struct Options {
TProtoStringType dllexport_decl;
bool safe_boundary_check = false;
bool proto_h = false;
@@ -78,11 +78,11 @@ struct Options {
bool inject_field_listener_events = false;
bool eagerly_verified_lazy = false;
bool force_eagerly_verified_lazy = false;
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index da229ce3c45..2b108413ef8 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -1,57 +1,57 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-using internal::WireFormatLite;
-
-namespace {
-
-// For encodings with fixed sizes, returns that size in bytes. Otherwise
-// returns -1.
-int FixedSize(FieldDescriptor::Type type) {
- switch (type) {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+using internal::WireFormatLite;
+
+namespace {
+
+// For encodings with fixed sizes, returns that size in bytes. Otherwise
+// returns -1.
+int FixedSize(FieldDescriptor::Type type) {
+ switch (type) {
case FieldDescriptor::TYPE_INT32:
return -1;
case FieldDescriptor::TYPE_INT64:
@@ -76,12 +76,12 @@ int FixedSize(FieldDescriptor::Type type) {
return WireFormatLite::kFloatSize;
case FieldDescriptor::TYPE_DOUBLE:
return WireFormatLite::kDoubleSize;
-
+
case FieldDescriptor::TYPE_BOOL:
return WireFormatLite::kBoolSize;
case FieldDescriptor::TYPE_ENUM:
return -1;
-
+
case FieldDescriptor::TYPE_STRING:
return -1;
case FieldDescriptor::TYPE_BYTES:
@@ -90,48 +90,48 @@ int FixedSize(FieldDescriptor::Type type) {
return -1;
case FieldDescriptor::TYPE_MESSAGE:
return -1;
-
+
// No default because we want the compiler to complain if any new
// types are added.
- }
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return -1;
-}
-
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
+ }
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return -1;
+}
+
+void SetPrimitiveVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
+ const Options& options) {
+ SetCommonFieldVariables(descriptor, variables, options);
(*variables)["type"] = PrimitiveTypeName(options, descriptor->cpp_type());
(*variables)["default"] = DefaultValue(options, descriptor);
(*variables)["tag"] = StrCat(internal::WireFormat::MakeTag(descriptor));
- int fixed_size = FixedSize(descriptor->type());
- if (fixed_size != -1) {
+ int fixed_size = FixedSize(descriptor->type());
+ if (fixed_size != -1) {
(*variables)["fixed_size"] = StrCat(fixed_size);
- }
+ }
(*variables)["wire_format_field_type"] = FieldDescriptorProto_Type_Name(
static_cast<FieldDescriptorProto_Type>(descriptor->type()));
- (*variables)["full_name"] = descriptor->full_name();
-}
-
-} // namespace
-
-// ===================================================================
-
-PrimitiveFieldGenerator::PrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
+ (*variables)["full_name"] = descriptor->full_name();
+}
+
+} // namespace
+
+// ===================================================================
+
+PrimitiveFieldGenerator::PrimitiveFieldGenerator(
+ const FieldDescriptor* descriptor, const Options& options)
: FieldGenerator(descriptor, options) {
- SetPrimitiveVariables(descriptor, &variables_, options);
-}
-
-PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}
-
+ SetPrimitiveVariables(descriptor, &variables_, options);
+}
+
+PrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}
+
void PrimitiveFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$type$ $name$_;\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -143,8 +143,8 @@ void PrimitiveFieldGenerator::GenerateAccessorDeclarations(
"void ${1$_internal_set_$name$$}$($type$ value);\n"
"public:\n",
descriptor_);
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -166,29 +166,29 @@ void PrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_ = $default$;\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("_internal_set_$name$(from._internal_$name$());\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("swap($name$_, other->$name$_);\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_ = $default$;\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -203,37 +203,37 @@ void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
"target = "
"::$proto_ns$::internal::WireFormatLite::Write$declared_type$ToArray("
"$number$, this->_internal_$name$(), target);\n");
-}
-
+}
+
void PrimitiveFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
- int fixed_size = FixedSize(descriptor_->type());
- if (fixed_size == -1) {
+ int fixed_size = FixedSize(descriptor_->type());
+ if (fixed_size == -1) {
format(
"total_size += $tag_size$ +\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" this->_internal_$name$());\n");
- } else {
+ } else {
format("total_size += $tag_size$ + $fixed_size$;\n");
- }
-}
-
+ }
+}
+
void PrimitiveFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_($default$)");
}
-// ===================================================================
-
+// ===================================================================
+
PrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator(
const FieldDescriptor* descriptor, const Options& options)
: PrimitiveFieldGenerator(descriptor, options) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
-}
-
-PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}
-
+ SetCommonOneofFieldVariables(descriptor, &variables_);
+}
+
+PrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}
+
void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -261,53 +261,53 @@ void PrimitiveOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
-}
-
+}
+
void PrimitiveOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$field_member$ = $default$;\n");
-}
-
+}
+
void PrimitiveOneofFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
+ // Don't print any swapping code. Swapping the union will swap this field.
+}
+
void PrimitiveOneofFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$ns$::_$classname$_default_instance_.$name$_ = $default$;\n");
-}
-
-// ===================================================================
-
-RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
+}
+
+// ===================================================================
+
+RepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(
+ const FieldDescriptor* descriptor, const Options& options)
: FieldGenerator(descriptor, options) {
- SetPrimitiveVariables(descriptor, &variables_, options);
-
- if (descriptor->is_packed()) {
- variables_["packed_reader"] = "ReadPackedPrimitive";
- variables_["repeated_reader"] = "ReadRepeatedPrimitiveNoInline";
- } else {
- variables_["packed_reader"] = "ReadPackedPrimitiveNoInline";
- variables_["repeated_reader"] = "ReadRepeatedPrimitive";
- }
-}
-
-RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}
-
+ SetPrimitiveVariables(descriptor, &variables_, options);
+
+ if (descriptor->is_packed()) {
+ variables_["packed_reader"] = "ReadPackedPrimitive";
+ variables_["repeated_reader"] = "ReadRepeatedPrimitiveNoInline";
+ } else {
+ variables_["packed_reader"] = "ReadPackedPrimitiveNoInline";
+ variables_["repeated_reader"] = "ReadRepeatedPrimitive";
+ }
+}
+
+RepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}
+
void RepeatedPrimitiveFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("::$proto_ns$::RepeatedField< $type$ > $name$_;\n");
if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 &&
- HasGeneratedMethods(descriptor_->file(), options_)) {
+ HasGeneratedMethods(descriptor_->file(), options_)) {
format("mutable std::atomic<int> _$name$_cached_byte_size_;\n");
- }
-}
-
+ }
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -328,8 +328,8 @@ void RepeatedPrimitiveFieldGenerator::GenerateAccessorDeclarations(
"$deprecated_attr$::$proto_ns$::RepeatedField< $type$ >*\n"
" ${1$mutable_$name$$}$();\n",
descriptor_);
-}
-
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -375,31 +375,31 @@ void RepeatedPrimitiveFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
" return _internal_mutable_$name$();\n"
"}\n");
-}
-
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.Clear();\n");
-}
-
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n");
-}
-
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
+ // Not needed for repeated fields.
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -409,7 +409,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateCopyConstructorCode(
void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (descriptor_->is_packed()) {
+ if (descriptor_->is_packed()) {
if (FixedSize(descriptor_->type()) == -1) {
format(
"{\n"
@@ -427,7 +427,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
"target);\n"
"}\n");
}
- } else {
+ } else {
format(
"for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n"
" target = stream->EnsureSpace(target);\n"
@@ -435,27 +435,27 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray(
"Write$declared_type$ToArray($number$, this->_internal_$name$(i), "
"target);\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("{\n");
format.Indent();
- int fixed_size = FixedSize(descriptor_->type());
- if (fixed_size == -1) {
+ int fixed_size = FixedSize(descriptor_->type());
+ if (fixed_size == -1) {
format(
"size_t data_size = ::$proto_ns$::internal::WireFormatLite::\n"
" $declared_type$Size(this->$name$_);\n");
- } else {
+ } else {
format(
"unsigned int count = static_cast<unsigned "
"int>(this->_internal_$name$_size());\n"
"size_t data_size = $fixed_size$UL * count;\n");
- }
-
- if (descriptor_->is_packed()) {
+ }
+
+ if (descriptor_->is_packed()) {
format(
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
@@ -469,17 +469,17 @@ void RepeatedPrimitiveFieldGenerator::GenerateByteSize(
" std::memory_order_relaxed);\n");
}
format("total_size += data_size;\n");
- } else {
+ } else {
format(
"total_size += $tag_size$ *\n"
" "
"::$proto_ns$::internal::FromIntSize(this->_internal_$name$_size());\n"
"total_size += data_size;\n");
- }
+ }
format.Outdent();
format("}\n");
-}
-
+}
+
void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -490,7 +490,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer(
}
}
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
index 394b304770f..0a96e700379 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
@@ -1,114 +1,114 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
-
-#include <map>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class PrimitiveFieldGenerator : public FieldGenerator {
- public:
- PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~PrimitiveFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class PrimitiveFieldGenerator : public FieldGenerator {
+ public:
+ PrimitiveFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~PrimitiveFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
-};
-
-class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {
- public:
- PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~PrimitiveOneofFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);
+};
+
+class PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {
+ public:
+ PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~PrimitiveOneofFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);
-};
-
-class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
- public:
- RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~RepeatedPrimitiveFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);
+};
+
+class RepeatedPrimitiveFieldGenerator : public FieldGenerator {
+ public:
+ RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~RepeatedPrimitiveFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
index 0a30646fd04..03f7b645b8d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc
@@ -1,47 +1,47 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_service.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
namespace {
void InitMethodVariables(const MethodDescriptor* method, const Options& options,
@@ -58,24 +58,24 @@ ServiceGenerator::ServiceGenerator(
const ServiceDescriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& vars, const Options& options)
: descriptor_(descriptor), vars_(vars), options_(options) {
- vars_["classname"] = descriptor_->name();
- vars_["full_name"] = descriptor_->full_name();
-}
-
-ServiceGenerator::~ServiceGenerator() {}
-
-void ServiceGenerator::GenerateDeclarations(io::Printer* printer) {
+ vars_["classname"] = descriptor_->name();
+ vars_["full_name"] = descriptor_->full_name();
+}
+
+ServiceGenerator::~ServiceGenerator() {}
+
+void ServiceGenerator::GenerateDeclarations(io::Printer* printer) {
Formatter format(printer, vars_);
- // Forward-declare the stub type.
+ // Forward-declare the stub type.
format(
"class $classname$_Stub;\n"
"\n");
-
- GenerateInterface(printer);
- GenerateStubDefinition(printer);
-}
-
-void ServiceGenerator::GenerateInterface(io::Printer* printer) {
+
+ GenerateInterface(printer);
+ GenerateStubDefinition(printer);
+}
+
+void ServiceGenerator::GenerateInterface(io::Printer* printer) {
Formatter format(printer, vars_);
format(
"class $dllexport_decl $$classname$ : public ::$proto_ns$::Service {\n"
@@ -84,17 +84,17 @@ void ServiceGenerator::GenerateInterface(io::Printer* printer) {
" inline $classname$() {};\n"
" public:\n"
" virtual ~$classname$();\n");
- printer->Indent();
-
+ printer->Indent();
+
format(
"\n"
"typedef $classname$_Stub Stub;\n"
"\n"
"static const ::$proto_ns$::ServiceDescriptor* descriptor();\n"
"\n");
-
- GenerateMethodSignatures(VIRTUAL, printer);
-
+
+ GenerateMethodSignatures(VIRTUAL, printer);
+
format(
"\n"
"// implements Service ----------------------------------------------\n"
@@ -109,24 +109,24 @@ void ServiceGenerator::GenerateInterface(io::Printer* printer) {
" const ::$proto_ns$::MethodDescriptor* method) const;\n"
"const ::$proto_ns$::Message& GetResponsePrototype(\n"
" const ::$proto_ns$::MethodDescriptor* method) const;\n");
-
- printer->Outdent();
+
+ printer->Outdent();
format(
"\n"
" private:\n"
" GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$);\n"
"};\n"
"\n");
-}
-
-void ServiceGenerator::GenerateStubDefinition(io::Printer* printer) {
+}
+
+void ServiceGenerator::GenerateStubDefinition(io::Printer* printer) {
Formatter format(printer, vars_);
format(
"class $dllexport_decl $$classname$_Stub : public $classname$ {\n"
" public:\n");
-
- printer->Indent();
-
+
+ printer->Indent();
+
format(
"$classname$_Stub(::$proto_ns$::RpcChannel* channel);\n"
"$classname$_Stub(::$proto_ns$::RpcChannel* channel,\n"
@@ -137,10 +137,10 @@ void ServiceGenerator::GenerateStubDefinition(io::Printer* printer) {
"\n"
"// implements $classname$ ------------------------------------------\n"
"\n");
-
- GenerateMethodSignatures(NON_VIRTUAL, printer);
-
- printer->Outdent();
+
+ GenerateMethodSignatures(NON_VIRTUAL, printer);
+
+ printer->Outdent();
format(
" private:\n"
" ::$proto_ns$::RpcChannel* channel_;\n"
@@ -148,12 +148,12 @@ void ServiceGenerator::GenerateStubDefinition(io::Printer* printer) {
" GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$_Stub);\n"
"};\n"
"\n");
-}
-
+}
+
void ServiceGenerator::GenerateMethodSignatures(VirtualOrNon virtual_or_non,
io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
Formatter format(printer, vars_);
InitMethodVariables(method, options_, &format);
format.Set("virtual", virtual_or_non == VIRTUAL ? "virtual " : "");
@@ -162,12 +162,12 @@ void ServiceGenerator::GenerateMethodSignatures(VirtualOrNon virtual_or_non,
" const $input_type$* request,\n"
" $output_type$* response,\n"
" ::google::protobuf::Closure* done);\n");
- }
-}
-
-// ===================================================================
-
-void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
+ }
+}
+
+// ===================================================================
+
+void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
Formatter format(printer, vars_);
format(
"$classname$::~$classname$() {}\n"
@@ -183,14 +183,14 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
"}\n"
"\n",
index_in_metadata_);
-
- // Generate methods of the interface.
- GenerateNotImplementedMethods(printer);
- GenerateCallMethod(printer);
- GenerateGetPrototype(REQUEST, printer);
- GenerateGetPrototype(RESPONSE, printer);
-
- // Generate stub implementation.
+
+ // Generate methods of the interface.
+ GenerateNotImplementedMethods(printer);
+ GenerateCallMethod(printer);
+ GenerateGetPrototype(REQUEST, printer);
+ GenerateGetPrototype(RESPONSE, printer);
+
+ // Generate stub implementation.
format(
"$classname$_Stub::$classname$_Stub(::$proto_ns$::RpcChannel* channel)\n"
" : channel_(channel), owns_channel_(false) {}\n"
@@ -205,13 +205,13 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) {
" if (owns_channel_) delete channel_;\n"
"}\n"
"\n");
-
- GenerateStubMethods(printer);
-}
-
-void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+
+ GenerateStubMethods(printer);
+}
+
+void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
Formatter format(printer, vars_);
InitMethodVariables(method, options_, &format);
format(
@@ -223,10 +223,10 @@ void ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {
" done->Run();\n"
"}\n"
"\n");
- }
-}
-
-void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
+ }
+}
+
+void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
Formatter format(printer, vars_);
format(
"void $classname$::CallMethod(const ::$proto_ns$::MethodDescriptor* "
@@ -238,14 +238,14 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
" GOOGLE_DCHECK_EQ(method->service(), $file_level_service_descriptors$[$1$]);\n"
" switch(method->index()) {\n",
index_in_metadata_);
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
Formatter format(printer, vars_);
InitMethodVariables(method, options_, &format);
-
- // Note: down_cast does not work here because it only works on pointers,
- // not references.
+
+ // Note: down_cast does not work here because it only works on pointers,
+ // not references.
format(
" case $1$:\n"
" $name$(controller,\n"
@@ -256,8 +256,8 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
" done);\n"
" break;\n",
i);
- }
-
+ }
+
format(
" default:\n"
" GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n"
@@ -265,33 +265,33 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) {
" }\n"
"}\n"
"\n");
-}
-
-void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
- io::Printer* printer) {
+}
+
+void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
+ io::Printer* printer) {
Formatter format(printer, vars_);
- if (which == REQUEST) {
+ if (which == REQUEST) {
format("const ::$proto_ns$::Message& $classname$::GetRequestPrototype(\n");
- } else {
+ } else {
format("const ::$proto_ns$::Message& $classname$::GetResponsePrototype(\n");
- }
-
+ }
+
format(
" const ::$proto_ns$::MethodDescriptor* method) const {\n"
" GOOGLE_DCHECK_EQ(method->service(), descriptor());\n"
" switch(method->index()) {\n");
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- const Descriptor* type =
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ const Descriptor* type =
(which == REQUEST) ? method->input_type() : method->output_type();
-
+
format(
" case $1$:\n"
" return $2$::default_instance();\n",
i, QualifiedClassName(type, options_));
- }
-
+ }
+
format(
" default:\n"
" GOOGLE_LOG(FATAL) << \"Bad method index; this should never happen.\";\n"
@@ -301,11 +301,11 @@ void ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
"}\n"
"\n",
which == REQUEST ? "input" : "output");
-}
-
-void ServiceGenerator::GenerateStubMethods(io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+}
+
+void ServiceGenerator::GenerateStubMethods(io::Printer* printer) {
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
Formatter format(printer, vars_);
InitMethodVariables(method, options_, &format);
format(
@@ -318,10 +318,10 @@ void ServiceGenerator::GenerateStubMethods(io::Printer* printer) {
" controller, request, response, done);\n"
"}\n",
i);
- }
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ }
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
index f510716fedc..4861c27fab7 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h
@@ -1,122 +1,122 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
-
-#include <map>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_options.h>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class ServiceGenerator {
- public:
- // See generator.cc for the meaning of dllexport_decl.
- explicit ServiceGenerator(const ServiceDescriptor* descriptor,
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class ServiceGenerator {
+ public:
+ // See generator.cc for the meaning of dllexport_decl.
+ explicit ServiceGenerator(const ServiceDescriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& vars,
- const Options& options);
- ~ServiceGenerator();
-
- // Header stuff.
-
- // Generate the class definitions for the service's interface and the
- // stub implementation.
- void GenerateDeclarations(io::Printer* printer);
-
- // Source file stuff.
-
+ const Options& options);
+ ~ServiceGenerator();
+
+ // Header stuff.
+
+ // Generate the class definitions for the service's interface and the
+ // stub implementation.
+ void GenerateDeclarations(io::Printer* printer);
+
+ // Source file stuff.
+
// Generate implementations of everything declared by
// GenerateDeclarations().
- void GenerateImplementation(io::Printer* printer);
-
- private:
- enum RequestOrResponse { REQUEST, RESPONSE };
- enum VirtualOrNon { VIRTUAL, NON_VIRTUAL };
-
- // Header stuff.
-
- // Generate the service abstract interface.
- void GenerateInterface(io::Printer* printer);
-
- // Generate the stub class definition.
- void GenerateStubDefinition(io::Printer* printer);
-
- // Prints signatures for all methods in the
- void GenerateMethodSignatures(VirtualOrNon virtual_or_non,
- io::Printer* printer);
-
- // Source file stuff.
-
- // Generate the default implementations of the service methods, which
- // produce a "not implemented" error.
- void GenerateNotImplementedMethods(io::Printer* printer);
-
- // Generate the CallMethod() method of the service.
- void GenerateCallMethod(io::Printer* printer);
-
- // Generate the Get{Request,Response}Prototype() methods.
- void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);
-
- // Generate the stub's implementations of the service methods.
- void GenerateStubMethods(io::Printer* printer);
-
- const ServiceDescriptor* descriptor_;
+ void GenerateImplementation(io::Printer* printer);
+
+ private:
+ enum RequestOrResponse { REQUEST, RESPONSE };
+ enum VirtualOrNon { VIRTUAL, NON_VIRTUAL };
+
+ // Header stuff.
+
+ // Generate the service abstract interface.
+ void GenerateInterface(io::Printer* printer);
+
+ // Generate the stub class definition.
+ void GenerateStubDefinition(io::Printer* printer);
+
+ // Prints signatures for all methods in the
+ void GenerateMethodSignatures(VirtualOrNon virtual_or_non,
+ io::Printer* printer);
+
+ // Source file stuff.
+
+ // Generate the default implementations of the service methods, which
+ // produce a "not implemented" error.
+ void GenerateNotImplementedMethods(io::Printer* printer);
+
+ // Generate the CallMethod() method of the service.
+ void GenerateCallMethod(io::Printer* printer);
+
+ // Generate the Get{Request,Response}Prototype() methods.
+ void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);
+
+ // Generate the stub's implementations of the service methods.
+ void GenerateStubMethods(io::Printer* printer);
+
+ const ServiceDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> vars_;
const Options& options_;
-
+
int index_in_metadata_;
friend class FileGenerator;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index 12faeaf7a0d..759d0d5d14f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -1,57 +1,57 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/cpp/cpp_string_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-namespace {
-
-void SetStringVariables(const FieldDescriptor* descriptor,
+
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+namespace {
+
+void SetStringVariables(const FieldDescriptor* descriptor,
std::map<TProtoStringType, TProtoStringType>* variables,
- const Options& options) {
- SetCommonFieldVariables(descriptor, variables, options);
+ const Options& options) {
+ SetCommonFieldVariables(descriptor, variables, options);
(*variables)["default"] = DefaultValue(options, descriptor);
- (*variables)["default_length"] =
+ (*variables)["default_length"] =
StrCat(descriptor->default_value_string().length());
TProtoStringType default_variable_string = MakeDefaultName(descriptor);
(*variables)["default_variable_name"] = default_variable_string;
@@ -63,7 +63,7 @@ void SetStringVariables(const FieldDescriptor* descriptor,
}
(*variables)["default_string"] =
- descriptor->default_value_string().empty()
+ descriptor->default_value_string().empty()
? "::" + (*variables)["proto_ns"] +
"::internal::GetEmptyStringAlreadyInited()"
: (*variables)["lazy_variable"] + ".get()";
@@ -80,81 +80,81 @@ void SetStringVariables(const FieldDescriptor* descriptor,
(*variables)[descriptor->default_value_string().empty()
? "default_value_tag"
: "lazy_variable"];
- (*variables)["pointer_type"] =
- descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
+ (*variables)["pointer_type"] =
+ descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
(*variables)["setter"] =
descriptor->type() == FieldDescriptor::TYPE_BYTES ? "SetBytes" : "Set";
(*variables)["null_check"] = (*variables)["DCHK"] + "(value != nullptr);\n";
- // NOTE: Escaped here to unblock proto1->proto2 migration.
- // TODO(liujisi): Extend this to apply for other conflicting methods.
- (*variables)["release_name"] =
+ // NOTE: Escaped here to unblock proto1->proto2 migration.
+ // TODO(liujisi): Extend this to apply for other conflicting methods.
+ (*variables)["release_name"] =
SafeFunctionName(descriptor->containing_type(), descriptor, "release_");
- (*variables)["full_name"] = descriptor->full_name();
-
+ (*variables)["full_name"] = descriptor->full_name();
+
if (options.opensource_runtime) {
(*variables)["string_piece"] = "TProtoStringType";
} else {
(*variables)["string_piece"] = "::StringPiece";
}
-}
-
-} // namespace
-
-// ===================================================================
-
-StringFieldGenerator::StringFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options)
+}
+
+} // namespace
+
+// ===================================================================
+
+StringFieldGenerator::StringFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options)
: FieldGenerator(descriptor, options) {
- SetStringVariables(descriptor, &variables_, options);
-}
-
-StringFieldGenerator::~StringFieldGenerator() {}
-
+ SetStringVariables(descriptor, &variables_, options);
+}
+
+StringFieldGenerator::~StringFieldGenerator() {}
+
void StringFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
format("::$proto_ns$::internal::ArenaStringPtr $name$_;\n");
-}
-
+}
+
void StringFieldGenerator::GenerateStaticMembers(io::Printer* printer) const {
Formatter format(printer, variables_);
- if (!descriptor_->default_value_string().empty()) {
+ if (!descriptor_->default_value_string().empty()) {
format(
"static const ::$proto_ns$::internal::LazyString"
" $default_variable_name$;\n");
- }
-}
-
+ }
+}
+
void StringFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
- // If we're using StringFieldGenerator for a field with a ctype, it's
- // because that ctype isn't actually implemented. In particular, this is
- // true of ctype=CORD and ctype=STRING_PIECE in the open source release.
- // We aren't releasing Cord because it has too many Google-specific
- // dependencies and we aren't releasing StringPiece because it's hardly
- // useful outside of Google and because it would get confusing to have
- // multiple instances of the StringPiece class in different libraries (PCRE
- // already includes it for their C++ bindings, which came from Google).
- //
- // In any case, we make all the accessors private while still actually
- // using a string to represent the field internally. This way, we can
- // guarantee that if we do ever implement the ctype, it won't break any
- // existing users who might be -- for whatever reason -- already using .proto
- // files that applied the ctype. The field can still be accessed via the
- // reflection interface since the reflection interface is independent of
- // the string's underlying representation.
-
+ // If we're using StringFieldGenerator for a field with a ctype, it's
+ // because that ctype isn't actually implemented. In particular, this is
+ // true of ctype=CORD and ctype=STRING_PIECE in the open source release.
+ // We aren't releasing Cord because it has too many Google-specific
+ // dependencies and we aren't releasing StringPiece because it's hardly
+ // useful outside of Google and because it would get confusing to have
+ // multiple instances of the StringPiece class in different libraries (PCRE
+ // already includes it for their C++ bindings, which came from Google).
+ //
+ // In any case, we make all the accessors private while still actually
+ // using a string to represent the field internally. This way, we can
+ // guarantee that if we do ever implement the ctype, it won't break any
+ // existing users who might be -- for whatever reason -- already using .proto
+ // files that applied the ctype. The field can still be accessed via the
+ // reflection interface since the reflection interface is independent of
+ // the string's underlying representation.
+
bool unknown_ctype = descriptor_->options().ctype() !=
EffectiveStringCType(descriptor_, options_);
-
- if (unknown_ctype) {
+
+ if (unknown_ctype) {
format.Outdent();
format(
" private:\n"
" // Hidden due to unknown ctype option.\n");
format.Indent();
- }
-
+ }
+
format(
"$deprecated_attr$const TProtoStringType& ${1$$name$$}$() const;\n"
"template <typename ArgT0 = const TProtoStringType&, typename... ArgT>\n"
@@ -174,14 +174,14 @@ void StringFieldGenerator::GenerateAccessorDeclarations(
"_internal_set_$name$(const TProtoStringType& value);\n"
"TProtoStringType* _internal_mutable_$name$();\n"
"public:\n");
-
- if (unknown_ctype) {
+
+ if (unknown_ctype) {
format.Outdent();
format(" public:\n");
format.Indent();
- }
-}
-
+ }
+}
+
void StringFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -238,10 +238,10 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
" $clear_hasbit$\n"
" return $name$_.ReleaseNonDefault($init_value$, "
"GetArenaForAllocation());\n");
- } else {
+ } else {
format(
" return $name$_.Release($init_value$, GetArenaForAllocation());\n");
- }
+ }
format(
"}\n"
@@ -256,29 +256,29 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
-}
-
+}
+
void StringFieldGenerator::GenerateNonInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (!descriptor_->default_value_string().empty()) {
+ if (!descriptor_->default_value_string().empty()) {
format(
"const ::$proto_ns$::internal::LazyString "
"$classname$::$default_variable_name$"
"{{{$default$, $default_length$}}, {nullptr}};\n");
- }
-}
-
+ }
+}
+
void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
if (descriptor_->default_value_string().empty()) {
format("$name$_.ClearToEmpty();\n");
- } else {
+ } else {
format(
"$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n");
- }
-}
-
+ }
+}
+
void StringFieldGenerator::GenerateMessageClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -310,8 +310,8 @@ void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
// TODO(gpike): improve this
format("_internal_set_$name$(from._internal_$name$());\n");
-}
-
+}
+
void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
@@ -320,13 +320,13 @@ void StringFieldGenerator::GenerateSwappingCode(io::Printer* printer) const {
" &$name$_, GetArenaForAllocation(),\n"
" &other->$name$_, other->GetArenaForAllocation()\n"
");\n");
-}
-
+}
+
void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.UnsafeSetDefault($init_value$);\n");
-}
-
+}
+
void StringFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -352,31 +352,31 @@ void StringFieldGenerator::GenerateCopyConstructorCode(
void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.DestroyNoArena($init_value$);\n");
-}
-
+}
+
void StringFieldGenerator::GenerateSerializeWithCachedSizesToArray(
io::Printer* printer) const {
Formatter format(printer, variables_);
- if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
- GenerateUtf8CheckCodeForString(
+ if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
+ GenerateUtf8CheckCodeForString(
descriptor_, options_, false,
"this->_internal_$name$().data(), "
"static_cast<int>(this->_internal_$name$().length()),\n",
format);
- }
+ }
format(
"target = stream->Write$declared_type$MaybeAliased(\n"
" $number$, this->_internal_$name$(), target);\n");
-}
-
+}
+
void StringFieldGenerator::GenerateByteSize(io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"total_size += $tag_size$ +\n"
" ::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" this->_internal_$name$());\n");
-}
-
+}
+
void StringFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -384,22 +384,22 @@ void StringFieldGenerator::GenerateConstinitInitializer(
format("$name$_(&::$proto_ns$::internal::fixed_address_empty_string)");
} else {
format("$name$_(nullptr)");
- }
-}
-
-// ===================================================================
-
+ }
+}
+
+// ===================================================================
+
StringOneofFieldGenerator::StringOneofFieldGenerator(
const FieldDescriptor* descriptor, const Options& options)
: StringFieldGenerator(descriptor, options) {
- SetCommonOneofFieldVariables(descriptor, &variables_);
+ SetCommonOneofFieldVariables(descriptor, &variables_);
variables_["field_name"] = UnderscoresToCamelCase(descriptor->name(), true);
variables_["oneof_index"] =
StrCat(descriptor->containing_oneof()->index());
-}
-
-StringOneofFieldGenerator::~StringOneofFieldGenerator() {}
-
+}
+
+StringOneofFieldGenerator::~StringOneofFieldGenerator() {}
+
void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -479,16 +479,16 @@ void StringOneofFieldGenerator::GenerateInlineAccessorDefinitions(
"$annotate_set$"
" // @@protoc_insertion_point(field_set_allocated:$full_name$)\n"
"}\n");
-}
-
+}
+
void StringOneofFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format(
"$field_member$.Destroy($default_value_tag$, "
"GetArenaForAllocation());\n");
-}
-
+}
+
void StringOneofFieldGenerator::GenerateMessageClearingCode(
io::Printer* printer) const {
return GenerateClearingCode(printer);
@@ -496,45 +496,45 @@ void StringOneofFieldGenerator::GenerateMessageClearingCode(
void StringOneofFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
- // Don't print any swapping code. Swapping the union will swap this field.
-}
-
+ // Don't print any swapping code. Swapping the union will swap this field.
+}
+
void StringOneofFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
// Nothing required here.
-}
-
-// ===================================================================
-
-RepeatedStringFieldGenerator::RepeatedStringFieldGenerator(
- const FieldDescriptor* descriptor, const Options& options)
+}
+
+// ===================================================================
+
+RepeatedStringFieldGenerator::RepeatedStringFieldGenerator(
+ const FieldDescriptor* descriptor, const Options& options)
: FieldGenerator(descriptor, options) {
- SetStringVariables(descriptor, &variables_, options);
-}
-
-RepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {}
-
+ SetStringVariables(descriptor, &variables_, options);
+}
+
+RepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {}
+
void RepeatedStringFieldGenerator::GeneratePrivateMembers(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("::$proto_ns$::RepeatedPtrField<TProtoStringType> $name$_;\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateAccessorDeclarations(
io::Printer* printer) const {
Formatter format(printer, variables_);
- // See comment above about unknown ctypes.
+ // See comment above about unknown ctypes.
bool unknown_ctype = descriptor_->options().ctype() !=
EffectiveStringCType(descriptor_, options_);
-
- if (unknown_ctype) {
+
+ if (unknown_ctype) {
format.Outdent();
format(
" private:\n"
" // Hidden due to unknown ctype option.\n");
format.Indent();
- }
-
+ }
+
format(
"$deprecated_attr$const TProtoStringType& ${1$$name$$}$(int index) const;\n"
"$deprecated_attr$TProtoStringType* ${1$mutable_$name$$}$(int index);\n"
@@ -579,14 +579,14 @@ void RepeatedStringFieldGenerator::GenerateAccessorDeclarations(
"TProtoStringType* _internal_add_$name$();\n"
"public:\n",
descriptor_);
-
- if (unknown_ctype) {
+
+ if (unknown_ctype) {
format.Outdent();
format(" public:\n");
format.Indent();
- }
-}
-
+ }
+}
+
void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -704,31 +704,31 @@ void RepeatedStringFieldGenerator::GenerateInlineAccessorDefinitions(
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
" return &$name$_;\n"
"}\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateClearingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.Clear();\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.MergeFrom(from.$name$_);\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateSwappingCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_.InternalSwap(&other->$name$_);\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateConstructorCode(
io::Printer* printer) const {
- // Not needed for repeated fields.
-}
-
+ // Not needed for repeated fields.
+}
+
void RepeatedStringFieldGenerator::GenerateCopyConstructorCode(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -743,17 +743,17 @@ void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray(
" const auto& s = this->_internal_$name$(i);\n");
// format("for (const TProtoStringType& s : this->$name$()) {\n");
format.Indent();
- if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
+ if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(descriptor_, options_, false,
"s.data(), static_cast<int>(s.length()),\n",
format);
- }
+ }
format.Outdent();
format(
" target = stream->Write$declared_type$($number$, s, target);\n"
"}\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateByteSize(
io::Printer* printer) const {
Formatter format(printer, variables_);
@@ -765,15 +765,15 @@ void RepeatedStringFieldGenerator::GenerateByteSize(
"::$proto_ns$::internal::WireFormatLite::$declared_type$Size(\n"
" $name$_.Get(i));\n"
"}\n");
-}
-
+}
+
void RepeatedStringFieldGenerator::GenerateConstinitInitializer(
io::Printer* printer) const {
Formatter format(printer, variables_);
format("$name$_()");
-}
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
index 213f13465d4..5d0a18da728 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h
@@ -1,122 +1,122 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 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.
-
-// Author: [email protected] (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
-
-#include <map>
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 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.
+
+// Author: [email protected] (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace cpp {
-
-class StringFieldGenerator : public FieldGenerator {
- public:
- StringFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~StringFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateStaticMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace cpp {
+
+class StringFieldGenerator : public FieldGenerator {
+ public:
+ StringFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~StringFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateStaticMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
void GenerateMessageClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const;
- void GenerateDestructorCode(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateDestructorCode(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
-};
-
-class StringOneofFieldGenerator : public StringFieldGenerator {
- public:
- StringOneofFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~StringOneofFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);
+};
+
+class StringOneofFieldGenerator : public StringFieldGenerator {
+ public:
+ StringOneofFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~StringOneofFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
// StringFieldGenerator, from which we inherit, overrides this so we need to
// override it as well.
void GenerateMessageClearingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOneofFieldGenerator);
-};
-
-class RepeatedStringFieldGenerator : public FieldGenerator {
- public:
- RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,
- const Options& options);
- ~RepeatedStringFieldGenerator();
-
- // implements FieldGenerator ---------------------------------------
- void GeneratePrivateMembers(io::Printer* printer) const;
- void GenerateAccessorDeclarations(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOneofFieldGenerator);
+};
+
+class RepeatedStringFieldGenerator : public FieldGenerator {
+ public:
+ RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,
+ const Options& options);
+ ~RepeatedStringFieldGenerator();
+
+ // implements FieldGenerator ---------------------------------------
+ void GeneratePrivateMembers(io::Printer* printer) const;
+ void GenerateAccessorDeclarations(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer) const;
- void GenerateClearingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateClearingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateSwappingCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const;
void GenerateCopyConstructorCode(io::Printer* printer) const;
- void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
- void GenerateByteSize(io::Printer* printer) const;
+ void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;
+ void GenerateByteSize(io::Printer* printer) const;
void GenerateConstinitInitializer(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);
-};
-
-} // namespace cpp
-} // namespace compiler
-} // namespace protobuf
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);
+};
+
+} // namespace cpp
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__