aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src
diff options
context:
space:
mode:
authorRuslan Kovalev <ruslan.a.kovalev@gmail.com>2022-02-10 16:46:45 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:45 +0300
commit9123176b341b6f2658cff5132482b8237c1416c8 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /contrib/libs/protoc/src
parent59e19371de37995fcb36beb16cd6ec030af960bc (diff)
downloadydb-9123176b341b6f2658cff5132482b8237c1416c8.tar.gz
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/protoc/src')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc142
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h266
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc2734
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h600
-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
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/importer.cc766
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/importer.h532
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc352
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h182
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc386
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h126
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc420
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h162
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc732
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h196
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc456
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h182
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc256
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h158
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc270
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h182
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc200
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h140
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc412
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h278
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc912
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h174
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc348
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h128
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc148
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h174
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc1052
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h612
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc820
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h112
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc930
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h108
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc1538
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h238
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc664
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h146
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc178
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h138
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc1080
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h242
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc640
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h196
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc630
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h148
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc380
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h192
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h162
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h138
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc800
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h196
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc554
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h186
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc556
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h246
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc280
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h140
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc832
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h230
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc498
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h176
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/main.cc94
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.cc3640
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/parser.h1036
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc270
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.h164
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc604
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h668
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto300
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc1984
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h274
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc824
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h194
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc182
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h110
105 files changed, 22955 insertions, 22955 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
index 944522904c..9ad4d14ef1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc
@@ -1,50 +1,50 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/code_generator.h>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-
-CodeGenerator::~CodeGenerator() {}
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+CodeGenerator::~CodeGenerator() {}
bool CodeGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files,
const TProtoStringType& parameter,
@@ -72,30 +72,30 @@ bool CodeGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files,
return succeeded;
}
-GeneratorContext::~GeneratorContext() {}
-
+GeneratorContext::~GeneratorContext() {}
+
io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend(
const TProtoStringType& filename) {
- return NULL;
-}
-
-io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
+ return NULL;
+}
+
+io::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(
const TProtoStringType& filename, const TProtoStringType& insertion_point) {
- GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
- return NULL; // make compiler happy
-}
-
+ GOOGLE_LOG(FATAL) << "This GeneratorContext does not support insertion.";
+ return NULL; // make compiler happy
+}
+
io::ZeroCopyOutputStream* GeneratorContext::OpenForInsertWithGeneratedCodeInfo(
const TProtoStringType& filename, const TProtoStringType& insertion_point,
const google::protobuf::GeneratedCodeInfo& /*info*/) {
return OpenForInsert(filename, insertion_point);
}
-void GeneratorContext::ListParsedFiles(
+void GeneratorContext::ListParsedFiles(
std::vector<const FileDescriptor*>* output) {
- GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
-}
-
+ GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles";
+}
+
void GeneratorContext::GetCompilerVersion(Version* version) const {
version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000);
version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000);
@@ -103,26 +103,26 @@ void GeneratorContext::GetCompilerVersion(Version* version) const {
version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX);
}
-// Parses a set of comma-delimited name/value pairs.
+// Parses a set of comma-delimited name/value pairs.
void ParseGeneratorParameter(
const TProtoStringType& text,
std::vector<std::pair<TProtoStringType, TProtoStringType> >* output) {
std::vector<TProtoStringType> parts = Split(text, ",", true);
-
- for (int i = 0; i < parts.size(); i++) {
+
+ for (int i = 0; i < parts.size(); i++) {
TProtoStringType::size_type equals_pos = parts[i].find_first_of('=');
std::pair<TProtoStringType, TProtoStringType> value;
if (equals_pos == TProtoStringType::npos) {
- value.first = parts[i];
- value.second = "";
- } else {
- value.first = parts[i].substr(0, equals_pos);
- value.second = parts[i].substr(equals_pos + 1);
- }
- output->push_back(value);
- }
-}
-
+ value.first = parts[i];
+ value.second = "";
+ } else {
+ value.first = parts[i].substr(0, equals_pos);
+ value.second = parts[i].substr(equals_pos + 1);
+ }
+ output->push_back(value);
+ }
+}
+
// Strips ".proto" or ".protodevel" from the end of a filename.
TProtoStringType StripProto(const TProtoStringType& filename) {
if (HasSuffixString(filename, ".protodevel")) {
@@ -132,6 +132,6 @@ TProtoStringType StripProto(const TProtoStringType& filename) {
}
}
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
index 764cf7846e..03f93c49f9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h
@@ -1,108 +1,108 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Defines the abstract interface implemented by each of the language-specific
-// code generators.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_CODE_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Defines the abstract interface implemented by each of the language-specific
+// code generators.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
+
#include <string>
#include <utility>
-#include <vector>
+#include <vector>
#include <google/protobuf/stubs/common.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-
+namespace google {
+namespace protobuf {
+
namespace io {
class ZeroCopyOutputStream;
}
-class FileDescriptor;
+class FileDescriptor;
class GeneratedCodeInfo;
-
-namespace compiler {
+
+namespace compiler {
class AccessInfoMap;
class Version;
-
-// Defined in this file.
-class CodeGenerator;
-class GeneratorContext;
-
-// The abstract interface to a class which generates code implementing a
-// particular proto file in a particular language. A number of these may
-// be registered with CommandLineInterface to support various languages.
+
+// Defined in this file.
+class CodeGenerator;
+class GeneratorContext;
+
+// The abstract interface to a class which generates code implementing a
+// particular proto file in a particular language. A number of these may
+// be registered with CommandLineInterface to support various languages.
class PROTOC_EXPORT CodeGenerator {
- public:
- inline CodeGenerator() {}
- virtual ~CodeGenerator();
-
- // Generates code for the given proto file, generating one or more files in
- // the given output directory.
- //
+ public:
+ inline CodeGenerator() {}
+ virtual ~CodeGenerator();
+
+ // Generates code for the given proto file, generating one or more files in
+ // the given output directory.
+ //
// A parameter to be passed to the generator can be specified on the command
// line. This is intended to be used to pass generator specific parameters.
// It is empty if no parameter was given. ParseGeneratorParameter (below),
// can be used to accept multiple parameters within the single parameter
// command line flag.
- //
- // Returns true if successful. Otherwise, sets *error to a description of
- // the problem (e.g. "invalid parameter") and returns false.
- virtual bool Generate(const FileDescriptor* file,
+ //
+ // Returns true if successful. Otherwise, sets *error to a description of
+ // the problem (e.g. "invalid parameter") and returns false.
+ virtual bool Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
- GeneratorContext* generator_context,
+ GeneratorContext* generator_context,
TProtoStringType* error) const = 0;
-
+
// Generates code for all given proto files.
- //
+ //
// WARNING: The canonical code generator design produces one or two output
// files per input .proto file, and we do not wish to encourage alternate
// designs.
- //
- // A parameter is given as passed on the command line, as in |Generate()|
- // above.
- //
- // Returns true if successful. Otherwise, sets *error to a description of
- // the problem (e.g. "invalid parameter") and returns false.
+ //
+ // A parameter is given as passed on the command line, as in |Generate()|
+ // above.
+ //
+ // Returns true if successful. Otherwise, sets *error to a description of
+ // the problem (e.g. "invalid parameter") and returns false.
virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files,
const TProtoStringType& parameter,
GeneratorContext* generator_context,
TProtoStringType* error) const;
-
+
// Sync with plugin.proto.
enum Feature {
FEATURE_PROTO3_OPTIONAL = 1,
@@ -118,45 +118,45 @@ class PROTOC_EXPORT CodeGenerator {
// version of the library. When protobufs does a api breaking change, the
// method can be removed.
virtual bool HasGenerateAll() const { return true; }
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator);
-};
-
-// CodeGenerators generate one or more files in a given directory. This
-// abstract interface represents the directory to which the CodeGenerator is
-// to write and other information about the context in which the Generator
-// runs.
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator);
+};
+
+// CodeGenerators generate one or more files in a given directory. This
+// abstract interface represents the directory to which the CodeGenerator is
+// to write and other information about the context in which the Generator
+// runs.
class PROTOC_EXPORT GeneratorContext {
- public:
+ public:
inline GeneratorContext() {
}
- virtual ~GeneratorContext();
-
- // Opens the given file, truncating it if it exists, and returns a
- // ZeroCopyOutputStream that writes to the file. The caller takes ownership
- // of the returned object. This method never fails (a dummy stream will be
- // returned instead).
- //
- // The filename given should be relative to the root of the source tree.
- // E.g. the C++ generator, when generating code for "foo/bar.proto", will
- // generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that
- // "foo/" is included in these filenames. The filename is not allowed to
- // contain "." or ".." components.
+ virtual ~GeneratorContext();
+
+ // Opens the given file, truncating it if it exists, and returns a
+ // ZeroCopyOutputStream that writes to the file. The caller takes ownership
+ // of the returned object. This method never fails (a dummy stream will be
+ // returned instead).
+ //
+ // The filename given should be relative to the root of the source tree.
+ // E.g. the C++ generator, when generating code for "foo/bar.proto", will
+ // generate the files "foo/bar.pb.h" and "foo/bar.pb.cc"; note that
+ // "foo/" is included in these filenames. The filename is not allowed to
+ // contain "." or ".." components.
virtual io::ZeroCopyOutputStream* Open(const TProtoStringType& filename) = 0;
-
- // Similar to Open() but the output will be appended to the file if exists
+
+ // Similar to Open() but the output will be appended to the file if exists
virtual io::ZeroCopyOutputStream* OpenForAppend(const TProtoStringType& filename);
-
- // Creates a ZeroCopyOutputStream which will insert code into the given file
- // at the given insertion point. See plugin.proto (plugin.pb.h) for more
- // information on insertion points. The default implementation
- // assert-fails -- it exists only for backwards-compatibility.
- //
- // WARNING: This feature is currently EXPERIMENTAL and is subject to change.
- virtual io::ZeroCopyOutputStream* OpenForInsert(
+
+ // Creates a ZeroCopyOutputStream which will insert code into the given file
+ // at the given insertion point. See plugin.proto (plugin.pb.h) for more
+ // information on insertion points. The default implementation
+ // assert-fails -- it exists only for backwards-compatibility.
+ //
+ // WARNING: This feature is currently EXPERIMENTAL and is subject to change.
+ virtual io::ZeroCopyOutputStream* OpenForInsert(
const TProtoStringType& filename, const TProtoStringType& insertion_point);
-
+
// Similar to OpenForInsert, but if `info` is non-empty, will open (or create)
// filename.pb.meta and insert info at the appropriate place with the
// necessary shifts. The default implementation ignores `info`.
@@ -166,40 +166,40 @@ class PROTOC_EXPORT GeneratorContext {
const TProtoStringType& filename, const TProtoStringType& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
- // Returns a vector of FileDescriptors for all the files being compiled
- // in this run. Useful for languages, such as Go, that treat files
- // differently when compiled as a set rather than individually.
+ // Returns a vector of FileDescriptors for all the files being compiled
+ // in this run. Useful for languages, such as Go, that treat files
+ // differently when compiled as a set rather than individually.
virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output);
-
+
// Retrieves the version number of the protocol compiler associated with
// this GeneratorContext.
virtual void GetCompilerVersion(Version* version) const;
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);
-};
-
-// The type GeneratorContext was once called OutputDirectory. This typedef
-// provides backward compatibility.
-typedef GeneratorContext OutputDirectory;
-
-// Several code generators treat the parameter argument as holding a
-// list of options separated by commas. This helper function parses
-// a set of comma-delimited name/value pairs: e.g.,
-// "foo=bar,baz,qux=corge"
-// parses to the pairs:
-// ("foo", "bar"), ("baz", ""), ("qux", "corge")
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);
+};
+
+// The type GeneratorContext was once called OutputDirectory. This typedef
+// provides backward compatibility.
+typedef GeneratorContext OutputDirectory;
+
+// Several code generators treat the parameter argument as holding a
+// list of options separated by commas. This helper function parses
+// a set of comma-delimited name/value pairs: e.g.,
+// "foo=bar,baz,qux=corge"
+// parses to the pairs:
+// ("foo", "bar"), ("baz", ""), ("qux", "corge")
PROTOC_EXPORT void ParseGeneratorParameter(
const TProtoStringType&, std::vector<std::pair<TProtoStringType, TProtoStringType> >*);
-
+
// Strips ".proto" or ".protodevel" from the end of a filename.
PROTOC_EXPORT TProtoStringType StripProto(const TProtoStringType& filename);
-} // namespace compiler
-} // namespace protobuf
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
index c7bc316c49..7663ea0085 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc
@@ -1,45 +1,45 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/command_line_interface.h>
#include <cstdint>
#include <google/protobuf/stubs/platform_macros.h>
-
-#include <stdio.h>
-#include <sys/types.h>
+
+#include <stdio.h>
+#include <sys/types.h>
#ifdef major
#undef major
#endif
@@ -47,25 +47,25 @@
#undef minor
#endif
#include <fcntl.h>
-#include <sys/stat.h>
+#include <sys/stat.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <ctype.h>
-#include <errno.h>
-#include <fstream>
-#include <iostream>
-
+#include <errno.h>
+#include <fstream>
+#include <iostream>
+
#include <limits.h> //For PATH_MAX
-
-#include <memory>
-
+
+#include <memory>
+
#if defined(__APPLE__)
-#include <mach-o/dyld.h>
+#include <mach-o/dyld.h>
#elif defined(__FreeBSD__)
#include <sys/sysctl.h>
-#endif
-
+#endif
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/stringprintf.h>
@@ -85,23 +85,23 @@
#include <google/protobuf/io/io_win32.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-namespace compiler {
-
-#ifndef O_BINARY
-#ifdef _O_BINARY
-#define O_BINARY _O_BINARY
-#else
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+#ifndef O_BINARY
+#ifdef _O_BINARY
+#define O_BINARY _O_BINARY
+#else
#define O_BINARY 0 // If this isn't defined, the platform doesn't need it.
-#endif
-#endif
-
-namespace {
+#endif
+#endif
+
+namespace {
#if defined(_WIN32)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
@@ -111,101 +111,101 @@ using google::protobuf::io::win32::mkdir;
using google::protobuf::io::win32::open;
using google::protobuf::io::win32::setmode;
using google::protobuf::io::win32::write;
-#endif
-
+#endif
+
static const char* kDefaultDirectDependenciesViolationMsg =
"File is imported but not declared in --direct_dependencies: %s";
-// Returns true if the text looks like a Windows-style absolute path, starting
-// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
-// copy in importer.cc?
+// Returns true if the text looks like a Windows-style absolute path, starting
+// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
+// copy in importer.cc?
static bool IsWindowsAbsolutePath(const TProtoStringType& text) {
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
return text.size() >= 3 && text[1] == ':' && isalpha(text[0]) &&
(text[2] == '/' || text[2] == '\\') && text.find_last_of(':') == 1;
-#else
- return false;
-#endif
-}
-
-void SetFdToTextMode(int fd) {
-#ifdef _WIN32
+#else
+ return false;
+#endif
+}
+
+void SetFdToTextMode(int fd) {
+#ifdef _WIN32
if (setmode(fd, _O_TEXT) == -1) {
- // This should never happen, I think.
+ // This should never happen, I think.
GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno);
- }
-#endif
- // (Text and binary are the same on non-Windows platforms.)
-}
-
-void SetFdToBinaryMode(int fd) {
-#ifdef _WIN32
+ }
+#endif
+ // (Text and binary are the same on non-Windows platforms.)
+}
+
+void SetFdToBinaryMode(int fd) {
+#ifdef _WIN32
if (setmode(fd, _O_BINARY) == -1) {
- // This should never happen, I think.
+ // This should never happen, I think.
GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno);
- }
-#endif
- // (Text and binary are the same on non-Windows platforms.)
-}
-
+ }
+#endif
+ // (Text and binary are the same on non-Windows platforms.)
+}
+
void AddTrailingSlash(TProtoStringType* path) {
- if (!path->empty() && path->at(path->size() - 1) != '/') {
- path->push_back('/');
- }
-}
-
+ if (!path->empty() && path->at(path->size() - 1) != '/') {
+ path->push_back('/');
+ }
+}
+
bool VerifyDirectoryExists(const TProtoStringType& path) {
- if (path.empty()) return true;
-
- if (access(path.c_str(), F_OK) == -1) {
- std::cerr << path << ": " << strerror(errno) << std::endl;
- return false;
- } else {
- return true;
- }
-}
-
-// Try to create the parent directory of the given file, creating the parent's
-// parent if necessary, and so on. The full file name is actually
-// (prefix + filename), but we assume |prefix| already exists and only create
-// directories listed in |filename|.
+ if (path.empty()) return true;
+
+ if (access(path.c_str(), F_OK) == -1) {
+ std::cerr << path << ": " << strerror(errno) << std::endl;
+ return false;
+ } else {
+ return true;
+ }
+}
+
+// Try to create the parent directory of the given file, creating the parent's
+// parent if necessary, and so on. The full file name is actually
+// (prefix + filename), but we assume |prefix| already exists and only create
+// directories listed in |filename|.
bool TryCreateParentDirectory(const TProtoStringType& prefix,
const TProtoStringType& filename) {
- // Recursively create parent directories to the output file.
+ // Recursively create parent directories to the output file.
// On Windows, both '/' and '\' are valid path separators.
std::vector<TProtoStringType> parts =
Split(filename, "/\\", true);
TProtoStringType path_so_far = prefix;
- for (int i = 0; i < parts.size() - 1; i++) {
- path_so_far += parts[i];
- if (mkdir(path_so_far.c_str(), 0777) != 0) {
- if (errno != EEXIST) {
- std::cerr << filename << ": while trying to create directory "
- << path_so_far << ": " << strerror(errno) << std::endl;
- return false;
- }
- }
- path_so_far += '/';
- }
-
- return true;
-}
-
-// Get the absolute path of this protoc binary.
+ for (int i = 0; i < parts.size() - 1; i++) {
+ path_so_far += parts[i];
+ if (mkdir(path_so_far.c_str(), 0777) != 0) {
+ if (errno != EEXIST) {
+ std::cerr << filename << ": while trying to create directory "
+ << path_so_far << ": " << strerror(errno) << std::endl;
+ return false;
+ }
+ }
+ path_so_far += '/';
+ }
+
+ return true;
+}
+
+// Get the absolute path of this protoc binary.
bool GetProtocAbsolutePath(TProtoStringType* path) {
-#ifdef _WIN32
- char buffer[MAX_PATH];
- int len = GetModuleFileNameA(NULL, buffer, MAX_PATH);
+#ifdef _WIN32
+ char buffer[MAX_PATH];
+ int len = GetModuleFileNameA(NULL, buffer, MAX_PATH);
#elif defined(__APPLE__)
- char buffer[PATH_MAX];
- int len = 0;
-
- char dirtybuffer[PATH_MAX];
- uint32_t size = sizeof(dirtybuffer);
- if (_NSGetExecutablePath(dirtybuffer, &size) == 0) {
- realpath(dirtybuffer, buffer);
- len = strlen(buffer);
- }
+ char buffer[PATH_MAX];
+ int len = 0;
+
+ char dirtybuffer[PATH_MAX];
+ uint32_t size = sizeof(dirtybuffer);
+ if (_NSGetExecutablePath(dirtybuffer, &size) == 0) {
+ realpath(dirtybuffer, buffer);
+ len = strlen(buffer);
+ }
#elif defined(__FreeBSD__)
char buffer[PATH_MAX];
size_t len = PATH_MAX;
@@ -213,66 +213,66 @@ bool GetProtocAbsolutePath(TProtoStringType* path) {
if (sysctl(mib, 4, &buffer, &len, NULL, 0) != 0) {
len = 0;
}
-#else
- char buffer[PATH_MAX];
- int len = readlink("/proc/self/exe", buffer, PATH_MAX);
-#endif
- if (len > 0) {
- path->assign(buffer, len);
- return true;
- } else {
- return false;
- }
-}
-
-// Whether a path is where google/protobuf/descriptor.proto and other well-known
-// type protos are installed.
+#else
+ char buffer[PATH_MAX];
+ int len = readlink("/proc/self/exe", buffer, PATH_MAX);
+#endif
+ if (len > 0) {
+ path->assign(buffer, len);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Whether a path is where google/protobuf/descriptor.proto and other well-known
+// type protos are installed.
bool IsInstalledProtoPath(const TProtoStringType& path) {
- // Checking the descriptor.proto file should be good enough.
+ // Checking the descriptor.proto file should be good enough.
TProtoStringType file_path = path + "/google/protobuf/descriptor.proto";
- return access(file_path.c_str(), F_OK) != -1;
-}
-
+ return access(file_path.c_str(), F_OK) != -1;
+}
+
// Add the paths where google/protobuf/descriptor.proto and other well-known
-// type protos are installed.
+// type protos are installed.
void AddDefaultProtoPaths(
std::vector<std::pair<TProtoStringType, TProtoStringType>>* paths) {
- // TODO(xiaofeng): The code currently only checks relative paths of where
- // the protoc binary is installed. We probably should make it handle more
- // cases than that.
+ // TODO(xiaofeng): The code currently only checks relative paths of where
+ // the protoc binary is installed. We probably should make it handle more
+ // cases than that.
TProtoStringType path;
- if (!GetProtocAbsolutePath(&path)) {
- return;
- }
- // Strip the binary name.
- size_t pos = path.find_last_of("/\\");
+ if (!GetProtocAbsolutePath(&path)) {
+ return;
+ }
+ // Strip the binary name.
+ size_t pos = path.find_last_of("/\\");
if (pos == TProtoStringType::npos || pos == 0) {
- return;
- }
- path = path.substr(0, pos);
- // Check the binary's directory.
- if (IsInstalledProtoPath(path)) {
+ return;
+ }
+ path = path.substr(0, pos);
+ // Check the binary's directory.
+ if (IsInstalledProtoPath(path)) {
paths->push_back(std::pair<TProtoStringType, TProtoStringType>("", path));
- return;
- }
- // Check if there is an include subdirectory.
- if (IsInstalledProtoPath(path + "/include")) {
+ return;
+ }
+ // Check if there is an include subdirectory.
+ if (IsInstalledProtoPath(path + "/include")) {
paths->push_back(
std::pair<TProtoStringType, TProtoStringType>("", path + "/include"));
- return;
- }
- // Check if the upper level directory has an "include" subdirectory.
- pos = path.find_last_of("/\\");
+ return;
+ }
+ // Check if the upper level directory has an "include" subdirectory.
+ pos = path.find_last_of("/\\");
if (pos == TProtoStringType::npos || pos == 0) {
- return;
- }
- path = path.substr(0, pos);
- if (IsInstalledProtoPath(path + "/include")) {
+ return;
+ }
+ path = path.substr(0, pos);
+ if (IsInstalledProtoPath(path + "/include")) {
paths->push_back(
std::pair<TProtoStringType, TProtoStringType>("", path + "/include"));
- return;
- }
-}
+ return;
+ }
+}
TProtoStringType PluginName(const TProtoStringType& plugin_prefix,
const TProtoStringType& directive) {
@@ -281,43 +281,43 @@ TProtoStringType PluginName(const TProtoStringType& plugin_prefix,
return plugin_prefix + "gen-" + directive.substr(2, directive.size() - 6);
}
-} // namespace
-
-// A MultiFileErrorCollector that prints errors to stderr.
+} // namespace
+
+// A MultiFileErrorCollector that prints errors to stderr.
class CommandLineInterface::ErrorPrinter
: public MultiFileErrorCollector,
public io::ErrorCollector,
public DescriptorPool::ErrorCollector {
- public:
+ public:
ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL)
: format_(format),
tree_(tree),
found_errors_(false),
found_warnings_(false) {}
- ~ErrorPrinter() {}
-
- // implements MultiFileErrorCollector ------------------------------
+ ~ErrorPrinter() {}
+
+ // implements MultiFileErrorCollector ------------------------------
void AddError(const TProtoStringType& filename, int line, int column,
const TProtoStringType& message) {
found_errors_ = true;
- AddErrorOrWarning(filename, line, column, message, "error", std::cerr);
- }
-
+ AddErrorOrWarning(filename, line, column, message, "error", std::cerr);
+ }
+
void AddWarning(const TProtoStringType& filename, int line, int column,
const TProtoStringType& message) {
found_warnings_ = true;
- AddErrorOrWarning(filename, line, column, message, "warning", std::clog);
- }
-
- // implements io::ErrorCollector -----------------------------------
+ AddErrorOrWarning(filename, line, column, message, "warning", std::clog);
+ }
+
+ // implements io::ErrorCollector -----------------------------------
void AddError(int line, int column, const TProtoStringType& message) {
- AddError("input", line, column, message);
- }
-
+ AddError("input", line, column, message);
+ }
+
void AddWarning(int line, int column, const TProtoStringType& message) {
- AddErrorOrWarning("input", line, column, message, "warning", std::clog);
- }
-
+ AddErrorOrWarning("input", line, column, message, "warning", std::clog);
+ }
+
// implements DescriptorPool::ErrorCollector-------------------------
void AddError(const TProtoStringType& filename, const TProtoStringType& element_name,
const Message* descriptor, ErrorLocation location,
@@ -335,71 +335,71 @@ class CommandLineInterface::ErrorPrinter
bool FoundWarnings() const { return found_warnings_; }
- private:
+ private:
void AddErrorOrWarning(const TProtoStringType& filename, int line, int column,
const TProtoStringType& message, const TProtoStringType& type,
std::ostream& out) {
- // Print full path when running under MSVS
+ // Print full path when running under MSVS
TProtoStringType dfile;
if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && tree_ != NULL &&
- tree_->VirtualFileToDiskFile(filename, &dfile)) {
- out << dfile;
- } else {
- out << filename;
- }
-
- // Users typically expect 1-based line/column numbers, so we add 1
- // to each here.
- if (line != -1) {
- // Allow for both GCC- and Visual-Studio-compatible output.
- switch (format_) {
- case CommandLineInterface::ERROR_FORMAT_GCC:
- out << ":" << (line + 1) << ":" << (column + 1);
- break;
- case CommandLineInterface::ERROR_FORMAT_MSVS:
+ tree_->VirtualFileToDiskFile(filename, &dfile)) {
+ out << dfile;
+ } else {
+ out << filename;
+ }
+
+ // Users typically expect 1-based line/column numbers, so we add 1
+ // to each here.
+ if (line != -1) {
+ // Allow for both GCC- and Visual-Studio-compatible output.
+ switch (format_) {
+ case CommandLineInterface::ERROR_FORMAT_GCC:
+ out << ":" << (line + 1) << ":" << (column + 1);
+ break;
+ case CommandLineInterface::ERROR_FORMAT_MSVS:
out << "(" << (line + 1) << ") : " << type
<< " in column=" << (column + 1);
- break;
- }
- }
-
- if (type == "warning") {
- out << ": warning: " << message << std::endl;
- } else {
- out << ": " << message << std::endl;
- }
- }
-
- const ErrorFormat format_;
+ break;
+ }
+ }
+
+ if (type == "warning") {
+ out << ": warning: " << message << std::endl;
+ } else {
+ out << ": " << message << std::endl;
+ }
+ }
+
+ const ErrorFormat format_;
DiskSourceTree* tree_;
bool found_errors_;
bool found_warnings_;
-};
-
-// -------------------------------------------------------------------
-
-// A GeneratorContext implementation that buffers files in memory, then dumps
-// them all to disk on demand.
-class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
- public:
+};
+
+// -------------------------------------------------------------------
+
+// A GeneratorContext implementation that buffers files in memory, then dumps
+// them all to disk on demand.
+class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
+ public:
GeneratorContextImpl(const std::vector<const FileDescriptor*>& parsed_files);
-
- // Write all files in the directory to disk at the given output location,
- // which must end in a '/'.
+
+ // Write all files in the directory to disk at the given output location,
+ // which must end in a '/'.
bool WriteAllToDisk(const TProtoStringType& prefix);
-
- // Write the contents of this directory to a ZIP-format archive with the
- // given name.
+
+ // Write the contents of this directory to a ZIP-format archive with the
+ // given name.
bool WriteAllToZip(const TProtoStringType& filename);
-
- // Add a boilerplate META-INF/MANIFEST.MF file as required by the Java JAR
- // format, unless one has already been written.
- void AddJarManifest();
-
- // Get name of all output files.
+
+ // Add a boilerplate META-INF/MANIFEST.MF file as required by the Java JAR
+ // format, unless one has already been written.
+ void AddJarManifest();
+
+ // Get name of all output files.
void GetOutputFilenames(std::vector<TProtoStringType>* output_filenames);
-
- // implements GeneratorContext --------------------------------------
+
+ // implements GeneratorContext --------------------------------------
io::ZeroCopyOutputStream* Open(const TProtoStringType& filename);
io::ZeroCopyOutputStream* OpenForAppend(const TProtoStringType& filename);
io::ZeroCopyOutputStream* OpenForInsert(const TProtoStringType& filename,
@@ -408,23 +408,23 @@ class CommandLineInterface::GeneratorContextImpl : public GeneratorContext {
const TProtoStringType& filename, const TProtoStringType& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
void ListParsedFiles(std::vector<const FileDescriptor*>* output) {
- *output = parsed_files_;
- }
-
- private:
- friend class MemoryOutputStream;
-
+ *output = parsed_files_;
+ }
+
+ private:
+ friend class MemoryOutputStream;
+
// The files_ field maps from path keys to file content values. It's a map
// instead of an unordered_map so that files are written in order (good when
- // writing zips).
+ // writing zips).
std::map<TProtoStringType, TProtoStringType> files_;
const std::vector<const FileDescriptor*>& parsed_files_;
- bool had_error_;
-};
-
-class CommandLineInterface::MemoryOutputStream
- : public io::ZeroCopyOutputStream {
- public:
+ bool had_error_;
+};
+
+class CommandLineInterface::MemoryOutputStream
+ : public io::ZeroCopyOutputStream {
+ public:
MemoryOutputStream(GeneratorContextImpl* directory,
const TProtoStringType& filename, bool append_mode);
MemoryOutputStream(GeneratorContextImpl* directory,
@@ -434,16 +434,16 @@ class CommandLineInterface::MemoryOutputStream
const TProtoStringType& filename,
const TProtoStringType& insertion_point,
const google::protobuf::GeneratedCodeInfo& info);
- virtual ~MemoryOutputStream();
-
- // implements ZeroCopyOutputStream ---------------------------------
+ virtual ~MemoryOutputStream();
+
+ // implements ZeroCopyOutputStream ---------------------------------
bool Next(void** data, int* size) override {
return inner_->Next(data, size);
}
void BackUp(int count) override { inner_->BackUp(count); }
int64_t ByteCount() const override { return inner_->ByteCount(); }
-
- private:
+
+ private:
// Checks to see if "filename_.pb.meta" exists in directory_; if so, fixes the
// offsets in that GeneratedCodeInfo record to reflect bytes inserted in
// filename_ at original offset insertion_offset with length insertion_length.
@@ -462,180 +462,180 @@ class CommandLineInterface::MemoryOutputStream
size_t insertion_offset, size_t indent_length,
google::protobuf::GeneratedCodeInfo& target_info);
- // Where to insert the string when it's done.
- GeneratorContextImpl* directory_;
+ // Where to insert the string when it's done.
+ GeneratorContextImpl* directory_;
TProtoStringType filename_;
TProtoStringType insertion_point_;
-
- // The string we're building.
+
+ // The string we're building.
TProtoStringType data_;
-
- // Whether we should append the output stream to the existing file.
- bool append_mode_;
-
- // StringOutputStream writing to data_.
+
+ // Whether we should append the output stream to the existing file.
+ bool append_mode_;
+
+ // StringOutputStream writing to data_.
std::unique_ptr<io::StringOutputStream> inner_;
// The GeneratedCodeInfo to insert at the insertion point.
google::protobuf::GeneratedCodeInfo info_to_insert_;
-};
-
-// -------------------------------------------------------------------
-
-CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl(
+};
+
+// -------------------------------------------------------------------
+
+CommandLineInterface::GeneratorContextImpl::GeneratorContextImpl(
const std::vector<const FileDescriptor*>& parsed_files)
: parsed_files_(parsed_files), had_error_(false) {}
-
-bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk(
+
+bool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk(
const TProtoStringType& prefix) {
- if (had_error_) {
- return false;
- }
-
- if (!VerifyDirectoryExists(prefix)) {
- return false;
- }
-
+ if (had_error_) {
+ return false;
+ }
+
+ if (!VerifyDirectoryExists(prefix)) {
+ return false;
+ }
+
for (const auto& pair : files_) {
const TProtoStringType& relative_filename = pair.first;
const char* data = pair.second.data();
int size = pair.second.size();
-
- if (!TryCreateParentDirectory(prefix, relative_filename)) {
- return false;
- }
+
+ if (!TryCreateParentDirectory(prefix, relative_filename)) {
+ return false;
+ }
TProtoStringType filename = prefix + relative_filename;
-
- // Create the output file.
- int file_descriptor;
- do {
- file_descriptor =
+
+ // Create the output file.
+ int file_descriptor;
+ do {
+ file_descriptor =
open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- } while (file_descriptor < 0 && errno == EINTR);
-
- if (file_descriptor < 0) {
- int error = errno;
- std::cerr << filename << ": " << strerror(error);
- return false;
- }
-
- // Write the file.
- while (size > 0) {
- int write_result;
- do {
- write_result = write(file_descriptor, data, size);
- } while (write_result < 0 && errno == EINTR);
-
- if (write_result <= 0) {
- // Write error.
-
- // FIXME(kenton): According to the man page, if write() returns zero,
- // there was no error; write() simply did not write anything. It's
- // unclear under what circumstances this might happen, but presumably
- // errno won't be set in this case. I am confused as to how such an
- // event should be handled. For now I'm treating it as an error,
- // since retrying seems like it could lead to an infinite loop. I
- // suspect this never actually happens anyway.
-
- if (write_result < 0) {
- int error = errno;
- std::cerr << filename << ": write: " << strerror(error);
- } else {
- std::cerr << filename << ": write() returned zero?" << std::endl;
- }
- return false;
- }
-
- data += write_result;
- size -= write_result;
- }
-
- if (close(file_descriptor) != 0) {
- int error = errno;
- std::cerr << filename << ": close: " << strerror(error);
- return false;
- }
- }
-
- return true;
-}
-
-bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip(
+ } while (file_descriptor < 0 && errno == EINTR);
+
+ if (file_descriptor < 0) {
+ int error = errno;
+ std::cerr << filename << ": " << strerror(error);
+ return false;
+ }
+
+ // Write the file.
+ while (size > 0) {
+ int write_result;
+ do {
+ write_result = write(file_descriptor, data, size);
+ } while (write_result < 0 && errno == EINTR);
+
+ if (write_result <= 0) {
+ // Write error.
+
+ // FIXME(kenton): According to the man page, if write() returns zero,
+ // there was no error; write() simply did not write anything. It's
+ // unclear under what circumstances this might happen, but presumably
+ // errno won't be set in this case. I am confused as to how such an
+ // event should be handled. For now I'm treating it as an error,
+ // since retrying seems like it could lead to an infinite loop. I
+ // suspect this never actually happens anyway.
+
+ if (write_result < 0) {
+ int error = errno;
+ std::cerr << filename << ": write: " << strerror(error);
+ } else {
+ std::cerr << filename << ": write() returned zero?" << std::endl;
+ }
+ return false;
+ }
+
+ data += write_result;
+ size -= write_result;
+ }
+
+ if (close(file_descriptor) != 0) {
+ int error = errno;
+ std::cerr << filename << ": close: " << strerror(error);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool CommandLineInterface::GeneratorContextImpl::WriteAllToZip(
const TProtoStringType& filename) {
- if (had_error_) {
- return false;
- }
-
- // Create the output file.
- int file_descriptor;
- do {
- file_descriptor =
+ if (had_error_) {
+ return false;
+ }
+
+ // Create the output file.
+ int file_descriptor;
+ do {
+ file_descriptor =
open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- } while (file_descriptor < 0 && errno == EINTR);
-
- if (file_descriptor < 0) {
- int error = errno;
- std::cerr << filename << ": " << strerror(error);
- return false;
- }
-
- // Create the ZipWriter
- io::FileOutputStream stream(file_descriptor);
- ZipWriter zip_writer(&stream);
-
+ } while (file_descriptor < 0 && errno == EINTR);
+
+ if (file_descriptor < 0) {
+ int error = errno;
+ std::cerr << filename << ": " << strerror(error);
+ return false;
+ }
+
+ // Create the ZipWriter
+ io::FileOutputStream stream(file_descriptor);
+ ZipWriter zip_writer(&stream);
+
for (const auto& pair : files_) {
zip_writer.Write(pair.first, pair.second);
- }
-
- zip_writer.WriteDirectory();
-
- if (stream.GetErrno() != 0) {
- std::cerr << filename << ": " << strerror(stream.GetErrno()) << std::endl;
+ }
+
+ zip_writer.WriteDirectory();
+
+ if (stream.GetErrno() != 0) {
+ std::cerr << filename << ": " << strerror(stream.GetErrno()) << std::endl;
return false;
- }
-
- if (!stream.Close()) {
- std::cerr << filename << ": " << strerror(stream.GetErrno()) << std::endl;
+ }
+
+ if (!stream.Close()) {
+ std::cerr << filename << ": " << strerror(stream.GetErrno()) << std::endl;
return false;
- }
-
- return true;
-}
-
-void CommandLineInterface::GeneratorContextImpl::AddJarManifest() {
+ }
+
+ return true;
+}
+
+void CommandLineInterface::GeneratorContextImpl::AddJarManifest() {
auto pair = files_.insert({"META-INF/MANIFEST.MF", ""});
if (pair.second) {
pair.first->second =
- "Manifest-Version: 1.0\n"
- "Created-By: 1.6.0 (protoc)\n"
+ "Manifest-Version: 1.0\n"
+ "Created-By: 1.6.0 (protoc)\n"
"\n";
- }
-}
-
-void CommandLineInterface::GeneratorContextImpl::GetOutputFilenames(
+ }
+}
+
+void CommandLineInterface::GeneratorContextImpl::GetOutputFilenames(
std::vector<TProtoStringType>* output_filenames) {
for (const auto& pair : files_) {
output_filenames->push_back(pair.first);
- }
-}
-
-io::ZeroCopyOutputStream* CommandLineInterface::GeneratorContextImpl::Open(
+ }
+}
+
+io::ZeroCopyOutputStream* CommandLineInterface::GeneratorContextImpl::Open(
const TProtoStringType& filename) {
- return new MemoryOutputStream(this, filename, false);
-}
-
-io::ZeroCopyOutputStream*
-CommandLineInterface::GeneratorContextImpl::OpenForAppend(
+ return new MemoryOutputStream(this, filename, false);
+}
+
+io::ZeroCopyOutputStream*
+CommandLineInterface::GeneratorContextImpl::OpenForAppend(
const TProtoStringType& filename) {
- return new MemoryOutputStream(this, filename, true);
-}
-
-io::ZeroCopyOutputStream*
-CommandLineInterface::GeneratorContextImpl::OpenForInsert(
+ return new MemoryOutputStream(this, filename, true);
+}
+
+io::ZeroCopyOutputStream*
+CommandLineInterface::GeneratorContextImpl::OpenForInsert(
const TProtoStringType& filename, const TProtoStringType& insertion_point) {
- return new MemoryOutputStream(this, filename, insertion_point);
-}
-
+ return new MemoryOutputStream(this, filename, insertion_point);
+}
+
io::ZeroCopyOutputStream*
CommandLineInterface::GeneratorContextImpl::OpenForInsertWithGeneratedCodeInfo(
const TProtoStringType& filename, const TProtoStringType& insertion_point,
@@ -643,22 +643,22 @@ CommandLineInterface::GeneratorContextImpl::OpenForInsertWithGeneratedCodeInfo(
return new MemoryOutputStream(this, filename, insertion_point, info);
}
-// -------------------------------------------------------------------
-
-CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
+// -------------------------------------------------------------------
+
+CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
GeneratorContextImpl* directory, const TProtoStringType& filename,
bool append_mode)
- : directory_(directory),
- filename_(filename),
- append_mode_(append_mode),
+ : directory_(directory),
+ filename_(filename),
+ append_mode_(append_mode),
inner_(new io::StringOutputStream(&data_)) {}
-
-CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
+
+CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
GeneratorContextImpl* directory, const TProtoStringType& filename,
const TProtoStringType& insertion_point)
- : directory_(directory),
- filename_(filename),
- insertion_point_(insertion_point),
+ : directory_(directory),
+ filename_(filename),
+ insertion_point_(insertion_point),
inner_(new io::StringOutputStream(&data_)) {}
CommandLineInterface::MemoryOutputStream::MemoryOutputStream(
@@ -703,8 +703,8 @@ void CommandLineInterface::MemoryOutputStream::InsertShiftedInfo(
insertion_offset += inner_indent;
annotation->set_end(annotation->end() + insertion_offset);
}
-}
-
+}
+
void CommandLineInterface::MemoryOutputStream::UpdateMetadata(
const TProtoStringType& insertion_content, size_t insertion_offset,
size_t insertion_length, size_t indent_length) {
@@ -772,161 +772,161 @@ void CommandLineInterface::MemoryOutputStream::UpdateMetadata(
}
}
-CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
- // Make sure all data has been written.
- inner_.reset();
-
- // Insert into the directory.
+CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {
+ // Make sure all data has been written.
+ inner_.reset();
+
+ // Insert into the directory.
auto pair = directory_->files_.insert({filename_, ""});
auto it = pair.first;
bool already_present = !pair.second;
-
- if (insertion_point_.empty()) {
- // This was just a regular Open().
+
+ if (insertion_point_.empty()) {
+ // This was just a regular Open().
if (already_present) {
- if (append_mode_) {
+ if (append_mode_) {
it->second.append(data_);
- } else {
- std::cerr << filename_ << ": Tried to write the same file twice."
- << std::endl;
- directory_->had_error_ = true;
- }
- return;
- }
-
+ } else {
+ std::cerr << filename_ << ": Tried to write the same file twice."
+ << std::endl;
+ directory_->had_error_ = true;
+ }
+ return;
+ }
+
it->second.swap(data_);
- } else {
- // This was an OpenForInsert().
-
- // If the data doesn't end with a clean line break, add one.
- if (!data_.empty() && data_[data_.size() - 1] != '\n') {
- data_.push_back('\n');
- }
-
- // Find the file we are going to insert into.
+ } else {
+ // This was an OpenForInsert().
+
+ // If the data doesn't end with a clean line break, add one.
+ if (!data_.empty() && data_[data_.size() - 1] != '\n') {
+ data_.push_back('\n');
+ }
+
+ // Find the file we are going to insert into.
if (!already_present) {
- std::cerr << filename_
- << ": Tried to insert into file that doesn't exist."
- << std::endl;
- directory_->had_error_ = true;
- return;
- }
+ std::cerr << filename_
+ << ": Tried to insert into file that doesn't exist."
+ << std::endl;
+ directory_->had_error_ = true;
+ return;
+ }
TProtoStringType* target = &it->second;
-
- // Find the insertion point.
+
+ // Find the insertion point.
TProtoStringType magic_string =
strings::Substitute("@@protoc_insertion_point($0)", insertion_point_);
TProtoStringType::size_type pos = target->find(magic_string);
-
+
if (pos == TProtoStringType::npos) {
- std::cerr << filename_ << ": insertion point \"" << insertion_point_
- << "\" not found." << std::endl;
- directory_->had_error_ = true;
- return;
- }
-
- if ((pos > 3) && (target->substr(pos - 3, 2) == "/*")) {
- // Support for inline "/* @@protoc_insertion_point() */"
- pos = pos - 3;
- } else {
- // Seek backwards to the beginning of the line, which is where we will
- // insert the data. Note that this has the effect of pushing the
- // insertion point down, so the data is inserted before it. This is
- // intentional because it means that multiple insertions at the same point
- // will end up in the expected order in the final output.
- pos = target->find_last_of('\n', pos);
+ std::cerr << filename_ << ": insertion point \"" << insertion_point_
+ << "\" not found." << std::endl;
+ directory_->had_error_ = true;
+ return;
+ }
+
+ if ((pos > 3) && (target->substr(pos - 3, 2) == "/*")) {
+ // Support for inline "/* @@protoc_insertion_point() */"
+ pos = pos - 3;
+ } else {
+ // Seek backwards to the beginning of the line, which is where we will
+ // insert the data. Note that this has the effect of pushing the
+ // insertion point down, so the data is inserted before it. This is
+ // intentional because it means that multiple insertions at the same point
+ // will end up in the expected order in the final output.
+ pos = target->find_last_of('\n', pos);
if (pos == TProtoStringType::npos) {
- // Insertion point is on the first line.
- pos = 0;
- } else {
- // Advance to character after '\n'.
- ++pos;
- }
- }
-
- // Extract indent.
+ // Insertion point is on the first line.
+ pos = 0;
+ } else {
+ // Advance to character after '\n'.
+ ++pos;
+ }
+ }
+
+ // Extract indent.
TProtoStringType indent_(*target, pos,
target->find_first_not_of(" \t", pos) - pos);
-
- if (indent_.empty()) {
- // No indent. This makes things easier.
- target->insert(pos, data_);
+
+ if (indent_.empty()) {
+ // No indent. This makes things easier.
+ target->insert(pos, data_);
UpdateMetadata(data_, pos, data_.size(), 0);
- } else {
- // Calculate how much space we need.
- int indent_size = 0;
- for (int i = 0; i < data_.size(); i++) {
- if (data_[i] == '\n') indent_size += indent_.size();
- }
-
- // Make a hole for it.
- target->insert(pos, data_.size() + indent_size, '\0');
-
- // Now copy in the data.
+ } else {
+ // Calculate how much space we need.
+ int indent_size = 0;
+ for (int i = 0; i < data_.size(); i++) {
+ if (data_[i] == '\n') indent_size += indent_.size();
+ }
+
+ // Make a hole for it.
+ target->insert(pos, data_.size() + indent_size, '\0');
+
+ // Now copy in the data.
TProtoStringType::size_type data_pos = 0;
char* target_ptr = ::google::protobuf::string_as_array(target) + pos;
- while (data_pos < data_.size()) {
- // Copy indent.
- memcpy(target_ptr, indent_.data(), indent_.size());
- target_ptr += indent_.size();
-
- // Copy line from data_.
- // We already guaranteed that data_ ends with a newline (above), so this
- // search can't fail.
+ while (data_pos < data_.size()) {
+ // Copy indent.
+ memcpy(target_ptr, indent_.data(), indent_.size());
+ target_ptr += indent_.size();
+
+ // Copy line from data_.
+ // We already guaranteed that data_ ends with a newline (above), so this
+ // search can't fail.
TProtoStringType::size_type line_length =
- data_.find_first_of('\n', data_pos) + 1 - data_pos;
- memcpy(target_ptr, data_.data() + data_pos, line_length);
- target_ptr += line_length;
- data_pos += line_length;
- }
+ data_.find_first_of('\n', data_pos) + 1 - data_pos;
+ memcpy(target_ptr, data_.data() + data_pos, line_length);
+ target_ptr += line_length;
+ data_pos += line_length;
+ }
UpdateMetadata(data_, pos, data_.size() + indent_size, indent_.size());
-
- GOOGLE_CHECK_EQ(target_ptr,
+
+ GOOGLE_CHECK_EQ(target_ptr,
::google::protobuf::string_as_array(target) + pos + data_.size() + indent_size);
- }
- }
-}
-
-// ===================================================================
-
+ }
+ }
+}
+
+// ===================================================================
+
#if defined(_WIN32) && !defined(__CYGWIN__)
const char* const CommandLineInterface::kPathSeparator = ";";
#else
const char* const CommandLineInterface::kPathSeparator = ":";
#endif
-CommandLineInterface::CommandLineInterface()
+CommandLineInterface::CommandLineInterface()
: direct_dependencies_violation_msg_(
kDefaultDirectDependenciesViolationMsg) {}
-CommandLineInterface::~CommandLineInterface() {}
-
+CommandLineInterface::~CommandLineInterface() {}
+
void CommandLineInterface::RegisterGenerator(const TProtoStringType& flag_name,
- CodeGenerator* generator,
+ CodeGenerator* generator,
const TProtoStringType& help_text) {
- GeneratorInfo info;
- info.flag_name = flag_name;
- info.generator = generator;
- info.help_text = help_text;
- generators_by_flag_name_[flag_name] = info;
-}
-
+ GeneratorInfo info;
+ info.flag_name = flag_name;
+ info.generator = generator;
+ info.help_text = help_text;
+ generators_by_flag_name_[flag_name] = info;
+}
+
void CommandLineInterface::RegisterGenerator(
const TProtoStringType& flag_name, const TProtoStringType& option_flag_name,
CodeGenerator* generator, const TProtoStringType& help_text) {
- GeneratorInfo info;
- info.flag_name = flag_name;
- info.option_flag_name = option_flag_name;
- info.generator = generator;
- info.help_text = help_text;
- generators_by_flag_name_[flag_name] = info;
- generators_by_option_name_[option_flag_name] = info;
-}
-
+ GeneratorInfo info;
+ info.flag_name = flag_name;
+ info.option_flag_name = option_flag_name;
+ info.generator = generator;
+ info.help_text = help_text;
+ generators_by_flag_name_[flag_name] = info;
+ generators_by_option_name_[option_flag_name] = info;
+}
+
void CommandLineInterface::AllowPlugins(const TProtoStringType& exe_name_prefix) {
- plugin_prefix_ = exe_name_prefix;
-}
-
+ plugin_prefix_ = exe_name_prefix;
+}
+
namespace {
bool ContainsProto3Optional(const Descriptor* desc) {
@@ -961,17 +961,17 @@ std::unique_ptr<SimpleDescriptorDatabase>
PopulateSingleSimpleDescriptorDatabase(const TProtoStringType& descriptor_set_name);
}
-int CommandLineInterface::Run(int argc, const char* const argv[]) {
- Clear();
- switch (ParseArguments(argc, argv)) {
- case PARSE_ARGUMENT_DONE_AND_EXIT:
- return 0;
- case PARSE_ARGUMENT_FAIL:
- return 1;
- case PARSE_ARGUMENT_DONE_AND_CONTINUE:
- break;
- }
-
+int CommandLineInterface::Run(int argc, const char* const argv[]) {
+ Clear();
+ switch (ParseArguments(argc, argv)) {
+ case PARSE_ARGUMENT_DONE_AND_EXIT:
+ return 0;
+ case PARSE_ARGUMENT_FAIL:
+ return 1;
+ case PARSE_ARGUMENT_DONE_AND_CONTINUE:
+ break;
+ }
+
std::vector<const FileDescriptor*> parsed_files;
std::unique_ptr<DiskSourceTree> disk_source_tree;
std::unique_ptr<ErrorPrinter> error_collector;
@@ -1025,12 +1025,12 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
disk_source_tree.reset(new DiskSourceTree());
if (!InitializeDiskSourceTree(disk_source_tree.get(),
descriptor_set_in_database.get())) {
- return 1;
- }
+ return 1;
+ }
error_collector.reset(
new ErrorPrinter(error_format_, disk_source_tree.get()));
-
+
source_tree_database.reset(new SourceTreeDescriptorDatabase(
disk_source_tree.get(), descriptor_set_in_database.get()));
source_tree_database->RecordErrorsTo(error_collector.get());
@@ -1039,122 +1039,122 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
source_tree_database.get(),
source_tree_database->GetValidationErrorCollector()));
}
-
+
descriptor_pool->EnforceWeakDependencies(true);
if (!ParseInputFiles(descriptor_pool.get(), disk_source_tree.get(),
&parsed_files)) {
return 1;
}
-
- // We construct a separate GeneratorContext for each output location. Note
- // that two code generators may output to the same location, in which case
- // they should share a single GeneratorContext so that OpenForInsert() works.
- GeneratorContextMap output_directories;
-
- // Generate output.
- if (mode_ == MODE_COMPILE) {
- for (int i = 0; i < output_directives_.size(); i++) {
+
+ // We construct a separate GeneratorContext for each output location. Note
+ // that two code generators may output to the same location, in which case
+ // they should share a single GeneratorContext so that OpenForInsert() works.
+ GeneratorContextMap output_directories;
+
+ // Generate output.
+ if (mode_ == MODE_COMPILE) {
+ for (int i = 0; i < output_directives_.size(); i++) {
TProtoStringType output_location = output_directives_[i].output_location;
- if (!HasSuffixString(output_location, ".zip") &&
+ if (!HasSuffixString(output_location, ".zip") &&
!HasSuffixString(output_location, ".jar") &&
!HasSuffixString(output_location, ".srcjar")) {
- AddTrailingSlash(&output_location);
- }
-
+ AddTrailingSlash(&output_location);
+ }
+
auto& generator = output_directories[output_location];
if (!generator) {
- // First time we've seen this output location.
+ // First time we've seen this output location.
generator.reset(new GeneratorContextImpl(parsed_files));
- }
-
+ }
+
if (!GenerateOutput(parsed_files, output_directives_[i],
generator.get())) {
- return 1;
- }
- }
- }
-
- // Write all output to disk.
+ return 1;
+ }
+ }
+ }
+
+ // Write all output to disk.
for (const auto& pair : output_directories) {
const TProtoStringType& location = pair.first;
GeneratorContextImpl* directory = pair.second.get();
- if (HasSuffixString(location, "/")) {
- if (!directory->WriteAllToDisk(location)) {
- return 1;
- }
- } else {
- if (HasSuffixString(location, ".jar")) {
- directory->AddJarManifest();
- }
-
- if (!directory->WriteAllToZip(location)) {
- return 1;
- }
- }
- }
-
- if (!dependency_out_name_.empty()) {
+ if (HasSuffixString(location, "/")) {
+ if (!directory->WriteAllToDisk(location)) {
+ return 1;
+ }
+ } else {
+ if (HasSuffixString(location, ".jar")) {
+ directory->AddJarManifest();
+ }
+
+ if (!directory->WriteAllToZip(location)) {
+ return 1;
+ }
+ }
+ }
+
+ if (!dependency_out_name_.empty()) {
GOOGLE_DCHECK(disk_source_tree.get());
- if (!GenerateDependencyManifestFile(parsed_files, output_directories,
+ if (!GenerateDependencyManifestFile(parsed_files, output_directories,
disk_source_tree.get())) {
- return 1;
- }
- }
-
+ return 1;
+ }
+ }
+
if (!descriptor_set_out_name_.empty()) {
- if (!WriteDescriptorSet(parsed_files)) {
- return 1;
- }
- }
-
- if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) {
- if (codec_type_.empty()) {
- // HACK: Define an EmptyMessage type to use for decoding.
- DescriptorPool pool;
- FileDescriptorProto file;
- file.set_name("empty_message.proto");
- file.add_message_type()->set_name("EmptyMessage");
- GOOGLE_CHECK(pool.BuildFile(file) != NULL);
- codec_type_ = "EmptyMessage";
- if (!EncodeOrDecode(&pool)) {
- return 1;
- }
- } else {
+ if (!WriteDescriptorSet(parsed_files)) {
+ return 1;
+ }
+ }
+
+ if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) {
+ if (codec_type_.empty()) {
+ // HACK: Define an EmptyMessage type to use for decoding.
+ DescriptorPool pool;
+ FileDescriptorProto file;
+ file.set_name("empty_message.proto");
+ file.add_message_type()->set_name("EmptyMessage");
+ GOOGLE_CHECK(pool.BuildFile(file) != NULL);
+ codec_type_ = "EmptyMessage";
+ if (!EncodeOrDecode(&pool)) {
+ return 1;
+ }
+ } else {
if (!EncodeOrDecode(descriptor_pool.get())) {
- return 1;
- }
- }
- }
-
+ return 1;
+ }
+ }
+ }
+
if (error_collector->FoundErrors() ||
(fatal_warnings_ && error_collector->FoundWarnings())) {
return 1;
}
- if (mode_ == MODE_PRINT) {
- switch (print_mode_) {
- case PRINT_FREE_FIELDS:
- for (int i = 0; i < parsed_files.size(); ++i) {
- const FileDescriptor* fd = parsed_files[i];
- for (int j = 0; j < fd->message_type_count(); ++j) {
- PrintFreeFieldNumbers(fd->message_type(j));
- }
- }
- break;
- case PRINT_NONE:
- GOOGLE_LOG(ERROR) << "If the code reaches here, it usually means a bug of "
+ if (mode_ == MODE_PRINT) {
+ switch (print_mode_) {
+ case PRINT_FREE_FIELDS:
+ for (int i = 0; i < parsed_files.size(); ++i) {
+ const FileDescriptor* fd = parsed_files[i];
+ for (int j = 0; j < fd->message_type_count(); ++j) {
+ PrintFreeFieldNumbers(fd->message_type(j));
+ }
+ }
+ break;
+ case PRINT_NONE:
+ GOOGLE_LOG(ERROR) << "If the code reaches here, it usually means a bug of "
"flag parsing in the CommandLineInterface.";
- return 1;
-
+ return 1;
+
// Do not add a default case.
- }
- }
-
- return 0;
-}
-
+ }
+ }
+
+ return 0;
+}
+
bool CommandLineInterface::InitializeDiskSourceTree(
DiskSourceTree* source_tree, DescriptorDatabase* fallback_database) {
AddDefaultProtoPaths(&proto_path_);
@@ -1311,30 +1311,30 @@ bool CommandLineInterface::ParseInputFiles(
return result;
}
-void CommandLineInterface::Clear() {
- // Clear all members that are set by Run(). Note that we must not clear
- // members which are set by other methods before Run() is called.
- executable_name_.clear();
- proto_path_.clear();
- input_files_.clear();
+void CommandLineInterface::Clear() {
+ // Clear all members that are set by Run(). Note that we must not clear
+ // members which are set by other methods before Run() is called.
+ executable_name_.clear();
+ proto_path_.clear();
+ input_files_.clear();
direct_dependencies_.clear();
direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg;
- output_directives_.clear();
- codec_type_.clear();
+ output_directives_.clear();
+ codec_type_.clear();
descriptor_set_in_names_.clear();
descriptor_set_out_name_.clear();
- dependency_out_name_.clear();
-
-
- mode_ = MODE_COMPILE;
- print_mode_ = PRINT_NONE;
- imports_in_descriptor_set_ = false;
- source_info_in_descriptor_set_ = false;
- disallow_services_ = false;
+ dependency_out_name_.clear();
+
+
+ mode_ = MODE_COMPILE;
+ print_mode_ = PRINT_NONE;
+ imports_in_descriptor_set_ = false;
+ source_info_in_descriptor_set_ = false;
+ disallow_services_ = false;
direct_dependencies_explicitly_set_ = false;
deterministic_output_ = false;
-}
-
+}
+
bool CommandLineInterface::MakeProtoProtoPathRelative(
DiskSourceTree* source_tree, TProtoStringType* proto,
DescriptorDatabase* fallback_database) {
@@ -1402,13 +1402,13 @@ bool CommandLineInterface::MakeProtoProtoPathRelative(
"(e.g. absolute and relative) are equivalent (it's harder "
"than you think)."
<< std::endl;
- return false;
+ return false;
}
- }
- }
+ }
+ }
return true;
}
-
+
bool CommandLineInterface::MakeInputsBeProtoPathRelative(
DiskSourceTree* source_tree, DescriptorDatabase* fallback_database) {
for (auto& input_file : input_files_) {
@@ -1418,10 +1418,10 @@ bool CommandLineInterface::MakeInputsBeProtoPathRelative(
}
}
- return true;
-}
-
-
+ return true;
+}
+
+
bool CommandLineInterface::ExpandArgumentFile(
const TProtoStringType& file, std::vector<TProtoStringType>* arguments) {
// The argument file is searched in the working directory only. We don't
@@ -1440,10 +1440,10 @@ bool CommandLineInterface::ExpandArgumentFile(
CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
int argc, const char* const argv[]) {
- executable_name_ = argv[0];
-
+ executable_name_ = argv[0];
+
std::vector<TProtoStringType> arguments;
- for (int i = 1; i < argc; ++i) {
+ for (int i = 1; i < argc; ++i) {
if (argv[i][0] == '@') {
if (!ExpandArgumentFile(argv[i] + 1, &arguments)) {
std::cerr << "Failed to open argument file: " << (argv[i] + 1)
@@ -1452,38 +1452,38 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
}
continue;
}
- arguments.push_back(argv[i]);
- }
-
+ arguments.push_back(argv[i]);
+ }
+
// if no arguments are given, show help
if (arguments.empty()) {
PrintHelpText();
return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
}
- // Iterate through all arguments and parse them.
- for (int i = 0; i < arguments.size(); ++i) {
+ // Iterate through all arguments and parse them.
+ for (int i = 0; i < arguments.size(); ++i) {
TProtoStringType name, value;
-
- if (ParseArgument(arguments[i].c_str(), &name, &value)) {
- // Returned true => Use the next argument as the flag value.
- if (i + 1 == arguments.size() || arguments[i + 1][0] == '-') {
- std::cerr << "Missing value for flag: " << name << std::endl;
- if (name == "--decode") {
- std::cerr << "To decode an unknown message, use --decode_raw."
- << std::endl;
- }
- return PARSE_ARGUMENT_FAIL;
- } else {
- ++i;
- value = arguments[i];
- }
- }
-
- ParseArgumentStatus status = InterpretArgument(name, value);
+
+ if (ParseArgument(arguments[i].c_str(), &name, &value)) {
+ // Returned true => Use the next argument as the flag value.
+ if (i + 1 == arguments.size() || arguments[i + 1][0] == '-') {
+ std::cerr << "Missing value for flag: " << name << std::endl;
+ if (name == "--decode") {
+ std::cerr << "To decode an unknown message, use --decode_raw."
+ << std::endl;
+ }
+ return PARSE_ARGUMENT_FAIL;
+ } else {
+ ++i;
+ value = arguments[i];
+ }
+ }
+
+ ParseArgumentStatus status = InterpretArgument(name, value);
if (status != PARSE_ARGUMENT_DONE_AND_CONTINUE) return status;
- }
-
+ }
+
// Make sure each plugin option has a matching plugin output.
bool foundUnknownPluginOption = false;
for (std::map<TProtoStringType, TProtoStringType>::const_iterator i =
@@ -1519,12 +1519,12 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
// The --proto_path & --descriptor_set_in flags both specify places to look
// for proto files. If neither were given, use the current working directory.
if (proto_path_.empty() && descriptor_set_in_names_.empty()) {
- // Don't use make_pair as the old/default standard library on Solaris
- // doesn't support it without explicit template parameters, which are
- // incompatible with C++0x's make_pair.
+ // Don't use make_pair as the old/default standard library on Solaris
+ // doesn't support it without explicit template parameters, which are
+ // incompatible with C++0x's make_pair.
proto_path_.push_back(std::pair<TProtoStringType, TProtoStringType>("", "."));
- }
-
+ }
+
// Check error cases that span multiple flag values.
bool missing_proto_definitions = false;
switch (mode_) {
@@ -1538,7 +1538,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
if (!input_files_.empty() || !descriptor_set_in_names_.empty()) {
std::cerr
<< "When using --decode_raw, no input files should be given."
- << std::endl;
+ << std::endl;
return PARSE_ARGUMENT_FAIL;
}
missing_proto_definitions = false;
@@ -1555,19 +1555,19 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
GOOGLE_LOG(FATAL) << "Unexpected mode: " << mode_;
}
if (missing_proto_definitions) {
- std::cerr << "Missing input file." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (mode_ == MODE_COMPILE && output_directives_.empty() &&
+ std::cerr << "Missing input file." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (mode_ == MODE_COMPILE && output_directives_.empty() &&
descriptor_set_out_name_.empty()) {
- std::cerr << "Missing output directives." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (mode_ != MODE_COMPILE && !dependency_out_name_.empty()) {
- std::cerr << "Can only use --dependency_out=FILE when generating code."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+ std::cerr << "Missing output directives." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (mode_ != MODE_COMPILE && !dependency_out_name_.empty()) {
+ std::cerr << "Can only use --dependency_out=FILE when generating code."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
if (mode_ != MODE_ENCODE && deterministic_output_) {
std::cerr << "Can only use --deterministic_output with --encode."
<< std::endl;
@@ -1580,103 +1580,103 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments(
<< std::endl;
return PARSE_ARGUMENT_FAIL;
}
- if (!dependency_out_name_.empty() && input_files_.size() > 1) {
- std::cerr
- << "Can only process one input file when using --dependency_out=FILE."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+ if (!dependency_out_name_.empty() && input_files_.size() > 1) {
+ std::cerr
+ << "Can only process one input file when using --dependency_out=FILE."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
if (imports_in_descriptor_set_ && descriptor_set_out_name_.empty()) {
- std::cerr << "--include_imports only makes sense when combined with "
+ std::cerr << "--include_imports only makes sense when combined with "
"--descriptor_set_out."
<< std::endl;
- }
+ }
if (source_info_in_descriptor_set_ && descriptor_set_out_name_.empty()) {
- std::cerr << "--include_source_info only makes sense when combined with "
+ std::cerr << "--include_source_info only makes sense when combined with "
"--descriptor_set_out."
<< std::endl;
- }
-
- return PARSE_ARGUMENT_DONE_AND_CONTINUE;
-}
-
+ }
+
+ return PARSE_ARGUMENT_DONE_AND_CONTINUE;
+}
+
bool CommandLineInterface::ParseArgument(const char* arg, TProtoStringType* name,
TProtoStringType* value) {
- bool parsed_value = false;
-
- if (arg[0] != '-') {
- // Not a flag.
- name->clear();
- parsed_value = true;
- *value = arg;
- } else if (arg[1] == '-') {
- // Two dashes: Multi-character name, with '=' separating name and
- // value.
- const char* equals_pos = strchr(arg, '=');
- if (equals_pos != NULL) {
+ bool parsed_value = false;
+
+ if (arg[0] != '-') {
+ // Not a flag.
+ name->clear();
+ parsed_value = true;
+ *value = arg;
+ } else if (arg[1] == '-') {
+ // Two dashes: Multi-character name, with '=' separating name and
+ // value.
+ const char* equals_pos = strchr(arg, '=');
+ if (equals_pos != NULL) {
*name = TProtoStringType(arg, equals_pos - arg);
- *value = equals_pos + 1;
- parsed_value = true;
- } else {
- *name = arg;
- }
- } else {
- // One dash: One-character name, all subsequent characters are the
- // value.
- if (arg[1] == '\0') {
- // arg is just "-". We treat this as an input file, except that at
- // present this will just lead to a "file not found" error.
- name->clear();
- *value = arg;
- parsed_value = true;
- } else {
+ *value = equals_pos + 1;
+ parsed_value = true;
+ } else {
+ *name = arg;
+ }
+ } else {
+ // One dash: One-character name, all subsequent characters are the
+ // value.
+ if (arg[1] == '\0') {
+ // arg is just "-". We treat this as an input file, except that at
+ // present this will just lead to a "file not found" error.
+ name->clear();
+ *value = arg;
+ parsed_value = true;
+ } else {
*name = TProtoStringType(arg, 2);
- *value = arg + 2;
- parsed_value = !value->empty();
- }
- }
-
- // Need to return true iff the next arg should be used as the value for this
- // one, false otherwise.
-
- if (parsed_value) {
- // We already parsed a value for this flag.
- return false;
- }
-
+ *value = arg + 2;
+ parsed_value = !value->empty();
+ }
+ }
+
+ // Need to return true iff the next arg should be used as the value for this
+ // one, false otherwise.
+
+ if (parsed_value) {
+ // We already parsed a value for this flag.
+ return false;
+ }
+
if (*name == "-h" || *name == "--help" || *name == "--disallow_services" ||
*name == "--include_imports" || *name == "--include_source_info" ||
*name == "--version" || *name == "--decode_raw" ||
*name == "--print_free_field_numbers" ||
*name == "--experimental_allow_proto3_optional" ||
*name == "--deterministic_output" || *name == "--fatal_warnings") {
- // HACK: These are the only flags that don't take a value.
- // They probably should not be hard-coded like this but for now it's
- // not worth doing better.
- return false;
- }
-
- // Next argument is the flag value.
- return true;
-}
-
-CommandLineInterface::ParseArgumentStatus
+ // HACK: These are the only flags that don't take a value.
+ // They probably should not be hard-coded like this but for now it's
+ // not worth doing better.
+ return false;
+ }
+
+ // Next argument is the flag value.
+ return true;
+}
+
+CommandLineInterface::ParseArgumentStatus
CommandLineInterface::InterpretArgument(const TProtoStringType& name,
const TProtoStringType& value) {
- if (name.empty()) {
- // Not a flag. Just a filename.
- if (value.empty()) {
- std::cerr
- << "You seem to have passed an empty string as one of the "
+ if (name.empty()) {
+ // Not a flag. Just a filename.
+ if (value.empty()) {
+ std::cerr
+ << "You seem to have passed an empty string as one of the "
"arguments to "
<< executable_name_
- << ". This is actually "
- "sort of hard to do. Congrats. Unfortunately it is not valid "
+ << ". This is actually "
+ "sort of hard to do. Congrats. Unfortunately it is not valid "
"input so the program is going to die now."
<< std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
+ return PARSE_ARGUMENT_FAIL;
+ }
+
#if defined(_WIN32)
// On Windows, the shell (typically cmd.exe) does not expand wildcards in
// file names (e.g. foo\*.proto), so we do it ourselves.
@@ -1700,57 +1700,57 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
#else // not _WIN32
// On other platforms than Windows (e.g. Linux, Mac OS) the shell (typically
// Bash) expands wildcards.
- input_files_.push_back(value);
+ input_files_.push_back(value);
#endif // _WIN32
-
- } else if (name == "-I" || name == "--proto_path") {
- // Java's -classpath (and some other languages) delimits path components
- // with colons. Let's accept that syntax too just to make things more
- // intuitive.
+
+ } else if (name == "-I" || name == "--proto_path") {
+ // Java's -classpath (and some other languages) delimits path components
+ // with colons. Let's accept that syntax too just to make things more
+ // intuitive.
std::vector<TProtoStringType> parts = Split(
value, CommandLineInterface::kPathSeparator,
true);
-
- for (int i = 0; i < parts.size(); i++) {
+
+ for (int i = 0; i < parts.size(); i++) {
TProtoStringType virtual_path;
TProtoStringType disk_path;
-
+
TProtoStringType::size_type equals_pos = parts[i].find_first_of('=');
if (equals_pos == TProtoStringType::npos) {
- virtual_path = "";
- disk_path = parts[i];
- } else {
- virtual_path = parts[i].substr(0, equals_pos);
- disk_path = parts[i].substr(equals_pos + 1);
- }
-
- if (disk_path.empty()) {
- std::cerr
- << "--proto_path passed empty directory name. (Use \".\" for "
+ virtual_path = "";
+ disk_path = parts[i];
+ } else {
+ virtual_path = parts[i].substr(0, equals_pos);
+ disk_path = parts[i].substr(equals_pos + 1);
+ }
+
+ if (disk_path.empty()) {
+ std::cerr
+ << "--proto_path passed empty directory name. (Use \".\" for "
"current directory.)"
<< std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
- // Make sure disk path exists, warn otherwise.
- if (access(disk_path.c_str(), F_OK) < 0) {
+ return PARSE_ARGUMENT_FAIL;
+ }
+
+ // Make sure disk path exists, warn otherwise.
+ if (access(disk_path.c_str(), F_OK) < 0) {
// Try the original path; it may have just happened to have a '=' in it.
- if (access(parts[i].c_str(), F_OK) < 0) {
+ if (access(parts[i].c_str(), F_OK) < 0) {
std::cerr << disk_path << ": warning: directory does not exist."
<< std::endl;
- } else {
- virtual_path = "";
- disk_path = parts[i];
- }
- }
-
- // Don't use make_pair as the old/default standard library on Solaris
- // doesn't support it without explicit template parameters, which are
- // incompatible with C++0x's make_pair.
+ } else {
+ virtual_path = "";
+ disk_path = parts[i];
+ }
+ }
+
+ // Don't use make_pair as the old/default standard library on Solaris
+ // doesn't support it without explicit template parameters, which are
+ // incompatible with C++0x's make_pair.
proto_path_.push_back(
std::pair<TProtoStringType, TProtoStringType>(virtual_path, disk_path));
- }
-
+ }
+
} else if (name == "--direct_dependencies") {
if (direct_dependencies_explicitly_set_) {
std::cerr << name
@@ -1793,102 +1793,102 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
value, CommandLineInterface::kPathSeparator,
true);
- } else if (name == "-o" || name == "--descriptor_set_out") {
+ } else if (name == "-o" || name == "--descriptor_set_out") {
if (!descriptor_set_out_name_.empty()) {
- std::cerr << name << " may only be passed once." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (value.empty()) {
- std::cerr << name << " requires a non-empty value." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (mode_ != MODE_COMPILE) {
- std::cerr
- << "Cannot use --encode or --decode and generate descriptors at the "
+ std::cerr << name << " may only be passed once." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (value.empty()) {
+ std::cerr << name << " requires a non-empty value." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (mode_ != MODE_COMPILE) {
+ std::cerr
+ << "Cannot use --encode or --decode and generate descriptors at the "
"same time."
<< std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+ return PARSE_ARGUMENT_FAIL;
+ }
descriptor_set_out_name_ = value;
-
- } else if (name == "--dependency_out") {
- if (!dependency_out_name_.empty()) {
- std::cerr << name << " may only be passed once." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- if (value.empty()) {
- std::cerr << name << " requires a non-empty value." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+
+ } else if (name == "--dependency_out") {
+ if (!dependency_out_name_.empty()) {
+ std::cerr << name << " may only be passed once." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ if (value.empty()) {
+ std::cerr << name << " requires a non-empty value." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
if (!descriptor_set_in_names_.empty()) {
std::cerr << name << " cannot be used with --descriptor_set_in."
<< std::endl;
return PARSE_ARGUMENT_FAIL;
}
- dependency_out_name_ = value;
-
- } else if (name == "--include_imports") {
- if (imports_in_descriptor_set_) {
- std::cerr << name << " may only be passed once." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- imports_in_descriptor_set_ = true;
-
- } else if (name == "--include_source_info") {
- if (source_info_in_descriptor_set_) {
- std::cerr << name << " may only be passed once." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- source_info_in_descriptor_set_ = true;
-
- } else if (name == "-h" || name == "--help") {
- PrintHelpText();
- return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
-
- } else if (name == "--version") {
- if (!version_info_.empty()) {
- std::cout << version_info_ << std::endl;
- }
+ dependency_out_name_ = value;
+
+ } else if (name == "--include_imports") {
+ if (imports_in_descriptor_set_) {
+ std::cerr << name << " may only be passed once." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ imports_in_descriptor_set_ = true;
+
+ } else if (name == "--include_source_info") {
+ if (source_info_in_descriptor_set_) {
+ std::cerr << name << " may only be passed once." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ source_info_in_descriptor_set_ = true;
+
+ } else if (name == "-h" || name == "--help") {
+ PrintHelpText();
+ return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
+
+ } else if (name == "--version") {
+ if (!version_info_.empty()) {
+ std::cout << version_info_ << std::endl;
+ }
std::cout << "libprotoc " << internal::VersionString(PROTOBUF_VERSION)
<< PROTOBUF_VERSION_SUFFIX << std::endl;
- return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
-
- } else if (name == "--disallow_services") {
- disallow_services_ = true;
-
+ return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler.
+
+ } else if (name == "--disallow_services") {
+ disallow_services_ = true;
+
} else if (name == "--experimental_allow_proto3_optional") {
// Flag is no longer observed, but we allow it for backward compat.
- } else if (name == "--encode" || name == "--decode" ||
- name == "--decode_raw") {
- if (mode_ != MODE_COMPILE) {
- std::cerr << "Only one of --encode and --decode can be specified."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+ } else if (name == "--encode" || name == "--decode" ||
+ name == "--decode_raw") {
+ if (mode_ != MODE_COMPILE) {
+ std::cerr << "Only one of --encode and --decode can be specified."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) {
- std::cerr << "Cannot use " << name
- << " and generate code or descriptors at the same time."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
- mode_ = (name == "--encode") ? MODE_ENCODE : MODE_DECODE;
-
- if (value.empty() && name != "--decode_raw") {
- std::cerr << "Type name for " << name << " cannot be blank." << std::endl;
- if (name == "--decode") {
- std::cerr << "To decode an unknown message, use --decode_raw."
- << std::endl;
- }
- return PARSE_ARGUMENT_FAIL;
- } else if (!value.empty() && name == "--decode_raw") {
- std::cerr << "--decode_raw does not take a parameter." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
- codec_type_ = value;
-
+ std::cerr << "Cannot use " << name
+ << " and generate code or descriptors at the same time."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+
+ mode_ = (name == "--encode") ? MODE_ENCODE : MODE_DECODE;
+
+ if (value.empty() && name != "--decode_raw") {
+ std::cerr << "Type name for " << name << " cannot be blank." << std::endl;
+ if (name == "--decode") {
+ std::cerr << "To decode an unknown message, use --decode_raw."
+ << std::endl;
+ }
+ return PARSE_ARGUMENT_FAIL;
+ } else if (!value.empty() && name == "--decode_raw") {
+ std::cerr << "--decode_raw does not take a parameter." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+
+ codec_type_ = value;
+
} else if (name == "--encode-decode-input") {
if (!encode_decode_input_.empty()) {
std::cerr << name << " may only be passed once." << std::endl;
@@ -1921,78 +1921,78 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
} else if (name == "--deterministic_output") {
deterministic_output_ = true;
- } else if (name == "--error_format") {
- if (value == "gcc") {
- error_format_ = ERROR_FORMAT_GCC;
- } else if (value == "msvs") {
- error_format_ = ERROR_FORMAT_MSVS;
- } else {
- std::cerr << "Unknown error format: " << value << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
+ } else if (name == "--error_format") {
+ if (value == "gcc") {
+ error_format_ = ERROR_FORMAT_GCC;
+ } else if (value == "msvs") {
+ error_format_ = ERROR_FORMAT_MSVS;
+ } else {
+ std::cerr << "Unknown error format: " << value << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+
} else if (name == "--fatal_warnings") {
if (fatal_warnings_) {
std::cerr << name << " may only be passed once." << std::endl;
return PARSE_ARGUMENT_FAIL;
}
fatal_warnings_ = true;
- } else if (name == "--plugin") {
- if (plugin_prefix_.empty()) {
- std::cerr << "This compiler does not support plugins." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
+ } else if (name == "--plugin") {
+ if (plugin_prefix_.empty()) {
+ std::cerr << "This compiler does not support plugins." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+
TProtoStringType plugin_name;
TProtoStringType path;
-
+
TProtoStringType::size_type equals_pos = value.find_first_of('=');
if (equals_pos == TProtoStringType::npos) {
- // Use the basename of the file.
+ // Use the basename of the file.
TProtoStringType::size_type slash_pos = value.find_last_of('/');
if (slash_pos == TProtoStringType::npos) {
- plugin_name = value;
- } else {
- plugin_name = value.substr(slash_pos + 1);
- }
- path = value;
- } else {
- plugin_name = value.substr(0, equals_pos);
- path = value.substr(equals_pos + 1);
- }
-
- plugins_[plugin_name] = path;
-
- } else if (name == "--print_free_field_numbers") {
- if (mode_ != MODE_COMPILE) {
- std::cerr << "Cannot use " << name
- << " and use --encode, --decode or print "
- << "other info at the same time." << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
+ plugin_name = value;
+ } else {
+ plugin_name = value.substr(slash_pos + 1);
+ }
+ path = value;
+ } else {
+ plugin_name = value.substr(0, equals_pos);
+ path = value.substr(equals_pos + 1);
+ }
+
+ plugins_[plugin_name] = path;
+
+ } else if (name == "--print_free_field_numbers") {
+ if (mode_ != MODE_COMPILE) {
+ std::cerr << "Cannot use " << name
+ << " and use --encode, --decode or print "
+ << "other info at the same time." << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) {
- std::cerr << "Cannot use " << name
- << " and generate code or descriptors at the same time."
- << std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
- mode_ = MODE_PRINT;
- print_mode_ = PRINT_FREE_FIELDS;
- } else {
- // Some other flag. Look it up in the generators list.
- const GeneratorInfo* generator_info =
- FindOrNull(generators_by_flag_name_, name);
- if (generator_info == NULL &&
- (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) {
- // Check if it's a generator option flag.
- generator_info = FindOrNull(generators_by_option_name_, name);
+ std::cerr << "Cannot use " << name
+ << " and generate code or descriptors at the same time."
+ << std::endl;
+ return PARSE_ARGUMENT_FAIL;
+ }
+ mode_ = MODE_PRINT;
+ print_mode_ = PRINT_FREE_FIELDS;
+ } else {
+ // Some other flag. Look it up in the generators list.
+ const GeneratorInfo* generator_info =
+ FindOrNull(generators_by_flag_name_, name);
+ if (generator_info == NULL &&
+ (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) {
+ // Check if it's a generator option flag.
+ generator_info = FindOrNull(generators_by_option_name_, name);
if (generator_info != NULL) {
TProtoStringType* parameters =
&generator_parameters_[generator_info->flag_name];
- if (!parameters->empty()) {
- parameters->append(",");
- }
- parameters->append(value);
+ if (!parameters->empty()) {
+ parameters->append(",");
+ }
+ parameters->append(value);
} else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) {
TProtoStringType* parameters =
&plugin_parameters_[PluginName(plugin_prefix_, name)];
@@ -2003,44 +2003,44 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name,
} else {
std::cerr << "Unknown flag: " << name << std::endl;
return PARSE_ARGUMENT_FAIL;
- }
- } else {
- // It's an output flag. Add it to the output directives.
- if (mode_ != MODE_COMPILE) {
- std::cerr << "Cannot use --encode, --decode or print .proto info and "
+ }
+ } else {
+ // It's an output flag. Add it to the output directives.
+ if (mode_ != MODE_COMPILE) {
+ std::cerr << "Cannot use --encode, --decode or print .proto info and "
"generate code at the same time."
<< std::endl;
- return PARSE_ARGUMENT_FAIL;
- }
-
- OutputDirective directive;
- directive.name = name;
- if (generator_info == NULL) {
- directive.generator = NULL;
- } else {
- directive.generator = generator_info->generator;
- }
-
- // Split value at ':' to separate the generator parameter from the
- // filename. However, avoid doing this if the colon is part of a valid
- // Windows-style absolute path.
+ return PARSE_ARGUMENT_FAIL;
+ }
+
+ OutputDirective directive;
+ directive.name = name;
+ if (generator_info == NULL) {
+ directive.generator = NULL;
+ } else {
+ directive.generator = generator_info->generator;
+ }
+
+ // Split value at ':' to separate the generator parameter from the
+ // filename. However, avoid doing this if the colon is part of a valid
+ // Windows-style absolute path.
TProtoStringType::size_type colon_pos = value.find_first_of(':');
if (colon_pos == TProtoStringType::npos || IsWindowsAbsolutePath(value)) {
- directive.output_location = value;
- } else {
- directive.parameter = value.substr(0, colon_pos);
- directive.output_location = value.substr(colon_pos + 1);
- }
-
- output_directives_.push_back(directive);
- }
- }
-
- return PARSE_ARGUMENT_DONE_AND_CONTINUE;
-}
-
-void CommandLineInterface::PrintHelpText() {
- // Sorry for indentation here; line wrapping would be uglier.
+ directive.output_location = value;
+ } else {
+ directive.parameter = value.substr(0, colon_pos);
+ directive.output_location = value.substr(colon_pos + 1);
+ }
+
+ output_directives_.push_back(directive);
+ }
+ }
+
+ return PARSE_ARGUMENT_DONE_AND_CONTINUE;
+}
+
+void CommandLineInterface::PrintHelpText() {
+ // Sorry for indentation here; line wrapping would be uglier.
std::cout << "Usage: " << executable_name_ << " [OPTION] PROTO_FILES";
std::cout << R"(
Parse PROTO_FILES and generate output based on the options given:
@@ -2109,7 +2109,7 @@ Parse PROTO_FILES and generate output based on the options given:
the same field number space with the parent
message. Extension ranges are counted as
occupied fields numbers.)";
- if (!plugin_prefix_.empty()) {
+ if (!plugin_prefix_.empty()) {
std::cout << R"(
--plugin=EXECUTABLE Specifies a plugin executable to use.
Normally, protoc searches the PATH for
@@ -2119,19 +2119,19 @@ Parse PROTO_FILES and generate output based on the options given:
NAME=PATH, in which case the given plugin name
is mapped to the given executable even if
the executable's own name differs.)";
- }
-
- for (GeneratorMap::iterator iter = generators_by_flag_name_.begin();
- iter != generators_by_flag_name_.end(); ++iter) {
- // FIXME(kenton): If the text is long enough it will wrap, which is ugly,
- // but fixing this nicely (e.g. splitting on spaces) is probably more
- // trouble than it's worth.
+ }
+
+ for (GeneratorMap::iterator iter = generators_by_flag_name_.begin();
+ iter != generators_by_flag_name_.end(); ++iter) {
+ // FIXME(kenton): If the text is long enough it will wrap, which is ugly,
+ // but fixing this nicely (e.g. splitting on spaces) is probably more
+ // trouble than it's worth.
std::cout << std::endl
<< " " << iter->first << "=OUT_DIR "
<< TProtoStringType(19 - iter->first.size(),
' ') // Spaces for alignment.
<< iter->second.help_text;
- }
+ }
std::cout << R"(
@<filename> Read options and filenames from file. If a
relative file path is specified, the file
@@ -2146,8 +2146,8 @@ Parse PROTO_FILES and generate output based on the options given:
Each line corresponds to a single argument,
even if it contains spaces.)";
std::cout << std::endl;
-}
-
+}
+
bool CommandLineInterface::EnforceProto3OptionalSupport(
const TProtoStringType& codegen_name, uint64_t supported_features,
const std::vector<const FileDescriptor*>& parsed_files) const {
@@ -2170,18 +2170,18 @@ bool CommandLineInterface::EnforceProto3OptionalSupport(
return true;
}
-bool CommandLineInterface::GenerateOutput(
+bool CommandLineInterface::GenerateOutput(
const std::vector<const FileDescriptor*>& parsed_files,
- const OutputDirective& output_directive,
- GeneratorContext* generator_context) {
- // Call the generator.
+ const OutputDirective& output_directive,
+ GeneratorContext* generator_context) {
+ // Call the generator.
TProtoStringType error;
- if (output_directive.generator == NULL) {
- // This is a plugin.
- GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") &&
- HasSuffixString(output_directive.name, "_out"))
- << "Bad name for plugin generator: " << output_directive.name;
-
+ if (output_directive.generator == NULL) {
+ // This is a plugin.
+ GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") &&
+ HasSuffixString(output_directive.name, "_out"))
+ << "Bad name for plugin generator: " << output_directive.name;
+
TProtoStringType plugin_name = PluginName(plugin_prefix_, output_directive.name);
TProtoStringType parameters = output_directive.parameter;
if (!plugin_parameters_[plugin_name].empty()) {
@@ -2191,19 +2191,19 @@ bool CommandLineInterface::GenerateOutput(
parameters.append(plugin_parameters_[plugin_name]);
}
if (!GeneratePluginOutput(parsed_files, plugin_name, parameters,
- generator_context, &error)) {
- std::cerr << output_directive.name << ": " << error << std::endl;
- return false;
- }
- } else {
- // Regular generator.
+ generator_context, &error)) {
+ std::cerr << output_directive.name << ": " << error << std::endl;
+ return false;
+ }
+ } else {
+ // Regular generator.
TProtoStringType parameters = output_directive.parameter;
- if (!generator_parameters_[output_directive.name].empty()) {
- if (!parameters.empty()) {
- parameters.append(",");
- }
- parameters.append(generator_parameters_[output_directive.name]);
- }
+ if (!generator_parameters_[output_directive.name].empty()) {
+ if (!parameters.empty()) {
+ parameters.append(",");
+ }
+ parameters.append(generator_parameters_[output_directive.name]);
+ }
if (!EnforceProto3OptionalSupport(
output_directive.name,
output_directive.generator->GetSupportedFeatures(), parsed_files)) {
@@ -2215,104 +2215,104 @@ bool CommandLineInterface::GenerateOutput(
// Generator returned an error.
std::cerr << output_directive.name << ": " << error << std::endl;
return false;
- }
- }
-
- return true;
-}
-
-bool CommandLineInterface::GenerateDependencyManifestFile(
+ }
+ }
+
+ return true;
+}
+
+bool CommandLineInterface::GenerateDependencyManifestFile(
const std::vector<const FileDescriptor*>& parsed_files,
- const GeneratorContextMap& output_directories,
- DiskSourceTree* source_tree) {
- FileDescriptorSet file_set;
-
+ const GeneratorContextMap& output_directories,
+ DiskSourceTree* source_tree) {
+ FileDescriptorSet file_set;
+
std::set<const FileDescriptor*> already_seen;
- for (int i = 0; i < parsed_files.size(); i++) {
+ for (int i = 0; i < parsed_files.size(); i++) {
GetTransitiveDependencies(parsed_files[i], false, false, &already_seen,
- file_set.mutable_file());
- }
-
+ file_set.mutable_file());
+ }
+
std::vector<TProtoStringType> output_filenames;
for (const auto& pair : output_directories) {
const TProtoStringType& location = pair.first;
GeneratorContextImpl* directory = pair.second.get();
std::vector<TProtoStringType> relative_output_filenames;
- directory->GetOutputFilenames(&relative_output_filenames);
- for (int i = 0; i < relative_output_filenames.size(); i++) {
+ directory->GetOutputFilenames(&relative_output_filenames);
+ for (int i = 0; i < relative_output_filenames.size(); i++) {
TProtoStringType output_filename = location + relative_output_filenames[i];
- if (output_filename.compare(0, 2, "./") == 0) {
- output_filename = output_filename.substr(2);
- }
- output_filenames.push_back(output_filename);
- }
- }
-
- int fd;
- do {
- fd = open(dependency_out_name_.c_str(),
- O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- } while (fd < 0 && errno == EINTR);
-
- if (fd < 0) {
- perror(dependency_out_name_.c_str());
- return false;
- }
-
- io::FileOutputStream out(fd);
- io::Printer printer(&out, '$');
-
- for (int i = 0; i < output_filenames.size(); i++) {
- printer.Print(output_filenames[i].c_str());
- if (i == output_filenames.size() - 1) {
- printer.Print(":");
- } else {
- printer.Print(" \\\n");
- }
- }
-
- for (int i = 0; i < file_set.file_size(); i++) {
- const FileDescriptorProto& file = file_set.file(i);
+ if (output_filename.compare(0, 2, "./") == 0) {
+ output_filename = output_filename.substr(2);
+ }
+ output_filenames.push_back(output_filename);
+ }
+ }
+
+ int fd;
+ do {
+ fd = open(dependency_out_name_.c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ } while (fd < 0 && errno == EINTR);
+
+ if (fd < 0) {
+ perror(dependency_out_name_.c_str());
+ return false;
+ }
+
+ io::FileOutputStream out(fd);
+ io::Printer printer(&out, '$');
+
+ for (int i = 0; i < output_filenames.size(); i++) {
+ printer.Print(output_filenames[i].c_str());
+ if (i == output_filenames.size() - 1) {
+ printer.Print(":");
+ } else {
+ printer.Print(" \\\n");
+ }
+ }
+
+ for (int i = 0; i < file_set.file_size(); i++) {
+ const FileDescriptorProto& file = file_set.file(i);
const TProtoStringType& virtual_file = file.name();
TProtoStringType disk_file;
- if (source_tree &&
- source_tree->VirtualFileToDiskFile(virtual_file, &disk_file)) {
- printer.Print(" $disk_file$", "disk_file", disk_file);
- if (i < file_set.file_size() - 1) printer.Print("\\\n");
- } else {
- std::cerr << "Unable to identify path for file " << virtual_file
- << std::endl;
- return false;
- }
- }
-
- return true;
-}
-
-bool CommandLineInterface::GeneratePluginOutput(
+ if (source_tree &&
+ source_tree->VirtualFileToDiskFile(virtual_file, &disk_file)) {
+ printer.Print(" $disk_file$", "disk_file", disk_file);
+ if (i < file_set.file_size() - 1) printer.Print("\\\n");
+ } else {
+ std::cerr << "Unable to identify path for file " << virtual_file
+ << std::endl;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool CommandLineInterface::GeneratePluginOutput(
const std::vector<const FileDescriptor*>& parsed_files,
const TProtoStringType& plugin_name, const TProtoStringType& parameter,
GeneratorContext* generator_context, TProtoStringType* error) {
- CodeGeneratorRequest request;
- CodeGeneratorResponse response;
+ CodeGeneratorRequest request;
+ CodeGeneratorResponse response;
TProtoStringType processed_parameter = parameter;
-
- // Build the request.
+
+ // Build the request.
if (!processed_parameter.empty()) {
request.set_parameter(processed_parameter);
- }
-
+ }
+
std::set<const FileDescriptor*> already_seen;
- for (int i = 0; i < parsed_files.size(); i++) {
- request.add_file_to_generate(parsed_files[i]->name());
- GetTransitiveDependencies(parsed_files[i],
- true, // Include json_name for plugins.
- true, // Include source code info.
- &already_seen, request.mutable_proto_file());
- }
-
+ for (int i = 0; i < parsed_files.size(); i++) {
+ request.add_file_to_generate(parsed_files[i]->name());
+ GetTransitiveDependencies(parsed_files[i],
+ true, // Include json_name for plugins.
+ true, // Include source code info.
+ &already_seen, request.mutable_proto_file());
+ }
+
google::protobuf::compiler::Version* version =
request.mutable_compiler_version();
version->set_major(PROTOBUF_VERSION / 1000000);
@@ -2320,81 +2320,81 @@ bool CommandLineInterface::GeneratePluginOutput(
version->set_patch(PROTOBUF_VERSION % 1000);
version->set_suffix(PROTOBUF_VERSION_SUFFIX);
- // Invoke the plugin.
- Subprocess subprocess;
-
- if (plugins_.count(plugin_name) > 0) {
- subprocess.Start(plugins_[plugin_name], Subprocess::EXACT_NAME);
- } else {
- subprocess.Start(plugin_name, Subprocess::SEARCH_PATH);
- }
-
+ // Invoke the plugin.
+ Subprocess subprocess;
+
+ if (plugins_.count(plugin_name) > 0) {
+ subprocess.Start(plugins_[plugin_name], Subprocess::EXACT_NAME);
+ } else {
+ subprocess.Start(plugin_name, Subprocess::SEARCH_PATH);
+ }
+
TProtoStringType communicate_error;
- if (!subprocess.Communicate(request, &response, &communicate_error)) {
- *error = strings::Substitute("$0: $1", plugin_name, communicate_error);
- return false;
- }
-
- // Write the files. We do this even if there was a generator error in order
- // to match the behavior of a compiled-in generator.
+ if (!subprocess.Communicate(request, &response, &communicate_error)) {
+ *error = strings::Substitute("$0: $1", plugin_name, communicate_error);
+ return false;
+ }
+
+ // Write the files. We do this even if there was a generator error in order
+ // to match the behavior of a compiled-in generator.
std::unique_ptr<io::ZeroCopyOutputStream> current_output;
- for (int i = 0; i < response.file_size(); i++) {
- const CodeGeneratorResponse::File& output_file = response.file(i);
-
- if (!output_file.insertion_point().empty()) {
+ for (int i = 0; i < response.file_size(); i++) {
+ const CodeGeneratorResponse::File& output_file = response.file(i);
+
+ if (!output_file.insertion_point().empty()) {
TProtoStringType filename = output_file.name();
- // Open a file for insert.
- // We reset current_output to NULL first so that the old file is closed
- // before the new one is opened.
- current_output.reset();
+ // Open a file for insert.
+ // We reset current_output to NULL first so that the old file is closed
+ // before the new one is opened.
+ current_output.reset();
current_output.reset(
generator_context->OpenForInsertWithGeneratedCodeInfo(
filename, output_file.insertion_point(),
output_file.generated_code_info()));
- } else if (!output_file.name().empty()) {
- // Starting a new file. Open it.
- // We reset current_output to NULL first so that the old file is closed
- // before the new one is opened.
- current_output.reset();
- current_output.reset(generator_context->Open(output_file.name()));
- } else if (current_output == NULL) {
- *error = strings::Substitute(
+ } else if (!output_file.name().empty()) {
+ // Starting a new file. Open it.
+ // We reset current_output to NULL first so that the old file is closed
+ // before the new one is opened.
+ current_output.reset();
+ current_output.reset(generator_context->Open(output_file.name()));
+ } else if (current_output == NULL) {
+ *error = strings::Substitute(
"$0: First file chunk returned by plugin did not specify a file "
"name.",
plugin_name);
- return false;
- }
-
- // Use CodedOutputStream for convenience; otherwise we'd need to provide
- // our own buffer-copying loop.
- io::CodedOutputStream writer(current_output.get());
- writer.WriteString(output_file.content());
- }
-
- // Check for errors.
- if (!response.error().empty()) {
- // Generator returned an error.
- *error = response.error();
- return false;
+ return false;
+ }
+
+ // Use CodedOutputStream for convenience; otherwise we'd need to provide
+ // our own buffer-copying loop.
+ io::CodedOutputStream writer(current_output.get());
+ writer.WriteString(output_file.content());
+ }
+
+ // Check for errors.
+ if (!response.error().empty()) {
+ // Generator returned an error.
+ *error = response.error();
+ return false;
} else if (!EnforceProto3OptionalSupport(
plugin_name, response.supported_features(), parsed_files)) {
return false;
- }
-
- return true;
-}
-
-bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
- // Look up the type.
- const Descriptor* type = pool->FindMessageTypeByName(codec_type_);
- if (type == NULL) {
- std::cerr << "Type not defined: " << codec_type_ << std::endl;
- return false;
- }
-
- DynamicMessageFactory dynamic_factory(pool);
+ }
+
+ return true;
+}
+
+bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
+ // Look up the type.
+ const Descriptor* type = pool->FindMessageTypeByName(codec_type_);
+ if (type == NULL) {
+ std::cerr << "Type not defined: " << codec_type_ << std::endl;
+ return false;
+ }
+
+ DynamicMessageFactory dynamic_factory(pool);
std::unique_ptr<Message> message(dynamic_factory.GetPrototype(type)->New());
-
+
int in_fd = STDIN_FILENO;
if (!encode_decode_input_.empty()) {
do {
@@ -2419,64 +2419,64 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
}
}
- if (mode_ == MODE_ENCODE) {
+ if (mode_ == MODE_ENCODE) {
SetFdToTextMode(in_fd);
SetFdToBinaryMode(out_fd);
- } else {
+ } else {
SetFdToBinaryMode(in_fd);
SetFdToTextMode(out_fd);
- }
-
+ }
+
io::FileInputStream in(in_fd);
io::FileOutputStream out(out_fd);
-
- if (mode_ == MODE_ENCODE) {
- // Input is text.
- ErrorPrinter error_collector(error_format_);
- TextFormat::Parser parser;
- parser.RecordErrorsTo(&error_collector);
- parser.AllowPartialMessage(true);
-
- if (!parser.Parse(&in, message.get())) {
- std::cerr << "Failed to parse input." << std::endl;
- return false;
- }
- } else {
- // Input is binary.
- if (!message->ParsePartialFromZeroCopyStream(&in)) {
- std::cerr << "Failed to parse input." << std::endl;
- return false;
- }
- }
-
- if (!message->IsInitialized()) {
- std::cerr << "warning: Input message is missing required fields: "
- << message->InitializationErrorString() << std::endl;
- }
-
- if (mode_ == MODE_ENCODE) {
- // Output is binary.
+
+ if (mode_ == MODE_ENCODE) {
+ // Input is text.
+ ErrorPrinter error_collector(error_format_);
+ TextFormat::Parser parser;
+ parser.RecordErrorsTo(&error_collector);
+ parser.AllowPartialMessage(true);
+
+ if (!parser.Parse(&in, message.get())) {
+ std::cerr << "Failed to parse input." << std::endl;
+ return false;
+ }
+ } else {
+ // Input is binary.
+ if (!message->ParsePartialFromZeroCopyStream(&in)) {
+ std::cerr << "Failed to parse input." << std::endl;
+ return false;
+ }
+ }
+
+ if (!message->IsInitialized()) {
+ std::cerr << "warning: Input message is missing required fields: "
+ << message->InitializationErrorString() << std::endl;
+ }
+
+ if (mode_ == MODE_ENCODE) {
+ // Output is binary.
io::CodedOutputStream coded_out(&out);
coded_out.SetSerializationDeterministic(deterministic_output_);
if (!message->SerializePartialToCodedStream(&coded_out)) {
- std::cerr << "output: I/O error." << std::endl;
- return false;
- }
- } else {
- // Output is text.
- if (!TextFormat::Print(*message, &out)) {
- std::cerr << "output: I/O error." << std::endl;
- return false;
- }
- }
-
- return true;
-}
-
-bool CommandLineInterface::WriteDescriptorSet(
+ std::cerr << "output: I/O error." << std::endl;
+ return false;
+ }
+ } else {
+ // Output is text.
+ if (!TextFormat::Print(*message, &out)) {
+ std::cerr << "output: I/O error." << std::endl;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool CommandLineInterface::WriteDescriptorSet(
const std::vector<const FileDescriptor*>& parsed_files) {
- FileDescriptorSet file_set;
-
+ FileDescriptorSet file_set;
+
std::set<const FileDescriptor*> already_seen;
if (!imports_in_descriptor_set_) {
// Since we don't want to output transitive dependencies, but we do want
@@ -2485,7 +2485,7 @@ bool CommandLineInterface::WriteDescriptorSet(
// in GetTransitiveDependencies.
std::set<const FileDescriptor*> to_output;
to_output.insert(parsed_files.begin(), parsed_files.end());
- for (int i = 0; i < parsed_files.size(); i++) {
+ for (int i = 0; i < parsed_files.size(); i++) {
const FileDescriptor* file = parsed_files[i];
for (int i = 0; i < file->dependency_count(); i++) {
const FileDescriptor* dependency = file->dependency(i);
@@ -2493,28 +2493,28 @@ bool CommandLineInterface::WriteDescriptorSet(
if (to_output.find(dependency) == to_output.end()) {
already_seen.insert(dependency);
}
- }
- }
- }
+ }
+ }
+ }
for (int i = 0; i < parsed_files.size(); i++) {
GetTransitiveDependencies(parsed_files[i],
true, // Include json_name
source_info_in_descriptor_set_, &already_seen,
file_set.mutable_file());
}
-
- int fd;
- do {
+
+ int fd;
+ do {
fd = open(descriptor_set_out_name_.c_str(),
- O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- } while (fd < 0 && errno == EINTR);
-
- if (fd < 0) {
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ } while (fd < 0 && errno == EINTR);
+
+ if (fd < 0) {
perror(descriptor_set_out_name_.c_str());
- return false;
- }
-
- io::FileOutputStream out(fd);
+ return false;
+ }
+
+ io::FileOutputStream out(fd);
{
io::CodedOutputStream coded_out(&out);
@@ -2527,154 +2527,154 @@ bool CommandLineInterface::WriteDescriptorSet(
out.Close();
return false;
}
- }
+ }
- if (!out.Close()) {
+ if (!out.Close()) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
- << std::endl;
- return false;
- }
-
- return true;
-}
-
-void CommandLineInterface::GetTransitiveDependencies(
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+void CommandLineInterface::GetTransitiveDependencies(
const FileDescriptor* file, bool include_json_name,
- bool include_source_code_info,
+ bool include_source_code_info,
std::set<const FileDescriptor*>* already_seen,
- RepeatedPtrField<FileDescriptorProto>* output) {
- if (!already_seen->insert(file).second) {
- // Already saw this file. Skip.
- return;
- }
-
- // Add all dependencies.
- for (int i = 0; i < file->dependency_count(); i++) {
+ RepeatedPtrField<FileDescriptorProto>* output) {
+ if (!already_seen->insert(file).second) {
+ // Already saw this file. Skip.
+ return;
+ }
+
+ // Add all dependencies.
+ for (int i = 0; i < file->dependency_count(); i++) {
GetTransitiveDependencies(file->dependency(i), include_json_name,
include_source_code_info, already_seen, output);
- }
-
- // Add this file.
- FileDescriptorProto* new_descriptor = output->Add();
- file->CopyTo(new_descriptor);
- if (include_json_name) {
- file->CopyJsonNameTo(new_descriptor);
- }
- if (include_source_code_info) {
- file->CopySourceCodeInfoTo(new_descriptor);
- }
-}
-
-namespace {
-
-// Utility function for PrintFreeFieldNumbers.
-// Stores occupied ranges into the ranges parameter, and next level of sub
-// message types into the nested_messages parameter. The FieldRange is left
-// inclusive, right exclusive. i.e. [a, b).
-//
-// Nested Messages:
-// Note that it only stores the nested message type, iff the nested type is
-// either a direct child of the given descriptor, or the nested type is a
+ }
+
+ // Add this file.
+ FileDescriptorProto* new_descriptor = output->Add();
+ file->CopyTo(new_descriptor);
+ if (include_json_name) {
+ file->CopyJsonNameTo(new_descriptor);
+ }
+ if (include_source_code_info) {
+ file->CopySourceCodeInfoTo(new_descriptor);
+ }
+}
+
+namespace {
+
+// Utility function for PrintFreeFieldNumbers.
+// Stores occupied ranges into the ranges parameter, and next level of sub
+// message types into the nested_messages parameter. The FieldRange is left
+// inclusive, right exclusive. i.e. [a, b).
+//
+// Nested Messages:
+// Note that it only stores the nested message type, iff the nested type is
+// either a direct child of the given descriptor, or the nested type is a
// descendant of the given descriptor and all the nodes between the
-// nested type and the given descriptor are group types. e.g.
-//
-// message Foo {
-// message Bar {
-// message NestedBar {}
-// }
-// group Baz = 1 {
-// group NestedBazGroup = 2 {
-// message Quz {
-// message NestedQuz {}
-// }
-// }
-// message NestedBaz {}
-// }
-// }
-//
-// In this case, Bar, Quz and NestedBaz will be added into the nested types.
-// Since free field numbers of group types will not be printed, this makes sure
-// the nested message types in groups will not be dropped. The nested_messages
-// parameter will contain the direct children (when groups are ignored in the
-// tree) of the given descriptor for the caller to traverse. The declaration
-// order of the nested messages is also preserved.
+// nested type and the given descriptor are group types. e.g.
+//
+// message Foo {
+// message Bar {
+// message NestedBar {}
+// }
+// group Baz = 1 {
+// group NestedBazGroup = 2 {
+// message Quz {
+// message NestedQuz {}
+// }
+// }
+// message NestedBaz {}
+// }
+// }
+//
+// In this case, Bar, Quz and NestedBaz will be added into the nested types.
+// Since free field numbers of group types will not be printed, this makes sure
+// the nested message types in groups will not be dropped. The nested_messages
+// parameter will contain the direct children (when groups are ignored in the
+// tree) of the given descriptor for the caller to traverse. The declaration
+// order of the nested messages is also preserved.
typedef std::pair<int, int> FieldRange;
void GatherOccupiedFieldRanges(
const Descriptor* descriptor, std::set<FieldRange>* ranges,
std::vector<const Descriptor*>* nested_messages) {
std::set<const Descriptor*> groups;
- for (int i = 0; i < descriptor->field_count(); ++i) {
- const FieldDescriptor* fd = descriptor->field(i);
- ranges->insert(FieldRange(fd->number(), fd->number() + 1));
- if (fd->type() == FieldDescriptor::TYPE_GROUP) {
- groups.insert(fd->message_type());
- }
- }
- for (int i = 0; i < descriptor->extension_range_count(); ++i) {
- ranges->insert(FieldRange(descriptor->extension_range(i)->start,
- descriptor->extension_range(i)->end));
- }
- for (int i = 0; i < descriptor->reserved_range_count(); ++i) {
- ranges->insert(FieldRange(descriptor->reserved_range(i)->start,
- descriptor->reserved_range(i)->end));
- }
- // Handle the nested messages/groups in declaration order to make it
- // post-order strict.
- for (int i = 0; i < descriptor->nested_type_count(); ++i) {
- const Descriptor* nested_desc = descriptor->nested_type(i);
- if (groups.find(nested_desc) != groups.end()) {
- GatherOccupiedFieldRanges(nested_desc, ranges, nested_messages);
- } else {
- nested_messages->push_back(nested_desc);
- }
- }
-}
-
-// Utility function for PrintFreeFieldNumbers.
-// Actually prints the formatted free field numbers for given message name and
-// occupied ranges.
+ for (int i = 0; i < descriptor->field_count(); ++i) {
+ const FieldDescriptor* fd = descriptor->field(i);
+ ranges->insert(FieldRange(fd->number(), fd->number() + 1));
+ if (fd->type() == FieldDescriptor::TYPE_GROUP) {
+ groups.insert(fd->message_type());
+ }
+ }
+ for (int i = 0; i < descriptor->extension_range_count(); ++i) {
+ ranges->insert(FieldRange(descriptor->extension_range(i)->start,
+ descriptor->extension_range(i)->end));
+ }
+ for (int i = 0; i < descriptor->reserved_range_count(); ++i) {
+ ranges->insert(FieldRange(descriptor->reserved_range(i)->start,
+ descriptor->reserved_range(i)->end));
+ }
+ // Handle the nested messages/groups in declaration order to make it
+ // post-order strict.
+ for (int i = 0; i < descriptor->nested_type_count(); ++i) {
+ const Descriptor* nested_desc = descriptor->nested_type(i);
+ if (groups.find(nested_desc) != groups.end()) {
+ GatherOccupiedFieldRanges(nested_desc, ranges, nested_messages);
+ } else {
+ nested_messages->push_back(nested_desc);
+ }
+ }
+}
+
+// Utility function for PrintFreeFieldNumbers.
+// Actually prints the formatted free field numbers for given message name and
+// occupied ranges.
void FormatFreeFieldNumbers(const TProtoStringType& name,
const std::set<FieldRange>& ranges) {
TProtoStringType output;
- StringAppendF(&output, "%-35s free:", name.c_str());
- int next_free_number = 1;
+ StringAppendF(&output, "%-35s free:", name.c_str());
+ int next_free_number = 1;
for (std::set<FieldRange>::const_iterator i = ranges.begin();
- i != ranges.end(); ++i) {
- // This happens when groups re-use parent field numbers, in which
- // case we skip the FieldRange entirely.
- if (next_free_number >= i->second) continue;
-
- if (next_free_number < i->first) {
- if (next_free_number + 1 == i->first) {
- // Singleton
- StringAppendF(&output, " %d", next_free_number);
- } else {
- // Range
- StringAppendF(&output, " %d-%d", next_free_number, i->first - 1);
- }
- }
- next_free_number = i->second;
- }
- if (next_free_number <= FieldDescriptor::kMaxNumber) {
- StringAppendF(&output, " %d-INF", next_free_number);
- }
- std::cout << output << std::endl;
-}
-
-} // namespace
-
+ i != ranges.end(); ++i) {
+ // This happens when groups re-use parent field numbers, in which
+ // case we skip the FieldRange entirely.
+ if (next_free_number >= i->second) continue;
+
+ if (next_free_number < i->first) {
+ if (next_free_number + 1 == i->first) {
+ // Singleton
+ StringAppendF(&output, " %d", next_free_number);
+ } else {
+ // Range
+ StringAppendF(&output, " %d-%d", next_free_number, i->first - 1);
+ }
+ }
+ next_free_number = i->second;
+ }
+ if (next_free_number <= FieldDescriptor::kMaxNumber) {
+ StringAppendF(&output, " %d-INF", next_free_number);
+ }
+ std::cout << output << std::endl;
+}
+
+} // namespace
+
void CommandLineInterface::PrintFreeFieldNumbers(const Descriptor* descriptor) {
std::set<FieldRange> ranges;
std::vector<const Descriptor*> nested_messages;
- GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages);
-
- for (int i = 0; i < nested_messages.size(); ++i) {
- PrintFreeFieldNumbers(nested_messages[i]);
- }
- FormatFreeFieldNumbers(descriptor->full_name(), ranges);
-}
-
-
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages);
+
+ for (int i = 0; i < nested_messages.size(); ++i) {
+ PrintFreeFieldNumbers(nested_messages[i]);
+ }
+ FormatFreeFieldNumbers(descriptor->full_name(), ranges);
+}
+
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h
index 8574aedced..337475c693 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h
@@ -1,59 +1,59 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Implements the Protocol Compiler front-end such that it may be reused by
-// custom compilers written to support other languages.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
-#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Implements the Protocol Compiler front-end such that it may be reused by
+// custom compilers written to support other languages.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
+#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
+
#include <cstdint>
-#include <map>
+#include <map>
#include <memory>
-#include <set>
+#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
-#include <utility>
+#include <utility>
#include <vector>
-
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-
+namespace google {
+namespace protobuf {
+
class Descriptor; // descriptor.h
class DescriptorDatabase; // descriptor_database.h
class DescriptorPool; // descriptor.h
@@ -63,40 +63,40 @@ class FileDescriptorProto; // descriptor.pb.h
template <typename T>
class RepeatedPtrField; // repeated_field.h
class SimpleDescriptorDatabase; // descriptor_database.h
-
-namespace compiler {
-
+
+namespace compiler {
+
class CodeGenerator; // code_generator.h
class GeneratorContext; // code_generator.h
class DiskSourceTree; // importer.h
-
-// This class implements the command-line interface to the protocol compiler.
-// It is designed to make it very easy to create a custom protocol compiler
-// supporting the languages of your choice. For example, if you wanted to
-// create a custom protocol compiler binary which includes both the regular
-// C++ support plus support for your own custom output "Foo", you would
-// write a class "FooGenerator" which implements the CodeGenerator interface,
-// then write a main() procedure like this:
-//
-// int main(int argc, char* argv[]) {
-// google::protobuf::compiler::CommandLineInterface cli;
-//
-// // Support generation of C++ source and headers.
-// google::protobuf::compiler::cpp::CppGenerator cpp_generator;
-// cli.RegisterGenerator("--cpp_out", &cpp_generator,
-// "Generate C++ source and header.");
-//
-// // Support generation of Foo code.
-// FooGenerator foo_generator;
-// cli.RegisterGenerator("--foo_out", &foo_generator,
-// "Generate Foo file.");
-//
-// return cli.Run(argc, argv);
-// }
-//
-// The compiler is invoked with syntax like:
-// protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto
-//
+
+// This class implements the command-line interface to the protocol compiler.
+// It is designed to make it very easy to create a custom protocol compiler
+// supporting the languages of your choice. For example, if you wanted to
+// create a custom protocol compiler binary which includes both the regular
+// C++ support plus support for your own custom output "Foo", you would
+// write a class "FooGenerator" which implements the CodeGenerator interface,
+// then write a main() procedure like this:
+//
+// int main(int argc, char* argv[]) {
+// google::protobuf::compiler::CommandLineInterface cli;
+//
+// // Support generation of C++ source and headers.
+// google::protobuf::compiler::cpp::CppGenerator cpp_generator;
+// cli.RegisterGenerator("--cpp_out", &cpp_generator,
+// "Generate C++ source and header.");
+//
+// // Support generation of Foo code.
+// FooGenerator foo_generator;
+// cli.RegisterGenerator("--foo_out", &foo_generator,
+// "Generate Foo file.");
+//
+// return cli.Run(argc, argv);
+// }
+//
+// The compiler is invoked with syntax like:
+// protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto
+//
// The .proto file to compile can be specified on the command line using either
// its physical file path, or a virtual path relative to a directory specified
// in --proto_path. For example, for src/foo.proto, the following two protoc
@@ -107,60 +107,60 @@ class DiskSourceTree; // importer.h
// If a file path can be interpreted both as a physical file path and as a
// relative virtual path, the physical file path takes precedence.
//
-// For a full description of the command-line syntax, invoke it with --help.
+// For a full description of the command-line syntax, invoke it with --help.
class PROTOC_EXPORT CommandLineInterface {
- public:
+ public:
static const char* const kPathSeparator;
- CommandLineInterface();
- ~CommandLineInterface();
-
- // Register a code generator for a language.
- //
- // Parameters:
- // * flag_name: The command-line flag used to specify an output file of
- // this type. The name must start with a '-'. If the name is longer
- // than one letter, it must start with two '-'s.
- // * generator: The CodeGenerator which will be called to generate files
- // of this type.
- // * help_text: Text describing this flag in the --help output.
- //
- // Some generators accept extra parameters. You can specify this parameter
- // on the command-line by placing it before the output directory, separated
- // by a colon:
- // protoc --foo_out=enable_bar:outdir
- // The text before the colon is passed to CodeGenerator::Generate() as the
- // "parameter".
+ CommandLineInterface();
+ ~CommandLineInterface();
+
+ // Register a code generator for a language.
+ //
+ // Parameters:
+ // * flag_name: The command-line flag used to specify an output file of
+ // this type. The name must start with a '-'. If the name is longer
+ // than one letter, it must start with two '-'s.
+ // * generator: The CodeGenerator which will be called to generate files
+ // of this type.
+ // * help_text: Text describing this flag in the --help output.
+ //
+ // Some generators accept extra parameters. You can specify this parameter
+ // on the command-line by placing it before the output directory, separated
+ // by a colon:
+ // protoc --foo_out=enable_bar:outdir
+ // The text before the colon is passed to CodeGenerator::Generate() as the
+ // "parameter".
void RegisterGenerator(const TProtoStringType& flag_name, CodeGenerator* generator,
const TProtoStringType& help_text);
-
- // Register a code generator for a language.
- // Besides flag_name you can specify another option_flag_name that could be
- // used to pass extra parameters to the registered code generator.
- // Suppose you have registered a generator by calling:
- // command_line_interface.RegisterGenerator("--foo_out", "--foo_opt", ...)
- // Then you could invoke the compiler with a command like:
- // protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz
- // This will pass "enable_bar,enable_baz" as the parameter to the generator.
+
+ // Register a code generator for a language.
+ // Besides flag_name you can specify another option_flag_name that could be
+ // used to pass extra parameters to the registered code generator.
+ // Suppose you have registered a generator by calling:
+ // command_line_interface.RegisterGenerator("--foo_out", "--foo_opt", ...)
+ // Then you could invoke the compiler with a command like:
+ // protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz
+ // This will pass "enable_bar,enable_baz" as the parameter to the generator.
void RegisterGenerator(const TProtoStringType& flag_name,
const TProtoStringType& option_flag_name,
- CodeGenerator* generator,
+ CodeGenerator* generator,
const TProtoStringType& help_text);
-
- // Enables "plugins". In this mode, if a command-line flag ends with "_out"
- // but does not match any registered generator, the compiler will attempt to
- // find a "plugin" to implement the generator. Plugins are just executables.
- // They should live somewhere in the PATH.
- //
- // The compiler determines the executable name to search for by concatenating
- // exe_name_prefix with the unrecognized flag name, removing "_out". So, for
- // example, if exe_name_prefix is "protoc-" and you pass the flag --foo_out,
+
+ // Enables "plugins". In this mode, if a command-line flag ends with "_out"
+ // but does not match any registered generator, the compiler will attempt to
+ // find a "plugin" to implement the generator. Plugins are just executables.
+ // They should live somewhere in the PATH.
+ //
+ // The compiler determines the executable name to search for by concatenating
+ // exe_name_prefix with the unrecognized flag name, removing "_out". So, for
+ // example, if exe_name_prefix is "protoc-" and you pass the flag --foo_out,
// the compiler will try to run the program "protoc-gen-foo".
- //
- // The plugin program should implement the following usage:
- // plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS
- // --out indicates the output directory (as passed to the --foo_out
- // parameter); if omitted, the current directory should be used. --parameter
+ //
+ // The plugin program should implement the following usage:
+ // plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS
+ // --out indicates the output directory (as passed to the --foo_out
+ // parameter); if omitted, the current directory should be used. --parameter
// gives the generator parameter, if any was provided (see below). The
// PROTO_FILES list the .proto files which were given on the compiler
// command-line; these are the files for which the plugin is expected to
@@ -169,13 +169,13 @@ class PROTOC_EXPORT CommandLineInterface {
// The set will include descriptors for all the files listed in PROTO_FILES as
// well as all files that they import. The plugin MUST NOT attempt to read
// the PROTO_FILES directly -- it must use the FileDescriptorSet.
- //
- // The plugin should generate whatever files are necessary, as code generators
- // normally do. It should write the names of all files it generates to
- // stdout. The names should be relative to the output directory, NOT absolute
- // names or relative to the current directory. If any errors occur, error
- // messages should be written to stderr. If an error is fatal, the plugin
- // should exit with a non-zero exit code.
+ //
+ // The plugin should generate whatever files are necessary, as code generators
+ // normally do. It should write the names of all files it generates to
+ // stdout. The names should be relative to the output directory, NOT absolute
+ // names or relative to the current directory. If any errors occur, error
+ // messages should be written to stderr. If an error is fatal, the plugin
+ // should exit with a non-zero exit code.
//
// Plugins can have generator parameters similar to normal built-in
// generators. Extra generator parameters can be passed in via a matching
@@ -184,49 +184,49 @@ class PROTOC_EXPORT CommandLineInterface {
// This will pass "enable_bar,enable_baz" as the parameter to the plugin.
//
void AllowPlugins(const TProtoStringType& exe_name_prefix);
-
- // Run the Protocol Compiler with the given command-line parameters.
- // Returns the error code which should be returned by main().
- //
- // It may not be safe to call Run() in a multi-threaded environment because
- // it calls strerror(). I'm not sure why you'd want to do this anyway.
- int Run(int argc, const char* const argv[]);
-
+
+ // Run the Protocol Compiler with the given command-line parameters.
+ // Returns the error code which should be returned by main().
+ //
+ // It may not be safe to call Run() in a multi-threaded environment because
+ // it calls strerror(). I'm not sure why you'd want to do this anyway.
+ int Run(int argc, const char* const argv[]);
+
// DEPRECATED. Calling this method has no effect. Protocol compiler now
// always try to find the .proto file relative to the current directory
// first and if the file is not found, it will then treat the input path
// as a virtual path.
void SetInputsAreProtoPathRelative(bool /* enable */) {}
-
- // Provides some text which will be printed when the --version flag is
- // used. The version of libprotoc will also be printed on the next line
- // after this text.
+
+ // Provides some text which will be printed when the --version flag is
+ // used. The version of libprotoc will also be printed on the next line
+ // after this text.
void SetVersionInfo(const TProtoStringType& text) { version_info_ = text; }
-
-
- private:
- // -----------------------------------------------------------------
-
- class ErrorPrinter;
- class GeneratorContextImpl;
- class MemoryOutputStream;
+
+
+ private:
+ // -----------------------------------------------------------------
+
+ class ErrorPrinter;
+ class GeneratorContextImpl;
+ class MemoryOutputStream;
typedef std::unordered_map<TProtoStringType, std::unique_ptr<GeneratorContextImpl>>
GeneratorContextMap;
-
- // Clear state from previous Run().
- void Clear();
-
+
+ // Clear state from previous Run().
+ void Clear();
+
// Remaps the proto file so that it is relative to one of the directories
// in proto_path_. Returns false if an error occurred.
bool MakeProtoProtoPathRelative(DiskSourceTree* source_tree,
TProtoStringType* proto,
DescriptorDatabase* fallback_database);
- // Remaps each file in input_files_ so that it is relative to one of the
+ // Remaps each file in input_files_ so that it is relative to one of the
// directories in proto_path_. Returns false if an error occurred.
bool MakeInputsBeProtoPathRelative(DiskSourceTree* source_tree,
DescriptorDatabase* fallback_database);
-
+
// Fails if these files use proto3 optional and the code generator doesn't
// support it. This is a permanent check.
bool EnforceProto3OptionalSupport(
@@ -234,41 +234,41 @@ class PROTOC_EXPORT CommandLineInterface {
const std::vector<const FileDescriptor*>& parsed_files) const;
- // Return status for ParseArguments() and InterpretArgument().
- enum ParseArgumentStatus {
- PARSE_ARGUMENT_DONE_AND_CONTINUE,
- PARSE_ARGUMENT_DONE_AND_EXIT,
- PARSE_ARGUMENT_FAIL
- };
-
- // Parse all command-line arguments.
- ParseArgumentStatus ParseArguments(int argc, const char* const argv[]);
-
+ // Return status for ParseArguments() and InterpretArgument().
+ enum ParseArgumentStatus {
+ PARSE_ARGUMENT_DONE_AND_CONTINUE,
+ PARSE_ARGUMENT_DONE_AND_EXIT,
+ PARSE_ARGUMENT_FAIL
+ };
+
+ // Parse all command-line arguments.
+ ParseArgumentStatus ParseArguments(int argc, const char* const argv[]);
+
// Read an argument file and append the file's content to the list of
// arguments. Return false if the file cannot be read.
bool ExpandArgumentFile(const TProtoStringType& file,
std::vector<TProtoStringType>* arguments);
-
- // Parses a command-line argument into a name/value pair. Returns
- // true if the next argument in the argv should be used as the value,
- // false otherwise.
- //
- // Examples:
- // "-Isrc/protos" ->
- // name = "-I", value = "src/protos"
- // "--cpp_out=src/foo.pb2.cc" ->
- // name = "--cpp_out", value = "src/foo.pb2.cc"
- // "foo.proto" ->
- // name = "", value = "foo.proto"
+
+ // Parses a command-line argument into a name/value pair. Returns
+ // true if the next argument in the argv should be used as the value,
+ // false otherwise.
+ //
+ // Examples:
+ // "-Isrc/protos" ->
+ // name = "-I", value = "src/protos"
+ // "--cpp_out=src/foo.pb2.cc" ->
+ // name = "--cpp_out", value = "src/foo.pb2.cc"
+ // "foo.proto" ->
+ // name = "", value = "foo.proto"
bool ParseArgument(const char* arg, TProtoStringType* name, TProtoStringType* value);
-
- // Interprets arguments parsed with ParseArgument.
+
+ // Interprets arguments parsed with ParseArgument.
ParseArgumentStatus InterpretArgument(const TProtoStringType& name,
const TProtoStringType& value);
-
- // Print the --help text to stderr.
- void PrintHelpText();
-
+
+ // Print the --help text to stderr.
+ void PrintHelpText();
+
// Loads proto_path_ into the provided source_tree.
bool InitializeDiskSourceTree(DiskSourceTree* source_tree,
DescriptorDatabase* fallback_database);
@@ -281,130 +281,130 @@ class PROTOC_EXPORT CommandLineInterface {
DiskSourceTree* source_tree,
std::vector<const FileDescriptor*>* parsed_files);
- // Generate the given output file from the given input.
- struct OutputDirective; // see below
+ // Generate the given output file from the given input.
+ struct OutputDirective; // see below
bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files,
- const OutputDirective& output_directive,
- GeneratorContext* generator_context);
+ const OutputDirective& output_directive,
+ GeneratorContext* generator_context);
bool GeneratePluginOutput(
const std::vector<const FileDescriptor*>& parsed_files,
const TProtoStringType& plugin_name, const TProtoStringType& parameter,
GeneratorContext* generator_context, TProtoStringType* error);
-
- // Implements --encode and --decode.
- bool EncodeOrDecode(const DescriptorPool* pool);
-
- // Implements the --descriptor_set_out option.
+
+ // Implements --encode and --decode.
+ bool EncodeOrDecode(const DescriptorPool* pool);
+
+ // Implements the --descriptor_set_out option.
bool WriteDescriptorSet(
const std::vector<const FileDescriptor*>& parsed_files);
-
- // Implements the --dependency_out option
- bool GenerateDependencyManifestFile(
+
+ // Implements the --dependency_out option
+ bool GenerateDependencyManifestFile(
const std::vector<const FileDescriptor*>& parsed_files,
- const GeneratorContextMap& output_directories,
- DiskSourceTree* source_tree);
-
- // Get all transitive dependencies of the given file (including the file
- // itself), adding them to the given list of FileDescriptorProtos. The
- // protos will be ordered such that every file is listed before any file that
- // depends on it, so that you can call DescriptorPool::BuildFile() on them
- // in order. Any files in *already_seen will not be added, and each file
- // added will be inserted into *already_seen. If include_source_code_info is
- // true then include the source code information in the FileDescriptorProtos.
- // If include_json_name is true, populate the json_name field of
- // FieldDescriptorProto for all fields.
- static void GetTransitiveDependencies(
+ const GeneratorContextMap& output_directories,
+ DiskSourceTree* source_tree);
+
+ // Get all transitive dependencies of the given file (including the file
+ // itself), adding them to the given list of FileDescriptorProtos. The
+ // protos will be ordered such that every file is listed before any file that
+ // depends on it, so that you can call DescriptorPool::BuildFile() on them
+ // in order. Any files in *already_seen will not be added, and each file
+ // added will be inserted into *already_seen. If include_source_code_info is
+ // true then include the source code information in the FileDescriptorProtos.
+ // If include_json_name is true, populate the json_name field of
+ // FieldDescriptorProto for all fields.
+ static void GetTransitiveDependencies(
const FileDescriptor* file, bool include_json_name,
- bool include_source_code_info,
+ bool include_source_code_info,
std::set<const FileDescriptor*>* already_seen,
- RepeatedPtrField<FileDescriptorProto>* output);
-
- // Implements the --print_free_field_numbers. This function prints free field
- // numbers into stdout for the message and it's nested message types in
- // post-order, i.e. nested types first. Printed range are left-right
- // inclusive, i.e. [a, b].
- //
- // Groups:
- // For historical reasons, groups are considered to share the same
- // field number space with the parent message, thus it will not print free
- // field numbers for groups. The field numbers used in the groups are
- // excluded in the free field numbers of the parent message.
- //
- // Extension Ranges:
- // Extension ranges are considered ocuppied field numbers and they will not be
- // listed as free numbers in the output.
- void PrintFreeFieldNumbers(const Descriptor* descriptor);
-
- // -----------------------------------------------------------------
-
- // The name of the executable as invoked (i.e. argv[0]).
+ RepeatedPtrField<FileDescriptorProto>* output);
+
+ // Implements the --print_free_field_numbers. This function prints free field
+ // numbers into stdout for the message and it's nested message types in
+ // post-order, i.e. nested types first. Printed range are left-right
+ // inclusive, i.e. [a, b].
+ //
+ // Groups:
+ // For historical reasons, groups are considered to share the same
+ // field number space with the parent message, thus it will not print free
+ // field numbers for groups. The field numbers used in the groups are
+ // excluded in the free field numbers of the parent message.
+ //
+ // Extension Ranges:
+ // Extension ranges are considered ocuppied field numbers and they will not be
+ // listed as free numbers in the output.
+ void PrintFreeFieldNumbers(const Descriptor* descriptor);
+
+ // -----------------------------------------------------------------
+
+ // The name of the executable as invoked (i.e. argv[0]).
TProtoStringType executable_name_;
-
- // Version info set with SetVersionInfo().
+
+ // Version info set with SetVersionInfo().
TProtoStringType version_info_;
-
- // Registered generators.
- struct GeneratorInfo {
+
+ // Registered generators.
+ struct GeneratorInfo {
TProtoStringType flag_name;
TProtoStringType option_flag_name;
- CodeGenerator* generator;
+ CodeGenerator* generator;
TProtoStringType help_text;
- };
+ };
typedef std::map<TProtoStringType, GeneratorInfo> GeneratorMap;
- GeneratorMap generators_by_flag_name_;
- GeneratorMap generators_by_option_name_;
- // A map from generator names to the parameters specified using the option
- // flag. For example, if the user invokes the compiler with:
- // protoc --foo_out=outputdir --foo_opt=enable_bar ...
- // Then there will be an entry ("--foo_out", "enable_bar") in this map.
+ GeneratorMap generators_by_flag_name_;
+ GeneratorMap generators_by_option_name_;
+ // A map from generator names to the parameters specified using the option
+ // flag. For example, if the user invokes the compiler with:
+ // protoc --foo_out=outputdir --foo_opt=enable_bar ...
+ // Then there will be an entry ("--foo_out", "enable_bar") in this map.
std::map<TProtoStringType, TProtoStringType> generator_parameters_;
// Similar to generator_parameters_, but stores the parameters for plugins.
std::map<TProtoStringType, TProtoStringType> plugin_parameters_;
-
- // See AllowPlugins(). If this is empty, plugins aren't allowed.
+
+ // See AllowPlugins(). If this is empty, plugins aren't allowed.
TProtoStringType plugin_prefix_;
-
- // Maps specific plugin names to files. When executing a plugin, this map
- // is searched first to find the plugin executable. If not found here, the
- // PATH (or other OS-specific search strategy) is searched.
+
+ // Maps specific plugin names to files. When executing a plugin, this map
+ // is searched first to find the plugin executable. If not found here, the
+ // PATH (or other OS-specific search strategy) is searched.
std::map<TProtoStringType, TProtoStringType> plugins_;
-
- // Stuff parsed from command line.
- enum Mode {
- MODE_COMPILE, // Normal mode: parse .proto files and compile them.
- MODE_ENCODE, // --encode: read text from stdin, write binary to stdout.
- MODE_DECODE, // --decode: read binary from stdin, write text to stdout.
- MODE_PRINT, // Print mode: print info of the given .proto files and exit.
- };
-
+
+ // Stuff parsed from command line.
+ enum Mode {
+ MODE_COMPILE, // Normal mode: parse .proto files and compile them.
+ MODE_ENCODE, // --encode: read text from stdin, write binary to stdout.
+ MODE_DECODE, // --decode: read binary from stdin, write text to stdout.
+ MODE_PRINT, // Print mode: print info of the given .proto files and exit.
+ };
+
Mode mode_ = MODE_COMPILE;
-
+
// For encode end decode modes only: read from input and write to output
// instead of stdin and stdout.
TProtoStringType encode_decode_input_;
TProtoStringType encode_decode_output_;
- enum PrintMode {
+ enum PrintMode {
PRINT_NONE, // Not in MODE_PRINT
PRINT_FREE_FIELDS, // --print_free_fields
- };
-
+ };
+
PrintMode print_mode_ = PRINT_NONE;
-
- enum ErrorFormat {
+
+ enum ErrorFormat {
ERROR_FORMAT_GCC, // GCC error output format (default).
ERROR_FORMAT_MSVS // Visual Studio output (--error_format=msvs).
- };
-
+ };
+
ErrorFormat error_format_ = ERROR_FORMAT_GCC;
-
+
// True if we should treat warnings as errors that fail the compilation.
bool fatal_warnings_ = false;
std::vector<std::pair<TProtoStringType, TProtoStringType> >
proto_path_; // Search path for proto files.
std::vector<TProtoStringType> input_files_; // Names of the input proto files.
-
+
// Names of proto files which are allowed to be imported. Used by build
// systems to enforce depend-on-what-you-import.
std::set<TProtoStringType> direct_dependencies_;
@@ -414,54 +414,54 @@ class PROTOC_EXPORT CommandLineInterface {
// presented to the user. "%s" will be replaced with the violating import.
TProtoStringType direct_dependencies_violation_msg_;
- // output_directives_ lists all the files we are supposed to output and what
- // generator to use for each.
- struct OutputDirective {
+ // output_directives_ lists all the files we are supposed to output and what
+ // generator to use for each.
+ struct OutputDirective {
TProtoStringType name; // E.g. "--foo_out"
CodeGenerator* generator; // NULL for plugins
TProtoStringType parameter;
TProtoStringType output_location;
- };
+ };
std::vector<OutputDirective> output_directives_;
-
- // When using --encode or --decode, this names the type we are encoding or
- // decoding. (Empty string indicates --decode_raw.)
+
+ // When using --encode or --decode, this names the type we are encoding or
+ // decoding. (Empty string indicates --decode_raw.)
TProtoStringType codec_type_;
-
+
// If --descriptor_set_in was given, these are filenames containing
// parsed FileDescriptorSets to be used for loading protos. Otherwise, empty.
std::vector<TProtoStringType> descriptor_set_in_names_;
- // If --descriptor_set_out was given, this is the filename to which the
- // FileDescriptorSet should be written. Otherwise, empty.
+ // If --descriptor_set_out was given, this is the filename to which the
+ // FileDescriptorSet should be written. Otherwise, empty.
TProtoStringType descriptor_set_out_name_;
-
- // If --dependency_out was given, this is the path to the file where the
- // dependency file will be written. Otherwise, empty.
+
+ // If --dependency_out was given, this is the path to the file where the
+ // dependency file will be written. Otherwise, empty.
TProtoStringType dependency_out_name_;
-
- // True if --include_imports was given, meaning that we should
- // write all transitive dependencies to the DescriptorSet. Otherwise, only
- // the .proto files listed on the command-line are added.
- bool imports_in_descriptor_set_;
-
- // True if --include_source_info was given, meaning that we should not strip
- // SourceCodeInfo from the DescriptorSet.
+
+ // True if --include_imports was given, meaning that we should
+ // write all transitive dependencies to the DescriptorSet. Otherwise, only
+ // the .proto files listed on the command-line are added.
+ bool imports_in_descriptor_set_;
+
+ // True if --include_source_info was given, meaning that we should not strip
+ // SourceCodeInfo from the DescriptorSet.
bool source_info_in_descriptor_set_ = false;
-
- // Was the --disallow_services flag used?
+
+ // Was the --disallow_services flag used?
bool disallow_services_ = false;
-
+
// When using --encode, this will be passed to SetSerializationDeterministic.
bool deterministic_output_ = false;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface);
-};
-
-} // namespace compiler
-} // namespace protobuf
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface);
+};
+
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__
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 b0160ef149..e0c80fc1c6 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: kenton@google.com (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: kenton@google.com (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 0a12e18fed..43f1e5f4a5 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: kenton@google.com (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: kenton@google.com (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 f314861342..ce2a0e4591 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: kenton@google.com (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: kenton@google.com (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 311248d8a3..3fa64a8640 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: kenton@google.com (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: kenton@google.com (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 7f34672e28..9b0fcb02da 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: kenton@google.com (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: kenton@google.com (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 c80550fd80..88c7dafbc3 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: kenton@google.com (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: kenton@google.com (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 17d1f13ea4..09261aaddc 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: kenton@google.com (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: kenton@google.com (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 51d697963d..b05f2d93fa 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: kenton@google.com (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: kenton@google.com (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 f0940f5d21..6218cfa8b5 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: kenton@google.com (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: kenton@google.com (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 fa8a876947..41e3907391 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: kenton@google.com (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: kenton@google.com (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 dcaa1ef9f6..1e2d01d147 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: kenton@google.com (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: kenton@google.com (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 413b39f139..235d02325f 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: kenton@google.com (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: kenton@google.com (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 d0bb537b92..0f9660d237 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: kenton@google.com (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: kenton@google.com (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 866b2019e9..1cc9329c86 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: kenton@google.com (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: kenton@google.com (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 e521d4797a..f8e1c380cc 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 f3c75f858f..5ea04290e6 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 1cba0ff3d5..cb890d5156 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: kenton@google.com (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: kenton@google.com (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 31abe51ee8..904a98acfe 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: kenton@google.com (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: kenton@google.com (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 f8ce78945b..720ce273bd 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: kenton@google.com (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: kenton@google.com (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 4d7b21db8e..4b4b8ea59b 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: kenton@google.com (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: kenton@google.com (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 205e6587cc..ed5cd0b046 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: rennie@google.com (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: rennie@google.com (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 2b108413ef..da229ce3c4 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: kenton@google.com (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: kenton@google.com (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 0a96e70037..394b304770 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: kenton@google.com (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: kenton@google.com (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 03f7b645b8..0a30646fd0 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: kenton@google.com (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: kenton@google.com (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 4861c27fab..f510716fed 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: kenton@google.com (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: kenton@google.com (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 759d0d5d14..12faeaf7a0 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: kenton@google.com (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: kenton@google.com (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 5d0a18da72..213f13465d 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: kenton@google.com (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: kenton@google.com (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__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
index 142afb8c9e..2fdbf5ce1f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc
@@ -1,37 +1,37 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#ifdef _MSC_VER
#include <direct.h>
#else
@@ -40,18 +40,18 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <algorithm>
-#include <memory>
-
+#include <sys/types.h>
+
+#include <algorithm>
+#include <memory>
+
#include <google/protobuf/compiler/importer.h>
#include <google/protobuf/compiler/parser.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/io/io_win32.h>
-
+
#ifdef _WIN32
#include <ctype.h>
#endif
@@ -67,60 +67,60 @@ using google::protobuf::io::win32::access;
using google::protobuf::io::win32::open;
#endif
-// Returns true if the text looks like a Windows-style absolute path, starting
-// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
-// copy in command_line_interface.cc?
+// Returns true if the text looks like a Windows-style absolute path, starting
+// with a drive letter. Example: "C:\foo". TODO(kenton): Share this with
+// copy in command_line_interface.cc?
static bool IsWindowsAbsolutePath(const TProtoStringType& text) {
-#if defined(_WIN32) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__CYGWIN__)
return text.size() >= 3 && text[1] == ':' && isalpha(text[0]) &&
(text[2] == '/' || text[2] == '\\') && text.find_last_of(':') == 1;
-#else
- return false;
-#endif
-}
-
-MultiFileErrorCollector::~MultiFileErrorCollector() {}
-
-// This class serves two purposes:
-// - It implements the ErrorCollector interface (used by Tokenizer and Parser)
-// in terms of MultiFileErrorCollector, using a particular filename.
-// - It lets us check if any errors have occurred.
-class SourceTreeDescriptorDatabase::SingleFileErrorCollector
- : public io::ErrorCollector {
- public:
+#else
+ return false;
+#endif
+}
+
+MultiFileErrorCollector::~MultiFileErrorCollector() {}
+
+// This class serves two purposes:
+// - It implements the ErrorCollector interface (used by Tokenizer and Parser)
+// in terms of MultiFileErrorCollector, using a particular filename.
+// - It lets us check if any errors have occurred.
+class SourceTreeDescriptorDatabase::SingleFileErrorCollector
+ : public io::ErrorCollector {
+ public:
SingleFileErrorCollector(const TProtoStringType& filename,
- MultiFileErrorCollector* multi_file_error_collector)
+ MultiFileErrorCollector* multi_file_error_collector)
: filename_(filename),
multi_file_error_collector_(multi_file_error_collector),
had_errors_(false) {}
- ~SingleFileErrorCollector() {}
-
- bool had_errors() { return had_errors_; }
-
- // implements ErrorCollector ---------------------------------------
+ ~SingleFileErrorCollector() {}
+
+ bool had_errors() { return had_errors_; }
+
+ // implements ErrorCollector ---------------------------------------
void AddError(int line, int column, const TProtoStringType& message) override {
- if (multi_file_error_collector_ != NULL) {
- multi_file_error_collector_->AddError(filename_, line, column, message);
- }
- had_errors_ = true;
- }
-
- private:
+ if (multi_file_error_collector_ != NULL) {
+ multi_file_error_collector_->AddError(filename_, line, column, message);
+ }
+ had_errors_ = true;
+ }
+
+ private:
TProtoStringType filename_;
- MultiFileErrorCollector* multi_file_error_collector_;
- bool had_errors_;
-};
-
-// ===================================================================
-
-SourceTreeDescriptorDatabase::SourceTreeDescriptorDatabase(
- SourceTree* source_tree)
+ MultiFileErrorCollector* multi_file_error_collector_;
+ bool had_errors_;
+};
+
+// ===================================================================
+
+SourceTreeDescriptorDatabase::SourceTreeDescriptorDatabase(
+ SourceTree* source_tree)
: source_tree_(source_tree),
fallback_database_(nullptr),
error_collector_(nullptr),
using_validation_error_collector_(false),
validation_error_collector_(this) {}
-
+
SourceTreeDescriptorDatabase::SourceTreeDescriptorDatabase(
SourceTree* source_tree, DescriptorDatabase* fallback_database)
: source_tree_(source_tree),
@@ -129,366 +129,366 @@ SourceTreeDescriptorDatabase::SourceTreeDescriptorDatabase(
using_validation_error_collector_(false),
validation_error_collector_(this) {}
-SourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {}
-
+SourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {}
+
bool SourceTreeDescriptorDatabase::FindFileByName(const TProtoStringType& filename,
FileDescriptorProto* output) {
std::unique_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename));
- if (input == NULL) {
+ if (input == NULL) {
if (fallback_database_ != nullptr &&
fallback_database_->FindFileByName(filename, output)) {
return true;
}
- if (error_collector_ != NULL) {
- error_collector_->AddError(filename, -1, 0,
- source_tree_->GetLastErrorMessage());
- }
- return false;
- }
-
- // Set up the tokenizer and parser.
- SingleFileErrorCollector file_error_collector(filename, error_collector_);
- io::Tokenizer tokenizer(input.get(), &file_error_collector);
-
- Parser parser;
- if (error_collector_ != NULL) {
- parser.RecordErrorsTo(&file_error_collector);
- }
- if (using_validation_error_collector_) {
- parser.RecordSourceLocationsTo(&source_locations_);
- }
-
- // Parse it.
- output->set_name(filename);
+ if (error_collector_ != NULL) {
+ error_collector_->AddError(filename, -1, 0,
+ source_tree_->GetLastErrorMessage());
+ }
+ return false;
+ }
+
+ // Set up the tokenizer and parser.
+ SingleFileErrorCollector file_error_collector(filename, error_collector_);
+ io::Tokenizer tokenizer(input.get(), &file_error_collector);
+
+ Parser parser;
+ if (error_collector_ != NULL) {
+ parser.RecordErrorsTo(&file_error_collector);
+ }
+ if (using_validation_error_collector_) {
+ parser.RecordSourceLocationsTo(&source_locations_);
+ }
+
+ // Parse it.
+ output->set_name(filename);
return parser.Parse(&tokenizer, output) && !file_error_collector.had_errors();
-}
-
-bool SourceTreeDescriptorDatabase::FindFileContainingSymbol(
+}
+
+bool SourceTreeDescriptorDatabase::FindFileContainingSymbol(
const TProtoStringType& symbol_name, FileDescriptorProto* output) {
- return false;
-}
-
-bool SourceTreeDescriptorDatabase::FindFileContainingExtension(
+ return false;
+}
+
+bool SourceTreeDescriptorDatabase::FindFileContainingExtension(
const TProtoStringType& containing_type, int field_number,
- FileDescriptorProto* output) {
- return false;
-}
-
-// -------------------------------------------------------------------
-
-SourceTreeDescriptorDatabase::ValidationErrorCollector::
+ FileDescriptorProto* output) {
+ return false;
+}
+
+// -------------------------------------------------------------------
+
+SourceTreeDescriptorDatabase::ValidationErrorCollector::
ValidationErrorCollector(SourceTreeDescriptorDatabase* owner)
: owner_(owner) {}
-
-SourceTreeDescriptorDatabase::ValidationErrorCollector::
+
+SourceTreeDescriptorDatabase::ValidationErrorCollector::
~ValidationErrorCollector() {}
-
-void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError(
+
+void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError(
const TProtoStringType& filename, const TProtoStringType& element_name,
const Message* descriptor, ErrorLocation location,
const TProtoStringType& message) {
- if (owner_->error_collector_ == NULL) return;
-
- int line, column;
+ if (owner_->error_collector_ == NULL) return;
+
+ int line, column;
if (location == DescriptorPool::ErrorCollector::IMPORT) {
owner_->source_locations_.FindImport(descriptor, element_name, &line,
&column);
} else {
owner_->source_locations_.Find(descriptor, location, &line, &column);
}
- owner_->error_collector_->AddError(filename, line, column, message);
-}
-
-void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning(
+ owner_->error_collector_->AddError(filename, line, column, message);
+}
+
+void SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning(
const TProtoStringType& filename, const TProtoStringType& element_name,
const Message* descriptor, ErrorLocation location,
const TProtoStringType& message) {
- if (owner_->error_collector_ == NULL) return;
-
- int line, column;
+ if (owner_->error_collector_ == NULL) return;
+
+ int line, column;
if (location == DescriptorPool::ErrorCollector::IMPORT) {
owner_->source_locations_.FindImport(descriptor, element_name, &line,
&column);
} else {
owner_->source_locations_.Find(descriptor, location, &line, &column);
}
- owner_->error_collector_->AddWarning(filename, line, column, message);
-}
-
-// ===================================================================
-
-Importer::Importer(SourceTree* source_tree,
- MultiFileErrorCollector* error_collector)
+ owner_->error_collector_->AddWarning(filename, line, column, message);
+}
+
+// ===================================================================
+
+Importer::Importer(SourceTree* source_tree,
+ MultiFileErrorCollector* error_collector)
: database_(source_tree),
pool_(&database_, database_.GetValidationErrorCollector()) {
- pool_.EnforceWeakDependencies(true);
- database_.RecordErrorsTo(error_collector);
-}
-
-Importer::~Importer() {}
-
+ pool_.EnforceWeakDependencies(true);
+ database_.RecordErrorsTo(error_collector);
+}
+
+Importer::~Importer() {}
+
const FileDescriptor* Importer::Import(const TProtoStringType& filename) {
- return pool_.FindFileByName(filename);
-}
-
+ return pool_.FindFileByName(filename);
+}
+
void Importer::AddUnusedImportTrackFile(const TProtoStringType& file_name,
bool is_error) {
pool_.AddUnusedImportTrackFile(file_name, is_error);
-}
-
-void Importer::ClearUnusedImportTrackFiles() {
- pool_.ClearUnusedImportTrackFiles();
-}
-
-
-// ===================================================================
-
-SourceTree::~SourceTree() {}
-
+}
+
+void Importer::ClearUnusedImportTrackFiles() {
+ pool_.ClearUnusedImportTrackFiles();
+}
+
+
+// ===================================================================
+
+SourceTree::~SourceTree() {}
+
TProtoStringType SourceTree::GetLastErrorMessage() { return "File not found."; }
-
-DiskSourceTree::DiskSourceTree() {}
-
-DiskSourceTree::~DiskSourceTree() {}
-
+
+DiskSourceTree::DiskSourceTree() {}
+
+DiskSourceTree::~DiskSourceTree() {}
+
static inline char LastChar(const TProtoStringType& str) {
- return str[str.size() - 1];
-}
-
-// Given a path, returns an equivalent path with these changes:
-// - On Windows, any backslashes are replaced with forward slashes.
-// - Any instances of the directory "." are removed.
-// - Any consecutive '/'s are collapsed into a single slash.
-// Note that the resulting string may be empty.
-//
-// TODO(kenton): It would be nice to handle "..", e.g. so that we can figure
-// out that "foo/bar.proto" is inside "baz/../foo". However, if baz is a
-// symlink or doesn't exist, then things get complicated, and we can't
-// actually determine this without investigating the filesystem, probably
-// in non-portable ways. So, we punt.
-//
-// TODO(kenton): It would be nice to use realpath() here except that it
-// resolves symbolic links. This could cause problems if people place
-// symbolic links in their source tree. For example, if you executed:
-// protoc --proto_path=foo foo/bar/baz.proto
-// then if foo/bar is a symbolic link, foo/bar/baz.proto will canonicalize
-// to a path which does not appear to be under foo, and thus the compiler
-// will complain that baz.proto is not inside the --proto_path.
+ return str[str.size() - 1];
+}
+
+// Given a path, returns an equivalent path with these changes:
+// - On Windows, any backslashes are replaced with forward slashes.
+// - Any instances of the directory "." are removed.
+// - Any consecutive '/'s are collapsed into a single slash.
+// Note that the resulting string may be empty.
+//
+// TODO(kenton): It would be nice to handle "..", e.g. so that we can figure
+// out that "foo/bar.proto" is inside "baz/../foo". However, if baz is a
+// symlink or doesn't exist, then things get complicated, and we can't
+// actually determine this without investigating the filesystem, probably
+// in non-portable ways. So, we punt.
+//
+// TODO(kenton): It would be nice to use realpath() here except that it
+// resolves symbolic links. This could cause problems if people place
+// symbolic links in their source tree. For example, if you executed:
+// protoc --proto_path=foo foo/bar/baz.proto
+// then if foo/bar is a symbolic link, foo/bar/baz.proto will canonicalize
+// to a path which does not appear to be under foo, and thus the compiler
+// will complain that baz.proto is not inside the --proto_path.
static TProtoStringType CanonicalizePath(TProtoStringType path) {
-#ifdef _WIN32
- // The Win32 API accepts forward slashes as a path delimiter even though
- // backslashes are standard. Let's avoid confusion and use only forward
- // slashes.
- if (HasPrefixString(path, "\\\\")) {
- // Avoid converting two leading backslashes.
- path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true);
- } else {
- path = StringReplace(path, "\\", "/", true);
- }
-#endif
-
+#ifdef _WIN32
+ // The Win32 API accepts forward slashes as a path delimiter even though
+ // backslashes are standard. Let's avoid confusion and use only forward
+ // slashes.
+ if (HasPrefixString(path, "\\\\")) {
+ // Avoid converting two leading backslashes.
+ path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true);
+ } else {
+ path = StringReplace(path, "\\", "/", true);
+ }
+#endif
+
std::vector<TProtoStringType> canonical_parts;
std::vector<TProtoStringType> parts = Split(
- path, "/", true); // Note: Removes empty parts.
- for (int i = 0; i < parts.size(); i++) {
- if (parts[i] == ".") {
- // Ignore.
- } else {
- canonical_parts.push_back(parts[i]);
- }
- }
+ path, "/", true); // Note: Removes empty parts.
+ for (int i = 0; i < parts.size(); i++) {
+ if (parts[i] == ".") {
+ // Ignore.
+ } else {
+ canonical_parts.push_back(parts[i]);
+ }
+ }
TProtoStringType result = Join(canonical_parts, "/");
- if (!path.empty() && path[0] == '/') {
- // Restore leading slash.
+ if (!path.empty() && path[0] == '/') {
+ // Restore leading slash.
result = '/' + result;
- }
+ }
if (!path.empty() && LastChar(path) == '/' && !result.empty() &&
LastChar(result) != '/') {
- // Restore trailing slash.
- result += '/';
- }
- return result;
-}
-
+ // Restore trailing slash.
+ result += '/';
+ }
+ return result;
+}
+
static inline bool ContainsParentReference(const TProtoStringType& path) {
return path == ".." || HasPrefixString(path, "../") ||
HasSuffixString(path, "/..") || path.find("/../") != TProtoStringType::npos;
-}
-
-// Maps a file from an old location to a new one. Typically, old_prefix is
-// a virtual path and new_prefix is its corresponding disk path. Returns
-// false if the filename did not start with old_prefix, otherwise replaces
-// old_prefix with new_prefix and stores the result in *result. Examples:
-// string result;
-// assert(ApplyMapping("foo/bar", "", "baz", &result));
-// assert(result == "baz/foo/bar");
-//
-// assert(ApplyMapping("foo/bar", "foo", "baz", &result));
-// assert(result == "baz/bar");
-//
-// assert(ApplyMapping("foo", "foo", "bar", &result));
-// assert(result == "bar");
-//
-// assert(!ApplyMapping("foo/bar", "baz", "qux", &result));
-// assert(!ApplyMapping("foo/bar", "baz", "qux", &result));
-// assert(!ApplyMapping("foobar", "foo", "baz", &result));
+}
+
+// Maps a file from an old location to a new one. Typically, old_prefix is
+// a virtual path and new_prefix is its corresponding disk path. Returns
+// false if the filename did not start with old_prefix, otherwise replaces
+// old_prefix with new_prefix and stores the result in *result. Examples:
+// string result;
+// assert(ApplyMapping("foo/bar", "", "baz", &result));
+// assert(result == "baz/foo/bar");
+//
+// assert(ApplyMapping("foo/bar", "foo", "baz", &result));
+// assert(result == "baz/bar");
+//
+// assert(ApplyMapping("foo", "foo", "bar", &result));
+// assert(result == "bar");
+//
+// assert(!ApplyMapping("foo/bar", "baz", "qux", &result));
+// assert(!ApplyMapping("foo/bar", "baz", "qux", &result));
+// assert(!ApplyMapping("foobar", "foo", "baz", &result));
static bool ApplyMapping(const TProtoStringType& filename,
const TProtoStringType& old_prefix,
const TProtoStringType& new_prefix, TProtoStringType* result) {
- if (old_prefix.empty()) {
- // old_prefix matches any relative path.
- if (ContainsParentReference(filename)) {
- // We do not allow the file name to use "..".
- return false;
- }
+ if (old_prefix.empty()) {
+ // old_prefix matches any relative path.
+ if (ContainsParentReference(filename)) {
+ // We do not allow the file name to use "..".
+ return false;
+ }
if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) {
- // This is an absolute path, so it isn't matched by the empty string.
- return false;
- }
- result->assign(new_prefix);
- if (!result->empty()) result->push_back('/');
- result->append(filename);
- return true;
- } else if (HasPrefixString(filename, old_prefix)) {
- // old_prefix is a prefix of the filename. Is it the whole filename?
- if (filename.size() == old_prefix.size()) {
- // Yep, it's an exact match.
- *result = new_prefix;
- return true;
- } else {
- // Not an exact match. Is the next character a '/'? Otherwise,
- // this isn't actually a match at all. E.g. the prefix "foo/bar"
- // does not match the filename "foo/barbaz".
- int after_prefix_start = -1;
- if (filename[old_prefix.size()] == '/') {
- after_prefix_start = old_prefix.size() + 1;
- } else if (filename[old_prefix.size() - 1] == '/') {
- // old_prefix is never empty, and canonicalized paths never have
- // consecutive '/' characters.
- after_prefix_start = old_prefix.size();
- }
- if (after_prefix_start != -1) {
- // Yep. So the prefixes are directories and the filename is a file
- // inside them.
+ // This is an absolute path, so it isn't matched by the empty string.
+ return false;
+ }
+ result->assign(new_prefix);
+ if (!result->empty()) result->push_back('/');
+ result->append(filename);
+ return true;
+ } else if (HasPrefixString(filename, old_prefix)) {
+ // old_prefix is a prefix of the filename. Is it the whole filename?
+ if (filename.size() == old_prefix.size()) {
+ // Yep, it's an exact match.
+ *result = new_prefix;
+ return true;
+ } else {
+ // Not an exact match. Is the next character a '/'? Otherwise,
+ // this isn't actually a match at all. E.g. the prefix "foo/bar"
+ // does not match the filename "foo/barbaz".
+ int after_prefix_start = -1;
+ if (filename[old_prefix.size()] == '/') {
+ after_prefix_start = old_prefix.size() + 1;
+ } else if (filename[old_prefix.size() - 1] == '/') {
+ // old_prefix is never empty, and canonicalized paths never have
+ // consecutive '/' characters.
+ after_prefix_start = old_prefix.size();
+ }
+ if (after_prefix_start != -1) {
+ // Yep. So the prefixes are directories and the filename is a file
+ // inside them.
TProtoStringType after_prefix = filename.substr(after_prefix_start);
- if (ContainsParentReference(after_prefix)) {
- // We do not allow the file name to use "..".
- return false;
- }
- result->assign(new_prefix);
- if (!result->empty()) result->push_back('/');
- result->append(after_prefix);
- return true;
- }
- }
- }
-
- return false;
-}
-
+ if (ContainsParentReference(after_prefix)) {
+ // We do not allow the file name to use "..".
+ return false;
+ }
+ result->assign(new_prefix);
+ if (!result->empty()) result->push_back('/');
+ result->append(after_prefix);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void DiskSourceTree::MapPath(const TProtoStringType& virtual_path,
const TProtoStringType& disk_path) {
- mappings_.push_back(Mapping(virtual_path, CanonicalizePath(disk_path)));
-}
-
-DiskSourceTree::DiskFileToVirtualFileResult
+ mappings_.push_back(Mapping(virtual_path, CanonicalizePath(disk_path)));
+}
+
+DiskSourceTree::DiskFileToVirtualFileResult
DiskSourceTree::DiskFileToVirtualFile(const TProtoStringType& disk_file,
TProtoStringType* virtual_file,
TProtoStringType* shadowing_disk_file) {
- int mapping_index = -1;
+ int mapping_index = -1;
TProtoStringType canonical_disk_file = CanonicalizePath(disk_file);
-
- for (int i = 0; i < mappings_.size(); i++) {
- // Apply the mapping in reverse.
- if (ApplyMapping(canonical_disk_file, mappings_[i].disk_path,
- mappings_[i].virtual_path, virtual_file)) {
- // Success.
- mapping_index = i;
- break;
- }
- }
-
- if (mapping_index == -1) {
- return NO_MAPPING;
- }
-
- // Iterate through all mappings with higher precedence and verify that none
- // of them map this file to some other existing file.
- for (int i = 0; i < mapping_index; i++) {
- if (ApplyMapping(*virtual_file, mappings_[i].virtual_path,
- mappings_[i].disk_path, shadowing_disk_file)) {
- if (access(shadowing_disk_file->c_str(), F_OK) >= 0) {
- // File exists.
- return SHADOWED;
- }
- }
- }
- shadowing_disk_file->clear();
-
- // Verify that we can open the file. Note that this also has the side-effect
- // of verifying that we are not canonicalizing away any non-existent
- // directories.
+
+ for (int i = 0; i < mappings_.size(); i++) {
+ // Apply the mapping in reverse.
+ if (ApplyMapping(canonical_disk_file, mappings_[i].disk_path,
+ mappings_[i].virtual_path, virtual_file)) {
+ // Success.
+ mapping_index = i;
+ break;
+ }
+ }
+
+ if (mapping_index == -1) {
+ return NO_MAPPING;
+ }
+
+ // Iterate through all mappings with higher precedence and verify that none
+ // of them map this file to some other existing file.
+ for (int i = 0; i < mapping_index; i++) {
+ if (ApplyMapping(*virtual_file, mappings_[i].virtual_path,
+ mappings_[i].disk_path, shadowing_disk_file)) {
+ if (access(shadowing_disk_file->c_str(), F_OK) >= 0) {
+ // File exists.
+ return SHADOWED;
+ }
+ }
+ }
+ shadowing_disk_file->clear();
+
+ // Verify that we can open the file. Note that this also has the side-effect
+ // of verifying that we are not canonicalizing away any non-existent
+ // directories.
std::unique_ptr<io::ZeroCopyInputStream> stream(OpenDiskFile(disk_file));
- if (stream == NULL) {
- return CANNOT_OPEN;
- }
-
- return SUCCESS;
-}
-
+ if (stream == NULL) {
+ return CANNOT_OPEN;
+ }
+
+ return SUCCESS;
+}
+
bool DiskSourceTree::VirtualFileToDiskFile(const TProtoStringType& virtual_file,
TProtoStringType* disk_file) {
std::unique_ptr<io::ZeroCopyInputStream> stream(
- OpenVirtualFile(virtual_file, disk_file));
- return stream != NULL;
-}
-
+ OpenVirtualFile(virtual_file, disk_file));
+ return stream != NULL;
+}
+
io::ZeroCopyInputStream* DiskSourceTree::Open(const TProtoStringType& filename) {
- return OpenVirtualFile(filename, NULL);
-}
-
+ return OpenVirtualFile(filename, NULL);
+}
+
TProtoStringType DiskSourceTree::GetLastErrorMessage() {
- return last_error_message_;
-}
-
-io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
+ return last_error_message_;
+}
+
+io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(
const TProtoStringType& virtual_file, TProtoStringType* disk_file) {
- if (virtual_file != CanonicalizePath(virtual_file) ||
- ContainsParentReference(virtual_file)) {
- // We do not allow importing of paths containing things like ".." or
- // consecutive slashes since the compiler expects files to be uniquely
- // identified by file name.
+ if (virtual_file != CanonicalizePath(virtual_file) ||
+ ContainsParentReference(virtual_file)) {
+ // We do not allow importing of paths containing things like ".." or
+ // consecutive slashes since the compiler expects files to be uniquely
+ // identified by file name.
last_error_message_ =
"Backslashes, consecutive slashes, \".\", or \"..\" "
"are not allowed in the virtual path";
- return NULL;
- }
-
- for (int i = 0; i < mappings_.size(); i++) {
+ return NULL;
+ }
+
+ for (int i = 0; i < mappings_.size(); i++) {
TProtoStringType temp_disk_file;
- if (ApplyMapping(virtual_file, mappings_[i].virtual_path,
- mappings_[i].disk_path, &temp_disk_file)) {
- io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file);
- if (stream != NULL) {
- if (disk_file != NULL) {
- *disk_file = temp_disk_file;
- }
- return stream;
- }
-
- if (errno == EACCES) {
- // The file exists but is not readable.
+ if (ApplyMapping(virtual_file, mappings_[i].virtual_path,
+ mappings_[i].disk_path, &temp_disk_file)) {
+ io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file);
+ if (stream != NULL) {
+ if (disk_file != NULL) {
+ *disk_file = temp_disk_file;
+ }
+ return stream;
+ }
+
+ if (errno == EACCES) {
+ // The file exists but is not readable.
last_error_message_ =
"Read access is denied for file: " + temp_disk_file;
- return NULL;
- }
- }
- }
- last_error_message_ = "File not found.";
- return NULL;
-}
-
-io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
+ return NULL;
+ }
+ }
+ }
+ last_error_message_ = "File not found.";
+ return NULL;
+}
+
+io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
const TProtoStringType& filename) {
struct stat sb;
int ret = 0;
@@ -506,19 +506,19 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
return NULL;
}
#endif
- int file_descriptor;
- do {
- file_descriptor = open(filename.c_str(), O_RDONLY);
- } while (file_descriptor < 0 && errno == EINTR);
- if (file_descriptor >= 0) {
- io::FileInputStream* result = new io::FileInputStream(file_descriptor);
- result->SetCloseOnDelete(true);
- return result;
- } else {
- return NULL;
- }
-}
-
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ int file_descriptor;
+ do {
+ file_descriptor = open(filename.c_str(), O_RDONLY);
+ } while (file_descriptor < 0 && errno == EINTR);
+ if (file_descriptor >= 0) {
+ io::FileInputStream* result = new io::FileInputStream(file_descriptor);
+ result->SetCloseOnDelete(true);
+ return result;
+ } else {
+ return NULL;
+ }
+}
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
index 897ff1102b..f38fcf2d67 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h
@@ -1,336 +1,336 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// This file is the public interface to the .proto file parser.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
-#define GOOGLE_PROTOBUF_COMPILER_IMPORTER_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// This file is the public interface to the .proto file parser.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
+#define GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
+
#include <set>
#include <string>
#include <utility>
-#include <vector>
+#include <vector>
#include <google/protobuf/compiler/parser.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor_database.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-
+namespace google {
+namespace protobuf {
+
namespace io {
class ZeroCopyInputStream;
}
-
-namespace compiler {
-
-// Defined in this file.
-class Importer;
-class MultiFileErrorCollector;
-class SourceTree;
-class DiskSourceTree;
-
-// TODO(kenton): Move all SourceTree stuff to a separate file?
-
-// An implementation of DescriptorDatabase which loads files from a SourceTree
-// and parses them.
-//
-// Note: This class is not thread-safe since it maintains a table of source
-// code locations for error reporting. However, when a DescriptorPool wraps
-// a DescriptorDatabase, it uses mutex locking to make sure only one method
-// of the database is called at a time, even if the DescriptorPool is used
-// from multiple threads. Therefore, there is only a problem if you create
-// multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase
-// and use them from multiple threads.
-//
-// Note: This class does not implement FindFileContainingSymbol() or
-// FindFileContainingExtension(); these will always return false.
+
+namespace compiler {
+
+// Defined in this file.
+class Importer;
+class MultiFileErrorCollector;
+class SourceTree;
+class DiskSourceTree;
+
+// TODO(kenton): Move all SourceTree stuff to a separate file?
+
+// An implementation of DescriptorDatabase which loads files from a SourceTree
+// and parses them.
+//
+// Note: This class is not thread-safe since it maintains a table of source
+// code locations for error reporting. However, when a DescriptorPool wraps
+// a DescriptorDatabase, it uses mutex locking to make sure only one method
+// of the database is called at a time, even if the DescriptorPool is used
+// from multiple threads. Therefore, there is only a problem if you create
+// multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase
+// and use them from multiple threads.
+//
+// Note: This class does not implement FindFileContainingSymbol() or
+// FindFileContainingExtension(); these will always return false.
class PROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {
- public:
- SourceTreeDescriptorDatabase(SourceTree* source_tree);
+ public:
+ SourceTreeDescriptorDatabase(SourceTree* source_tree);
// If non-NULL, fallback_database will be checked if a file doesn't exist in
// the specified source_tree.
SourceTreeDescriptorDatabase(SourceTree* source_tree,
DescriptorDatabase* fallback_database);
- ~SourceTreeDescriptorDatabase();
-
- // Instructs the SourceTreeDescriptorDatabase to report any parse errors
- // to the given MultiFileErrorCollector. This should be called before
- // parsing. error_collector must remain valid until either this method
- // is called again or the SourceTreeDescriptorDatabase is destroyed.
- void RecordErrorsTo(MultiFileErrorCollector* error_collector) {
- error_collector_ = error_collector;
- }
-
- // Gets a DescriptorPool::ErrorCollector which records errors to the
- // MultiFileErrorCollector specified with RecordErrorsTo(). This collector
- // has the ability to determine exact line and column numbers of errors
- // from the information given to it by the DescriptorPool.
- DescriptorPool::ErrorCollector* GetValidationErrorCollector() {
- using_validation_error_collector_ = true;
- return &validation_error_collector_;
- }
-
- // implements DescriptorDatabase -----------------------------------
+ ~SourceTreeDescriptorDatabase();
+
+ // Instructs the SourceTreeDescriptorDatabase to report any parse errors
+ // to the given MultiFileErrorCollector. This should be called before
+ // parsing. error_collector must remain valid until either this method
+ // is called again or the SourceTreeDescriptorDatabase is destroyed.
+ void RecordErrorsTo(MultiFileErrorCollector* error_collector) {
+ error_collector_ = error_collector;
+ }
+
+ // Gets a DescriptorPool::ErrorCollector which records errors to the
+ // MultiFileErrorCollector specified with RecordErrorsTo(). This collector
+ // has the ability to determine exact line and column numbers of errors
+ // from the information given to it by the DescriptorPool.
+ DescriptorPool::ErrorCollector* GetValidationErrorCollector() {
+ using_validation_error_collector_ = true;
+ return &validation_error_collector_;
+ }
+
+ // implements DescriptorDatabase -----------------------------------
bool FindFileByName(const TProtoStringType& filename,
FileDescriptorProto* output) override;
bool FindFileContainingSymbol(const TProtoStringType& symbol_name,
FileDescriptorProto* output) override;
bool FindFileContainingExtension(const TProtoStringType& containing_type,
- int field_number,
+ int field_number,
FileDescriptorProto* output) override;
-
- private:
- class SingleFileErrorCollector;
-
- SourceTree* source_tree_;
+
+ private:
+ class SingleFileErrorCollector;
+
+ SourceTree* source_tree_;
DescriptorDatabase* fallback_database_;
- MultiFileErrorCollector* error_collector_;
-
+ MultiFileErrorCollector* error_collector_;
+
class PROTOBUF_EXPORT ValidationErrorCollector
: public DescriptorPool::ErrorCollector {
- public:
- ValidationErrorCollector(SourceTreeDescriptorDatabase* owner);
- ~ValidationErrorCollector();
-
- // implements ErrorCollector ---------------------------------------
+ public:
+ ValidationErrorCollector(SourceTreeDescriptorDatabase* owner);
+ ~ValidationErrorCollector();
+
+ // implements ErrorCollector ---------------------------------------
void AddError(const TProtoStringType& filename, const TProtoStringType& element_name,
const Message* descriptor, ErrorLocation location,
const TProtoStringType& message) override;
-
+
void AddWarning(const TProtoStringType& filename,
const TProtoStringType& element_name, const Message* descriptor,
ErrorLocation location,
const TProtoStringType& message) override;
-
- private:
- SourceTreeDescriptorDatabase* owner_;
- };
- friend class ValidationErrorCollector;
-
- bool using_validation_error_collector_;
- SourceLocationTable source_locations_;
- ValidationErrorCollector validation_error_collector_;
-};
-
-// Simple interface for parsing .proto files. This wraps the process
-// of opening the file, parsing it with a Parser, recursively parsing all its
-// imports, and then cross-linking the results to produce a FileDescriptor.
-//
-// This is really just a thin wrapper around SourceTreeDescriptorDatabase.
-// You may find that SourceTreeDescriptorDatabase is more flexible.
-//
-// TODO(kenton): I feel like this class is not well-named.
+
+ private:
+ SourceTreeDescriptorDatabase* owner_;
+ };
+ friend class ValidationErrorCollector;
+
+ bool using_validation_error_collector_;
+ SourceLocationTable source_locations_;
+ ValidationErrorCollector validation_error_collector_;
+};
+
+// Simple interface for parsing .proto files. This wraps the process
+// of opening the file, parsing it with a Parser, recursively parsing all its
+// imports, and then cross-linking the results to produce a FileDescriptor.
+//
+// This is really just a thin wrapper around SourceTreeDescriptorDatabase.
+// You may find that SourceTreeDescriptorDatabase is more flexible.
+//
+// TODO(kenton): I feel like this class is not well-named.
class PROTOBUF_EXPORT Importer {
- public:
+ public:
Importer(SourceTree* source_tree, MultiFileErrorCollector* error_collector);
- ~Importer();
-
- // Import the given file and build a FileDescriptor representing it. If
- // the file is already in the DescriptorPool, the existing FileDescriptor
- // will be returned. The FileDescriptor is property of the DescriptorPool,
- // and will remain valid until it is destroyed. If any errors occur, they
- // will be reported using the error collector and Import() will return NULL.
- //
- // A particular Importer object will only report errors for a particular
- // file once. All future attempts to import the same file will return NULL
- // without reporting any errors. The idea is that you might want to import
- // a lot of files without seeing the same errors over and over again. If
- // you want to see errors for the same files repeatedly, you can use a
- // separate Importer object to import each one (but use the same
- // DescriptorPool so that they can be cross-linked).
+ ~Importer();
+
+ // Import the given file and build a FileDescriptor representing it. If
+ // the file is already in the DescriptorPool, the existing FileDescriptor
+ // will be returned. The FileDescriptor is property of the DescriptorPool,
+ // and will remain valid until it is destroyed. If any errors occur, they
+ // will be reported using the error collector and Import() will return NULL.
+ //
+ // A particular Importer object will only report errors for a particular
+ // file once. All future attempts to import the same file will return NULL
+ // without reporting any errors. The idea is that you might want to import
+ // a lot of files without seeing the same errors over and over again. If
+ // you want to see errors for the same files repeatedly, you can use a
+ // separate Importer object to import each one (but use the same
+ // DescriptorPool so that they can be cross-linked).
const FileDescriptor* Import(const TProtoStringType& filename);
-
- // The DescriptorPool in which all imported FileDescriptors and their
- // contents are stored.
+
+ // The DescriptorPool in which all imported FileDescriptors and their
+ // contents are stored.
inline const DescriptorPool* pool() const { return &pool_; }
-
+
void AddUnusedImportTrackFile(const TProtoStringType& file_name,
bool is_error = false);
- void ClearUnusedImportTrackFiles();
-
-
- private:
- SourceTreeDescriptorDatabase database_;
- DescriptorPool pool_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Importer);
-};
-
-// If the importer encounters problems while trying to import the proto files,
-// it reports them to a MultiFileErrorCollector.
+ void ClearUnusedImportTrackFiles();
+
+
+ private:
+ SourceTreeDescriptorDatabase database_;
+ DescriptorPool pool_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Importer);
+};
+
+// If the importer encounters problems while trying to import the proto files,
+// it reports them to a MultiFileErrorCollector.
class PROTOBUF_EXPORT MultiFileErrorCollector {
- public:
- inline MultiFileErrorCollector() {}
- virtual ~MultiFileErrorCollector();
-
- // Line and column numbers are zero-based. A line number of -1 indicates
- // an error with the entire file (e.g. "not found").
+ public:
+ inline MultiFileErrorCollector() {}
+ virtual ~MultiFileErrorCollector();
+
+ // Line and column numbers are zero-based. A line number of -1 indicates
+ // an error with the entire file (e.g. "not found").
virtual void AddError(const TProtoStringType& filename, int line, int column,
const TProtoStringType& message) = 0;
-
+
virtual void AddWarning(const TProtoStringType& /* filename */, int /* line */,
int /* column */, const TProtoStringType& /* message */) {}
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector);
-};
-
-// Abstract interface which represents a directory tree containing proto files.
-// Used by the default implementation of Importer to resolve import statements
-// Most users will probably want to use the DiskSourceTree implementation,
-// below.
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector);
+};
+
+// Abstract interface which represents a directory tree containing proto files.
+// Used by the default implementation of Importer to resolve import statements
+// Most users will probably want to use the DiskSourceTree implementation,
+// below.
class PROTOBUF_EXPORT SourceTree {
- public:
- inline SourceTree() {}
- virtual ~SourceTree();
-
- // Open the given file and return a stream that reads it, or NULL if not
- // found. The caller takes ownership of the returned object. The filename
- // must be a path relative to the root of the source tree and must not
- // contain "." or ".." components.
+ public:
+ inline SourceTree() {}
+ virtual ~SourceTree();
+
+ // Open the given file and return a stream that reads it, or NULL if not
+ // found. The caller takes ownership of the returned object. The filename
+ // must be a path relative to the root of the source tree and must not
+ // contain "." or ".." components.
virtual io::ZeroCopyInputStream* Open(const TProtoStringType& filename) = 0;
-
- // If Open() returns NULL, calling this method immediately will return an
- // description of the error.
- // Subclasses should implement this method and return a meaningful value for
- // better error reporting.
- // TODO(xiaofeng): change this to a pure virtual function.
+
+ // If Open() returns NULL, calling this method immediately will return an
+ // description of the error.
+ // Subclasses should implement this method and return a meaningful value for
+ // better error reporting.
+ // TODO(xiaofeng): change this to a pure virtual function.
virtual TProtoStringType GetLastErrorMessage();
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree);
-};
-
-// An implementation of SourceTree which loads files from locations on disk.
-// Multiple mappings can be set up to map locations in the DiskSourceTree to
-// locations in the physical filesystem.
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree);
+};
+
+// An implementation of SourceTree which loads files from locations on disk.
+// Multiple mappings can be set up to map locations in the DiskSourceTree to
+// locations in the physical filesystem.
class PROTOBUF_EXPORT DiskSourceTree : public SourceTree {
- public:
- DiskSourceTree();
- ~DiskSourceTree();
-
- // Map a path on disk to a location in the SourceTree. The path may be
- // either a file or a directory. If it is a directory, the entire tree
- // under it will be mapped to the given virtual location. To map a directory
- // to the root of the source tree, pass an empty string for virtual_path.
- //
- // If multiple mapped paths apply when opening a file, they will be searched
- // in order. For example, if you do:
- // MapPath("bar", "foo/bar");
- // MapPath("", "baz");
- // and then you do:
- // Open("bar/qux");
- // the DiskSourceTree will first try to open foo/bar/qux, then baz/bar/qux,
+ public:
+ DiskSourceTree();
+ ~DiskSourceTree();
+
+ // Map a path on disk to a location in the SourceTree. The path may be
+ // either a file or a directory. If it is a directory, the entire tree
+ // under it will be mapped to the given virtual location. To map a directory
+ // to the root of the source tree, pass an empty string for virtual_path.
+ //
+ // If multiple mapped paths apply when opening a file, they will be searched
+ // in order. For example, if you do:
+ // MapPath("bar", "foo/bar");
+ // MapPath("", "baz");
+ // and then you do:
+ // Open("bar/qux");
+ // the DiskSourceTree will first try to open foo/bar/qux, then baz/bar/qux,
// returning the first one that opens successfully.
- //
- // disk_path may be an absolute path or relative to the current directory,
- // just like a path you'd pass to open().
+ //
+ // disk_path may be an absolute path or relative to the current directory,
+ // just like a path you'd pass to open().
void MapPath(const TProtoStringType& virtual_path, const TProtoStringType& disk_path);
-
- // Return type for DiskFileToVirtualFile().
- enum DiskFileToVirtualFileResult {
- SUCCESS,
- SHADOWED,
- CANNOT_OPEN,
- NO_MAPPING
- };
-
- // Given a path to a file on disk, find a virtual path mapping to that
- // file. The first mapping created with MapPath() whose disk_path contains
- // the filename is used. However, that virtual path may not actually be
- // usable to open the given file. Possible return values are:
- // * SUCCESS: The mapping was found. *virtual_file is filled in so that
- // calling Open(*virtual_file) will open the file named by disk_file.
- // * SHADOWED: A mapping was found, but using Open() to open this virtual
- // path will end up returning some different file. This is because some
- // other mapping with a higher precedence also matches this virtual path
- // and maps it to a different file that exists on disk. *virtual_file
- // is filled in as it would be in the SUCCESS case. *shadowing_disk_file
- // is filled in with the disk path of the file which would be opened if
- // you were to call Open(*virtual_file).
- // * CANNOT_OPEN: The mapping was found and was not shadowed, but the
- // file specified cannot be opened. When this value is returned,
- // errno will indicate the reason the file cannot be opened. *virtual_file
- // will be set to the virtual path as in the SUCCESS case, even though
- // it is not useful.
- // * NO_MAPPING: Indicates that no mapping was found which contains this
- // file.
+
+ // Return type for DiskFileToVirtualFile().
+ enum DiskFileToVirtualFileResult {
+ SUCCESS,
+ SHADOWED,
+ CANNOT_OPEN,
+ NO_MAPPING
+ };
+
+ // Given a path to a file on disk, find a virtual path mapping to that
+ // file. The first mapping created with MapPath() whose disk_path contains
+ // the filename is used. However, that virtual path may not actually be
+ // usable to open the given file. Possible return values are:
+ // * SUCCESS: The mapping was found. *virtual_file is filled in so that
+ // calling Open(*virtual_file) will open the file named by disk_file.
+ // * SHADOWED: A mapping was found, but using Open() to open this virtual
+ // path will end up returning some different file. This is because some
+ // other mapping with a higher precedence also matches this virtual path
+ // and maps it to a different file that exists on disk. *virtual_file
+ // is filled in as it would be in the SUCCESS case. *shadowing_disk_file
+ // is filled in with the disk path of the file which would be opened if
+ // you were to call Open(*virtual_file).
+ // * CANNOT_OPEN: The mapping was found and was not shadowed, but the
+ // file specified cannot be opened. When this value is returned,
+ // errno will indicate the reason the file cannot be opened. *virtual_file
+ // will be set to the virtual path as in the SUCCESS case, even though
+ // it is not useful.
+ // * NO_MAPPING: Indicates that no mapping was found which contains this
+ // file.
DiskFileToVirtualFileResult DiskFileToVirtualFile(
const TProtoStringType& disk_file, TProtoStringType* virtual_file,
TProtoStringType* shadowing_disk_file);
-
- // Given a virtual path, find the path to the file on disk.
- // Return true and update disk_file with the on-disk path if the file exists.
- // Return false and leave disk_file untouched if the file doesn't exist.
+
+ // Given a virtual path, find the path to the file on disk.
+ // Return true and update disk_file with the on-disk path if the file exists.
+ // Return false and leave disk_file untouched if the file doesn't exist.
bool VirtualFileToDiskFile(const TProtoStringType& virtual_file,
TProtoStringType* disk_file);
-
- // implements SourceTree -------------------------------------------
+
+ // implements SourceTree -------------------------------------------
io::ZeroCopyInputStream* Open(const TProtoStringType& filename) override;
-
+
TProtoStringType GetLastErrorMessage() override;
-
- private:
- struct Mapping {
+
+ private:
+ struct Mapping {
TProtoStringType virtual_path;
TProtoStringType disk_path;
-
+
inline Mapping(const TProtoStringType& virtual_path_param,
const TProtoStringType& disk_path_param)
: virtual_path(virtual_path_param), disk_path(disk_path_param) {}
- };
+ };
std::vector<Mapping> mappings_;
TProtoStringType last_error_message_;
-
- // Like Open(), but returns the on-disk path in disk_file if disk_file is
- // non-NULL and the file could be successfully opened.
+
+ // Like Open(), but returns the on-disk path in disk_file if disk_file is
+ // non-NULL and the file could be successfully opened.
io::ZeroCopyInputStream* OpenVirtualFile(const TProtoStringType& virtual_file,
TProtoStringType* disk_file);
-
- // Like Open() but given the actual on-disk path.
+
+ // Like Open() but given the actual on-disk path.
io::ZeroCopyInputStream* OpenDiskFile(const TProtoStringType& filename);
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree);
-};
-
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree);
+};
+
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
index 26ba96dcf0..3403cfca2c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc
@@ -1,202 +1,202 @@
-// 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/java/java_context.h>
-
+
#include <google/protobuf/compiler/java/java_field.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-Context::Context(const FileDescriptor* file, const Options& options)
- : name_resolver_(new ClassNameResolver), options_(options) {
- InitializeFieldGeneratorInfo(file);
-}
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+Context::Context(const FileDescriptor* file, const Options& options)
+ : name_resolver_(new ClassNameResolver), options_(options) {
+ InitializeFieldGeneratorInfo(file);
+}
+
Context::~Context() {}
-
+
ClassNameResolver* Context::GetNameResolver() const {
- return name_resolver_.get();
-}
-
-namespace {
-// Whether two fields have conflicting accessors (assuming name1 and name2
-// are different). name1 and name2 are field1 and field2's camel-case name
-// respectively.
+ return name_resolver_.get();
+}
+
+namespace {
+// Whether two fields have conflicting accessors (assuming name1 and name2
+// are different). name1 and name2 are field1 and field2's camel-case name
+// respectively.
bool IsConflicting(const FieldDescriptor* field1, const TProtoStringType& name1,
const FieldDescriptor* field2, const TProtoStringType& name2,
TProtoStringType* info) {
- if (field1->is_repeated()) {
- if (field2->is_repeated()) {
- // Both fields are repeated.
- return false;
- } else {
- // field1 is repeated, and field2 is not.
- if (name1 + "Count" == name2) {
- *info = "both repeated field \"" + field1->name() + "\" and singular " +
+ if (field1->is_repeated()) {
+ if (field2->is_repeated()) {
+ // Both fields are repeated.
+ return false;
+ } else {
+ // field1 is repeated, and field2 is not.
+ if (name1 + "Count" == name2) {
+ *info = "both repeated field \"" + field1->name() + "\" and singular " +
"field \"" + field2->name() + "\" generate the method \"" +
"get" + name1 + "Count()\"";
- return true;
- }
- if (name1 + "List" == name2) {
- *info = "both repeated field \"" + field1->name() + "\" and singular " +
+ return true;
+ }
+ if (name1 + "List" == name2) {
+ *info = "both repeated field \"" + field1->name() + "\" and singular " +
"field \"" + field2->name() + "\" generate the method \"" +
"get" + name1 + "List()\"";
- return true;
- }
- // Well, there are obviously many more conflicting cases, but it probably
- // doesn't worth the effort to exhaust all of them because they rarely
- // happen and as we are continuing adding new methods/changing existing
- // methods the number of different conflicting cases will keep growing.
- // We can just add more cases here when they are found in the real world.
- return false;
- }
- } else {
- if (field2->is_repeated()) {
- return IsConflicting(field2, name2, field1, name1, info);
- } else {
- // None of the two fields are repeated.
- return false;
- }
- }
-}
-} // namespace
-
-void Context::InitializeFieldGeneratorInfo(const FileDescriptor* file) {
- for (int i = 0; i < file->message_type_count(); ++i) {
- InitializeFieldGeneratorInfoForMessage(file->message_type(i));
- }
-}
-
-void Context::InitializeFieldGeneratorInfoForMessage(
- const Descriptor* message) {
- for (int i = 0; i < message->nested_type_count(); ++i) {
- InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
- }
+ return true;
+ }
+ // Well, there are obviously many more conflicting cases, but it probably
+ // doesn't worth the effort to exhaust all of them because they rarely
+ // happen and as we are continuing adding new methods/changing existing
+ // methods the number of different conflicting cases will keep growing.
+ // We can just add more cases here when they are found in the real world.
+ return false;
+ }
+ } else {
+ if (field2->is_repeated()) {
+ return IsConflicting(field2, name2, field1, name1, info);
+ } else {
+ // None of the two fields are repeated.
+ return false;
+ }
+ }
+}
+} // namespace
+
+void Context::InitializeFieldGeneratorInfo(const FileDescriptor* file) {
+ for (int i = 0; i < file->message_type_count(); ++i) {
+ InitializeFieldGeneratorInfoForMessage(file->message_type(i));
+ }
+}
+
+void Context::InitializeFieldGeneratorInfoForMessage(
+ const Descriptor* message) {
+ for (int i = 0; i < message->nested_type_count(); ++i) {
+ InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
+ }
std::vector<const FieldDescriptor*> fields;
fields.reserve(message->field_count());
- for (int i = 0; i < message->field_count(); ++i) {
- fields.push_back(message->field(i));
- }
- InitializeFieldGeneratorInfoForFields(fields);
-
- for (int i = 0; i < message->oneof_decl_count(); ++i) {
- const OneofDescriptor* oneof = message->oneof_decl(i);
- OneofGeneratorInfo info;
- info.name = UnderscoresToCamelCase(oneof->name(), false);
- info.capitalized_name = UnderscoresToCamelCase(oneof->name(), true);
- oneof_generator_info_map_[oneof] = info;
- }
-}
-
-void Context::InitializeFieldGeneratorInfoForFields(
+ for (int i = 0; i < message->field_count(); ++i) {
+ fields.push_back(message->field(i));
+ }
+ InitializeFieldGeneratorInfoForFields(fields);
+
+ for (int i = 0; i < message->oneof_decl_count(); ++i) {
+ const OneofDescriptor* oneof = message->oneof_decl(i);
+ OneofGeneratorInfo info;
+ info.name = UnderscoresToCamelCase(oneof->name(), false);
+ info.capitalized_name = UnderscoresToCamelCase(oneof->name(), true);
+ oneof_generator_info_map_[oneof] = info;
+ }
+}
+
+void Context::InitializeFieldGeneratorInfoForFields(
const std::vector<const FieldDescriptor*>& fields) {
- // Find out all fields that conflict with some other field in the same
- // message.
+ // Find out all fields that conflict with some other field in the same
+ // message.
std::vector<bool> is_conflict(fields.size());
std::vector<TProtoStringType> conflict_reason(fields.size());
- for (int i = 0; i < fields.size(); ++i) {
- const FieldDescriptor* field = fields[i];
+ for (int i = 0; i < fields.size(); ++i) {
+ const FieldDescriptor* field = fields[i];
const TProtoStringType& name = UnderscoresToCapitalizedCamelCase(field);
- for (int j = i + 1; j < fields.size(); ++j) {
- const FieldDescriptor* other = fields[j];
+ for (int j = i + 1; j < fields.size(); ++j) {
+ const FieldDescriptor* other = fields[j];
const TProtoStringType& other_name = UnderscoresToCapitalizedCamelCase(other);
- if (name == other_name) {
- is_conflict[i] = is_conflict[j] = true;
- conflict_reason[i] = conflict_reason[j] =
- "capitalized name of field \"" + field->name() +
- "\" conflicts with field \"" + other->name() + "\"";
- } else if (IsConflicting(field, name, other, other_name,
- &conflict_reason[j])) {
- is_conflict[i] = is_conflict[j] = true;
- conflict_reason[i] = conflict_reason[j];
- }
- }
- if (is_conflict[i]) {
- GOOGLE_LOG(WARNING) << "field \"" << field->full_name() << "\" is conflicting "
- << "with another field: " << conflict_reason[i];
- }
- }
- for (int i = 0; i < fields.size(); ++i) {
- const FieldDescriptor* field = fields[i];
- FieldGeneratorInfo info;
+ if (name == other_name) {
+ is_conflict[i] = is_conflict[j] = true;
+ conflict_reason[i] = conflict_reason[j] =
+ "capitalized name of field \"" + field->name() +
+ "\" conflicts with field \"" + other->name() + "\"";
+ } else if (IsConflicting(field, name, other, other_name,
+ &conflict_reason[j])) {
+ is_conflict[i] = is_conflict[j] = true;
+ conflict_reason[i] = conflict_reason[j];
+ }
+ }
+ if (is_conflict[i]) {
+ GOOGLE_LOG(WARNING) << "field \"" << field->full_name() << "\" is conflicting "
+ << "with another field: " << conflict_reason[i];
+ }
+ }
+ for (int i = 0; i < fields.size(); ++i) {
+ const FieldDescriptor* field = fields[i];
+ FieldGeneratorInfo info;
info.name = CamelCaseFieldName(field);
- info.capitalized_name = UnderscoresToCapitalizedCamelCase(field);
- // For fields conflicting with some other fields, we append the field
- // number to their field names in generated code to avoid conflicts.
- if (is_conflict[i]) {
+ info.capitalized_name = UnderscoresToCapitalizedCamelCase(field);
+ // For fields conflicting with some other fields, we append the field
+ // number to their field names in generated code to avoid conflicts.
+ if (is_conflict[i]) {
info.name += StrCat(field->number());
info.capitalized_name += StrCat(field->number());
- info.disambiguated_reason = conflict_reason[i];
- }
- field_generator_info_map_[field] = info;
- }
-}
-
-const FieldGeneratorInfo* Context::GetFieldGeneratorInfo(
- const FieldDescriptor* field) const {
- const FieldGeneratorInfo* result =
- FindOrNull(field_generator_info_map_, field);
- if (result == NULL) {
- GOOGLE_LOG(FATAL) << "Can not find FieldGeneratorInfo for field: "
- << field->full_name();
- }
- return result;
-}
-
-const OneofGeneratorInfo* Context::GetOneofGeneratorInfo(
- const OneofDescriptor* oneof) const {
- const OneofGeneratorInfo* result =
- FindOrNull(oneof_generator_info_map_, oneof);
- if (result == NULL) {
- GOOGLE_LOG(FATAL) << "Can not find OneofGeneratorInfo for oneof: "
- << oneof->name();
- }
- return result;
-}
-
-// Does this message class have generated parsing, serialization, and other
-// standard methods for which reflection-based fallback implementations exist?
-bool Context::HasGeneratedMethods(const Descriptor* descriptor) const {
- return options_.enforce_lite ||
- descriptor->file()->options().optimize_for() != FileOptions::CODE_SIZE;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ info.disambiguated_reason = conflict_reason[i];
+ }
+ field_generator_info_map_[field] = info;
+ }
+}
+
+const FieldGeneratorInfo* Context::GetFieldGeneratorInfo(
+ const FieldDescriptor* field) const {
+ const FieldGeneratorInfo* result =
+ FindOrNull(field_generator_info_map_, field);
+ if (result == NULL) {
+ GOOGLE_LOG(FATAL) << "Can not find FieldGeneratorInfo for field: "
+ << field->full_name();
+ }
+ return result;
+}
+
+const OneofGeneratorInfo* Context::GetOneofGeneratorInfo(
+ const OneofDescriptor* oneof) const {
+ const OneofGeneratorInfo* result =
+ FindOrNull(oneof_generator_info_map_, oneof);
+ if (result == NULL) {
+ GOOGLE_LOG(FATAL) << "Can not find OneofGeneratorInfo for oneof: "
+ << oneof->name();
+ }
+ return result;
+}
+
+// Does this message class have generated parsing, serialization, and other
+// standard methods for which reflection-based fallback implementations exist?
+bool Context::HasGeneratedMethods(const Descriptor* descriptor) const {
+ return options_.enforce_lite ||
+ descriptor->file()->options().optimize_for() != FileOptions::CODE_SIZE;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h
index 4c54a2c414..3fa6af1778 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h
@@ -1,45 +1,45 @@
-// 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_JAVA_CONTEXT_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
-
-#include <map>
-#include <memory>
-#include <vector>
-
+// 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_JAVA_CONTEXT_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
+
+#include <map>
+#include <memory>
+#include <vector>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_options.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FileDescriptor;
class FieldDescriptor;
class OneofDescriptor;
@@ -50,64 +50,64 @@ namespace java {
class ClassNameResolver; // name_resolver.h
}
} // namespace compiler
-} // namespace protobuf
+} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-struct FieldGeneratorInfo;
-struct OneofGeneratorInfo;
-// A context object holds the information that is shared among all code
-// generators.
-class Context {
- public:
- Context(const FileDescriptor* file, const Options& options);
- ~Context();
-
- // Get the name resolver associated with this context. The resolver
- // can be used to map descriptors to Java class names.
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+struct FieldGeneratorInfo;
+struct OneofGeneratorInfo;
+// A context object holds the information that is shared among all code
+// generators.
+class Context {
+ public:
+ Context(const FileDescriptor* file, const Options& options);
+ ~Context();
+
+ // Get the name resolver associated with this context. The resolver
+ // can be used to map descriptors to Java class names.
ClassNameResolver* GetNameResolver() const;
-
- // Get the FieldGeneratorInfo for a given field.
- const FieldGeneratorInfo* GetFieldGeneratorInfo(
- const FieldDescriptor* field) const;
-
- // Get the OneofGeneratorInfo for a given oneof.
- const OneofGeneratorInfo* GetOneofGeneratorInfo(
- const OneofDescriptor* oneof) const;
-
- const Options& options() const { return options_; }
-
- // Enforces all the files (including transitive dependencies) to use
- // LiteRuntime.
-
- bool EnforceLite() const { return options_.enforce_lite; }
-
- // Does this message class have generated parsing, serialization, and other
- // standard methods for which reflection-based fallback implementations exist?
- bool HasGeneratedMethods(const Descriptor* descriptor) const;
-
- private:
- void InitializeFieldGeneratorInfo(const FileDescriptor* file);
- void InitializeFieldGeneratorInfoForMessage(const Descriptor* message);
- void InitializeFieldGeneratorInfoForFields(
+
+ // Get the FieldGeneratorInfo for a given field.
+ const FieldGeneratorInfo* GetFieldGeneratorInfo(
+ const FieldDescriptor* field) const;
+
+ // Get the OneofGeneratorInfo for a given oneof.
+ const OneofGeneratorInfo* GetOneofGeneratorInfo(
+ const OneofDescriptor* oneof) const;
+
+ const Options& options() const { return options_; }
+
+ // Enforces all the files (including transitive dependencies) to use
+ // LiteRuntime.
+
+ bool EnforceLite() const { return options_.enforce_lite; }
+
+ // Does this message class have generated parsing, serialization, and other
+ // standard methods for which reflection-based fallback implementations exist?
+ bool HasGeneratedMethods(const Descriptor* descriptor) const;
+
+ private:
+ void InitializeFieldGeneratorInfo(const FileDescriptor* file);
+ void InitializeFieldGeneratorInfoForMessage(const Descriptor* message);
+ void InitializeFieldGeneratorInfoForFields(
const std::vector<const FieldDescriptor*>& fields);
-
+
std::unique_ptr<ClassNameResolver> name_resolver_;
std::map<const FieldDescriptor*, FieldGeneratorInfo>
field_generator_info_map_;
std::map<const OneofDescriptor*, OneofGeneratorInfo>
oneof_generator_info_map_;
- Options options_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ Options options_;
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
index db7737a149..51a85cdc7c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc
@@ -1,191 +1,191 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_doc_comment.h>
-
-#include <vector>
-
+
+#include <vector>
+
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
TProtoStringType EscapeJavadoc(const TProtoStringType& input) {
TProtoStringType result;
- result.reserve(input.size() * 2);
-
- char prev = '*';
-
+ result.reserve(input.size() * 2);
+
+ char prev = '*';
+
for (TProtoStringType::size_type i = 0; i < input.size(); i++) {
- char c = input[i];
- switch (c) {
- case '*':
- // Avoid "/*".
- if (prev == '/') {
- result.append("&#42;");
- } else {
- result.push_back(c);
- }
- break;
- case '/':
- // Avoid "*/".
- if (prev == '*') {
- result.append("&#47;");
- } else {
- result.push_back(c);
- }
- break;
- case '@':
- // '@' starts javadoc tags including the @deprecated tag, which will
- // cause a compile-time error if inserted before a declaration that
- // does not have a corresponding @Deprecated annotation.
- result.append("&#64;");
- break;
- case '<':
- // Avoid interpretation as HTML.
- result.append("&lt;");
- break;
- case '>':
- // Avoid interpretation as HTML.
- result.append("&gt;");
- break;
- case '&':
- // Avoid interpretation as HTML.
- result.append("&amp;");
- break;
- case '\\':
- // Java interprets Unicode escape sequences anywhere!
- result.append("&#92;");
- break;
- default:
- result.push_back(c);
- break;
- }
-
- prev = c;
- }
-
- return result;
-}
-
+ char c = input[i];
+ switch (c) {
+ case '*':
+ // Avoid "/*".
+ if (prev == '/') {
+ result.append("&#42;");
+ } else {
+ result.push_back(c);
+ }
+ break;
+ case '/':
+ // Avoid "*/".
+ if (prev == '*') {
+ result.append("&#47;");
+ } else {
+ result.push_back(c);
+ }
+ break;
+ case '@':
+ // '@' starts javadoc tags including the @deprecated tag, which will
+ // cause a compile-time error if inserted before a declaration that
+ // does not have a corresponding @Deprecated annotation.
+ result.append("&#64;");
+ break;
+ case '<':
+ // Avoid interpretation as HTML.
+ result.append("&lt;");
+ break;
+ case '>':
+ // Avoid interpretation as HTML.
+ result.append("&gt;");
+ break;
+ case '&':
+ // Avoid interpretation as HTML.
+ result.append("&amp;");
+ break;
+ case '\\':
+ // Java interprets Unicode escape sequences anywhere!
+ result.append("&#92;");
+ break;
+ default:
+ result.push_back(c);
+ break;
+ }
+
+ prev = c;
+ }
+
+ return result;
+}
+
static void WriteDocCommentBodyForLocation(io::Printer* printer,
const SourceLocation& location) {
TProtoStringType comments = location.leading_comments.empty()
? location.trailing_comments
: location.leading_comments;
- if (!comments.empty()) {
- // TODO(kenton): Ideally we should parse the comment text as Markdown and
- // write it back as HTML, but this requires a Markdown parser. For now
- // we just use <pre> to get fixed-width text formatting.
-
- // If the comment itself contains block comment start or end markers,
- // HTML-escape them so that they don't accidentally close the doc comment.
- comments = EscapeJavadoc(comments);
-
+ if (!comments.empty()) {
+ // TODO(kenton): Ideally we should parse the comment text as Markdown and
+ // write it back as HTML, but this requires a Markdown parser. For now
+ // we just use <pre> to get fixed-width text formatting.
+
+ // If the comment itself contains block comment start or end markers,
+ // HTML-escape them so that they don't accidentally close the doc comment.
+ comments = EscapeJavadoc(comments);
+
std::vector<TProtoStringType> lines = Split(comments, "\n");
- while (!lines.empty() && lines.back().empty()) {
- lines.pop_back();
- }
-
- printer->Print(" * <pre>\n");
- for (int i = 0; i < lines.size(); i++) {
- // Most lines should start with a space. Watch out for lines that start
- // with a /, since putting that right after the leading asterisk will
- // close the comment.
- if (!lines[i].empty() && lines[i][0] == '/') {
- printer->Print(" * $line$\n", "line", lines[i]);
- } else {
- printer->Print(" *$line$\n", "line", lines[i]);
- }
- }
- printer->Print(
- " * </pre>\n"
- " *\n");
- }
-}
-
-template <typename DescriptorType>
+ while (!lines.empty() && lines.back().empty()) {
+ lines.pop_back();
+ }
+
+ printer->Print(" * <pre>\n");
+ for (int i = 0; i < lines.size(); i++) {
+ // Most lines should start with a space. Watch out for lines that start
+ // with a /, since putting that right after the leading asterisk will
+ // close the comment.
+ if (!lines[i].empty() && lines[i][0] == '/') {
+ printer->Print(" * $line$\n", "line", lines[i]);
+ } else {
+ printer->Print(" *$line$\n", "line", lines[i]);
+ }
+ }
+ printer->Print(
+ " * </pre>\n"
+ " *\n");
+ }
+}
+
+template <typename DescriptorType>
static void WriteDocCommentBody(io::Printer* printer,
const DescriptorType* descriptor) {
- SourceLocation location;
- if (descriptor->GetSourceLocation(&location)) {
- WriteDocCommentBodyForLocation(printer, location);
- }
-}
-
+ SourceLocation location;
+ if (descriptor->GetSourceLocation(&location)) {
+ WriteDocCommentBodyForLocation(printer, location);
+ }
+}
+
static TProtoStringType FirstLineOf(const TProtoStringType& value) {
TProtoStringType result = value;
-
+
TProtoStringType::size_type pos = result.find_first_of('\n');
if (pos != TProtoStringType::npos) {
- result.erase(pos);
- }
-
- // If line ends in an opening brace, make it "{ ... }" so it looks nice.
- if (!result.empty() && result[result.size() - 1] == '{') {
- result.append(" ... }");
- }
-
- return result;
-}
-
-void WriteMessageDocComment(io::Printer* printer, const Descriptor* message) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, message);
- printer->Print(
+ result.erase(pos);
+ }
+
+ // If line ends in an opening brace, make it "{ ... }" so it looks nice.
+ if (!result.empty() && result[result.size() - 1] == '{') {
+ result.append(" ... }");
+ }
+
+ return result;
+}
+
+void WriteMessageDocComment(io::Printer* printer, const Descriptor* message) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, message);
+ printer->Print(
" * Protobuf type {@code $fullname$}\n"
" */\n",
"fullname", EscapeJavadoc(message->full_name()));
-}
-
-void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) {
- // We start the comment with the main body based on the comments from the
+}
+
+void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) {
+ // We start the comment with the main body based on the comments from the
// .proto file (if present). We then continue with the field declaration,
// e.g.:
- // optional string foo = 5;
+ // optional string foo = 5;
// And then we end with the javadoc tags if applicable.
- // If the field is a group, the debug string might end with {.
- printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
+ // If the field is a group, the debug string might end with {.
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, field);
printer->Print(" * <code>$def$</code>\n", "def",
EscapeJavadoc(FirstLineOf(field->DebugString())));
- printer->Print(" */\n");
-}
-
+ printer->Print(" */\n");
+}
+
void WriteFieldAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
@@ -371,46 +371,46 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
// Enum
-void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, enum_);
- printer->Print(
+void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, enum_);
+ printer->Print(
" * Protobuf enum {@code $fullname$}\n"
" */\n",
"fullname", EscapeJavadoc(enum_->full_name()));
-}
-
-void WriteEnumValueDocComment(io::Printer* printer,
- const EnumValueDescriptor* value) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, value);
- printer->Print(
+}
+
+void WriteEnumValueDocComment(io::Printer* printer,
+ const EnumValueDescriptor* value) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, value);
+ printer->Print(
" * <code>$def$</code>\n"
" */\n",
"def", EscapeJavadoc(FirstLineOf(value->DebugString())));
-}
-
-void WriteServiceDocComment(io::Printer* printer,
- const ServiceDescriptor* service) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, service);
- printer->Print(
+}
+
+void WriteServiceDocComment(io::Printer* printer,
+ const ServiceDescriptor* service) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, service);
+ printer->Print(
" * Protobuf service {@code $fullname$}\n"
" */\n",
"fullname", EscapeJavadoc(service->full_name()));
-}
-
-void WriteMethodDocComment(io::Printer* printer,
- const MethodDescriptor* method) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, method);
- printer->Print(
+}
+
+void WriteMethodDocComment(io::Printer* printer,
+ const MethodDescriptor* method) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, method);
+ printer->Print(
" * <code>$def$</code>\n"
" */\n",
"def", EscapeJavadoc(FirstLineOf(method->DebugString())));
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
index 14903ad1bc..e7faa4a6a0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h
@@ -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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
+
#include <google/protobuf/descriptor.h>
-
+
#include <google/protobuf/port_def.inc>
-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 java {
-
+namespace protobuf {
+namespace compiler {
+namespace java {
+
enum FieldAccessorType {
HAZZER,
GETTER,
@@ -66,8 +66,8 @@ enum FieldAccessorType {
LIST_MULTI_ADDER
};
-void WriteMessageDocComment(io::Printer* printer, const Descriptor* message);
-void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field);
+void WriteMessageDocComment(io::Printer* printer, const Descriptor* message);
+void WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field);
void WriteFieldAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
@@ -80,22 +80,22 @@ void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
const FieldDescriptor* field,
const FieldAccessorType type,
const bool builder = false);
-void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_);
-void WriteEnumValueDocComment(io::Printer* printer,
- const EnumValueDescriptor* value);
-void WriteServiceDocComment(io::Printer* printer,
- const ServiceDescriptor* service);
-void WriteMethodDocComment(io::Printer* printer,
- const MethodDescriptor* method);
-
-// Exposed for testing only.
+void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_);
+void WriteEnumValueDocComment(io::Printer* printer,
+ const EnumValueDescriptor* value);
+void WriteServiceDocComment(io::Printer* printer,
+ const ServiceDescriptor* service);
+void WriteMethodDocComment(io::Printer* printer,
+ const MethodDescriptor* method);
+
+// Exposed for testing only.
PROTOC_EXPORT TProtoStringType EscapeJavadoc(const TProtoStringType& input);
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
index 99948b9edd..d9070eeaab 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc
@@ -1,40 +1,40 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -43,138 +43,138 @@
#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 java {
-
-EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
bool immutable_api, Context* context)
: descriptor_(descriptor),
immutable_api_(immutable_api),
context_(context),
name_resolver_(context->GetNameResolver()) {
- for (int i = 0; i < descriptor_->value_count(); i++) {
- const EnumValueDescriptor* value = descriptor_->value(i);
- const EnumValueDescriptor* canonical_value =
+ for (int i = 0; i < descriptor_->value_count(); i++) {
+ const EnumValueDescriptor* value = descriptor_->value(i);
+ const EnumValueDescriptor* canonical_value =
descriptor_->FindValueByNumber(value->number());
-
- if (value == canonical_value) {
- canonical_values_.push_back(value);
- } else {
- Alias alias;
- alias.value = value;
- alias.canonical_value = canonical_value;
- aliases_.push_back(alias);
- }
- }
-}
-
-EnumGenerator::~EnumGenerator() {}
-
-void EnumGenerator::Generate(io::Printer* printer) {
- WriteEnumDocComment(printer, descriptor_);
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
- printer->Print(
+
+ if (value == canonical_value) {
+ canonical_values_.push_back(value);
+ } else {
+ Alias alias;
+ alias.value = value;
+ alias.canonical_value = canonical_value;
+ aliases_.push_back(alias);
+ }
+ }
+}
+
+EnumGenerator::~EnumGenerator() {}
+
+void EnumGenerator::Generate(io::Printer* printer) {
+ WriteEnumDocComment(printer, descriptor_);
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
+ printer->Print(
"$deprecation$public enum $classname$\n"
- " implements com.google.protobuf.ProtocolMessageEnum {\n",
+ " implements com.google.protobuf.ProtocolMessageEnum {\n",
"classname", descriptor_->name(), "deprecation",
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "");
- printer->Annotate("classname", descriptor_);
- printer->Indent();
-
- bool ordinal_is_index = true;
+ printer->Annotate("classname", descriptor_);
+ printer->Indent();
+
+ bool ordinal_is_index = true;
TProtoStringType index_text = "ordinal()";
- for (int i = 0; i < canonical_values_.size(); i++) {
- if (canonical_values_[i]->index() != i) {
- ordinal_is_index = false;
- index_text = "index";
- break;
- }
- }
-
- for (int i = 0; i < canonical_values_.size(); i++) {
+ for (int i = 0; i < canonical_values_.size(); i++) {
+ if (canonical_values_[i]->index() != i) {
+ ordinal_is_index = false;
+ index_text = "index";
+ break;
+ }
+ }
+
+ for (int i = 0; i < canonical_values_.size(); i++) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["name"] = canonical_values_[i]->name();
+ vars["name"] = canonical_values_[i]->name();
vars["index"] = StrCat(canonical_values_[i]->index());
vars["number"] = StrCat(canonical_values_[i]->number());
- WriteEnumValueDocComment(printer, canonical_values_[i]);
- if (canonical_values_[i]->options().deprecated()) {
- printer->Print("@java.lang.Deprecated\n");
- }
- if (ordinal_is_index) {
+ WriteEnumValueDocComment(printer, canonical_values_[i]);
+ if (canonical_values_[i]->options().deprecated()) {
+ printer->Print("@java.lang.Deprecated\n");
+ }
+ if (ordinal_is_index) {
printer->Print(vars, "$name$($number$),\n");
- } else {
+ } else {
printer->Print(vars, "$name$($index$, $number$),\n");
- }
+ }
printer->Annotate("name", canonical_values_[i]);
- }
-
- if (SupportUnknownEnumValue(descriptor_->file())) {
- if (ordinal_is_index) {
+ }
+
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (ordinal_is_index) {
printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", "");
- } else {
+ } else {
printer->Print("${$UNRECOGNIZED$}$(-1, -1),\n", "{", "", "}", "");
- }
+ }
printer->Annotate("{", "}", descriptor_);
- }
-
- printer->Print(
+ }
+
+ printer->Print(
";\n"
"\n");
-
- // -----------------------------------------------------------------
-
- for (int i = 0; i < aliases_.size(); i++) {
+
+ // -----------------------------------------------------------------
+
+ for (int i = 0; i < aliases_.size(); i++) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["classname"] = descriptor_->name();
- vars["name"] = aliases_[i].value->name();
- vars["canonical_name"] = aliases_[i].canonical_value->name();
- WriteEnumValueDocComment(printer, aliases_[i].value);
+ vars["classname"] = descriptor_->name();
+ vars["name"] = aliases_[i].value->name();
+ vars["canonical_name"] = aliases_[i].canonical_value->name();
+ WriteEnumValueDocComment(printer, aliases_[i].value);
printer->Print(
vars, "public static final $classname$ $name$ = $canonical_name$;\n");
printer->Annotate("name", aliases_[i].value);
- }
-
- for (int i = 0; i < descriptor_->value_count(); i++) {
+ }
+
+ for (int i = 0; i < descriptor_->value_count(); i++) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["name"] = descriptor_->value(i)->name();
+ vars["name"] = descriptor_->value(i)->name();
vars["number"] = StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
vars["deprecation"] = descriptor_->value(i)->options().deprecated()
? "@java.lang.Deprecated "
: "";
- WriteEnumValueDocComment(printer, descriptor_->value(i));
- printer->Print(vars,
+ WriteEnumValueDocComment(printer, descriptor_->value(i));
+ printer->Print(vars,
"$deprecation$public static final int ${$$name$_VALUE$}$ = "
"$number$;\n");
printer->Annotate("{", "}", descriptor_->value(i));
- }
- printer->Print("\n");
-
- // -----------------------------------------------------------------
-
- printer->Print(
+ }
+ printer->Print("\n");
+
+ // -----------------------------------------------------------------
+
+ printer->Print(
"\n"
"public final int getNumber() {\n");
- if (SupportUnknownEnumValue(descriptor_->file())) {
- if (ordinal_is_index) {
- printer->Print(
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (ordinal_is_index) {
+ printer->Print(
" if (this == UNRECOGNIZED) {\n"
" throw new java.lang.IllegalArgumentException(\n"
" \"Can't get the number of an unknown enum value.\");\n"
" }\n");
- } else {
- printer->Print(
+ } else {
+ printer->Print(
" if (index == -1) {\n"
" throw new java.lang.IllegalArgumentException(\n"
" \"Can't get the number of an unknown enum value.\");\n"
" }\n");
- }
- }
- printer->Print(
+ }
+ }
+ printer->Print(
" return value;\n"
"}\n"
"\n"
@@ -197,18 +197,18 @@ void EnumGenerator::Generate(io::Printer* printer) {
"public static $classname$ forNumber(int value) {\n"
" switch (value) {\n",
"classname", descriptor_->name());
- printer->Indent();
- printer->Indent();
-
- for (int i = 0; i < canonical_values_.size(); i++) {
+ printer->Indent();
+ printer->Indent();
+
+ for (int i = 0; i < canonical_values_.size(); i++) {
printer->Print("case $number$: return $name$;\n", "name",
canonical_values_[i]->name(), "number",
StrCat(canonical_values_[i]->number()));
- }
-
- printer->Outdent();
- printer->Outdent();
- printer->Print(
+ }
+
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
" default: return null;\n"
" }\n"
"}\n"
@@ -226,12 +226,12 @@ void EnumGenerator::Generate(io::Printer* printer) {
" };\n"
"\n",
"classname", descriptor_->name());
-
- // -----------------------------------------------------------------
- // Reflection
-
- if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) {
- printer->Print(
+
+ // -----------------------------------------------------------------
+ // Reflection
+
+ if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) {
+ printer->Print(
"public final com.google.protobuf.Descriptors.EnumValueDescriptor\n"
" getValueDescriptor() {\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
@@ -261,11 +261,11 @@ void EnumGenerator::Generate(io::Printer* printer) {
"public static final com.google.protobuf.Descriptors.EnumDescriptor\n"
" getDescriptor() {\n",
"index_text", index_text);
-
- // TODO(kenton): Cache statically? Note that we can't access descriptors
- // at module init time because it wouldn't work with descriptor.proto, but
- // we can cache the value the first time getDescriptor() is called.
- if (descriptor_->containing_type() == NULL) {
+
+ // TODO(kenton): Cache statically? Note that we can't access descriptors
+ // at module init time because it wouldn't work with descriptor.proto, but
+ // we can cache the value the first time getDescriptor() is called.
+ if (descriptor_->containing_type() == NULL) {
// The class generated for the File fully populates the descriptor with
// extensions in both the mutable and immutable cases. (In the mutable api
// this is accomplished by attempting to load the immutable outer class).
@@ -274,9 +274,9 @@ void EnumGenerator::Generate(io::Printer* printer) {
"file",
name_resolver_->GetClassName(descriptor_->file(), immutable_api_),
"index", StrCat(descriptor_->index()));
- } else {
- printer->Print(
- " return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
+ } else {
+ printer->Print(
+ " return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
"parent",
name_resolver_->GetClassName(descriptor_->containing_type(),
immutable_api_),
@@ -287,40 +287,40 @@ void EnumGenerator::Generate(io::Printer* printer) {
? "getDefaultInstance().getDescriptorForType()"
: "getDescriptor()",
"index", StrCat(descriptor_->index()));
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"}\n"
"\n"
"private static final $classname$[] VALUES = ",
"classname", descriptor_->name());
-
- if (CanUseEnumValues()) {
- // If the constants we are going to output are exactly the ones we
- // have declared in the Java enum in the same order, then we can use
- // the values() method that the Java compiler automatically generates
- // for every enum.
- printer->Print("values();\n");
- } else {
+
+ if (CanUseEnumValues()) {
+ // If the constants we are going to output are exactly the ones we
+ // have declared in the Java enum in the same order, then we can use
+ // the values() method that the Java compiler automatically generates
+ // for every enum.
+ printer->Print("values();\n");
+ } else {
printer->Print("getStaticValuesArray();\n");
printer->Print("private static $classname$[] getStaticValuesArray() {\n",
"classname", descriptor_->name());
printer->Indent();
- printer->Print(
+ printer->Print(
"return new $classname$[] {\n"
" ",
"classname", descriptor_->name());
- for (int i = 0; i < descriptor_->value_count(); i++) {
+ for (int i = 0; i < descriptor_->value_count(); i++) {
printer->Print("$name$, ", "name", descriptor_->value(i)->name());
- }
- printer->Print(
- "\n"
- "};\n");
+ }
+ printer->Print(
+ "\n"
+ "};\n");
printer->Outdent();
printer->Print("}");
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"\n"
"public static $classname$ valueOf(\n"
" com.google.protobuf.Descriptors.EnumValueDescriptor desc) {\n"
@@ -329,63 +329,63 @@ void EnumGenerator::Generate(io::Printer* printer) {
" \"EnumValueDescriptor is not for this type.\");\n"
" }\n",
"classname", descriptor_->name());
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
" if (desc.getIndex() == -1) {\n"
" return UNRECOGNIZED;\n"
" }\n");
- }
- printer->Print(
+ }
+ printer->Print(
" return VALUES[desc.getIndex()];\n"
"}\n"
"\n");
-
- if (!ordinal_is_index) {
- printer->Print("private final int index;\n");
- }
- }
-
- // -----------------------------------------------------------------
-
+
+ if (!ordinal_is_index) {
+ printer->Print("private final int index;\n");
+ }
+ }
+
+ // -----------------------------------------------------------------
+
printer->Print("private final int value;\n\n");
-
- if (ordinal_is_index) {
+
+ if (ordinal_is_index) {
printer->Print("private $classname$(int value) {\n", "classname",
descriptor_->name());
- } else {
+ } else {
printer->Print("private $classname$(int index, int value) {\n", "classname",
descriptor_->name());
- }
- if (HasDescriptorMethods(descriptor_, context_->EnforceLite()) &&
- !ordinal_is_index) {
- printer->Print(" this.index = index;\n");
- }
- printer->Print(
+ }
+ if (HasDescriptorMethods(descriptor_, context_->EnforceLite()) &&
+ !ordinal_is_index) {
+ printer->Print(" this.index = index;\n");
+ }
+ printer->Print(
" this.value = value;\n"
"}\n");
-
- printer->Print(
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(enum_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-bool EnumGenerator::CanUseEnumValues() {
- if (canonical_values_.size() != descriptor_->value_count()) {
- return false;
- }
- for (int i = 0; i < descriptor_->value_count(); i++) {
- if (descriptor_->value(i)->name() != canonical_values_[i]->name()) {
- return false;
- }
- }
- return true;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+bool EnumGenerator::CanUseEnumValues() {
+ if (canonical_values_.size() != descriptor_->value_count()) {
+ return false;
+ }
+ for (int i = 0; i < descriptor_->value_count(); i++) {
+ if (descriptor_->value(i)->name() != canonical_values_[i]->name()) {
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h
index 8974f8f005..0a2c363b53 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
+
#include <string>
-#include <vector>
+#include <vector>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,52 +49,52 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class EnumGenerator {
- public:
- EnumGenerator(const EnumDescriptor* descriptor, bool immutable_api,
- Context* context);
- ~EnumGenerator();
-
- void Generate(io::Printer* printer);
-
- private:
- const EnumDescriptor* descriptor_;
-
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class EnumGenerator {
+ public:
+ EnumGenerator(const EnumDescriptor* descriptor, bool immutable_api,
+ Context* context);
+ ~EnumGenerator();
+
+ void Generate(io::Printer* printer);
+
+ private:
+ const EnumDescriptor* descriptor_;
+
// The proto language allows multiple enum constants to have the same
// numeric value. Java, however, does not allow multiple enum constants to
// be considered equivalent. We treat the first defined constant for any
- // given numeric value as "canonical" and the rest as aliases of that
- // canonical value.
+ // given numeric value as "canonical" and the rest as aliases of that
+ // canonical value.
std::vector<const EnumValueDescriptor*> canonical_values_;
-
- struct Alias {
- const EnumValueDescriptor* value;
- const EnumValueDescriptor* canonical_value;
- };
+
+ struct Alias {
+ const EnumValueDescriptor* value;
+ const EnumValueDescriptor* canonical_value;
+ };
std::vector<Alias> aliases_;
-
- bool immutable_api_;
-
- Context* context_;
- ClassNameResolver* name_resolver_;
-
- bool CanUseEnumValues();
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ bool immutable_api_;
+
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+
+ bool CanUseEnumValues();
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc
index dd0400414a..318c820198 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_enum_field.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -47,34 +47,34 @@
#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 java {
-
-namespace {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- (*variables)["type"] =
- name_resolver->GetImmutableClassName(descriptor->enum_type());
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ (*variables)["type"] =
+ name_resolver->GetImmutableClassName(descriptor->enum_type());
(*variables)["kt_type"] = (*variables)["type"];
- (*variables)["mutable_type"] =
- name_resolver->GetMutableClassName(descriptor->enum_type());
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["mutable_type"] =
+ name_resolver->GetMutableClassName(descriptor->enum_type());
+ (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] =
StrCat(descriptor->default_value_enum()->number());
(*variables)["tag"] = StrCat(
static_cast<int32_t>(internal::WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = StrCat(
- internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -82,123 +82,123 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
- (*variables)["on_changed"] = "onChanged();";
- // Use deprecated valueOf() method to be compatible with old generated code
- // for v2.5.0/v2.6.1.
- // TODO(xiaofeng): Use "forNumber" when we no longer support compatibility
+ (*variables)["on_changed"] = "onChanged();";
+ // Use deprecated valueOf() method to be compatible with old generated code
+ // for v2.5.0/v2.6.1.
+ // TODO(xiaofeng): Use "forNumber" when we no longer support compatibility
// with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations.
- (*variables)["for_number"] = "valueOf";
-
+ (*variables)["for_number"] = "valueOf";
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
- (*variables)["is_field_present_message"] =
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["set_has_field_bit_builder"] =
+ GenerateSetBit(builderBitIndex) + ";";
+ (*variables)["clear_has_field_bit_builder"] =
+ GenerateClearBit(builderBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["set_has_field_bit_builder"] = "";
+ (*variables)["clear_has_field_bit_builder"] = "";
+
+ (*variables)["is_field_present_message"] =
(*variables)["name"] + "_ != " + (*variables)["default"] +
".getNumber()";
- }
-
+ }
+
// For repeated builders, one bit is used for whether the array is immutable.
- (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
- (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
- (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
-
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-
- if (SupportUnknownEnumValue(descriptor->file())) {
- (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED";
- } else {
- (*variables)["unknown"] = (*variables)["default"];
- }
-}
-
-} // namespace
-
-// ===================================================================
-
+ (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
+ (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
+
+ // For repeated fields, one bit is used for whether the array is immutable
+ // in the parsing constructor.
+ (*variables)["get_mutable_bit_parser"] =
+ GenerateGetBitMutableLocal(builderBitIndex);
+ (*variables)["set_mutable_bit_parser"] =
+ GenerateSetBitMutableLocal(builderBitIndex);
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+
+ if (SupportUnknownEnumValue(descriptor->file())) {
+ (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED";
+ } else {
+ (*variables)["unknown"] = (*variables)["default"];
+ }
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutableEnumFieldGenerator::ImmutableEnumFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
+ SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
&variables_);
-}
-
-ImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {}
-
-int ImmutableEnumFieldGenerator::GetNumBitsForMessage() const {
+}
+
+ImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {}
+
+int ImmutableEnumFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
-int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
+}
+
+int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
return GetNumBitsForMessage();
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$boolean has$capitalized_name$();\n");
- }
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Value();\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const {
printer->Print(variables_, "private int $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override $deprecation$public boolean "
"${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override $deprecation$public int "
"${$get$capitalized_name$Value$}$() {\n"
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override $deprecation$public $type$ "
"${$get$capitalized_name$$}$() {\n"
" @SuppressWarnings(\"deprecation\")\n"
@@ -206,23 +206,23 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const {
" return result == null ? $unknown$ : result;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
printer->Print(variables_, "private int $name$_ = $default_number$;\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override $deprecation$public boolean "
"${$has$capitalized_name$$}$() {\n"
" return $get_has_field_bit_builder$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override $deprecation$public int "
"${$get$capitalized_name$Value$}$() {\n"
" return $name$_;\n"
@@ -230,7 +230,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$Value$}$(int value) {\n"
" $set_has_field_bit_builder$\n"
@@ -239,9 +239,9 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" @SuppressWarnings(\"deprecation\")\n"
@@ -251,7 +251,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" if (value == null) {\n"
@@ -274,8 +274,8 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -306,59 +306,59 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
void ImmutableEnumFieldGenerator::GenerateFieldBuilderInitializationCode(
io::Printer* printer) const {
- // noop for enums
-}
-
+ // noop for enums
+}
+
void ImmutableEnumFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $default_number$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $default_number$;\n");
+}
+
void ImmutableEnumFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$name$_ = $default_number$;\n"
"$clear_has_field_bit_builder$\n");
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (other.has$capitalized_name$()) {\n"
" set$capitalized_name$(other.get$capitalized_name$());\n"
"}\n");
- } else if (SupportUnknownEnumValue(descriptor_->file())) {
+ } else if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(
variables_,
"if (other.$name$_ != $default_number$) {\n"
" set$capitalized_name$Value(other.get$capitalized_name$Value());\n"
"}\n");
- } else {
- GOOGLE_LOG(FATAL) << "Can't reach here.";
- }
-}
-
+ } else {
+ GOOGLE_LOG(FATAL) << "Can't reach here.";
+ }
+}
+
void ImmutableEnumFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($get_has_field_bit_from_local$) {\n"
" $set_has_field_bit_to_local$;\n"
"}\n");
- }
+ }
printer->Print(variables_, "result.$name$_ = $name$_;\n");
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(variables_,
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(variables_,
"int rawValue = input.readEnum();\n"
"$set_has_field_bit_message$\n"
"$name$_ = rawValue;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"int rawValue = input.readEnum();\n"
" @SuppressWarnings(\"deprecation\")\n"
"$type$ value = $type$.$for_number$(rawValue);\n"
@@ -368,63 +368,63 @@ void ImmutableEnumFieldGenerator::GenerateParsingCode(
" $set_has_field_bit_message$\n"
" $name$_ = rawValue;\n"
"}\n");
- }
-}
-
+ }
+}
+
void ImmutableEnumFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- // noop for enums
-}
-
+ // noop for enums
+}
+
void ImmutableEnumFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($is_field_present_message$) {\n"
" output.writeEnum($number$, $name$_);\n"
"}\n");
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($is_field_present_message$) {\n"
" size += com.google.protobuf.CodedOutputStream\n"
" .computeEnumSize($number$, $name$_);\n"
"}\n");
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
printer->Print(variables_, "if ($name$_ != other.$name$_) return false;\n");
-}
-
+}
+
void ImmutableEnumFieldGenerator::GenerateHashCode(io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"hash = (37 * hash) + $constant_name$;\n"
"hash = (53 * hash) + $name$_;\n");
-}
-
+}
+
TProtoStringType ImmutableEnumFieldGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
-}
-
-// ===================================================================
-
+ return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
+}
+
+// ===================================================================
+
ImmutableEnumOneofFieldGenerator::ImmutableEnumOneofFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: ImmutableEnumFieldGenerator(descriptor, messageBitIndex, builderBitIndex,
context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {}
-
+
void ImmutableEnumOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
@@ -433,7 +433,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -444,9 +444,9 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers(
" return $default_number$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
" @SuppressWarnings(\"deprecation\")\n"
@@ -457,8 +457,8 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers(
" return $default$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
GOOGLE_DCHECK(HasHazzer(descriptor_));
@@ -470,7 +470,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -484,7 +484,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$Value$}$(int value) {\n"
" $set_oneof_case_message$;\n"
@@ -493,9 +493,9 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
@@ -509,7 +509,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" if (value == null) {\n"
@@ -534,37 +534,37 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" result.$oneof_name$_ = $oneof_name$_;\n"
"}\n");
-}
-
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(
variables_,
"set$capitalized_name$Value(other.get$capitalized_name$Value());\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"set$capitalized_name$(other.get$capitalized_name$());\n");
- }
-}
-
+ }
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(variables_,
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(variables_,
"int rawValue = input.readEnum();\n"
"$set_oneof_case_message$;\n"
"$oneof_name$_ = rawValue;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"int rawValue = input.readEnum();\n"
"@SuppressWarnings(\"deprecation\")\n"
"$type$ value = $type$.$for_number$(rawValue);\n"
@@ -574,9 +574,9 @@ void ImmutableEnumOneofFieldGenerator::GenerateParsingCode(
" $set_oneof_case_message$;\n"
" $oneof_name$_ = rawValue;\n"
"}\n");
- }
-}
-
+ }
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(
@@ -584,8 +584,8 @@ void ImmutableEnumOneofFieldGenerator::GenerateSerializationCode(
"if ($has_oneof_case_message$) {\n"
" output.writeEnum($number$, ((java.lang.Integer) $oneof_name$_));\n"
"}\n");
-}
-
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
printer->Print(
@@ -594,58 +594,58 @@ void ImmutableEnumOneofFieldGenerator::GenerateSerializedSizeCode(
" size += com.google.protobuf.CodedOutputStream\n"
" .computeEnumSize($number$, ((java.lang.Integer) $oneof_name$_));\n"
"}\n");
-}
-
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(
variables_,
"if (get$capitalized_name$Value()\n"
" != other.get$capitalized_name$Value()) return false;\n");
- } else {
+ } else {
printer->Print(
variables_,
"if (!get$capitalized_name$()\n"
" .equals(other.get$capitalized_name$())) return false;\n");
- }
-}
-
+ }
+}
+
void ImmutableEnumOneofFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(variables_,
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(variables_,
"hash = (37 * hash) + $constant_name$;\n"
"hash = (53 * hash) + get$capitalized_name$Value();\n");
- } else {
+ } else {
printer->Print(
variables_,
"hash = (37 * hash) + $constant_name$;\n"
"hash = (53 * hash) + get$capitalized_name$().getNumber();\n");
- }
-}
-
-// ===================================================================
-
+ }
+}
+
+// ===================================================================
+
RepeatedImmutableEnumFieldGenerator::RepeatedImmutableEnumFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
+ SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
&variables_);
-}
-
-RepeatedImmutableEnumFieldGenerator::~RepeatedImmutableEnumFieldGenerator() {}
-
-int RepeatedImmutableEnumFieldGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
-int RepeatedImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
- return 1;
-}
-
+}
+
+RepeatedImmutableEnumFieldGenerator::~RepeatedImmutableEnumFieldGenerator() {}
+
+int RepeatedImmutableEnumFieldGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
+int RepeatedImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
+ return 1;
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
@@ -653,23 +653,23 @@ void RepeatedImmutableEnumFieldGenerator::GenerateInterfaceMembers(
variables_,
"$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$$type$ get$capitalized_name$(int index);\n");
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.util.List<java.lang.Integer>\n"
"get$capitalized_name$ValueList();\n");
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Value(int index);\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(
@@ -686,7 +686,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
" return result == null ? $unknown$ : result;\n"
" }\n"
" };\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
@@ -713,9 +713,9 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
" return $name$_converter_.convert($name$_.get(index));\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<java.lang.Integer>\n"
"${$get$capitalized_name$ValueList$}$() {\n"
@@ -724,20 +724,20 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public int "
"${$get$capitalized_name$Value$}$(int index) {\n"
" return $name$_.get(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
if (descriptor_->is_packed()) {
printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
printer->Print(
@@ -753,14 +753,14 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
// list can never be modified.
"private java.util.List<java.lang.Integer> $name$_ =\n"
" java.util.Collections.emptyList();\n"
-
+
"private void ensure$capitalized_name$IsMutable() {\n"
" if (!$get_mutable_bit_builder$) {\n"
" $name$_ = new java.util.ArrayList<java.lang.Integer>($name$_);\n"
" $set_mutable_bit_builder$;\n"
" }\n"
"}\n");
-
+
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
@@ -790,7 +790,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
" if (value == null) {\n"
@@ -804,7 +804,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$$}$($type$ value) {\n"
" if (value == null) {\n"
@@ -818,7 +818,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<? extends $type$> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -840,10 +840,10 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- if (SupportUnknownEnumValue(descriptor_->file())) {
+
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public java.util.List<java.lang.Integer>\n"
"${$get$capitalized_name$ValueList$}$() {\n"
" return java.util.Collections.unmodifiableList($name$_);\n"
@@ -851,7 +851,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public int "
"${$get$capitalized_name$Value$}$(int index) {\n"
" return $name$_.get(index);\n"
@@ -872,7 +872,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$Value$}$(int value) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -895,34 +895,34 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
-void RepeatedImmutableEnumFieldGenerator::
+ }
+}
+
+void RepeatedImmutableEnumFieldGenerator::
GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
- // noop for enums
-}
-
+ // noop for enums
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
-}
-
+ printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$name$_ = java.util.Collections.emptyList();\n"
"$clear_mutable_bit_builder$;\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- // The code below does two optimizations:
- // 1. If the other list is empty, there's nothing to do. This ensures we
- // don't allocate a new array if we already have an immutable one.
- // 2. If the other list is non-empty and our current list is empty, we can
- // reuse the other list which is guaranteed to be immutable.
- printer->Print(variables_,
+ // The code below does two optimizations:
+ // 1. If the other list is empty, there's nothing to do. This ensures we
+ // don't allocate a new array if we already have an immutable one.
+ // 2. If the other list is non-empty and our current list is empty, we can
+ // reuse the other list which is guaranteed to be immutable.
+ printer->Print(variables_,
"if (!other.$name$_.isEmpty()) {\n"
" if ($name$_.isEmpty()) {\n"
" $name$_ = other.$name$_;\n"
@@ -933,12 +933,12 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMergingCode(
" }\n"
" $on_changed$\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- // The code below ensures that the result has an immutable list. If our
- // list is immutable, we can just reuse it. If not, we make it immutable.
+ // The code below ensures that the result has an immutable list. If our
+ // list is immutable, we can just reuse it. If not, we make it immutable.
printer->Print(
variables_,
"if ($get_mutable_bit_builder$) {\n"
@@ -946,20 +946,20 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuildingCode(
" $clear_mutable_bit_builder$;\n"
"}\n"
"result.$name$_ = $name$_;\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- // Read and store the enum
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(variables_,
+ // Read and store the enum
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(variables_,
"int rawValue = input.readEnum();\n"
"if (!$get_mutable_bit_parser$) {\n"
" $name$_ = new java.util.ArrayList<java.lang.Integer>();\n"
" $set_mutable_bit_parser$;\n"
"}\n"
"$name$_.add(rawValue);\n");
- } else {
+ } else {
printer->Print(
variables_,
"int rawValue = input.readEnum();\n"
@@ -974,27 +974,27 @@ void RepeatedImmutableEnumFieldGenerator::GenerateParsingCode(
" }\n"
" $name$_.add(rawValue);\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked(
io::Printer* printer) const {
- // Wrap GenerateParsingCode's contents with a while loop.
-
- printer->Print(variables_,
+ // Wrap GenerateParsingCode's contents with a while loop.
+
+ printer->Print(variables_,
"int length = input.readRawVarint32();\n"
"int oldLimit = input.pushLimit(length);\n"
"while(input.getBytesUntilLimit() > 0) {\n");
- printer->Indent();
-
- GenerateParsingCode(printer);
-
- printer->Outdent();
- printer->Print(variables_,
+ printer->Indent();
+
+ GenerateParsingCode(printer);
+
+ printer->Outdent();
+ printer->Print(variables_,
"}\n"
"input.popLimit(oldLimit);\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
printer->Print(
@@ -1002,12 +1002,12 @@ void RepeatedImmutableEnumFieldGenerator::GenerateParsingDoneCode(
"if ($get_mutable_bit_parser$) {\n"
" $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- if (descriptor_->is_packed()) {
- printer->Print(variables_,
+ if (descriptor_->is_packed()) {
+ printer->Print(variables_,
"if (get$capitalized_name$List().size() > 0) {\n"
" output.writeUInt32NoTag($tag$);\n"
" output.writeUInt32NoTag($name$MemoizedSerializedSize);\n"
@@ -1015,62 +1015,62 @@ void RepeatedImmutableEnumFieldGenerator::GenerateSerializationCode(
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.writeEnumNoTag($name$_.get(i));\n"
"}\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.writeEnum($number$, $name$_.get(i));\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"{\n"
" int dataSize = 0;\n");
- printer->Indent();
-
- printer->Print(variables_,
+ printer->Indent();
+
+ printer->Print(variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" dataSize += com.google.protobuf.CodedOutputStream\n"
" .computeEnumSizeNoTag($name$_.get(i));\n"
"}\n");
printer->Print("size += dataSize;\n");
- if (descriptor_->is_packed()) {
- printer->Print(variables_,
+ if (descriptor_->is_packed()) {
+ printer->Print(variables_,
"if (!get$capitalized_name$List().isEmpty()) {"
" size += $tag_size$;\n"
" size += com.google.protobuf.CodedOutputStream\n"
" .computeUInt32SizeNoTag(dataSize);\n"
"}");
- } else {
+ } else {
printer->Print(variables_, "size += $tag_size$ * $name$_.size();\n");
- }
-
- // cache the data size for packed fields.
- if (descriptor_->is_packed()) {
+ }
+
+ // cache the data size for packed fields.
+ if (descriptor_->is_packed()) {
printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n");
- }
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
+ }
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (!$name$_.equals(other.$name$_)) return false;\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (get$capitalized_name$Count() > 0) {\n"
" hash = (37 * hash) + $constant_name$;\n"
" hash = (53 * hash) + $name$_.hashCode();\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -1164,10 +1164,10 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
}
TProtoStringType RepeatedImmutableEnumFieldGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
index 27108d7ff1..13414bd8db 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,19 +49,19 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
+ public:
explicit ImmutableEnumFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
~ImmutableEnumFieldGenerator() override;
-
+
// implements ImmutableFieldGenerator
// ---------------------------------------
int GetNumBitsForMessage() const override;
@@ -82,47 +82,47 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldGenerator);
-};
-
-class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
- public:
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldGenerator);
+};
+
+class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
+ public:
ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
- ~ImmutableEnumOneofFieldGenerator();
-
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateBuildingCode(io::Printer* printer) const;
- void GenerateParsingCode(io::Printer* printer) const;
- void GenerateSerializationCode(io::Printer* printer) const;
- void GenerateSerializedSizeCode(io::Printer* printer) const;
- void GenerateEqualsCode(io::Printer* printer) const;
- void GenerateHashCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldGenerator);
-};
-
-class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
- public:
- explicit RepeatedImmutableEnumFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, Context* context);
+ ~ImmutableEnumOneofFieldGenerator();
+
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateBuildingCode(io::Printer* printer) const;
+ void GenerateParsingCode(io::Printer* printer) const;
+ void GenerateSerializationCode(io::Printer* printer) const;
+ void GenerateSerializedSizeCode(io::Printer* printer) const;
+ void GenerateEqualsCode(io::Printer* printer) const;
+ void GenerateHashCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldGenerator);
+};
+
+class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
+ public:
+ explicit RepeatedImmutableEnumFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, Context* context);
~RepeatedImmutableEnumFieldGenerator() override;
-
- // implements ImmutableFieldGenerator ---------------------------------------
+
+ // implements ImmutableFieldGenerator ---------------------------------------
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -142,20 +142,20 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
+
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index f96915d57a..e94f70289b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_enum_field_lite.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -47,13 +47,13 @@
#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 java {
-
-namespace {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
bool EnableExperimentalRuntimeForLite() {
#ifdef PROTOBUF_EXPERIMENT
return PROTOBUF_EXPERIMENT;
@@ -61,27 +61,27 @@ bool EnableExperimentalRuntimeForLite() {
return false;
#endif // !PROTOBUF_EXPERIMENT
}
-
+
void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- (*variables)["type"] =
- name_resolver->GetImmutableClassName(descriptor->enum_type());
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ (*variables)["type"] =
+ name_resolver->GetImmutableClassName(descriptor->enum_type());
(*variables)["kt_type"] = (*variables)["type"];
- (*variables)["mutable_type"] =
- name_resolver->GetMutableClassName(descriptor->enum_type());
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["mutable_type"] =
+ name_resolver->GetMutableClassName(descriptor->enum_type());
+ (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] =
StrCat(descriptor->default_value_enum()->number());
(*variables)["tag"] = StrCat(
static_cast<int32_t>(internal::WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = StrCat(
- internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -90,47 +90,47 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
" is deprecated\") "
: "";
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
-
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["clear_has_field_bit_message"] = "";
-
- (*variables)["is_field_present_message"] =
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["clear_has_field_bit_message"] =
+ GenerateClearBit(messageBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["clear_has_field_bit_message"] = "";
+
+ (*variables)["is_field_present_message"] =
(*variables)["name"] + "_ != " + (*variables)["default"] +
".getNumber()";
- }
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-
- if (SupportUnknownEnumValue(descriptor->file())) {
- (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED";
- } else {
- (*variables)["unknown"] = (*variables)["default"];
- }
+ }
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+
+ if (SupportUnknownEnumValue(descriptor->file())) {
+ (*variables)["unknown"] = (*variables)["type"] + ".UNRECOGNIZED";
+ } else {
+ (*variables)["unknown"] = (*variables)["default"];
+ }
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["null_check"] = "value.getClass();\n";
-}
-
-} // namespace
-
-// ===================================================================
-
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutableEnumFieldLiteGenerator::ImmutableEnumFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
@@ -140,34 +140,34 @@ ImmutableEnumFieldLiteGenerator::ImmutableEnumFieldLiteGenerator(
SetEnumVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
&variables_);
-}
-
-ImmutableEnumFieldLiteGenerator::~ImmutableEnumFieldLiteGenerator() {}
-
-int ImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
+}
+
+ImmutableEnumFieldLiteGenerator::~ImmutableEnumFieldLiteGenerator() {}
+
+int ImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
+}
+
void ImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$boolean has$capitalized_name$();\n");
- }
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Value();\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
-}
-
+}
+
void ImmutableEnumFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private int $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -177,8 +177,8 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -187,39 +187,39 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers(
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" $type$ result = $type$.forNumber($name$_);\n"
" return result == null ? $unknown$ : result;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Generate private setters for the builder to proxy into.
- if (SupportUnknownEnumValue(descriptor_->file())) {
+
+ // Generate private setters for the builder to proxy into.
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$Value(int value) {\n"
" $set_has_field_bit_message$"
" $name$_ = value;\n"
"}\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$($type$ value) {\n"
" $name$_ = value.getNumber();\n"
" $set_has_field_bit_message$\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $clear_has_field_bit_message$\n"
" $name$_ = $default_number$;\n"
"}\n");
-}
-
+}
+
void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
@@ -231,8 +231,8 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -243,7 +243,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$Value$}$(int value) {\n"
" copyOnWrite();\n"
@@ -251,9 +251,9 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return instance.get$capitalized_name$();\n"
@@ -261,7 +261,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -279,8 +279,8 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -311,11 +311,11 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
void ImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- if (!IsDefaultValueJavaDefault(descriptor_)) {
- printer->Print(variables_, "$name$_ = $default_number$;\n");
- }
-}
-
+ if (!IsDefaultValueJavaDefault(descriptor_)) {
+ printer->Print(variables_, "$name$_ = $default_number$;\n");
+ }
+}
+
void ImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -323,35 +323,35 @@ void ImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
output);
if (HasHasbit(descriptor_)) {
WriteIntToUtf16CharSequence(messageBitIndex_, output);
- }
+ }
printer->Print(variables_, "\"$name$_\",\n");
if (!SupportUnknownEnumValue((descriptor_))) {
PrintEnumVerifierLogic(printer, descriptor_, variables_,
/*var_name=*/"$type$",
/*terminating_string=*/",\n",
/*enforce_lite=*/context_->EnforceLite());
- }
-}
-
+ }
+}
+
TProtoStringType ImmutableEnumFieldLiteGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
-}
-
-// ===================================================================
-
+ return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
+}
+
+// ===================================================================
+
ImmutableEnumOneofFieldLiteGenerator::ImmutableEnumOneofFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: ImmutableEnumFieldLiteGenerator(descriptor, messageBitIndex, context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {}
-
+
void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
@@ -361,7 +361,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -373,9 +373,9 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
" return $default_number$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
@@ -386,32 +386,32 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
" return $default$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Generate private setters for the builder to proxy into.
- if (SupportUnknownEnumValue(descriptor_->file())) {
+
+ // Generate private setters for the builder to proxy into.
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$Value(int value) {\n"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value;\n"
"}\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$($type$ value) {\n"
" $oneof_name$_ = value.getNumber();\n"
" $set_oneof_case_message$;\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
" $oneof_name$_ = null;\n"
" }\n"
"}\n");
-}
-
+}
+
void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -437,7 +437,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -448,7 +448,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$Value$}$(int value) {\n"
" copyOnWrite();\n"
@@ -456,9 +456,9 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return instance.get$capitalized_name$();\n"
@@ -466,7 +466,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -484,11 +484,11 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
-// ===================================================================
-
-RepeatedImmutableEnumFieldLiteGenerator::
+}
+
+// ===================================================================
+
+RepeatedImmutableEnumFieldLiteGenerator::
RepeatedImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context)
@@ -498,15 +498,15 @@ RepeatedImmutableEnumFieldLiteGenerator::
SetEnumVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor), name_resolver_,
&variables_);
-}
-
-RepeatedImmutableEnumFieldLiteGenerator::
+}
+
+RepeatedImmutableEnumFieldLiteGenerator::
~RepeatedImmutableEnumFieldLiteGenerator() {}
-
-int RepeatedImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
+
+int RepeatedImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
void RepeatedImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
@@ -514,23 +514,23 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
variables_,
"$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$$type$ get$capitalized_name$(int index);\n");
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.util.List<java.lang.Integer>\n"
"get$capitalized_name$ValueList();\n");
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Value(int index);\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(
@@ -547,7 +547,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
" return result == null ? $unknown$ : result;\n"
" }\n"
" };\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
@@ -574,9 +574,9 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
" return $name$_converter_.convert($name$_.getInt(index));\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<java.lang.Integer>\n"
"${$get$capitalized_name$ValueList$}$() {\n"
@@ -585,21 +585,21 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public int "
"${$get$capitalized_name$Value$}$(int index) {\n"
" return $name$_.getInt(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() &&
- context_->HasGeneratedMethods(descriptor_->containing_type())) {
+ context_->HasGeneratedMethods(descriptor_->containing_type())) {
printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n");
- }
-
- // Generate private setters for the builder to proxy into.
+ }
+
+ // Generate private setters for the builder to proxy into.
printer->Print(
variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
@@ -611,7 +611,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
" }\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$(\n"
" int index, $type$ value) {\n"
" $null_check$"
@@ -619,14 +619,14 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
" $name$_.setInt(index, value.getNumber());\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void add$capitalized_name$($type$ value) {\n"
" $null_check$"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.addInt(value.getNumber());\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void addAll$capitalized_name$(\n"
" java.lang.Iterable<? extends $type$> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -635,28 +635,28 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
" }\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $name$_ = emptyIntList();\n"
"}\n");
-
- if (SupportUnknownEnumValue(descriptor_->file())) {
+
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$Value(\n"
" int index, int value) {\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.setInt(index, value);\n"
"}\n");
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void add$capitalized_name$Value(int value) {\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.addInt(value);\n"
"}\n");
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_MULTI_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void addAll$capitalized_name$Value(\n"
" java.lang.Iterable<java.lang.Integer> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -664,9 +664,9 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
" $name$_.addInt(value);\n"
" }\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -684,7 +684,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$type$> "
"${$get$capitalized_name$List$}$() {\n"
@@ -709,7 +709,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
" copyOnWrite();\n"
@@ -719,7 +719,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -729,7 +729,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<? extends $type$> values) {\n"
" copyOnWrite();\n"
@@ -747,10 +747,10 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- if (SupportUnknownEnumValue(descriptor_->file())) {
+
+ if (SupportUnknownEnumValue(descriptor_->file())) {
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<java.lang.Integer>\n"
"${$get$capitalized_name$ValueList$}$() {\n"
@@ -760,7 +760,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public int "
"${$get$capitalized_name$Value$}$(int index) {\n"
@@ -781,7 +781,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$Value$}$(int value) {\n"
" instance.add$capitalized_name$Value(value);\n"
@@ -800,14 +800,14 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
+ }
+}
+
void RepeatedImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = emptyIntList();\n");
-}
-
+ printer->Print(variables_, "$name$_ = emptyIntList();\n");
+}
+
void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -901,10 +901,10 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
}
TProtoStringType RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h
index 3b856b0c60..eb8e8cd313 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
+
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -51,19 +51,19 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
+ public:
explicit ImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
~ImmutableEnumFieldLiteGenerator() override;
-
+
// implements ImmutableFieldLiteGenerator
// ------------------------------------
int GetNumBitsForMessage() const override;
@@ -74,44 +74,44 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- const int messageBitIndex_;
- Context* context_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldLiteGenerator);
-};
-
-class ImmutableEnumOneofFieldLiteGenerator
- : public ImmutableEnumFieldLiteGenerator {
- public:
+ const int messageBitIndex_;
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldLiteGenerator);
+};
+
+class ImmutableEnumOneofFieldLiteGenerator
+ : public ImmutableEnumFieldLiteGenerator {
+ public:
ImmutableEnumOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, Context* context);
~ImmutableEnumOneofFieldLiteGenerator() override;
-
+
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldLiteGenerator);
-};
-
-class RepeatedImmutableEnumFieldLiteGenerator
- : public ImmutableFieldLiteGenerator {
- public:
- explicit RepeatedImmutableEnumFieldLiteGenerator(
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldLiteGenerator);
+};
+
+class RepeatedImmutableEnumFieldLiteGenerator
+ : public ImmutableFieldLiteGenerator {
+ public:
+ explicit RepeatedImmutableEnumFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
~RepeatedImmutableEnumFieldLiteGenerator() override;
-
- // implements ImmutableFieldLiteGenerator ------------------------------------
+
+ // implements ImmutableFieldLiteGenerator ------------------------------------
int GetNumBitsForMessage() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
void GenerateMembers(io::Printer* printer) const override;
@@ -120,21 +120,21 @@ class RepeatedImmutableEnumFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
+
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- Context* context_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
index f8e5943969..bf84607aac 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc
@@ -1,40 +1,40 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum_lite.h>
@@ -44,101 +44,101 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-EnumLiteGenerator::EnumLiteGenerator(const EnumDescriptor* descriptor,
- bool immutable_api, Context* context)
- : descriptor_(descriptor),
- immutable_api_(immutable_api),
- context_(context),
- name_resolver_(context->GetNameResolver()) {
- for (int i = 0; i < descriptor_->value_count(); i++) {
- const EnumValueDescriptor* value = descriptor_->value(i);
- const EnumValueDescriptor* canonical_value =
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+EnumLiteGenerator::EnumLiteGenerator(const EnumDescriptor* descriptor,
+ bool immutable_api, Context* context)
+ : descriptor_(descriptor),
+ immutable_api_(immutable_api),
+ context_(context),
+ name_resolver_(context->GetNameResolver()) {
+ for (int i = 0; i < descriptor_->value_count(); i++) {
+ const EnumValueDescriptor* value = descriptor_->value(i);
+ const EnumValueDescriptor* canonical_value =
descriptor_->FindValueByNumber(value->number());
-
- if (value == canonical_value) {
- canonical_values_.push_back(value);
- } else {
- Alias alias;
- alias.value = value;
- alias.canonical_value = canonical_value;
- aliases_.push_back(alias);
- }
- }
-}
-
-EnumLiteGenerator::~EnumLiteGenerator() {}
-
-void EnumLiteGenerator::Generate(io::Printer* printer) {
- WriteEnumDocComment(printer, descriptor_);
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
- printer->Print(
+
+ if (value == canonical_value) {
+ canonical_values_.push_back(value);
+ } else {
+ Alias alias;
+ alias.value = value;
+ alias.canonical_value = canonical_value;
+ aliases_.push_back(alias);
+ }
+ }
+}
+
+EnumLiteGenerator::~EnumLiteGenerator() {}
+
+void EnumLiteGenerator::Generate(io::Printer* printer) {
+ WriteEnumDocComment(printer, descriptor_);
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
+ printer->Print(
"$deprecation$public enum $classname$\n"
- " implements com.google.protobuf.Internal.EnumLite {\n",
+ " implements com.google.protobuf.Internal.EnumLite {\n",
"classname", descriptor_->name(), "deprecation",
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "");
- printer->Annotate("classname", descriptor_);
- printer->Indent();
-
- for (int i = 0; i < canonical_values_.size(); i++) {
+ printer->Annotate("classname", descriptor_);
+ printer->Indent();
+
+ for (int i = 0; i < canonical_values_.size(); i++) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["name"] = canonical_values_[i]->name();
+ vars["name"] = canonical_values_[i]->name();
vars["number"] = StrCat(canonical_values_[i]->number());
- WriteEnumValueDocComment(printer, canonical_values_[i]);
- if (canonical_values_[i]->options().deprecated()) {
- printer->Print("@java.lang.Deprecated\n");
- }
+ WriteEnumValueDocComment(printer, canonical_values_[i]);
+ if (canonical_values_[i]->options().deprecated()) {
+ printer->Print("@java.lang.Deprecated\n");
+ }
printer->Print(vars, "$name$($number$),\n");
printer->Annotate("name", canonical_values_[i]);
- }
-
- if (SupportUnknownEnumValue(descriptor_->file())) {
+ }
+
+ if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", "");
printer->Annotate("{", "}", descriptor_);
- }
-
- printer->Print(
+ }
+
+ printer->Print(
";\n"
"\n");
-
- // -----------------------------------------------------------------
-
- for (int i = 0; i < aliases_.size(); i++) {
+
+ // -----------------------------------------------------------------
+
+ for (int i = 0; i < aliases_.size(); i++) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["classname"] = descriptor_->name();
- vars["name"] = aliases_[i].value->name();
- vars["canonical_name"] = aliases_[i].canonical_value->name();
- WriteEnumValueDocComment(printer, aliases_[i].value);
+ vars["classname"] = descriptor_->name();
+ vars["name"] = aliases_[i].value->name();
+ vars["canonical_name"] = aliases_[i].canonical_value->name();
+ WriteEnumValueDocComment(printer, aliases_[i].value);
printer->Print(
vars, "public static final $classname$ $name$ = $canonical_name$;\n");
printer->Annotate("name", aliases_[i].value);
- }
-
- for (int i = 0; i < descriptor_->value_count(); i++) {
+ }
+
+ for (int i = 0; i < descriptor_->value_count(); i++) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["name"] = descriptor_->value(i)->name();
+ vars["name"] = descriptor_->value(i)->name();
vars["number"] = StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
vars["deprecation"] = descriptor_->value(i)->options().deprecated()
? "@java.lang.Deprecated "
: "";
- WriteEnumValueDocComment(printer, descriptor_->value(i));
- printer->Print(vars,
+ WriteEnumValueDocComment(printer, descriptor_->value(i));
+ printer->Print(vars,
"$deprecation$public static final int ${$$name$_VALUE$}$ = "
"$number$;\n");
printer->Annotate("{", "}", descriptor_->value(i));
- }
- printer->Print("\n");
-
- // -----------------------------------------------------------------
-
- printer->Print(
+ }
+ printer->Print("\n");
+
+ // -----------------------------------------------------------------
+
+ printer->Print(
"\n"
"@java.lang.Override\n"
"public final int getNumber() {\n");
@@ -166,18 +166,18 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
"public static $classname$ forNumber(int value) {\n"
" switch (value) {\n",
"classname", descriptor_->name());
- printer->Indent();
- printer->Indent();
-
- for (int i = 0; i < canonical_values_.size(); i++) {
+ printer->Indent();
+ printer->Indent();
+
+ for (int i = 0; i < canonical_values_.size(); i++) {
printer->Print("case $number$: return $name$;\n", "name",
canonical_values_[i]->name(), "number",
StrCat(canonical_values_[i]->number()));
- }
-
- printer->Outdent();
- printer->Outdent();
- printer->Print(
+ }
+
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
" default: return null;\n"
" }\n"
"}\n"
@@ -211,25 +211,25 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
" };\n"
"\n",
"classname", descriptor_->name());
-
- printer->Print(
+
+ printer->Print(
"private final int value;\n\n"
"private $classname$(int value) {\n",
"classname", descriptor_->name());
- printer->Print(
+ printer->Print(
" this.value = value;\n"
"}\n");
-
- printer->Print(
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(enum_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h
index c1d1b26efc..50f3fe7b1a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
+
#include <string>
-#include <vector>
+#include <vector>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,50 +49,50 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class EnumLiteGenerator {
- public:
- EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api,
- Context* context);
- ~EnumLiteGenerator();
-
- void Generate(io::Printer* printer);
-
- private:
- const EnumDescriptor* descriptor_;
-
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class EnumLiteGenerator {
+ public:
+ EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api,
+ Context* context);
+ ~EnumLiteGenerator();
+
+ void Generate(io::Printer* printer);
+
+ private:
+ const EnumDescriptor* descriptor_;
+
// The proto language allows multiple enum constants to have the same
// numeric value. Java, however, does not allow multiple enum constants to
// be considered equivalent. We treat the first defined constant for any
- // given numeric value as "canonical" and the rest as aliases of that
- // canonical value.
+ // given numeric value as "canonical" and the rest as aliases of that
+ // canonical value.
std::vector<const EnumValueDescriptor*> canonical_values_;
-
- struct Alias {
- const EnumValueDescriptor* value;
- const EnumValueDescriptor* canonical_value;
- };
+
+ struct Alias {
+ const EnumValueDescriptor* value;
+ const EnumValueDescriptor* canonical_value;
+ };
std::vector<Alias> aliases_;
-
- bool immutable_api_;
-
- Context* context_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ bool immutable_api_;
+
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
index fb51d1ef86..9602780c49 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc
@@ -1,172 +1,172 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_extension.h>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-ImmutableExtensionGenerator::ImmutableExtensionGenerator(
- const FieldDescriptor* descriptor, Context* context)
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+ImmutableExtensionGenerator::ImmutableExtensionGenerator(
+ const FieldDescriptor* descriptor, Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- if (descriptor_->extension_scope() != NULL) {
+ if (descriptor_->extension_scope() != NULL) {
scope_ =
name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
- } else {
- scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());
- }
-}
-
-ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {}
-
-// Initializes the vars referenced in the generated code templates.
+ } else {
+ scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());
+ }
+}
+
+ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {}
+
+// Initializes the vars referenced in the generated code templates.
void ExtensionGenerator::InitTemplateVars(
const FieldDescriptor* descriptor, const TProtoStringType& scope, bool immutable,
ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* vars_pointer) {
std::map<TProtoStringType, TProtoStringType>& vars = *vars_pointer;
- vars["scope"] = scope;
+ vars["scope"] = scope;
vars["name"] = UnderscoresToCamelCaseCheckReserved(descriptor);
- vars["containing_type"] =
- name_resolver->GetClassName(descriptor->containing_type(), immutable);
+ vars["containing_type"] =
+ name_resolver->GetClassName(descriptor->containing_type(), immutable);
vars["number"] = StrCat(descriptor->number());
- vars["constant_name"] = FieldConstantName(descriptor);
+ vars["constant_name"] = FieldConstantName(descriptor);
vars["index"] = StrCat(descriptor->index());
vars["default"] = descriptor->is_repeated()
? ""
: DefaultValue(descriptor, immutable, name_resolver);
- vars["type_constant"] = FieldTypeName(GetType(descriptor));
+ vars["type_constant"] = FieldTypeName(GetType(descriptor));
vars["packed"] = descriptor->is_packed() ? "true" : "false";
- vars["enum_map"] = "null";
- vars["prototype"] = "null";
-
- JavaType java_type = GetJavaType(descriptor);
+ vars["enum_map"] = "null";
+ vars["prototype"] = "null";
+
+ JavaType java_type = GetJavaType(descriptor);
TProtoStringType singular_type;
- switch (java_type) {
- case JAVATYPE_MESSAGE:
+ switch (java_type) {
+ case JAVATYPE_MESSAGE:
singular_type =
name_resolver->GetClassName(descriptor->message_type(), immutable);
- vars["prototype"] = singular_type + ".getDefaultInstance()";
- break;
- case JAVATYPE_ENUM:
+ vars["prototype"] = singular_type + ".getDefaultInstance()";
+ break;
+ case JAVATYPE_ENUM:
singular_type =
name_resolver->GetClassName(descriptor->enum_type(), immutable);
- vars["enum_map"] = singular_type + ".internalGetValueMap()";
- break;
- case JAVATYPE_STRING:
- singular_type = "java.lang.String";
- break;
- case JAVATYPE_BYTES:
- singular_type = immutable ? "com.google.protobuf.ByteString" : "byte[]";
- break;
- default:
- singular_type = BoxedPrimitiveTypeName(java_type);
- break;
- }
+ vars["enum_map"] = singular_type + ".internalGetValueMap()";
+ break;
+ case JAVATYPE_STRING:
+ singular_type = "java.lang.String";
+ break;
+ case JAVATYPE_BYTES:
+ singular_type = immutable ? "com.google.protobuf.ByteString" : "byte[]";
+ break;
+ default:
+ singular_type = BoxedPrimitiveTypeName(java_type);
+ break;
+ }
vars["type"] = descriptor->is_repeated()
? "java.util.List<" + singular_type + ">"
: singular_type;
- vars["singular_type"] = singular_type;
-}
-
-void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
+ vars["singular_type"] = singular_type;
+}
+
+void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
std::map<TProtoStringType, TProtoStringType> vars;
- const bool kUseImmutableNames = true;
- InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
- &vars);
+ const bool kUseImmutableNames = true;
+ InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
+ &vars);
printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
-
- WriteFieldDocComment(printer, descriptor_);
- if (descriptor_->extension_scope() == NULL) {
- // Non-nested
- printer->Print(
- vars,
- "public static final\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $containing_type$,\n"
- " $type$> $name$ = com.google.protobuf.GeneratedMessage\n"
- " .newFileScopedGeneratedExtension(\n"
- " $singular_type$.class,\n"
- " $prototype$);\n");
- } else {
- // Nested
- printer->Print(
- vars,
- "public static final\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $containing_type$,\n"
- " $type$> $name$ = com.google.protobuf.GeneratedMessage\n"
- " .newMessageScopedGeneratedExtension(\n"
- " $scope$.getDefaultInstance(),\n"
- " $index$,\n"
- " $singular_type$.class,\n"
- " $prototype$);\n");
- }
+
+ WriteFieldDocComment(printer, descriptor_);
+ if (descriptor_->extension_scope() == NULL) {
+ // Non-nested
+ printer->Print(
+ vars,
+ "public static final\n"
+ " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
+ " $containing_type$,\n"
+ " $type$> $name$ = com.google.protobuf.GeneratedMessage\n"
+ " .newFileScopedGeneratedExtension(\n"
+ " $singular_type$.class,\n"
+ " $prototype$);\n");
+ } else {
+ // Nested
+ printer->Print(
+ vars,
+ "public static final\n"
+ " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
+ " $containing_type$,\n"
+ " $type$> $name$ = com.google.protobuf.GeneratedMessage\n"
+ " .newMessageScopedGeneratedExtension(\n"
+ " $scope$.getDefaultInstance(),\n"
+ " $index$,\n"
+ " $singular_type$.class,\n"
+ " $prototype$);\n");
+ }
printer->Annotate("name", descriptor_);
-}
-
-int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
- io::Printer* printer) {
- int bytecode_estimate = 0;
- if (descriptor_->extension_scope() == NULL) {
- // Only applies to non-nested extensions.
- printer->Print(
- "$name$.internalInit(descriptor.getExtensions().get($index$));\n",
+}
+
+int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
+ io::Printer* printer) {
+ int bytecode_estimate = 0;
+ if (descriptor_->extension_scope() == NULL) {
+ // Only applies to non-nested extensions.
+ printer->Print(
+ "$name$.internalInit(descriptor.getExtensions().get($index$));\n",
"name", UnderscoresToCamelCaseCheckReserved(descriptor_), "index",
StrCat(descriptor_->index()));
- bytecode_estimate += 21;
- }
- return bytecode_estimate;
-}
-
-int ImmutableExtensionGenerator::GenerateRegistrationCode(
- io::Printer* printer) {
+ bytecode_estimate += 21;
+ }
+ return bytecode_estimate;
+}
+
+int ImmutableExtensionGenerator::GenerateRegistrationCode(
+ io::Printer* printer) {
printer->Print("registry.add($scope$.$name$);\n", "scope", scope_, "name",
UnderscoresToCamelCaseCheckReserved(descriptor_));
- return 7;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return 7;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
index cf9ae4f2f5..76defbb8cb 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h
@@ -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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/common.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FieldDescriptor; // descriptor.h
namespace compiler {
namespace java {
@@ -51,65 +51,65 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-// 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:
- explicit ExtensionGenerator() {}
- virtual ~ExtensionGenerator() {}
-
- virtual void Generate(io::Printer* printer) = 0;
-
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+// 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:
+ explicit ExtensionGenerator() {}
+ virtual ~ExtensionGenerator() {}
+
+ virtual void Generate(io::Printer* printer) = 0;
+
// Returns an estimate of the number of bytes the printed code will compile
// to
- virtual int GenerateNonNestedInitializationCode(io::Printer* printer) = 0;
-
+ virtual int GenerateNonNestedInitializationCode(io::Printer* printer) = 0;
+
// Returns an estimate of the number of bytes the printed code will compile
// to
- virtual int GenerateRegistrationCode(io::Printer* printer) = 0;
-
- protected:
+ virtual int GenerateRegistrationCode(io::Printer* printer) = 0;
+
+ protected:
static void InitTemplateVars(
const FieldDescriptor* descriptor, const TProtoStringType& scope,
bool immutable, ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* vars_pointer);
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
-};
-
-class ImmutableExtensionGenerator : public ExtensionGenerator {
- public:
- explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor,
- Context* context);
- virtual ~ImmutableExtensionGenerator();
-
- virtual void Generate(io::Printer* printer);
- virtual int GenerateNonNestedInitializationCode(io::Printer* printer);
- virtual int GenerateRegistrationCode(io::Printer* printer);
-
- protected:
- const FieldDescriptor* descriptor_;
- ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
+};
+
+class ImmutableExtensionGenerator : public ExtensionGenerator {
+ public:
+ explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor,
+ Context* context);
+ virtual ~ImmutableExtensionGenerator();
+
+ virtual void Generate(io::Printer* printer);
+ virtual int GenerateNonNestedInitializationCode(io::Printer* printer);
+ virtual int GenerateRegistrationCode(io::Printer* printer);
+
+ protected:
+ const FieldDescriptor* descriptor_;
+ ClassNameResolver* name_resolver_;
TProtoStringType scope_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
index 22ce3ba92e..3f12f20a57 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc
@@ -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.
-
+// 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/java/java_extension_lite.h>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
- const FieldDescriptor* descriptor, Context* context)
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
+ const FieldDescriptor* descriptor, Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- if (descriptor_->extension_scope() != NULL) {
+ if (descriptor_->extension_scope() != NULL) {
scope_ =
name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
- } else {
- scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());
- }
-}
-
-ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}
-
-void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
+ } else {
+ scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());
+ }
+}
+
+ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}
+
+void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
std::map<TProtoStringType, TProtoStringType> vars;
- const bool kUseImmutableNames = true;
- InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
- &vars);
+ const bool kUseImmutableNames = true;
+ InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
+ &vars);
printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
-
- WriteFieldDocComment(printer, descriptor_);
- if (descriptor_->is_repeated()) {
- printer->Print(
- vars,
- "public static final\n"
- " com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\n"
- " $containing_type$,\n"
- " $type$> $name$ = com.google.protobuf.GeneratedMessageLite\n"
- " .newRepeatedGeneratedExtension(\n"
- " $containing_type$.getDefaultInstance(),\n"
- " $prototype$,\n"
- " $enum_map$,\n"
- " $number$,\n"
- " com.google.protobuf.WireFormat.FieldType.$type_constant$,\n"
- " $packed$,\n"
- " $singular_type$.class);\n");
- } else {
- printer->Print(
- vars,
- "public static final\n"
- " com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\n"
- " $containing_type$,\n"
- " $type$> $name$ = com.google.protobuf.GeneratedMessageLite\n"
- " .newSingularGeneratedExtension(\n"
- " $containing_type$.getDefaultInstance(),\n"
- " $default$,\n"
- " $prototype$,\n"
- " $enum_map$,\n"
- " $number$,\n"
- " com.google.protobuf.WireFormat.FieldType.$type_constant$,\n"
- " $singular_type$.class);\n");
- }
+
+ WriteFieldDocComment(printer, descriptor_);
+ if (descriptor_->is_repeated()) {
+ printer->Print(
+ vars,
+ "public static final\n"
+ " com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\n"
+ " $containing_type$,\n"
+ " $type$> $name$ = com.google.protobuf.GeneratedMessageLite\n"
+ " .newRepeatedGeneratedExtension(\n"
+ " $containing_type$.getDefaultInstance(),\n"
+ " $prototype$,\n"
+ " $enum_map$,\n"
+ " $number$,\n"
+ " com.google.protobuf.WireFormat.FieldType.$type_constant$,\n"
+ " $packed$,\n"
+ " $singular_type$.class);\n");
+ } else {
+ printer->Print(
+ vars,
+ "public static final\n"
+ " com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\n"
+ " $containing_type$,\n"
+ " $type$> $name$ = com.google.protobuf.GeneratedMessageLite\n"
+ " .newSingularGeneratedExtension(\n"
+ " $containing_type$.getDefaultInstance(),\n"
+ " $default$,\n"
+ " $prototype$,\n"
+ " $enum_map$,\n"
+ " $number$,\n"
+ " com.google.protobuf.WireFormat.FieldType.$type_constant$,\n"
+ " $singular_type$.class);\n");
+ }
printer->Annotate("name", descriptor_);
-}
-
-int ImmutableExtensionLiteGenerator::GenerateNonNestedInitializationCode(
- io::Printer* printer) {
- return 0;
-}
-
-int ImmutableExtensionLiteGenerator::GenerateRegistrationCode(
- io::Printer* printer) {
+}
+
+int ImmutableExtensionLiteGenerator::GenerateNonNestedInitializationCode(
+ io::Printer* printer) {
+ return 0;
+}
+
+int ImmutableExtensionLiteGenerator::GenerateRegistrationCode(
+ io::Printer* printer) {
printer->Print("registry.add($scope$.$name$);\n", "scope", scope_, "name",
UnderscoresToCamelCaseCheckReserved(descriptor_));
- return 7;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return 7;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
index 20bc041a7d..8912d4ea56 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h
@@ -1,75 +1,75 @@
-// 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_JAVA_EXTENSION_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_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_JAVA_EXTENSION_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_extension.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-// Generates code for a lite 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 ImmutableExtensionLiteGenerator : public ExtensionGenerator {
- public:
- explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor,
- Context* context);
- virtual ~ImmutableExtensionLiteGenerator();
-
- virtual void Generate(io::Printer* printer);
-
- // Returns an estimate of the number of bytes the printed code will compile to
- virtual int GenerateNonNestedInitializationCode(io::Printer* printer);
-
- // Returns an estimate of the number of bytes the printed code will compile to
- virtual int GenerateRegistrationCode(io::Printer* printer);
-
- private:
- const FieldDescriptor* descriptor_;
- ClassNameResolver* name_resolver_;
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+// Generates code for a lite 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 ImmutableExtensionLiteGenerator : public ExtensionGenerator {
+ public:
+ explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor,
+ Context* context);
+ virtual ~ImmutableExtensionLiteGenerator();
+
+ virtual void Generate(io::Printer* printer);
+
+ // Returns an estimate of the number of bytes the printed code will compile to
+ virtual int GenerateNonNestedInitializationCode(io::Printer* printer);
+
+ // Returns an estimate of the number of bytes the printed code will compile to
+ virtual int GenerateRegistrationCode(io::Printer* printer);
+
+ private:
+ const FieldDescriptor* descriptor_;
+ ClassNameResolver* name_resolver_;
TProtoStringType scope_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
index e082fd1150..15283e1083 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc
@@ -1,41 +1,41 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_field.h>
-
-#include <memory>
-
+
+#include <memory>
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -53,203 +53,203 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-namespace {
-
+
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field,
int messageBitIndex,
int builderBitIndex,
Context* context) {
- if (field->is_repeated()) {
- switch (GetJavaType(field)) {
- case JAVATYPE_MESSAGE:
- if (IsMapEntry(field->message_type())) {
+ if (field->is_repeated()) {
+ switch (GetJavaType(field)) {
+ case JAVATYPE_MESSAGE:
+ if (IsMapEntry(field->message_type())) {
return new ImmutableMapFieldGenerator(field, messageBitIndex,
builderBitIndex, context);
- } else {
+ } else {
return new RepeatedImmutableMessageFieldGenerator(
field, messageBitIndex, builderBitIndex, context);
- }
- case JAVATYPE_ENUM:
- return new RepeatedImmutableEnumFieldGenerator(
- field, messageBitIndex, builderBitIndex, context);
- case JAVATYPE_STRING:
- return new RepeatedImmutableStringFieldGenerator(
- field, messageBitIndex, builderBitIndex, context);
- default:
- return new RepeatedImmutablePrimitiveFieldGenerator(
- field, messageBitIndex, builderBitIndex, context);
- }
- } else {
+ }
+ case JAVATYPE_ENUM:
+ return new RepeatedImmutableEnumFieldGenerator(
+ field, messageBitIndex, builderBitIndex, context);
+ case JAVATYPE_STRING:
+ return new RepeatedImmutableStringFieldGenerator(
+ field, messageBitIndex, builderBitIndex, context);
+ default:
+ return new RepeatedImmutablePrimitiveFieldGenerator(
+ field, messageBitIndex, builderBitIndex, context);
+ }
+ } else {
if (IsRealOneof(field)) {
- switch (GetJavaType(field)) {
- case JAVATYPE_MESSAGE:
+ switch (GetJavaType(field)) {
+ case JAVATYPE_MESSAGE:
return new ImmutableMessageOneofFieldGenerator(
field, messageBitIndex, builderBitIndex, context);
- case JAVATYPE_ENUM:
+ case JAVATYPE_ENUM:
return new ImmutableEnumOneofFieldGenerator(field, messageBitIndex,
builderBitIndex, context);
- case JAVATYPE_STRING:
- return new ImmutableStringOneofFieldGenerator(
- field, messageBitIndex, builderBitIndex, context);
- default:
- return new ImmutablePrimitiveOneofFieldGenerator(
- field, messageBitIndex, builderBitIndex, context);
- }
- } else {
- switch (GetJavaType(field)) {
- case JAVATYPE_MESSAGE:
+ case JAVATYPE_STRING:
+ return new ImmutableStringOneofFieldGenerator(
+ field, messageBitIndex, builderBitIndex, context);
+ default:
+ return new ImmutablePrimitiveOneofFieldGenerator(
+ field, messageBitIndex, builderBitIndex, context);
+ }
+ } else {
+ switch (GetJavaType(field)) {
+ case JAVATYPE_MESSAGE:
return new ImmutableMessageFieldGenerator(field, messageBitIndex,
builderBitIndex, context);
- case JAVATYPE_ENUM:
+ case JAVATYPE_ENUM:
return new ImmutableEnumFieldGenerator(field, messageBitIndex,
builderBitIndex, context);
- case JAVATYPE_STRING:
+ case JAVATYPE_STRING:
return new ImmutableStringFieldGenerator(field, messageBitIndex,
builderBitIndex, context);
- default:
+ default:
return new ImmutablePrimitiveFieldGenerator(field, messageBitIndex,
builderBitIndex, context);
- }
- }
- }
-}
-
-ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator(
+ }
+ }
+ }
+}
+
+ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator(
const FieldDescriptor* field, int messageBitIndex, Context* context) {
- if (field->is_repeated()) {
- switch (GetJavaType(field)) {
- case JAVATYPE_MESSAGE:
- if (IsMapEntry(field->message_type())) {
+ if (field->is_repeated()) {
+ switch (GetJavaType(field)) {
+ case JAVATYPE_MESSAGE:
+ if (IsMapEntry(field->message_type())) {
return new ImmutableMapFieldLiteGenerator(field, messageBitIndex,
context);
- } else {
+ } else {
return new RepeatedImmutableMessageFieldLiteGenerator(
field, messageBitIndex, context);
- }
- case JAVATYPE_ENUM:
- return new RepeatedImmutableEnumFieldLiteGenerator(
+ }
+ case JAVATYPE_ENUM:
+ return new RepeatedImmutableEnumFieldLiteGenerator(
field, messageBitIndex, context);
- case JAVATYPE_STRING:
- return new RepeatedImmutableStringFieldLiteGenerator(
+ case JAVATYPE_STRING:
+ return new RepeatedImmutableStringFieldLiteGenerator(
field, messageBitIndex, context);
- default:
- return new RepeatedImmutablePrimitiveFieldLiteGenerator(
+ default:
+ return new RepeatedImmutablePrimitiveFieldLiteGenerator(
field, messageBitIndex, context);
- }
- } else {
+ }
+ } else {
if (IsRealOneof(field)) {
- switch (GetJavaType(field)) {
- case JAVATYPE_MESSAGE:
+ switch (GetJavaType(field)) {
+ case JAVATYPE_MESSAGE:
return new ImmutableMessageOneofFieldLiteGenerator(
field, messageBitIndex, context);
- case JAVATYPE_ENUM:
- return new ImmutableEnumOneofFieldLiteGenerator(
+ case JAVATYPE_ENUM:
+ return new ImmutableEnumOneofFieldLiteGenerator(
field, messageBitIndex, context);
- case JAVATYPE_STRING:
- return new ImmutableStringOneofFieldLiteGenerator(
+ case JAVATYPE_STRING:
+ return new ImmutableStringOneofFieldLiteGenerator(
field, messageBitIndex, context);
- default:
- return new ImmutablePrimitiveOneofFieldLiteGenerator(
+ default:
+ return new ImmutablePrimitiveOneofFieldLiteGenerator(
field, messageBitIndex, context);
- }
- } else {
- switch (GetJavaType(field)) {
- case JAVATYPE_MESSAGE:
+ }
+ } else {
+ switch (GetJavaType(field)) {
+ case JAVATYPE_MESSAGE:
return new ImmutableMessageFieldLiteGenerator(field, messageBitIndex,
context);
- case JAVATYPE_ENUM:
+ case JAVATYPE_ENUM:
return new ImmutableEnumFieldLiteGenerator(field, messageBitIndex,
context);
- case JAVATYPE_STRING:
+ case JAVATYPE_STRING:
return new ImmutableStringFieldLiteGenerator(field, messageBitIndex,
context);
- default:
- return new ImmutablePrimitiveFieldLiteGenerator(
+ default:
+ return new ImmutablePrimitiveFieldLiteGenerator(
field, messageBitIndex, context);
- }
- }
- }
-}
-
-
-static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) {
- // Reaching here indicates a bug. Cases are:
- // - This FieldGenerator should support packing,
- // but this method should be overridden.
- // - This FieldGenerator doesn't support packing, and this method
- // should never have been called.
- GOOGLE_LOG(FATAL) << "GenerateParsingCodeFromPacked() "
- << "called on field generator that does not support packing.";
-}
-
-} // namespace
-
-ImmutableFieldGenerator::~ImmutableFieldGenerator() {}
-
+ }
+ }
+ }
+}
+
+
+static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) {
+ // Reaching here indicates a bug. Cases are:
+ // - This FieldGenerator should support packing,
+ // but this method should be overridden.
+ // - This FieldGenerator doesn't support packing, and this method
+ // should never have been called.
+ GOOGLE_LOG(FATAL) << "GenerateParsingCodeFromPacked() "
+ << "called on field generator that does not support packing.";
+}
+
+} // namespace
+
+ImmutableFieldGenerator::~ImmutableFieldGenerator() {}
+
void ImmutableFieldGenerator::GenerateParsingCodeFromPacked(
io::Printer* printer) const {
- ReportUnexpectedPackedFieldsCall(printer);
-}
-
-ImmutableFieldLiteGenerator::~ImmutableFieldLiteGenerator() {}
-
-// ===================================================================
-
-template <>
-FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
- const Descriptor* descriptor, Context* context)
+ ReportUnexpectedPackedFieldsCall(printer);
+}
+
+ImmutableFieldLiteGenerator::~ImmutableFieldLiteGenerator() {}
+
+// ===================================================================
+
+template <>
+FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
+ const Descriptor* descriptor, Context* context)
: descriptor_(descriptor), field_generators_(descriptor->field_count()) {
- // Construct all the FieldGenerators and assign them bit indices for their
- // bit fields.
- int messageBitIndex = 0;
- int builderBitIndex = 0;
- for (int i = 0; i < descriptor->field_count(); i++) {
- ImmutableFieldGenerator* generator = MakeImmutableGenerator(
- descriptor->field(i), messageBitIndex, builderBitIndex, context);
- field_generators_[i].reset(generator);
- messageBitIndex += generator->GetNumBitsForMessage();
- builderBitIndex += generator->GetNumBitsForBuilder();
- }
-}
-
+ // Construct all the FieldGenerators and assign them bit indices for their
+ // bit fields.
+ int messageBitIndex = 0;
+ int builderBitIndex = 0;
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ ImmutableFieldGenerator* generator = MakeImmutableGenerator(
+ descriptor->field(i), messageBitIndex, builderBitIndex, context);
+ field_generators_[i].reset(generator);
+ messageBitIndex += generator->GetNumBitsForMessage();
+ builderBitIndex += generator->GetNumBitsForBuilder();
+ }
+}
+
template <>
-FieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap() {}
-
-template <>
-FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(
- const Descriptor* descriptor, Context* context)
+FieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap() {}
+
+template <>
+FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(
+ const Descriptor* descriptor, Context* context)
: descriptor_(descriptor), field_generators_(descriptor->field_count()) {
- // Construct all the FieldGenerators and assign them bit indices for their
- // bit fields.
- int messageBitIndex = 0;
- for (int i = 0; i < descriptor->field_count(); i++) {
- ImmutableFieldLiteGenerator* generator = MakeImmutableLiteGenerator(
+ // Construct all the FieldGenerators and assign them bit indices for their
+ // bit fields.
+ int messageBitIndex = 0;
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ ImmutableFieldLiteGenerator* generator = MakeImmutableLiteGenerator(
descriptor->field(i), messageBitIndex, context);
- field_generators_[i].reset(generator);
- messageBitIndex += generator->GetNumBitsForMessage();
- }
-}
-
+ field_generators_[i].reset(generator);
+ messageBitIndex += generator->GetNumBitsForMessage();
+ }
+}
+
template <>
-FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}
-
-
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- const FieldGeneratorInfo* info,
+FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}
+
+
+void SetCommonFieldVariables(const FieldDescriptor* descriptor,
+ const FieldGeneratorInfo* info,
std::map<TProtoStringType, TProtoStringType>* variables) {
- (*variables)["field_name"] = descriptor->name();
- (*variables)["name"] = info->name;
+ (*variables)["field_name"] = descriptor->name();
+ (*variables)["name"] = info->name;
(*variables)["classname"] = descriptor->containing_type()->name();
- (*variables)["capitalized_name"] = info->capitalized_name;
- (*variables)["disambiguated_reason"] = info->disambiguated_reason;
- (*variables)["constant_name"] = FieldConstantName(descriptor);
+ (*variables)["capitalized_name"] = info->capitalized_name;
+ (*variables)["disambiguated_reason"] = info->disambiguated_reason;
+ (*variables)["constant_name"] = FieldConstantName(descriptor);
(*variables)["number"] = StrCat(descriptor->number());
(*variables)["kt_dsl_builder"] = "_builder";
// These variables are placeholders to pick out the beginning and ends of
@@ -277,14 +277,14 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
(*variables)["annotation_field_type"] + "_PACKED";
}
}
-}
-
-void SetCommonOneofVariables(const FieldDescriptor* descriptor,
- const OneofGeneratorInfo* info,
+}
+
+void SetCommonOneofVariables(const FieldDescriptor* descriptor,
+ const OneofGeneratorInfo* info,
std::map<TProtoStringType, TProtoStringType>* variables) {
- (*variables)["oneof_name"] = info->name;
- (*variables)["oneof_capitalized_name"] = info->capitalized_name;
- (*variables)["oneof_index"] =
+ (*variables)["oneof_name"] = info->name;
+ (*variables)["oneof_capitalized_name"] = info->capitalized_name;
+ (*variables)["oneof_index"] =
StrCat(descriptor->containing_oneof()->index());
(*variables)["oneof_stored_type"] = GetOneofStoredType(descriptor);
(*variables)["set_oneof_case_message"] =
@@ -292,21 +292,21 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor,
(*variables)["clear_oneof_case_message"] = info->name + "Case_ = 0";
(*variables)["has_oneof_case_message"] =
info->name + "Case_ == " + StrCat(descriptor->number());
-}
-
+}
+
void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
- io::Printer* printer) {
+ io::Printer* printer) {
const std::map<TProtoStringType, TProtoStringType>::const_iterator it =
- variables.find("disambiguated_reason");
- if (it != variables.end() && !it->second.empty()) {
- printer->Print(
- variables,
- "// An alternative name is used for field \"$field_name$\" because:\n"
- "// $disambiguated_reason$\n");
- }
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ variables.find("disambiguated_reason");
+ if (it != variables.end() && !it->second.empty()) {
+ printer->Print(
+ variables,
+ "// An alternative name is used for field \"$field_name$\" because:\n"
+ "// $disambiguated_reason$\n");
+ }
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
index 4c6e278176..09384c483a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h
@@ -1,51 +1,51 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
+
#include <cstdint>
-#include <map>
-#include <memory>
+#include <map>
+#include <memory>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -54,100 +54,100 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableFieldGenerator {
- public:
- ImmutableFieldGenerator() {}
- virtual ~ImmutableFieldGenerator();
-
- virtual int GetNumBitsForMessage() const = 0;
- virtual int GetNumBitsForBuilder() const = 0;
- virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;
- virtual void GenerateMembers(io::Printer* printer) const = 0;
- virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;
- virtual void GenerateInitializationCode(io::Printer* printer) const = 0;
- virtual void GenerateBuilderClearCode(io::Printer* printer) const = 0;
- virtual void GenerateMergingCode(io::Printer* printer) const = 0;
- virtual void GenerateBuildingCode(io::Printer* printer) const = 0;
- virtual void GenerateParsingCode(io::Printer* printer) const = 0;
- virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const;
- virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0;
- virtual void GenerateSerializationCode(io::Printer* printer) const = 0;
- virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0;
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableFieldGenerator {
+ public:
+ ImmutableFieldGenerator() {}
+ virtual ~ImmutableFieldGenerator();
+
+ virtual int GetNumBitsForMessage() const = 0;
+ virtual int GetNumBitsForBuilder() const = 0;
+ virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;
+ virtual void GenerateMembers(io::Printer* printer) const = 0;
+ virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;
+ virtual void GenerateInitializationCode(io::Printer* printer) const = 0;
+ virtual void GenerateBuilderClearCode(io::Printer* printer) const = 0;
+ virtual void GenerateMergingCode(io::Printer* printer) const = 0;
+ virtual void GenerateBuildingCode(io::Printer* printer) const = 0;
+ virtual void GenerateParsingCode(io::Printer* printer) const = 0;
+ virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const;
+ virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0;
+ virtual void GenerateSerializationCode(io::Printer* printer) const = 0;
+ virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0;
virtual void GenerateFieldBuilderInitializationCode(
io::Printer* printer) const = 0;
virtual void GenerateKotlinDslMembers(io::Printer* printer) const = 0;
-
- virtual void GenerateEqualsCode(io::Printer* printer) const = 0;
- virtual void GenerateHashCode(io::Printer* printer) const = 0;
-
+
+ virtual void GenerateEqualsCode(io::Printer* printer) const = 0;
+ virtual void GenerateHashCode(io::Printer* printer) const = 0;
+
virtual TProtoStringType GetBoxedType() const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldGenerator);
-};
-
-class ImmutableFieldLiteGenerator {
- public:
- ImmutableFieldLiteGenerator() {}
- virtual ~ImmutableFieldLiteGenerator();
-
- virtual int GetNumBitsForMessage() const = 0;
- virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;
- virtual void GenerateMembers(io::Printer* printer) const = 0;
- virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;
- virtual void GenerateInitializationCode(io::Printer* printer) const = 0;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldGenerator);
+};
+
+class ImmutableFieldLiteGenerator {
+ public:
+ ImmutableFieldLiteGenerator() {}
+ virtual ~ImmutableFieldLiteGenerator();
+
+ virtual int GetNumBitsForMessage() const = 0;
+ virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;
+ virtual void GenerateMembers(io::Printer* printer) const = 0;
+ virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;
+ virtual void GenerateInitializationCode(io::Printer* printer) const = 0;
virtual void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const = 0;
virtual void GenerateKotlinDslMembers(io::Printer* printer) const = 0;
-
+
virtual TProtoStringType GetBoxedType() const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldLiteGenerator);
-};
-
-
-// Convenience class which constructs FieldGenerators for a Descriptor.
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldLiteGenerator);
+};
+
+
+// Convenience class which constructs FieldGenerators for a Descriptor.
template <typename FieldGeneratorType>
-class FieldGeneratorMap {
- public:
+class FieldGeneratorMap {
+ public:
explicit FieldGeneratorMap(const Descriptor* descriptor, Context* context);
- ~FieldGeneratorMap();
-
- const FieldGeneratorType& get(const FieldDescriptor* field) const;
-
- private:
- const Descriptor* descriptor_;
+ ~FieldGeneratorMap();
+
+ const FieldGeneratorType& get(const FieldDescriptor* field) const;
+
+ private:
+ const Descriptor* descriptor_;
std::vector<std::unique_ptr<FieldGeneratorType>> field_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
-};
-
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
+};
+
template <typename FieldGeneratorType>
inline const FieldGeneratorType& FieldGeneratorMap<FieldGeneratorType>::get(
const FieldDescriptor* field) const {
- GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
- return *field_generators_[field->index()];
-}
-
-// Instantiate template for mutable and immutable maps.
+ GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);
+ return *field_generators_[field->index()];
+}
+
+// Instantiate template for mutable and immutable maps.
template <>
FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
const Descriptor* descriptor, Context* context);
-
+
template <>
-FieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap();
-
-
+FieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap();
+
+
template <>
FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(
const Descriptor* descriptor, Context* context);
@@ -156,36 +156,36 @@ template <>
FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap();
-// Field information used in FieldGeneartors.
-struct FieldGeneratorInfo {
+// Field information used in FieldGeneartors.
+struct FieldGeneratorInfo {
TProtoStringType name;
TProtoStringType capitalized_name;
TProtoStringType disambiguated_reason;
-};
-
+};
+
// Oneof information used in OneofFieldGenerators.
-struct OneofGeneratorInfo {
+struct OneofGeneratorInfo {
TProtoStringType name;
TProtoStringType capitalized_name;
-};
-
-// Set some common variables used in variable FieldGenerators.
-void SetCommonFieldVariables(const FieldDescriptor* descriptor,
- const FieldGeneratorInfo* info,
+};
+
+// Set some common variables used in variable FieldGenerators.
+void SetCommonFieldVariables(const FieldDescriptor* descriptor,
+ const FieldGeneratorInfo* info,
std::map<TProtoStringType, TProtoStringType>* variables);
-
-// Set some common oneof variables used in OneofFieldGenerators.
-void SetCommonOneofVariables(const FieldDescriptor* descriptor,
- const OneofGeneratorInfo* info,
+
+// Set some common oneof variables used in OneofFieldGenerators.
+void SetCommonOneofVariables(const FieldDescriptor* descriptor,
+ const OneofGeneratorInfo* info,
std::map<TProtoStringType, TProtoStringType>* variables);
-
-// Print useful comments before a field's accessors.
+
+// Print useful comments before a field's accessors.
void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
- io::Printer* printer);
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ io::Printer* printer);
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
index ddefc543d7..0809febb8b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc
@@ -1,42 +1,42 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_file.h>
-
-#include <memory>
-#include <set>
-
+
+#include <memory>
+#include <set>
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_enum.h>
#include <google/protobuf/compiler/java/java_enum_lite.h>
@@ -53,177 +53,177 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-namespace {
-
-struct FieldDescriptorCompare {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
+struct FieldDescriptorCompare {
bool operator()(const FieldDescriptor* f1, const FieldDescriptor* f2) const {
if (f1 == NULL) {
- return false;
- }
+ return false;
+ }
if (f2 == NULL) {
- return true;
- }
- return f1->full_name() < f2->full_name();
- }
-};
-
+ return true;
+ }
+ return f1->full_name() < f2->full_name();
+ }
+};
+
typedef std::set<const FieldDescriptor*, FieldDescriptorCompare>
FieldDescriptorSet;
-
-// Recursively searches the given message to collect extensions.
-// Returns true if all the extensions can be recognized. The extensions will be
-// appended in to the extensions parameter.
-// Returns false when there are unknown fields, in which case the data in the
-// extensions output parameter is not reliable and should be discarded.
+
+// Recursively searches the given message to collect extensions.
+// Returns true if all the extensions can be recognized. The extensions will be
+// appended in to the extensions parameter.
+// Returns false when there are unknown fields, in which case the data in the
+// extensions output parameter is not reliable and should be discarded.
bool CollectExtensions(const Message& message, FieldDescriptorSet* extensions) {
- const Reflection* reflection = message.GetReflection();
-
- // There are unknown fields that could be extensions, thus this call fails.
- if (reflection->GetUnknownFields(message).field_count() > 0) return false;
-
+ const Reflection* reflection = message.GetReflection();
+
+ // There are unknown fields that could be extensions, thus this call fails.
+ if (reflection->GetUnknownFields(message).field_count() > 0) return false;
+
std::vector<const FieldDescriptor*> fields;
- reflection->ListFields(message, &fields);
-
- for (int i = 0; i < fields.size(); i++) {
+ reflection->ListFields(message, &fields);
+
+ for (int i = 0; i < fields.size(); i++) {
if (fields[i]->is_extension()) {
extensions->insert(fields[i]);
}
-
- if (GetJavaType(fields[i]) == JAVATYPE_MESSAGE) {
- if (fields[i]->is_repeated()) {
- int size = reflection->FieldSize(message, fields[i]);
- for (int j = 0; j < size; j++) {
- const Message& sub_message =
+
+ if (GetJavaType(fields[i]) == JAVATYPE_MESSAGE) {
+ if (fields[i]->is_repeated()) {
+ int size = reflection->FieldSize(message, fields[i]);
+ for (int j = 0; j < size; j++) {
+ const Message& sub_message =
reflection->GetRepeatedMessage(message, fields[i], j);
- if (!CollectExtensions(sub_message, extensions)) return false;
- }
- } else {
- const Message& sub_message = reflection->GetMessage(message, fields[i]);
- if (!CollectExtensions(sub_message, extensions)) return false;
- }
- }
- }
-
- return true;
-}
-
-// Finds all extensions in the given message and its sub-messages. If the
-// message contains unknown fields (which could be extensions), then those
-// extensions are defined in alternate_pool.
-// The message will be converted to a DynamicMessage backed by alternate_pool
-// in order to handle this case.
-void CollectExtensions(const FileDescriptorProto& file_proto,
- const DescriptorPool& alternate_pool,
- FieldDescriptorSet* extensions,
+ if (!CollectExtensions(sub_message, extensions)) return false;
+ }
+ } else {
+ const Message& sub_message = reflection->GetMessage(message, fields[i]);
+ if (!CollectExtensions(sub_message, extensions)) return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+// Finds all extensions in the given message and its sub-messages. If the
+// message contains unknown fields (which could be extensions), then those
+// extensions are defined in alternate_pool.
+// The message will be converted to a DynamicMessage backed by alternate_pool
+// in order to handle this case.
+void CollectExtensions(const FileDescriptorProto& file_proto,
+ const DescriptorPool& alternate_pool,
+ FieldDescriptorSet* extensions,
const TProtoStringType& file_data) {
- if (!CollectExtensions(file_proto, extensions)) {
- // There are unknown fields in the file_proto, which are probably
- // extensions. We need to parse the data into a dynamic message based on the
- // builder-pool to find out all extensions.
- const Descriptor* file_proto_desc = alternate_pool.FindMessageTypeByName(
- file_proto.GetDescriptor()->full_name());
- GOOGLE_CHECK(file_proto_desc)
- << "Find unknown fields in FileDescriptorProto when building "
- << file_proto.name()
- << ". It's likely that those fields are custom options, however, "
- "descriptor.proto is not in the transitive dependencies. "
- "This normally should not happen. Please report a bug.";
- DynamicMessageFactory factory;
+ if (!CollectExtensions(file_proto, extensions)) {
+ // There are unknown fields in the file_proto, which are probably
+ // extensions. We need to parse the data into a dynamic message based on the
+ // builder-pool to find out all extensions.
+ const Descriptor* file_proto_desc = alternate_pool.FindMessageTypeByName(
+ file_proto.GetDescriptor()->full_name());
+ GOOGLE_CHECK(file_proto_desc)
+ << "Find unknown fields in FileDescriptorProto when building "
+ << file_proto.name()
+ << ". It's likely that those fields are custom options, however, "
+ "descriptor.proto is not in the transitive dependencies. "
+ "This normally should not happen. Please report a bug.";
+ DynamicMessageFactory factory;
std::unique_ptr<Message> dynamic_file_proto(
- factory.GetPrototype(file_proto_desc)->New());
- GOOGLE_CHECK(dynamic_file_proto.get() != NULL);
- GOOGLE_CHECK(dynamic_file_proto->ParseFromString(file_data));
-
- // Collect the extensions again from the dynamic message. There should be no
- // more unknown fields this time, i.e. all the custom options should be
- // parsed as extensions now.
- extensions->clear();
- GOOGLE_CHECK(CollectExtensions(*dynamic_file_proto, extensions))
- << "Find unknown fields in FileDescriptorProto when building "
- << file_proto.name()
- << ". It's likely that those fields are custom options, however, "
- "those options cannot be recognized in the builder pool. "
- "This normally should not happen. Please report a bug.";
- }
-}
-
-// Our static initialization methods can become very, very large.
-// So large that if we aren't careful we end up blowing the JVM's
-// 64K bytes of bytecode/method. Fortunately, since these static
-// methods are executed only once near the beginning of a program,
-// there's usually plenty of stack space available and we can
-// extend our methods by simply chaining them to another method
-// with a tail call. This inserts the sequence call-next-method,
-// end this one, begin-next-method as needed.
+ factory.GetPrototype(file_proto_desc)->New());
+ GOOGLE_CHECK(dynamic_file_proto.get() != NULL);
+ GOOGLE_CHECK(dynamic_file_proto->ParseFromString(file_data));
+
+ // Collect the extensions again from the dynamic message. There should be no
+ // more unknown fields this time, i.e. all the custom options should be
+ // parsed as extensions now.
+ extensions->clear();
+ GOOGLE_CHECK(CollectExtensions(*dynamic_file_proto, extensions))
+ << "Find unknown fields in FileDescriptorProto when building "
+ << file_proto.name()
+ << ". It's likely that those fields are custom options, however, "
+ "those options cannot be recognized in the builder pool. "
+ "This normally should not happen. Please report a bug.";
+ }
+}
+
+// Our static initialization methods can become very, very large.
+// So large that if we aren't careful we end up blowing the JVM's
+// 64K bytes of bytecode/method. Fortunately, since these static
+// methods are executed only once near the beginning of a program,
+// there's usually plenty of stack space available and we can
+// extend our methods by simply chaining them to another method
+// with a tail call. This inserts the sequence call-next-method,
+// end this one, begin-next-method as needed.
void MaybeRestartJavaMethod(io::Printer* printer, int* bytecode_estimate,
int* method_num, const char* chain_statement,
const char* method_decl) {
- // The goal here is to stay under 64K bytes of jvm bytecode/method,
- // since otherwise we hit a hardcoded limit in the jvm and javac will
- // then fail with the error "code too large". This limit lets our
- // estimates be off by a factor of two and still we're okay.
- static const int bytesPerMethod = kMaxStaticSize;
-
- if ((*bytecode_estimate) > bytesPerMethod) {
- ++(*method_num);
+ // The goal here is to stay under 64K bytes of jvm bytecode/method,
+ // since otherwise we hit a hardcoded limit in the jvm and javac will
+ // then fail with the error "code too large". This limit lets our
+ // estimates be off by a factor of two and still we're okay.
+ static const int bytesPerMethod = kMaxStaticSize;
+
+ if ((*bytecode_estimate) > bytesPerMethod) {
+ ++(*method_num);
printer->Print(chain_statement, "method_num", StrCat(*method_num));
- printer->Outdent();
- printer->Print("}\n");
+ printer->Outdent();
+ printer->Print("}\n");
printer->Print(method_decl, "method_num", StrCat(*method_num));
- printer->Indent();
- *bytecode_estimate = 0;
- }
-}
-} // namespace
-
-FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options,
- bool immutable_api)
- : file_(file),
- java_package_(FileJavaPackage(file, immutable_api)),
+ printer->Indent();
+ *bytecode_estimate = 0;
+ }
+}
+} // namespace
+
+FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options,
+ bool immutable_api)
+ : file_(file),
+ java_package_(FileJavaPackage(file, immutable_api)),
message_generators_(file->message_type_count()),
extension_generators_(file->extension_count()),
- context_(new Context(file, options)),
- name_resolver_(context_->GetNameResolver()),
- options_(options),
- immutable_api_(immutable_api) {
- classname_ = name_resolver_->GetFileClassName(file, immutable_api);
+ context_(new Context(file, options)),
+ name_resolver_(context_->GetNameResolver()),
+ options_(options),
+ immutable_api_(immutable_api) {
+ classname_ = name_resolver_->GetFileClassName(file, immutable_api);
generator_factory_.reset(new ImmutableGeneratorFactory(context_.get()));
- for (int i = 0; i < file_->message_type_count(); ++i) {
- message_generators_[i].reset(
- generator_factory_->NewMessageGenerator(file_->message_type(i)));
- }
- for (int i = 0; i < file_->extension_count(); ++i) {
- extension_generators_[i].reset(
- generator_factory_->NewExtensionGenerator(file_->extension(i)));
- }
-}
-
-FileGenerator::~FileGenerator() {}
-
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ message_generators_[i].reset(
+ generator_factory_->NewMessageGenerator(file_->message_type(i)));
+ }
+ for (int i = 0; i < file_->extension_count(); ++i) {
+ extension_generators_[i].reset(
+ generator_factory_->NewExtensionGenerator(file_->extension(i)));
+ }
+}
+
+FileGenerator::~FileGenerator() {}
+
bool FileGenerator::Validate(TProtoStringType* error) {
- // Check that no class name matches the file's class name. This is a common
- // problem that leads to Java compile errors that can be hard to understand.
- // It's especially bad when using the java_multiple_files, since we would
- // end up overwriting the outer class with one of the inner ones.
+ // Check that no class name matches the file's class name. This is a common
+ // problem that leads to Java compile errors that can be hard to understand.
+ // It's especially bad when using the java_multiple_files, since we would
+ // end up overwriting the outer class with one of the inner ones.
if (name_resolver_->HasConflictingClassName(file_, classname_,
NameEquality::EXACT_EQUAL)) {
- error->assign(file_->name());
- error->append(
+ error->assign(file_->name());
+ error->append(
": Cannot generate Java output because the file's outer class name, "
"\"");
- error->append(classname_);
- error->append(
+ error->append(classname_);
+ error->append(
"\", matches the name of one of the types declared inside it. "
"Please either rename the type or use the java_outer_classname "
"option to specify a different outer class name for the .proto file.");
- return false;
- }
+ return false;
+ }
// Similar to the check above, but ignore the case this time. This is not a
// problem on Linux, but will lead to Java compile errors on Windows / Mac
// because filenames are case-insensitive on those platforms.
@@ -250,146 +250,146 @@ bool FileGenerator::Validate(TProtoStringType* error) {
"https://github.com/protocolbuffers/protobuf/blob/master/java/"
"lite.md";
}
- return true;
-}
-
-void FileGenerator::Generate(io::Printer* printer) {
- // We don't import anything because we refer to all classes by their
- // fully-qualified names in the generated source.
- printer->Print(
+ return true;
+}
+
+void FileGenerator::Generate(io::Printer* printer) {
+ // We don't import anything because we refer to all classes by their
+ // fully-qualified names in the generated source.
+ printer->Print(
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"// source: $filename$\n"
"\n",
"filename", file_->name());
- if (!java_package_.empty()) {
- printer->Print(
+ if (!java_package_.empty()) {
+ printer->Print(
"package $package$;\n"
"\n",
"package", java_package_);
- }
- PrintGeneratedAnnotation(
- printer, '$', options_.annotate_code ? classname_ + ".java.pb.meta" : "");
+ }
+ PrintGeneratedAnnotation(
+ printer, '$', options_.annotate_code ? classname_ + ".java.pb.meta" : "");
- printer->Print(
+ printer->Print(
"$deprecation$public final class $classname$ {\n"
- " private $ctor$() {}\n",
+ " private $ctor$() {}\n",
"deprecation",
file_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "classname", classname_, "ctor", classname_);
- printer->Annotate("classname", file_->name());
- printer->Indent();
-
- // -----------------------------------------------------------------
-
- printer->Print(
+ "classname", classname_, "ctor", classname_);
+ printer->Annotate("classname", file_->name());
+ printer->Indent();
+
+ // -----------------------------------------------------------------
+
+ printer->Print(
"public static void registerAllExtensions(\n"
" com.google.protobuf.ExtensionRegistryLite registry) {\n");
-
- printer->Indent();
-
- for (int i = 0; i < file_->extension_count(); i++) {
- extension_generators_[i]->GenerateRegistrationCode(printer);
- }
-
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateExtensionRegistrationCode(printer);
- }
-
- printer->Outdent();
+
+ printer->Indent();
+
+ for (int i = 0; i < file_->extension_count(); i++) {
+ extension_generators_[i]->GenerateRegistrationCode(printer);
+ }
+
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ message_generators_[i]->GenerateExtensionRegistrationCode(printer);
+ }
+
+ printer->Outdent();
printer->Print("}\n");
- if (HasDescriptorMethods(file_, context_->EnforceLite())) {
- // Overload registerAllExtensions for the non-lite usage to
- // redundantly maintain the original signature (this is
- // redundant because ExtensionRegistryLite now invokes
- // ExtensionRegistry in the non-lite usage). Intent is
- // to remove this in the future.
- printer->Print(
+ if (HasDescriptorMethods(file_, context_->EnforceLite())) {
+ // Overload registerAllExtensions for the non-lite usage to
+ // redundantly maintain the original signature (this is
+ // redundant because ExtensionRegistryLite now invokes
+ // ExtensionRegistry in the non-lite usage). Intent is
+ // to remove this in the future.
+ printer->Print(
"\n"
"public static void registerAllExtensions(\n"
" com.google.protobuf.ExtensionRegistry registry) {\n"
" registerAllExtensions(\n"
" (com.google.protobuf.ExtensionRegistryLite) registry);\n"
"}\n");
- }
-
- // -----------------------------------------------------------------
-
- if (!MultipleJavaFiles(file_, immutable_api_)) {
- for (int i = 0; i < file_->enum_type_count(); i++) {
- if (HasDescriptorMethods(file_, context_->EnforceLite())) {
- EnumGenerator(file_->enum_type(i), immutable_api_, context_.get())
- .Generate(printer);
- } else {
- EnumLiteGenerator(file_->enum_type(i), immutable_api_, context_.get())
- .Generate(printer);
- }
- }
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateInterface(printer);
- message_generators_[i]->Generate(printer);
- }
- if (HasGenericServices(file_, context_->EnforceLite())) {
- for (int i = 0; i < file_->service_count(); i++) {
+ }
+
+ // -----------------------------------------------------------------
+
+ if (!MultipleJavaFiles(file_, immutable_api_)) {
+ for (int i = 0; i < file_->enum_type_count(); i++) {
+ if (HasDescriptorMethods(file_, context_->EnforceLite())) {
+ EnumGenerator(file_->enum_type(i), immutable_api_, context_.get())
+ .Generate(printer);
+ } else {
+ EnumLiteGenerator(file_->enum_type(i), immutable_api_, context_.get())
+ .Generate(printer);
+ }
+ }
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ message_generators_[i]->GenerateInterface(printer);
+ message_generators_[i]->Generate(printer);
+ }
+ if (HasGenericServices(file_, context_->EnforceLite())) {
+ for (int i = 0; i < file_->service_count(); i++) {
std::unique_ptr<ServiceGenerator> generator(
- generator_factory_->NewServiceGenerator(file_->service(i)));
- generator->Generate(printer);
- }
- }
- }
-
- // Extensions must be generated in the outer class since they are values,
- // not classes.
- for (int i = 0; i < file_->extension_count(); i++) {
- extension_generators_[i]->Generate(printer);
- }
-
- // Static variables. We'd like them to be final if possible, but due to
- // the JVM's 64k size limit on static blocks, we have to initialize some
- // of them in methods; thus they cannot be final.
- int static_block_bytecode_estimate = 0;
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateStaticVariables(
- printer, &static_block_bytecode_estimate);
- }
-
- printer->Print("\n");
-
- if (HasDescriptorMethods(file_, context_->EnforceLite())) {
- if (immutable_api_) {
- GenerateDescriptorInitializationCodeForImmutable(printer);
- } else {
- GenerateDescriptorInitializationCodeForMutable(printer);
- }
- } else {
+ generator_factory_->NewServiceGenerator(file_->service(i)));
+ generator->Generate(printer);
+ }
+ }
+ }
+
+ // Extensions must be generated in the outer class since they are values,
+ // not classes.
+ for (int i = 0; i < file_->extension_count(); i++) {
+ extension_generators_[i]->Generate(printer);
+ }
+
+ // Static variables. We'd like them to be final if possible, but due to
+ // the JVM's 64k size limit on static blocks, we have to initialize some
+ // of them in methods; thus they cannot be final.
+ int static_block_bytecode_estimate = 0;
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ message_generators_[i]->GenerateStaticVariables(
+ printer, &static_block_bytecode_estimate);
+ }
+
+ printer->Print("\n");
+
+ if (HasDescriptorMethods(file_, context_->EnforceLite())) {
+ if (immutable_api_) {
+ GenerateDescriptorInitializationCodeForImmutable(printer);
+ } else {
+ GenerateDescriptorInitializationCodeForMutable(printer);
+ }
+ } else {
printer->Print("static {\n");
- printer->Indent();
- int bytecode_estimate = 0;
- int method_num = 0;
-
- for (int i = 0; i < file_->message_type_count(); i++) {
+ printer->Indent();
+ int bytecode_estimate = 0;
+ int method_num = 0;
+
+ for (int i = 0; i < file_->message_type_count(); i++) {
bytecode_estimate +=
message_generators_[i]->GenerateStaticVariableInitializers(printer);
- MaybeRestartJavaMethod(
+ MaybeRestartJavaMethod(
printer, &bytecode_estimate, &method_num,
"_clinit_autosplit_$method_num$();\n",
"private static void _clinit_autosplit_$method_num$() {\n");
- }
-
- printer->Outdent();
+ }
+
+ printer->Outdent();
printer->Print("}\n");
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(outer_class_scope)\n");
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
- io::Printer* printer) {
- printer->Print(
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
+ io::Printer* printer) {
+ printer->Print(
"public static com.google.protobuf.Descriptors.FileDescriptor\n"
" getDescriptor() {\n"
" return descriptor;\n"
@@ -399,92 +399,92 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
"static {\n",
// TODO(dweis): Mark this as final.
"final", "");
- printer->Indent();
-
- SharedCodeGenerator shared_code_generator(file_, options_);
- shared_code_generator.GenerateDescriptors(printer);
-
- int bytecode_estimate = 0;
- int method_num = 0;
-
- for (int i = 0; i < file_->message_type_count(); i++) {
+ printer->Indent();
+
+ SharedCodeGenerator shared_code_generator(file_, options_);
+ shared_code_generator.GenerateDescriptors(printer);
+
+ int bytecode_estimate = 0;
+ int method_num = 0;
+
+ for (int i = 0; i < file_->message_type_count(); i++) {
bytecode_estimate +=
message_generators_[i]->GenerateStaticVariableInitializers(printer);
- MaybeRestartJavaMethod(
+ MaybeRestartJavaMethod(
printer, &bytecode_estimate, &method_num,
"_clinit_autosplit_dinit_$method_num$();\n",
"private static void _clinit_autosplit_dinit_$method_num$() {\n");
- }
- for (int i = 0; i < file_->extension_count(); i++) {
+ }
+ for (int i = 0; i < file_->extension_count(); i++) {
bytecode_estimate +=
extension_generators_[i]->GenerateNonNestedInitializationCode(printer);
- MaybeRestartJavaMethod(
+ MaybeRestartJavaMethod(
printer, &bytecode_estimate, &method_num,
"_clinit_autosplit_dinit_$method_num$();\n",
"private static void _clinit_autosplit_dinit_$method_num$() {\n");
- }
-
- // Proto compiler builds a DescriptorPool, which holds all the descriptors to
- // generate, when processing the ".proto" files. We call this DescriptorPool
- // the parsed pool (a.k.a. file_->pool()).
- //
- // Note that when users try to extend the (.*)DescriptorProto in their
- // ".proto" files, it does not affect the pre-built FileDescriptorProto class
- // in proto compiler. When we put the descriptor data in the file_proto, those
- // extensions become unknown fields.
- //
- // Now we need to find out all the extension value to the (.*)DescriptorProto
- // in the file_proto message, and prepare an ExtensionRegistry to return.
- //
- // To find those extensions, we need to parse the data into a dynamic message
- // of the FileDescriptor based on the builder-pool, then we can use
- // reflections to find all extension fields
- FileDescriptorProto file_proto;
- file_->CopyTo(&file_proto);
+ }
+
+ // Proto compiler builds a DescriptorPool, which holds all the descriptors to
+ // generate, when processing the ".proto" files. We call this DescriptorPool
+ // the parsed pool (a.k.a. file_->pool()).
+ //
+ // Note that when users try to extend the (.*)DescriptorProto in their
+ // ".proto" files, it does not affect the pre-built FileDescriptorProto class
+ // in proto compiler. When we put the descriptor data in the file_proto, those
+ // extensions become unknown fields.
+ //
+ // Now we need to find out all the extension value to the (.*)DescriptorProto
+ // in the file_proto message, and prepare an ExtensionRegistry to return.
+ //
+ // To find those extensions, we need to parse the data into a dynamic message
+ // of the FileDescriptor based on the builder-pool, then we can use
+ // reflections to find all extension fields
+ FileDescriptorProto file_proto;
+ file_->CopyTo(&file_proto);
TProtoStringType file_data;
- file_proto.SerializeToString(&file_data);
- FieldDescriptorSet extensions;
- CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
-
- if (extensions.size() > 0) {
- // Must construct an ExtensionRegistry containing all existing extensions
- // and use it to parse the descriptor data again to recognize extensions.
- printer->Print(
+ file_proto.SerializeToString(&file_data);
+ FieldDescriptorSet extensions;
+ CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
+
+ if (extensions.size() > 0) {
+ // Must construct an ExtensionRegistry containing all existing extensions
+ // and use it to parse the descriptor data again to recognize extensions.
+ printer->Print(
"com.google.protobuf.ExtensionRegistry registry =\n"
" com.google.protobuf.ExtensionRegistry.newInstance();\n");
- FieldDescriptorSet::iterator it;
- for (it = extensions.begin(); it != extensions.end(); it++) {
+ FieldDescriptorSet::iterator it;
+ for (it = extensions.begin(); it != extensions.end(); it++) {
std::unique_ptr<ExtensionGenerator> generator(
- generator_factory_->NewExtensionGenerator(*it));
- bytecode_estimate += generator->GenerateRegistrationCode(printer);
- MaybeRestartJavaMethod(
+ generator_factory_->NewExtensionGenerator(*it));
+ bytecode_estimate += generator->GenerateRegistrationCode(printer);
+ MaybeRestartJavaMethod(
printer, &bytecode_estimate, &method_num,
"_clinit_autosplit_dinit_$method_num$(registry);\n",
"private static void _clinit_autosplit_dinit_$method_num$(\n"
" com.google.protobuf.ExtensionRegistry registry) {\n");
- }
- printer->Print(
+ }
+ printer->Print(
"com.google.protobuf.Descriptors.FileDescriptor\n"
" .internalUpdateFileDescriptor(descriptor, registry);\n");
- }
-
- // Force descriptor initialization of all dependencies.
- for (int i = 0; i < file_->dependency_count(); i++) {
- if (ShouldIncludeDependency(file_->dependency(i), true)) {
+ }
+
+ // Force descriptor initialization of all dependencies.
+ for (int i = 0; i < file_->dependency_count(); i++) {
+ if (ShouldIncludeDependency(file_->dependency(i), true)) {
TProtoStringType dependency =
- name_resolver_->GetImmutableClassName(file_->dependency(i));
+ name_resolver_->GetImmutableClassName(file_->dependency(i));
printer->Print("$dependency$.getDescriptor();\n", "dependency",
dependency);
- }
- }
-
- printer->Outdent();
+ }
+ }
+
+ printer->Outdent();
printer->Print("}\n");
-}
-
+}
+
void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
io::Printer* printer) {
- printer->Print(
+ printer->Print(
"public static com.google.protobuf.Descriptors.FileDescriptor\n"
" getDescriptor() {\n"
" return descriptor;\n"
@@ -492,33 +492,33 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
"private static final com.google.protobuf.Descriptors.FileDescriptor\n"
" descriptor;\n"
"static {\n");
- printer->Indent();
-
- printer->Print(
+ printer->Indent();
+
+ printer->Print(
"descriptor = $immutable_package$.$descriptor_classname$.descriptor;\n",
"immutable_package", FileJavaPackage(file_, true), "descriptor_classname",
name_resolver_->GetDescriptorClassName(file_));
-
- for (int i = 0; i < file_->message_type_count(); i++) {
- message_generators_[i]->GenerateStaticVariableInitializers(printer);
- }
- for (int i = 0; i < file_->extension_count(); i++) {
- extension_generators_[i]->GenerateNonNestedInitializationCode(printer);
- }
-
- // Check if custom options exist. If any, try to load immutable classes since
- // custom options are only represented with immutable messages.
- FileDescriptorProto file_proto;
- file_->CopyTo(&file_proto);
+
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ message_generators_[i]->GenerateStaticVariableInitializers(printer);
+ }
+ for (int i = 0; i < file_->extension_count(); i++) {
+ extension_generators_[i]->GenerateNonNestedInitializationCode(printer);
+ }
+
+ // Check if custom options exist. If any, try to load immutable classes since
+ // custom options are only represented with immutable messages.
+ FileDescriptorProto file_proto;
+ file_->CopyTo(&file_proto);
TProtoStringType file_data;
- file_proto.SerializeToString(&file_data);
- FieldDescriptorSet extensions;
- CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
-
- if (extensions.size() > 0) {
- // Try to load immutable messages' outer class. Its initialization code
- // will take care of interpreting custom options.
- printer->Print(
+ file_proto.SerializeToString(&file_data);
+ FieldDescriptorSet extensions;
+ CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
+
+ if (extensions.size() > 0) {
+ // Try to load immutable messages' outer class. Its initialization code
+ // will take care of interpreting custom options.
+ printer->Print(
"try {\n"
// Note that we have to load the immutable class dynamically here as
// we want the mutable code to be independent from the immutable code
@@ -570,23 +570,23 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
printer->Outdent();
printer->Print("}\n");
- }
-
- // Force descriptor initialization of all dependencies.
- for (int i = 0; i < file_->dependency_count(); i++) {
- if (ShouldIncludeDependency(file_->dependency(i), false)) {
+ }
+
+ // Force descriptor initialization of all dependencies.
+ for (int i = 0; i < file_->dependency_count(); i++) {
+ if (ShouldIncludeDependency(file_->dependency(i), false)) {
TProtoStringType dependency =
name_resolver_->GetMutableClassName(file_->dependency(i));
printer->Print("$dependency$.getDescriptor();\n", "dependency",
dependency);
- }
- }
-
- printer->Outdent();
+ }
+ }
+
+ printer->Outdent();
printer->Print("}\n");
-}
-
-template <typename GeneratorClass, typename DescriptorClass>
+}
+
+template <typename GeneratorClass, typename DescriptorClass>
static void GenerateSibling(
const TProtoStringType& package_dir, const TProtoStringType& java_package,
const DescriptorClass* descriptor, GeneratorContext* context,
@@ -596,85 +596,85 @@ static void GenerateSibling(
void (GeneratorClass::*pfn)(io::Printer* printer)) {
TProtoStringType filename =
package_dir + descriptor->name() + name_suffix + ".java";
- file_list->push_back(filename);
+ file_list->push_back(filename);
TProtoStringType info_full_path = filename + ".pb.meta";
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
-
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
+
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- io::Printer printer(output.get(), '$',
- annotate_code ? &annotation_collector : NULL);
-
- printer.Print(
+ io::Printer printer(output.get(), '$',
+ annotate_code ? &annotation_collector : NULL);
+
+ printer.Print(
"// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"// source: $filename$\n"
"\n",
"filename", descriptor->file()->name());
- if (!java_package.empty()) {
- printer.Print(
+ if (!java_package.empty()) {
+ printer.Print(
"package $package$;\n"
"\n",
"package", java_package);
- }
-
- (generator->*pfn)(&printer);
-
- if (annotate_code) {
+ }
+
+ (generator->*pfn)(&printer);
+
+ if (annotate_code) {
std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- context->Open(info_full_path));
- annotations.SerializeToZeroCopyStream(info_output.get());
- annotation_list->push_back(info_full_path);
- }
-}
-
+ context->Open(info_full_path));
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ annotation_list->push_back(info_full_path);
+ }
+}
+
void FileGenerator::GenerateSiblings(
const TProtoStringType& package_dir, GeneratorContext* context,
std::vector<TProtoStringType>* file_list,
std::vector<TProtoStringType>* annotation_list) {
- if (MultipleJavaFiles(file_, immutable_api_)) {
- for (int i = 0; i < file_->enum_type_count(); i++) {
- if (HasDescriptorMethods(file_, context_->EnforceLite())) {
- EnumGenerator generator(file_->enum_type(i), immutable_api_,
- context_.get());
- GenerateSibling<EnumGenerator>(
- package_dir, java_package_, file_->enum_type(i), context, file_list,
- options_.annotate_code, annotation_list, "", &generator,
- &EnumGenerator::Generate);
- } else {
- EnumLiteGenerator generator(file_->enum_type(i), immutable_api_,
- context_.get());
- GenerateSibling<EnumLiteGenerator>(
- package_dir, java_package_, file_->enum_type(i), context, file_list,
- options_.annotate_code, annotation_list, "", &generator,
- &EnumLiteGenerator::Generate);
- }
- }
- for (int i = 0; i < file_->message_type_count(); i++) {
- if (immutable_api_) {
- GenerateSibling<MessageGenerator>(
- package_dir, java_package_, file_->message_type(i), context,
- file_list, options_.annotate_code, annotation_list, "OrBuilder",
- message_generators_[i].get(), &MessageGenerator::GenerateInterface);
- }
- GenerateSibling<MessageGenerator>(
- package_dir, java_package_, file_->message_type(i), context,
- file_list, options_.annotate_code, annotation_list, "",
- message_generators_[i].get(), &MessageGenerator::Generate);
- }
- if (HasGenericServices(file_, context_->EnforceLite())) {
- for (int i = 0; i < file_->service_count(); i++) {
+ if (MultipleJavaFiles(file_, immutable_api_)) {
+ for (int i = 0; i < file_->enum_type_count(); i++) {
+ if (HasDescriptorMethods(file_, context_->EnforceLite())) {
+ EnumGenerator generator(file_->enum_type(i), immutable_api_,
+ context_.get());
+ GenerateSibling<EnumGenerator>(
+ package_dir, java_package_, file_->enum_type(i), context, file_list,
+ options_.annotate_code, annotation_list, "", &generator,
+ &EnumGenerator::Generate);
+ } else {
+ EnumLiteGenerator generator(file_->enum_type(i), immutable_api_,
+ context_.get());
+ GenerateSibling<EnumLiteGenerator>(
+ package_dir, java_package_, file_->enum_type(i), context, file_list,
+ options_.annotate_code, annotation_list, "", &generator,
+ &EnumLiteGenerator::Generate);
+ }
+ }
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ if (immutable_api_) {
+ GenerateSibling<MessageGenerator>(
+ package_dir, java_package_, file_->message_type(i), context,
+ file_list, options_.annotate_code, annotation_list, "OrBuilder",
+ message_generators_[i].get(), &MessageGenerator::GenerateInterface);
+ }
+ GenerateSibling<MessageGenerator>(
+ package_dir, java_package_, file_->message_type(i), context,
+ file_list, options_.annotate_code, annotation_list, "",
+ message_generators_[i].get(), &MessageGenerator::Generate);
+ }
+ if (HasGenericServices(file_, context_->EnforceLite())) {
+ for (int i = 0; i < file_->service_count(); i++) {
std::unique_ptr<ServiceGenerator> generator(
- generator_factory_->NewServiceGenerator(file_->service(i)));
- GenerateSibling<ServiceGenerator>(
- package_dir, java_package_, file_->service(i), context, file_list,
- options_.annotate_code, annotation_list, "", generator.get(),
- &ServiceGenerator::Generate);
- }
- }
- }
-}
-
+ generator_factory_->NewServiceGenerator(file_->service(i)));
+ GenerateSibling<ServiceGenerator>(
+ package_dir, java_package_, file_->service(i), context, file_list,
+ options_.annotate_code, annotation_list, "", generator.get(),
+ &ServiceGenerator::Generate);
+ }
+ }
+ }
+}
+
TProtoStringType FileGenerator::GetKotlinClassname() {
return name_resolver_->GetFileClassName(file_, immutable_api_, true);
}
@@ -725,10 +725,10 @@ void FileGenerator::GenerateKotlinSiblings(
bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor,
bool immutable_api) {
- return true;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return true;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h
index b182dd06a2..b567b62fd9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.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.
-
-// Author: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
-
-#include <memory>
+// 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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
+
+#include <memory>
#include <string>
-#include <vector>
+#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_options.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FileDescriptor; // descriptor.h
namespace io {
class Printer; // printer.h
-}
+}
namespace compiler {
class GeneratorContext; // code_generator.h
namespace java {
@@ -59,67 +59,67 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class FileGenerator {
- public:
- FileGenerator(const FileDescriptor* file, const Options& options,
- bool immutable_api = true);
- ~FileGenerator();
-
- // Checks for problems that would otherwise lead to cryptic compile errors.
- // Returns true if there are no problems, or writes an error description to
- // the given string and returns false otherwise.
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class FileGenerator {
+ public:
+ FileGenerator(const FileDescriptor* file, const Options& options,
+ bool immutable_api = true);
+ ~FileGenerator();
+
+ // Checks for problems that would otherwise lead to cryptic compile errors.
+ // Returns true if there are no problems, or writes an error description to
+ // the given string and returns false otherwise.
bool Validate(TProtoStringType* error);
-
- void Generate(io::Printer* printer);
-
+
+ void Generate(io::Printer* printer);
+
TProtoStringType GetKotlinClassname();
void GenerateKotlinSiblings(const TProtoStringType& package_dir,
GeneratorContext* generator_context,
std::vector<TProtoStringType>* file_list,
std::vector<TProtoStringType>* annotation_list);
- // If we aren't putting everything into one file, this will write all the
- // files other than the outer file (i.e. one for each message, enum, and
- // service type).
+ // If we aren't putting everything into one file, this will write all the
+ // files other than the outer file (i.e. one for each message, enum, and
+ // service type).
void GenerateSiblings(const TProtoStringType& package_dir,
- GeneratorContext* generator_context,
+ GeneratorContext* generator_context,
std::vector<TProtoStringType>* file_list,
std::vector<TProtoStringType>* annotation_list);
-
+
const TProtoStringType& java_package() { return java_package_; }
const TProtoStringType& classname() { return classname_; }
-
- private:
- void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer);
- void GenerateDescriptorInitializationCodeForMutable(io::Printer* printer);
-
- bool ShouldIncludeDependency(const FileDescriptor* descriptor,
- bool immutable_api_);
-
- const FileDescriptor* file_;
+
+ private:
+ void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer);
+ void GenerateDescriptorInitializationCodeForMutable(io::Printer* printer);
+
+ bool ShouldIncludeDependency(const FileDescriptor* descriptor,
+ bool immutable_api_);
+
+ const FileDescriptor* file_;
TProtoStringType java_package_;
TProtoStringType classname_;
-
+
std::vector<std::unique_ptr<MessageGenerator>> message_generators_;
std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
std::unique_ptr<GeneratorFactory> generator_factory_;
std::unique_ptr<Context> context_;
- ClassNameResolver* name_resolver_;
- const Options options_;
- bool immutable_api_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+ const Options options_;
+ bool immutable_api_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
index 985700e5a8..2b5728579e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc
@@ -1,42 +1,42 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_generator.h>
-
-#include <memory>
-
+
+#include <memory>
+
#include <google/protobuf/compiler/java/java_file.h>
#include <google/protobuf/compiler/java/java_generator_factory.h>
#include <google/protobuf/compiler/java/java_helpers.h>
@@ -48,164 +48,164 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-
-JavaGenerator::JavaGenerator() {}
-JavaGenerator::~JavaGenerator() {}
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+
+JavaGenerator::JavaGenerator() {}
+JavaGenerator::~JavaGenerator() {}
+
uint64_t JavaGenerator::GetSupportedFeatures() const {
return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
}
-bool JavaGenerator::Generate(const FileDescriptor* file,
+bool JavaGenerator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
- GeneratorContext* context,
+ GeneratorContext* context,
TProtoStringType* error) const {
- // -----------------------------------------------------------------
- // parse generator options
-
+ // -----------------------------------------------------------------
+ // parse generator options
+
std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
- ParseGeneratorParameter(parameter, &options);
- Options file_options;
-
- for (int i = 0; i < options.size(); i++) {
- if (options[i].first == "output_list_file") {
- file_options.output_list_file = options[i].second;
- } else if (options[i].first == "immutable") {
- file_options.generate_immutable_code = true;
- } else if (options[i].first == "mutable") {
- file_options.generate_mutable_code = true;
- } else if (options[i].first == "shared") {
- file_options.generate_shared_code = true;
+ ParseGeneratorParameter(parameter, &options);
+ Options file_options;
+
+ for (int i = 0; i < options.size(); i++) {
+ if (options[i].first == "output_list_file") {
+ file_options.output_list_file = options[i].second;
+ } else if (options[i].first == "immutable") {
+ file_options.generate_immutable_code = true;
+ } else if (options[i].first == "mutable") {
+ file_options.generate_mutable_code = true;
+ } else if (options[i].first == "shared") {
+ file_options.generate_shared_code = true;
} else if (options[i].first == "lite") {
// Note: Java Lite does not guarantee API/ABI stability. We may choose to
// break existing API in order to boost performance / reduce code size.
file_options.enforce_lite = true;
- } else if (options[i].first == "annotate_code") {
- file_options.annotate_code = true;
- } else if (options[i].first == "annotation_list_file") {
- file_options.annotation_list_file = options[i].second;
- } else {
- *error = "Unknown generator option: " + options[i].first;
- return false;
- }
- }
-
- if (file_options.enforce_lite && file_options.generate_mutable_code) {
- *error = "lite runtime generator option cannot be used with mutable API.";
- return false;
- }
-
- // By default we generate immutable code and shared code for immutable API.
- if (!file_options.generate_immutable_code &&
- !file_options.generate_mutable_code &&
- !file_options.generate_shared_code) {
- file_options.generate_immutable_code = true;
- file_options.generate_shared_code = true;
- }
-
- // -----------------------------------------------------------------
-
-
+ } else if (options[i].first == "annotate_code") {
+ file_options.annotate_code = true;
+ } else if (options[i].first == "annotation_list_file") {
+ file_options.annotation_list_file = options[i].second;
+ } else {
+ *error = "Unknown generator option: " + options[i].first;
+ return false;
+ }
+ }
+
+ if (file_options.enforce_lite && file_options.generate_mutable_code) {
+ *error = "lite runtime generator option cannot be used with mutable API.";
+ return false;
+ }
+
+ // By default we generate immutable code and shared code for immutable API.
+ if (!file_options.generate_immutable_code &&
+ !file_options.generate_mutable_code &&
+ !file_options.generate_shared_code) {
+ file_options.generate_immutable_code = true;
+ file_options.generate_shared_code = true;
+ }
+
+ // -----------------------------------------------------------------
+
+
std::vector<TProtoStringType> all_files;
std::vector<TProtoStringType> all_annotations;
-
-
+
+
std::vector<FileGenerator*> file_generators;
- if (file_options.generate_immutable_code) {
- file_generators.push_back(new FileGenerator(file, file_options,
- /* immutable = */ true));
- }
- if (file_options.generate_mutable_code) {
- file_generators.push_back(new FileGenerator(file, file_options,
- /* mutable = */ false));
- }
-
- for (int i = 0; i < file_generators.size(); ++i) {
- if (!file_generators[i]->Validate(error)) {
- for (int j = 0; j < file_generators.size(); ++j) {
- delete file_generators[j];
- }
- return false;
- }
- }
-
- for (int i = 0; i < file_generators.size(); ++i) {
- FileGenerator* file_generator = file_generators[i];
-
+ if (file_options.generate_immutable_code) {
+ file_generators.push_back(new FileGenerator(file, file_options,
+ /* immutable = */ true));
+ }
+ if (file_options.generate_mutable_code) {
+ file_generators.push_back(new FileGenerator(file, file_options,
+ /* mutable = */ false));
+ }
+
+ for (int i = 0; i < file_generators.size(); ++i) {
+ if (!file_generators[i]->Validate(error)) {
+ for (int j = 0; j < file_generators.size(); ++j) {
+ delete file_generators[j];
+ }
+ return false;
+ }
+ }
+
+ for (int i = 0; i < file_generators.size(); ++i) {
+ FileGenerator* file_generator = file_generators[i];
+
TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
-
+
TProtoStringType java_filename = package_dir;
- java_filename += file_generator->classname();
- java_filename += ".java";
- all_files.push_back(java_filename);
+ java_filename += file_generator->classname();
+ java_filename += ".java";
+ all_files.push_back(java_filename);
TProtoStringType info_full_path = java_filename + ".pb.meta";
- if (file_options.annotate_code) {
- all_annotations.push_back(info_full_path);
- }
-
- // Generate main java file.
+ if (file_options.annotate_code) {
+ all_annotations.push_back(info_full_path);
+ }
+
+ // Generate main java file.
std::unique_ptr<io::ZeroCopyOutputStream> output(
- context->Open(java_filename));
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
+ context->Open(java_filename));
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
io::Printer printer(
output.get(), '$',
file_options.annotate_code ? &annotation_collector : NULL);
-
- file_generator->Generate(&printer);
-
- // Generate sibling files.
- file_generator->GenerateSiblings(package_dir, context, &all_files,
- &all_annotations);
-
- if (file_options.annotate_code) {
+
+ file_generator->Generate(&printer);
+
+ // Generate sibling files.
+ file_generator->GenerateSiblings(package_dir, context, &all_files,
+ &all_annotations);
+
+ if (file_options.annotate_code) {
std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- context->Open(info_full_path));
- annotations.SerializeToZeroCopyStream(info_output.get());
- }
- }
-
-
- for (int i = 0; i < file_generators.size(); ++i) {
- delete file_generators[i];
- }
- file_generators.clear();
-
- // Generate output list if requested.
- if (!file_options.output_list_file.empty()) {
- // Generate output list. This is just a simple text file placed in a
- // deterministic location which lists the .java files being generated.
+ context->Open(info_full_path));
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ }
+ }
+
+
+ for (int i = 0; i < file_generators.size(); ++i) {
+ delete file_generators[i];
+ }
+ file_generators.clear();
+
+ // Generate output list if requested.
+ if (!file_options.output_list_file.empty()) {
+ // Generate output list. This is just a simple text file placed in a
+ // deterministic location which lists the .java files being generated.
std::unique_ptr<io::ZeroCopyOutputStream> srclist_raw_output(
- context->Open(file_options.output_list_file));
- io::Printer srclist_printer(srclist_raw_output.get(), '$');
- for (int i = 0; i < all_files.size(); i++) {
- srclist_printer.Print("$filename$\n", "filename", all_files[i]);
- }
- }
-
- if (!file_options.annotation_list_file.empty()) {
- // Generate output list. This is just a simple text file placed in a
- // deterministic location which lists the .java files being generated.
+ context->Open(file_options.output_list_file));
+ io::Printer srclist_printer(srclist_raw_output.get(), '$');
+ for (int i = 0; i < all_files.size(); i++) {
+ srclist_printer.Print("$filename$\n", "filename", all_files[i]);
+ }
+ }
+
+ if (!file_options.annotation_list_file.empty()) {
+ // Generate output list. This is just a simple text file placed in a
+ // deterministic location which lists the .java files being generated.
std::unique_ptr<io::ZeroCopyOutputStream> annotation_list_raw_output(
- context->Open(file_options.annotation_list_file));
- io::Printer annotation_list_printer(annotation_list_raw_output.get(), '$');
- for (int i = 0; i < all_annotations.size(); i++) {
- annotation_list_printer.Print("$filename$\n", "filename",
- all_annotations[i]);
- }
- }
-
- return true;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ context->Open(file_options.annotation_list_file));
+ io::Printer annotation_list_printer(annotation_list_raw_output.get(), '$');
+ for (int i = 0; i < all_annotations.size(); i++) {
+ annotation_list_printer.Print("$filename$\n", "filename",
+ all_annotations[i]);
+ }
+ }
+
+ return true;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h
index fda70afb50..90d2610550 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Generates Java code for a given .proto file.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Generates Java code for a given .proto file.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
+
#include <string>
#include <google/protobuf/compiler/code_generator.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-// CodeGenerator implementation which generates Java code. If you create your
-// own protocol compiler binary and you want it to support Java 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 java {
+
+// CodeGenerator implementation which generates Java code. If you create your
+// own protocol compiler binary and you want it to support Java output, you
+// can do so by registering an instance of this CodeGenerator with the
+// CommandLineInterface in your main() function.
class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
- public:
- JavaGenerator();
- ~JavaGenerator();
-
- // implements CodeGenerator ----------------------------------------
+ public:
+ JavaGenerator();
+ ~JavaGenerator();
+
+ // implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
GeneratorContext* context, TProtoStringType* error) const override;
-
+
uint64_t GetSupportedFeatures() const override;
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc
index 549df0114b..3a62adb103 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc
@@ -1,37 +1,37 @@
-// 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: liujisi@google.com (Pherl Liu)
-
+// 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: liujisi@google.com (Pherl Liu)
+
#include <google/protobuf/compiler/java/java_generator_factory.h>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_enum_field.h>
#include <google/protobuf/compiler/java/java_extension.h>
@@ -41,46 +41,46 @@
#include <google/protobuf/compiler/java/java_message.h>
#include <google/protobuf/compiler/java/java_message_lite.h>
#include <google/protobuf/compiler/java/java_service.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-GeneratorFactory::GeneratorFactory() {}
-GeneratorFactory::~GeneratorFactory() {}
-
-// ===================================================================
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+GeneratorFactory::GeneratorFactory() {}
+GeneratorFactory::~GeneratorFactory() {}
+
+// ===================================================================
+
ImmutableGeneratorFactory::ImmutableGeneratorFactory(Context* context)
: context_(context) {}
-ImmutableGeneratorFactory::~ImmutableGeneratorFactory() {}
-
-MessageGenerator* ImmutableGeneratorFactory::NewMessageGenerator(
- const Descriptor* descriptor) const {
- if (HasDescriptorMethods(descriptor, context_->EnforceLite())) {
- return new ImmutableMessageGenerator(descriptor, context_);
- } else {
- return new ImmutableMessageLiteGenerator(descriptor, context_);
- }
-}
-
-ExtensionGenerator* ImmutableGeneratorFactory::NewExtensionGenerator(
- const FieldDescriptor* descriptor) const {
- if (HasDescriptorMethods(descriptor->file(), context_->EnforceLite())) {
- return new ImmutableExtensionGenerator(descriptor, context_);
- } else {
- return new ImmutableExtensionLiteGenerator(descriptor, context_);
- }
-}
-
-ServiceGenerator* ImmutableGeneratorFactory::NewServiceGenerator(
- const ServiceDescriptor* descriptor) const {
- return new ImmutableServiceGenerator(descriptor, context_);
-}
-
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ImmutableGeneratorFactory::~ImmutableGeneratorFactory() {}
+
+MessageGenerator* ImmutableGeneratorFactory::NewMessageGenerator(
+ const Descriptor* descriptor) const {
+ if (HasDescriptorMethods(descriptor, context_->EnforceLite())) {
+ return new ImmutableMessageGenerator(descriptor, context_);
+ } else {
+ return new ImmutableMessageLiteGenerator(descriptor, context_);
+ }
+}
+
+ExtensionGenerator* ImmutableGeneratorFactory::NewExtensionGenerator(
+ const FieldDescriptor* descriptor) const {
+ if (HasDescriptorMethods(descriptor->file(), context_->EnforceLite())) {
+ return new ImmutableExtensionGenerator(descriptor, context_);
+ } else {
+ return new ImmutableExtensionLiteGenerator(descriptor, context_);
+ }
+}
+
+ServiceGenerator* ImmutableGeneratorFactory::NewServiceGenerator(
+ const ServiceDescriptor* descriptor) const {
+ return new ImmutableServiceGenerator(descriptor, context_);
+}
+
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
index 557f4e30b9..16688a56d0 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h
@@ -1,42 +1,42 @@
-// 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: liujisi@google.com (Pherl Liu)
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_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: liujisi@google.com (Pherl Liu)
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
+
#include <google/protobuf/stubs/common.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FieldDescriptor; // descriptor.h
class Descriptor; // descriptor.h
class ServiceDescriptor; // descriptor.h
@@ -50,54 +50,54 @@ class Context; // context.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class GeneratorFactory {
- public:
- GeneratorFactory();
- virtual ~GeneratorFactory();
-
- virtual MessageGenerator* NewMessageGenerator(
- const Descriptor* descriptor) const = 0;
-
- virtual ExtensionGenerator* NewExtensionGenerator(
- const FieldDescriptor* descriptor) const = 0;
-
- virtual ServiceGenerator* NewServiceGenerator(
- const ServiceDescriptor* descriptor) const = 0;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorFactory);
-};
-
-// Factory that creates generators for immutable-default messages.
-class ImmutableGeneratorFactory : public GeneratorFactory {
- public:
- ImmutableGeneratorFactory(Context* context);
- virtual ~ImmutableGeneratorFactory();
-
- virtual MessageGenerator* NewMessageGenerator(
- const Descriptor* descriptor) const;
-
- virtual ExtensionGenerator* NewExtensionGenerator(
- const FieldDescriptor* descriptor) const;
-
- virtual ServiceGenerator* NewServiceGenerator(
- const ServiceDescriptor* descriptor) const;
-
- private:
- Context* context_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableGeneratorFactory);
-};
-
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class GeneratorFactory {
+ public:
+ GeneratorFactory();
+ virtual ~GeneratorFactory();
+
+ virtual MessageGenerator* NewMessageGenerator(
+ const Descriptor* descriptor) const = 0;
+
+ virtual ExtensionGenerator* NewExtensionGenerator(
+ const FieldDescriptor* descriptor) const = 0;
+
+ virtual ServiceGenerator* NewServiceGenerator(
+ const ServiceDescriptor* descriptor) const = 0;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorFactory);
+};
+
+// Factory that creates generators for immutable-default messages.
+class ImmutableGeneratorFactory : public GeneratorFactory {
+ public:
+ ImmutableGeneratorFactory(Context* context);
+ virtual ~ImmutableGeneratorFactory();
+
+ virtual MessageGenerator* NewMessageGenerator(
+ const Descriptor* descriptor) const;
+
+ virtual ExtensionGenerator* NewExtensionGenerator(
+ const FieldDescriptor* descriptor) const;
+
+ virtual ServiceGenerator* NewServiceGenerator(
+ const ServiceDescriptor* descriptor) const;
+
+ private:
+ Context* context_;
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableGeneratorFactory);
+};
+
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
index adb62daccc..a498388ade 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc
@@ -1,45 +1,45 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_helpers.h>
-#include <algorithm>
+#include <algorithm>
#include <cstdint>
-#include <limits>
+#include <limits>
#include <unordered_set>
-#include <vector>
-
+#include <vector>
+
#include <google/protobuf/stubs/stringprintf.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/compiler/java/java_names.h>
@@ -48,35 +48,35 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/hash.h> // for hash<T *>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-const char kThickSeparator[] =
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+const char kThickSeparator[] =
"// ===================================================================\n";
-const char kThinSeparator[] =
+const char kThinSeparator[] =
"// -------------------------------------------------------------------\n";
-
-namespace {
-
-const char* kDefaultPackage = "";
-
-// Names that should be avoided as field names.
-// Using them will cause the compiler to generate accessors whose names are
-// colliding with methods defined in base classes.
-const char* kForbiddenWordList[] = {
+
+namespace {
+
+const char* kDefaultPackage = "";
+
+// Names that should be avoided as field names.
+// Using them will cause the compiler to generate accessors whose names are
+// colliding with methods defined in base classes.
+const char* kForbiddenWordList[] = {
// message base class:
"cached_size",
"serialized_size",
// java.lang.Object:
"class",
-};
-
+};
+
const std::unordered_set<TProtoStringType>* kReservedNames =
new std::unordered_set<TProtoStringType>({
"abstract", "assert", "boolean", "break", "byte",
@@ -92,49 +92,49 @@ const std::unordered_set<TProtoStringType>* kReservedNames =
});
bool IsForbidden(const TProtoStringType& field_name) {
- for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
- if (field_name == kForbiddenWordList[i]) {
- return true;
- }
- }
- return false;
-}
-
+ for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
+ if (field_name == kForbiddenWordList[i]) {
+ return true;
+ }
+ }
+ return false;
+}
+
TProtoStringType FieldName(const FieldDescriptor* field) {
TProtoStringType field_name;
- // Groups are hacky: The name of the field is just the lower-cased name
- // of the group type. In Java, though, we would like to retain the original
- // capitalization of the type name.
- if (GetType(field) == FieldDescriptor::TYPE_GROUP) {
- field_name = field->message_type()->name();
- } else {
- field_name = field->name();
- }
- if (IsForbidden(field_name)) {
- // Append a trailing "#" to indicate that the name should be decorated to
- // avoid collision with other names.
- field_name += "#";
- }
- return field_name;
-}
-
-
-} // namespace
-
-void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
+ // Groups are hacky: The name of the field is just the lower-cased name
+ // of the group type. In Java, though, we would like to retain the original
+ // capitalization of the type name.
+ if (GetType(field) == FieldDescriptor::TYPE_GROUP) {
+ field_name = field->message_type()->name();
+ } else {
+ field_name = field->name();
+ }
+ if (IsForbidden(field_name)) {
+ // Append a trailing "#" to indicate that the name should be decorated to
+ // avoid collision with other names.
+ field_name += "#";
+ }
+ return field_name;
+}
+
+
+} // namespace
+
+void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
const TProtoStringType& annotation_file) {
- if (annotation_file.empty()) {
- return;
- }
+ if (annotation_file.empty()) {
+ return;
+ }
TProtoStringType ptemplate =
- "@javax.annotation.Generated(value=\"protoc\", comments=\"annotations:";
- ptemplate.push_back(delimiter);
- ptemplate.append("annotation_file");
- ptemplate.push_back(delimiter);
- ptemplate.append("\")\n");
- printer->Print(ptemplate.c_str(), "annotation_file", annotation_file);
-}
-
+ "@javax.annotation.Generated(value=\"protoc\", comments=\"annotations:";
+ ptemplate.push_back(delimiter);
+ ptemplate.append("annotation_file");
+ ptemplate.push_back(delimiter);
+ ptemplate.append("\")\n");
+ printer->Print(ptemplate.c_str(), "annotation_file", annotation_file);
+}
+
void PrintEnumVerifierLogic(io::Printer* printer,
const FieldDescriptor* descriptor,
const std::map<TProtoStringType, TProtoStringType>& variables,
@@ -160,39 +160,39 @@ TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
bool cap_next_letter) {
GOOGLE_CHECK(!input.empty());
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') {
- if (i == 0 && !cap_next_letter) {
- // Force first letter to lower-case unless explicitly told to
- // capitalize it.
- result += input[i] + ('a' - 'A');
- } else {
- // Capital letters after the first 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;
- }
- }
- // Add a trailing "_" if the name should be altered.
- if (input[input.size() - 1] == '#') {
- result += '_';
- }
- return 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') {
+ if (i == 0 && !cap_next_letter) {
+ // Force first letter to lower-case unless explicitly told to
+ // capitalize it.
+ result += input[i] + ('a' - 'A');
+ } else {
+ // Capital letters after the first 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;
+ }
+ }
+ // Add a trailing "_" if the name should be altered.
+ if (input[input.size() - 1] == '#') {
+ result += '_';
+ }
+ return result;
+}
+
TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
bool capitalize_next = !lower_first;
TProtoStringType result;
@@ -226,21 +226,21 @@ char ToLowerCh(char ch) {
}
TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field) {
- return UnderscoresToCamelCase(FieldName(field), false);
-}
-
+ return UnderscoresToCamelCase(FieldName(field), false);
+}
+
TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
- return UnderscoresToCamelCase(FieldName(field), true);
-}
-
+ return UnderscoresToCamelCase(FieldName(field), true);
+}
+
TProtoStringType CapitalizedFieldName(const FieldDescriptor* field) {
return UnderscoresToCapitalizedCamelCase(field);
}
TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method) {
- return UnderscoresToCamelCase(method->name(), false);
-}
-
+ return UnderscoresToCamelCase(method->name(), false);
+}
+
TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {
TProtoStringType name = UnderscoresToCamelCase(field);
if (kReservedNames->find(name) != kReservedNames->end()) {
@@ -266,9 +266,9 @@ bool IsForbiddenKotlin(const TProtoStringType& field_name) {
}
TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor) {
- return "static_" + StringReplace(descriptor->full_name(), ".", "_", true);
-}
-
+ return "static_" + StringReplace(descriptor->full_name(), ".", "_", true);
+}
+
TProtoStringType CamelCaseFieldName(const FieldDescriptor* field) {
TProtoStringType fieldName = UnderscoresToCamelCase(field);
if ('0' <= fieldName[0] && fieldName[0] <= '9') {
@@ -278,134 +278,134 @@ TProtoStringType CamelCaseFieldName(const FieldDescriptor* field) {
}
TProtoStringType FileClassName(const FileDescriptor* file, bool immutable) {
- ClassNameResolver name_resolver;
- return name_resolver.GetFileClassName(file, immutable);
-}
-
+ ClassNameResolver name_resolver;
+ return name_resolver.GetFileClassName(file, immutable);
+}
+
TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable) {
TProtoStringType result;
-
- if (file->options().has_java_package()) {
- result = file->options().java_package();
- } else {
- result = kDefaultPackage;
- if (!file->package().empty()) {
- if (!result.empty()) result += '.';
- result += file->package();
- }
- }
-
- return result;
-}
-
+
+ if (file->options().has_java_package()) {
+ result = file->options().java_package();
+ } else {
+ result = kDefaultPackage;
+ if (!file->package().empty()) {
+ if (!result.empty()) result += '.';
+ result += file->package();
+ }
+ }
+
+ return result;
+}
+
TProtoStringType FileJavaPackage(const FileDescriptor* file) {
return FileJavaPackage(file, true /* immutable */);
}
TProtoStringType JavaPackageToDir(TProtoStringType package_name) {
TProtoStringType package_dir = StringReplace(package_name, ".", "/", true);
- if (!package_dir.empty()) package_dir += "/";
- return package_dir;
-}
-
+ if (!package_dir.empty()) package_dir += "/";
+ return package_dir;
+}
+
TProtoStringType ClassName(const Descriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
TProtoStringType ClassName(const EnumDescriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
TProtoStringType ClassName(const ServiceDescriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
TProtoStringType ClassName(const FileDescriptor* descriptor) {
- ClassNameResolver name_resolver;
- return name_resolver.GetClassName(descriptor, true);
-}
-
+ ClassNameResolver name_resolver;
+ return name_resolver.GetClassName(descriptor, true);
+}
+
TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor) {
TProtoStringType interfaces = "// @@protoc_insertion_point(message_implements:" +
descriptor->full_name() + ")";
- return interfaces;
-}
-
-
+ return interfaces;
+}
+
+
TProtoStringType ExtraBuilderInterfaces(const Descriptor* descriptor) {
TProtoStringType interfaces = "// @@protoc_insertion_point(builder_implements:" +
descriptor->full_name() + ")";
- return interfaces;
-}
-
+ return interfaces;
+}
+
TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor) {
TProtoStringType interfaces = "// @@protoc_insertion_point(interface_extends:" +
descriptor->full_name() + ")";
- return interfaces;
-}
-
+ return interfaces;
+}
+
TProtoStringType FieldConstantName(const FieldDescriptor* field) {
TProtoStringType name = field->name() + "_FIELD_NUMBER";
ToUpper(&name);
- return name;
-}
-
-FieldDescriptor::Type GetType(const FieldDescriptor* field) {
- return field->type();
-}
-
-JavaType GetJavaType(const FieldDescriptor* field) {
- switch (GetType(field)) {
- case FieldDescriptor::TYPE_INT32:
- case FieldDescriptor::TYPE_UINT32:
- case FieldDescriptor::TYPE_SINT32:
- case FieldDescriptor::TYPE_FIXED32:
- case FieldDescriptor::TYPE_SFIXED32:
- return JAVATYPE_INT;
-
- case FieldDescriptor::TYPE_INT64:
- case FieldDescriptor::TYPE_UINT64:
- case FieldDescriptor::TYPE_SINT64:
- case FieldDescriptor::TYPE_FIXED64:
- case FieldDescriptor::TYPE_SFIXED64:
- return JAVATYPE_LONG;
-
- case FieldDescriptor::TYPE_FLOAT:
- return JAVATYPE_FLOAT;
-
- case FieldDescriptor::TYPE_DOUBLE:
- return JAVATYPE_DOUBLE;
-
- case FieldDescriptor::TYPE_BOOL:
- return JAVATYPE_BOOLEAN;
-
- case FieldDescriptor::TYPE_STRING:
- return JAVATYPE_STRING;
-
- case FieldDescriptor::TYPE_BYTES:
- return JAVATYPE_BYTES;
-
- case FieldDescriptor::TYPE_ENUM:
- return JAVATYPE_ENUM;
-
- case FieldDescriptor::TYPE_GROUP:
- case FieldDescriptor::TYPE_MESSAGE:
- return JAVATYPE_MESSAGE;
-
+ return name;
+}
+
+FieldDescriptor::Type GetType(const FieldDescriptor* field) {
+ return field->type();
+}
+
+JavaType GetJavaType(const FieldDescriptor* field) {
+ switch (GetType(field)) {
+ case FieldDescriptor::TYPE_INT32:
+ case FieldDescriptor::TYPE_UINT32:
+ case FieldDescriptor::TYPE_SINT32:
+ case FieldDescriptor::TYPE_FIXED32:
+ case FieldDescriptor::TYPE_SFIXED32:
+ return JAVATYPE_INT;
+
+ case FieldDescriptor::TYPE_INT64:
+ case FieldDescriptor::TYPE_UINT64:
+ case FieldDescriptor::TYPE_SINT64:
+ case FieldDescriptor::TYPE_FIXED64:
+ case FieldDescriptor::TYPE_SFIXED64:
+ return JAVATYPE_LONG;
+
+ case FieldDescriptor::TYPE_FLOAT:
+ return JAVATYPE_FLOAT;
+
+ case FieldDescriptor::TYPE_DOUBLE:
+ return JAVATYPE_DOUBLE;
+
+ case FieldDescriptor::TYPE_BOOL:
+ return JAVATYPE_BOOLEAN;
+
+ case FieldDescriptor::TYPE_STRING:
+ return JAVATYPE_STRING;
+
+ case FieldDescriptor::TYPE_BYTES:
+ return JAVATYPE_BYTES;
+
+ case FieldDescriptor::TYPE_ENUM:
+ return JAVATYPE_ENUM;
+
+ case FieldDescriptor::TYPE_GROUP:
+ case FieldDescriptor::TYPE_MESSAGE:
+ return JAVATYPE_MESSAGE;
+
// No default because we want the compiler to complain if any new
// types are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return JAVATYPE_INT;
-}
-
-const char* PrimitiveTypeName(JavaType type) {
- switch (type) {
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return JAVATYPE_INT;
+}
+
+const char* PrimitiveTypeName(JavaType type) {
+ switch (type) {
case JAVATYPE_INT:
return "int";
case JAVATYPE_LONG:
@@ -424,21 +424,21 @@ const char* PrimitiveTypeName(JavaType type) {
return NULL;
case JAVATYPE_MESSAGE:
return NULL;
-
+
// No default because we want the compiler to complain if any new
// JavaTypes are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
-}
-
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return NULL;
+}
+
const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
return PrimitiveTypeName(GetJavaType(descriptor));
}
-const char* BoxedPrimitiveTypeName(JavaType type) {
- switch (type) {
+const char* BoxedPrimitiveTypeName(JavaType type) {
+ switch (type) {
case JAVATYPE_INT:
return "java.lang.Integer";
case JAVATYPE_LONG:
@@ -457,15 +457,15 @@ const char* BoxedPrimitiveTypeName(JavaType type) {
return NULL;
case JAVATYPE_MESSAGE:
return NULL;
-
+
// No default because we want the compiler to complain if any new
// JavaTypes are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return NULL;
-}
-
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return NULL;
+}
+
const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) {
return BoxedPrimitiveTypeName(GetJavaType(descriptor));
}
@@ -511,8 +511,8 @@ TProtoStringType GetOneofStoredType(const FieldDescriptor* field) {
}
}
-const char* FieldTypeName(FieldDescriptor::Type field_type) {
- switch (field_type) {
+const char* FieldTypeName(FieldDescriptor::Type field_type) {
+ switch (field_type) {
case FieldDescriptor::TYPE_INT32:
return "INT32";
case FieldDescriptor::TYPE_UINT32:
@@ -549,222 +549,222 @@ const char* FieldTypeName(FieldDescriptor::Type field_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 NULL;
-}
-
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return NULL;
+}
+
bool AllAscii(const TProtoStringType& text) {
- for (int i = 0; i < text.size(); i++) {
- if ((text[i] & 0x80) != 0) {
- return false;
- }
- }
- return true;
-}
-
+ for (int i = 0; i < text.size(); i++) {
+ if ((text[i] & 0x80) != 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
ClassNameResolver* name_resolver) {
- // Switch on CppType since we need to know which default_value_* method
- // of FieldDescriptor to call.
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
+ // Switch on CppType since we need to know which default_value_* method
+ // of FieldDescriptor to call.
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
return StrCat(field->default_value_int32());
- case FieldDescriptor::CPPTYPE_UINT32:
- // Need to print as a signed int since Java has no unsigned.
+ case FieldDescriptor::CPPTYPE_UINT32:
+ // Need to print as a signed int since Java has no unsigned.
return StrCat(static_cast<int32_t>(field->default_value_uint32()));
- case FieldDescriptor::CPPTYPE_INT64:
+ case FieldDescriptor::CPPTYPE_INT64:
return StrCat(field->default_value_int64()) + "L";
- case FieldDescriptor::CPPTYPE_UINT64:
+ case FieldDescriptor::CPPTYPE_UINT64:
return StrCat(static_cast<int64_t>(field->default_value_uint64())) +
- "L";
- case FieldDescriptor::CPPTYPE_DOUBLE: {
- double value = field->default_value_double();
+ "L";
+ case FieldDescriptor::CPPTYPE_DOUBLE: {
+ double value = field->default_value_double();
if (value == std::numeric_limits<double>::infinity()) {
- return "Double.POSITIVE_INFINITY";
+ return "Double.POSITIVE_INFINITY";
} else if (value == -std::numeric_limits<double>::infinity()) {
- return "Double.NEGATIVE_INFINITY";
- } else if (value != value) {
- return "Double.NaN";
- } else {
- return SimpleDtoa(value) + "D";
- }
- }
- case FieldDescriptor::CPPTYPE_FLOAT: {
- float value = field->default_value_float();
+ return "Double.NEGATIVE_INFINITY";
+ } else if (value != value) {
+ return "Double.NaN";
+ } else {
+ return SimpleDtoa(value) + "D";
+ }
+ }
+ case FieldDescriptor::CPPTYPE_FLOAT: {
+ float value = field->default_value_float();
if (value == std::numeric_limits<float>::infinity()) {
- return "Float.POSITIVE_INFINITY";
+ return "Float.POSITIVE_INFINITY";
} else if (value == -std::numeric_limits<float>::infinity()) {
- return "Float.NEGATIVE_INFINITY";
- } else if (value != value) {
- return "Float.NaN";
- } else {
- return SimpleFtoa(value) + "F";
- }
- }
- case FieldDescriptor::CPPTYPE_BOOL:
- return field->default_value_bool() ? "true" : "false";
- case FieldDescriptor::CPPTYPE_STRING:
- if (GetType(field) == FieldDescriptor::TYPE_BYTES) {
- if (field->has_default_value()) {
- // See comments in Internal.java for gory details.
- return strings::Substitute(
+ return "Float.NEGATIVE_INFINITY";
+ } else if (value != value) {
+ return "Float.NaN";
+ } else {
+ return SimpleFtoa(value) + "F";
+ }
+ }
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field->default_value_bool() ? "true" : "false";
+ case FieldDescriptor::CPPTYPE_STRING:
+ if (GetType(field) == FieldDescriptor::TYPE_BYTES) {
+ if (field->has_default_value()) {
+ // See comments in Internal.java for gory details.
+ return strings::Substitute(
"com.google.protobuf.Internal.bytesDefaultValue(\"$0\")",
CEscape(field->default_value_string()));
- } else {
- return "com.google.protobuf.ByteString.EMPTY";
- }
- } else {
- if (AllAscii(field->default_value_string())) {
- // All chars are ASCII. In this case CEscape() works fine.
- return "\"" + CEscape(field->default_value_string()) + "\"";
- } else {
- // See comments in Internal.java for gory details.
- return strings::Substitute(
- "com.google.protobuf.Internal.stringDefaultValue(\"$0\")",
- CEscape(field->default_value_string()));
- }
- }
-
- case FieldDescriptor::CPPTYPE_ENUM:
- return name_resolver->GetClassName(field->enum_type(), immutable) + "." +
+ } else {
+ return "com.google.protobuf.ByteString.EMPTY";
+ }
+ } else {
+ if (AllAscii(field->default_value_string())) {
+ // All chars are ASCII. In this case CEscape() works fine.
+ return "\"" + CEscape(field->default_value_string()) + "\"";
+ } else {
+ // See comments in Internal.java for gory details.
+ return strings::Substitute(
+ "com.google.protobuf.Internal.stringDefaultValue(\"$0\")",
+ CEscape(field->default_value_string()));
+ }
+ }
+
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return name_resolver->GetClassName(field->enum_type(), immutable) + "." +
field->default_value_enum()->name();
-
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return name_resolver->GetClassName(field->message_type(), immutable) +
+
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return name_resolver->GetClassName(field->message_type(), immutable) +
".getDefaultInstance()";
-
+
// No default because we want the compiler to complain if any new
// types are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return "";
-}
-
-bool IsDefaultValueJavaDefault(const FieldDescriptor* field) {
- // Switch on CppType since we need to know which default_value_* method
- // of FieldDescriptor to call.
- switch (field->cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
- return field->default_value_int32() == 0;
- case FieldDescriptor::CPPTYPE_UINT32:
- return field->default_value_uint32() == 0;
- case FieldDescriptor::CPPTYPE_INT64:
- return field->default_value_int64() == 0L;
- case FieldDescriptor::CPPTYPE_UINT64:
- return field->default_value_uint64() == 0L;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- return field->default_value_double() == 0.0;
- case FieldDescriptor::CPPTYPE_FLOAT:
- return field->default_value_float() == 0.0;
- case FieldDescriptor::CPPTYPE_BOOL:
- return field->default_value_bool() == false;
- case FieldDescriptor::CPPTYPE_ENUM:
- return field->default_value_enum()->number() == 0;
- case FieldDescriptor::CPPTYPE_STRING:
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return false;
-
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return "";
+}
+
+bool IsDefaultValueJavaDefault(const FieldDescriptor* field) {
+ // Switch on CppType since we need to know which default_value_* method
+ // of FieldDescriptor to call.
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
+ return field->default_value_int32() == 0;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ return field->default_value_uint32() == 0;
+ case FieldDescriptor::CPPTYPE_INT64:
+ return field->default_value_int64() == 0L;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ return field->default_value_uint64() == 0L;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ return field->default_value_double() == 0.0;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ return field->default_value_float() == 0.0;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field->default_value_bool() == false;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ return field->default_value_enum()->number() == 0;
+ case FieldDescriptor::CPPTYPE_STRING:
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return false;
+
// No default because we want the compiler to complain if any new
// types are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return false;
-}
-
-bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) {
- return GetJavaType(field) == JAVATYPE_BYTES &&
- field->default_value_string() != "";
-}
-
-const char* bit_masks[] = {
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return false;
+}
+
+bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) {
+ return GetJavaType(field) == JAVATYPE_BYTES &&
+ field->default_value_string() != "";
+}
+
+const char* bit_masks[] = {
"0x00000001", "0x00000002", "0x00000004", "0x00000008",
"0x00000010", "0x00000020", "0x00000040", "0x00000080",
-
+
"0x00000100", "0x00000200", "0x00000400", "0x00000800",
"0x00001000", "0x00002000", "0x00004000", "0x00008000",
-
+
"0x00010000", "0x00020000", "0x00040000", "0x00080000",
"0x00100000", "0x00200000", "0x00400000", "0x00800000",
-
+
"0x01000000", "0x02000000", "0x04000000", "0x08000000",
"0x10000000", "0x20000000", "0x40000000", "0x80000000",
-};
-
+};
+
TProtoStringType GetBitFieldName(int index) {
TProtoStringType varName = "bitField";
varName += StrCat(index);
- varName += "_";
- return varName;
-}
-
+ varName += "_";
+ return varName;
+}
+
TProtoStringType GetBitFieldNameForBit(int bitIndex) {
- return GetBitFieldName(bitIndex / 32);
-}
-
-namespace {
-
+ return GetBitFieldName(bitIndex / 32);
+}
+
+namespace {
+
TProtoStringType GenerateGetBitInternal(const TProtoStringType& prefix, int bitIndex) {
TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
- int bitInVarIndex = bitIndex % 32;
-
+ int bitInVarIndex = bitIndex % 32;
+
TProtoStringType mask = bit_masks[bitInVarIndex];
TProtoStringType result = "((" + varName + " & " + mask + ") != 0)";
- return result;
-}
-
+ return result;
+}
+
TProtoStringType GenerateSetBitInternal(const TProtoStringType& prefix, int bitIndex) {
TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
- int bitInVarIndex = bitIndex % 32;
-
+ int bitInVarIndex = bitIndex % 32;
+
TProtoStringType mask = bit_masks[bitInVarIndex];
TProtoStringType result = varName + " |= " + mask;
- return result;
-}
-
-} // namespace
-
+ return result;
+}
+
+} // namespace
+
TProtoStringType GenerateGetBit(int bitIndex) {
- return GenerateGetBitInternal("", bitIndex);
-}
-
+ return GenerateGetBitInternal("", bitIndex);
+}
+
TProtoStringType GenerateSetBit(int bitIndex) {
- return GenerateSetBitInternal("", bitIndex);
-}
-
+ return GenerateSetBitInternal("", bitIndex);
+}
+
TProtoStringType GenerateClearBit(int bitIndex) {
TProtoStringType varName = GetBitFieldNameForBit(bitIndex);
- int bitInVarIndex = bitIndex % 32;
-
+ int bitInVarIndex = bitIndex % 32;
+
TProtoStringType mask = bit_masks[bitInVarIndex];
TProtoStringType result = varName + " = (" + varName + " & ~" + mask + ")";
- return result;
-}
-
+ return result;
+}
+
TProtoStringType GenerateGetBitFromLocal(int bitIndex) {
- return GenerateGetBitInternal("from_", bitIndex);
-}
-
+ return GenerateGetBitInternal("from_", bitIndex);
+}
+
TProtoStringType GenerateSetBitToLocal(int bitIndex) {
- return GenerateSetBitInternal("to_", bitIndex);
-}
-
+ return GenerateSetBitInternal("to_", bitIndex);
+}
+
TProtoStringType GenerateGetBitMutableLocal(int bitIndex) {
- return GenerateGetBitInternal("mutable_", bitIndex);
-}
-
+ return GenerateGetBitInternal("mutable_", bitIndex);
+}
+
TProtoStringType GenerateSetBitMutableLocal(int bitIndex) {
- return GenerateSetBitInternal("mutable_", bitIndex);
-}
-
-bool IsReferenceType(JavaType type) {
- switch (type) {
+ return GenerateSetBitInternal("mutable_", bitIndex);
+}
+
+bool IsReferenceType(JavaType type) {
+ switch (type) {
case JAVATYPE_INT:
return false;
case JAVATYPE_LONG:
@@ -783,17 +783,17 @@ bool IsReferenceType(JavaType type) {
return true;
case JAVATYPE_MESSAGE:
return true;
-
+
// No default because we want the compiler to complain if any new
// JavaTypes are added.
- }
-
- GOOGLE_LOG(FATAL) << "Can't get here.";
- return false;
-}
-
-const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
- switch (GetType(field)) {
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return false;
+}
+
+const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
+ switch (GetType(field)) {
case FieldDescriptor::TYPE_INT32:
return "Int32";
case FieldDescriptor::TYPE_UINT32:
@@ -823,27 +823,27 @@ const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
case FieldDescriptor::TYPE_STRING:
return "String";
case FieldDescriptor::TYPE_BYTES: {
- return "Bytes";
- }
+ return "Bytes";
+ }
case FieldDescriptor::TYPE_ENUM:
return "Enum";
case FieldDescriptor::TYPE_GROUP:
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 NULL;
-}
-
-// For encodings with fixed sizes, returns that size in bytes. Otherwise
-// returns -1.
-int FixedSize(FieldDescriptor::Type type) {
- switch (type) {
+ }
+
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return NULL;
+}
+
+// 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:
@@ -868,12 +868,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:
@@ -882,82 +882,82 @@ 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;
-}
-
-// Sort the fields of the given Descriptor by number into a new[]'d array
-// and return it. The caller should delete the returned array.
-const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
- const FieldDescriptor** fields =
+ }
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ return -1;
+}
+
+// Sort the fields of the given Descriptor by number into a new[]'d array
+// and return it. The caller should delete the returned array.
+const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
+ const FieldDescriptor** fields =
new const FieldDescriptor*[descriptor->field_count()];
- for (int i = 0; i < descriptor->field_count(); i++) {
- fields[i] = descriptor->field(i);
- }
- std::sort(fields, fields + descriptor->field_count(),
- FieldOrderingByNumber());
- return fields;
-}
-
-// Returns true if the message type has any required fields. If it doesn't,
-// we can optimize out calls to its isInitialized() method.
-//
-// already_seen is used to avoid checking the same type multiple times
-// (and also to protect against recursion).
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ fields[i] = descriptor->field(i);
+ }
+ std::sort(fields, fields + descriptor->field_count(),
+ FieldOrderingByNumber());
+ return fields;
+}
+
+// Returns true if the message type has any required fields. If it doesn't,
+// we can optimize out calls to its isInitialized() method.
+//
+// already_seen is used to avoid checking the same type multiple times
+// (and also to protect against recursion).
bool HasRequiredFields(const Descriptor* type,
std::unordered_set<const Descriptor*>* already_seen) {
- if (already_seen->count(type) > 0) {
- // The type is already in cache. This means that either:
- // a. The type has no required fields.
- // b. We are in the midst of checking if the type has required fields,
- // somewhere up the stack. In this case, we know that if the type
- // has any required fields, they'll be found when we return to it,
- // and the whole call to HasRequiredFields() will return true.
- // Therefore, we don't have to check if this type has required fields
- // here.
- return false;
- }
- already_seen->insert(type);
-
- // If the type has extensions, an extension with message type could contain
- // required fields, so we have to be conservative and assume such an
- // extension exists.
- if (type->extension_range_count() > 0) return true;
-
- for (int i = 0; i < type->field_count(); i++) {
- const FieldDescriptor* field = type->field(i);
- if (field->is_required()) {
- return true;
- }
- if (GetJavaType(field) == JAVATYPE_MESSAGE) {
- if (HasRequiredFields(field->message_type(), already_seen)) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool HasRequiredFields(const Descriptor* type) {
+ if (already_seen->count(type) > 0) {
+ // The type is already in cache. This means that either:
+ // a. The type has no required fields.
+ // b. We are in the midst of checking if the type has required fields,
+ // somewhere up the stack. In this case, we know that if the type
+ // has any required fields, they'll be found when we return to it,
+ // and the whole call to HasRequiredFields() will return true.
+ // Therefore, we don't have to check if this type has required fields
+ // here.
+ return false;
+ }
+ already_seen->insert(type);
+
+ // If the type has extensions, an extension with message type could contain
+ // required fields, so we have to be conservative and assume such an
+ // extension exists.
+ if (type->extension_range_count() > 0) return true;
+
+ for (int i = 0; i < type->field_count(); i++) {
+ const FieldDescriptor* field = type->field(i);
+ if (field->is_required()) {
+ return true;
+ }
+ if (GetJavaType(field) == JAVATYPE_MESSAGE) {
+ if (HasRequiredFields(field->message_type(), already_seen)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool HasRequiredFields(const Descriptor* type) {
std::unordered_set<const Descriptor*> already_seen;
- return HasRequiredFields(type, &already_seen);
-}
-
-bool HasRepeatedFields(const Descriptor* descriptor) {
- for (int i = 0; i < descriptor->field_count(); ++i) {
- const FieldDescriptor* field = descriptor->field(i);
- if (field->is_repeated()) {
- return true;
- }
- }
- return false;
-}
-
+ return HasRequiredFields(type, &already_seen);
+}
+
+bool HasRepeatedFields(const Descriptor* descriptor) {
+ for (int i = 0; i < descriptor->field_count(); ++i) {
+ const FieldDescriptor* field = descriptor->field(i);
+ if (field->is_repeated()) {
+ return true;
+ }
+ }
+ return false;
+}
+
// Encode an unsigned 32-bit value into a sequence of UTF-16 characters.
//
// If the value is in [0x0000, 0xD7FF], we encode it with a single character
@@ -1094,7 +1094,7 @@ void EscapeUtf16ToString(uint16_t code, TProtoStringType* output) {
}
}
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
index 1d099a37c9..5acc729c1d 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h
@@ -1,40 +1,40 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
+
#include <cstdint>
#include <string>
@@ -42,30 +42,30 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-// Commonly-used separator comments. Thick is a line of '=', thin is a line
-// of '-'.
-extern const char kThickSeparator[];
-extern const char kThinSeparator[];
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+// Commonly-used separator comments. Thick is a line of '=', thin is a line
+// of '-'.
+extern const char kThickSeparator[];
+extern const char kThinSeparator[];
+
bool IsForbiddenKotlin(const TProtoStringType& field_name);
-// If annotation_file is non-empty, prints a javax.annotation.Generated
-// annotation to the given Printer. annotation_file will be referenced in the
-// annotation's comments field. delimiter should be the Printer's delimiter
-// character. annotation_file will be included verbatim into a Java literal
-// string, so it should not contain quotes or invalid Java escape sequences;
-// however, these are unlikely to appear in practice, as the value of
-// annotation_file should be generated from the filename of the source file
-// being annotated (which in turn must be a Java identifier plus ".java").
-void PrintGeneratedAnnotation(io::Printer* printer, char delimiter = '$',
+// If annotation_file is non-empty, prints a javax.annotation.Generated
+// annotation to the given Printer. annotation_file will be referenced in the
+// annotation's comments field. delimiter should be the Printer's delimiter
+// character. annotation_file will be included verbatim into a Java literal
+// string, so it should not contain quotes or invalid Java escape sequences;
+// however, these are unlikely to appear in practice, as the value of
+// annotation_file should be generated from the filename of the source file
+// being annotated (which in turn must be a Java identifier plus ".java").
+void PrintGeneratedAnnotation(io::Printer* printer, char delimiter = '$',
const TProtoStringType& annotation_file = "");
-
+
// If a GeneratedMessageLite contains non-lite enums, then its verifier
// must be instantiated inline, rather than retrieved from the enum class.
void PrintEnumVerifierLogic(io::Printer* printer,
@@ -74,8 +74,8 @@ void PrintEnumVerifierLogic(io::Printer* printer,
const char* var_name,
const char* terminating_string, bool enforce_lite);
-// Converts a name to camel-case. If cap_first_letter is true, capitalize the
-// first letter.
+// Converts a name to camel-case. If cap_first_letter is true, capitalize the
+// first letter.
TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first);
char ToUpperCh(char ch);
@@ -85,15 +85,15 @@ char ToLowerCh(char ch);
// first letter.
TProtoStringType UnderscoresToCamelCase(const TProtoStringType& name,
bool cap_first_letter);
-// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
-// "fooBarBaz" or "FooBarBaz", respectively.
+// Converts the field's name to camel-case, e.g. "foo_bar_baz" becomes
+// "fooBarBaz" or "FooBarBaz", respectively.
TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field);
TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
-
-// Similar, but for method names. (Typically, this merely has the effect
-// of lower-casing the first letter of the name.)
+
+// Similar, but for method names. (Typically, this merely has the effect
+// of lower-casing the first letter of the name.)
TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method);
-
+
// Same as UnderscoresToCamelCase, but checks for reserved keywords
TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field);
@@ -101,44 +101,44 @@ TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* fiel
// complete Java identifier by adding a _ if needed.
TProtoStringType CamelCaseFieldName(const FieldDescriptor* field);
-// Get an identifier that uniquely identifies this type within the file.
-// This is used to declare static variables related to this type at the
-// outermost file scope.
+// Get an identifier that uniquely identifies this type within the file.
+// This is used to declare static variables related to this type at the
+// outermost file scope.
TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor);
-
-// Gets the unqualified class name for the file. For each .proto file, there
-// will be one Java class containing all the immutable messages and another
-// Java class containing all the mutable messages.
-// TODO(xiaofeng): remove the default value after updating client code.
+
+// Gets the unqualified class name for the file. For each .proto file, there
+// will be one Java class containing all the immutable messages and another
+// Java class containing all the mutable messages.
+// TODO(xiaofeng): remove the default value after updating client code.
TProtoStringType FileClassName(const FileDescriptor* file, bool immutable = true);
-
-// Returns the file's Java package name.
+
+// Returns the file's Java package name.
TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable);
-
-// Returns output directory for the given package name.
+
+// Returns output directory for the given package name.
TProtoStringType JavaPackageToDir(TProtoStringType package_name);
-
-// Comma-separate list of option-specified interfaces implemented by the
-// Message, to follow the "implements" declaration of the Message definition.
+
+// Comma-separate list of option-specified interfaces implemented by the
+// Message, to follow the "implements" declaration of the Message definition.
TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor);
-// Comma-separate list of option-specified interfaces implemented by the
-// MutableMessage, to follow the "implements" declaration of the MutableMessage
-// definition.
+// Comma-separate list of option-specified interfaces implemented by the
+// MutableMessage, to follow the "implements" declaration of the MutableMessage
+// definition.
TProtoStringType ExtraMutableMessageInterfaces(const Descriptor* descriptor);
-// Comma-separate list of option-specified interfaces implemented by the
-// Builder, to follow the "implements" declaration of the Builder definition.
+// Comma-separate list of option-specified interfaces implemented by the
+// Builder, to follow the "implements" declaration of the Builder definition.
TProtoStringType ExtraBuilderInterfaces(const Descriptor* descriptor);
-// Comma-separate list of option-specified interfaces extended by the
-// MessageOrBuilder, to follow the "extends" declaration of the
-// MessageOrBuilder definition.
+// Comma-separate list of option-specified interfaces extended by the
+// MessageOrBuilder, to follow the "extends" declaration of the
+// MessageOrBuilder definition.
TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor);
-
-// Get the unqualified Java class name for mutable messages. i.e. without
-// package or outer classnames.
+
+// Get the unqualified Java class name for mutable messages. i.e. without
+// package or outer classnames.
inline TProtoStringType ShortMutableJavaClassName(const Descriptor* descriptor) {
- return descriptor->name();
-}
-
+ return descriptor->name();
+}
+
// Whether the given descriptor is for one of the core descriptor protos. We
// cannot currently use the new runtime with core protos since there is a
// bootstrapping problem with obtaining their descriptors.
@@ -146,221 +146,221 @@ inline bool IsDescriptorProto(const Descriptor* descriptor) {
return descriptor->file()->name() == "net/proto2/proto/descriptor.proto" ||
descriptor->file()->name() == "google/protobuf/descriptor.proto";
}
-
+
// Returns the stored type string used by the experimental runtime for oneof
// fields.
TProtoStringType GetOneofStoredType(const FieldDescriptor* field);
-// Whether we should generate multiple java files for messages.
+// Whether we should generate multiple java files for messages.
inline bool MultipleJavaFiles(const FileDescriptor* descriptor,
bool immutable) {
(void) immutable;
- return descriptor->options().java_multiple_files();
-}
-
-
-// Returns true if `descriptor` will be written to its own .java file.
-// `immutable` should be set to true if we're generating for the immutable API.
-template <typename Descriptor>
-bool IsOwnFile(const Descriptor* descriptor, bool immutable) {
- return descriptor->containing_type() == NULL &&
- MultipleJavaFiles(descriptor->file(), immutable);
-}
-
-template <>
-inline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) {
- return MultipleJavaFiles(descriptor->file(), immutable);
-}
-
-// If `descriptor` describes an object with its own .java file,
-// returns the name (relative to that .java file) of the file that stores
-// annotation data for that descriptor. `suffix` is usually empty, but may
-// (e.g.) be "OrBuilder" for some generated interfaces.
-template <typename Descriptor>
+ return descriptor->options().java_multiple_files();
+}
+
+
+// Returns true if `descriptor` will be written to its own .java file.
+// `immutable` should be set to true if we're generating for the immutable API.
+template <typename Descriptor>
+bool IsOwnFile(const Descriptor* descriptor, bool immutable) {
+ return descriptor->containing_type() == NULL &&
+ MultipleJavaFiles(descriptor->file(), immutable);
+}
+
+template <>
+inline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) {
+ return MultipleJavaFiles(descriptor->file(), immutable);
+}
+
+// If `descriptor` describes an object with its own .java file,
+// returns the name (relative to that .java file) of the file that stores
+// annotation data for that descriptor. `suffix` is usually empty, but may
+// (e.g.) be "OrBuilder" for some generated interfaces.
+template <typename Descriptor>
TProtoStringType AnnotationFileName(const Descriptor* descriptor,
const TProtoStringType& suffix) {
- return descriptor->name() + suffix + ".java.pb.meta";
-}
-
-template <typename Descriptor>
-void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,
- Descriptor* descriptor, bool immutable,
+ return descriptor->name() + suffix + ".java.pb.meta";
+}
+
+template <typename Descriptor>
+void MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,
+ Descriptor* descriptor, bool immutable,
const TProtoStringType& suffix = "") {
if (IsOwnFile(descriptor, immutable)) {
- PrintGeneratedAnnotation(printer, '$',
+ PrintGeneratedAnnotation(printer, '$',
context->options().annotate_code
? AnnotationFileName(descriptor, suffix)
: "");
- }
-}
-
-// 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 type of the FieldDescriptor.
-// This does nothing interesting for the open source release, but is used for
-// hacks that improve compatibility with version 1 protocol buffers at Google.
-FieldDescriptor::Type GetType(const FieldDescriptor* field);
-
-enum JavaType {
- JAVATYPE_INT,
- JAVATYPE_LONG,
- JAVATYPE_FLOAT,
- JAVATYPE_DOUBLE,
- JAVATYPE_BOOLEAN,
- JAVATYPE_STRING,
- JAVATYPE_BYTES,
- JAVATYPE_ENUM,
- JAVATYPE_MESSAGE
-};
-
-JavaType GetJavaType(const FieldDescriptor* field);
-
-const char* PrimitiveTypeName(JavaType type);
-
-// Get the fully-qualified class name for a boxed primitive type, e.g.
-// "java.lang.Integer" for JAVATYPE_INT. Returns NULL for enum and message
-// types.
-const char* BoxedPrimitiveTypeName(JavaType type);
-
+
+// Returns the type of the FieldDescriptor.
+// This does nothing interesting for the open source release, but is used for
+// hacks that improve compatibility with version 1 protocol buffers at Google.
+FieldDescriptor::Type GetType(const FieldDescriptor* field);
+
+enum JavaType {
+ JAVATYPE_INT,
+ JAVATYPE_LONG,
+ JAVATYPE_FLOAT,
+ JAVATYPE_DOUBLE,
+ JAVATYPE_BOOLEAN,
+ JAVATYPE_STRING,
+ JAVATYPE_BYTES,
+ JAVATYPE_ENUM,
+ JAVATYPE_MESSAGE
+};
+
+JavaType GetJavaType(const FieldDescriptor* field);
+
+const char* PrimitiveTypeName(JavaType type);
+
+// Get the fully-qualified class name for a boxed primitive type, e.g.
+// "java.lang.Integer" for JAVATYPE_INT. Returns NULL for enum and message
+// types.
+const char* BoxedPrimitiveTypeName(JavaType type);
+
// Kotlin source does not distinguish between primitives and non-primitives,
// but does use Kotlin-specific qualified types for them.
const char* KotlinTypeName(JavaType type);
-// Get the name of the java enum constant representing this type. E.g.,
-// "INT32" for FieldDescriptor::TYPE_INT32. The enum constant's full
-// name is "com.google.protobuf.WireFormat.FieldType.INT32".
-const char* FieldTypeName(const FieldDescriptor::Type field_type);
-
-class ClassNameResolver;
+// Get the name of the java enum constant representing this type. E.g.,
+// "INT32" for FieldDescriptor::TYPE_INT32. The enum constant's full
+// name is "com.google.protobuf.WireFormat.FieldType.INT32".
+const char* FieldTypeName(const FieldDescriptor::Type field_type);
+
+class ClassNameResolver;
TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
ClassNameResolver* name_resolver);
inline TProtoStringType ImmutableDefaultValue(const FieldDescriptor* field,
ClassNameResolver* name_resolver) {
- return DefaultValue(field, true, name_resolver);
-}
-bool IsDefaultValueJavaDefault(const FieldDescriptor* field);
-bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field);
-
-// Does this message class have descriptor and reflection methods?
+ return DefaultValue(field, true, name_resolver);
+}
+bool IsDefaultValueJavaDefault(const FieldDescriptor* field);
+bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field);
+
+// Does this message class have descriptor and reflection methods?
inline bool HasDescriptorMethods(const Descriptor* /* descriptor */,
- bool enforce_lite) {
+ bool enforce_lite) {
return !enforce_lite;
-}
+}
inline bool HasDescriptorMethods(const EnumDescriptor* /* descriptor */,
- bool enforce_lite) {
+ bool enforce_lite) {
return !enforce_lite;
-}
+}
inline bool HasDescriptorMethods(const FileDescriptor* /* descriptor */,
- bool enforce_lite) {
+ bool enforce_lite) {
return !enforce_lite;
-}
-
-// Should we generate generic services for this file?
+}
+
+// Should we generate generic services for this file?
inline bool HasGenericServices(const FileDescriptor* file, bool enforce_lite) {
- return file->service_count() > 0 &&
- HasDescriptorMethods(file, enforce_lite) &&
- file->options().java_generic_services();
-}
-
-// Methods for shared bitfields.
-
-// Gets the name of the shared bitfield for the given index.
+ return file->service_count() > 0 &&
+ HasDescriptorMethods(file, enforce_lite) &&
+ file->options().java_generic_services();
+}
+
+// Methods for shared bitfields.
+
+// Gets the name of the shared bitfield for the given index.
TProtoStringType GetBitFieldName(int index);
-
-// Gets the name of the shared bitfield for the given bit index.
-// Effectively, GetBitFieldName(bitIndex / 32)
+
+// Gets the name of the shared bitfield for the given bit index.
+// Effectively, GetBitFieldName(bitIndex / 32)
TProtoStringType GetBitFieldNameForBit(int bitIndex);
-
-// Generates the java code for the expression that returns the boolean value
-// of the bit of the shared bitfields for the given bit index.
-// Example: "((bitField1_ & 0x04) == 0x04)"
+
+// Generates the java code for the expression that returns the boolean value
+// of the bit of the shared bitfields for the given bit index.
+// Example: "((bitField1_ & 0x04) == 0x04)"
TProtoStringType GenerateGetBit(int bitIndex);
-
-// Generates the java code for the expression that sets the bit of the shared
-// bitfields for the given bit index.
-// Example: "bitField1_ = (bitField1_ | 0x04)"
+
+// Generates the java code for the expression that sets the bit of the shared
+// bitfields for the given bit index.
+// Example: "bitField1_ = (bitField1_ | 0x04)"
TProtoStringType GenerateSetBit(int bitIndex);
-
-// Generates the java code for the expression that clears the bit of the shared
-// bitfields for the given bit index.
-// Example: "bitField1_ = (bitField1_ & ~0x04)"
+
+// Generates the java code for the expression that clears the bit of the shared
+// bitfields for the given bit index.
+// Example: "bitField1_ = (bitField1_ & ~0x04)"
TProtoStringType GenerateClearBit(int bitIndex);
-
-// Does the same as GenerateGetBit but operates on the bit field on a local
-// variable. This is used by the builder to copy the value in the builder to
-// the message.
-// Example: "((from_bitField1_ & 0x04) == 0x04)"
+
+// Does the same as GenerateGetBit but operates on the bit field on a local
+// variable. This is used by the builder to copy the value in the builder to
+// the message.
+// Example: "((from_bitField1_ & 0x04) == 0x04)"
TProtoStringType GenerateGetBitFromLocal(int bitIndex);
-
-// Does the same as GenerateSetBit but operates on the bit field on a local
-// variable. This is used by the builder to copy the value in the builder to
-// the message.
-// Example: "to_bitField1_ = (to_bitField1_ | 0x04)"
+
+// Does the same as GenerateSetBit but operates on the bit field on a local
+// variable. This is used by the builder to copy the value in the builder to
+// the message.
+// Example: "to_bitField1_ = (to_bitField1_ | 0x04)"
TProtoStringType GenerateSetBitToLocal(int bitIndex);
-
-// Does the same as GenerateGetBit but operates on the bit field on a local
-// variable. This is used by the parsing constructor to record if a repeated
-// field is mutable.
-// Example: "((mutable_bitField1_ & 0x04) == 0x04)"
+
+// Does the same as GenerateGetBit but operates on the bit field on a local
+// variable. This is used by the parsing constructor to record if a repeated
+// field is mutable.
+// Example: "((mutable_bitField1_ & 0x04) == 0x04)"
TProtoStringType GenerateGetBitMutableLocal(int bitIndex);
-
-// Does the same as GenerateSetBit but operates on the bit field on a local
-// variable. This is used by the parsing constructor to record if a repeated
-// field is mutable.
-// Example: "mutable_bitField1_ = (mutable_bitField1_ | 0x04)"
+
+// Does the same as GenerateSetBit but operates on the bit field on a local
+// variable. This is used by the parsing constructor to record if a repeated
+// field is mutable.
+// Example: "mutable_bitField1_ = (mutable_bitField1_ | 0x04)"
TProtoStringType GenerateSetBitMutableLocal(int bitIndex);
-
-// Returns whether the JavaType is a reference type.
-bool IsReferenceType(JavaType type);
-
-// Returns the capitalized name for calling relative functions in
-// CodedInputStream
-const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable);
-
-// For encodings with fixed sizes, returns that size in bytes. Otherwise
-// returns -1.
-int FixedSize(FieldDescriptor::Type type);
-
-// Comparators used to sort fields in MessageGenerator
-struct FieldOrderingByNumber {
- inline bool operator()(const FieldDescriptor* a,
- const FieldDescriptor* b) const {
- return a->number() < b->number();
- }
-};
-
-struct ExtensionRangeOrdering {
- bool operator()(const Descriptor::ExtensionRange* a,
- const Descriptor::ExtensionRange* b) const {
- return a->start < b->start;
- }
-};
-
-// Sort the fields of the given Descriptor by number into a new[]'d array
-// and return it. The caller should delete the returned array.
-const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor);
-
-// Does this message class have any packed fields?
-inline bool HasPackedFields(const Descriptor* descriptor) {
- for (int i = 0; i < descriptor->field_count(); i++) {
- if (descriptor->field(i)->is_packed()) {
- return true;
- }
- }
- return false;
-}
-
-// Check a message type and its sub-message types recursively to see if any of
-// them has a required field. Return true if a required field is found.
-bool HasRequiredFields(const Descriptor* descriptor);
-
+
+// Returns whether the JavaType is a reference type.
+bool IsReferenceType(JavaType type);
+
+// Returns the capitalized name for calling relative functions in
+// CodedInputStream
+const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable);
+
+// For encodings with fixed sizes, returns that size in bytes. Otherwise
+// returns -1.
+int FixedSize(FieldDescriptor::Type type);
+
+// Comparators used to sort fields in MessageGenerator
+struct FieldOrderingByNumber {
+ inline bool operator()(const FieldDescriptor* a,
+ const FieldDescriptor* b) const {
+ return a->number() < b->number();
+ }
+};
+
+struct ExtensionRangeOrdering {
+ bool operator()(const Descriptor::ExtensionRange* a,
+ const Descriptor::ExtensionRange* b) const {
+ return a->start < b->start;
+ }
+};
+
+// Sort the fields of the given Descriptor by number into a new[]'d array
+// and return it. The caller should delete the returned array.
+const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor);
+
+// Does this message class have any packed fields?
+inline bool HasPackedFields(const Descriptor* descriptor) {
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ if (descriptor->field(i)->is_packed()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Check a message type and its sub-message types recursively to see if any of
+// them has a required field. Return true if a required field is found.
+bool HasRequiredFields(const Descriptor* descriptor);
+
inline bool IsProto2(const FileDescriptor* descriptor) {
return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2;
-}
-
+}
+
inline bool IsRealOneof(const FieldDescriptor* descriptor) {
return descriptor->containing_oneof() &&
!descriptor->containing_oneof()->is_synthetic();
@@ -381,50 +381,50 @@ inline bool HasHasbit(const FieldDescriptor* descriptor) {
(descriptor->has_optional_keyword() || IsProto2(descriptor->file()));
}
-// Whether generate classes expose public PARSER instances.
-inline bool ExposePublicParser(const FileDescriptor* descriptor) {
- // TODO(liujisi): Mark the PARSER private in 3.1.x releases.
- return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2;
-}
-
-// Whether unknown enum values are kept (i.e., not stored in UnknownFieldSet
-// but in the message and can be queried using additional getters that return
-// ints.
-inline bool SupportUnknownEnumValue(const FileDescriptor* descriptor) {
- return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;
-}
-
+// Whether generate classes expose public PARSER instances.
+inline bool ExposePublicParser(const FileDescriptor* descriptor) {
+ // TODO(liujisi): Mark the PARSER private in 3.1.x releases.
+ return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2;
+}
+
+// Whether unknown enum values are kept (i.e., not stored in UnknownFieldSet
+// but in the message and can be queried using additional getters that return
+// ints.
+inline bool SupportUnknownEnumValue(const FileDescriptor* descriptor) {
+ return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;
+}
+
inline bool SupportUnknownEnumValue(const FieldDescriptor* field) {
return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;
}
// Check whether a message has repeated fields.
-bool HasRepeatedFields(const Descriptor* descriptor);
-
-inline bool IsMapEntry(const Descriptor* descriptor) {
- return descriptor->options().map_entry();
-}
-
-inline bool IsMapField(const FieldDescriptor* descriptor) {
- return descriptor->is_map();
-}
-
-inline bool IsAnyMessage(const Descriptor* descriptor) {
- return descriptor->full_name() == "google.protobuf.Any";
-}
-
+bool HasRepeatedFields(const Descriptor* descriptor);
+
+inline bool IsMapEntry(const Descriptor* descriptor) {
+ return descriptor->options().map_entry();
+}
+
+inline bool IsMapField(const FieldDescriptor* descriptor) {
+ return descriptor->is_map();
+}
+
+inline bool IsAnyMessage(const Descriptor* descriptor) {
+ return descriptor->full_name() == "google.protobuf.Any";
+}
+
inline bool IsWrappersProtoFile(const FileDescriptor* descriptor) {
return descriptor->name() == "google/protobuf/wrappers.proto";
}
-inline bool CheckUtf8(const FieldDescriptor* descriptor) {
- return descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ||
+inline bool CheckUtf8(const FieldDescriptor* descriptor) {
+ return descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ||
descriptor->file()->options().java_string_check_utf8();
-}
-
+}
+
inline TProtoStringType GeneratedCodeVersionSuffix() {
- return "V3";
-}
+ return "V3";
+}
void WriteUInt32ToUtf16CharSequence(uint32_t number,
std::vector<uint16_t>* output);
@@ -451,9 +451,9 @@ int GetExperimentalJavaFieldType(const FieldDescriptor* field);
// and the first field number that are not in the table part
std::pair<int, int> GetTableDrivenNumberOfEntriesAndLookUpStartFieldNumber(
const FieldDescriptor** fields, int count);
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
index ec6d6d3cc5..353bff46db 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc
@@ -1,74 +1,74 @@
-// 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/java/java_map_field.h>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/io/printer.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-namespace {
-
-const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
- const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("key");
-}
-
-const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
- const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("value");
-}
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
+const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
+ GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ const Descriptor* message = descriptor->message_type();
+ GOOGLE_CHECK(message->options().map_entry());
+ return message->FindFieldByName("key");
+}
+
+const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
+ GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ const Descriptor* message = descriptor->message_type();
+ GOOGLE_CHECK(message->options().map_entry());
+ return message->FindFieldByName("value");
+}
+
TProtoStringType TypeName(const FieldDescriptor* field,
ClassNameResolver* name_resolver, bool boxed) {
- if (GetJavaType(field) == JAVATYPE_MESSAGE) {
- return name_resolver->GetImmutableClassName(field->message_type());
- } else if (GetJavaType(field) == JAVATYPE_ENUM) {
- return name_resolver->GetImmutableClassName(field->enum_type());
- } else {
- return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
- : PrimitiveTypeName(GetJavaType(field));
- }
-}
-
+ if (GetJavaType(field) == JAVATYPE_MESSAGE) {
+ return name_resolver->GetImmutableClassName(field->message_type());
+ } else if (GetJavaType(field) == JAVATYPE_ENUM) {
+ return name_resolver->GetImmutableClassName(field->enum_type());
+ } else {
+ return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
+ : PrimitiveTypeName(GetJavaType(field));
+ }
+}
+
TProtoStringType KotlinTypeName(const FieldDescriptor* field,
ClassNameResolver* name_resolver) {
if (GetJavaType(field) == JAVATYPE_MESSAGE) {
@@ -81,25 +81,25 @@ TProtoStringType KotlinTypeName(const FieldDescriptor* field,
}
TProtoStringType WireType(const FieldDescriptor* field) {
- return "com.google.protobuf.WireFormat.FieldType." +
+ return "com.google.protobuf.WireFormat.FieldType." +
TProtoStringType(FieldTypeName(field->type()));
-}
-
+}
+
void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, const FieldGeneratorInfo* info,
- Context* context,
+ Context* context,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
- ClassNameResolver* name_resolver = context->GetNameResolver();
-
- (*variables)["type"] =
- name_resolver->GetImmutableClassName(descriptor->message_type());
- const FieldDescriptor* key = KeyField(descriptor);
- const FieldDescriptor* value = ValueField(descriptor);
- const JavaType keyJavaType = GetJavaType(key);
- const JavaType valueJavaType = GetJavaType(value);
-
- (*variables)["key_type"] = TypeName(key, name_resolver, false);
+ SetCommonFieldVariables(descriptor, info, variables);
+ ClassNameResolver* name_resolver = context->GetNameResolver();
+
+ (*variables)["type"] =
+ name_resolver->GetImmutableClassName(descriptor->message_type());
+ const FieldDescriptor* key = KeyField(descriptor);
+ const FieldDescriptor* value = ValueField(descriptor);
+ const JavaType keyJavaType = GetJavaType(key);
+ const JavaType valueJavaType = GetJavaType(value);
+
+ (*variables)["key_type"] = TypeName(key, name_resolver, false);
TProtoStringType boxed_key_type = TypeName(key, name_resolver, true);
(*variables)["boxed_key_type"] = boxed_key_type;
(*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver);
@@ -107,8 +107,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// Used for calling the serialization function.
(*variables)["short_key_type"] =
boxed_key_type.substr(boxed_key_type.rfind('.') + 1);
- (*variables)["key_wire_type"] = WireType(key);
- (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
+ (*variables)["key_wire_type"] = WireType(key);
+ (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
(*variables)["key_null_check"] =
IsReferenceType(keyJavaType)
? "if (key == null) { throw new java.lang.NullPointerException(); }"
@@ -117,36 +117,36 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
IsReferenceType(valueJavaType)
? "if (value == null) { throw new java.lang.NullPointerException(); }"
: "";
- if (valueJavaType == JAVATYPE_ENUM) {
- // We store enums as Integers internally.
- (*variables)["value_type"] = "int";
- (*variables)["boxed_value_type"] = "java.lang.Integer";
- (*variables)["value_wire_type"] = WireType(value);
- (*variables)["value_default_value"] =
- DefaultValue(value, true, name_resolver) + ".getNumber()";
-
- (*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
-
- if (SupportUnknownEnumValue(descriptor->file())) {
- // Map unknown values to a special UNRECOGNIZED value if supported.
- (*variables)["unrecognized_value"] =
- (*variables)["value_enum_type"] + ".UNRECOGNIZED";
- } else {
- // Map unknown values to the default value if we don't have UNRECOGNIZED.
- (*variables)["unrecognized_value"] =
- DefaultValue(value, true, name_resolver);
- }
- } else {
- (*variables)["value_type"] = TypeName(value, name_resolver, false);
- (*variables)["boxed_value_type"] = TypeName(value, name_resolver, true);
- (*variables)["value_wire_type"] = WireType(value);
- (*variables)["value_default_value"] =
- DefaultValue(value, true, name_resolver);
- }
- (*variables)["type_parameters"] =
- (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"];
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ if (valueJavaType == JAVATYPE_ENUM) {
+ // We store enums as Integers internally.
+ (*variables)["value_type"] = "int";
+ (*variables)["boxed_value_type"] = "java.lang.Integer";
+ (*variables)["value_wire_type"] = WireType(value);
+ (*variables)["value_default_value"] =
+ DefaultValue(value, true, name_resolver) + ".getNumber()";
+
+ (*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
+
+ if (SupportUnknownEnumValue(descriptor->file())) {
+ // Map unknown values to a special UNRECOGNIZED value if supported.
+ (*variables)["unrecognized_value"] =
+ (*variables)["value_enum_type"] + ".UNRECOGNIZED";
+ } else {
+ // Map unknown values to the default value if we don't have UNRECOGNIZED.
+ (*variables)["unrecognized_value"] =
+ DefaultValue(value, true, name_resolver);
+ }
+ } else {
+ (*variables)["value_type"] = TypeName(value, name_resolver, false);
+ (*variables)["boxed_value_type"] = TypeName(value, name_resolver, true);
+ (*variables)["value_wire_type"] = WireType(value);
+ (*variables)["value_default_value"] =
+ DefaultValue(value, true, name_resolver);
+ }
+ (*variables)["type_parameters"] =
+ (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"];
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -154,53 +154,53 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
- (*variables)["on_changed"] = "onChanged();";
-
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
+ (*variables)["on_changed"] = "onChanged();";
+
+ // For repeated fields, one bit is used for whether the array is immutable
+ // in the parsing constructor.
+ (*variables)["get_mutable_bit_parser"] =
+ GenerateGetBitMutableLocal(builderBitIndex);
+ (*variables)["set_mutable_bit_parser"] =
+ GenerateSetBitMutableLocal(builderBitIndex);
+
(*variables)["default_entry"] =
(*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
- (*variables)["map_field_parameter"] = (*variables)["default_entry"];
- (*variables)["descriptor"] =
+ (*variables)["map_field_parameter"] = (*variables)["default_entry"];
+ (*variables)["descriptor"] =
name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" +
UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, ";
(*variables)["ver"] = GeneratedCodeVersionSuffix();
-}
-
-} // namespace
-
+}
+
+} // namespace
+
ImmutableMapFieldGenerator::ImmutableMapFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
+ SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor), context,
&variables_);
-}
-
+}
+
ImmutableMapFieldGenerator::~ImmutableMapFieldGenerator() {}
-
+
int ImmutableMapFieldGenerator::GetNumBitsForMessage() const { return 0; }
-
+
int ImmutableMapFieldGenerator::GetNumBitsForBuilder() const { return 1; }
-
+
void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$int ${$get$capitalized_name$Count$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$boolean ${$contains$capitalized_name$$}$(\n"
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -209,55 +209,55 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
"java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue);\n");
+ " $key_type$ key,\n"
+ " $value_enum_type$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key);\n");
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$type_parameters$>\n"
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$Value$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$ValueMap$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
" $value_type$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- }
- } else {
+ }
+ } else {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -266,41 +266,41 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
"java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
" $value_type$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
+ }
+}
+
void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
- printer->Print(
- variables_,
- "private static final class $capitalized_name$DefaultEntryHolder {\n"
- " static final com.google.protobuf.MapEntry<\n"
- " $type_parameters$> defaultEntry =\n"
- " com.google.protobuf.MapEntry\n"
- " .<$type_parameters$>newDefaultInstance(\n"
- " $descriptor$\n"
- " $key_wire_type$,\n"
- " $key_default_value$,\n"
- " $value_wire_type$,\n"
- " $value_default_value$);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "private static final class $capitalized_name$DefaultEntryHolder {\n"
+ " static final com.google.protobuf.MapEntry<\n"
+ " $type_parameters$> defaultEntry =\n"
+ " com.google.protobuf.MapEntry\n"
+ " .<$type_parameters$>newDefaultInstance(\n"
+ " $descriptor$\n"
+ " $key_wire_type$,\n"
+ " $key_default_value$,\n"
+ " $value_wire_type$,\n"
+ " $value_default_value$);\n"
+ "}\n");
printer->Print(variables_,
"private com.google.protobuf.MapField<\n"
" $type_parameters$> $name$_;\n"
@@ -312,15 +312,15 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
" }\n"
" return $name$_;\n"
"}\n");
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(
- variables_,
- "private static final\n"
- "com.google.protobuf.Internal.MapAdapter.Converter<\n"
- " java.lang.Integer, $value_enum_type$> $name$ValueConverter =\n"
- " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
- " $value_enum_type$.internalGetValueMap(),\n"
- " $unrecognized_value$);\n");
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ printer->Print(
+ variables_,
+ "private static final\n"
+ "com.google.protobuf.Internal.MapAdapter.Converter<\n"
+ " java.lang.Integer, $value_enum_type$> $name$ValueConverter =\n"
+ " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
+ " $value_enum_type$.internalGetValueMap(),\n"
+ " $unrecognized_value$);\n");
printer->Print(
variables_,
"private static final java.util.Map<$boxed_key_type$, "
@@ -331,10 +331,10 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
" $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
" map, $name$ValueConverter);\n"
"}\n");
- }
- GenerateMapGetters(printer);
-}
-
+ }
+ GenerateMapGetters(printer);
+}
+
void ImmutableMapFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
printer->Print(variables_,
@@ -360,7 +360,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" }\n"
" return $name$_;\n"
"}\n");
- GenerateMapGetters(printer);
+ GenerateMapGetters(printer);
printer->Print(variables_,
"$deprecation$\n"
"public Builder ${$clear$capitalized_name$$}$() {\n"
@@ -369,7 +369,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"public Builder ${$remove$capitalized_name$$}$(\n"
@@ -380,20 +380,20 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use alternate mutation accessors instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use alternate mutation accessors instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$getMutable$capitalized_name$$}$() {\n"
" return internalGetAdapted$capitalized_name$Map(\n"
" internalGetMutable$capitalized_name$().getMutableMap());\n"
- "}\n");
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public Builder ${$put$capitalized_name$$}$(\n"
" $key_type$ key,\n"
@@ -405,65 +405,65 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n"
- " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n"
+ " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n"
" internalGetAdapted$capitalized_name$Map(\n"
" internalGetMutable$capitalized_name$().getMutableMap())\n"
" .putAll(values);\n"
- " return this;\n"
- "}\n");
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use alternate mutation accessors instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use alternate mutation accessors instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$getMutable$capitalized_name$Value$}$() {\n"
- " return internalGetMutable$capitalized_name$().getMutableMap();\n"
- "}\n");
+ " return internalGetMutable$capitalized_name$().getMutableMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ value) {\n"
- " $key_null_check$\n"
+ " $key_type$ key,\n"
+ " $value_type$ value) {\n"
+ " $key_null_check$\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .put(key, value);\n"
- " return this;\n"
- "}\n");
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .putAll(values);\n"
- " return this;\n"
- "}\n");
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- }
- } else {
- printer->Print(
- variables_,
- "/**\n"
- " * Use alternate mutation accessors instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$>\n"
+ }
+ } else {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use alternate mutation accessors instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$>\n"
"${$getMutable$capitalized_name$$}$() {\n"
- " return internalGetMutable$capitalized_name$().getMutableMap();\n"
- "}\n");
+ " return internalGetMutable$capitalized_name$().getMutableMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$"
"public Builder ${$put$capitalized_name$$}$(\n"
@@ -476,7 +476,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"public Builder ${$putAll$capitalized_name$$}$(\n"
@@ -486,9 +486,9 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
+ }
+}
+
void ImmutableMapFieldGenerator::GenerateMapGetters(
io::Printer* printer) const {
printer->Print(variables_,
@@ -497,18 +497,18 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" return internalGet$capitalized_name$().getMap().size();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$deprecation$\n"
"@java.lang.Override\n"
"public boolean ${$contains$capitalized_name$$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " return internalGet$capitalized_name$().getMap().containsKey(key);\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " return internalGet$capitalized_name$().getMap().containsKey(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -520,7 +520,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" return get$capitalized_name$Map();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -530,93 +530,93 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" internalGet$capitalized_name$().getMap());"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$().getMap();\n"
- " return map.containsKey(key)\n"
- " ? $name$ValueConverter.doForward(map.get(key))\n"
- " : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_enum_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$().getMap();\n"
+ " return map.containsKey(key)\n"
+ " ? $name$ValueConverter.doForward(map.get(key))\n"
+ " : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$().getMap();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return $name$ValueConverter.doForward(map.get(key));\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$().getMap();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return $name$ValueConverter.doForward(map.get(key));\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
- " */\n"
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
+ " */\n"
"@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$Value$}$() {\n"
- " return get$capitalized_name$ValueMap();\n"
- "}\n");
+ " return get$capitalized_name$ValueMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$ValueMap$}$() {\n"
- " return internalGet$capitalized_name$().getMap();\n"
- "}\n");
+ " return internalGet$capitalized_name$().getMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$().getMap();\n"
- " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$().getMap();\n"
+ " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$().getMap();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return map.get(key);\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$().getMap();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return map.get(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- }
- } else {
+ }
+ } else {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -628,7 +628,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" return get$capitalized_name$Map();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -637,21 +637,21 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" return internalGet$capitalized_name$().getMap();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> map =\n"
- " internalGet$capitalized_name$().getMap();\n"
- " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> map =\n"
+ " internalGet$capitalized_name$().getMap();\n"
+ " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -666,9 +666,9 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
" return map.get(key);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
+ }
+}
+
void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -752,34 +752,34 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
void ImmutableMapFieldGenerator::GenerateFieldBuilderInitializationCode(
io::Printer* printer) const {
- // Nothing to initialize.
-}
-
+ // Nothing to initialize.
+}
+
void ImmutableMapFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- // Nothing to initialize.
-}
-
+ // Nothing to initialize.
+}
+
void ImmutableMapFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
printer->Print(variables_,
"internalGetMutable$capitalized_name$().clear();\n");
-}
-
+}
+
void ImmutableMapFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
printer->Print(variables_,
"internalGetMutable$capitalized_name$().mergeFrom(\n"
" other.internalGet$capitalized_name$());\n");
-}
-
+}
+
void ImmutableMapFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
printer->Print(variables_,
"result.$name$_ = internalGet$capitalized_name$();\n"
"result.$name$_.makeImmutable();\n");
-}
-
+}
+
void ImmutableMapFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
printer->Print(variables_,
@@ -788,37 +788,37 @@ void ImmutableMapFieldGenerator::GenerateParsingCode(
" $map_field_parameter$);\n"
" $set_mutable_bit_parser$;\n"
"}\n");
- if (!SupportUnknownEnumValue(descriptor_->file()) &&
- GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(
- variables_,
- "com.google.protobuf.ByteString bytes = input.readBytes();\n"
- "com.google.protobuf.MapEntry<$type_parameters$>\n"
+ if (!SupportUnknownEnumValue(descriptor_->file()) &&
+ GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ printer->Print(
+ variables_,
+ "com.google.protobuf.ByteString bytes = input.readBytes();\n"
+ "com.google.protobuf.MapEntry<$type_parameters$>\n"
"$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n");
- printer->Print(
- variables_,
+ printer->Print(
+ variables_,
"if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n"
- " unknownFields.mergeLengthDelimitedField($number$, bytes);\n"
- "} else {\n"
+ " unknownFields.mergeLengthDelimitedField($number$, bytes);\n"
+ "} else {\n"
" $name$_.getMutableMap().put(\n"
" $name$__.getKey(), $name$__.getValue());\n"
- "}\n");
- } else {
- printer->Print(
- variables_,
- "com.google.protobuf.MapEntry<$type_parameters$>\n"
+ "}\n");
+ } else {
+ printer->Print(
+ variables_,
+ "com.google.protobuf.MapEntry<$type_parameters$>\n"
"$name$__ = input.readMessage(\n"
- " $default_entry$.getParserForType(), extensionRegistry);\n"
+ " $default_entry$.getParserForType(), extensionRegistry);\n"
"$name$_.getMutableMap().put(\n"
" $name$__.getKey(), $name$__.getValue());\n");
- }
-}
-
+ }
+}
+
void ImmutableMapFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- // Nothing to do here.
-}
-
+ // Nothing to do here.
+}
+
void ImmutableMapFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(variables_,
@@ -828,45 +828,45 @@ void ImmutableMapFieldGenerator::GenerateSerializationCode(
" internalGet$capitalized_name$(),\n"
" $default_entry$,\n"
" $number$);\n");
-}
-
+}
+
void ImmutableMapFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(
- variables_,
- "for (java.util.Map.Entry<$type_parameters$> entry\n"
- " : internalGet$capitalized_name$().getMap().entrySet()) {\n"
- " com.google.protobuf.MapEntry<$type_parameters$>\n"
+ printer->Print(
+ variables_,
+ "for (java.util.Map.Entry<$type_parameters$> entry\n"
+ " : internalGet$capitalized_name$().getMap().entrySet()) {\n"
+ " com.google.protobuf.MapEntry<$type_parameters$>\n"
" $name$__ = $default_entry$.newBuilderForType()\n"
- " .setKey(entry.getKey())\n"
- " .setValue(entry.getValue())\n"
- " .build();\n"
- " size += com.google.protobuf.CodedOutputStream\n"
+ " .setKey(entry.getKey())\n"
+ " .setValue(entry.getValue())\n"
+ " .build();\n"
+ " size += com.google.protobuf.CodedOutputStream\n"
" .computeMessageSize($number$, $name$__);\n"
- "}\n");
-}
-
+ "}\n");
+}
+
void ImmutableMapFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
printer->Print(variables_,
"if (!internalGet$capitalized_name$().equals(\n"
" other.internalGet$capitalized_name$())) return false;\n");
-}
-
+}
+
void ImmutableMapFieldGenerator::GenerateHashCode(io::Printer* printer) const {
- printer->Print(
- variables_,
- "if (!internalGet$capitalized_name$().getMap().isEmpty()) {\n"
- " hash = (37 * hash) + $constant_name$;\n"
- " hash = (53 * hash) + internalGet$capitalized_name$().hashCode();\n"
- "}\n");
-}
-
+ printer->Print(
+ variables_,
+ "if (!internalGet$capitalized_name$().getMap().isEmpty()) {\n"
+ " hash = (37 * hash) + $constant_name$;\n"
+ " hash = (53 * hash) + internalGet$capitalized_name$().hashCode();\n"
+ "}\n");
+}
+
TProtoStringType ImmutableMapFieldGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->message_type());
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h
index 43de92ef0f..d4bfbfe132 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h
@@ -1,51 +1,51 @@
-// 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_JAVA_MAP_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_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.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
+
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
- public:
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
+ public:
explicit ImmutableMapFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
~ImmutableMapFieldGenerator() override;
-
- // implements ImmutableFieldGenerator ---------------------------------------
+
+ // implements ImmutableFieldGenerator ---------------------------------------
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -64,19 +64,19 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const;
-
- private:
- const FieldDescriptor* descriptor_;
+
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
- void GenerateMapGetters(io::Printer* printer) const;
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+ void GenerateMapGetters(io::Printer* printer) const;
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
index 2a1ed335b1..79bd924701 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -1,35 +1,35 @@
-// 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/java/java_map_field_lite.h>
-
+
#include <cstdint>
#include <google/protobuf/compiler/java/java_context.h>
@@ -37,40 +37,40 @@
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/io/printer.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-namespace {
-
-const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
- const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("key");
-}
-
-const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
- const Descriptor* message = descriptor->message_type();
- GOOGLE_CHECK(message->options().map_entry());
- return message->FindFieldByName("value");
-}
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
+const FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {
+ GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ const Descriptor* message = descriptor->message_type();
+ GOOGLE_CHECK(message->options().map_entry());
+ return message->FindFieldByName("key");
+}
+
+const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
+ GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());
+ const Descriptor* message = descriptor->message_type();
+ GOOGLE_CHECK(message->options().map_entry());
+ return message->FindFieldByName("value");
+}
+
TProtoStringType TypeName(const FieldDescriptor* field,
ClassNameResolver* name_resolver, bool boxed) {
- if (GetJavaType(field) == JAVATYPE_MESSAGE) {
- return name_resolver->GetImmutableClassName(field->message_type());
- } else if (GetJavaType(field) == JAVATYPE_ENUM) {
- return name_resolver->GetImmutableClassName(field->enum_type());
- } else {
- return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
- : PrimitiveTypeName(GetJavaType(field));
- }
-}
-
+ if (GetJavaType(field) == JAVATYPE_MESSAGE) {
+ return name_resolver->GetImmutableClassName(field->message_type());
+ } else if (GetJavaType(field) == JAVATYPE_ENUM) {
+ return name_resolver->GetImmutableClassName(field->enum_type());
+ } else {
+ return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))
+ : PrimitiveTypeName(GetJavaType(field));
+ }
+}
+
TProtoStringType KotlinTypeName(const FieldDescriptor* field,
ClassNameResolver* name_resolver) {
if (GetJavaType(field) == JAVATYPE_MESSAGE) {
@@ -83,30 +83,30 @@ TProtoStringType KotlinTypeName(const FieldDescriptor* field,
}
TProtoStringType WireType(const FieldDescriptor* field) {
- return "com.google.protobuf.WireFormat.FieldType." +
+ return "com.google.protobuf.WireFormat.FieldType." +
TProtoStringType(FieldTypeName(field->type()));
-}
-
+}
+
void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, const FieldGeneratorInfo* info,
- Context* context,
+ Context* context,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- ClassNameResolver* name_resolver = context->GetNameResolver();
- (*variables)["type"] =
- name_resolver->GetImmutableClassName(descriptor->message_type());
- const FieldDescriptor* key = KeyField(descriptor);
- const FieldDescriptor* value = ValueField(descriptor);
- const JavaType keyJavaType = GetJavaType(key);
- const JavaType valueJavaType = GetJavaType(value);
-
- (*variables)["key_type"] = TypeName(key, name_resolver, false);
- (*variables)["boxed_key_type"] = TypeName(key, name_resolver, true);
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ ClassNameResolver* name_resolver = context->GetNameResolver();
+ (*variables)["type"] =
+ name_resolver->GetImmutableClassName(descriptor->message_type());
+ const FieldDescriptor* key = KeyField(descriptor);
+ const FieldDescriptor* value = ValueField(descriptor);
+ const JavaType keyJavaType = GetJavaType(key);
+ const JavaType valueJavaType = GetJavaType(value);
+
+ (*variables)["key_type"] = TypeName(key, name_resolver, false);
+ (*variables)["boxed_key_type"] = TypeName(key, name_resolver, true);
(*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver);
(*variables)["kt_value_type"] = KotlinTypeName(value, name_resolver);
- (*variables)["key_wire_type"] = WireType(key);
- (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
+ (*variables)["key_wire_type"] = WireType(key);
+ (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["key_null_check"] =
@@ -117,37 +117,37 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
IsReferenceType(valueJavaType)
? "java.lang.Class<?> valueClass = value.getClass();"
: "";
-
- if (GetJavaType(value) == JAVATYPE_ENUM) {
- // We store enums as Integers internally.
- (*variables)["value_type"] = "int";
- (*variables)["boxed_value_type"] = "java.lang.Integer";
- (*variables)["value_wire_type"] = WireType(value);
- (*variables)["value_default_value"] =
- DefaultValue(value, true, name_resolver) + ".getNumber()";
-
- (*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
-
- if (SupportUnknownEnumValue(descriptor->file())) {
- // Map unknown values to a special UNRECOGNIZED value if supported.
- (*variables)["unrecognized_value"] =
- (*variables)["value_enum_type"] + ".UNRECOGNIZED";
- } else {
- // Map unknown values to the default value if we don't have UNRECOGNIZED.
- (*variables)["unrecognized_value"] =
- DefaultValue(value, true, name_resolver);
- }
- } else {
- (*variables)["value_type"] = TypeName(value, name_resolver, false);
- (*variables)["boxed_value_type"] = TypeName(value, name_resolver, true);
- (*variables)["value_wire_type"] = WireType(value);
- (*variables)["value_default_value"] =
- DefaultValue(value, true, name_resolver);
- }
- (*variables)["type_parameters"] =
- (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"];
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+
+ if (GetJavaType(value) == JAVATYPE_ENUM) {
+ // We store enums as Integers internally.
+ (*variables)["value_type"] = "int";
+ (*variables)["boxed_value_type"] = "java.lang.Integer";
+ (*variables)["value_wire_type"] = WireType(value);
+ (*variables)["value_default_value"] =
+ DefaultValue(value, true, name_resolver) + ".getNumber()";
+
+ (*variables)["value_enum_type"] = TypeName(value, name_resolver, false);
+
+ if (SupportUnknownEnumValue(descriptor->file())) {
+ // Map unknown values to a special UNRECOGNIZED value if supported.
+ (*variables)["unrecognized_value"] =
+ (*variables)["value_enum_type"] + ".UNRECOGNIZED";
+ } else {
+ // Map unknown values to the default value if we don't have UNRECOGNIZED.
+ (*variables)["unrecognized_value"] =
+ DefaultValue(value, true, name_resolver);
+ }
+ } else {
+ (*variables)["value_type"] = TypeName(value, name_resolver, false);
+ (*variables)["boxed_value_type"] = TypeName(value, name_resolver, true);
+ (*variables)["value_wire_type"] = WireType(value);
+ (*variables)["value_default_value"] =
+ DefaultValue(value, true, name_resolver);
+ }
+ (*variables)["type_parameters"] =
+ (*variables)["boxed_key_type"] + ", " + (*variables)["boxed_value_type"];
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -155,13 +155,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
-
+
(*variables)["default_entry"] =
(*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
-}
-
-} // namespace
-
+}
+
+} // namespace
+
ImmutableMapFieldLiteGenerator::ImmutableMapFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
@@ -170,24 +170,24 @@ ImmutableMapFieldLiteGenerator::ImmutableMapFieldLiteGenerator(
SetMessageVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor), context,
&variables_);
-}
-
+}
+
ImmutableMapFieldLiteGenerator::~ImmutableMapFieldLiteGenerator() {}
-
+
int ImmutableMapFieldLiteGenerator::GetNumBitsForMessage() const { return 0; }
-
+
void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$int ${$get$capitalized_name$Count$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$boolean ${$contains$capitalized_name$$}$(\n"
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -196,55 +196,55 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
"java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue);\n");
+ " $key_type$ key,\n"
+ " $value_enum_type$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key);\n");
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$type_parameters$>\n"
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$Value$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$ValueMap$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
" $value_type$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- }
- } else {
+ }
+ } else {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -253,41 +253,41 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
"java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$java.util.Map<$type_parameters$>\n"
"${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
" $value_type$ defaultValue);\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"$value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
" $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
+ }
+}
+
void ImmutableMapFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
- printer->Print(
- variables_,
- "private static final class $capitalized_name$DefaultEntryHolder {\n"
- " static final com.google.protobuf.MapEntryLite<\n"
- " $type_parameters$> defaultEntry =\n"
- " com.google.protobuf.MapEntryLite\n"
- " .<$type_parameters$>newDefaultInstance(\n"
- " $key_wire_type$,\n"
- " $key_default_value$,\n"
- " $value_wire_type$,\n"
- " $value_default_value$);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "private static final class $capitalized_name$DefaultEntryHolder {\n"
+ " static final com.google.protobuf.MapEntryLite<\n"
+ " $type_parameters$> defaultEntry =\n"
+ " com.google.protobuf.MapEntryLite\n"
+ " .<$type_parameters$>newDefaultInstance(\n"
+ " $key_wire_type$,\n"
+ " $key_default_value$,\n"
+ " $value_wire_type$,\n"
+ " $value_default_value$);\n"
+ "}\n");
printer->Print(variables_,
"private com.google.protobuf.MapFieldLite<\n"
" $type_parameters$> $name$_ =\n"
@@ -310,7 +310,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" return internalGet$capitalized_name$().size();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -320,15 +320,15 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" return internalGet$capitalized_name$().containsKey(key);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(
- variables_,
- "private static final\n"
- "com.google.protobuf.Internal.MapAdapter.Converter<\n"
- " java.lang.Integer, $value_enum_type$> $name$ValueConverter =\n"
- " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
- " $value_enum_type$.internalGetValueMap(),\n"
- " $unrecognized_value$);\n");
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ printer->Print(
+ variables_,
+ "private static final\n"
+ "com.google.protobuf.Internal.MapAdapter.Converter<\n"
+ " java.lang.Integer, $value_enum_type$> $name$ValueConverter =\n"
+ " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
+ " $value_enum_type$.internalGetValueMap(),\n"
+ " $unrecognized_value$);\n");
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -339,108 +339,108 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" return get$capitalized_name$Map();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$get$capitalized_name$Map$}$() {\n"
- " return java.util.Collections.unmodifiableMap(\n"
- " new com.google.protobuf.Internal.MapAdapter<\n"
- " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
- " internalGet$capitalized_name$(),\n"
- " $name$ValueConverter));\n"
- "}\n");
+ " return java.util.Collections.unmodifiableMap(\n"
+ " new com.google.protobuf.Internal.MapAdapter<\n"
+ " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
+ " internalGet$capitalized_name$(),\n"
+ " $name$ValueConverter));\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$();\n"
- " return map.containsKey(key)\n"
- " ? $name$ValueConverter.doForward(map.get(key))\n"
- " : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_enum_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$();\n"
+ " return map.containsKey(key)\n"
+ " ? $name$ValueConverter.doForward(map.get(key))\n"
+ " : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return $name$ValueConverter.doForward(map.get(key));\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return $name$ValueConverter.doForward(map.get(key));\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
- " */\n"
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
+ " */\n"
"@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$Value$}$() {\n"
- " return get$capitalized_name$ValueMap();\n"
- "}\n");
+ " return get$capitalized_name$ValueMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$ValueMap$}$() {\n"
- " return java.util.Collections.unmodifiableMap(\n"
- " internalGet$capitalized_name$());\n"
- "}\n");
+ " return java.util.Collections.unmodifiableMap(\n"
+ " internalGet$capitalized_name$());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$();\n"
- " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$();\n"
+ " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " internalGet$capitalized_name$();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return map.get(key);\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " internalGet$capitalized_name$();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return map.get(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- }
- } else {
+ }
+ } else {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -452,7 +452,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" return get$capitalized_name$Map();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -462,21 +462,21 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" internalGet$capitalized_name$());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> map =\n"
- " internalGet$capitalized_name$();\n"
- " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> map =\n"
+ " internalGet$capitalized_name$();\n"
+ " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -491,39 +491,39 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" return map.get(key);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
- // Generate private setters for the builder to proxy into.
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "private java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "getMutable$capitalized_name$Map() {\n"
- " return new com.google.protobuf.Internal.MapAdapter<\n"
- " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
- " internalGetMutable$capitalized_name$(),\n"
- " $name$ValueConverter);\n"
- "}\n");
- if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "private java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
- "getMutable$capitalized_name$ValueMap() {\n"
- " return internalGetMutable$capitalized_name$();\n"
- "}\n");
- }
- } else {
- WriteFieldDocComment(printer, descriptor_);
+ }
+
+ // Generate private setters for the builder to proxy into.
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "private java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "getMutable$capitalized_name$Map() {\n"
+ " return new com.google.protobuf.Internal.MapAdapter<\n"
+ " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
+ " internalGetMutable$capitalized_name$(),\n"
+ " $name$ValueConverter);\n"
+ "}\n");
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "private java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "getMutable$capitalized_name$ValueMap() {\n"
+ " return internalGetMutable$capitalized_name$();\n"
+ "}\n");
+ }
+ } else {
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"private java.util.Map<$type_parameters$>\n"
"getMutable$capitalized_name$Map() {\n"
" return internalGetMutable$capitalized_name$();\n"
"}\n");
- }
-}
-
+ }
+}
+
void ImmutableMapFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -550,16 +550,16 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return instance.get$capitalized_name$Map().size();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public boolean ${$contains$capitalized_name$$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " return instance.get$capitalized_name$Map().containsKey(key);\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " return instance.get$capitalized_name$Map().containsKey(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
printer->Print(variables_,
"$deprecation$\n"
@@ -569,7 +569,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$\n"
"public Builder ${$remove$capitalized_name$$}$(\n"
@@ -580,7 +580,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -591,7 +591,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return get$capitalized_name$Map();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -601,139 +601,139 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" instance.get$capitalized_name$Map());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n"
- " instance.get$capitalized_name$Map();\n"
- " return map.containsKey(key)\n"
- " ? map.get(key)\n"
- " : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_enum_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n"
+ " instance.get$capitalized_name$Map();\n"
+ " return map.containsKey(key)\n"
+ " ? map.get(key)\n"
+ " : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n"
- " instance.get$capitalized_name$Map();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return map.get(key);\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n"
+ " instance.get$capitalized_name$Map();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return map.get(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$put$capitalized_name$$}$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ value) {\n"
- " $key_null_check$\n"
- " $value_null_check$\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$Map().put(key, value);\n"
- " return this;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_enum_type$ value) {\n"
+ " $key_null_check$\n"
+ " $value_null_check$\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$Map().put(key, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n"
- " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$Map().putAll(values);\n"
- " return this;\n"
- "}\n");
+ " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$Map().putAll(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
- " */\n"
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
+ " */\n"
"@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$Value$}$() {\n"
- " return get$capitalized_name$ValueMap();\n"
- "}\n");
+ " return get$capitalized_name$ValueMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$ValueMap$}$() {\n"
- " return java.util.Collections.unmodifiableMap(\n"
- " instance.get$capitalized_name$ValueMap());\n"
- "}\n");
+ " return java.util.Collections.unmodifiableMap(\n"
+ " instance.get$capitalized_name$ValueMap());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " instance.get$capitalized_name$ValueMap();\n"
- " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " instance.get$capitalized_name$ValueMap();\n"
+ " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
- " instance.get$capitalized_name$ValueMap();\n"
- " if (!map.containsKey(key)) {\n"
- " throw new java.lang.IllegalArgumentException();\n"
- " }\n"
- " return map.get(key);\n"
- "}\n");
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n"
+ " instance.get$capitalized_name$ValueMap();\n"
+ " if (!map.containsKey(key)) {\n"
+ " throw new java.lang.IllegalArgumentException();\n"
+ " }\n"
+ " return map.get(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ value) {\n"
- " $key_null_check$\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$ValueMap().put(key, value);\n"
- " return this;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ value) {\n"
+ " $key_null_check$\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$ValueMap().put(key, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n"
- " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$ValueMap().putAll(values);\n"
- " return this;\n"
- "}\n");
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$ValueMap().putAll(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- }
- } else {
+ }
+ } else {
printer->Print(variables_,
"/**\n"
" * Use {@link #get$capitalized_name$Map()} instead.\n"
@@ -745,7 +745,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return get$capitalized_name$Map();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$"
@@ -755,21 +755,21 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" instance.get$capitalized_name$Map());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
"@java.lang.Override\n"
- "$deprecation$\n"
+ "$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ defaultValue) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> map =\n"
- " instance.get$capitalized_name$Map();\n"
- " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ defaultValue) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> map =\n"
+ " instance.get$capitalized_name$Map();\n"
+ " return map.containsKey(key) ? map.get(key) : defaultValue;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$\n"
@@ -784,34 +784,34 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return map.get(key);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$"
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$deprecation$"
"public Builder ${$put$capitalized_name$$}$(\n"
- " $key_type$ key,\n"
- " $value_type$ value) {\n"
- " $key_null_check$\n"
- " $value_null_check$\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$Map().put(key, value);\n"
- " return this;\n"
- "}\n");
+ " $key_type$ key,\n"
+ " $value_type$ value) {\n"
+ " $key_null_check$\n"
+ " $value_null_check$\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$Map().put(key, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$"
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$deprecation$"
"public Builder ${$putAll$capitalized_name$$}$(\n"
- " java.util.Map<$type_parameters$> values) {\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$Map().putAll(values);\n"
- " return this;\n"
- "}\n");
+ " java.util.Map<$type_parameters$> values) {\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$Map().putAll(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
+ }
+}
+
void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -895,14 +895,14 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
void ImmutableMapFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- // Nothing to initialize.
-}
-
+ // Nothing to initialize.
+}
+
TProtoStringType ImmutableMapFieldLiteGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->message_type());
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h
index 2672f548c8..f2773f5b35 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h
@@ -1,53 +1,53 @@
-// 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_JAVA_MAP_FIELD_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_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.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__
+
#include <cstdint>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
- public:
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
+ public:
explicit ImmutableMapFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
~ImmutableMapFieldLiteGenerator() override;
-
- // implements ImmutableFieldLiteGenerator ------------------------------------
+
+ // implements ImmutableFieldLiteGenerator ------------------------------------
int GetNumBitsForMessage() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
void GenerateMembers(io::Printer* printer) const override;
@@ -56,19 +56,19 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
- private:
- const FieldDescriptor* descriptor_;
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
Context* context_;
- ClassNameResolver* name_resolver_;
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
index a2d6fc0a4a..029d886cde 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc
@@ -1,45 +1,45 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_message.h>
-
-#include <algorithm>
+
+#include <algorithm>
#include <cstdint>
-#include <map>
-#include <memory>
-#include <vector>
-
+#include <map>
+#include <memory>
+#include <vector>
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -55,27 +55,27 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-namespace {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+namespace {
TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
ClassNameResolver* name_resolver) {
- const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
- return name_resolver->GetImmutableClassName(value_field->message_type());
-}
-} // namespace
-
-// ===================================================================
-
-MessageGenerator::MessageGenerator(const Descriptor* descriptor)
+ const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
+ GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
+ return name_resolver->GetImmutableClassName(value_field->message_type());
+}
+} // namespace
+
+// ===================================================================
+
+MessageGenerator::MessageGenerator(const Descriptor* descriptor)
: descriptor_(descriptor) {
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
@@ -83,53 +83,53 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor)
}
}
}
-
-MessageGenerator::~MessageGenerator() {}
-
-// ===================================================================
-ImmutableMessageGenerator::ImmutableMessageGenerator(
- const Descriptor* descriptor, Context* context)
+
+MessageGenerator::~MessageGenerator() {}
+
+// ===================================================================
+ImmutableMessageGenerator::ImmutableMessageGenerator(
+ const Descriptor* descriptor, Context* context)
: MessageGenerator(descriptor),
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
- << "Generator factory error: A non-lite message generator is used to "
- "generate lite messages.";
-}
-
-ImmutableMessageGenerator::~ImmutableMessageGenerator() {}
-
-void ImmutableMessageGenerator::GenerateStaticVariables(
- io::Printer* printer, int* bytecode_estimate) {
- // Because descriptor.proto (com.google.protobuf.DescriptorProtos) is
- // used in the construction of descriptors, we have a tricky bootstrapping
- // problem. To help control static initialization order, we make sure all
- // descriptors and other static data that depends on them are members of
- // the outermost class in the file. This way, they will be initialized in
- // a deterministic order.
-
+ GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ << "Generator factory error: A non-lite message generator is used to "
+ "generate lite messages.";
+}
+
+ImmutableMessageGenerator::~ImmutableMessageGenerator() {}
+
+void ImmutableMessageGenerator::GenerateStaticVariables(
+ io::Printer* printer, int* bytecode_estimate) {
+ // Because descriptor.proto (com.google.protobuf.DescriptorProtos) is
+ // used in the construction of descriptors, we have a tricky bootstrapping
+ // problem. To help control static initialization order, we make sure all
+ // descriptors and other static data that depends on them are members of
+ // the outermost class in the file. This way, they will be initialized in
+ // a deterministic order.
+
std::map<TProtoStringType, TProtoStringType> vars;
- vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
+ vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
vars["index"] = StrCat(descriptor_->index());
- vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
- if (descriptor_->containing_type() != NULL) {
+ vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
+ if (descriptor_->containing_type() != NULL) {
vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
- }
- if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
- // We can only make these package-private since the classes that use them
- // are in separate files.
- vars["private"] = "";
- } else {
- vars["private"] = "private ";
- }
- if (*bytecode_estimate <= kMaxStaticSize) {
- vars["final"] = "final ";
- } else {
- vars["final"] = "";
- }
-
- // The descriptor for this type.
+ }
+ if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
+ // We can only make these package-private since the classes that use them
+ // are in separate files.
+ vars["private"] = "";
+ } else {
+ vars["private"] = "private ";
+ }
+ if (*bytecode_estimate <= kMaxStaticSize) {
+ vars["final"] = "final ";
+ } else {
+ vars["final"] = "";
+ }
+
+ // The descriptor for this type.
printer->Print(
vars,
// TODO(teboring): final needs to be added back. The way to fix it is to
@@ -137,94 +137,94 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
// the types, and then init them in clinit with the new method calls.
"$private$static $final$com.google.protobuf.Descriptors.Descriptor\n"
" internal_$identifier$_descriptor;\n");
- *bytecode_estimate += 30;
-
- // And the FieldAccessorTable.
- GenerateFieldAccessorTable(printer, bytecode_estimate);
-
- // Generate static members for all nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // TODO(kenton): Reuse MessageGenerator objects?
- ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
- .GenerateStaticVariables(printer, bytecode_estimate);
- }
-}
-
-int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
- io::Printer* printer) {
- int bytecode_estimate = 0;
+ *bytecode_estimate += 30;
+
+ // And the FieldAccessorTable.
+ GenerateFieldAccessorTable(printer, bytecode_estimate);
+
+ // Generate static members for all nested types.
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ // TODO(kenton): Reuse MessageGenerator objects?
+ ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
+ .GenerateStaticVariables(printer, bytecode_estimate);
+ }
+}
+
+int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
+ io::Printer* printer) {
+ int bytecode_estimate = 0;
std::map<TProtoStringType, TProtoStringType> vars;
- vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
+ vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
vars["index"] = StrCat(descriptor_->index());
- vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
- if (descriptor_->containing_type() != NULL) {
+ vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
+ if (descriptor_->containing_type() != NULL) {
vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
- }
-
- // The descriptor for this type.
- if (descriptor_->containing_type() == NULL) {
- printer->Print(vars,
+ }
+
+ // The descriptor for this type.
+ if (descriptor_->containing_type() == NULL) {
+ printer->Print(vars,
"internal_$identifier$_descriptor =\n"
" getDescriptor().getMessageTypes().get($index$);\n");
- bytecode_estimate += 30;
- } else {
+ bytecode_estimate += 30;
+ } else {
printer->Print(
vars,
"internal_$identifier$_descriptor =\n"
" internal_$parent$_descriptor.getNestedTypes().get($index$);\n");
- bytecode_estimate += 30;
- }
-
- // And the FieldAccessorTable.
- bytecode_estimate += GenerateFieldAccessorTableInitializer(printer);
-
- // Generate static member initializers for all nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // TODO(kenton): Reuse MessageGenerator objects?
- bytecode_estimate +=
- ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
- .GenerateStaticVariableInitializers(printer);
- }
- return bytecode_estimate;
-}
-
+ bytecode_estimate += 30;
+ }
+
+ // And the FieldAccessorTable.
+ bytecode_estimate += GenerateFieldAccessorTableInitializer(printer);
+
+ // Generate static member initializers for all nested types.
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ // TODO(kenton): Reuse MessageGenerator objects?
+ bytecode_estimate +=
+ ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
+ .GenerateStaticVariableInitializers(printer);
+ }
+ return bytecode_estimate;
+}
+
void ImmutableMessageGenerator::GenerateFieldAccessorTable(
io::Printer* printer, int* bytecode_estimate) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
- // We can only make these package-private since the classes that use them
- // are in separate files.
- vars["private"] = "";
- } else {
- vars["private"] = "private ";
- }
- if (*bytecode_estimate <= kMaxStaticSize) {
- vars["final"] = "final ";
- } else {
- vars["final"] = "";
- }
- vars["ver"] = GeneratedCodeVersionSuffix();
+ vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
+ if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
+ // We can only make these package-private since the classes that use them
+ // are in separate files.
+ vars["private"] = "";
+ } else {
+ vars["private"] = "private ";
+ }
+ if (*bytecode_estimate <= kMaxStaticSize) {
+ vars["final"] = "final ";
+ } else {
+ vars["final"] = "";
+ }
+ vars["ver"] = GeneratedCodeVersionSuffix();
printer->Print(
vars,
"$private$static $final$\n"
" com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
" internal_$identifier$_fieldAccessorTable;\n");
-
+
// The following bytecode_estimate calculation logic must stay in sync with
// the similar logic in the GenerateFieldAccessorTableInitializer method below
// to make sure that the generated static final fields are initialized in the
// static initialization block directly.
//
- // 6 bytes per field and oneof
+ // 6 bytes per field and oneof
*bytecode_estimate +=
10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count();
-}
-
+}
+
int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
io::Printer* printer) {
- int bytecode_estimate = 10;
- printer->Print(
+ int bytecode_estimate = 10;
+ printer->Print(
"internal_$identifier$_fieldAccessorTable = new\n"
" com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable(\n"
" internal_$identifier$_descriptor,\n"
@@ -235,52 +235,52 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
// sync with the similar logic in the GenerateFieldAccessorTable method
// above. See the corresponding comment in GenerateFieldAccessorTable for
// details.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- bytecode_estimate += 6;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ bytecode_estimate += 6;
printer->Print("\"$field_name$\", ", "field_name", info->capitalized_name);
- }
+ }
// We reproduce synthetic oneofs here since proto reflection needs these.
- for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
- const OneofGeneratorInfo* info = context_->GetOneofGeneratorInfo(oneof);
- bytecode_estimate += 6;
+ for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
+ const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
+ const OneofGeneratorInfo* info = context_->GetOneofGeneratorInfo(oneof);
+ bytecode_estimate += 6;
printer->Print("\"$oneof_name$\", ", "oneof_name", info->capitalized_name);
- }
- printer->Print("});\n");
- return bytecode_estimate;
-}
-
-// ===================================================================
-
-void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
- /* immutable = */ true, "OrBuilder");
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+ }
+ printer->Print("});\n");
+ return bytecode_estimate;
+}
+
+// ===================================================================
+
+void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
+ /* immutable = */ true, "OrBuilder");
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
- " $extra_interfaces$\n"
- " com.google.protobuf.GeneratedMessage$ver$.\n"
- " ExtendableMessageOrBuilder<$classname$> {\n",
+ " $extra_interfaces$\n"
+ " com.google.protobuf.GeneratedMessage$ver$.\n"
+ " ExtendableMessageOrBuilder<$classname$> {\n",
"deprecation",
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
+ "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
"classname", descriptor_->name(), "{", "", "}", "", "ver",
GeneratedCodeVersionSuffix());
- } else {
- printer->Print(
+ } else {
+ printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
- " $extra_interfaces$\n"
- " com.google.protobuf.MessageOrBuilder {\n",
+ " $extra_interfaces$\n"
+ " com.google.protobuf.MessageOrBuilder {\n",
"deprecation",
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
+ "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
"classname", descriptor_->name(), "{", "", "}", "");
- }
+ }
printer->Annotate("{", "}", descriptor_);
-
- printer->Indent();
+
+ printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("\n");
field_generators_.get(descriptor_->field(i))
@@ -295,79 +295,79 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
context_->GetNameResolver()->GetImmutableClassName(descriptor_));
}
- printer->Outdent();
-
- printer->Print("}\n");
-}
-
-// ===================================================================
-
-void ImmutableMessageGenerator::Generate(io::Printer* printer) {
- bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
-
+ printer->Outdent();
+
+ printer->Print("}\n");
+}
+
+// ===================================================================
+
+void ImmutableMessageGenerator::Generate(io::Printer* printer) {
+ bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
+
std::map<TProtoStringType, TProtoStringType> variables;
variables["static"] = is_own_file ? "" : "static ";
- variables["classname"] = descriptor_->name();
- variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
- variables["ver"] = GeneratedCodeVersionSuffix();
+ variables["classname"] = descriptor_->name();
+ variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
+ variables["ver"] = GeneratedCodeVersionSuffix();
variables["deprecation"] =
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "";
-
- WriteMessageDocComment(printer, descriptor_);
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
- /* immutable = */ true);
-
- // The builder_type stores the super type name of the nested Builder class.
+
+ WriteMessageDocComment(printer, descriptor_);
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
+ /* immutable = */ true);
+
+ // The builder_type stores the super type name of the nested Builder class.
TProtoStringType builder_type;
- if (descriptor_->extension_range_count() > 0) {
+ if (descriptor_->extension_range_count() > 0) {
printer->Print(
variables,
"$deprecation$public $static$final class $classname$ extends\n");
- printer->Annotate("classname", descriptor_);
- printer->Print(
- variables,
- " com.google.protobuf.GeneratedMessage$ver$.ExtendableMessage<\n"
- " $classname$> implements\n"
- " $extra_interfaces$\n"
- " $classname$OrBuilder {\n");
- builder_type = strings::Substitute(
- "com.google.protobuf.GeneratedMessage$1.ExtendableBuilder<$0, ?>",
- name_resolver_->GetImmutableClassName(descriptor_),
- GeneratedCodeVersionSuffix());
- } else {
+ printer->Annotate("classname", descriptor_);
+ printer->Print(
+ variables,
+ " com.google.protobuf.GeneratedMessage$ver$.ExtendableMessage<\n"
+ " $classname$> implements\n"
+ " $extra_interfaces$\n"
+ " $classname$OrBuilder {\n");
+ builder_type = strings::Substitute(
+ "com.google.protobuf.GeneratedMessage$1.ExtendableBuilder<$0, ?>",
+ name_resolver_->GetImmutableClassName(descriptor_),
+ GeneratedCodeVersionSuffix());
+ } else {
printer->Print(
variables,
"$deprecation$public $static$final class $classname$ extends\n");
- printer->Annotate("classname", descriptor_);
- printer->Print(variables,
+ printer->Annotate("classname", descriptor_);
+ printer->Print(variables,
" com.google.protobuf.GeneratedMessage$ver$ implements\n"
" $extra_interfaces$\n"
" $classname$OrBuilder {\n");
builder_type =
strings::Substitute("com.google.protobuf.GeneratedMessage$0.Builder<?>",
GeneratedCodeVersionSuffix());
- }
+ }
printer->Print("private static final long serialVersionUID = 0L;\n");
- printer->Indent();
- // Using builder_type, instead of Builder, prevents the Builder class from
- // being loaded into PermGen space when the default instance is created.
- // This optimizes the PermGen space usage for clients that do not modify
- // messages.
- printer->Print(
+ printer->Indent();
+ // Using builder_type, instead of Builder, prevents the Builder class from
+ // being loaded into PermGen space when the default instance is created.
+ // This optimizes the PermGen space usage for clients that do not modify
+ // messages.
+ printer->Print(
"// Use $classname$.newBuilder() to construct.\n"
"private $classname$($buildertype$ builder) {\n"
" super(builder);\n"
"}\n",
"classname", descriptor_->name(), "buildertype", builder_type);
printer->Print("private $classname$() {\n", "classname", descriptor_->name());
- printer->Indent();
- GenerateInitializers(printer);
- printer->Outdent();
- printer->Print(
+ printer->Indent();
+ GenerateInitializers(printer);
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
-
+
printer->Print(variables,
"@java.lang.Override\n"
"@SuppressWarnings({\"unused\"})\n"
@@ -377,57 +377,57 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"}\n"
"\n");
- printer->Print(
+ printer->Print(
"@java.lang.Override\n"
"public final com.google.protobuf.UnknownFieldSet\n"
"getUnknownFields() {\n"
" return this.unknownFields;\n"
"}\n");
-
- if (context_->HasGeneratedMethods(descriptor_)) {
- GenerateParsingConstructor(printer);
- }
-
- GenerateDescriptorMethods(printer);
-
- // Nested types
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
+
+ if (context_->HasGeneratedMethods(descriptor_)) {
+ GenerateParsingConstructor(printer);
+ }
+
+ GenerateDescriptorMethods(printer);
+
+ // Nested types
+ for (int i = 0; i < descriptor_->enum_type_count(); i++) {
EnumGenerator(descriptor_->enum_type(i), true, context_).Generate(printer);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // Don't generate Java classes for map entry messages.
- if (IsMapEntry(descriptor_->nested_type(i))) continue;
+ }
+
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ // Don't generate Java classes for map entry messages.
+ if (IsMapEntry(descriptor_->nested_type(i))) continue;
ImmutableMessageGenerator messageGenerator(descriptor_->nested_type(i),
context_);
- messageGenerator.GenerateInterface(printer);
- messageGenerator.Generate(printer);
- }
-
+ messageGenerator.GenerateInterface(printer);
+ messageGenerator.Generate(printer);
+ }
+
// Integers for bit fields.
int totalBits = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
totalBits +=
field_generators_.get(descriptor_->field(i)).GetNumBitsForMessage();
- }
+ }
int totalInts = (totalBits + 31) / 32;
for (int i = 0; i < totalInts; i++) {
printer->Print("private int $bit_field_name$;\n", "bit_field_name",
GetBitFieldName(i));
}
-
- // oneof
+
+ // oneof
std::map<TProtoStringType, TProtoStringType> vars;
for (auto oneof : oneofs_) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
vars["oneof_index"] = StrCat((oneof)->index());
- // oneofCase_ and oneof_
- printer->Print(vars,
+ // oneofCase_ and oneof_
+ printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
"private java.lang.Object $oneof_name$_;\n");
- // OneofCase enum
+ // OneofCase enum
printer->Print(
vars,
"public enum $oneof_capitalized_name$Case\n"
@@ -435,15 +435,15 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
// 3.x users
" implements com.google.protobuf.Internal.EnumLite,\n"
" com.google.protobuf.AbstractMessage.InternalOneOfEnum {\n");
- printer->Indent();
+ printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
- printer->Print(
+ printer->Print(
"$deprecation$$field_name$($field_number$),\n", "deprecation",
field->options().deprecated() ? "@java.lang.Deprecated " : "",
"field_name", ToUpper(field->name()), "field_number",
StrCat(field->number()));
- }
+ }
printer->Print("$cap_oneof_name$_NOT_SET(0);\n", "cap_oneof_name",
ToUpper(vars["oneof_name"]));
printer->Print(vars,
@@ -451,7 +451,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"private $oneof_capitalized_name$Case(int value) {\n"
" this.value = value;\n"
"}\n");
- printer->Print(
+ printer->Print(
vars,
"/**\n"
" * @param value The number of the enum to look for.\n"
@@ -470,8 +470,8 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
printer->Print(" case $field_number$: return $field_name$;\n",
"field_number", StrCat(field->number()),
"field_name", ToUpper(field->name()));
- }
- printer->Print(
+ }
+ printer->Print(
" case 0: return $cap_oneof_name$_NOT_SET;\n"
" default: return null;\n"
" }\n"
@@ -480,66 +480,66 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
" return this.value;\n"
"}\n",
"cap_oneof_name", ToUpper(vars["oneof_name"]));
- printer->Outdent();
- printer->Print("};\n\n");
- // oneofCase()
- printer->Print(vars,
+ printer->Outdent();
+ printer->Print("};\n\n");
+ // oneofCase()
+ printer->Print(vars,
"public $oneof_capitalized_name$Case\n"
"get$oneof_capitalized_name$Case() {\n"
" return $oneof_capitalized_name$Case.forNumber(\n"
" $oneof_name$Case_);\n"
"}\n"
"\n");
- }
-
- if (IsAnyMessage(descriptor_)) {
- GenerateAnyMethods(printer);
- }
-
- // Fields
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("public static final int $constant_name$ = $number$;\n",
+ }
+
+ if (IsAnyMessage(descriptor_)) {
+ GenerateAnyMethods(printer);
+ }
+
+ // Fields
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("public static final int $constant_name$ = $number$;\n",
"constant_name", FieldConstantName(descriptor_->field(i)),
"number", StrCat(descriptor_->field(i)->number()));
printer->Annotate("constant_name", descriptor_->field(i));
- field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
- printer->Print("\n");
- }
-
- if (context_->HasGeneratedMethods(descriptor_)) {
- GenerateIsInitialized(printer);
- GenerateMessageSerializationMethods(printer);
- GenerateEqualsAndHashCode(printer);
- }
-
-
- GenerateParseFromMethods(printer);
- GenerateBuilder(printer);
-
- printer->Print(
+ field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
+ printer->Print("\n");
+ }
+
+ if (context_->HasGeneratedMethods(descriptor_)) {
+ GenerateIsInitialized(printer);
+ GenerateMessageSerializationMethods(printer);
+ GenerateEqualsAndHashCode(printer);
+ }
+
+
+ GenerateParseFromMethods(printer);
+ GenerateBuilder(printer);
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(class_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- // Carefully initialize the default instance in such a way that it doesn't
- // conflict with other initialization.
+
+ // Carefully initialize the default instance in such a way that it doesn't
+ // conflict with other initialization.
printer->Print("private static final $classname$ DEFAULT_INSTANCE;\n",
"classname",
name_resolver_->GetImmutableClassName(descriptor_));
- printer->Print(
+ printer->Print(
"static {\n"
" DEFAULT_INSTANCE = new $classname$();\n"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
- "public static $classname$ getDefaultInstance() {\n"
- " return DEFAULT_INSTANCE;\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
-
+
+ printer->Print(
+ "public static $classname$ getDefaultInstance() {\n"
+ " return DEFAULT_INSTANCE;\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+
// 'of' method for Wrappers
if (IsWrappersProtoFile(descriptor_->file())) {
printer->Print(
@@ -551,98 +551,98 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0))));
}
- GenerateParser(printer);
-
- printer->Print(
+ GenerateParser(printer);
+
+ printer->Print(
"@java.lang.Override\n"
"public $classname$ getDefaultInstanceForType() {\n"
" return DEFAULT_INSTANCE;\n"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- // Extensions must be declared after the DEFAULT_INSTANCE is initialized
- // because the DEFAULT_INSTANCE is used by the extension to lazily retrieve
- // the outer class's FileDescriptor.
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- ImmutableExtensionGenerator(descriptor_->extension(i), context_)
- .Generate(printer);
- }
-
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-// ===================================================================
-
+
+ // Extensions must be declared after the DEFAULT_INSTANCE is initialized
+ // because the DEFAULT_INSTANCE is used by the extension to lazily retrieve
+ // the outer class's FileDescriptor.
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ ImmutableExtensionGenerator(descriptor_->extension(i), context_)
+ .Generate(printer);
+ }
+
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+// ===================================================================
+
void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
io::Printer* printer) {
std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
- SortFieldsByNumber(descriptor_));
-
+ SortFieldsByNumber(descriptor_));
+
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(),
- ExtensionRangeOrdering());
- printer->Print(
+ 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(),
+ ExtensionRangeOrdering());
+ printer->Print(
"@java.lang.Override\n"
"public void writeTo(com.google.protobuf.CodedOutputStream output)\n"
" throws java.io.IOException {\n");
- printer->Indent();
+ printer->Indent();
- if (HasPackedFields(descriptor_)) {
- // writeTo(CodedOutputStream output) might be invoked without
- // getSerializedSize() ever being called, but we need the memoized
+ if (HasPackedFields(descriptor_)) {
+ // writeTo(CodedOutputStream output) might be invoked without
+ // getSerializedSize() ever being called, but we need the memoized
// sizes in case this message has packed fields. Rather than emit checks
// for each packed field, just call getSerializedSize() up front. In most
// cases, getSerializedSize() will have already been called anyway by one
// of the wrapper writeTo() methods, making this call cheap.
printer->Print("getSerializedSize();\n");
- }
-
- if (descriptor_->extension_range_count() > 0) {
- if (descriptor_->options().message_set_wire_format()) {
- printer->Print(
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
"com.google.protobuf.GeneratedMessage$ver$\n"
" .ExtendableMessage<$classname$>.ExtensionWriter\n"
" extensionWriter = newMessageSetExtensionWriter();\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_),
"ver", GeneratedCodeVersionSuffix());
- } else {
- printer->Print(
+ } else {
+ printer->Print(
"com.google.protobuf.GeneratedMessage$ver$\n"
" .ExtendableMessage<$classname$>.ExtensionWriter\n"
" extensionWriter = newExtensionWriter();\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_),
"ver", GeneratedCodeVersionSuffix());
- }
- }
-
- // Merge the fields and the extension ranges, both sorted by field number.
- for (int i = 0, j = 0;
+ }
+ }
+
+ // Merge the fields and the extension ranges, both sorted by field number.
+ for (int i = 0, j = 0;
i < descriptor_->field_count() || j < sorted_extensions.size();) {
- if (i == descriptor_->field_count()) {
- GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
- } else if (j == sorted_extensions.size()) {
- GenerateSerializeOneField(printer, sorted_fields[i++]);
- } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) {
- GenerateSerializeOneField(printer, sorted_fields[i++]);
- } else {
- GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
- }
- }
-
+ if (i == descriptor_->field_count()) {
+ GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
+ } else if (j == sorted_extensions.size()) {
+ GenerateSerializeOneField(printer, sorted_fields[i++]);
+ } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) {
+ GenerateSerializeOneField(printer, sorted_fields[i++]);
+ } else {
+ GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
+ }
+ }
+
if (descriptor_->options().message_set_wire_format()) {
printer->Print("unknownFields.writeAsMessageSetTo(output);\n");
} else {
printer->Print("unknownFields.writeTo(output);\n");
- }
-
- printer->Outdent();
- printer->Print(
+ }
+
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n"
"@java.lang.Override\n"
@@ -650,43 +650,43 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
" int size = memoizedSize;\n"
" if (size != -1) return size;\n"
"\n");
- printer->Indent();
-
+ printer->Indent();
+
printer->Print("size = 0;\n");
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer);
- }
-
- if (descriptor_->extension_range_count() > 0) {
- if (descriptor_->options().message_set_wire_format()) {
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer);
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ if (descriptor_->options().message_set_wire_format()) {
printer->Print("size += extensionsSerializedSizeAsMessageSet();\n");
- } else {
+ } else {
printer->Print("size += extensionsSerializedSize();\n");
- }
- }
-
+ }
+ }
+
if (descriptor_->options().message_set_wire_format()) {
printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n");
} else {
printer->Print("size += unknownFields.getSerializedSize();\n");
- }
-
+ }
+
printer->Print(
"memoizedSize = size;\n"
"return size;\n");
- printer->Outdent();
- printer->Print(
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
-}
-
+}
+
void ImmutableMessageGenerator::GenerateParseFromMethods(io::Printer* printer) {
- // Note: These are separate from GenerateMessageSerializationMethods()
- // because they need to be generated even for messages that are optimized
- // for code size.
- printer->Print(
+ // Note: These are separate from GenerateMessageSerializationMethods()
+ // because they need to be generated even for messages that are optimized
+ // for code size.
+ printer->Print(
"public static $classname$ parseFrom(\n"
" java.nio.ByteBuffer data)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"
@@ -761,28 +761,28 @@ void ImmutableMessageGenerator::GenerateParseFromMethods(io::Printer* printer) {
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
GeneratedCodeVersionSuffix());
-}
-
-void ImmutableMessageGenerator::GenerateSerializeOneField(
- io::Printer* printer, const FieldDescriptor* field) {
- field_generators_.get(field).GenerateSerializationCode(printer);
-}
-
-void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(
- io::Printer* printer, const Descriptor::ExtensionRange* range) {
+}
+
+void ImmutableMessageGenerator::GenerateSerializeOneField(
+ io::Printer* printer, const FieldDescriptor* field) {
+ field_generators_.get(field).GenerateSerializationCode(printer);
+}
+
+void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(
+ io::Printer* printer, const Descriptor::ExtensionRange* range) {
printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
StrCat(range->end));
-}
-
-// ===================================================================
-
-void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) {
- // LITE_RUNTIME implements this at the GeneratedMessageLite level.
- printer->Print(
+}
+
+// ===================================================================
+
+void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) {
+ // LITE_RUNTIME implements this at the GeneratedMessageLite level.
+ printer->Print(
"@java.lang.Override\n"
"public Builder newBuilderForType() { return newBuilder(); }\n");
-
- printer->Print(
+
+ printer->Print(
"public static Builder newBuilder() {\n"
" return DEFAULT_INSTANCE.toBuilder();\n"
"}\n"
@@ -796,8 +796,8 @@ void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) {
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
+
+ printer->Print(
"@java.lang.Override\n"
"protected Builder newBuilderForType(\n"
" com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
@@ -805,15 +805,15 @@ void ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) {
" return builder;\n"
"}\n",
"ver", GeneratedCodeVersionSuffix());
-
- MessageBuilderGenerator builderGenerator(descriptor_, context_);
- builderGenerator.Generate(printer);
-}
-
+
+ MessageBuilderGenerator builderGenerator(descriptor_, context_);
+ builderGenerator.Generate(printer);
+}
+
void ImmutableMessageGenerator::GenerateDescriptorMethods(
io::Printer* printer) {
- if (!descriptor_->options().no_standard_descriptor_accessor()) {
- printer->Print(
+ if (!descriptor_->options().no_standard_descriptor_accessor()) {
+ printer->Print(
"public static final com.google.protobuf.Descriptors.Descriptor\n"
" getDescriptor() {\n"
" return $fileclass$.internal_$identifier$_descriptor;\n"
@@ -821,44 +821,44 @@ void ImmutableMessageGenerator::GenerateDescriptorMethods(
"\n",
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
- }
+ }
std::vector<const FieldDescriptor*> map_fields;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- if (GetJavaType(field) == JAVATYPE_MESSAGE &&
- IsMapEntry(field->message_type())) {
- map_fields.push_back(field);
- }
- }
- if (!map_fields.empty()) {
- printer->Print(
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (GetJavaType(field) == JAVATYPE_MESSAGE &&
+ IsMapEntry(field->message_type())) {
+ map_fields.push_back(field);
+ }
+ }
+ if (!map_fields.empty()) {
+ printer->Print(
"@SuppressWarnings({\"rawtypes\"})\n"
"@java.lang.Override\n"
"protected com.google.protobuf.MapField internalGetMapField(\n"
" int number) {\n"
" switch (number) {\n");
- printer->Indent();
- printer->Indent();
- for (int i = 0; i < map_fields.size(); ++i) {
- const FieldDescriptor* field = map_fields[i];
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- printer->Print(
+ printer->Indent();
+ printer->Indent();
+ for (int i = 0; i < map_fields.size(); ++i) {
+ const FieldDescriptor* field = map_fields[i];
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ printer->Print(
"case $number$:\n"
" return internalGet$capitalized_name$();\n",
"number", StrCat(field->number()), "capitalized_name",
info->capitalized_name);
- }
- printer->Print(
- "default:\n"
- " throw new RuntimeException(\n"
- " \"Invalid map field number: \" + number);\n");
- printer->Outdent();
- printer->Outdent();
- printer->Print(
- " }\n"
- "}\n");
- }
- printer->Print(
+ }
+ printer->Print(
+ "default:\n"
+ " throw new RuntimeException(\n"
+ " \"Invalid map field number: \" + number);\n");
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
+ " }\n"
+ "}\n");
+ }
+ printer->Print(
"@java.lang.Override\n"
"protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
" internalGetFieldAccessorTable() {\n"
@@ -871,53 +871,53 @@ void ImmutableMessageGenerator::GenerateDescriptorMethods(
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
GeneratedCodeVersionSuffix());
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
- // Memoizes whether the protocol buffer is fully initialized (has all
- // required fields). -1 means not yet computed. 0 means false and 1 means
- // true.
+ // Memoizes whether the protocol buffer is fully initialized (has all
+ // required fields). -1 means not yet computed. 0 means false and 1 means
+ // true.
printer->Print("private byte memoizedIsInitialized = -1;\n");
- printer->Print(
+ printer->Print(
"@java.lang.Override\n"
"public final boolean isInitialized() {\n");
- printer->Indent();
-
- // Don't directly compare to -1 to avoid an Android x86 JIT bug.
- printer->Print(
+ printer->Indent();
+
+ // Don't directly compare to -1 to avoid an Android x86 JIT bug.
+ printer->Print(
"byte isInitialized = memoizedIsInitialized;\n"
"if (isInitialized == 1) return true;\n"
"if (isInitialized == 0) return false;\n"
"\n");
-
- // Check that all required fields in this message are set.
- // TODO(kenton): We can optimize this when we switch to putting all the
- // "has" fields into a single bitfield.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
-
- if (field->is_required()) {
- printer->Print(
+
+ // Check that all required fields in this message are set.
+ // TODO(kenton): We can optimize this when we switch to putting all the
+ // "has" fields into a single bitfield.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+
+ if (field->is_required()) {
+ printer->Print(
"if (!has$name$()) {\n"
" memoizedIsInitialized = 0;\n"
" return false;\n"
"}\n",
"name", info->capitalized_name);
- }
- }
-
- // Now check that all embedded messages are initialized.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- if (GetJavaType(field) == JAVATYPE_MESSAGE &&
- HasRequiredFields(field->message_type())) {
- switch (field->label()) {
- case FieldDescriptor::LABEL_REQUIRED:
- printer->Print(
+ }
+ }
+
+ // Now check that all embedded messages are initialized.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ if (GetJavaType(field) == JAVATYPE_MESSAGE &&
+ HasRequiredFields(field->message_type())) {
+ switch (field->label()) {
+ case FieldDescriptor::LABEL_REQUIRED:
+ printer->Print(
"if (!get$name$().isInitialized()) {\n"
" memoizedIsInitialized = 0;\n"
" return false;\n"
@@ -925,16 +925,16 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
"type",
name_resolver_->GetImmutableClassName(field->message_type()),
"name", info->capitalized_name);
- break;
- case FieldDescriptor::LABEL_OPTIONAL:
- printer->Print(
+ break;
+ case FieldDescriptor::LABEL_OPTIONAL:
+ printer->Print(
"if (has$name$()) {\n"
" if (!get$name$().isInitialized()) {\n"
- " memoizedIsInitialized = 0;\n"
- " return false;\n"
- " }\n"
- "}\n",
- "name", info->capitalized_name);
+ " memoizedIsInitialized = 0;\n"
+ " return false;\n"
+ " }\n"
+ "}\n",
+ "name", info->capitalized_name);
break;
case FieldDescriptor::LABEL_REPEATED:
if (IsMapEntry(field->message_type())) {
@@ -949,8 +949,8 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
MapValueImmutableClassdName(field->message_type(),
name_resolver_),
"name", info->capitalized_name);
- } else {
- printer->Print(
+ } else {
+ printer->Print(
"for (int i = 0; i < get$name$Count(); i++) {\n"
" if (!get$name$(i).isInitialized()) {\n"
" memoizedIsInitialized = 0;\n"
@@ -960,52 +960,52 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
"type",
name_resolver_->GetImmutableClassName(field->message_type()),
"name", info->capitalized_name);
- }
- break;
- }
- }
- }
-
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+ }
+ break;
+ }
+ }
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"if (!extensionsAreInitialized()) {\n"
" memoizedIsInitialized = 0;\n"
" return false;\n"
"}\n");
- }
-
- printer->Outdent();
-
+ }
+
+ printer->Outdent();
+
printer->Print(" memoizedIsInitialized = 1;\n");
-
- printer->Print(
+
+ printer->Print(
" return true;\n"
"}\n"
"\n");
-}
-
-// ===================================================================
-
-namespace {
-bool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) {
- if (field->is_repeated()) {
- return false;
- }
+}
+
+// ===================================================================
+
+namespace {
+bool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) {
+ if (field->is_repeated()) {
+ return false;
+ }
if (HasHasbit(field)) {
- return true;
- }
+ return true;
+ }
return GetJavaType(field) == JAVATYPE_MESSAGE && !IsRealOneof(field);
-}
-} // namespace
-
+}
+} // namespace
+
void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
io::Printer* printer) {
- printer->Print(
+ printer->Print(
"@java.lang.Override\n"
"public boolean equals(");
printer->Print("final java.lang.Object obj) {\n");
- printer->Indent();
- printer->Print(
+ printer->Indent();
+ printer->Print(
"if (obj == this) {\n"
" return true;\n"
"}\n"
@@ -1015,246 +1015,246 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
"$classname$ other = ($classname$) obj;\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
if (!IsRealOneof(field)) {
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);
- if (check_has_bits) {
- printer->Print(
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);
+ if (check_has_bits) {
+ printer->Print(
"if (has$name$() != other.has$name$()) return false;\n"
"if (has$name$()) {\n",
"name", info->capitalized_name);
- printer->Indent();
- }
- field_generators_.get(field).GenerateEqualsCode(printer);
- if (check_has_bits) {
- printer->Outdent();
+ printer->Indent();
+ }
+ field_generators_.get(field).GenerateEqualsCode(printer);
+ if (check_has_bits) {
+ printer->Outdent();
printer->Print("}\n");
- }
- }
- }
-
- // Compare oneofs.
+ }
+ }
+ }
+
+ // Compare oneofs.
for (auto oneof : oneofs_) {
- printer->Print(
+ printer->Print(
"if (!get$oneof_capitalized_name$Case().equals("
"other.get$oneof_capitalized_name$Case())) return false;\n",
"oneof_capitalized_name",
context_->GetOneofGeneratorInfo(oneof)->capitalized_name);
printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name",
context_->GetOneofGeneratorInfo(oneof)->name);
- printer->Indent();
+ printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print("case $field_number$:\n", "field_number",
StrCat(field->number()));
- printer->Indent();
- field_generators_.get(field).GenerateEqualsCode(printer);
- printer->Print("break;\n");
- printer->Outdent();
- }
- printer->Print(
+ printer->Indent();
+ field_generators_.get(field).GenerateEqualsCode(printer);
+ printer->Print("break;\n");
+ printer->Outdent();
+ }
+ printer->Print(
"case 0:\n"
"default:\n");
- printer->Outdent();
- printer->Print("}\n");
- }
-
+ printer->Outdent();
+ printer->Print("}\n");
+ }
+
// Always consider unknown fields for equality. This will sometimes return
// false for non-canonical ordering when running in LITE_RUNTIME but it's
// the best we can do.
printer->Print(
"if (!unknownFields.equals(other.unknownFields)) return false;\n");
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"if (!getExtensionFields().equals(other.getExtensionFields()))\n"
" return false;\n");
- }
+ }
printer->Print("return true;\n");
- printer->Outdent();
- printer->Print(
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
-
- printer->Print(
+
+ printer->Print(
"@java.lang.Override\n"
"public int hashCode() {\n");
- printer->Indent();
+ printer->Indent();
printer->Print("if (memoizedHashCode != 0) {\n");
- printer->Indent();
+ printer->Indent();
printer->Print("return memoizedHashCode;\n");
- printer->Outdent();
- printer->Print(
+ printer->Outdent();
+ printer->Print(
"}\n"
"int hash = 41;\n");
-
+
// If we output a getDescriptor() method, use that as it is more efficient.
if (descriptor_->options().no_standard_descriptor_accessor()) {
printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n");
} else {
printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n");
}
-
- // hashCode non-oneofs.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
+
+ // hashCode non-oneofs.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
if (!IsRealOneof(field)) {
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);
- if (check_has_bits) {
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);
+ if (check_has_bits) {
printer->Print("if (has$name$()) {\n", "name", info->capitalized_name);
- printer->Indent();
- }
- field_generators_.get(field).GenerateHashCode(printer);
- if (check_has_bits) {
- printer->Outdent();
- printer->Print("}\n");
- }
- }
- }
-
- // hashCode oneofs.
+ printer->Indent();
+ }
+ field_generators_.get(field).GenerateHashCode(printer);
+ if (check_has_bits) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
+ }
+ }
+
+ // hashCode oneofs.
for (auto oneof : oneofs_) {
printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name",
context_->GetOneofGeneratorInfo(oneof)->name);
- printer->Indent();
+ printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print("case $field_number$:\n", "field_number",
StrCat(field->number()));
- printer->Indent();
- field_generators_.get(field).GenerateHashCode(printer);
- printer->Print("break;\n");
- printer->Outdent();
- }
- printer->Print(
+ printer->Indent();
+ field_generators_.get(field).GenerateHashCode(printer);
+ printer->Print("break;\n");
+ printer->Outdent();
+ }
+ printer->Print(
"case 0:\n"
"default:\n");
- printer->Outdent();
- printer->Print("}\n");
- }
-
- if (descriptor_->extension_range_count() > 0) {
+ printer->Outdent();
+ printer->Print("}\n");
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
printer->Print("hash = hashFields(hash, getExtensionFields());\n");
- }
-
+ }
+
printer->Print("hash = (29 * hash) + unknownFields.hashCode();\n");
- printer->Print(
+ printer->Print(
"memoizedHashCode = hash;\n"
"return hash;\n");
- printer->Outdent();
- printer->Print(
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
void ImmutableMessageGenerator::GenerateExtensionRegistrationCode(
io::Printer* printer) {
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- ImmutableExtensionGenerator(descriptor_->extension(i), context_)
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ ImmutableExtensionGenerator(descriptor_->extension(i), context_)
.GenerateRegistrationCode(printer);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
+ }
+
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
.GenerateExtensionRegistrationCode(printer);
- }
-}
-
-// ===================================================================
+ }
+}
+
+// ===================================================================
void ImmutableMessageGenerator::GenerateParsingConstructor(
io::Printer* printer) {
std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
- SortFieldsByNumber(descriptor_));
-
- printer->Print(
- "private $classname$(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n",
- "classname", descriptor_->name());
- printer->Indent();
-
- // Initialize all fields to default.
- printer->Print(
+ SortFieldsByNumber(descriptor_));
+
+ printer->Print(
+ "private $classname$(\n"
+ " com.google.protobuf.CodedInputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n",
+ "classname", descriptor_->name());
+ printer->Indent();
+
+ // Initialize all fields to default.
+ printer->Print(
"this();\n"
"if (extensionRegistry == null) {\n"
" throw new java.lang.NullPointerException();\n"
"}\n");
-
- // Use builder bits to track mutable repeated fields.
- int totalBuilderBits = 0;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const ImmutableFieldGenerator& field =
- field_generators_.get(descriptor_->field(i));
- totalBuilderBits += field.GetNumBitsForBuilder();
- }
- int totalBuilderInts = (totalBuilderBits + 31) / 32;
- for (int i = 0; i < totalBuilderInts; i++) {
+
+ // Use builder bits to track mutable repeated fields.
+ int totalBuilderBits = 0;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const ImmutableFieldGenerator& field =
+ field_generators_.get(descriptor_->field(i));
+ totalBuilderBits += field.GetNumBitsForBuilder();
+ }
+ int totalBuilderInts = (totalBuilderBits + 31) / 32;
+ for (int i = 0; i < totalBuilderInts; i++) {
printer->Print("int mutable_$bit_field_name$ = 0;\n", "bit_field_name",
GetBitFieldName(i));
- }
-
+ }
+
printer->Print(
- "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n"
- " com.google.protobuf.UnknownFieldSet.newBuilder();\n");
-
+ "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n"
+ " com.google.protobuf.UnknownFieldSet.newBuilder();\n");
+
printer->Print("try {\n");
- printer->Indent();
-
- printer->Print(
+ printer->Indent();
+
+ printer->Print(
"boolean done = false;\n"
"while (!done) {\n");
- printer->Indent();
-
- printer->Print(
+ printer->Indent();
+
+ printer->Print(
"int tag = input.readTag();\n"
"switch (tag) {\n");
- printer->Indent();
-
- printer->Print(
+ printer->Indent();
+
+ printer->Print(
"case 0:\n" // zero signals EOF / limit reached
" done = true;\n"
" break;\n");
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = sorted_fields[i];
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = sorted_fields[i];
uint32_t tag = WireFormatLite::MakeTag(
field->number(), WireFormat::WireTypeForFieldType(field->type()));
-
+
printer->Print("case $tag$: {\n", "tag",
StrCat(static_cast<int32_t>(tag)));
- printer->Indent();
-
- field_generators_.get(field).GenerateParsingCode(printer);
-
- printer->Outdent();
- printer->Print(
+ printer->Indent();
+
+ field_generators_.get(field).GenerateParsingCode(printer);
+
+ printer->Outdent();
+ printer->Print(
" break;\n"
"}\n");
-
- if (field->is_packable()) {
- // To make packed = true wire compatible, we generate parsing code from a
- // packed version of this field regardless of field->options().packed().
+
+ if (field->is_packable()) {
+ // To make packed = true wire compatible, we generate parsing code from a
+ // packed version of this field regardless of field->options().packed().
uint32_t packed_tag = WireFormatLite::MakeTag(
field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print("case $tag$: {\n", "tag",
StrCat(static_cast<int32_t>(packed_tag)));
- printer->Indent();
-
- field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
-
- printer->Outdent();
- printer->Print(
+ printer->Indent();
+
+ field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
+
+ printer->Outdent();
+ printer->Print(
" break;\n"
"}\n");
- }
- }
-
+ }
+ }
+
printer->Print(
"default: {\n"
" if (!parseUnknownField(\n"
@@ -1264,109 +1264,109 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
" break;\n"
"}\n");
- printer->Outdent();
- printer->Outdent();
- printer->Print(
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
" }\n" // switch (tag)
"}\n"); // while (!done)
-
- printer->Outdent();
- printer->Print(
- "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
- " throw e.setUnfinishedMessage(this);\n"
- "} catch (java.io.IOException e) {\n"
- " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
- " e).setUnfinishedMessage(this);\n"
- "} finally {\n");
- printer->Indent();
-
- // Make repeated field list immutable.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = sorted_fields[i];
- field_generators_.get(field).GenerateParsingDoneCode(printer);
- }
-
+
+ printer->Outdent();
+ printer->Print(
+ "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
+ " throw e.setUnfinishedMessage(this);\n"
+ "} catch (java.io.IOException e) {\n"
+ " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
+ " e).setUnfinishedMessage(this);\n"
+ "} finally {\n");
+ printer->Indent();
+
+ // Make repeated field list immutable.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = sorted_fields[i];
+ field_generators_.get(field).GenerateParsingDoneCode(printer);
+ }
+
// Make unknown fields immutable.
printer->Print("this.unknownFields = unknownFields.build();\n");
-
- // Make extensions immutable.
+
+ // Make extensions immutable.
printer->Print("makeExtensionsImmutable();\n");
-
- printer->Outdent();
- printer->Outdent();
- printer->Print(
+
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
" }\n" // finally
- "}\n");
-}
-
-// ===================================================================
-void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
- printer->Print(
- "$visibility$ static final com.google.protobuf.Parser<$classname$>\n"
- " PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n",
- "visibility",
- ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public"
- : "private",
- "classname", descriptor_->name());
- printer->Indent();
- printer->Print(
+ "}\n");
+}
+
+// ===================================================================
+void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
+ printer->Print(
+ "$visibility$ static final com.google.protobuf.Parser<$classname$>\n"
+ " PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n",
+ "visibility",
+ ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public"
+ : "private",
+ "classname", descriptor_->name());
+ printer->Indent();
+ printer->Print(
"@java.lang.Override\n"
- "public $classname$ parsePartialFrom(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n",
- "classname", descriptor_->name());
- if (context_->HasGeneratedMethods(descriptor_)) {
+ "public $classname$ parsePartialFrom(\n"
+ " com.google.protobuf.CodedInputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n",
+ "classname", descriptor_->name());
+ if (context_->HasGeneratedMethods(descriptor_)) {
printer->Print(" return new $classname$(input, extensionRegistry);\n",
"classname", descriptor_->name());
- } else {
- // When parsing constructor isn't generated, use builder to parse
- // messages. Note, will fallback to use reflection based mergeFieldFrom()
- // in AbstractMessage.Builder.
- printer->Indent();
- printer->Print(
- "Builder builder = newBuilder();\n"
- "try {\n"
- " builder.mergeFrom(input, extensionRegistry);\n"
- "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
- " throw e.setUnfinishedMessage(builder.buildPartial());\n"
- "} catch (java.io.IOException e) {\n"
- " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
- " e.getMessage()).setUnfinishedMessage(\n"
- " builder.buildPartial());\n"
- "}\n"
- "return builder.buildPartial();\n");
- printer->Outdent();
- }
+ } else {
+ // When parsing constructor isn't generated, use builder to parse
+ // messages. Note, will fallback to use reflection based mergeFieldFrom()
+ // in AbstractMessage.Builder.
+ printer->Indent();
+ printer->Print(
+ "Builder builder = newBuilder();\n"
+ "try {\n"
+ " builder.mergeFrom(input, extensionRegistry);\n"
+ "} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
+ " throw e.setUnfinishedMessage(builder.buildPartial());\n"
+ "} catch (java.io.IOException e) {\n"
+ " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
+ " e.getMessage()).setUnfinishedMessage(\n"
+ " builder.buildPartial());\n"
+ "}\n"
+ "return builder.buildPartial();\n");
+ printer->Outdent();
+ }
printer->Print("}\n");
- printer->Outdent();
- printer->Print(
- "};\n"
- "\n");
-
- printer->Print(
- "public static com.google.protobuf.Parser<$classname$> parser() {\n"
- " return PARSER;\n"
- "}\n"
- "\n"
- "@java.lang.Override\n"
- "public com.google.protobuf.Parser<$classname$> getParserForType() {\n"
- " return PARSER;\n"
- "}\n"
- "\n",
- "classname", descriptor_->name());
-}
-
-// ===================================================================
-void ImmutableMessageGenerator::GenerateInitializers(io::Printer* printer) {
- for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "\n");
+
+ printer->Print(
+ "public static com.google.protobuf.Parser<$classname$> parser() {\n"
+ " return PARSER;\n"
+ "}\n"
+ "\n"
+ "@java.lang.Override\n"
+ "public com.google.protobuf.Parser<$classname$> getParserForType() {\n"
+ " return PARSER;\n"
+ "}\n"
+ "\n",
+ "classname", descriptor_->name());
+}
+
+// ===================================================================
+void ImmutableMessageGenerator::GenerateInitializers(io::Printer* printer) {
+ for (int i = 0; i < descriptor_->field_count(); i++) {
if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateInitializationCode(printer);
- }
- }
-}
-
+ field_generators_.get(descriptor_->field(i))
+ .GenerateInitializationCode(printer);
+ }
+ }
+}
+
// ===================================================================
void ImmutableMessageGenerator::GenerateMutableCopy(io::Printer* printer) {
printer->Print(
@@ -1639,8 +1639,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"message", message_name);
}
-void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
- printer->Print(
+void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
+ printer->Print(
"private static String getTypeUrl(\n"
" java.lang.String typeUrlPrefix,\n"
" com.google.protobuf.Descriptors.Descriptor descriptor) {\n"
@@ -1711,9 +1711,9 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
" cachedUnpackValue = result;\n"
" return result;\n"
"}\n");
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
index d32bb056a5..cafc91e68b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
+
#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,105 +49,105 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-static const int kMaxStaticSize = 1 << 15; // aka 32k
-
-class MessageGenerator {
- public:
- explicit MessageGenerator(const Descriptor* descriptor);
- virtual ~MessageGenerator();
-
- // All static variables have to be declared at the top-level of the file
- // so that we can control initialization order, which is important for
- // DescriptorProto bootstrapping to work.
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+static const int kMaxStaticSize = 1 << 15; // aka 32k
+
+class MessageGenerator {
+ public:
+ explicit MessageGenerator(const Descriptor* descriptor);
+ virtual ~MessageGenerator();
+
+ // All static variables have to be declared at the top-level of the file
+ // so that we can control initialization order, which is important for
+ // DescriptorProto bootstrapping to work.
virtual void GenerateStaticVariables(io::Printer* printer,
int* bytecode_estimate) = 0;
-
- // Output code which initializes the static variables generated by
- // GenerateStaticVariables(). Returns an estimate of bytecode size.
- virtual int GenerateStaticVariableInitializers(io::Printer* printer) = 0;
-
- // Generate the class itself.
- virtual void Generate(io::Printer* printer) = 0;
-
+
+ // Output code which initializes the static variables generated by
+ // GenerateStaticVariables(). Returns an estimate of bytecode size.
+ virtual int GenerateStaticVariableInitializers(io::Printer* printer) = 0;
+
+ // Generate the class itself.
+ virtual void Generate(io::Printer* printer) = 0;
+
// Generates the base interface that both the class and its builder
// implement
- virtual void GenerateInterface(io::Printer* printer) = 0;
-
- // Generate code to register all contained extensions with an
- // ExtensionRegistry.
- virtual void GenerateExtensionRegistrationCode(io::Printer* printer) = 0;
+ virtual void GenerateInterface(io::Printer* printer) = 0;
+
+ // Generate code to register all contained extensions with an
+ // ExtensionRegistry.
+ virtual void GenerateExtensionRegistrationCode(io::Printer* printer) = 0;
virtual void GenerateKotlinDsl(io::Printer* printer) const = 0;
virtual void GenerateKotlinMembers(io::Printer* printer) const = 0;
virtual void GenerateTopLevelKotlinMembers(io::Printer* printer) const = 0;
-
- protected:
- const Descriptor* descriptor_;
+
+ protected:
+ const Descriptor* descriptor_;
std::set<const OneofDescriptor*> oneofs_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
-};
-
-class ImmutableMessageGenerator : public MessageGenerator {
- public:
- ImmutableMessageGenerator(const Descriptor* descriptor, Context* context);
- virtual ~ImmutableMessageGenerator();
-
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
+};
+
+class ImmutableMessageGenerator : public MessageGenerator {
+ public:
+ ImmutableMessageGenerator(const Descriptor* descriptor, Context* context);
+ virtual ~ImmutableMessageGenerator();
+
void Generate(io::Printer* printer) override;
void GenerateInterface(io::Printer* printer) override;
void GenerateExtensionRegistrationCode(io::Printer* printer) override;
void GenerateStaticVariables(io::Printer* printer,
int* bytecode_estimate) override;
-
- // Returns an estimate of the number of bytes the printed code will compile to
+
+ // Returns an estimate of the number of bytes the printed code will compile to
int GenerateStaticVariableInitializers(io::Printer* printer) override;
void GenerateKotlinDsl(io::Printer* printer) const override;
void GenerateKotlinMembers(io::Printer* printer) const override;
void GenerateTopLevelKotlinMembers(io::Printer* printer) const override;
-
- private:
- void GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate);
-
- // Returns an estimate of the number of bytes the printed code will compile to
- int GenerateFieldAccessorTableInitializer(io::Printer* printer);
-
- void GenerateMessageSerializationMethods(io::Printer* printer);
- void GenerateParseFromMethods(io::Printer* printer);
- void GenerateSerializeOneField(io::Printer* printer,
- const FieldDescriptor* field);
- void GenerateSerializeOneExtensionRange(
- io::Printer* printer, const Descriptor::ExtensionRange* range);
-
- void GenerateBuilder(io::Printer* printer);
- void GenerateIsInitialized(io::Printer* printer);
- void GenerateDescriptorMethods(io::Printer* printer);
- void GenerateInitializers(io::Printer* printer);
- void GenerateEqualsAndHashCode(io::Printer* printer);
- void GenerateParser(io::Printer* printer);
- void GenerateParsingConstructor(io::Printer* printer);
+
+ private:
+ void GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate);
+
+ // Returns an estimate of the number of bytes the printed code will compile to
+ int GenerateFieldAccessorTableInitializer(io::Printer* printer);
+
+ void GenerateMessageSerializationMethods(io::Printer* printer);
+ void GenerateParseFromMethods(io::Printer* printer);
+ void GenerateSerializeOneField(io::Printer* printer,
+ const FieldDescriptor* field);
+ void GenerateSerializeOneExtensionRange(
+ io::Printer* printer, const Descriptor::ExtensionRange* range);
+
+ void GenerateBuilder(io::Printer* printer);
+ void GenerateIsInitialized(io::Printer* printer);
+ void GenerateDescriptorMethods(io::Printer* printer);
+ void GenerateInitializers(io::Printer* printer);
+ void GenerateEqualsAndHashCode(io::Printer* printer);
+ void GenerateParser(io::Printer* printer);
+ void GenerateParsingConstructor(io::Printer* printer);
void GenerateMutableCopy(io::Printer* printer);
void GenerateKotlinExtensions(io::Printer* printer) const;
- void GenerateAnyMethods(io::Printer* printer);
-
- Context* context_;
- ClassNameResolver* name_resolver_;
- FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ void GenerateAnyMethods(io::Printer* printer);
+
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+ FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
index 3fd517cde1..510b9d785c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -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: dweis@google.com (Daniel Weis)
-// 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: dweis@google.com (Daniel Weis)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_message_builder.h>
-
-#include <algorithm>
-#include <map>
-#include <memory>
-#include <vector>
-
+
+#include <algorithm>
+#include <map>
+#include <memory>
+#include <vector>
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -52,43 +52,43 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-namespace {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
ClassNameResolver* name_resolver) {
- const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
- return name_resolver->GetImmutableClassName(value_field->message_type());
-}
-} // namespace
-
+ const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
+ GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
+ return name_resolver->GetImmutableClassName(value_field->message_type());
+}
+} // namespace
+
MessageBuilderGenerator::MessageBuilderGenerator(const Descriptor* descriptor,
Context* context)
: descriptor_(descriptor),
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
- << "Generator factory error: A non-lite message generator is used to "
- "generate lite messages.";
+ GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ << "Generator factory error: A non-lite message generator is used to "
+ "generate lite messages.";
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
oneofs_.insert(descriptor_->field(i)->containing_oneof());
}
}
-}
-
-MessageBuilderGenerator::~MessageBuilderGenerator() {}
-
+}
+
+MessageBuilderGenerator::~MessageBuilderGenerator() {}
+
void MessageBuilderGenerator::Generate(io::Printer* printer) {
- WriteMessageDocComment(printer, descriptor_);
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+ WriteMessageDocComment(printer, descriptor_);
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"public static final class Builder extends\n"
" com.google.protobuf.GeneratedMessage$ver$.ExtendableBuilder<\n"
" $classname$, Builder> implements\n"
@@ -97,8 +97,8 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
"classname", name_resolver_->GetImmutableClassName(descriptor_),
"extra_interfaces", ExtraBuilderInterfaces(descriptor_), "ver",
GeneratedCodeVersionSuffix());
- } else {
- printer->Print(
+ } else {
+ printer->Print(
"public static final class Builder extends\n"
" com.google.protobuf.GeneratedMessage$ver$.Builder<Builder> "
"implements\n"
@@ -107,30 +107,30 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
"classname", name_resolver_->GetImmutableClassName(descriptor_),
"extra_interfaces", ExtraBuilderInterfaces(descriptor_), "ver",
GeneratedCodeVersionSuffix());
- }
- printer->Indent();
-
- GenerateDescriptorMethods(printer);
- GenerateCommonBuilderMethods(printer);
-
- if (context_->HasGeneratedMethods(descriptor_)) {
- GenerateIsInitialized(printer);
- GenerateBuilderParsingMethods(printer);
- }
-
- // oneof
+ }
+ printer->Indent();
+
+ GenerateDescriptorMethods(printer);
+ GenerateCommonBuilderMethods(printer);
+
+ if (context_->HasGeneratedMethods(descriptor_)) {
+ GenerateIsInitialized(printer);
+ GenerateBuilderParsingMethods(printer);
+ }
+
+ // oneof
std::map<TProtoStringType, TProtoStringType> vars;
for (auto oneof : oneofs_) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
vars["oneof_index"] = StrCat(oneof->index());
- // oneofCase_ and oneof_
- printer->Print(vars,
+ // oneofCase_ and oneof_
+ printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
"private java.lang.Object $oneof_name$_;\n");
- // oneofCase() and clearOneof()
- printer->Print(vars,
+ // oneofCase() and clearOneof()
+ printer->Print(vars,
"public $oneof_capitalized_name$Case\n"
" get$oneof_capitalized_name$Case() {\n"
" return $oneof_capitalized_name$Case.forNumber(\n"
@@ -140,31 +140,31 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
"public Builder clear$oneof_capitalized_name$() {\n"
" $oneof_name$Case_ = 0;\n"
" $oneof_name$_ = null;\n");
- printer->Print(" onChanged();\n");
- printer->Print(
+ printer->Print(" onChanged();\n");
+ printer->Print(
" return this;\n"
"}\n"
"\n");
- }
-
+ }
+
// Integers for bit fields.
int totalBits = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
totalBits +=
field_generators_.get(descriptor_->field(i)).GetNumBitsForBuilder();
- }
+ }
int totalInts = (totalBits + 31) / 32;
for (int i = 0; i < totalInts; i++) {
printer->Print("private int $bit_field_name$;\n", "bit_field_name",
GetBitFieldName(i));
}
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("\n");
- field_generators_.get(descriptor_->field(i))
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("\n");
+ field_generators_.get(descriptor_->field(i))
.GenerateBuilderMembers(printer);
- }
-
+ }
+
// Override methods declared in GeneratedMessage to return the concrete
// generated type so callsites won't depend on GeneratedMessage. This
// is needed to keep binary compatibility when we change generated code
@@ -183,21 +183,21 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
" return super.mergeUnknownFields(unknownFields);\n"
"}\n"
"\n");
-
- printer->Print(
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(builder_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
-// ===================================================================
-
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+// ===================================================================
+
void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
- if (!descriptor_->options().no_standard_descriptor_accessor()) {
- printer->Print(
+ if (!descriptor_->options().no_standard_descriptor_accessor()) {
+ printer->Print(
"public static final com.google.protobuf.Descriptors.Descriptor\n"
" getDescriptor() {\n"
" return $fileclass$.internal_$identifier$_descriptor;\n"
@@ -205,68 +205,68 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
"\n",
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
- }
+ }
std::vector<const FieldDescriptor*> map_fields;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- if (GetJavaType(field) == JAVATYPE_MESSAGE &&
- IsMapEntry(field->message_type())) {
- map_fields.push_back(field);
- }
- }
- if (!map_fields.empty()) {
- printer->Print(
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (GetJavaType(field) == JAVATYPE_MESSAGE &&
+ IsMapEntry(field->message_type())) {
+ map_fields.push_back(field);
+ }
+ }
+ if (!map_fields.empty()) {
+ printer->Print(
"@SuppressWarnings({\"rawtypes\"})\n"
"protected com.google.protobuf.MapField internalGetMapField(\n"
" int number) {\n"
" switch (number) {\n");
- printer->Indent();
- printer->Indent();
- for (int i = 0; i < map_fields.size(); ++i) {
- const FieldDescriptor* field = map_fields[i];
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- printer->Print(
+ printer->Indent();
+ printer->Indent();
+ for (int i = 0; i < map_fields.size(); ++i) {
+ const FieldDescriptor* field = map_fields[i];
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ printer->Print(
"case $number$:\n"
" return internalGet$capitalized_name$();\n",
"number", StrCat(field->number()), "capitalized_name",
info->capitalized_name);
- }
- printer->Print(
- "default:\n"
- " throw new RuntimeException(\n"
- " \"Invalid map field number: \" + number);\n");
- printer->Outdent();
- printer->Outdent();
- printer->Print(
- " }\n"
- "}\n");
- printer->Print(
+ }
+ printer->Print(
+ "default:\n"
+ " throw new RuntimeException(\n"
+ " \"Invalid map field number: \" + number);\n");
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
+ " }\n"
+ "}\n");
+ printer->Print(
"@SuppressWarnings({\"rawtypes\"})\n"
"protected com.google.protobuf.MapField internalGetMutableMapField(\n"
" int number) {\n"
" switch (number) {\n");
- printer->Indent();
- printer->Indent();
- for (int i = 0; i < map_fields.size(); ++i) {
- const FieldDescriptor* field = map_fields[i];
+ printer->Indent();
+ printer->Indent();
+ for (int i = 0; i < map_fields.size(); ++i) {
+ const FieldDescriptor* field = map_fields[i];
const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- printer->Print(
+ printer->Print(
"case $number$:\n"
" return internalGetMutable$capitalized_name$();\n",
"number", StrCat(field->number()), "capitalized_name",
info->capitalized_name);
- }
- printer->Print(
- "default:\n"
- " throw new RuntimeException(\n"
- " \"Invalid map field number: \" + number);\n");
- printer->Outdent();
- printer->Outdent();
- printer->Print(
- " }\n"
- "}\n");
- }
- printer->Print(
+ }
+ printer->Print(
+ "default:\n"
+ " throw new RuntimeException(\n"
+ " \"Invalid map field number: \" + number);\n");
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
+ " }\n"
+ "}\n");
+ }
+ printer->Print(
"@java.lang.Override\n"
"protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
" internalGetFieldAccessorTable() {\n"
@@ -279,21 +279,21 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
GeneratedCodeVersionSuffix());
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
void MessageBuilderGenerator::GenerateCommonBuilderMethods(
io::Printer* printer) {
- printer->Print(
- "// Construct using $classname$.newBuilder()\n"
- "private Builder() {\n"
- " maybeForceBuilderInitialization();\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
+ printer->Print(
+ "// Construct using $classname$.newBuilder()\n"
+ "private Builder() {\n"
+ " maybeForceBuilderInitialization();\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+
+ printer->Print(
"private Builder(\n"
" com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
" super(parent);\n"
@@ -301,57 +301,57 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
"}\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
GeneratedCodeVersionSuffix());
-
- printer->Print(
+
+ printer->Print(
"private void maybeForceBuilderInitialization() {\n"
" if (com.google.protobuf.GeneratedMessage$ver$\n"
" .alwaysUseFieldBuilders) {\n",
"ver", GeneratedCodeVersionSuffix());
-
- printer->Indent();
- printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); i++) {
+
+ printer->Indent();
+ printer->Indent();
+ for (int i = 0; i < descriptor_->field_count(); i++) {
if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateFieldBuilderInitializationCode(printer);
- }
- }
- printer->Outdent();
- printer->Outdent();
-
- printer->Print(
+ field_generators_.get(descriptor_->field(i))
+ .GenerateFieldBuilderInitializationCode(printer);
+ }
+ }
+ printer->Outdent();
+ printer->Outdent();
+
+ printer->Print(
" }\n"
"}\n");
-
- printer->Print(
+
+ printer->Print(
"@java.lang.Override\n"
"public Builder clear() {\n"
" super.clear();\n");
-
- printer->Indent();
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
+
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateBuilderClearCode(printer);
- }
- }
-
+ field_generators_.get(descriptor_->field(i))
+ .GenerateBuilderClearCode(printer);
+ }
+ }
+
for (auto oneof : oneofs_) {
- printer->Print(
+ printer->Print(
"$oneof_name$Case_ = 0;\n"
"$oneof_name$_ = null;\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
- }
-
- printer->Outdent();
-
- printer->Print(
+ }
+
+ printer->Outdent();
+
+ printer->Print(
" return this;\n"
"}\n"
"\n");
-
- printer->Print(
+
+ printer->Print(
"@java.lang.Override\n"
"public com.google.protobuf.Descriptors.Descriptor\n"
" getDescriptorForType() {\n"
@@ -360,17 +360,17 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
"\n",
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
-
- // LITE runtime implements this in GeneratedMessageLite.
- printer->Print(
+
+ // LITE runtime implements this in GeneratedMessageLite.
+ printer->Print(
"@java.lang.Override\n"
"public $classname$ getDefaultInstanceForType() {\n"
" return $classname$.getDefaultInstance();\n"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
+
+ printer->Print(
"@java.lang.Override\n"
"public $classname$ build() {\n"
" $classname$ result = buildPartial();\n"
@@ -381,26 +381,26 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
+
+ printer->Print(
"@java.lang.Override\n"
"public $classname$ buildPartial() {\n"
" $classname$ result = new $classname$(this);\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Indent();
-
- int totalBuilderBits = 0;
- int totalMessageBits = 0;
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const ImmutableFieldGenerator& field =
- field_generators_.get(descriptor_->field(i));
- totalBuilderBits += field.GetNumBitsForBuilder();
- totalMessageBits += field.GetNumBitsForMessage();
- }
- int totalBuilderInts = (totalBuilderBits + 31) / 32;
- int totalMessageInts = (totalMessageBits + 31) / 32;
-
+
+ printer->Indent();
+
+ int totalBuilderBits = 0;
+ int totalMessageBits = 0;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const ImmutableFieldGenerator& field =
+ field_generators_.get(descriptor_->field(i));
+ totalBuilderBits += field.GetNumBitsForBuilder();
+ totalMessageBits += field.GetNumBitsForMessage();
+ }
+ int totalBuilderInts = (totalBuilderBits + 31) / 32;
+ int totalMessageInts = (totalMessageBits + 31) / 32;
+
// Local vars for from and to bit fields to avoid accessing the builder and
// message over and over for these fields. Seems to provide a slight
// perforamance improvement in micro benchmark and this is also what proto1
@@ -408,44 +408,44 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
for (int i = 0; i < totalBuilderInts; i++) {
printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n",
"bit_field_name", GetBitFieldName(i));
- }
+ }
for (int i = 0; i < totalMessageInts; i++) {
printer->Print("int to_$bit_field_name$ = 0;\n", "bit_field_name",
GetBitFieldName(i));
}
-
- // Output generation code for each field.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- field_generators_.get(descriptor_->field(i)).GenerateBuildingCode(printer);
- }
-
+
+ // Output generation code for each field.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ field_generators_.get(descriptor_->field(i)).GenerateBuildingCode(printer);
+ }
+
// Copy the bit field results to the generated message
for (int i = 0; i < totalMessageInts; i++) {
printer->Print("result.$bit_field_name$ = to_$bit_field_name$;\n",
"bit_field_name", GetBitFieldName(i));
- }
-
+ }
+
for (auto oneof : oneofs_) {
- printer->Print("result.$oneof_name$Case_ = $oneof_name$Case_;\n",
+ printer->Print("result.$oneof_name$Case_ = $oneof_name$Case_;\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
- }
-
- printer->Outdent();
-
+ }
+
+ printer->Outdent();
+
printer->Print(" onBuilt();\n");
-
- printer->Print(
+
+ printer->Print(
" return result;\n"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
+
// Override methods declared in GeneratedMessage to return the concrete
// generated type so callsites won't depend on GeneratedMessage. This
// is needed to keep binary compatibility when we change generated code
// to subclass a different GeneratedMessage class (e.g., in v3.0.0 release
// we changed all generated code to subclass GeneratedMessageV3).
- printer->Print(
+ printer->Print(
"@java.lang.Override\n"
"public Builder clone() {\n"
" return super.clone();\n"
@@ -478,9 +478,9 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
" java.lang.Object value) {\n"
" return super.addRepeatedField(field, value);\n"
"}\n");
-
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"@java.lang.Override\n"
"public <Type> Builder setExtension(\n"
" com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
@@ -509,12 +509,12 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
" return super.clearExtension(extension);\n"
"}\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- }
-
- // -----------------------------------------------------------------
-
- if (context_->HasGeneratedMethods(descriptor_)) {
- printer->Print(
+ }
+
+ // -----------------------------------------------------------------
+
+ if (context_->HasGeneratedMethods(descriptor_)) {
+ printer->Print(
"@java.lang.Override\n"
"public Builder mergeFrom(com.google.protobuf.Message other) {\n"
" if (other instanceof $classname$) {\n"
@@ -526,71 +526,71 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
+
+ printer->Print(
"public Builder mergeFrom($classname$ other) {\n"
// Optimization: If other is the default instance, we know none of its
// fields are set so we can skip the merge.
" if (other == $classname$.getDefaultInstance()) return this;\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- printer->Indent();
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
if (!IsRealOneof(descriptor_->field(i))) {
field_generators_.get(descriptor_->field(i))
.GenerateMergingCode(printer);
- }
- }
-
- // Merge oneof fields.
+ }
+ }
+
+ // Merge oneof fields.
for (auto oneof : oneofs_) {
printer->Print("switch (other.get$oneof_capitalized_name$Case()) {\n",
"oneof_capitalized_name",
context_->GetOneofGeneratorInfo(oneof)->capitalized_name);
- printer->Indent();
+ printer->Indent();
for (int j = 0; j < oneof->field_count(); j++) {
const FieldDescriptor* field = oneof->field(j);
printer->Print("case $field_name$: {\n", "field_name",
ToUpper(field->name()));
- printer->Indent();
- field_generators_.get(field).GenerateMergingCode(printer);
+ printer->Indent();
+ field_generators_.get(field).GenerateMergingCode(printer);
printer->Print("break;\n");
- printer->Outdent();
+ printer->Outdent();
printer->Print("}\n");
- }
- printer->Print(
+ }
+ printer->Print(
"case $cap_oneof_name$_NOT_SET: {\n"
" break;\n"
"}\n",
"cap_oneof_name",
ToUpper(context_->GetOneofGeneratorInfo(oneof)->name));
- printer->Outdent();
+ printer->Outdent();
printer->Print("}\n");
- }
-
- printer->Outdent();
-
- // if message type has extensions
- if (descriptor_->extension_range_count() > 0) {
+ }
+
+ printer->Outdent();
+
+ // if message type has extensions
+ if (descriptor_->extension_range_count() > 0) {
printer->Print(" this.mergeExtensionFields(other);\n");
- }
-
+ }
+
printer->Print(" this.mergeUnknownFields(other.unknownFields);\n");
-
+
printer->Print(" onChanged();\n");
-
- printer->Print(
+
+ printer->Print(
" return this;\n"
"}\n"
"\n");
- }
-}
-
-// ===================================================================
-
+ }
+}
+
+// ===================================================================
+
void MessageBuilderGenerator::GenerateBuilderParsingMethods(
io::Printer* printer) {
- printer->Print(
+ printer->Print(
"@java.lang.Override\n"
"public Builder mergeFrom(\n"
" com.google.protobuf.CodedInputStream input,\n"
@@ -610,60 +610,60 @@ void MessageBuilderGenerator::GenerateBuilderParsingMethods(
" return this;\n"
"}\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
- printer->Print(
+ printer->Print(
"@java.lang.Override\n"
"public final boolean isInitialized() {\n");
- printer->Indent();
-
- // Check that all required fields in this message are set.
- // TODO(kenton): We can optimize this when we switch to putting all the
- // "has" fields into a single bitfield.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
-
- if (field->is_required()) {
- printer->Print(
+ printer->Indent();
+
+ // Check that all required fields in this message are set.
+ // TODO(kenton): We can optimize this when we switch to putting all the
+ // "has" fields into a single bitfield.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+
+ if (field->is_required()) {
+ printer->Print(
"if (!has$name$()) {\n"
" return false;\n"
"}\n",
"name", info->capitalized_name);
- }
- }
-
- // Now check that all embedded messages are initialized.
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = descriptor_->field(i);
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
- if (GetJavaType(field) == JAVATYPE_MESSAGE &&
- HasRequiredFields(field->message_type())) {
- switch (field->label()) {
- case FieldDescriptor::LABEL_REQUIRED:
- printer->Print(
+ }
+ }
+
+ // Now check that all embedded messages are initialized.
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ if (GetJavaType(field) == JAVATYPE_MESSAGE &&
+ HasRequiredFields(field->message_type())) {
+ switch (field->label()) {
+ case FieldDescriptor::LABEL_REQUIRED:
+ printer->Print(
"if (!get$name$().isInitialized()) {\n"
" return false;\n"
"}\n",
"type",
name_resolver_->GetImmutableClassName(field->message_type()),
"name", info->capitalized_name);
- break;
- case FieldDescriptor::LABEL_OPTIONAL:
+ break;
+ case FieldDescriptor::LABEL_OPTIONAL:
printer->Print(
"if (has$name$()) {\n"
" if (!get$name$().isInitialized()) {\n"
" return false;\n"
" }\n"
"}\n",
- "name", info->capitalized_name);
- break;
- case FieldDescriptor::LABEL_REPEATED:
- if (IsMapEntry(field->message_type())) {
- printer->Print(
+ "name", info->capitalized_name);
+ break;
+ case FieldDescriptor::LABEL_REPEATED:
+ if (IsMapEntry(field->message_type())) {
+ printer->Print(
"for ($type$ item : get$name$Map().values()) {\n"
" if (!item.isInitialized()) {\n"
" return false;\n"
@@ -673,8 +673,8 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
MapValueImmutableClassdName(field->message_type(),
name_resolver_),
"name", info->capitalized_name);
- } else {
- printer->Print(
+ } else {
+ printer->Print(
"for (int i = 0; i < get$name$Count(); i++) {\n"
" if (!get$name$(i).isInitialized()) {\n"
" return false;\n"
@@ -683,30 +683,30 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
"type",
name_resolver_->GetImmutableClassName(field->message_type()),
"name", info->capitalized_name);
- }
- break;
- }
- }
- }
-
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+ }
+ break;
+ }
+ }
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"if (!extensionsAreInitialized()) {\n"
" return false;\n"
"}\n");
- }
-
- printer->Outdent();
-
- printer->Print(
+ }
+
+ printer->Outdent();
+
+ printer->Print(
" return true;\n"
"}\n"
"\n");
-}
-
-// ===================================================================
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+// ===================================================================
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
index fc3acc2e13..fcd73b3436 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h
@@ -1,46 +1,46 @@
-// 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: dweis@google.com (Daniel Weis)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_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: dweis@google.com (Daniel Weis)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
+
#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,41 +49,41 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class MessageBuilderGenerator {
- public:
- explicit MessageBuilderGenerator(const Descriptor* descriptor,
- Context* context);
- virtual ~MessageBuilderGenerator();
-
- virtual void Generate(io::Printer* printer);
-
- private:
- void GenerateCommonBuilderMethods(io::Printer* printer);
- void GenerateDescriptorMethods(io::Printer* printer);
- void GenerateBuilderParsingMethods(io::Printer* printer);
- void GenerateIsInitialized(io::Printer* printer);
-
- const Descriptor* descriptor_;
- Context* context_;
- ClassNameResolver* name_resolver_;
- FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class MessageBuilderGenerator {
+ public:
+ explicit MessageBuilderGenerator(const Descriptor* descriptor,
+ Context* context);
+ virtual ~MessageBuilderGenerator();
+
+ virtual void Generate(io::Printer* printer);
+
+ private:
+ void GenerateCommonBuilderMethods(io::Printer* printer);
+ void GenerateDescriptorMethods(io::Printer* printer);
+ void GenerateBuilderParsingMethods(io::Printer* printer);
+ void GenerateIsInitialized(io::Printer* printer);
+
+ const Descriptor* descriptor_;
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+ FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
std::set<const OneofDescriptor*> oneofs_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
index 185870fa6e..bff99b7b1a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc
@@ -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: dweis@google.com (Daniel Weis)
-// 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: dweis@google.com (Daniel Weis)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_message_builder_lite.h>
-
-#include <algorithm>
-#include <map>
-#include <memory>
-#include <vector>
-
+
+#include <algorithm>
+#include <map>
+#include <memory>
+#include <vector>
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum.h>
@@ -52,33 +52,33 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-MessageBuilderLiteGenerator::MessageBuilderLiteGenerator(
- const Descriptor* descriptor, Context* context)
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+MessageBuilderLiteGenerator::MessageBuilderLiteGenerator(
+ const Descriptor* descriptor, Context* context)
: descriptor_(descriptor),
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
- << "Generator factory error: A lite message generator is used to "
- "generate non-lite messages.";
+ GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ << "Generator factory error: A lite message generator is used to "
+ "generate non-lite messages.";
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
oneofs_.insert(descriptor_->field(i)->containing_oneof());
}
}
-}
-
-MessageBuilderLiteGenerator::~MessageBuilderLiteGenerator() {}
-
+}
+
+MessageBuilderLiteGenerator::~MessageBuilderLiteGenerator() {}
+
void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
- WriteMessageDocComment(printer, descriptor_);
- printer->Print(
+ WriteMessageDocComment(printer, descriptor_);
+ printer->Print(
"public static final class Builder extends\n"
" com.google.protobuf.GeneratedMessageLite.$extendible$Builder<\n"
" $classname$, Builder> implements\n"
@@ -87,20 +87,20 @@ void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
"classname", name_resolver_->GetImmutableClassName(descriptor_),
"extra_interfaces", ExtraBuilderInterfaces(descriptor_), "extendible",
descriptor_->extension_range_count() > 0 ? "Extendable" : "");
- printer->Indent();
-
- GenerateCommonBuilderMethods(printer);
-
- // oneof
+ printer->Indent();
+
+ GenerateCommonBuilderMethods(printer);
+
+ // oneof
std::map<TProtoStringType, TProtoStringType> vars;
for (auto oneof : oneofs_) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
vars["oneof_index"] = StrCat(oneof->index());
-
- // oneofCase() and clearOneof()
- printer->Print(vars,
+
+ // oneofCase() and clearOneof()
+ printer->Print(vars,
"@java.lang.Override\n"
"public $oneof_capitalized_name$Case\n"
" get$oneof_capitalized_name$Case() {\n"
@@ -113,39 +113,39 @@ void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
" return this;\n"
"}\n"
"\n");
- }
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("\n");
- field_generators_.get(descriptor_->field(i))
+ }
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("\n");
+ field_generators_.get(descriptor_->field(i))
.GenerateBuilderMembers(printer);
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(builder_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
-// ===================================================================
-
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+// ===================================================================
+
void MessageBuilderLiteGenerator::GenerateCommonBuilderMethods(
io::Printer* printer) {
- printer->Print(
+ printer->Print(
"// Construct using $classname$.newBuilder()\n"
"private Builder() {\n"
" super(DEFAULT_INSTANCE);\n"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-}
-
-// ===================================================================
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+// ===================================================================
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
index b0100e0bde..3402adf332 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h
@@ -1,46 +1,46 @@
-// 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: dweis@google.com (Daniel Weis)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_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: dweis@google.com (Daniel Weis)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
+
#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,38 +49,38 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class MessageBuilderLiteGenerator {
- public:
- explicit MessageBuilderLiteGenerator(const Descriptor* descriptor,
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class MessageBuilderLiteGenerator {
+ public:
+ explicit MessageBuilderLiteGenerator(const Descriptor* descriptor,
Context* context);
- virtual ~MessageBuilderLiteGenerator();
-
- virtual void Generate(io::Printer* printer);
-
- private:
- void GenerateCommonBuilderMethods(io::Printer* printer);
-
- const Descriptor* descriptor_;
- Context* context_;
- ClassNameResolver* name_resolver_;
- FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
+ virtual ~MessageBuilderLiteGenerator();
+
+ virtual void Generate(io::Printer* printer);
+
+ private:
+ void GenerateCommonBuilderMethods(io::Printer* printer);
+
+ const Descriptor* descriptor_;
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+ FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
std::set<const OneofDescriptor*> oneofs_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
index 4e962b2dc2..6e2f181387 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc
@@ -1,40 +1,40 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
@@ -43,31 +43,31 @@
#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 java {
-
-
-namespace {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+
+namespace {
+
void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- (*variables)["type"] =
- name_resolver->GetImmutableClassName(descriptor->message_type());
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ (*variables)["type"] =
+ name_resolver->GetImmutableClassName(descriptor->message_type());
(*variables)["kt_type"] = (*variables)["type"];
- (*variables)["mutable_type"] =
- name_resolver->GetMutableClassName(descriptor->message_type());
- (*variables)["group_or_message"] =
+ (*variables)["mutable_type"] =
+ name_resolver->GetMutableClassName(descriptor->message_type());
+ (*variables)["group_or_message"] =
(GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? "Group"
: "Message";
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -75,57 +75,57 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
- (*variables)["on_changed"] = "onChanged();";
- (*variables)["ver"] = GeneratedCodeVersionSuffix();
- (*variables)["get_parser"] =
+ (*variables)["on_changed"] = "onChanged();";
+ (*variables)["ver"] = GeneratedCodeVersionSuffix();
+ (*variables)["get_parser"] =
ExposePublicParser(descriptor->message_type()->file()) ? "PARSER"
: "parser()";
-
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != null";
- }
-
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["set_has_field_bit_builder"] =
+ GenerateSetBit(builderBitIndex) + ";";
+ (*variables)["clear_has_field_bit_builder"] =
+ GenerateClearBit(builderBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["set_has_field_bit_builder"] = "";
+ (*variables)["clear_has_field_bit_builder"] = "";
+
+ (*variables)["is_field_present_message"] =
+ (*variables)["name"] + "_ != null";
+ }
+
// For repeated builders, one bit is used for whether the array is immutable.
- (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
- (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
- (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
-
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-}
-
-} // namespace
-
-// ===================================================================
-
+ (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
+ (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
+
+ // For repeated fields, one bit is used for whether the array is immutable
+ // in the parsing constructor.
+ (*variables)["get_mutable_bit_parser"] =
+ GenerateGetBitMutableLocal(builderBitIndex);
+ (*variables)["set_mutable_bit_parser"] =
+ GenerateSetBitMutableLocal(builderBitIndex);
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
@@ -133,40 +133,40 @@ ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator(
SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
context->GetFieldGeneratorInfo(descriptor),
name_resolver_, &variables_);
-}
-
-ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {}
-
-int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
+}
+
+ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {}
+
+int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
-int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
+}
+
+int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
return GetNumBitsForMessage();
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
- // TODO(jonp): In the future, consider having a method specific to the
- // interface so that builders can choose dynamically to either return a
- // message or a nested builder, so that asking for the interface doesn't
- // cause a message to ever be built.
+ // TODO(jonp): In the future, consider having a method specific to the
+ // interface so that builders can choose dynamically to either return a
+ // message or a nested builder, so that asking for the interface doesn't
+ // cause a message to ever be built.
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n");
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
-
- WriteFieldDocComment(printer, descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder();\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private $type$ $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
-
+ PrintExtraFieldInfo(variables_, printer);
+
if (HasHasbit(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -184,8 +184,8 @@ void ImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -194,7 +194,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- } else {
+ } else {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
variables_,
@@ -211,69 +211,69 @@ void ImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$OrBuilder "
"${$get$capitalized_name$OrBuilder$}$() {\n"
" return get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-}
-
-void ImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
+ }
+}
+
+void ImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
io::Printer* printer, const char* regular_case,
- const char* nested_builder_case) const {
- printer->Print(variables_, "if ($name$Builder_ == null) {\n");
- printer->Indent();
- printer->Print(variables_, regular_case);
- printer->Outdent();
- printer->Print("} else {\n");
- printer->Indent();
- printer->Print(variables_, nested_builder_case);
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
+ const char* nested_builder_case) const {
+ printer->Print(variables_, "if ($name$Builder_ == null) {\n");
+ printer->Indent();
+ printer->Print(variables_, regular_case);
+ printer->Outdent();
+ printer->Print("} else {\n");
+ printer->Indent();
+ printer->Print(variables_, nested_builder_case);
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
io::Printer* printer, const char* method_prototype,
const char* regular_case, const char* nested_builder_case,
- const char* trailing_code) const {
- printer->Print(variables_, method_prototype);
+ const char* trailing_code) const {
+ printer->Print(variables_, method_prototype);
printer->Annotate("{", "}", descriptor_);
- printer->Print(" {\n");
- printer->Indent();
- PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);
- if (trailing_code != NULL) {
- printer->Print(variables_, trailing_code);
- }
- printer->Outdent();
- printer->Print("}\n");
-}
-
+ printer->Print(" {\n");
+ printer->Indent();
+ PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);
+ if (trailing_code != NULL) {
+ printer->Print(variables_, trailing_code);
+ }
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // When using nested-builders, the code initially works just like the
- // non-nested builder case. It only creates a nested builder lazily on
- // demand and then forever delegates to it after creation.
-
+ // When using nested-builders, the code initially works just like the
+ // non-nested builder case. It only creates a nested builder lazily on
+ // demand and then forever delegates to it after creation.
+
bool has_hasbit = HasHasbit(descriptor_);
-
+
printer->Print(variables_, "private $type$ $name$_;\n");
-
- printer->Print(variables_,
+
+ printer->Print(variables_,
// If this builder is non-null, it is used and the other fields
// are ignored.
"private com.google.protobuf.SingleFieldBuilder$ver$<\n"
" $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;"
"\n");
-
- // The comments above the methods below are based on a hypothetical
- // field of type "Field" called "Field".
-
- // boolean hasField()
+
+ // The comments above the methods below are based on a hypothetical
+ // field of type "Field" called "Field".
+
+ // boolean hasField()
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
if (has_hasbit) {
printer->Print(
@@ -282,60 +282,60 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" return $get_has_field_bit_builder$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- } else {
+ } else {
printer->Print(
variables_,
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $name$Builder_ != null || $name$_ != null;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
- // Field getField()
+ }
+
+ // Field getField()
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
PrintNestedBuilderFunction(
printer, "$deprecation$public $type$ ${$get$capitalized_name$$}$()",
"return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n",
"return $name$Builder_.getMessage();\n", NULL);
-
- // Field.Builder setField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder setField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value)",
-
+
"if (value == null) {\n"
" throw new NullPointerException();\n"
"}\n"
"$name$_ = value;\n"
"$on_changed$\n",
-
+
"$name$Builder_.setMessage(value);\n",
-
+
"$set_has_field_bit_builder$\n"
"return this;\n");
-
- // Field.Builder setField(Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder setField(Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" $type$.Builder builderForValue)",
-
+
"$name$_ = builderForValue.build();\n"
"$on_changed$\n",
-
+
"$name$Builder_.setMessage(builderForValue.build());\n",
-
+
"$set_has_field_bit_builder$\n"
"return this;\n");
-
- // Field.Builder mergeField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder mergeField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)",
-
+
has_hasbit
? "if ($get_has_field_bit_builder$ &&\n"
" $name$_ != null &&\n"
@@ -353,29 +353,29 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" $name$_ = value;\n"
"}\n"
"$on_changed$\n",
-
+
"$name$Builder_.mergeFrom(value);\n",
-
+
"$set_has_field_bit_builder$\n"
"return this;\n");
-
- // Field.Builder clearField()
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder clearField()
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
-
+
"$name$_ = null;\n"
"$on_changed$\n",
-
+
has_hasbit ? "$name$Builder_.clear();\n"
: "$name$_ = null;\n"
"$name$Builder_ = null;\n",
-
+
"$clear_has_field_bit_builder$\n"
"return this;\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public $type$.Builder "
"${$get$capitalized_name$Builder$}$() {\n"
" $set_has_field_bit_builder$\n"
@@ -383,8 +383,8 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" return get$capitalized_name$FieldBuilder().getBuilder();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public $type$OrBuilder "
"${$get$capitalized_name$OrBuilder$}$() {\n"
" if ($name$Builder_ != null) {\n"
@@ -395,7 +395,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"private com.google.protobuf.SingleFieldBuilder$ver$<\n"
@@ -411,8 +411,8 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
" return $name$Builder_;\n"
"}\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -443,35 +443,35 @@ void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode(
io::Printer* printer) const {
if (HasHasbit(descriptor_)) {
printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
- }
-}
-
+ }
+}
+
void ImmutableMessageFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {}
-
+
void ImmutableMessageFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
if (HasHasbit(descriptor_)) {
PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
-
+
"$name$Builder_.clear();\n");
- printer->Print(variables_, "$clear_has_field_bit_builder$\n");
- } else {
+ printer->Print(variables_, "$clear_has_field_bit_builder$\n");
+ } else {
PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
-
+
"$name$_ = null;\n"
"$name$Builder_ = null;\n");
- }
-}
-
+ }
+}
+
void ImmutableMessageFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (other.has$capitalized_name$()) {\n"
" merge$capitalized_name$(other.get$capitalized_name$());\n"
"}\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
if (HasHasbit(descriptor_)) {
@@ -480,46 +480,46 @@ void ImmutableMessageFieldGenerator::GenerateBuildingCode(
PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
"result.$name$_ = $name$Builder_.build();\n");
printer->Outdent();
- printer->Print(variables_,
+ printer->Print(variables_,
" $set_has_field_bit_to_local$;\n"
"}\n");
} else {
PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
"result.$name$_ = $name$Builder_.build();\n");
- }
-}
-
+ }
+}
+
void ImmutableMessageFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$type$.Builder subBuilder = null;\n"
"if ($is_field_present_message$) {\n"
" subBuilder = $name$_.toBuilder();\n"
"}\n");
-
- if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
- printer->Print(variables_,
+
+ if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
+ printer->Print(variables_,
"$name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
" extensionRegistry);\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"$name$_ = input.readMessage($type$.$get_parser$, "
"extensionRegistry);\n");
- }
-
- printer->Print(variables_,
+ }
+
+ printer->Print(variables_,
"if (subBuilder != null) {\n"
" subBuilder.mergeFrom($name$_);\n"
" $name$_ = subBuilder.buildPartial();\n"
"}\n"
"$set_has_field_bit_message$\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- // noop for messages.
-}
-
+ // noop for messages.
+}
+
void ImmutableMessageFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(
@@ -527,8 +527,8 @@ void ImmutableMessageFieldGenerator::GenerateSerializationCode(
"if ($is_field_present_message$) {\n"
" output.write$group_or_message$($number$, get$capitalized_name$());\n"
"}\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
printer->Print(
@@ -537,45 +537,45 @@ void ImmutableMessageFieldGenerator::GenerateSerializedSizeCode(
" size += com.google.protobuf.CodedOutputStream\n"
" .compute$group_or_message$Size($number$, get$capitalized_name$());\n"
"}\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (!get$capitalized_name$()\n"
" .equals(other.get$capitalized_name$())) return false;\n");
-}
-
+}
+
void ImmutableMessageFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"hash = (37 * hash) + $constant_name$;\n"
"hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
-}
-
+}
+
TProtoStringType ImmutableMessageFieldGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->message_type());
-}
-
-// ===================================================================
-
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
+}
+
+// ===================================================================
+
ImmutableMessageOneofFieldGenerator::ImmutableMessageOneofFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: ImmutableMessageFieldGenerator(descriptor, messageBitIndex,
builderBitIndex, context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
ImmutableMessageOneofFieldGenerator::~ImmutableMessageOneofFieldGenerator() {}
-
+
void ImmutableMessageOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $has_oneof_case_message$;\n"
@@ -591,9 +591,9 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers(
" return $type$.getDefaultInstance();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$OrBuilder "
"${$get$capitalized_name$OrBuilder$}$() {\n"
@@ -603,23 +603,23 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers(
" return $type$.getDefaultInstance();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // When using nested-builders, the code initially works just like the
- // non-nested builder case. It only creates a nested builder lazily on
- // demand and then forever delegates to it after creation.
- printer->Print(variables_,
+ // When using nested-builders, the code initially works just like the
+ // non-nested builder case. It only creates a nested builder lazily on
+ // demand and then forever delegates to it after creation.
+ printer->Print(variables_,
// If this builder is non-null, it is used and the other fields
// are ignored.
"private com.google.protobuf.SingleFieldBuilder$ver$<\n"
" $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;"
"\n");
-
- // The comments above the methods below are based on a hypothetical
- // field of type "Field" called "Field".
-
+
+ // The comments above the methods below are based on a hypothetical
+ // field of type "Field" called "Field".
+
// boolean hasField()
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
@@ -628,64 +628,64 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field getField()
+
+ // Field getField()
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
PrintNestedBuilderFunction(
printer,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$()",
-
+
"if ($has_oneof_case_message$) {\n"
" return ($type$) $oneof_name$_;\n"
"}\n"
"return $type$.getDefaultInstance();\n",
-
+
"if ($has_oneof_case_message$) {\n"
" return $name$Builder_.getMessage();\n"
"}\n"
"return $type$.getDefaultInstance();\n",
-
+
NULL);
-
- // Field.Builder setField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder setField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value)",
-
+
"if (value == null) {\n"
" throw new NullPointerException();\n"
"}\n"
"$oneof_name$_ = value;\n"
"$on_changed$\n",
-
+
"$name$Builder_.setMessage(value);\n",
-
+
"$set_oneof_case_message$;\n"
"return this;\n");
-
- // Field.Builder setField(Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder setField(Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" $type$.Builder builderForValue)",
-
+
"$oneof_name$_ = builderForValue.build();\n"
"$on_changed$\n",
-
+
"$name$Builder_.setMessage(builderForValue.build());\n",
-
+
"$set_oneof_case_message$;\n"
"return this;\n");
-
- // Field.Builder mergeField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder mergeField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)",
-
+
"if ($has_oneof_case_message$ &&\n"
" $oneof_name$_ != $type$.getDefaultInstance()) {\n"
" $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_)\n"
@@ -694,42 +694,42 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
" $oneof_name$_ = value;\n"
"}\n"
"$on_changed$\n",
-
+
"if ($has_oneof_case_message$) {\n"
" $name$Builder_.mergeFrom(value);\n"
"}\n"
"$name$Builder_.setMessage(value);\n",
-
+
"$set_oneof_case_message$;\n"
"return this;\n");
-
- // Field.Builder clearField()
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder clearField()
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
-
+
"if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
" $oneof_name$_ = null;\n"
" $on_changed$\n"
"}\n",
-
+
"if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
" $oneof_name$_ = null;\n"
"}\n"
"$name$Builder_.clear();\n",
-
+
"return this;\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public $type$.Builder "
"${$get$capitalized_name$Builder$}$() {\n"
" return get$capitalized_name$FieldBuilder().getBuilder();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -745,7 +745,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"private com.google.protobuf.SingleFieldBuilder$ver$<\n"
@@ -767,56 +767,56 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
" return $name$Builder_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
printer->Print(variables_, "if ($has_oneof_case_message$) {\n");
- printer->Indent();
-
+ printer->Indent();
+
PrintNestedBuilderCondition(
printer, "result.$oneof_name$_ = $oneof_name$_;\n",
-
+
"result.$oneof_name$_ = $name$Builder_.build();\n");
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void ImmutableMessageOneofFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"merge$capitalized_name$(other.get$capitalized_name$());\n");
-}
-
+}
+
void ImmutableMessageOneofFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$type$.Builder subBuilder = null;\n"
"if ($has_oneof_case_message$) {\n"
" subBuilder = (($type$) $oneof_name$_).toBuilder();\n"
"}\n");
-
- if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
+
+ if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
printer->Print(
variables_,
"$oneof_name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
" extensionRegistry);\n");
- } else {
+ } else {
printer->Print(
variables_,
"$oneof_name$_ =\n"
" input.readMessage($type$.$get_parser$, extensionRegistry);\n");
- }
-
- printer->Print(variables_,
+ }
+
+ printer->Print(variables_,
"if (subBuilder != null) {\n"
" subBuilder.mergeFrom(($type$) $oneof_name$_);\n"
" $oneof_name$_ = subBuilder.buildPartial();\n"
"}\n");
printer->Print(variables_, "$set_oneof_case_message$;\n");
-}
-
+}
+
void ImmutableMessageOneofFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
printer->Print(
@@ -824,8 +824,8 @@ void ImmutableMessageOneofFieldGenerator::GenerateSerializationCode(
"if ($has_oneof_case_message$) {\n"
" output.write$group_or_message$($number$, ($type$) $oneof_name$_);\n"
"}\n");
-}
-
+}
+
void ImmutableMessageOneofFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
printer->Print(
@@ -834,71 +834,71 @@ void ImmutableMessageOneofFieldGenerator::GenerateSerializedSizeCode(
" size += com.google.protobuf.CodedOutputStream\n"
" .compute$group_or_message$Size($number$, ($type$) $oneof_name$_);\n"
"}\n");
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
RepeatedImmutableMessageFieldGenerator::RepeatedImmutableMessageFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-RepeatedImmutableMessageFieldGenerator::
+ SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+RepeatedImmutableMessageFieldGenerator::
~RepeatedImmutableMessageFieldGenerator() {}
-
-int RepeatedImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
-int RepeatedImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
- return 1;
-}
-
+
+int RepeatedImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
+int RepeatedImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
+ return 1;
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
- // TODO(jonp): In the future, consider having methods specific to the
- // interface so that builders can choose dynamically to either return a
- // message or a nested builder, so that asking for the interface doesn't
- // cause a message to ever be built.
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ // TODO(jonp): In the future, consider having methods specific to the
+ // interface so that builders can choose dynamically to either return a
+ // message or a nested builder, so that asking for the interface doesn't
+ // cause a message to ever be built.
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$java.util.List<$type$> \n"
" get$capitalized_name$List();\n");
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$$type$ get$capitalized_name$(int index);\n");
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$java.util.List<? extends $type$OrBuilder> \n"
" get$capitalized_name$OrBuilderList();\n");
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder(\n"
" int index);\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private java.util.List<$type$> $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ PrintExtraFieldInfo(variables_, printer);
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$type$> "
"${$get$capitalized_name$List$}$() {\n"
" return $name$_;\n" // note: unmodifiable list
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -907,7 +907,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -915,7 +915,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_.size();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -923,8 +923,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_.get(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$OrBuilder "
"${$get$capitalized_name$OrBuilder$}$(\n"
@@ -932,44 +932,44 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers(
" return $name$_.get(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
-void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
+}
+
+void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
io::Printer* printer, const char* regular_case,
- const char* nested_builder_case) const {
- printer->Print(variables_, "if ($name$Builder_ == null) {\n");
- printer->Indent();
- printer->Print(variables_, regular_case);
- printer->Outdent();
- printer->Print("} else {\n");
- printer->Indent();
- printer->Print(variables_, nested_builder_case);
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
+ const char* nested_builder_case) const {
+ printer->Print(variables_, "if ($name$Builder_ == null) {\n");
+ printer->Indent();
+ printer->Print(variables_, regular_case);
+ printer->Outdent();
+ printer->Print("} else {\n");
+ printer->Indent();
+ printer->Print(variables_, nested_builder_case);
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
io::Printer* printer, const char* method_prototype,
const char* regular_case, const char* nested_builder_case,
- const char* trailing_code) const {
- printer->Print(variables_, method_prototype);
+ const char* trailing_code) const {
+ printer->Print(variables_, method_prototype);
printer->Annotate("{", "}", descriptor_);
- printer->Print(" {\n");
- printer->Indent();
- PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);
- if (trailing_code != NULL) {
- printer->Print(variables_, trailing_code);
- }
- printer->Outdent();
- printer->Print("}\n");
-}
-
+ printer->Print(" {\n");
+ printer->Indent();
+ PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);
+ if (trailing_code != NULL) {
+ printer->Print(variables_, trailing_code);
+ }
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // When using nested-builders, the code initially works just like the
- // non-nested builder case. It only creates a nested builder lazily on
- // demand and then forever delegates to it after creation.
-
+ // When using nested-builders, the code initially works just like the
+ // non-nested builder case. It only creates a nested builder lazily on
+ // demand and then forever delegates to it after creation.
+
printer->Print(
variables_,
// Used when the builder is null.
@@ -984,7 +984,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
// list can never be modified.
"private java.util.List<$type$> $name$_ =\n"
" java.util.Collections.emptyList();\n"
-
+
"private void ensure$capitalized_name$IsMutable() {\n"
" if (!$get_mutable_bit_builder$) {\n"
" $name$_ = new java.util.ArrayList<$type$>($name$_);\n"
@@ -992,7 +992,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n"
"\n");
-
+
printer->Print(
variables_,
// If this builder is non-null, it is used and the other fields are
@@ -1000,45 +1000,45 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"private com.google.protobuf.RepeatedFieldBuilder$ver$<\n"
" $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\n"
"\n");
-
- // The comments above the methods below are based on a hypothetical
- // repeated field of type "Field" called "RepeatedField".
-
- // List<Field> getRepeatedFieldList()
- WriteFieldDocComment(printer, descriptor_);
+
+ // The comments above the methods below are based on a hypothetical
+ // repeated field of type "Field" called "RepeatedField".
+
+ // List<Field> getRepeatedFieldList()
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public java.util.List<$type$> "
"${$get$capitalized_name$List$}$()",
-
+
"return java.util.Collections.unmodifiableList($name$_);\n",
"return $name$Builder_.getMessageList();\n",
-
+
NULL);
-
- // int getRepeatedFieldCount()
- WriteFieldDocComment(printer, descriptor_);
+
+ // int getRepeatedFieldCount()
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer, "$deprecation$public int ${$get$capitalized_name$Count$}$()",
-
+
"return $name$_.size();\n", "return $name$Builder_.getCount();\n",
-
+
NULL);
-
- // Field getRepeatedField(int index)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field getRepeatedField(int index)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public $type$ ${$get$capitalized_name$$}$(int index)",
-
+
"return $name$_.get(index);\n",
-
+
"return $name$Builder_.getMessage(index);\n",
-
+
NULL);
-
- // Builder setRepeatedField(int index, Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder setRepeatedField(int index, Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
@@ -1050,132 +1050,132 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
"$name$_.set(index, value);\n"
"$on_changed$\n",
"$name$Builder_.setMessage(index, value);\n", "return this;\n");
-
- // Builder setRepeatedField(int index, Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder setRepeatedField(int index, Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$.Builder builderForValue)",
-
+
"ensure$capitalized_name$IsMutable();\n"
"$name$_.set(index, builderForValue.build());\n"
"$on_changed$\n",
-
+
"$name$Builder_.setMessage(index, builderForValue.build());\n",
-
+
"return this;\n");
-
- // Builder addRepeatedField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder addRepeatedField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value)",
-
+
"if (value == null) {\n"
" throw new NullPointerException();\n"
"}\n"
"ensure$capitalized_name$IsMutable();\n"
"$name$_.add(value);\n"
-
+
"$on_changed$\n",
-
+
"$name$Builder_.addMessage(value);\n",
-
+
"return this;\n");
-
- // Builder addRepeatedField(int index, Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder addRepeatedField(int index, Field value)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" int index, $type$ value)",
-
+
"if (value == null) {\n"
" throw new NullPointerException();\n"
"}\n"
"ensure$capitalized_name$IsMutable();\n"
"$name$_.add(index, value);\n"
"$on_changed$\n",
-
+
"$name$Builder_.addMessage(index, value);\n",
-
+
"return this;\n");
-
- // Builder addRepeatedField(Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder addRepeatedField(Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" $type$.Builder builderForValue)",
-
+
"ensure$capitalized_name$IsMutable();\n"
"$name$_.add(builderForValue.build());\n"
"$on_changed$\n",
-
+
"$name$Builder_.addMessage(builderForValue.build());\n",
-
+
"return this;\n");
-
- // Builder addRepeatedField(int index, Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder addRepeatedField(int index, Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" int index, $type$.Builder builderForValue)",
-
+
"ensure$capitalized_name$IsMutable();\n"
"$name$_.add(index, builderForValue.build());\n"
"$on_changed$\n",
-
+
"$name$Builder_.addMessage(index, builderForValue.build());\n",
-
+
"return this;\n");
-
- // Builder addAllRepeatedField(Iterable<Field> values)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder addAllRepeatedField(Iterable<Field> values)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<? extends $type$> values)",
-
+
"ensure$capitalized_name$IsMutable();\n"
"com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
" values, $name$_);\n"
"$on_changed$\n",
-
+
"$name$Builder_.addAllMessages(values);\n",
-
+
"return this;\n");
-
- // Builder clearAllRepeatedField()
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder clearAllRepeatedField()
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
-
+
"$name$_ = java.util.Collections.emptyList();\n"
"$clear_mutable_bit_builder$;\n"
"$on_changed$\n",
-
+
"$name$Builder_.clear();\n",
-
+
"return this;\n");
-
- // Builder removeRepeatedField(int index)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder removeRepeatedField(int index)
+ WriteFieldDocComment(printer, descriptor_);
PrintNestedBuilderFunction(
printer,
"$deprecation$public Builder ${$remove$capitalized_name$$}$(int index)",
-
+
"ensure$capitalized_name$IsMutable();\n"
"$name$_.remove(index);\n"
"$on_changed$\n",
-
+
"$name$Builder_.remove(index);\n",
-
+
"return this;\n");
-
- WriteFieldDocComment(printer, descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public $type$.Builder ${$get$capitalized_name$Builder$}$(\n"
@@ -1183,8 +1183,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" return get$capitalized_name$FieldBuilder().getBuilder(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$OrBuilder "
"${$get$capitalized_name$OrBuilder$}$(\n"
@@ -1196,8 +1196,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
@@ -1209,8 +1209,8 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldDocComment(printer, descriptor_);
+
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$.Builder "
"${$add$capitalized_name$Builder$}$() {\n"
@@ -1218,7 +1218,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" $type$.getDefaultInstance());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public $type$.Builder ${$add$capitalized_name$Builder$}$(\n"
@@ -1227,7 +1227,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" index, $type$.getDefaultInstance());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public java.util.List<$type$.Builder> \n"
@@ -1250,34 +1250,34 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
" return $name$Builder_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
-void RepeatedImmutableMessageFieldGenerator::
+}
+
+void RepeatedImmutableMessageFieldGenerator::
GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
-}
-
+ printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- PrintNestedBuilderCondition(printer,
+ PrintNestedBuilderCondition(printer,
"$name$_ = java.util.Collections.emptyList();\n"
"$clear_mutable_bit_builder$;\n",
-
+
"$name$Builder_.clear();\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- // The code below does two optimizations (non-nested builder case):
- // 1. If the other list is empty, there's nothing to do. This ensures we
- // don't allocate a new array if we already have an immutable one.
- // 2. If the other list is non-empty and our current list is empty, we can
- // reuse the other list which is guaranteed to be immutable.
+ // The code below does two optimizations (non-nested builder case):
+ // 1. If the other list is empty, there's nothing to do. This ensures we
+ // don't allocate a new array if we already have an immutable one.
+ // 2. If the other list is non-empty and our current list is empty, we can
+ // reuse the other list which is guaranteed to be immutable.
PrintNestedBuilderCondition(
printer,
"if (!other.$name$_.isEmpty()) {\n"
@@ -1290,7 +1290,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMergingCode(
" }\n"
" $on_changed$\n"
"}\n",
-
+
"if (!other.$name$_.isEmpty()) {\n"
" if ($name$Builder_.isEmpty()) {\n"
" $name$Builder_.dispose();\n"
@@ -1305,13 +1305,13 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMergingCode(
" $name$Builder_.addAllMessages(other.$name$_);\n"
" }\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- // The code below (non-nested builder case) ensures that the result has an
- // immutable list. If our list is immutable, we can just reuse it. If not,
- // we make it immutable.
+ // The code below (non-nested builder case) ensures that the result has an
+ // immutable list. If our list is immutable, we can just reuse it. If not,
+ // we make it immutable.
PrintNestedBuilderCondition(
printer,
"if ($get_mutable_bit_builder$) {\n"
@@ -1319,31 +1319,31 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuildingCode(
" $clear_mutable_bit_builder$;\n"
"}\n"
"result.$name$_ = $name$_;\n",
-
+
"result.$name$_ = $name$Builder_.build();\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (!$get_mutable_bit_parser$) {\n"
" $name$_ = new java.util.ArrayList<$type$>();\n"
" $set_mutable_bit_parser$;\n"
"}\n");
-
- if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
+
+ if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
printer->Print(
variables_,
"$name$_.add(input.readGroup($number$, $type$.$get_parser$,\n"
" extensionRegistry));\n");
- } else {
+ } else {
printer->Print(
variables_,
"$name$_.add(\n"
" input.readMessage($type$.$get_parser$, extensionRegistry));\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
printer->Print(
@@ -1351,16 +1351,16 @@ void RepeatedImmutableMessageFieldGenerator::GenerateParsingDoneCode(
"if ($get_mutable_bit_parser$) {\n"
" $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.write$group_or_message$($number$, $name$_.get(i));\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
printer->Print(
@@ -1369,16 +1369,16 @@ void RepeatedImmutableMessageFieldGenerator::GenerateSerializedSizeCode(
" size += com.google.protobuf.CodedOutputStream\n"
" .compute$group_or_message$Size($number$, $name$_.get(i));\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
printer->Print(
variables_,
"if (!get$capitalized_name$List()\n"
" .equals(other.get$capitalized_name$List())) return false;\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
printer->Print(
@@ -1387,12 +1387,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateHashCode(
" hash = (37 * hash) + $constant_name$;\n"
" hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
"}\n");
-}
-
+}
+
TProtoStringType RepeatedImmutableMessageFieldGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->message_type());
-}
-
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
+}
+
void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -1485,7 +1485,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"}");
}
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
index 94a215577f..2716498328 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,88 +49,88 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
+ public:
explicit ImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex,
Context* context);
- ~ImmutableMessageFieldGenerator();
-
+ ~ImmutableMessageFieldGenerator();
+
// implements ImmutableFieldGenerator
// ---------------------------------------
- int GetNumBitsForMessage() const;
- int GetNumBitsForBuilder() const;
- void GenerateInterfaceMembers(io::Printer* printer) const;
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateInitializationCode(io::Printer* printer) const;
- void GenerateBuilderClearCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateBuildingCode(io::Printer* printer) const;
- void GenerateParsingCode(io::Printer* printer) const;
- void GenerateParsingDoneCode(io::Printer* printer) const;
- void GenerateSerializationCode(io::Printer* printer) const;
- void GenerateSerializedSizeCode(io::Printer* printer) const;
- void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;
- void GenerateEqualsCode(io::Printer* printer) const;
- void GenerateHashCode(io::Printer* printer) const;
+ int GetNumBitsForMessage() const;
+ int GetNumBitsForBuilder() const;
+ void GenerateInterfaceMembers(io::Printer* printer) const;
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateInitializationCode(io::Printer* printer) const;
+ void GenerateBuilderClearCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateBuildingCode(io::Printer* printer) const;
+ void GenerateParsingCode(io::Printer* printer) const;
+ void GenerateParsingDoneCode(io::Printer* printer) const;
+ void GenerateSerializationCode(io::Printer* printer) const;
+ void GenerateSerializedSizeCode(io::Printer* printer) const;
+ void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;
+ void GenerateEqualsCode(io::Printer* printer) const;
+ void GenerateHashCode(io::Printer* printer) const;
void GenerateKotlinDslMembers(io::Printer* printer) const;
-
+
TProtoStringType GetBoxedType() const;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- void PrintNestedBuilderCondition(io::Printer* printer,
+ ClassNameResolver* name_resolver_;
+
+ void PrintNestedBuilderCondition(io::Printer* printer,
const char* regular_case,
const char* nested_builder_case) const;
- void PrintNestedBuilderFunction(io::Printer* printer,
+ void PrintNestedBuilderFunction(io::Printer* printer,
const char* method_prototype,
const char* regular_case,
const char* nested_builder_case,
const char* trailing_code) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator);
-};
-
-class ImmutableMessageOneofFieldGenerator
- : public ImmutableMessageFieldGenerator {
- public:
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator);
+};
+
+class ImmutableMessageOneofFieldGenerator
+ : public ImmutableMessageFieldGenerator {
+ public:
ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
- ~ImmutableMessageOneofFieldGenerator();
-
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateBuildingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateParsingCode(io::Printer* printer) const;
- void GenerateSerializationCode(io::Printer* printer) const;
- void GenerateSerializedSizeCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldGenerator);
-};
-
-class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
- public:
- explicit RepeatedImmutableMessageFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, Context* context);
+ ~ImmutableMessageOneofFieldGenerator();
+
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateBuildingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateParsingCode(io::Printer* printer) const;
+ void GenerateSerializationCode(io::Printer* printer) const;
+ void GenerateSerializedSizeCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldGenerator);
+};
+
+class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
+ public:
+ explicit RepeatedImmutableMessageFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, Context* context);
~RepeatedImmutableMessageFieldGenerator() override;
-
- // implements ImmutableFieldGenerator ---------------------------------------
+
+ // implements ImmutableFieldGenerator ---------------------------------------
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -149,30 +149,30 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- void PrintNestedBuilderCondition(io::Printer* printer,
+ ClassNameResolver* name_resolver_;
+
+ void PrintNestedBuilderCondition(io::Printer* printer,
const char* regular_case,
const char* nested_builder_case) const;
- void PrintNestedBuilderFunction(io::Printer* printer,
+ void PrintNestedBuilderFunction(io::Printer* printer,
const char* method_prototype,
const char* regular_case,
const char* nested_builder_case,
const char* trailing_code) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc
index 0de4dbe0f8..f36555f00c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_message_field_lite.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
@@ -45,30 +45,30 @@
#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 java {
-
-namespace {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+
void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- (*variables)["type"] =
- name_resolver->GetImmutableClassName(descriptor->message_type());
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ (*variables)["type"] =
+ name_resolver->GetImmutableClassName(descriptor->message_type());
(*variables)["kt_type"] = (*variables)["type"];
- (*variables)["mutable_type"] =
- name_resolver->GetMutableClassName(descriptor->message_type());
- (*variables)["group_or_message"] =
+ (*variables)["mutable_type"] =
+ name_resolver->GetMutableClassName(descriptor->message_type());
+ (*variables)["group_or_message"] =
(GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? "Group"
: "Message";
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -77,40 +77,40 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
" is deprecated\") "
: "";
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
-
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["clear_has_field_bit_message"] = "";
-
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != null";
- }
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["clear_has_field_bit_message"] =
+ GenerateClearBit(messageBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["clear_has_field_bit_message"] = "";
+
+ (*variables)["is_field_present_message"] =
+ (*variables)["name"] + "_ != null";
+ }
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["null_check"] = "value.getClass();\n";
-}
-
-} // namespace
-
-// ===================================================================
-
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutableMessageFieldLiteGenerator::ImmutableMessageFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
@@ -119,34 +119,34 @@ ImmutableMessageFieldLiteGenerator::ImmutableMessageFieldLiteGenerator(
SetMessageVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
name_resolver_, &variables_);
-}
-
-ImmutableMessageFieldLiteGenerator::~ImmutableMessageFieldLiteGenerator() {}
-
-int ImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {
+}
+
+ImmutableMessageFieldLiteGenerator::~ImmutableMessageFieldLiteGenerator() {}
+
+int ImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {
// TODO(dweis): We don't need a has bit for messages as they have null
// sentinels and no user should be reflecting on this. We could save some
// bits by setting to 0 and updating the runtimes but this might come at a
// runtime performance cost since we can't memoize has-bit reads.
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
+}
+
void ImmutableMessageFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_, "$deprecation$boolean has$capitalized_name$();\n");
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
-}
-
+}
+
void ImmutableMessageFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
-
+
printer->Print(variables_, "private $type$ $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
-
+ PrintExtraFieldInfo(variables_, printer);
+
if (HasHasbit(descriptor_)) {
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -154,7 +154,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -162,8 +162,8 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- } else {
- WriteFieldDocComment(printer, descriptor_);
+ } else {
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -171,7 +171,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $name$_ != null;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -179,19 +179,19 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
- // Field.Builder setField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ }
+
+ // Field.Builder setField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void set$capitalized_name$($type$ value) {\n"
" $null_check$"
" $name$_ = value;\n"
" $set_has_field_bit_message$\n"
" }\n");
-
- // Field.Builder mergeField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder mergeField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.SuppressWarnings({\"ReferenceEquality\"})\n"
@@ -206,42 +206,42 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers(
" }\n"
" $set_has_field_bit_message$\n"
"}\n");
-
- // Field.Builder clearField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder clearField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void clear$capitalized_name$() {"
" $name$_ = null;\n"
" $clear_has_field_bit_message$\n"
"}\n");
-}
-
+}
+
void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // The comments above the methods below are based on a hypothetical
- // field of type "Field" called "Field".
-
- // boolean hasField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ // The comments above the methods below are based on a hypothetical
+ // field of type "Field" called "Field".
+
+ // boolean hasField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field getField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field getField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return instance.get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder setField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder setField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -249,10 +249,10 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
" }\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder setField(Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder setField(Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" $type$.Builder builderForValue) {\n"
" copyOnWrite();\n"
@@ -260,10 +260,10 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder mergeField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder mergeField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$merge$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -271,18 +271,18 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder clearField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder clearField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {"
" copyOnWrite();\n"
" instance.clear$capitalized_name$();\n"
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -316,37 +316,37 @@ void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
output);
if (HasHasbit(descriptor_)) {
WriteIntToUtf16CharSequence(messageBitIndex_, output);
- }
+ }
printer->Print(variables_, "\"$name$_\",\n");
-}
-
+}
+
void ImmutableMessageFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {}
-
+
TProtoStringType ImmutableMessageFieldLiteGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->message_type());
-}
-
-// ===================================================================
-
-ImmutableMessageOneofFieldLiteGenerator::
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
+}
+
+// ===================================================================
+
+ImmutableMessageOneofFieldLiteGenerator::
ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context)
: ImmutableMessageFieldLiteGenerator(descriptor, messageBitIndex, context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
-ImmutableMessageOneofFieldLiteGenerator::
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
+ImmutableMessageOneofFieldLiteGenerator::
~ImmutableMessageOneofFieldLiteGenerator() {}
-
+
void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ PrintExtraFieldInfo(variables_, printer);
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $has_oneof_case_message$;\n"
@@ -362,18 +362,18 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
" return $type$.getDefaultInstance();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder setField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder setField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void set$capitalized_name$($type$ value) {\n"
" $null_check$"
" $oneof_name$_ = value;\n"
" $set_oneof_case_message$;\n"
"}\n");
-
- // Field.Builder mergeField(Field value)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder mergeField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"private void merge$capitalized_name$($type$ value) {\n"
@@ -387,18 +387,18 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
" }\n"
" $set_oneof_case_message$;\n"
"}\n");
-
- // Field.Builder clearField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder clearField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
" $oneof_name$_ = null;\n"
" }\n"
"}\n");
-}
-
+}
+
void ImmutableMessageOneofFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -410,9 +410,9 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateFieldInfo(
void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // The comments above the methods below are based on a hypothetical
- // field of type "Field" called "Field".
-
+ // The comments above the methods below are based on a hypothetical
+ // field of type "Field" called "Field".
+
// boolean hasField()
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
@@ -421,19 +421,19 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field getField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field getField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return instance.get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder setField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder setField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -441,10 +441,10 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder setField(Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder setField(Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" $type$.Builder builderForValue) {\n"
" copyOnWrite();\n"
@@ -452,10 +452,10 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder mergeField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Field.Builder mergeField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$merge$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -463,9 +463,9 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Field.Builder clearField()
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field.Builder clearField()
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
@@ -474,60 +474,60 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
-// ===================================================================
-
-RepeatedImmutableMessageFieldLiteGenerator::
+}
+
+// ===================================================================
+
+RepeatedImmutableMessageFieldLiteGenerator::
RepeatedImmutableMessageFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
SetMessageVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-RepeatedImmutableMessageFieldLiteGenerator::
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+RepeatedImmutableMessageFieldLiteGenerator::
~RepeatedImmutableMessageFieldLiteGenerator() {}
-
-int RepeatedImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
+
+int RepeatedImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
void RepeatedImmutableMessageFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
- // TODO(jonp): In the future, consider having methods specific to the
- // interface so that builders can choose dynamically to either return a
- // message or a nested builder, so that asking for the interface doesn't
- // cause a message to ever be built.
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ // TODO(jonp): In the future, consider having methods specific to the
+ // interface so that builders can choose dynamically to either return a
+ // message or a nested builder, so that asking for the interface doesn't
+ // cause a message to ever be built.
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$java.util.List<$type$> \n"
" get$capitalized_name$List();\n");
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$$type$ get$capitalized_name$(int index);\n");
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(
variables_,
"private com.google.protobuf.Internal.ProtobufList<$type$> $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ PrintExtraFieldInfo(variables_, printer);
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$type$> "
"${$get$capitalized_name$List$}$() {\n"
" return $name$_;\n" // note: unmodifiable list
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
@@ -535,7 +535,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -543,7 +543,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $name$_.size();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -551,15 +551,15 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
" return $name$_.get(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public $type$OrBuilder "
"${$get$capitalized_name$OrBuilder$}$(\n"
" int index) {\n"
" return $name$_.get(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
printer->Print(
variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
@@ -571,70 +571,70 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers(
" }\n"
"}\n"
"\n");
-
- // Builder setRepeatedField(int index, Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder setRepeatedField(int index, Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void set$capitalized_name$(\n"
" int index, $type$ value) {\n"
" $null_check$"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.set(index, value);\n"
"}\n");
-
- // Builder addRepeatedField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addRepeatedField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void add$capitalized_name$($type$ value) {\n"
" $null_check$"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value);\n"
"}\n");
-
- // Builder addRepeatedField(int index, Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addRepeatedField(int index, Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void add$capitalized_name$(\n"
" int index, $type$ value) {\n"
" $null_check$"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(index, value);\n"
"}\n");
-
- // Builder addAllRepeatedField(Iterable<Field> values)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addAllRepeatedField(Iterable<Field> values)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void addAll$capitalized_name$(\n"
" java.lang.Iterable<? extends $type$> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
" com.google.protobuf.AbstractMessageLite.addAll(\n"
" values, $name$_);\n"
"}\n");
-
- // Builder clearAllRepeatedField()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder clearAllRepeatedField()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $name$_ = emptyProtobufList();\n"
"}\n");
-
- // Builder removeRepeatedField(int index)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder removeRepeatedField(int index)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"private void remove$capitalized_name$(int index) {\n"
" ensure$capitalized_name$IsMutable();\n"
" $name$_.remove(index);\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // The comments above the methods below are based on a hypothetical
- // repeated field of type "Field" called "RepeatedField".
-
- // List<Field> getRepeatedFieldList()
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ // The comments above the methods below are based on a hypothetical
+ // repeated field of type "Field" called "RepeatedField".
+
+ // List<Field> getRepeatedFieldList()
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$type$> "
"${$get$capitalized_name$List$}$() {\n"
@@ -642,9 +642,9 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" instance.get$capitalized_name$List());\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // int getRepeatedFieldCount()
- WriteFieldDocComment(printer, descriptor_);
+
+ // int getRepeatedFieldCount()
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -652,9 +652,9 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return instance.get$capitalized_name$Count();\n"
"}");
printer->Annotate("{", "}", descriptor_);
-
- // Field getRepeatedField(int index)
- WriteFieldDocComment(printer, descriptor_);
+
+ // Field getRepeatedField(int index)
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"@java.lang.Override\n"
@@ -662,10 +662,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return instance.get$capitalized_name$(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder setRepeatedField(int index, Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder setRepeatedField(int index, Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
" copyOnWrite();\n"
@@ -673,10 +673,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder setRepeatedField(int index, Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder setRepeatedField(int index, Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$.Builder builderForValue) {\n"
" copyOnWrite();\n"
@@ -685,10 +685,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder addRepeatedField(Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addRepeatedField(Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -696,10 +696,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder addRepeatedField(int index, Field value)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addRepeatedField(int index, Field value)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
" copyOnWrite();\n"
@@ -707,9 +707,9 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- // Builder addRepeatedField(Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+ // Builder addRepeatedField(Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" $type$.Builder builderForValue) {\n"
" copyOnWrite();\n"
@@ -717,10 +717,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder addRepeatedField(int index, Field.Builder builderForValue)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addRepeatedField(int index, Field.Builder builderForValue)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" int index, $type$.Builder builderForValue) {\n"
" copyOnWrite();\n"
@@ -729,10 +729,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder addAllRepeatedField(Iterable<Field> values)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder addAllRepeatedField(Iterable<Field> values)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<? extends $type$> values) {\n"
" copyOnWrite();\n"
@@ -740,9 +740,9 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder clearAllRepeatedField()
- WriteFieldDocComment(printer, descriptor_);
+
+ // Builder clearAllRepeatedField()
+ WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
@@ -751,10 +751,10 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
- // Builder removeRepeatedField(int index)
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
+
+ // Builder removeRepeatedField(int index)
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$remove$capitalized_name$$}$(int index) {\n"
" copyOnWrite();\n"
@@ -762,27 +762,27 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void RepeatedImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
output);
- printer->Print(variables_,
+ printer->Print(variables_,
"\"$name$_\",\n"
"$type$.class,\n");
-}
-
+}
+
void RepeatedImmutableMessageFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = emptyProtobufList();\n");
-}
-
+ printer->Print(variables_, "$name$_ = emptyProtobufList();\n");
+}
+
TProtoStringType RepeatedImmutableMessageFieldLiteGenerator::GetBoxedType() const {
- return name_resolver_->GetImmutableClassName(descriptor_->message_type());
-}
-
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
+}
+
void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -875,7 +875,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"}");
}
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h
index 571347f197..22a12ce857 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
+
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -51,67 +51,67 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
+ public:
explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
- ~ImmutableMessageFieldLiteGenerator();
-
+ ~ImmutableMessageFieldLiteGenerator();
+
// implements ImmutableFieldLiteGenerator
// ------------------------------------
- int GetNumBitsForMessage() const;
- void GenerateInterfaceMembers(io::Printer* printer) const;
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateInitializationCode(io::Printer* printer) const;
+ int GetNumBitsForMessage() const;
+ void GenerateInterfaceMembers(io::Printer* printer) const;
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateInitializationCode(io::Printer* printer) const;
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const;
void GenerateKotlinDslMembers(io::Printer* printer) const;
-
+
TProtoStringType GetBoxedType() const;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- const int messageBitIndex_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldLiteGenerator);
-};
-
-class ImmutableMessageOneofFieldLiteGenerator
- : public ImmutableMessageFieldLiteGenerator {
- public:
+ const int messageBitIndex_;
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldLiteGenerator);
+};
+
+class ImmutableMessageOneofFieldLiteGenerator
+ : public ImmutableMessageFieldLiteGenerator {
+ public:
ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
- ~ImmutableMessageOneofFieldLiteGenerator();
-
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
+ ~ImmutableMessageOneofFieldLiteGenerator();
+
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);
-};
-
-class RepeatedImmutableMessageFieldLiteGenerator
- : public ImmutableFieldLiteGenerator {
- public:
- explicit RepeatedImmutableMessageFieldLiteGenerator(
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);
+};
+
+class RepeatedImmutableMessageFieldLiteGenerator
+ : public ImmutableFieldLiteGenerator {
+ public:
+ explicit RepeatedImmutableMessageFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
~RepeatedImmutableMessageFieldLiteGenerator() override;
-
- // implements ImmutableFieldLiteGenerator ------------------------------------
+
+ // implements ImmutableFieldLiteGenerator ------------------------------------
int GetNumBitsForMessage() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
void GenerateMembers(io::Printer* printer) const override;
@@ -120,21 +120,21 @@ class RepeatedImmutableMessageFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
- protected:
- const FieldDescriptor* descriptor_;
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
index 74a54def04..bec5a7f47c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -1,45 +1,45 @@
-// 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: dweis@google.com (Daniel Weis)
-// 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: dweis@google.com (Daniel Weis)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_message_lite.h>
-
-#include <algorithm>
+
+#include <algorithm>
#include <cstdint>
-#include <map>
-#include <memory>
-#include <vector>
-
+#include <map>
+#include <memory>
+#include <vector>
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_enum_lite.h>
@@ -55,86 +55,86 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-// ===================================================================
-ImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator(
- const Descriptor* descriptor, Context* context)
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+// ===================================================================
+ImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator(
+ const Descriptor* descriptor, Context* context)
: MessageGenerator(descriptor),
context_(context),
name_resolver_(context->GetNameResolver()),
field_generators_(descriptor, context_) {
- GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
- << "Generator factory error: A lite message generator is used to "
- "generate non-lite messages.";
+ GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))
+ << "Generator factory error: A lite message generator is used to "
+ "generate non-lite messages.";
for (int i = 0; i < descriptor_->field_count(); i++) {
if (IsRealOneof(descriptor_->field(i))) {
oneofs_.insert(descriptor_->field(i)->containing_oneof());
}
}
-}
-
-ImmutableMessageLiteGenerator::~ImmutableMessageLiteGenerator() {}
-
-void ImmutableMessageLiteGenerator::GenerateStaticVariables(
- io::Printer* printer, int* bytecode_estimate) {
- // Generate static members for all nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // TODO(kenton): Reuse MessageGenerator objects?
- ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
- .GenerateStaticVariables(printer, bytecode_estimate);
- }
-}
-
-int ImmutableMessageLiteGenerator::GenerateStaticVariableInitializers(
- io::Printer* printer) {
- int bytecode_estimate = 0;
- // Generate static member initializers for all nested types.
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // TODO(kenton): Reuse MessageGenerator objects?
- bytecode_estimate +=
- ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
- .GenerateStaticVariableInitializers(printer);
- }
- return bytecode_estimate;
-}
-
-// ===================================================================
-
-void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
- /* immutable = */ true, "OrBuilder");
- if (descriptor_->extension_range_count() > 0) {
- printer->Print(
+}
+
+ImmutableMessageLiteGenerator::~ImmutableMessageLiteGenerator() {}
+
+void ImmutableMessageLiteGenerator::GenerateStaticVariables(
+ io::Printer* printer, int* bytecode_estimate) {
+ // Generate static members for all nested types.
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ // TODO(kenton): Reuse MessageGenerator objects?
+ ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
+ .GenerateStaticVariables(printer, bytecode_estimate);
+ }
+}
+
+int ImmutableMessageLiteGenerator::GenerateStaticVariableInitializers(
+ io::Printer* printer) {
+ int bytecode_estimate = 0;
+ // Generate static member initializers for all nested types.
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ // TODO(kenton): Reuse MessageGenerator objects?
+ bytecode_estimate +=
+ ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
+ .GenerateStaticVariableInitializers(printer);
+ }
+ return bytecode_estimate;
+}
+
+// ===================================================================
+
+void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
+ /* immutable = */ true, "OrBuilder");
+ if (descriptor_->extension_range_count() > 0) {
+ printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends \n"
- " $extra_interfaces$\n"
- " com.google.protobuf.GeneratedMessageLite.\n"
- " ExtendableMessageOrBuilder<\n"
- " $classname$, $classname$.Builder> {\n",
+ " $extra_interfaces$\n"
+ " com.google.protobuf.GeneratedMessageLite.\n"
+ " ExtendableMessageOrBuilder<\n"
+ " $classname$, $classname$.Builder> {\n",
"deprecation",
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
+ "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
"classname", descriptor_->name(), "{", "", "}", "");
- } else {
- printer->Print(
+ } else {
+ printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
- " $extra_interfaces$\n"
- " com.google.protobuf.MessageLiteOrBuilder {\n",
+ " $extra_interfaces$\n"
+ " com.google.protobuf.MessageLiteOrBuilder {\n",
"deprecation",
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
- "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
+ "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
"classname", descriptor_->name(), "{", "", "}", "");
- }
+ }
printer->Annotate("{", "}", descriptor_);
-
- printer->Indent();
+
+ printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("\n");
field_generators_.get(descriptor_->field(i))
@@ -149,31 +149,31 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
context_->GetNameResolver()->GetImmutableClassName(descriptor_));
}
- printer->Outdent();
-
- printer->Print("}\n");
-}
-
-// ===================================================================
-
-void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
- bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
-
+ printer->Outdent();
+
+ printer->Print("}\n");
+}
+
+// ===================================================================
+
+void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
+ bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
+
std::map<TProtoStringType, TProtoStringType> variables;
- variables["static"] = is_own_file ? " " : " static ";
- variables["classname"] = descriptor_->name();
- variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
+ variables["static"] = is_own_file ? " " : " static ";
+ variables["classname"] = descriptor_->name();
+ variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
variables["deprecation"] =
descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "";
-
- WriteMessageDocComment(printer, descriptor_);
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
- /* immutable = */ true);
-
- // The builder_type stores the super type name of the nested Builder class.
+ WriteMessageDocComment(printer, descriptor_);
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
+ /* immutable = */ true);
+
+
+ // The builder_type stores the super type name of the nested Builder class.
TProtoStringType builder_type;
- if (descriptor_->extension_range_count() > 0) {
+ if (descriptor_->extension_range_count() > 0) {
printer->Print(
variables,
"$deprecation$public $static$final class $classname$ extends\n"
@@ -181,71 +181,71 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
" $classname$, $classname$.Builder> implements\n"
" $extra_interfaces$\n"
" $classname$OrBuilder {\n");
- builder_type = strings::Substitute(
- "com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<$0, ?>",
- name_resolver_->GetImmutableClassName(descriptor_));
- } else {
+ builder_type = strings::Substitute(
+ "com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<$0, ?>",
+ name_resolver_->GetImmutableClassName(descriptor_));
+ } else {
printer->Print(
variables,
"$deprecation$public $static$final class $classname$ extends\n"
- " com.google.protobuf.GeneratedMessageLite<\n"
- " $classname$, $classname$.Builder> implements\n"
- " $extra_interfaces$\n"
- " $classname$OrBuilder {\n");
-
- builder_type = "com.google.protobuf.GeneratedMessageLite.Builder";
- }
- printer->Indent();
-
- GenerateConstructor(printer);
-
- // Nested types
- for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- EnumLiteGenerator(descriptor_->enum_type(i), true, context_)
- .Generate(printer);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- // Don't generate Java classes for map entry messages.
- if (IsMapEntry(descriptor_->nested_type(i))) continue;
+ " com.google.protobuf.GeneratedMessageLite<\n"
+ " $classname$, $classname$.Builder> implements\n"
+ " $extra_interfaces$\n"
+ " $classname$OrBuilder {\n");
+
+ builder_type = "com.google.protobuf.GeneratedMessageLite.Builder";
+ }
+ printer->Indent();
+
+ GenerateConstructor(printer);
+
+ // Nested types
+ for (int i = 0; i < descriptor_->enum_type_count(); i++) {
+ EnumLiteGenerator(descriptor_->enum_type(i), true, context_)
+ .Generate(printer);
+ }
+
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ // Don't generate Java classes for map entry messages.
+ if (IsMapEntry(descriptor_->nested_type(i))) continue;
ImmutableMessageLiteGenerator messageGenerator(descriptor_->nested_type(i),
context_);
- messageGenerator.GenerateInterface(printer);
- messageGenerator.Generate(printer);
- }
-
+ messageGenerator.GenerateInterface(printer);
+ messageGenerator.Generate(printer);
+ }
+
// Integers for bit fields.
int totalBits = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
totalBits +=
field_generators_.get(descriptor_->field(i)).GetNumBitsForMessage();
- }
+ }
int totalInts = (totalBits + 31) / 32;
for (int i = 0; i < totalInts; i++) {
printer->Print("private int $bit_field_name$;\n", "bit_field_name",
GetBitFieldName(i));
}
-
- // oneof
+
+ // oneof
std::map<TProtoStringType, TProtoStringType> vars;
for (auto oneof : oneofs_) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] =
context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
vars["oneof_index"] = StrCat((oneof)->index());
- // oneofCase_ and oneof_
- printer->Print(vars,
+ // oneofCase_ and oneof_
+ printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
"private java.lang.Object $oneof_name$_;\n");
- // OneofCase enum
+ // OneofCase enum
printer->Print(vars, "public enum $oneof_capitalized_name$Case {\n");
- printer->Indent();
+ printer->Indent();
for (int j = 0; j < (oneof)->field_count(); j++) {
const FieldDescriptor* field = (oneof)->field(j);
printer->Print("$field_name$($field_number$),\n", "field_name",
ToUpper(field->name()), "field_number",
StrCat(field->number()));
- }
+ }
printer->Print("$cap_oneof_name$_NOT_SET(0);\n", "cap_oneof_name",
ToUpper(vars["oneof_name"]));
printer->Print(vars,
@@ -253,7 +253,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"private $oneof_capitalized_name$Case(int value) {\n"
" this.value = value;\n"
"}\n");
- printer->Print(
+ printer->Print(
vars,
"/**\n"
" * @deprecated Use {@link #forNumber(int)} instead.\n"
@@ -270,8 +270,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Print(" case $field_number$: return $field_name$;\n",
"field_number", StrCat(field->number()),
"field_name", ToUpper(field->name()));
- }
- printer->Print(
+ }
+ printer->Print(
" case 0: return $cap_oneof_name$_NOT_SET;\n"
" default: return null;\n"
" }\n"
@@ -282,10 +282,10 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
" return this.value;\n"
"}\n",
"cap_oneof_name", ToUpper(vars["oneof_name"]));
- printer->Outdent();
- printer->Print("};\n\n");
- // oneofCase()
- printer->Print(vars,
+ printer->Outdent();
+ printer->Print("};\n\n");
+ // oneofCase()
+ printer->Print(vars,
"@java.lang.Override\n"
"public $oneof_capitalized_name$Case\n"
"get$oneof_capitalized_name$Case() {\n"
@@ -298,28 +298,28 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
" $oneof_name$_ = null;\n"
"}\n"
"\n");
- }
-
- // Fields
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("public static final int $constant_name$ = $number$;\n",
+ }
+
+ // Fields
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("public static final int $constant_name$ = $number$;\n",
"constant_name", FieldConstantName(descriptor_->field(i)),
"number", StrCat(descriptor_->field(i)->number()));
- field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
- printer->Print("\n");
- }
-
- GenerateParseFromMethods(printer);
- GenerateBuilder(printer);
-
- if (HasRequiredFields(descriptor_)) {
- // Memoizes whether the protocol buffer is fully initialized (has all
+ field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
+ printer->Print("\n");
+ }
+
+ GenerateParseFromMethods(printer);
+ GenerateBuilder(printer);
+
+ if (HasRequiredFields(descriptor_)) {
+ // Memoizes whether the protocol buffer is fully initialized (has all
// required fields). 0 means false, 1 means true, and all other values
// mean not yet computed.
printer->Print("private byte memoizedIsInitialized = 2;\n");
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"@java.lang.Override\n"
"@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n"
"protected final java.lang.Object dynamicMethod(\n"
@@ -330,25 +330,25 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
" return new $classname$();\n"
" }\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Indent();
- printer->Indent();
-
+
+ printer->Indent();
+ printer->Indent();
+
printer->Print("case NEW_BUILDER: {\n");
-
- printer->Indent();
- GenerateDynamicMethodNewBuilder(printer);
- printer->Outdent();
-
- printer->Print(
+
+ printer->Indent();
+ GenerateDynamicMethodNewBuilder(printer);
+ printer->Outdent();
+
+ printer->Print(
"}\n"
"case BUILD_MESSAGE_INFO: {\n");
-
- printer->Indent();
+
+ printer->Indent();
GenerateDynamicMethodNewBuildMessageInfo(printer);
- printer->Outdent();
-
- printer->Print(
+ printer->Outdent();
+
+ printer->Print(
"}\n"
"// fall through\n"
"case GET_DEFAULT_INSTANCE: {\n"
@@ -376,9 +376,9 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
" }\n"
" return parser;\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Outdent();
-
+
+ printer->Outdent();
+
if (HasRequiredFields(descriptor_)) {
printer->Print(
"}\n"
@@ -399,27 +399,27 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
" return null;\n"
"}\n");
}
-
- printer->Outdent();
- printer->Print(
+
+ printer->Outdent();
+ printer->Print(
" }\n"
" throw new UnsupportedOperationException();\n"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
+
+ printer->Print(
"\n"
"// @@protoc_insertion_point(class_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- // Carefully initialize the default instance in such a way that it doesn't
- // conflict with other initialization.
+
+ // Carefully initialize the default instance in such a way that it doesn't
+ // conflict with other initialization.
printer->Print("private static final $classname$ DEFAULT_INSTANCE;\n",
"classname",
name_resolver_->GetImmutableClassName(descriptor_));
- printer->Print(
+ printer->Print(
"static {\n"
" $classname$ defaultInstance = new $classname$();\n"
" // New instances are implicitly immutable so no need to make\n"
@@ -433,14 +433,14 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"}\n"
"\n",
"classname", descriptor_->name());
-
- printer->Print(
- "public static $classname$ getDefaultInstance() {\n"
- " return DEFAULT_INSTANCE;\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
-
+
+ printer->Print(
+ "public static $classname$ getDefaultInstance() {\n"
+ " return DEFAULT_INSTANCE;\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+
// 'of' method for Wrappers
if (IsWrappersProtoFile(descriptor_->file())) {
printer->Print(
@@ -452,38 +452,38 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0))));
}
- GenerateParser(printer);
-
- // Extensions must be declared after the DEFAULT_INSTANCE is initialized
- // because the DEFAULT_INSTANCE is used by the extension to lazily retrieve
- // the outer class's FileDescriptor.
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)
- .Generate(printer);
- }
-
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
+ GenerateParser(printer);
+
+ // Extensions must be declared after the DEFAULT_INSTANCE is initialized
+ // because the DEFAULT_INSTANCE is used by the extension to lazily retrieve
+ // the outer class's FileDescriptor.
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)
+ .Generate(printer);
+ }
+
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
io::Printer* printer) {
printer->Indent();
-
+
// Collect field info into a sequence of UTF-16 chars. It will be embedded
// as a Java string in the generated code.
std::vector<uint16_t> chars;
-
+
int flags = 0;
if (IsProto2(descriptor_->file())) {
flags |= 0x1;
- }
+ }
if (descriptor_->options().message_set_wire_format()) {
flags |= 0x2;
- }
+ }
WriteIntToUtf16CharSequence(flags, &chars);
WriteIntToUtf16CharSequence(descriptor_->field_count(), &chars);
-
+
if (descriptor_->field_count() == 0) {
printer->Print("java.lang.Object[] objects = null;");
} else {
@@ -494,25 +494,25 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
// Record the number of oneofs.
WriteIntToUtf16CharSequence(oneofs_.size(), &chars);
for (auto oneof : oneofs_) {
- printer->Print(
+ printer->Print(
"\"$oneof_name$_\",\n"
"\"$oneof_name$Case_\",\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
- }
-
+ }
+
// Integers for bit fields.
int total_bits = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
total_bits +=
field_generators_.get(descriptor_->field(i)).GetNumBitsForMessage();
- }
+ }
int total_ints = (total_bits + 31) / 32;
for (int i = 0; i < total_ints; i++) {
printer->Print("\"$bit_field_name$\",\n", "bit_field_name",
GetBitFieldName(i));
}
WriteIntToUtf16CharSequence(total_ints, &chars);
-
+
int map_count = 0;
int repeated_count = 0;
std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
@@ -525,14 +525,14 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
repeated_count++;
}
}
-
+
WriteIntToUtf16CharSequence(sorted_fields[0]->number(), &chars);
WriteIntToUtf16CharSequence(
sorted_fields[descriptor_->field_count() - 1]->number(), &chars);
WriteIntToUtf16CharSequence(descriptor_->field_count(), &chars);
WriteIntToUtf16CharSequence(map_count, &chars);
WriteIntToUtf16CharSequence(repeated_count, &chars);
-
+
std::vector<const FieldDescriptor*> fields_for_is_initialized_check;
for (int i = 0; i < descriptor_->field_count(); i++) {
if (descriptor_->field(i)->is_required() ||
@@ -542,15 +542,15 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
}
}
WriteIntToUtf16CharSequence(fields_for_is_initialized_check.size(), &chars);
-
+
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = sorted_fields[i];
field_generators_.get(field).GenerateFieldInfo(printer, &chars);
- }
+ }
printer->Outdent();
printer->Print("};\n");
- }
-
+ }
+
printer->Print("java.lang.String info =\n");
TProtoStringType line;
for (size_t i = 0; i < chars.size(); i++) {
@@ -560,18 +560,18 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
printer->Print(" \"$string$\" +\n", "string", line);
line.clear();
}
- }
+ }
printer->Print(" \"$string$\";\n", "string", line);
-
+
printer->Print("return newMessageInfo(DEFAULT_INSTANCE, info, objects);\n");
- printer->Outdent();
-}
-
+ printer->Outdent();
+}
+
// ===================================================================
-
+
void ImmutableMessageLiteGenerator::GenerateParseFromMethods(
io::Printer* printer) {
- printer->Print(
+ printer->Print(
"public static $classname$ parseFrom(\n"
" java.nio.ByteBuffer data)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"
@@ -649,12 +649,12 @@ void ImmutableMessageLiteGenerator::GenerateParseFromMethods(
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-}
-
-// ===================================================================
-
-void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
- printer->Print(
+}
+
+// ===================================================================
+
+void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
+ printer->Print(
"public static Builder newBuilder() {\n"
" return (Builder) DEFAULT_INSTANCE.createBuilder();\n"
"}\n"
@@ -663,67 +663,67 @@ void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- MessageBuilderLiteGenerator builderGenerator(descriptor_, context_);
- builderGenerator.Generate(printer);
-}
-
-// ===================================================================
-
-void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuilder(
- io::Printer* printer) {
+
+ MessageBuilderLiteGenerator builderGenerator(descriptor_, context_);
+ builderGenerator.Generate(printer);
+}
+
+// ===================================================================
+
+void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuilder(
+ io::Printer* printer) {
printer->Print("return new Builder();\n");
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
void ImmutableMessageLiteGenerator::GenerateExtensionRegistrationCode(
- io::Printer* printer) {
- for (int i = 0; i < descriptor_->extension_count(); i++) {
- ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)
+ io::Printer* printer) {
+ for (int i = 0; i < descriptor_->extension_count(); i++) {
+ ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)
.GenerateRegistrationCode(printer);
- }
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
+ }
+
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
.GenerateExtensionRegistrationCode(printer);
- }
-}
-
-// ===================================================================
+ }
+}
+
+// ===================================================================
void ImmutableMessageLiteGenerator::GenerateConstructor(io::Printer* printer) {
printer->Print("private $classname$() {\n", "classname", descriptor_->name());
- printer->Indent();
-
- // Initialize all fields to default.
- GenerateInitializers(printer);
-
- printer->Outdent();
+ printer->Indent();
+
+ // Initialize all fields to default.
+ GenerateInitializers(printer);
+
+ printer->Outdent();
printer->Print("}\n");
-}
-
-// ===================================================================
-void ImmutableMessageLiteGenerator::GenerateParser(io::Printer* printer) {
- printer->Print(
+}
+
+// ===================================================================
+void ImmutableMessageLiteGenerator::GenerateParser(io::Printer* printer) {
+ printer->Print(
"private static volatile com.google.protobuf.Parser<$classname$> "
"PARSER;\n"
- "\n"
- "public static com.google.protobuf.Parser<$classname$> parser() {\n"
- " return DEFAULT_INSTANCE.getParserForType();\n"
- "}\n",
- "classname", descriptor_->name());
-}
-
-// ===================================================================
-void ImmutableMessageLiteGenerator::GenerateInitializers(io::Printer* printer) {
- for (int i = 0; i < descriptor_->field_count(); i++) {
+ "\n"
+ "public static com.google.protobuf.Parser<$classname$> parser() {\n"
+ " return DEFAULT_INSTANCE.getParserForType();\n"
+ "}\n",
+ "classname", descriptor_->name());
+}
+
+// ===================================================================
+void ImmutableMessageLiteGenerator::GenerateInitializers(io::Printer* printer) {
+ for (int i = 0; i < descriptor_->field_count(); i++) {
if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateInitializationCode(printer);
- }
- }
-}
-
+ field_generators_.get(descriptor_->field(i))
+ .GenerateInitializationCode(printer);
+ }
+ }
+}
+
void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
io::Printer* printer) const {
printer->Print(
@@ -960,7 +960,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"message", message_name);
}
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
index a5308062c2..4dfa291314 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h
@@ -1,86 +1,86 @@
-// 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: dweis@google.com (Daniel Weis)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_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: dweis@google.com (Daniel Weis)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
+
#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
#include <google/protobuf/compiler/java/java_message.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableMessageLiteGenerator : public MessageGenerator {
- public:
- ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context);
- virtual ~ImmutableMessageLiteGenerator();
-
- virtual void Generate(io::Printer* printer);
- virtual void GenerateInterface(io::Printer* printer);
- virtual void GenerateExtensionRegistrationCode(io::Printer* printer);
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableMessageLiteGenerator : public MessageGenerator {
+ public:
+ ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context);
+ virtual ~ImmutableMessageLiteGenerator();
+
+ virtual void Generate(io::Printer* printer);
+ virtual void GenerateInterface(io::Printer* printer);
+ virtual void GenerateExtensionRegistrationCode(io::Printer* printer);
virtual void GenerateStaticVariables(io::Printer* printer,
int* bytecode_estimate);
- virtual int GenerateStaticVariableInitializers(io::Printer* printer);
+ virtual int GenerateStaticVariableInitializers(io::Printer* printer);
void GenerateKotlinDsl(io::Printer* printer) const override;
void GenerateKotlinMembers(io::Printer* printer) const override;
void GenerateTopLevelKotlinMembers(io::Printer* printer) const override;
-
- private:
- void GenerateParseFromMethods(io::Printer* printer);
-
- void GenerateBuilder(io::Printer* printer);
- void GenerateDynamicMethodNewBuilder(io::Printer* printer);
- void GenerateInitializers(io::Printer* printer);
- void GenerateParser(io::Printer* printer);
- void GenerateConstructor(io::Printer* printer);
+
+ private:
+ void GenerateParseFromMethods(io::Printer* printer);
+
+ void GenerateBuilder(io::Printer* printer);
+ void GenerateDynamicMethodNewBuilder(io::Printer* printer);
+ void GenerateInitializers(io::Printer* printer);
+ void GenerateParser(io::Printer* printer);
+ void GenerateConstructor(io::Printer* printer);
void GenerateDynamicMethodNewBuildMessageInfo(io::Printer* printer);
void GenerateKotlinExtensions(io::Printer* printer) const;
-
- Context* context_;
- ClassNameResolver* name_resolver_;
- FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+ FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
index ee131f2bdd..595ead4955 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc
@@ -1,74 +1,74 @@
-// 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/java/java_name_resolver.h>
-
-#include <map>
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_names.h>
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-namespace {
-// A suffix that will be appended to the file's outer class name if the name
-// conflicts with some other types defined in the file.
-const char* kOuterClassNameSuffix = "OuterClass";
-
-// Strip package name from a descriptor's full name.
-// For example:
-// Full name : foo.Bar.Baz
-// Package name: foo
-// After strip : Bar.Baz
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+namespace {
+// A suffix that will be appended to the file's outer class name if the name
+// conflicts with some other types defined in the file.
+const char* kOuterClassNameSuffix = "OuterClass";
+
+// Strip package name from a descriptor's full name.
+// For example:
+// Full name : foo.Bar.Baz
+// Package name: foo
+// After strip : Bar.Baz
TProtoStringType StripPackageName(const TProtoStringType& full_name,
const FileDescriptor* file) {
- if (file->package().empty()) {
- return full_name;
- } else {
- // Strip package name
- return full_name.substr(file->package().size() + 1);
- }
-}
-
-// Get the name of a message's Java class without package name prefix.
+ if (file->package().empty()) {
+ return full_name;
+ } else {
+ // Strip package name
+ return full_name.substr(file->package().size() + 1);
+ }
+}
+
+// Get the name of a message's Java class without package name prefix.
TProtoStringType ClassNameWithoutPackage(const Descriptor* descriptor,
bool immutable) {
return StripPackageName(descriptor->full_name(), descriptor->file());
-}
-
+}
+
TProtoStringType ClassNameWithoutPackageKotlin(const Descriptor* descriptor) {
TProtoStringType result = descriptor->name();
const Descriptor* temp = descriptor->containing_type();
@@ -80,29 +80,29 @@ TProtoStringType ClassNameWithoutPackageKotlin(const Descriptor* descriptor) {
return result;
}
-// Get the name of an enum's Java class without package name prefix.
+// Get the name of an enum's Java class without package name prefix.
TProtoStringType ClassNameWithoutPackage(const EnumDescriptor* descriptor,
bool immutable) {
- // Doesn't append "Mutable" for enum type's name.
- const Descriptor* message_descriptor = descriptor->containing_type();
- if (message_descriptor == NULL) {
- return descriptor->name();
- } else {
+ // Doesn't append "Mutable" for enum type's name.
+ const Descriptor* message_descriptor = descriptor->containing_type();
+ if (message_descriptor == NULL) {
+ return descriptor->name();
+ } else {
return ClassNameWithoutPackage(message_descriptor, immutable) + "." +
descriptor->name();
- }
-}
-
-// Get the name of a service's Java class without package name prefix.
+ }
+}
+
+// Get the name of a service's Java class without package name prefix.
TProtoStringType ClassNameWithoutPackage(const ServiceDescriptor* descriptor,
bool immutable) {
TProtoStringType full_name =
StripPackageName(descriptor->full_name(), descriptor->file());
- // We don't allow nested service definitions.
+ // We don't allow nested service definitions.
GOOGLE_CHECK(full_name.find('.') == TProtoStringType::npos);
- return full_name;
-}
-
+ return full_name;
+}
+
// Return true if a and b are equals (case insensitive).
NameEquality CheckNameEquality(const TProtoStringType& a, const TProtoStringType& b) {
if (ToUpper(a) == ToUpper(b)) {
@@ -114,63 +114,63 @@ NameEquality CheckNameEquality(const TProtoStringType& a, const TProtoStringType
return NameEquality::NO_MATCH;
}
-// Check whether a given message or its nested types has the given class name.
-bool MessageHasConflictingClassName(const Descriptor* message,
+// Check whether a given message or its nested types has the given class name.
+bool MessageHasConflictingClassName(const Descriptor* message,
const TProtoStringType& classname,
NameEquality equality_mode) {
if (CheckNameEquality(message->name(), classname) == equality_mode) {
return true;
}
- for (int i = 0; i < message->nested_type_count(); ++i) {
+ for (int i = 0; i < message->nested_type_count(); ++i) {
if (MessageHasConflictingClassName(message->nested_type(i), classname,
equality_mode)) {
- return true;
- }
- }
- for (int i = 0; i < message->enum_type_count(); ++i) {
+ return true;
+ }
+ }
+ for (int i = 0; i < message->enum_type_count(); ++i) {
if (CheckNameEquality(message->enum_type(i)->name(), classname) ==
equality_mode) {
- return true;
- }
- }
- return false;
-}
-
-} // namespace
-
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace
+
ClassNameResolver::ClassNameResolver() {}
-
+
ClassNameResolver::~ClassNameResolver() {}
-
+
TProtoStringType ClassNameResolver::GetFileDefaultImmutableClassName(
- const FileDescriptor* file) {
+ const FileDescriptor* file) {
TProtoStringType basename;
TProtoStringType::size_type last_slash = file->name().find_last_of('/');
if (last_slash == TProtoStringType::npos) {
- basename = file->name();
- } else {
- basename = file->name().substr(last_slash + 1);
- }
- return UnderscoresToCamelCase(StripProto(basename), true);
-}
-
+ basename = file->name();
+ } else {
+ basename = file->name().substr(last_slash + 1);
+ }
+ return UnderscoresToCamelCase(StripProto(basename), true);
+}
+
TProtoStringType ClassNameResolver::GetFileImmutableClassName(
- const FileDescriptor* file) {
+ const FileDescriptor* file) {
TProtoStringType& class_name = file_immutable_outer_class_names_[file];
- if (class_name.empty()) {
- if (file->options().has_java_outer_classname()) {
- class_name = file->options().java_outer_classname();
- } else {
- class_name = GetFileDefaultImmutableClassName(file);
+ if (class_name.empty()) {
+ if (file->options().has_java_outer_classname()) {
+ class_name = file->options().java_outer_classname();
+ } else {
+ class_name = GetFileDefaultImmutableClassName(file);
if (HasConflictingClassName(file, class_name,
NameEquality::EXACT_EQUAL)) {
- class_name += kOuterClassNameSuffix;
- }
- }
- }
- return class_name;
-}
-
+ class_name += kOuterClassNameSuffix;
+ }
+ }
+ }
+ return class_name;
+}
+
TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
bool immutable) {
return GetFileClassName(file, immutable, false);
@@ -181,43 +181,43 @@ TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
if (kotlin) {
return GetFileImmutableClassName(file) + "Kt";
} else if (immutable) {
- return GetFileImmutableClassName(file);
- } else {
- return "Mutable" + GetFileImmutableClassName(file);
- }
-}
-
-// Check whether there is any type defined in the proto file that has
-// the given class name.
+ return GetFileImmutableClassName(file);
+ } else {
+ return "Mutable" + GetFileImmutableClassName(file);
+ }
+}
+
+// Check whether there is any type defined in the proto file that has
+// the given class name.
bool ClassNameResolver::HasConflictingClassName(const FileDescriptor* file,
const TProtoStringType& classname,
NameEquality equality_mode) {
- for (int i = 0; i < file->enum_type_count(); i++) {
+ for (int i = 0; i < file->enum_type_count(); i++) {
if (CheckNameEquality(file->enum_type(i)->name(), classname) ==
equality_mode) {
- return true;
- }
- }
- for (int i = 0; i < file->service_count(); i++) {
+ return true;
+ }
+ }
+ for (int i = 0; i < file->service_count(); i++) {
if (CheckNameEquality(file->service(i)->name(), classname) ==
equality_mode) {
- return true;
- }
- }
- for (int i = 0; i < file->message_type_count(); i++) {
+ return true;
+ }
+ }
+ for (int i = 0; i < file->message_type_count(); i++) {
if (MessageHasConflictingClassName(file->message_type(i), classname,
equality_mode)) {
- return true;
- }
- }
- return false;
-}
-
+ return true;
+ }
+ }
+ return false;
+}
+
TProtoStringType ClassNameResolver::GetDescriptorClassName(
- const FileDescriptor* descriptor) {
- return GetFileImmutableClassName(descriptor);
-}
-
+ const FileDescriptor* descriptor) {
+ return GetFileImmutableClassName(descriptor);
+}
+
TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
bool immutable) {
return GetClassName(descriptor, immutable, false);
@@ -226,13 +226,13 @@ TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descripto
TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
bool immutable, bool kotlin) {
TProtoStringType result = FileJavaPackage(descriptor, immutable);
- if (!result.empty()) result += '.';
+ if (!result.empty()) result += '.';
result += GetFileClassName(descriptor, immutable, kotlin);
- return result;
-}
-
-// Get the full name of a Java class by prepending the Java package name
-// or outer class name.
+ return result;
+}
+
+// Get the full name of a Java class by prepending the Java package name
+// or outer class name.
TProtoStringType ClassNameResolver::GetClassFullName(
const TProtoStringType& name_without_package, const FileDescriptor* file,
bool immutable, bool is_own_file) {
@@ -245,30 +245,30 @@ TProtoStringType ClassNameResolver::GetClassFullName(
bool immutable, bool is_own_file, bool kotlin) {
TProtoStringType result;
if (is_own_file) {
- result = FileJavaPackage(file, immutable);
- } else {
+ result = FileJavaPackage(file, immutable);
+ } else {
result = GetClassName(file, immutable, kotlin);
- }
- if (!result.empty()) {
- result += '.';
- }
- result += name_without_package;
+ }
+ if (!result.empty()) {
+ result += '.';
+ }
+ result += name_without_package;
if (kotlin) result += "Kt";
- return result;
-}
-
+ return result;
+}
+
TProtoStringType ClassNameResolver::GetClassName(const Descriptor* descriptor,
bool immutable) {
return GetClassName(descriptor, immutable, false);
-}
-
+}
+
TProtoStringType ClassNameResolver::GetClassName(const Descriptor* descriptor,
bool immutable, bool kotlin) {
return GetClassFullName(
ClassNameWithoutPackage(descriptor, immutable), descriptor->file(),
immutable, MultipleJavaFiles(descriptor->file(), immutable), kotlin);
-}
-
+}
+
TProtoStringType ClassNameResolver::GetClassName(const EnumDescriptor* descriptor,
bool immutable) {
return GetClassName(descriptor, immutable, false);
@@ -288,15 +288,15 @@ TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descri
TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descriptor,
bool immutable, bool kotlin) {
- return GetClassFullName(ClassNameWithoutPackage(descriptor, immutable),
- descriptor->file(), immutable,
+ return GetClassFullName(ClassNameWithoutPackage(descriptor, immutable),
+ descriptor->file(), immutable,
IsOwnFile(descriptor, immutable), kotlin);
-}
-
-// Get the Java Class style full name of a message.
+}
+
+// Get the Java Class style full name of a message.
TProtoStringType ClassNameResolver::GetJavaClassFullName(
const TProtoStringType& name_without_package, const FileDescriptor* file,
- bool immutable) {
+ bool immutable) {
return GetJavaClassFullName(name_without_package, file, immutable, false);
}
@@ -304,28 +304,28 @@ TProtoStringType ClassNameResolver::GetJavaClassFullName(
const TProtoStringType& name_without_package, const FileDescriptor* file,
bool immutable, bool kotlin) {
TProtoStringType result;
- if (MultipleJavaFiles(file, immutable)) {
- result = FileJavaPackage(file, immutable);
- if (!result.empty()) result += '.';
- } else {
+ if (MultipleJavaFiles(file, immutable)) {
+ result = FileJavaPackage(file, immutable);
+ if (!result.empty()) result += '.';
+ } else {
result = GetClassName(file, immutable, kotlin);
- if (!result.empty()) result += '$';
- }
- result += StringReplace(name_without_package, ".", "$", true);
- return result;
-}
-
+ if (!result.empty()) result += '$';
+ }
+ result += StringReplace(name_without_package, ".", "$", true);
+ return result;
+}
+
TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
- const FieldDescriptor* descriptor, bool immutable) {
+ const FieldDescriptor* descriptor, bool immutable) {
return GetExtensionIdentifierName(descriptor, immutable, false);
}
TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
const FieldDescriptor* descriptor, bool immutable, bool kotlin) {
return GetClassName(descriptor->containing_type(), immutable, kotlin) + "." +
- descriptor->name();
-}
-
+ descriptor->name();
+}
+
TProtoStringType ClassNameResolver::GetKotlinFactoryName(
const Descriptor* descriptor) {
TProtoStringType name = ToCamelCase(descriptor->name(), /* lower_first = */ true);
@@ -333,23 +333,23 @@ TProtoStringType ClassNameResolver::GetKotlinFactoryName(
}
TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
- const Descriptor* descriptor) {
+ const Descriptor* descriptor) {
return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, true),
descriptor->file(), true);
-}
-
+}
+
TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
- const EnumDescriptor* descriptor) {
+ const EnumDescriptor* descriptor) {
return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, true),
descriptor->file(), true);
-}
-
+}
+
TProtoStringType ClassNameResolver::GetKotlinExtensionsClassName(
const Descriptor* descriptor) {
return GetClassFullName(ClassNameWithoutPackageKotlin(descriptor),
descriptor->file(), true, true, true);
}
-
+
TProtoStringType ClassNameResolver::GetJavaMutableClassName(
const Descriptor* descriptor) {
return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, false),
@@ -374,7 +374,7 @@ TProtoStringType ClassNameResolver::GetDowngradedClassName(
ClassNameWithoutPackage(descriptor, false);
}
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
index 31b95900e4..180f3de630 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h
@@ -1,86 +1,86 @@
-// 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_JAVA_NAME_RESOLVER_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_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_JAVA_NAME_RESOLVER_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
+
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/common.h>
-
-namespace google {
-namespace protobuf {
-class Descriptor;
-class EnumDescriptor;
-class FieldDescriptor;
-class FileDescriptor;
-class ServiceDescriptor;
-
-namespace compiler {
-namespace java {
-
+
+namespace google {
+namespace protobuf {
+class Descriptor;
+class EnumDescriptor;
+class FieldDescriptor;
+class FileDescriptor;
+class ServiceDescriptor;
+
+namespace compiler {
+namespace java {
+
// Indicates how closely the two class names match.
enum NameEquality { NO_MATCH, EXACT_EQUAL, EQUAL_IGNORE_CASE };
-// Used to get the Java class related names for a given descriptor. It caches
-// the results to avoid redundant calculation across multiple name queries.
-// Thread-safety note: This class is *not* thread-safe.
-class ClassNameResolver {
- public:
- ClassNameResolver();
- ~ClassNameResolver();
-
- // Gets the unqualified outer class name for the file.
+// Used to get the Java class related names for a given descriptor. It caches
+// the results to avoid redundant calculation across multiple name queries.
+// Thread-safety note: This class is *not* thread-safe.
+class ClassNameResolver {
+ public:
+ ClassNameResolver();
+ ~ClassNameResolver();
+
+ // Gets the unqualified outer class name for the file.
TProtoStringType GetFileClassName(const FileDescriptor* file, bool immutable);
TProtoStringType GetFileClassName(const FileDescriptor* file, bool immutable,
bool kotlin);
- // Gets the unqualified immutable outer class name of a file.
+ // Gets the unqualified immutable outer class name of a file.
TProtoStringType GetFileImmutableClassName(const FileDescriptor* file);
- // Gets the unqualified default immutable outer class name of a file
- // (converted from the proto file's name).
+ // Gets the unqualified default immutable outer class name of a file
+ // (converted from the proto file's name).
TProtoStringType GetFileDefaultImmutableClassName(const FileDescriptor* file);
-
- // Check whether there is any type defined in the proto file that has
- // the given class name.
- bool HasConflictingClassName(const FileDescriptor* file,
+
+ // Check whether there is any type defined in the proto file that has
+ // the given class name.
+ bool HasConflictingClassName(const FileDescriptor* file,
const TProtoStringType& classname,
NameEquality equality_mode);
-
- // Gets the name of the outer class that holds descriptor information.
- // Descriptors are shared between immutable messages and mutable messages.
- // Since both of them are generated optionally, the descriptors need to be
- // put in another common place.
+
+ // Gets the name of the outer class that holds descriptor information.
+ // Descriptors are shared between immutable messages and mutable messages.
+ // Since both of them are generated optionally, the descriptors need to be
+ // put in another common place.
TProtoStringType GetDescriptorClassName(const FileDescriptor* file);
-
- // Gets the fully-qualified class name corresponding to the given descriptor.
+
+ // Gets the fully-qualified class name corresponding to the given descriptor.
TProtoStringType GetClassName(const Descriptor* descriptor, bool immutable);
TProtoStringType GetClassName(const Descriptor* descriptor, bool immutable,
bool kotlin);
@@ -93,26 +93,26 @@ class ClassNameResolver {
TProtoStringType GetClassName(const FileDescriptor* descriptor, bool immutable);
TProtoStringType GetClassName(const FileDescriptor* descriptor, bool immutable,
bool kotlin);
-
+
template <class DescriptorType>
TProtoStringType GetImmutableClassName(const DescriptorType* descriptor) {
- return GetClassName(descriptor, true);
- }
+ return GetClassName(descriptor, true);
+ }
template <class DescriptorType>
TProtoStringType GetMutableClassName(const DescriptorType* descriptor) {
- return GetClassName(descriptor, false);
- }
-
- // Gets the fully qualified name of an extension identifier.
+ return GetClassName(descriptor, false);
+ }
+
+ // Gets the fully qualified name of an extension identifier.
TProtoStringType GetExtensionIdentifierName(const FieldDescriptor* descriptor,
bool immutable);
TProtoStringType GetExtensionIdentifierName(const FieldDescriptor* descriptor,
bool immutable, bool kotlin);
-
- // Gets the fully qualified name for generated classes in Java convention.
- // Nested classes will be separated using '$' instead of '.'
- // For example:
- // com.package.OuterClass$OuterMessage$InnerMessage
+
+ // Gets the fully qualified name for generated classes in Java convention.
+ // Nested classes will be separated using '$' instead of '.'
+ // For example:
+ // com.package.OuterClass$OuterMessage$InnerMessage
TProtoStringType GetJavaImmutableClassName(const Descriptor* descriptor);
TProtoStringType GetJavaImmutableClassName(const EnumDescriptor* descriptor);
TProtoStringType GetKotlinFactoryName(const Descriptor* descriptor);
@@ -123,31 +123,31 @@ class ClassNameResolver {
TProtoStringType GetDowngradedFileClassName(const FileDescriptor* file);
TProtoStringType GetDowngradedClassName(const Descriptor* descriptor);
- private:
- // Get the full name of a Java class by prepending the Java package name
- // or outer class name.
+ private:
+ // Get the full name of a Java class by prepending the Java package name
+ // or outer class name.
TProtoStringType GetClassFullName(const TProtoStringType& name_without_package,
const FileDescriptor* file, bool immutable,
bool is_own_file);
TProtoStringType GetClassFullName(const TProtoStringType& name_without_package,
const FileDescriptor* file, bool immutable,
bool is_own_file, bool kotlin);
- // Get the Java Class style full name of a message.
+ // Get the Java Class style full name of a message.
TProtoStringType GetJavaClassFullName(const TProtoStringType& name_without_package,
const FileDescriptor* file, bool immutable);
TProtoStringType GetJavaClassFullName(const TProtoStringType& name_without_package,
const FileDescriptor* file, bool immutable,
bool kotlin);
- // Caches the result to provide better performance.
+ // Caches the result to provide better performance.
std::map<const FileDescriptor*, TProtoStringType>
file_immutable_outer_class_names_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h
index 838d63e814..9aeddc81cc 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h
@@ -1,85 +1,85 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Provides a mechanism for mapping a descriptor to the
-// fully-qualified name of the corresponding Java class.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Provides a mechanism for mapping a descriptor to the
+// fully-qualified name of the corresponding Java class.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
+
#include <string>
-
-namespace google {
-namespace protobuf {
-
-class Descriptor;
-class EnumDescriptor;
-class FileDescriptor;
+
+namespace google {
+namespace protobuf {
+
+class Descriptor;
+class EnumDescriptor;
+class FileDescriptor;
class FieldDescriptor;
-class ServiceDescriptor;
-
-namespace compiler {
-namespace java {
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The fully-qualified Java class name.
+class ServiceDescriptor;
+
+namespace compiler {
+namespace java {
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified Java class name.
TProtoStringType ClassName(const Descriptor* descriptor);
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The fully-qualified Java class name.
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified Java class name.
TProtoStringType ClassName(const EnumDescriptor* descriptor);
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The fully-qualified Java class name.
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified Java class name.
TProtoStringType ClassName(const FileDescriptor* descriptor);
-
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// The fully-qualified Java class name.
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// The fully-qualified Java class name.
TProtoStringType ClassName(const ServiceDescriptor* descriptor);
-
+
// Requires:
// descriptor != NULL
//
@@ -93,8 +93,8 @@ TProtoStringType FileJavaPackage(const FileDescriptor* descriptor);
// Capitalized camel case name field name.
TProtoStringType CapitalizedFieldName(const FieldDescriptor* descriptor);
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h
index be0d2a9e02..1454c23206 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h
@@ -1,73 +1,73 @@
-// 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_JAVA_OPTIONS_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
+
#include <string>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-// Generator options
-struct Options {
- Options()
- : generate_immutable_code(false),
- generate_mutable_code(false),
- generate_shared_code(false),
- enforce_lite(false),
- annotate_code(false) {
- }
-
- bool generate_immutable_code;
- bool generate_mutable_code;
- bool generate_shared_code;
- // When set, the protoc will generate the current files and all the transitive
- // dependencies as lite runtime.
- bool enforce_lite;
- // If true, we should build .meta files and emit @Generated annotations into
- // generated code.
- bool annotate_code;
- // Name of a file where we will write a list of generated .meta file names,
- // one per line.
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+// Generator options
+struct Options {
+ Options()
+ : generate_immutable_code(false),
+ generate_mutable_code(false),
+ generate_shared_code(false),
+ enforce_lite(false),
+ annotate_code(false) {
+ }
+
+ bool generate_immutable_code;
+ bool generate_mutable_code;
+ bool generate_shared_code;
+ // When set, the protoc will generate the current files and all the transitive
+ // dependencies as lite runtime.
+ bool enforce_lite;
+ // If true, we should build .meta files and emit @Generated annotations into
+ // generated code.
+ bool annotate_code;
+ // Name of a file where we will write a list of generated .meta file names,
+ // one per line.
TProtoStringType annotation_list_file;
- // Name of a file where we will write a list of generated file names, one
- // per line.
+ // Name of a file where we will write a list of generated file names, one
+ // per line.
TProtoStringType output_list_file;
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc
index fc69e2d8a4..ab550761b1 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_primitive_field.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -47,28 +47,28 @@
#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 java {
-
-using internal::WireFormat;
-
-namespace {
-
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+
+namespace {
+
+void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ const FieldGeneratorInfo* info,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
+ SetCommonFieldVariables(descriptor, info, variables);
JavaType javaType = GetJavaType(descriptor);
-
+
(*variables)["type"] = PrimitiveTypeName(javaType);
(*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
(*variables)["kt_type"] = KotlinTypeName(javaType);
- (*variables)["field_type"] = (*variables)["type"];
+ (*variables)["field_type"] = (*variables)["type"];
if (javaType == JAVATYPE_BOOLEAN || javaType == JAVATYPE_DOUBLE ||
javaType == JAVATYPE_FLOAT || javaType == JAVATYPE_INT ||
@@ -106,27 +106,27 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["repeated_set"] = (*variables)["name"] + "_.set";
}
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_init"] =
IsDefaultValueJavaDefault(descriptor)
? ""
: ("= " + ImmutableDefaultValue(descriptor, name_resolver));
- (*variables)["capitalized_type"] =
- GetCapitalizedType(descriptor, /* immutable = */ true);
+ (*variables)["capitalized_type"] =
+ GetCapitalizedType(descriptor, /* immutable = */ true);
(*variables)["tag"] =
StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = StrCat(
- WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
- if (IsReferenceType(GetJavaType(descriptor))) {
- (*variables)["null_check"] =
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n";
- } else {
- (*variables)["null_check"] = "";
- }
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ if (IsReferenceType(GetJavaType(descriptor))) {
+ (*variables)["null_check"] =
+ " if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ " }\n";
+ } else {
+ (*variables)["null_check"] = "";
+ }
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -134,96 +134,96 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
- int fixed_size = FixedSize(GetType(descriptor));
- if (fixed_size != -1) {
+ int fixed_size = FixedSize(GetType(descriptor));
+ if (fixed_size != -1) {
(*variables)["fixed_size"] = StrCat(fixed_size);
- }
- (*variables)["on_changed"] = "onChanged();";
-
+ }
+ (*variables)["on_changed"] = "onChanged();";
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
- if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {
- (*variables)["is_field_present_message"] =
- "!" + (*variables)["name"] + "_.isEmpty()";
- } else {
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"];
- }
- }
-
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["set_has_field_bit_builder"] =
+ GenerateSetBit(builderBitIndex) + ";";
+ (*variables)["clear_has_field_bit_builder"] =
+ GenerateClearBit(builderBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["set_has_field_bit_builder"] = "";
+ (*variables)["clear_has_field_bit_builder"] = "";
+
+ if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {
+ (*variables)["is_field_present_message"] =
+ "!" + (*variables)["name"] + "_.isEmpty()";
+ } else {
+ (*variables)["is_field_present_message"] =
+ (*variables)["name"] + "_ != " + (*variables)["default"];
+ }
+ }
+
// For repeated builders, one bit is used for whether the array is immutable.
- (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
- (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
- (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
-
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-}
-
-} // namespace
-
-// ===================================================================
-
+ (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
+ (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
+
+ // For repeated fields, one bit is used for whether the array is immutable
+ // in the parsing constructor.
+ (*variables)["get_mutable_bit_parser"] =
+ GenerateGetBitMutableLocal(builderBitIndex);
+ (*variables)["set_mutable_bit_parser"] =
+ GenerateSetBitMutableLocal(builderBitIndex);
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutablePrimitiveFieldGenerator::ImmutablePrimitiveFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {}
-
-int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
+ SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {}
+
+int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
-int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
+}
+
+int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
return GetNumBitsForMessage();
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$boolean has$capitalized_name$();\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private $field_type$ $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -233,21 +233,21 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
printer->Print(variables_, "private $field_type$ $name$_ $default_init$;\n");
-
+
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -257,19 +257,19 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
" return $get_has_field_bit_builder$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
"$null_check$"
@@ -279,7 +279,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ true);
printer->Print(
@@ -287,22 +287,22 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
" $clear_has_field_bit_builder$\n");
printer->Annotate("{", "}", descriptor_);
- JavaType type = GetJavaType(descriptor_);
- if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {
- // The default value is not a simple literal so we want to avoid executing
- // it multiple times. Instead, get the default out of the default instance.
+ JavaType type = GetJavaType(descriptor_);
+ if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {
+ // The default value is not a simple literal so we want to avoid executing
+ // it multiple times. Instead, get the default out of the default instance.
printer->Print(
variables_,
" $name$_ = getDefaultInstance().get$capitalized_name$();\n");
- } else {
+ } else {
printer->Print(variables_, " $name$_ = $default$;\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" $on_changed$\n"
" return this;\n"
"}\n");
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -333,38 +333,38 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
void ImmutablePrimitiveFieldGenerator::GenerateFieldBuilderInitializationCode(
io::Printer* printer) const {
- // noop for primitives
-}
-
+ // noop for primitives
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
if (!IsDefaultValueJavaDefault(descriptor_)) {
printer->Print(variables_, "$name$_ = $default$;\n");
}
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$name$_ = $default$;\n"
"$clear_has_field_bit_builder$\n");
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (other.has$capitalized_name$()) {\n"
" set$capitalized_name$(other.get$capitalized_name$());\n"
"}\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"if (other.get$capitalized_name$() != $default$) {\n"
" set$capitalized_name$(other.get$capitalized_name$());\n"
"}\n");
- }
-}
-
+ }
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
@@ -383,154 +383,154 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
}
} else {
printer->Print(variables_, "result.$name$_ = $name$_;\n");
- }
-}
-
+ }
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$set_has_field_bit_message$\n"
"$name$_ = input.read$capitalized_type$();\n");
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- // noop for primitives.
-}
-
+ // noop for primitives.
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($is_field_present_message$) {\n"
" output.write$capitalized_type$($number$, $name$_);\n"
"}\n");
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($is_field_present_message$) {\n"
" size += com.google.protobuf.CodedOutputStream\n"
" .compute$capitalized_type$Size($number$, $name$_);\n"
"}\n");
-}
-
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
- switch (GetJavaType(descriptor_)) {
- case JAVATYPE_INT:
- case JAVATYPE_LONG:
- case JAVATYPE_BOOLEAN:
- printer->Print(variables_,
+ switch (GetJavaType(descriptor_)) {
+ case JAVATYPE_INT:
+ case JAVATYPE_LONG:
+ case JAVATYPE_BOOLEAN:
+ printer->Print(variables_,
"if (get$capitalized_name$()\n"
" != other.get$capitalized_name$()) return false;\n");
- break;
-
- case JAVATYPE_FLOAT:
+ break;
+
+ case JAVATYPE_FLOAT:
printer->Print(
variables_,
"if (java.lang.Float.floatToIntBits(get$capitalized_name$())\n"
" != java.lang.Float.floatToIntBits(\n"
" other.get$capitalized_name$())) return false;\n");
- break;
-
- case JAVATYPE_DOUBLE:
+ break;
+
+ case JAVATYPE_DOUBLE:
printer->Print(
variables_,
"if (java.lang.Double.doubleToLongBits(get$capitalized_name$())\n"
" != java.lang.Double.doubleToLongBits(\n"
" other.get$capitalized_name$())) return false;\n");
- break;
-
- case JAVATYPE_STRING:
- case JAVATYPE_BYTES:
+ break;
+
+ case JAVATYPE_STRING:
+ case JAVATYPE_BYTES:
printer->Print(
variables_,
"if (!get$capitalized_name$()\n"
" .equals(other.get$capitalized_name$())) return false;\n");
- break;
-
- case JAVATYPE_ENUM:
- case JAVATYPE_MESSAGE:
- default:
- GOOGLE_LOG(FATAL) << "Can't get here.";
- break;
- }
-}
-
+ break;
+
+ case JAVATYPE_ENUM:
+ case JAVATYPE_MESSAGE:
+ default:
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ break;
+ }
+}
+
void ImmutablePrimitiveFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
printer->Print(variables_, "hash = (37 * hash) + $constant_name$;\n");
- switch (GetJavaType(descriptor_)) {
- case JAVATYPE_INT:
- printer->Print(variables_,
+ switch (GetJavaType(descriptor_)) {
+ case JAVATYPE_INT:
+ printer->Print(variables_,
"hash = (53 * hash) + get$capitalized_name$();\n");
- break;
-
- case JAVATYPE_LONG:
+ break;
+
+ case JAVATYPE_LONG:
printer->Print(
variables_,
"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
" get$capitalized_name$());\n");
- break;
-
- case JAVATYPE_BOOLEAN:
+ break;
+
+ case JAVATYPE_BOOLEAN:
printer->Print(
variables_,
"hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\n"
" get$capitalized_name$());\n");
- break;
-
- case JAVATYPE_FLOAT:
- printer->Print(variables_,
+ break;
+
+ case JAVATYPE_FLOAT:
+ printer->Print(variables_,
"hash = (53 * hash) + java.lang.Float.floatToIntBits(\n"
" get$capitalized_name$());\n");
- break;
-
- case JAVATYPE_DOUBLE:
+ break;
+
+ case JAVATYPE_DOUBLE:
printer->Print(
variables_,
"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
" java.lang.Double.doubleToLongBits(get$capitalized_name$()));\n");
- break;
-
- case JAVATYPE_STRING:
- case JAVATYPE_BYTES:
+ break;
+
+ case JAVATYPE_STRING:
+ case JAVATYPE_BYTES:
printer->Print(
variables_,
"hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
- break;
-
- case JAVATYPE_ENUM:
- case JAVATYPE_MESSAGE:
- default:
- GOOGLE_LOG(FATAL) << "Can't get here.";
- break;
- }
-}
-
+ break;
+
+ case JAVATYPE_ENUM:
+ case JAVATYPE_MESSAGE:
+ default:
+ GOOGLE_LOG(FATAL) << "Can't get here.";
+ break;
+ }
+}
+
TProtoStringType ImmutablePrimitiveFieldGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
-}
-
-// ===================================================================
-
+ return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+}
+
+// ===================================================================
+
ImmutablePrimitiveOneofFieldGenerator::ImmutablePrimitiveOneofFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: ImmutablePrimitiveFieldGenerator(descriptor, messageBitIndex,
builderBitIndex, context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
-ImmutablePrimitiveOneofFieldGenerator::
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
+ImmutablePrimitiveOneofFieldGenerator::
~ImmutablePrimitiveOneofFieldGenerator() {}
-
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
@@ -539,9 +539,9 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
@@ -550,20 +550,20 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
" return $default$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
" return ($boxed_type$) $oneof_name$_;\n"
@@ -571,10 +571,10 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
" return $default$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
"$null_check$"
@@ -598,32 +598,32 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" result.$oneof_name$_ = $oneof_name$_;\n"
"}\n");
-}
-
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"set$capitalized_name$(other.get$capitalized_name$());\n");
-}
-
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$set_oneof_case_message$;\n"
"$oneof_name$_ = input.read$capitalized_type$();\n");
-}
-
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" output.write$capitalized_type$(\n");
// $type$ and $boxed_type$ is the same for bytes fields so we don't need to
@@ -636,11 +636,11 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializationCode(
" $number$, ($type$)(($boxed_type$) $oneof_name$_));\n");
}
printer->Print("}\n");
-}
-
+}
+
void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" size += com.google.protobuf.CodedOutputStream\n"
" .compute$capitalized_type$Size(\n");
@@ -654,52 +654,52 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializedSizeCode(
" $number$, ($type$)(($boxed_type$) $oneof_name$_));\n");
}
printer->Print("}\n");
-}
-
-// ===================================================================
-
-RepeatedImmutablePrimitiveFieldGenerator::
+}
+
+// ===================================================================
+
+RepeatedImmutablePrimitiveFieldGenerator::
RepeatedImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-RepeatedImmutablePrimitiveFieldGenerator::
+ SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+RepeatedImmutablePrimitiveFieldGenerator::
~RepeatedImmutablePrimitiveFieldGenerator() {}
-
-int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
-int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
- return 1;
-}
-
+
+int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
+int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
+ return 1;
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.util.List<$boxed_type$> "
"get$capitalized_name$List();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$$type$ get$capitalized_name$(int index);\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private $field_list_type$ $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$boxed_type$>\n"
" ${$get$capitalized_name$List$}$() {\n"
@@ -720,35 +720,35 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers(
" return $repeated_get$(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
if (descriptor_->is_packed()) {
- printer->Print(variables_,
+ printer->Print(variables_,
"private int $name$MemoizedSerializedSize = -1;\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // One field is the list and the bit field keeps track of whether the
- // list is immutable. If it's immutable, the invariant is that it must
- // either an instance of Collections.emptyList() or it's an ArrayList
- // wrapped in a Collections.unmodifiableList() wrapper and nobody else has
+ // One field is the list and the bit field keeps track of whether the
+ // list is immutable. If it's immutable, the invariant is that it must
+ // either an instance of Collections.emptyList() or it's an ArrayList
+ // wrapped in a Collections.unmodifiableList() wrapper and nobody else has
// a reference to the underlying ArrayList. This invariant allows us to
- // share instances of lists between protocol buffers avoiding expensive
- // memory allocations. Note, immutable is a strong guarantee here -- not
- // just that the list cannot be modified via the reference but that the
- // list can never be modified.
- printer->Print(variables_,
+ // share instances of lists between protocol buffers avoiding expensive
+ // memory allocations. Note, immutable is a strong guarantee here -- not
+ // just that the list cannot be modified via the reference but that the
+ // list can never be modified.
+ printer->Print(variables_,
"private $field_list_type$ $name$_ = $empty_list$;\n");
-
- printer->Print(variables_,
+
+ printer->Print(variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
" if (!$get_mutable_bit_builder$) {\n"
" $name$_ = $mutable_copy_list$;\n"
" $set_mutable_bit_builder$;\n"
" }\n"
"}\n");
-
+
// Note: We return an unmodifiable list because otherwise the caller
// could hold on to the returned list and modify it after the message
// has been built, thus mutating the message which is supposed to be
@@ -778,7 +778,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
"$null_check$"
@@ -790,7 +790,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$$}$($type$ value) {\n"
"$null_check$"
@@ -802,7 +802,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<? extends $boxed_type$> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -823,8 +823,8 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -917,31 +917,31 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
"}");
}
-void RepeatedImmutablePrimitiveFieldGenerator::
+void RepeatedImmutablePrimitiveFieldGenerator::
GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
- // noop for primitives
-}
-
+ // noop for primitives
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $empty_list$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $empty_list$;\n");
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$name$_ = $empty_list$;\n"
"$clear_mutable_bit_builder$;\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- // The code below does two optimizations:
- // 1. If the other list is empty, there's nothing to do. This ensures we
- // don't allocate a new array if we already have an immutable one.
- // 2. If the other list is non-empty and our current list is empty, we can
- // reuse the other list which is guaranteed to be immutable.
- printer->Print(variables_,
+ // The code below does two optimizations:
+ // 1. If the other list is empty, there's nothing to do. This ensures we
+ // don't allocate a new array if we already have an immutable one.
+ // 2. If the other list is non-empty and our current list is empty, we can
+ // reuse the other list which is guaranteed to be immutable.
+ printer->Print(variables_,
"if (!other.$name$_.isEmpty()) {\n"
" if ($name$_.isEmpty()) {\n"
" $name$_ = other.$name$_;\n"
@@ -952,30 +952,30 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateMergingCode(
" }\n"
" $on_changed$\n"
"}\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- // The code below ensures that the result has an immutable list. If our
- // list is immutable, we can just reuse it. If not, we make it immutable.
- printer->Print(variables_,
+ // The code below ensures that the result has an immutable list. If our
+ // list is immutable, we can just reuse it. If not, we make it immutable.
+ printer->Print(variables_,
"if ($get_mutable_bit_builder$) {\n"
" $name_make_immutable$;\n"
" $clear_mutable_bit_builder$;\n"
"}\n"
"result.$name$_ = $name$_;\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (!$get_mutable_bit_parser$) {\n"
" $name$_ = $create_list$;\n"
" $set_mutable_bit_parser$;\n"
"}\n"
"$repeated_add$(input.read$capitalized_type$());\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCodeFromPacked(
io::Printer* printer) const {
printer->Print(
@@ -990,23 +990,23 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCodeFromPacked(
" $repeated_add$(input.read$capitalized_type$());\n"
"}\n"
"input.popLimit(limit);\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($get_mutable_bit_parser$) {\n"
" $name_make_immutable$; // C\n"
"}\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- if (descriptor_->is_packed()) {
- // We invoke getSerializedSize in writeTo for messages that have packed
- // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods.
- // That makes it safe to rely on the memoized size here.
- printer->Print(variables_,
+ if (descriptor_->is_packed()) {
+ // We invoke getSerializedSize in writeTo for messages that have packed
+ // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods.
+ // That makes it safe to rely on the memoized size here.
+ printer->Print(variables_,
"if (get$capitalized_name$List().size() > 0) {\n"
" output.writeUInt32NoTag($tag$);\n"
" output.writeUInt32NoTag($name$MemoizedSerializedSize);\n"
@@ -1014,67 +1014,67 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.write$capitalized_type$NoTag($repeated_get$(i));\n"
"}\n");
- } else {
+ } else {
printer->Print(
variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.write$capitalized_type$($number$, $repeated_get$(i));\n"
"}\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"{\n"
" int dataSize = 0;\n");
- printer->Indent();
-
- if (FixedSize(GetType(descriptor_)) == -1) {
+ printer->Indent();
+
+ if (FixedSize(GetType(descriptor_)) == -1) {
printer->Print(
variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" dataSize += com.google.protobuf.CodedOutputStream\n"
" .compute$capitalized_type$SizeNoTag($repeated_get$(i));\n"
"}\n");
- } else {
+ } else {
printer->Print(
variables_,
"dataSize = $fixed_size$ * get$capitalized_name$List().size();\n");
- }
-
+ }
+
printer->Print("size += dataSize;\n");
-
- if (descriptor_->is_packed()) {
- printer->Print(variables_,
+
+ if (descriptor_->is_packed()) {
+ printer->Print(variables_,
"if (!get$capitalized_name$List().isEmpty()) {\n"
" size += $tag_size$;\n"
" size += com.google.protobuf.CodedOutputStream\n"
" .computeInt32SizeNoTag(dataSize);\n"
"}\n");
- } else {
+ } else {
printer->Print(
variables_,
"size += $tag_size$ * get$capitalized_name$List().size();\n");
- }
-
- // cache the data size for packed fields.
- if (descriptor_->is_packed()) {
+ }
+
+ // cache the data size for packed fields.
+ if (descriptor_->is_packed()) {
printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n");
- }
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
+ }
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
printer->Print(
variables_,
"if (!get$capitalized_name$List()\n"
" .equals(other.get$capitalized_name$List())) return false;\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
printer->Print(
@@ -1083,13 +1083,13 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateHashCode(
" hash = (37 * hash) + $constant_name$;\n"
" hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
"}\n");
-}
-
+}
+
TProtoStringType RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
index 3eaf87810a..b90ea89257 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -49,20 +49,20 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
+ public:
explicit ImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex,
Context* context);
~ImmutablePrimitiveFieldGenerator() override;
-
+
// implements ImmutableFieldGenerator
// ---------------------------------------
int GetNumBitsForMessage() const override;
@@ -83,47 +83,47 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldGenerator);
-};
-
-class ImmutablePrimitiveOneofFieldGenerator
- : public ImmutablePrimitiveFieldGenerator {
- public:
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldGenerator);
+};
+
+class ImmutablePrimitiveOneofFieldGenerator
+ : public ImmutablePrimitiveFieldGenerator {
+ public:
ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex, Context* context);
- ~ImmutablePrimitiveOneofFieldGenerator();
-
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateBuildingCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateParsingCode(io::Printer* printer) const;
- void GenerateSerializationCode(io::Printer* printer) const;
- void GenerateSerializedSizeCode(io::Printer* printer) const;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldGenerator);
-};
-
-class RepeatedImmutablePrimitiveFieldGenerator
- : public ImmutableFieldGenerator {
- public:
- explicit RepeatedImmutablePrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, Context* context);
+ ~ImmutablePrimitiveOneofFieldGenerator();
+
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateBuildingCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateParsingCode(io::Printer* printer) const;
+ void GenerateSerializationCode(io::Printer* printer) const;
+ void GenerateSerializedSizeCode(io::Printer* printer) const;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldGenerator);
+};
+
+class RepeatedImmutablePrimitiveFieldGenerator
+ : public ImmutableFieldGenerator {
+ public:
+ explicit RepeatedImmutablePrimitiveFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, Context* context);
~RepeatedImmutablePrimitiveFieldGenerator() override;
-
- // implements ImmutableFieldGenerator ---------------------------------------
+
+ // implements ImmutableFieldGenerator ---------------------------------------
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -143,20 +143,20 @@ class RepeatedImmutablePrimitiveFieldGenerator
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
+
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index 4a33227ea1..35f78fce9e 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_primitive_field_lite.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -47,16 +47,16 @@
#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 java {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-namespace {
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+namespace {
bool EnableExperimentalRuntimeForLite() {
#ifdef PROTOBUF_EXPERIMENT
return PROTOBUF_EXPERIMENT;
@@ -64,78 +64,78 @@ bool EnableExperimentalRuntimeForLite() {
return false;
#endif // !PROTOBUF_EXPERIMENT
}
-
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
+
+void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ const FieldGeneratorInfo* info,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
- JavaType javaType = GetJavaType(descriptor);
- (*variables)["type"] = PrimitiveTypeName(javaType);
- (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
+ SetCommonFieldVariables(descriptor, info, variables);
+ JavaType javaType = GetJavaType(descriptor);
+ (*variables)["type"] = PrimitiveTypeName(javaType);
+ (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
(*variables)["kt_type"] = KotlinTypeName(javaType);
- (*variables)["field_type"] = (*variables)["type"];
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["capitalized_type"] =
- GetCapitalizedType(descriptor, /* immutable = */ true);
+ (*variables)["field_type"] = (*variables)["type"];
+ (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["capitalized_type"] =
+ GetCapitalizedType(descriptor, /* immutable = */ true);
(*variables)["tag"] =
StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = StrCat(
- WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
-
+
TProtoStringType capitalized_type = UnderscoresToCamelCase(
PrimitiveTypeName(javaType), true /* cap_next_letter */);
- switch (javaType) {
- case JAVATYPE_INT:
- case JAVATYPE_LONG:
- case JAVATYPE_FLOAT:
- case JAVATYPE_DOUBLE:
- case JAVATYPE_BOOLEAN:
- (*variables)["field_list_type"] =
- "com.google.protobuf.Internal." + capitalized_type + "List";
- (*variables)["empty_list"] = "empty" + capitalized_type + "List()";
- (*variables)["make_name_unmodifiable"] =
- (*variables)["name"] + "_.makeImmutable()";
- (*variables)["repeated_get"] =
- (*variables)["name"] + "_.get" + capitalized_type;
- (*variables)["repeated_add"] =
- (*variables)["name"] + "_.add" + capitalized_type;
- (*variables)["repeated_set"] =
- (*variables)["name"] + "_.set" + capitalized_type;
- (*variables)["visit_type"] = capitalized_type;
- (*variables)["visit_type_list"] = "visit" + capitalized_type + "List";
- break;
- default:
- (*variables)["field_list_type"] =
- "com.google.protobuf.Internal.ProtobufList<" +
- (*variables)["boxed_type"] + ">";
- (*variables)["empty_list"] = "emptyProtobufList()";
- (*variables)["make_name_unmodifiable"] =
- (*variables)["name"] + "_.makeImmutable()";
- (*variables)["repeated_get"] = (*variables)["name"] + "_.get";
- (*variables)["repeated_add"] = (*variables)["name"] + "_.add";
- (*variables)["repeated_set"] = (*variables)["name"] + "_.set";
- (*variables)["visit_type"] = "ByteString";
- (*variables)["visit_type_list"] = "visitList";
- }
-
- if (javaType == JAVATYPE_BYTES) {
- (*variables)["bytes_default"] =
- ToUpper((*variables)["name"]) + "_DEFAULT_VALUE";
- }
-
- if (IsReferenceType(javaType)) {
+ switch (javaType) {
+ case JAVATYPE_INT:
+ case JAVATYPE_LONG:
+ case JAVATYPE_FLOAT:
+ case JAVATYPE_DOUBLE:
+ case JAVATYPE_BOOLEAN:
+ (*variables)["field_list_type"] =
+ "com.google.protobuf.Internal." + capitalized_type + "List";
+ (*variables)["empty_list"] = "empty" + capitalized_type + "List()";
+ (*variables)["make_name_unmodifiable"] =
+ (*variables)["name"] + "_.makeImmutable()";
+ (*variables)["repeated_get"] =
+ (*variables)["name"] + "_.get" + capitalized_type;
+ (*variables)["repeated_add"] =
+ (*variables)["name"] + "_.add" + capitalized_type;
+ (*variables)["repeated_set"] =
+ (*variables)["name"] + "_.set" + capitalized_type;
+ (*variables)["visit_type"] = capitalized_type;
+ (*variables)["visit_type_list"] = "visit" + capitalized_type + "List";
+ break;
+ default:
+ (*variables)["field_list_type"] =
+ "com.google.protobuf.Internal.ProtobufList<" +
+ (*variables)["boxed_type"] + ">";
+ (*variables)["empty_list"] = "emptyProtobufList()";
+ (*variables)["make_name_unmodifiable"] =
+ (*variables)["name"] + "_.makeImmutable()";
+ (*variables)["repeated_get"] = (*variables)["name"] + "_.get";
+ (*variables)["repeated_add"] = (*variables)["name"] + "_.add";
+ (*variables)["repeated_set"] = (*variables)["name"] + "_.set";
+ (*variables)["visit_type"] = "ByteString";
+ (*variables)["visit_type_list"] = "visitList";
+ }
+
+ if (javaType == JAVATYPE_BYTES) {
+ (*variables)["bytes_default"] =
+ ToUpper((*variables)["name"]) + "_DEFAULT_VALUE";
+ }
+
+ if (IsReferenceType(javaType)) {
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["null_check"] =
" java.lang.Class<?> valueClass = value.getClass();\n";
- } else {
- (*variables)["null_check"] = "";
- }
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+ } else {
+ (*variables)["null_check"] = "";
+ }
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -143,84 +143,84 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
- int fixed_size = FixedSize(GetType(descriptor));
- if (fixed_size != -1) {
+ int fixed_size = FixedSize(GetType(descriptor));
+ if (fixed_size != -1) {
(*variables)["fixed_size"] = StrCat(fixed_size);
- }
-
+ }
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["clear_has_field_bit_message"] = "";
-
- if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {
- (*variables)["is_field_present_message"] =
- "!" + (*variables)["name"] + "_.isEmpty()";
- } else {
- (*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"];
- }
- }
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-}
-
-} // namespace
-
-// ===================================================================
-
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["clear_has_field_bit_message"] =
+ GenerateClearBit(messageBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["clear_has_field_bit_message"] = "";
+
+ if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {
+ (*variables)["is_field_present_message"] =
+ "!" + (*variables)["name"] + "_.isEmpty()";
+ } else {
+ (*variables)["is_field_present_message"] =
+ (*variables)["name"] + "_ != " + (*variables)["default"];
+ }
+ }
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutablePrimitiveFieldLiteGenerator::ImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
messageBitIndex_(messageBitIndex),
name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-ImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {}
-
-int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+ImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {}
+
+int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
+}
+
void ImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$boolean has$capitalized_name$();\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
-}
-
+}
+
void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
- if (IsByteStringWithCustomDefaultValue(descriptor_)) {
- // allocate this once statically since we know ByteStrings are immutable
- // values that can be reused.
- printer->Print(
- variables_,
- "private static final $field_type$ $bytes_default$ = $default$;\n");
- }
+ if (IsByteStringWithCustomDefaultValue(descriptor_)) {
+ // allocate this once statically since we know ByteStrings are immutable
+ // values that can be reused.
+ printer->Print(
+ variables_,
+ "private static final $field_type$ $bytes_default$ = $default$;\n");
+ }
printer->Print(variables_, "private $field_type$ $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -230,41 +230,41 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return $name$_;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$($type$ value) {\n"
"$null_check$"
" $set_has_field_bit_message$\n"
" $name$_ = value;\n"
"}\n");
-
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $clear_has_field_bit_message$\n");
- JavaType type = GetJavaType(descriptor_);
- if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {
- // The default value is not a simple literal so we want to avoid executing
- // it multiple times. Instead, get the default out of the default instance.
+ JavaType type = GetJavaType(descriptor_);
+ if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {
+ // The default value is not a simple literal so we want to avoid executing
+ // it multiple times. Instead, get the default out of the default instance.
printer->Print(
variables_,
" $name$_ = getDefaultInstance().get$capitalized_name$();\n");
- } else {
+ } else {
printer->Print(variables_, " $name$_ = $default$;\n");
- }
+ }
printer->Print(variables_, "}\n");
-}
-
+}
+
void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
@@ -276,19 +276,19 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return instance.get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -296,7 +296,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ true);
printer->Print(
@@ -307,8 +307,8 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -346,40 +346,40 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo(
WriteIntToUtf16CharSequence(messageBitIndex_, output);
}
printer->Print(variables_, "\"$name$_\",\n");
-}
-
+}
+
void ImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- if (IsByteStringWithCustomDefaultValue(descriptor_)) {
- printer->Print(variables_, "$name$_ = $bytes_default$;\n");
- } else if (!IsDefaultValueJavaDefault(descriptor_)) {
- printer->Print(variables_, "$name$_ = $default$;\n");
- }
-}
-
+ if (IsByteStringWithCustomDefaultValue(descriptor_)) {
+ printer->Print(variables_, "$name$_ = $bytes_default$;\n");
+ } else if (!IsDefaultValueJavaDefault(descriptor_)) {
+ printer->Print(variables_, "$name$_ = $default$;\n");
+ }
+}
+
TProtoStringType ImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
-}
-
-// ===================================================================
-
-ImmutablePrimitiveOneofFieldLiteGenerator::
+ return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+}
+
+// ===================================================================
+
+ImmutablePrimitiveOneofFieldLiteGenerator::
ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context)
: ImmutablePrimitiveFieldLiteGenerator(descriptor, messageBitIndex,
context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
-ImmutablePrimitiveOneofFieldLiteGenerator::
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
+ImmutablePrimitiveOneofFieldLiteGenerator::
~ImmutablePrimitiveOneofFieldLiteGenerator() {}
-
+
void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
@@ -388,9 +388,9 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers(
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
@@ -399,25 +399,25 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers(
" return $default$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$($type$ value) {\n"
"$null_check$"
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value;\n"
"}\n");
-
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
" $oneof_name$_ = null;\n"
" }\n"
"}\n");
-}
-
+}
+
void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -425,29 +425,29 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo(
output);
WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
}
-
+
void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
" return instance.get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$set$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -455,7 +455,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ true);
printer->Print(
@@ -466,11 +466,11 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
-// ===================================================================
-
-RepeatedImmutablePrimitiveFieldLiteGenerator::
+}
+
+// ===================================================================
+
+RepeatedImmutablePrimitiveFieldLiteGenerator::
RepeatedImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
Context* context)
@@ -478,37 +478,37 @@ RepeatedImmutablePrimitiveFieldLiteGenerator::
context_(context),
name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-RepeatedImmutablePrimitiveFieldLiteGenerator::
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+RepeatedImmutablePrimitiveFieldLiteGenerator::
~RepeatedImmutablePrimitiveFieldLiteGenerator() {}
-
-int RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
+
+int RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.util.List<$boxed_type$> "
"get$capitalized_name$List();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$$type$ get$capitalized_name$(int index);\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private $field_list_type$ $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$boxed_type$>\n"
" ${$get$capitalized_name$List$}$() {\n"
@@ -531,13 +531,13 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
" return $repeated_get$(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() &&
- context_->HasGeneratedMethods(descriptor_->containing_type())) {
- printer->Print(variables_,
+ context_->HasGeneratedMethods(descriptor_->containing_type())) {
+ printer->Print(variables_,
"private int $name$MemoizedSerializedSize = -1;\n");
- }
-
+ }
+
printer->Print(
variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
@@ -548,9 +548,9 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
" com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
" }\n"
"}\n");
-
+
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$(\n"
" int index, $type$ value) {\n"
"$null_check$"
@@ -558,14 +558,14 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
" $repeated_set$(index, value);\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void add$capitalized_name$($type$ value) {\n"
"$null_check$"
" ensure$capitalized_name$IsMutable();\n"
" $repeated_add$(value);\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void addAll$capitalized_name$(\n"
" java.lang.Iterable<? extends $boxed_type$> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -573,16 +573,16 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
" values, $name$_);\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $name$_ = $empty_list$;\n"
"}\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<$boxed_type$>\n"
" ${$get$capitalized_name$List$}$() {\n"
@@ -608,7 +608,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, $type$ value) {\n"
" copyOnWrite();\n"
@@ -618,7 +618,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder "
"${$add$capitalized_name$$}$($type$ value) {\n"
" copyOnWrite();\n"
@@ -628,7 +628,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<? extends $boxed_type$> values) {\n"
" copyOnWrite();\n"
@@ -646,8 +646,8 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -746,18 +746,18 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo(
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
output);
printer->Print(variables_, "\"$name$_\",\n");
-}
-
+}
+
void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $empty_list$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $empty_list$;\n");
+}
+
TProtoStringType RepeatedImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h
index 32f113e0f2..1359c358df 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
+
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -51,19 +51,19 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutablePrimitiveFieldLiteGenerator
- : public ImmutableFieldLiteGenerator {
- public:
- explicit ImmutablePrimitiveFieldLiteGenerator(
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutablePrimitiveFieldLiteGenerator
+ : public ImmutableFieldLiteGenerator {
+ public:
+ explicit ImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
~ImmutablePrimitiveFieldLiteGenerator() override;
-
+
// implements ImmutableFieldLiteGenerator
// ------------------------------------
int GetNumBitsForMessage() const override;
@@ -74,45 +74,45 @@ class ImmutablePrimitiveFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
- protected:
- const FieldDescriptor* descriptor_;
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- const int messageBitIndex_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldLiteGenerator);
-};
-
-class ImmutablePrimitiveOneofFieldLiteGenerator
- : public ImmutablePrimitiveFieldLiteGenerator {
- public:
+ const int messageBitIndex_;
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldLiteGenerator);
+};
+
+class ImmutablePrimitiveOneofFieldLiteGenerator
+ : public ImmutablePrimitiveFieldLiteGenerator {
+ public:
ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
- ~ImmutablePrimitiveOneofFieldLiteGenerator();
-
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
-
+ ~ImmutablePrimitiveOneofFieldLiteGenerator();
+
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const;
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator);
-};
-
-class RepeatedImmutablePrimitiveFieldLiteGenerator
- : public ImmutableFieldLiteGenerator {
- public:
- explicit RepeatedImmutablePrimitiveFieldLiteGenerator(
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator);
+};
+
+class RepeatedImmutablePrimitiveFieldLiteGenerator
+ : public ImmutableFieldLiteGenerator {
+ public:
+ explicit RepeatedImmutablePrimitiveFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
~RepeatedImmutablePrimitiveFieldLiteGenerator() override;
-
- // implements ImmutableFieldLiteGenerator ------------------------------------
+
+ // implements ImmutableFieldLiteGenerator ------------------------------------
int GetNumBitsForMessage() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
void GenerateMembers(io::Printer* printer) const override;
@@ -121,21 +121,21 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
- private:
- const FieldDescriptor* descriptor_;
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- Context* context_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
index 7d08703c17..05748f5847 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc
@@ -1,88 +1,88 @@
-// 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: kenton@google.com (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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_service.h>
-
+
#include <google/protobuf/compiler/java/java_context.h>
#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor)
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor)
: descriptor_(descriptor) {}
-
-ServiceGenerator::~ServiceGenerator() {}
-
-// ===================================================================
-ImmutableServiceGenerator::ImmutableServiceGenerator(
- const ServiceDescriptor* descriptor, Context* context)
+
+ServiceGenerator::~ServiceGenerator() {}
+
+// ===================================================================
+ImmutableServiceGenerator::ImmutableServiceGenerator(
+ const ServiceDescriptor* descriptor, Context* context)
: ServiceGenerator(descriptor),
context_(context),
name_resolver_(context->GetNameResolver()) {}
-
-ImmutableServiceGenerator::~ImmutableServiceGenerator() {}
-
-void ImmutableServiceGenerator::Generate(io::Printer* printer) {
- bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- WriteServiceDocComment(printer, descriptor_);
- MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
- /* immutable = */ true);
- printer->Print(
+
+ImmutableServiceGenerator::~ImmutableServiceGenerator() {}
+
+void ImmutableServiceGenerator::Generate(io::Printer* printer) {
+ bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
+ WriteServiceDocComment(printer, descriptor_);
+ MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
+ /* immutable = */ true);
+ printer->Print(
"public $static$ abstract class $classname$\n"
" implements com.google.protobuf.Service {\n",
"static", is_own_file ? "" : "static", "classname", descriptor_->name());
- printer->Indent();
-
+ printer->Indent();
+
printer->Print("protected $classname$() {}\n\n", "classname",
descriptor_->name());
-
- GenerateInterface(printer);
-
- GenerateNewReflectiveServiceMethod(printer);
- GenerateNewReflectiveBlockingServiceMethod(printer);
-
- GenerateAbstractMethods(printer);
-
- // Generate getDescriptor() and getDescriptorForType().
- printer->Print(
+
+ GenerateInterface(printer);
+
+ GenerateNewReflectiveServiceMethod(printer);
+ GenerateNewReflectiveBlockingServiceMethod(printer);
+
+ GenerateAbstractMethods(printer);
+
+ // Generate getDescriptor() and getDescriptorForType().
+ printer->Print(
"public static final\n"
" com.google.protobuf.Descriptors.ServiceDescriptor\n"
" getDescriptor() {\n"
@@ -90,106 +90,106 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
"}\n",
"file", name_resolver_->GetImmutableClassName(descriptor_->file()),
"index", StrCat(descriptor_->index()));
- GenerateGetDescriptorForType(printer);
-
- // Generate more stuff.
- GenerateCallMethod(printer);
- GenerateGetPrototype(REQUEST, printer);
- GenerateGetPrototype(RESPONSE, printer);
- GenerateStub(printer);
- GenerateBlockingStub(printer);
-
- // Add an insertion point.
- printer->Print(
+ GenerateGetDescriptorForType(printer);
+
+ // Generate more stuff.
+ GenerateCallMethod(printer);
+ GenerateGetPrototype(REQUEST, printer);
+ GenerateGetPrototype(RESPONSE, printer);
+ GenerateStub(printer);
+ GenerateBlockingStub(printer);
+
+ // Add an insertion point.
+ printer->Print(
"\n"
"// @@protoc_insertion_point(class_scope:$full_name$)\n",
"full_name", descriptor_->full_name());
-
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-void ImmutableServiceGenerator::GenerateGetDescriptorForType(
- io::Printer* printer) {
- printer->Print(
+
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+void ImmutableServiceGenerator::GenerateGetDescriptorForType(
+ io::Printer* printer) {
+ printer->Print(
"public final com.google.protobuf.Descriptors.ServiceDescriptor\n"
" getDescriptorForType() {\n"
" return getDescriptor();\n"
"}\n");
-}
-
-void ImmutableServiceGenerator::GenerateInterface(io::Printer* printer) {
- printer->Print("public interface Interface {\n");
- printer->Indent();
- GenerateAbstractMethods(printer);
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-void ImmutableServiceGenerator::GenerateNewReflectiveServiceMethod(
- io::Printer* printer) {
- printer->Print(
+}
+
+void ImmutableServiceGenerator::GenerateInterface(io::Printer* printer) {
+ printer->Print("public interface Interface {\n");
+ printer->Indent();
+ GenerateAbstractMethods(printer);
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+void ImmutableServiceGenerator::GenerateNewReflectiveServiceMethod(
+ io::Printer* printer) {
+ printer->Print(
"public static com.google.protobuf.Service newReflectiveService(\n"
" final Interface impl) {\n"
" return new $classname$() {\n",
"classname", descriptor_->name());
- printer->Indent();
- printer->Indent();
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- printer->Print("@java.lang.Override\n");
- GenerateMethodSignature(printer, method, IS_CONCRETE);
- printer->Print(
+ printer->Indent();
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ printer->Print("@java.lang.Override\n");
+ GenerateMethodSignature(printer, method, IS_CONCRETE);
+ printer->Print(
" {\n"
" impl.$method$(controller, request, done);\n"
"}\n\n",
"method", UnderscoresToCamelCase(method));
- }
-
- printer->Outdent();
- printer->Print("};\n");
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-void ImmutableServiceGenerator::GenerateNewReflectiveBlockingServiceMethod(
- io::Printer* printer) {
- printer->Print(
+ }
+
+ printer->Outdent();
+ printer->Print("};\n");
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+void ImmutableServiceGenerator::GenerateNewReflectiveBlockingServiceMethod(
+ io::Printer* printer) {
+ printer->Print(
"public static com.google.protobuf.BlockingService\n"
" newReflectiveBlockingService(final BlockingInterface impl) {\n"
" return new com.google.protobuf.BlockingService() {\n");
- printer->Indent();
- printer->Indent();
-
- GenerateGetDescriptorForType(printer);
-
- GenerateCallBlockingMethod(printer);
- GenerateGetPrototype(REQUEST, printer);
- GenerateGetPrototype(RESPONSE, printer);
-
- printer->Outdent();
- printer->Print("};\n");
- printer->Outdent();
- printer->Print("}\n\n");
-}
-
-void ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) {
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- WriteMethodDocComment(printer, method);
- GenerateMethodSignature(printer, method, IS_ABSTRACT);
- printer->Print(";\n\n");
- }
-}
-
+ printer->Indent();
+ printer->Indent();
+
+ GenerateGetDescriptorForType(printer);
+
+ GenerateCallBlockingMethod(printer);
+ GenerateGetPrototype(REQUEST, printer);
+ GenerateGetPrototype(RESPONSE, printer);
+
+ printer->Outdent();
+ printer->Print("};\n");
+ printer->Outdent();
+ printer->Print("}\n\n");
+}
+
+void ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) {
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ WriteMethodDocComment(printer, method);
+ GenerateMethodSignature(printer, method, IS_ABSTRACT);
+ printer->Print(";\n\n");
+ }
+}
+
TProtoStringType ImmutableServiceGenerator::GetOutput(
const MethodDescriptor* method) {
return name_resolver_->GetImmutableClassName(method->output_type());
}
-void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
- printer->Print(
+void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
+ printer->Print(
"\n"
"public final void callMethod(\n"
" com.google.protobuf.Descriptors.MethodDescriptor method,\n"
@@ -203,14 +203,14 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
" \"service type.\");\n"
" }\n"
" switch(method.getIndex()) {\n");
- printer->Indent();
- printer->Indent();
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+ printer->Indent();
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
std::map<TProtoStringType, TProtoStringType> vars;
vars["index"] = StrCat(i);
- vars["method"] = UnderscoresToCamelCase(method);
+ vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
printer->Print(
@@ -220,24 +220,24 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
" com.google.protobuf.RpcUtil.<$output$>specializeCallback(\n"
" done));\n"
" return;\n");
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"default:\n"
" throw new java.lang.AssertionError(\"Can't get here.\");\n");
-
- printer->Outdent();
- printer->Outdent();
-
- printer->Print(
+
+ printer->Outdent();
+ printer->Outdent();
+
+ printer->Print(
" }\n"
"}\n"
"\n");
-}
-
-void ImmutableServiceGenerator::GenerateCallBlockingMethod(
- io::Printer* printer) {
- printer->Print(
+}
+
+void ImmutableServiceGenerator::GenerateCallBlockingMethod(
+ io::Printer* printer) {
+ printer->Print(
"\n"
"public final com.google.protobuf.Message callBlockingMethod(\n"
" com.google.protobuf.Descriptors.MethodDescriptor method,\n"
@@ -250,41 +250,41 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod(
" \"wrong service type.\");\n"
" }\n"
" switch(method.getIndex()) {\n");
- printer->Indent();
- printer->Indent();
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+ printer->Indent();
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
std::map<TProtoStringType, TProtoStringType> vars;
vars["index"] = StrCat(i);
- vars["method"] = UnderscoresToCamelCase(method);
+ vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
- printer->Print(vars,
+ printer->Print(vars,
"case $index$:\n"
" return impl.$method$(controller, ($input$)request);\n");
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"default:\n"
" throw new java.lang.AssertionError(\"Can't get here.\");\n");
-
- printer->Outdent();
- printer->Outdent();
-
- printer->Print(
+
+ printer->Outdent();
+ printer->Outdent();
+
+ printer->Print(
" }\n"
"}\n"
"\n");
-}
-
-void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
+}
+
+void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
io::Printer* printer) {
- /*
- * TODO(cpovirk): The exception message says "Service.foo" when it may be
- * "BlockingService.foo." Consider fixing.
- */
- printer->Print(
+ /*
+ * TODO(cpovirk): The exception message says "Service.foo" when it may be
+ * "BlockingService.foo." Consider fixing.
+ */
+ printer->Print(
"public final com.google.protobuf.Message\n"
" get$request_or_response$Prototype(\n"
" com.google.protobuf.Descriptors.MethodDescriptor method) {\n"
@@ -295,37 +295,37 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
" }\n"
" switch(method.getIndex()) {\n",
"request_or_response", (which == REQUEST) ? "Request" : "Response");
- printer->Indent();
- printer->Indent();
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
+ printer->Indent();
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
std::map<TProtoStringType, TProtoStringType> vars;
vars["index"] = StrCat(i);
vars["type"] =
(which == REQUEST)
? name_resolver_->GetImmutableClassName(method->input_type())
: GetOutput(method);
- printer->Print(vars,
+ printer->Print(vars,
"case $index$:\n"
" return $type$.getDefaultInstance();\n");
- }
-
- printer->Print(
+ }
+
+ printer->Print(
"default:\n"
" throw new java.lang.AssertionError(\"Can't get here.\");\n");
-
- printer->Outdent();
- printer->Outdent();
-
- printer->Print(
+
+ printer->Outdent();
+ printer->Outdent();
+
+ printer->Print(
" }\n"
"}\n"
"\n");
-}
-
-void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
- printer->Print(
+}
+
+void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
+ printer->Print(
"public static Stub newStub(\n"
" com.google.protobuf.RpcChannel channel) {\n"
" return new Stub(channel);\n"
@@ -335,9 +335,9 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
"{"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- printer->Indent();
-
- printer->Print(
+ printer->Indent();
+
+ printer->Print(
"private Stub(com.google.protobuf.RpcChannel channel) {\n"
" this.channel = channel;\n"
"}\n"
@@ -347,18 +347,18 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
"public com.google.protobuf.RpcChannel getChannel() {\n"
" return channel;\n"
"}\n");
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- printer->Print("\n");
- GenerateMethodSignature(printer, method, IS_CONCRETE);
- printer->Print(" {\n");
- printer->Indent();
-
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ printer->Print("\n");
+ GenerateMethodSignature(printer, method, IS_CONCRETE);
+ printer->Print(" {\n");
+ printer->Indent();
+
std::map<TProtoStringType, TProtoStringType> vars;
vars["index"] = StrCat(i);
vars["output"] = GetOutput(method);
- printer->Print(vars,
+ printer->Print(vars,
"channel.callMethod(\n"
" getDescriptor().getMethods().get($index$),\n"
" controller,\n"
@@ -368,107 +368,107 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
" done,\n"
" $output$.class,\n"
" $output$.getDefaultInstance()));\n");
-
- printer->Outdent();
- printer->Print("}\n");
- }
-
- printer->Outdent();
- printer->Print(
+
+ printer->Outdent();
+ printer->Print("}\n");
+ }
+
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
-}
-
-void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
- printer->Print(
+}
+
+void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
+ printer->Print(
"public static BlockingInterface newBlockingStub(\n"
" com.google.protobuf.BlockingRpcChannel channel) {\n"
" return new BlockingStub(channel);\n"
"}\n"
"\n");
-
+
printer->Print("public interface BlockingInterface {");
- printer->Indent();
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- GenerateBlockingMethodSignature(printer, method);
- printer->Print(";\n");
- }
-
- printer->Outdent();
- printer->Print(
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ GenerateBlockingMethodSignature(printer, method);
+ printer->Print(";\n");
+ }
+
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
-
- printer->Print(
+
+ printer->Print(
"private static final class BlockingStub implements BlockingInterface "
"{\n");
- printer->Indent();
-
- printer->Print(
+ printer->Indent();
+
+ printer->Print(
"private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) {\n"
" this.channel = channel;\n"
"}\n"
"\n"
"private final com.google.protobuf.BlockingRpcChannel channel;\n");
-
- for (int i = 0; i < descriptor_->method_count(); i++) {
- const MethodDescriptor* method = descriptor_->method(i);
- GenerateBlockingMethodSignature(printer, method);
- printer->Print(" {\n");
- printer->Indent();
-
+
+ for (int i = 0; i < descriptor_->method_count(); i++) {
+ const MethodDescriptor* method = descriptor_->method(i);
+ GenerateBlockingMethodSignature(printer, method);
+ printer->Print(" {\n");
+ printer->Indent();
+
std::map<TProtoStringType, TProtoStringType> vars;
vars["index"] = StrCat(i);
vars["output"] = GetOutput(method);
- printer->Print(vars,
+ printer->Print(vars,
"return ($output$) channel.callBlockingMethod(\n"
" getDescriptor().getMethods().get($index$),\n"
" controller,\n"
" request,\n"
" $output$.getDefaultInstance());\n");
-
- printer->Outdent();
- printer->Print(
+
+ printer->Outdent();
+ printer->Print(
"}\n"
"\n");
- }
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
+ }
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void ImmutableServiceGenerator::GenerateMethodSignature(
io::Printer* printer, const MethodDescriptor* method,
IsAbstract is_abstract) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["name"] = UnderscoresToCamelCase(method);
- vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
+ vars["name"] = UnderscoresToCamelCase(method);
+ vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
- vars["abstract"] = (is_abstract == IS_ABSTRACT) ? "abstract" : "";
- printer->Print(vars,
+ vars["abstract"] = (is_abstract == IS_ABSTRACT) ? "abstract" : "";
+ printer->Print(vars,
"public $abstract$ void $name$(\n"
" com.google.protobuf.RpcController controller,\n"
" $input$ request,\n"
" com.google.protobuf.RpcCallback<$output$> done)");
-}
-
-void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
+}
+
+void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
io::Printer* printer, const MethodDescriptor* method) {
std::map<TProtoStringType, TProtoStringType> vars;
- vars["method"] = UnderscoresToCamelCase(method);
- vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
+ vars["method"] = UnderscoresToCamelCase(method);
+ vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
- printer->Print(vars,
+ printer->Print(vars,
"\n"
"public $output$ $method$(\n"
" com.google.protobuf.RpcController controller,\n"
" $input$ request)\n"
" throws com.google.protobuf.ServiceException");
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
index 971efd5fc9..e3d52a40ca 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h
@@ -1,45 +1,45 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
+
+#include <map>
#include <google/protobuf/descriptor.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -48,92 +48,92 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
namespace io {
class Printer; // printer.h
-}
+}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ServiceGenerator {
- public:
- explicit ServiceGenerator(const ServiceDescriptor* descriptor);
- virtual ~ServiceGenerator();
-
- virtual void Generate(io::Printer* printer) = 0;
-
- enum RequestOrResponse { REQUEST, RESPONSE };
- enum IsAbstract { IS_ABSTRACT, IS_CONCRETE };
-
- protected:
- const ServiceDescriptor* descriptor_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
-};
-
-class ImmutableServiceGenerator : public ServiceGenerator {
- public:
- ImmutableServiceGenerator(const ServiceDescriptor* descriptor,
- Context* context);
- virtual ~ImmutableServiceGenerator();
-
- virtual void Generate(io::Printer* printer);
-
- private:
- // Generate the getDescriptorForType() method.
- void GenerateGetDescriptorForType(io::Printer* printer);
-
- // Generate a Java interface for the service.
- void GenerateInterface(io::Printer* printer);
-
- // Generate newReflectiveService() method.
- void GenerateNewReflectiveServiceMethod(io::Printer* printer);
-
- // Generate newReflectiveBlockingService() method.
- void GenerateNewReflectiveBlockingServiceMethod(io::Printer* printer);
-
- // Generate abstract method declarations for all methods.
- void GenerateAbstractMethods(io::Printer* printer);
-
- // Generate the implementation of Service.callMethod().
- void GenerateCallMethod(io::Printer* printer);
-
- // Generate the implementation of BlockingService.callBlockingMethod().
- void GenerateCallBlockingMethod(io::Printer* printer);
-
- // Generate the implementations of Service.get{Request,Response}Prototype().
- void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);
-
- // Generate a stub implementation of the service.
- void GenerateStub(io::Printer* printer);
-
- // Generate a method signature, possibly abstract, without body or trailing
- // semicolon.
- void GenerateMethodSignature(io::Printer* printer,
- const MethodDescriptor* method,
- IsAbstract is_abstract);
-
- // Generate a blocking stub interface and implementation of the service.
- void GenerateBlockingStub(io::Printer* printer);
-
- // Generate the method signature for one method of a blocking stub.
- void GenerateBlockingMethodSignature(io::Printer* printer,
- const MethodDescriptor* method);
-
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ServiceGenerator {
+ public:
+ explicit ServiceGenerator(const ServiceDescriptor* descriptor);
+ virtual ~ServiceGenerator();
+
+ virtual void Generate(io::Printer* printer) = 0;
+
+ enum RequestOrResponse { REQUEST, RESPONSE };
+ enum IsAbstract { IS_ABSTRACT, IS_CONCRETE };
+
+ protected:
+ const ServiceDescriptor* descriptor_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);
+};
+
+class ImmutableServiceGenerator : public ServiceGenerator {
+ public:
+ ImmutableServiceGenerator(const ServiceDescriptor* descriptor,
+ Context* context);
+ virtual ~ImmutableServiceGenerator();
+
+ virtual void Generate(io::Printer* printer);
+
+ private:
+ // Generate the getDescriptorForType() method.
+ void GenerateGetDescriptorForType(io::Printer* printer);
+
+ // Generate a Java interface for the service.
+ void GenerateInterface(io::Printer* printer);
+
+ // Generate newReflectiveService() method.
+ void GenerateNewReflectiveServiceMethod(io::Printer* printer);
+
+ // Generate newReflectiveBlockingService() method.
+ void GenerateNewReflectiveBlockingServiceMethod(io::Printer* printer);
+
+ // Generate abstract method declarations for all methods.
+ void GenerateAbstractMethods(io::Printer* printer);
+
+ // Generate the implementation of Service.callMethod().
+ void GenerateCallMethod(io::Printer* printer);
+
+ // Generate the implementation of BlockingService.callBlockingMethod().
+ void GenerateCallBlockingMethod(io::Printer* printer);
+
+ // Generate the implementations of Service.get{Request,Response}Prototype().
+ void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);
+
+ // Generate a stub implementation of the service.
+ void GenerateStub(io::Printer* printer);
+
+ // Generate a method signature, possibly abstract, without body or trailing
+ // semicolon.
+ void GenerateMethodSignature(io::Printer* printer,
+ const MethodDescriptor* method,
+ IsAbstract is_abstract);
+
+ // Generate a blocking stub interface and implementation of the service.
+ void GenerateBlockingStub(io::Printer* printer);
+
+ // Generate the method signature for one method of a blocking stub.
+ void GenerateBlockingMethodSignature(io::Printer* printer,
+ const MethodDescriptor* method);
+
// Return the output type of the method.
TProtoStringType GetOutput(const MethodDescriptor* method);
- Context* context_;
- ClassNameResolver* name_resolver_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // NET_PROTO2_COMPILER_JAVA_SERVICE_H__
+
+#endif // NET_PROTO2_COMPILER_JAVA_SERVICE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
index 50683b6108..a0d5e2b45f 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc
@@ -1,39 +1,39 @@
-// 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: xiaofeng@google.com (Feng Xiao)
-
+// 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: xiaofeng@google.com (Feng Xiao)
+
#include <google/protobuf/compiler/java/java_shared_code_generator.h>
-
-#include <memory>
-
+
+#include <memory>
+
#include <google/protobuf/compiler/java/java_helpers.h>
#include <google/protobuf/compiler/java/java_name_resolver.h>
#include <google/protobuf/compiler/java/java_names.h>
@@ -43,125 +43,125 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-SharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file,
- const Options& options)
- : name_resolver_(new ClassNameResolver), file_(file), options_(options) {}
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+SharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file,
+ const Options& options)
+ : name_resolver_(new ClassNameResolver), file_(file), options_(options) {}
+
SharedCodeGenerator::~SharedCodeGenerator() {}
-
+
void SharedCodeGenerator::Generate(
GeneratorContext* context, std::vector<TProtoStringType>* file_list,
std::vector<TProtoStringType>* annotation_file_list) {
TProtoStringType java_package = FileJavaPackage(file_);
TProtoStringType package_dir = JavaPackageToDir(java_package);
-
- if (HasDescriptorMethods(file_, options_.enforce_lite)) {
- // Generate descriptors.
+
+ if (HasDescriptorMethods(file_, options_.enforce_lite)) {
+ // Generate descriptors.
TProtoStringType classname = name_resolver_->GetDescriptorClassName(file_);
TProtoStringType filename = package_dir + classname + ".java";
- file_list->push_back(filename);
+ file_list->push_back(filename);
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
std::unique_ptr<io::Printer> printer(
- new io::Printer(output.get(), '$',
- options_.annotate_code ? &annotation_collector : NULL));
+ new io::Printer(output.get(), '$',
+ options_.annotate_code ? &annotation_collector : NULL));
TProtoStringType info_relative_path = classname + ".java.pb.meta";
TProtoStringType info_full_path = filename + ".pb.meta";
- printer->Print(
- "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "// source: $filename$\n"
- "\n",
- "filename", file_->name());
- if (!java_package.empty()) {
- printer->Print(
+ printer->Print(
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "// source: $filename$\n"
+ "\n",
+ "filename", file_->name());
+ if (!java_package.empty()) {
+ printer->Print(
"package $package$;\n"
"\n",
"package", java_package);
- }
- PrintGeneratedAnnotation(printer.get(), '$',
- options_.annotate_code ? info_relative_path : "");
- printer->Print(
- "public final class $classname$ {\n"
- " public static com.google.protobuf.Descriptors.FileDescriptor\n"
- " descriptor;\n"
- " static {\n",
- "classname", classname);
- printer->Annotate("classname", file_->name());
- printer->Indent();
- printer->Indent();
- GenerateDescriptors(printer.get());
- printer->Outdent();
- printer->Outdent();
- printer->Print(
+ }
+ PrintGeneratedAnnotation(printer.get(), '$',
+ options_.annotate_code ? info_relative_path : "");
+ printer->Print(
+ "public final class $classname$ {\n"
+ " public static com.google.protobuf.Descriptors.FileDescriptor\n"
+ " descriptor;\n"
+ " static {\n",
+ "classname", classname);
+ printer->Annotate("classname", file_->name());
+ printer->Indent();
+ printer->Indent();
+ GenerateDescriptors(printer.get());
+ printer->Outdent();
+ printer->Outdent();
+ printer->Print(
" }\n"
"}\n");
-
- if (options_.annotate_code) {
+
+ if (options_.annotate_code) {
std::unique_ptr<io::ZeroCopyOutputStream> info_output(
- context->Open(info_full_path));
- annotations.SerializeToZeroCopyStream(info_output.get());
- annotation_file_list->push_back(info_full_path);
- }
-
- printer.reset();
- output.reset();
- }
-}
-
-void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
- // Embed the descriptor. We simply serialize the entire FileDescriptorProto
- // and embed it as a string literal, which is parsed and built into real
- // descriptors at initialization time. We unfortunately have to put it in
- // a string literal, not a byte array, because apparently using a literal
- // byte array causes the Java compiler to generate *instructions* to
- // initialize each and every byte of the array, e.g. as if you typed:
- // b[0] = 123; b[1] = 456; b[2] = 789;
- // This makes huge bytecode files and can easily hit the compiler's internal
- // code size limits (error "code to large"). String literals are apparently
- // embedded raw, which is what we want.
- FileDescriptorProto file_proto;
- file_->CopyTo(&file_proto);
-
+ context->Open(info_full_path));
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ annotation_file_list->push_back(info_full_path);
+ }
+
+ printer.reset();
+ output.reset();
+ }
+}
+
+void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
+ // Embed the descriptor. We simply serialize the entire FileDescriptorProto
+ // and embed it as a string literal, which is parsed and built into real
+ // descriptors at initialization time. We unfortunately have to put it in
+ // a string literal, not a byte array, because apparently using a literal
+ // byte array causes the Java compiler to generate *instructions* to
+ // initialize each and every byte of the array, e.g. as if you typed:
+ // b[0] = 123; b[1] = 456; b[2] = 789;
+ // This makes huge bytecode files and can easily hit the compiler's internal
+ // code size limits (error "code to large"). String literals are apparently
+ // embedded raw, which is what we want.
+ FileDescriptorProto file_proto;
+ file_->CopyTo(&file_proto);
+
TProtoStringType file_data;
- file_proto.SerializeToString(&file_data);
-
+ file_proto.SerializeToString(&file_data);
+
printer->Print("java.lang.String[] descriptorData = {\n");
- printer->Indent();
-
+ printer->Indent();
+
// Limit the number of bytes per line.
- static const int kBytesPerLine = 40;
+ static const int kBytesPerLine = 40;
// Limit the number of lines per string part.
static const int kLinesPerPart = 400;
// Every block of bytes, start a new string literal, in order to avoid the
// 64k length limit. Note that this value needs to be <64k.
static const int kBytesPerPart = kBytesPerLine * kLinesPerPart;
- for (int i = 0; i < file_data.size(); i += kBytesPerLine) {
- if (i > 0) {
+ for (int i = 0; i < file_data.size(); i += kBytesPerLine) {
+ if (i > 0) {
if (i % kBytesPerPart == 0) {
- printer->Print(",\n");
- } else {
- printer->Print(" +\n");
- }
- }
+ printer->Print(",\n");
+ } else {
+ printer->Print(" +\n");
+ }
+ }
printer->Print("\"$data$\"", "data",
CEscape(file_data.substr(i, kBytesPerLine)));
- }
-
- printer->Outdent();
- printer->Print("\n};\n");
-
- // -----------------------------------------------------------------
- // Find out all dependencies.
+ }
+
+ printer->Outdent();
+ printer->Print("\n};\n");
+
+ // -----------------------------------------------------------------
+ // Find out all dependencies.
std::vector<std::pair<TProtoStringType, TProtoStringType> > dependencies;
- for (int i = 0; i < file_->dependency_count(); i++) {
+ for (int i = 0; i < file_->dependency_count(); i++) {
TProtoStringType filename = file_->dependency(i)->name();
TProtoStringType package = FileJavaPackage(file_->dependency(i));
TProtoStringType classname =
@@ -173,26 +173,26 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
full_name = package + "." + classname;
}
dependencies.push_back(std::make_pair(filename, full_name));
- }
-
- // -----------------------------------------------------------------
- // Invoke internalBuildGeneratedFileFrom() to build the file.
- printer->Print(
+ }
+
+ // -----------------------------------------------------------------
+ // Invoke internalBuildGeneratedFileFrom() to build the file.
+ printer->Print(
"descriptor = com.google.protobuf.Descriptors.FileDescriptor\n"
" .internalBuildGeneratedFileFrom(descriptorData,\n");
- printer->Print(
+ printer->Print(
" new com.google.protobuf.Descriptors.FileDescriptor[] {\n");
-
- for (int i = 0; i < dependencies.size(); i++) {
+
+ for (int i = 0; i < dependencies.size(); i++) {
const TProtoStringType& dependency = dependencies[i].second;
printer->Print(" $dependency$.getDescriptor(),\n", "dependency",
dependency);
- }
-
+ }
+
printer->Print(" });\n");
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h
index 85bab9ed52..93fe6d7996 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h
@@ -1,90 +1,90 @@
-// 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: xiaofeng@google.com (Feng Xiao)
-//
-// Generators that generate shared code between immutable API and mutable API.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
-
-#include <memory>
+// 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: xiaofeng@google.com (Feng Xiao)
+//
+// Generators that generate shared code between immutable API and mutable API.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
+
+#include <memory>
#include <string>
-#include <vector>
-
+#include <vector>
+
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_options.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
class FileDescriptor; // descriptor.h
namespace compiler {
class GeneratorContext; // code_generator.h
namespace java {
class ClassNameResolver; // name_resolver.h
-}
+}
} // namespace compiler
namespace io {
class Printer; // printer.h
}
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-// A generator that generates code that are shared between immutable API
-// and mutable API. Currently only descriptors are shared.
-class SharedCodeGenerator {
- public:
- SharedCodeGenerator(const FileDescriptor* file, const Options& options);
- ~SharedCodeGenerator();
-
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+// A generator that generates code that are shared between immutable API
+// and mutable API. Currently only descriptors are shared.
+class SharedCodeGenerator {
+ public:
+ SharedCodeGenerator(const FileDescriptor* file, const Options& options);
+ ~SharedCodeGenerator();
+
void Generate(GeneratorContext* generator_context,
std::vector<TProtoStringType>* file_list,
std::vector<TProtoStringType>* annotation_file_list);
-
- void GenerateDescriptors(io::Printer* printer);
-
- private:
+
+ void GenerateDescriptors(io::Printer* printer);
+
+ private:
std::unique_ptr<ClassNameResolver> name_resolver_;
- const FileDescriptor* file_;
- const Options options_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ const FileDescriptor* file_;
+ const Options options_;
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
index 04acfc1461..e0019a5ffe 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc
@@ -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: kenton@google.com (Kenton Varda)
-// Author: jonp@google.com (Jon Perlow)
-// 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: kenton@google.com (Kenton Varda)
+// Author: jonp@google.com (Jon Perlow)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_string_field.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -48,46 +48,46 @@
#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 java {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-namespace {
-
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+namespace {
+
+void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ const FieldGeneratorInfo* info,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY";
-
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["default_init"] =
- "= " + ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["capitalized_type"] = "String";
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ (*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY";
+
+ (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default_init"] =
+ "= " + ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["capitalized_type"] = "String";
(*variables)["tag"] =
StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = StrCat(
- WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
- (*variables)["null_check"] =
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n";
+ WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ (*variables)["null_check"] =
+ " if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ " }\n";
(*variables)["writeString"] = "com.google.protobuf.GeneratedMessage" +
GeneratedCodeVersionSuffix() + ".writeString";
(*variables)["computeStringSize"] = "com.google.protobuf.GeneratedMessage" +
GeneratedCodeVersionSuffix() +
".computeStringSize";
-
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -95,125 +95,125 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
" is deprecated\") "
: "";
- (*variables)["on_changed"] = "onChanged();";
-
+ (*variables)["on_changed"] = "onChanged();";
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
- (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["set_has_field_bit_builder"] =
- GenerateSetBit(builderBitIndex) + ";";
- (*variables)["clear_has_field_bit_builder"] =
- GenerateClearBit(builderBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["set_has_field_bit_builder"] = "";
- (*variables)["clear_has_field_bit_builder"] = "";
-
- (*variables)["is_field_present_message"] =
- "!get" + (*variables)["capitalized_name"] + "Bytes().isEmpty()";
- }
-
- // For repeated builders, one bit is used for whether the array is immutable.
- (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
- (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
- (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
-
- // For repeated fields, one bit is used for whether the array is immutable
- // in the parsing constructor.
- (*variables)["get_mutable_bit_parser"] =
- GenerateGetBitMutableLocal(builderBitIndex);
- (*variables)["set_mutable_bit_parser"] =
- GenerateSetBitMutableLocal(builderBitIndex);
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-}
-
-} // namespace
-
-// ===================================================================
-
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["set_has_field_bit_builder"] =
+ GenerateSetBit(builderBitIndex) + ";";
+ (*variables)["clear_has_field_bit_builder"] =
+ GenerateClearBit(builderBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["set_has_field_bit_builder"] = "";
+ (*variables)["clear_has_field_bit_builder"] = "";
+
+ (*variables)["is_field_present_message"] =
+ "!get" + (*variables)["capitalized_name"] + "Bytes().isEmpty()";
+ }
+
+ // For repeated builders, one bit is used for whether the array is immutable.
+ (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
+ (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
+ (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
+
+ // For repeated fields, one bit is used for whether the array is immutable
+ // in the parsing constructor.
+ (*variables)["get_mutable_bit_parser"] =
+ GenerateGetBitMutableLocal(builderBitIndex);
+ (*variables)["set_mutable_bit_parser"] =
+ GenerateSetBitMutableLocal(builderBitIndex);
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutableStringFieldGenerator::ImmutableStringFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-ImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {}
-
-int ImmutableStringFieldGenerator::GetNumBitsForMessage() const {
+ SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+ImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {}
+
+int ImmutableStringFieldGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
-int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
+}
+
+int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
return GetNumBitsForMessage();
-}
-
-// A note about how strings are handled. This code used to just store a String
-// in the Message. This had two issues:
-//
+}
+
+// A note about how strings are handled. This code used to just store a String
+// in the Message. This had two issues:
+//
// 1. It wouldn't roundtrip byte arrays that were not valid UTF-8 encoded
-// strings, but rather fields that were raw bytes incorrectly marked
-// as strings in the proto file. This is common because in the proto1
-// syntax, string was the way to indicate bytes and C++ engineers can
-// easily make this mistake without affecting the C++ API. By converting to
-// strings immediately, some java code might corrupt these byte arrays as
-// it passes through a java server even if the field was never accessed by
-// application code.
-//
-// 2. There's a performance hit to converting between bytes and strings and
-// it many cases, the field is never even read by the application code. This
-// avoids unnecessary conversions in the common use cases.
-//
-// So now, the field for String is maintained as an Object reference which can
-// either store a String or a ByteString. The code uses an instanceof check
-// to see which one it has and converts to the other one if needed. It remembers
-// the last value requested (in a thread safe manner) as this is most likely
-// the one needed next. The thread safety is such that if two threads both
-// convert the field because the changes made by each thread were not visible to
-// the other, they may cause a conversion to happen more times than would
-// otherwise be necessary. This was deemed better than adding synchronization
-// overhead. It will not cause any corruption issues or affect the behavior of
-// the API. The instanceof check is also highly optimized in the JVM and we
-// decided it was better to reduce the memory overhead by not having two
-// separate fields but rather use dynamic type checking.
-//
-// For single fields, the logic for this is done inside the generated code. For
-// repeated fields, the logic is done in LazyStringArrayList and
-// UnmodifiableLazyStringList.
+// strings, but rather fields that were raw bytes incorrectly marked
+// as strings in the proto file. This is common because in the proto1
+// syntax, string was the way to indicate bytes and C++ engineers can
+// easily make this mistake without affecting the C++ API. By converting to
+// strings immediately, some java code might corrupt these byte arrays as
+// it passes through a java server even if the field was never accessed by
+// application code.
+//
+// 2. There's a performance hit to converting between bytes and strings and
+// it many cases, the field is never even read by the application code. This
+// avoids unnecessary conversions in the common use cases.
+//
+// So now, the field for String is maintained as an Object reference which can
+// either store a String or a ByteString. The code uses an instanceof check
+// to see which one it has and converts to the other one if needed. It remembers
+// the last value requested (in a thread safe manner) as this is most likely
+// the one needed next. The thread safety is such that if two threads both
+// convert the field because the changes made by each thread were not visible to
+// the other, they may cause a conversion to happen more times than would
+// otherwise be necessary. This was deemed better than adding synchronization
+// overhead. It will not cause any corruption issues or affect the behavior of
+// the API. The instanceof check is also highly optimized in the JVM and we
+// decided it was better to reduce the memory overhead by not having two
+// separate fields but rather use dynamic type checking.
+//
+// For single fields, the logic for this is done inside the generated code. For
+// repeated fields, the logic is done in LazyStringArrayList and
+// UnmodifiableLazyStringList.
void ImmutableStringFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$boolean has$capitalized_name$();\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.lang.String get$capitalized_name$();\n");
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$com.google.protobuf.ByteString\n"
" get$capitalized_name$Bytes();\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private volatile java.lang.Object $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
-
+ PrintExtraFieldInfo(variables_, printer);
+
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -223,8 +223,8 @@ void ImmutableStringFieldGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -236,22 +236,22 @@ void ImmutableStringFieldGenerator::GenerateMembers(
" } else {\n"
" com.google.protobuf.ByteString bs = \n"
" (com.google.protobuf.ByteString) ref;\n"
- " java.lang.String s = bs.toStringUtf8();\n");
+ " java.lang.String s = bs.toStringUtf8();\n");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " $name$_ = s;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
" if (bs.isValidUtf8()) {\n"
" $name$_ = s;\n"
" }\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" return s;\n"
" }\n"
"}\n");
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
@@ -267,11 +267,11 @@ void ImmutableStringFieldGenerator::GenerateMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"private java.lang.Object $name$_ $default_init$;\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
@@ -281,8 +281,8 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
" return $get_has_field_bit_builder$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -293,23 +293,23 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
" (com.google.protobuf.ByteString) ref;\n"
" java.lang.String s = bs.toStringUtf8();\n");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " $name$_ = s;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
" if (bs.isValidUtf8()) {\n"
" $name$_ = s;\n"
" }\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" return s;\n"
" } else {\n"
" return (java.lang.String) ref;\n"
" }\n"
"}\n");
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
" java.lang.Object ref = $name$_;\n"
@@ -324,10 +324,10 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
"$null_check$"
@@ -344,15 +344,15 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
"$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
" $clear_has_field_bit_builder$\n");
printer->Annotate("{", "}", descriptor_);
- // The default value is not a simple literal so we want to avoid executing
- // it multiple times. Instead, get the default out of the default instance.
- printer->Print(variables_,
+ // The default value is not a simple literal so we want to avoid executing
+ // it multiple times. Instead, get the default out of the default instance.
+ printer->Print(variables_,
" $name$_ = getDefaultInstance().get$capitalized_name$();\n");
- printer->Print(variables_,
+ printer->Print(variables_,
" $on_changed$\n"
" return this;\n"
"}\n");
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
printer->Print(
@@ -361,17 +361,17 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers(
" com.google.protobuf.ByteString value) {\n"
"$null_check$");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" $set_has_field_bit_builder$\n"
" $name$_ = value;\n"
" $on_changed$\n"
" return this;\n"
"}\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -402,131 +402,131 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
void ImmutableStringFieldGenerator::GenerateFieldBuilderInitializationCode(
io::Printer* printer) const {
- // noop for primitives
-}
-
+ // noop for primitives
+}
+
void ImmutableStringFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $default$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $default$;\n");
+}
+
void ImmutableStringFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$name$_ = $default$;\n"
"$clear_has_field_bit_builder$\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
- // Allow a slight breach of abstraction here in order to avoid forcing
- // all string fields to Strings when copying fields from a Message.
- printer->Print(variables_,
+ // Allow a slight breach of abstraction here in order to avoid forcing
+ // all string fields to Strings when copying fields from a Message.
+ printer->Print(variables_,
"if (other.has$capitalized_name$()) {\n"
" $set_has_field_bit_builder$\n"
" $name$_ = other.$name$_;\n"
" $on_changed$\n"
"}\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"if (!other.get$capitalized_name$().isEmpty()) {\n"
" $name$_ = other.$name$_;\n"
" $on_changed$\n"
"}\n");
- }
-}
-
+ }
+}
+
void ImmutableStringFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($get_has_field_bit_from_local$) {\n"
" $set_has_field_bit_to_local$;\n"
"}\n");
- }
+ }
printer->Print(variables_, "result.$name$_ = $name$_;\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- if (CheckUtf8(descriptor_)) {
- printer->Print(variables_,
+ if (CheckUtf8(descriptor_)) {
+ printer->Print(variables_,
"java.lang.String s = input.readStringRequireUtf8();\n"
"$set_has_field_bit_message$\n"
"$name$_ = s;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"com.google.protobuf.ByteString bs = input.readBytes();\n"
"$set_has_field_bit_message$\n"
"$name$_ = bs;\n");
- }
-}
-
+ }
+}
+
void ImmutableStringFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- // noop for strings.
-}
-
+ // noop for strings.
+}
+
void ImmutableStringFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($is_field_present_message$) {\n"
" $writeString$(output, $number$, $name$_);\n"
"}\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($is_field_present_message$) {\n"
" size += $computeStringSize$($number$, $name$_);\n"
"}\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if (!get$capitalized_name$()\n"
" .equals(other.get$capitalized_name$())) return false;\n");
-}
-
+}
+
void ImmutableStringFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
printer->Print(variables_, "hash = (37 * hash) + $constant_name$;\n");
- printer->Print(variables_,
+ printer->Print(variables_,
"hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
-}
-
+}
+
TProtoStringType ImmutableStringFieldGenerator::GetBoxedType() const {
- return "java.lang.String";
-}
-
-// ===================================================================
-
+ return "java.lang.String";
+}
+
+// ===================================================================
+
ImmutableStringOneofFieldGenerator::ImmutableStringOneofFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: ImmutableStringFieldGenerator(descriptor, messageBitIndex,
builderBitIndex, context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
ImmutableStringOneofFieldGenerator::~ImmutableStringOneofFieldGenerator() {}
-
+
void ImmutableStringOneofFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -542,24 +542,24 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers(
" (com.google.protobuf.ByteString) ref;\n"
" java.lang.String s = bs.toStringUtf8();\n");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
- printer->Print(variables_,
+ if (CheckUtf8(descriptor_)) {
+ printer->Print(variables_,
" if ($has_oneof_case_message$) {\n"
" $oneof_name$_ = s;\n"
" }\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
" if (bs.isValidUtf8() && ($has_oneof_case_message$)) {\n"
" $oneof_name$_ = s;\n"
" }\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" return s;\n"
" }\n"
"}\n");
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
-
- printer->Print(variables_,
+
+ printer->Print(variables_,
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
" java.lang.Object ref $default_init$;\n"
@@ -579,13 +579,13 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $has_oneof_case_message$;\n"
@@ -607,24 +607,24 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
" java.lang.String s = bs.toStringUtf8();\n"
" if ($has_oneof_case_message$) {\n");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " $oneof_name$_ = s;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
" if (bs.isValidUtf8()) {\n"
" $oneof_name$_ = s;\n"
" }\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" }\n"
" return s;\n"
" } else {\n"
" return (java.lang.String) ref;\n"
" }\n"
"}\n");
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
@@ -645,10 +645,10 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
"$null_check$"
@@ -671,7 +671,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
printer->Print(
@@ -680,88 +680,88 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
" com.google.protobuf.ByteString value) {\n"
"$null_check$");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" $set_oneof_case_message$;\n"
" $oneof_name$_ = value;\n"
" $on_changed$\n"
" return this;\n"
"}\n");
-}
-
+}
+
void ImmutableStringOneofFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- // Allow a slight breach of abstraction here in order to avoid forcing
- // all string fields to Strings when copying fields from a Message.
- printer->Print(variables_,
+ // Allow a slight breach of abstraction here in order to avoid forcing
+ // all string fields to Strings when copying fields from a Message.
+ printer->Print(variables_,
"$set_oneof_case_message$;\n"
"$oneof_name$_ = other.$oneof_name$_;\n"
"$on_changed$\n");
-}
-
+}
+
void ImmutableStringOneofFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" result.$oneof_name$_ = $oneof_name$_;\n"
"}\n");
-}
-
+}
+
void ImmutableStringOneofFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- if (CheckUtf8(descriptor_)) {
- printer->Print(variables_,
+ if (CheckUtf8(descriptor_)) {
+ printer->Print(variables_,
"java.lang.String s = input.readStringRequireUtf8();\n"
"$set_oneof_case_message$;\n"
"$oneof_name$_ = s;\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"com.google.protobuf.ByteString bs = input.readBytes();\n"
"$set_oneof_case_message$;\n"
"$oneof_name$_ = bs;\n");
- }
-}
-
+ }
+}
+
void ImmutableStringOneofFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" $writeString$(output, $number$, $oneof_name$_);\n"
"}\n");
-}
-
+}
+
void ImmutableStringOneofFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($has_oneof_case_message$) {\n"
" size += $computeStringSize$($number$, $oneof_name$_);\n"
"}\n");
-}
-
-// ===================================================================
-
+}
+
+// ===================================================================
+
RepeatedImmutableStringFieldGenerator::RepeatedImmutableStringFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-RepeatedImmutableStringFieldGenerator::
+ SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+RepeatedImmutableStringFieldGenerator::
~RepeatedImmutableStringFieldGenerator() {}
-
-int RepeatedImmutableStringFieldGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
-int RepeatedImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
- return 1;
-}
-
+
+int RepeatedImmutableStringFieldGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
+int RepeatedImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
+ return 1;
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
@@ -776,7 +776,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers(
"$deprecation$java.util.List<java.lang.String>\n"
" get$capitalized_name$List();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(
@@ -784,18 +784,18 @@ void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers(
"$deprecation$java.lang.String get$capitalized_name$(int index);\n");
WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$com.google.protobuf.ByteString\n"
" get$capitalized_name$Bytes(int index);\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateMembers(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"private com.google.protobuf.LazyStringList $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public com.google.protobuf.ProtocolStringList\n"
" ${$get$capitalized_name$List$}$() {\n"
" return $name$_;\n" // note: unmodifiable list
@@ -809,7 +809,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public java.lang.String "
"${$get$capitalized_name$$}$(int index) {\n"
" return $name$_.get(index);\n"
@@ -817,29 +817,29 @@ void RepeatedImmutableStringFieldGenerator::GenerateMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$(int index) {\n"
" return $name$_.getByteString(index);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
- // One field is the list and the bit field keeps track of whether the
- // list is immutable. If it's immutable, the invariant is that it must
- // either an instance of Collections.emptyList() or it's an ArrayList
- // wrapped in a Collections.unmodifiableList() wrapper and nobody else has
+ // One field is the list and the bit field keeps track of whether the
+ // list is immutable. If it's immutable, the invariant is that it must
+ // either an instance of Collections.emptyList() or it's an ArrayList
+ // wrapped in a Collections.unmodifiableList() wrapper and nobody else has
// a reference to the underlying ArrayList. This invariant allows us to
- // share instances of lists between protocol buffers avoiding expensive
- // memory allocations. Note, immutable is a strong guarantee here -- not
- // just that the list cannot be modified via the reference but that the
- // list can never be modified.
+ // share instances of lists between protocol buffers avoiding expensive
+ // memory allocations. Note, immutable is a strong guarantee here -- not
+ // just that the list cannot be modified via the reference but that the
+ // list can never be modified.
printer->Print(
variables_,
"private com.google.protobuf.LazyStringList $name$_ = $empty_list$;\n");
-
+
printer->Print(
variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
@@ -848,13 +848,13 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
" $set_mutable_bit_builder$;\n"
" }\n"
"}\n");
-
+
// Note: We return an unmodifiable list because otherwise the caller
// could hold on to the returned list and modify it after the message
// has been built, thus mutating the message which is supposed to be
// immutable.
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public com.google.protobuf.ProtocolStringList\n"
" ${$get$capitalized_name$List$}$() {\n"
" return $name$_.getUnmodifiableView();\n"
@@ -868,7 +868,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public java.lang.String "
"${$get$capitalized_name$$}$(int index) {\n"
" return $name$_.get(index);\n"
@@ -876,7 +876,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$(int index) {\n"
" return $name$_.getByteString(index);\n"
@@ -884,7 +884,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, java.lang.String value) {\n"
"$null_check$"
@@ -896,7 +896,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
"$null_check$"
@@ -908,7 +908,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<java.lang.String> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -929,7 +929,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
printer->Print(
@@ -938,17 +938,17 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers(
" com.google.protobuf.ByteString value) {\n"
"$null_check$");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value);\n"
" $on_changed$\n"
" return this;\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -1050,31 +1050,31 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
"}");
}
-void RepeatedImmutableStringFieldGenerator::
+void RepeatedImmutableStringFieldGenerator::
GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
- // noop for primitives
-}
-
+ // noop for primitives
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $empty_list$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $empty_list$;\n");
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateBuilderClearCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"$name$_ = $empty_list$;\n"
"$clear_mutable_bit_builder$;\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateMergingCode(
io::Printer* printer) const {
- // The code below does two optimizations:
- // 1. If the other list is empty, there's nothing to do. This ensures we
- // don't allocate a new array if we already have an immutable one.
- // 2. If the other list is non-empty and our current list is empty, we can
- // reuse the other list which is guaranteed to be immutable.
- printer->Print(variables_,
+ // The code below does two optimizations:
+ // 1. If the other list is empty, there's nothing to do. This ensures we
+ // don't allocate a new array if we already have an immutable one.
+ // 2. If the other list is non-empty and our current list is empty, we can
+ // reuse the other list which is guaranteed to be immutable.
+ printer->Print(variables_,
"if (!other.$name$_.isEmpty()) {\n"
" if ($name$_.isEmpty()) {\n"
" $name$_ = other.$name$_;\n"
@@ -1085,87 +1085,87 @@ void RepeatedImmutableStringFieldGenerator::GenerateMergingCode(
" }\n"
" $on_changed$\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateBuildingCode(
io::Printer* printer) const {
- // The code below ensures that the result has an immutable list. If our
- // list is immutable, we can just reuse it. If not, we make it immutable.
-
- printer->Print(variables_,
+ // The code below ensures that the result has an immutable list. If our
+ // list is immutable, we can just reuse it. If not, we make it immutable.
+
+ printer->Print(variables_,
"if ($get_mutable_bit_builder$) {\n"
" $name$_ = $name$_.getUnmodifiableView();\n"
" $clear_mutable_bit_builder$;\n"
"}\n"
"result.$name$_ = $name$_;\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateParsingCode(
io::Printer* printer) const {
- if (CheckUtf8(descriptor_)) {
- printer->Print(variables_,
+ if (CheckUtf8(descriptor_)) {
+ printer->Print(variables_,
"java.lang.String s = input.readStringRequireUtf8();\n");
- } else {
- printer->Print(variables_,
+ } else {
+ printer->Print(variables_,
"com.google.protobuf.ByteString bs = input.readBytes();\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
"if (!$get_mutable_bit_parser$) {\n"
" $name$_ = new com.google.protobuf.LazyStringArrayList();\n"
" $set_mutable_bit_parser$;\n"
"}\n");
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, "$name$_.add(s);\n");
- } else {
+ } else {
printer->Print(variables_, "$name$_.add(bs);\n");
- }
-}
-
+ }
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateParsingDoneCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"if ($get_mutable_bit_parser$) {\n"
" $name$_ = $name$_.getUnmodifiableView();\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateSerializationCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" $writeString$(output, $number$, $name$_.getRaw(i));\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateSerializedSizeCode(
io::Printer* printer) const {
- printer->Print(variables_,
+ printer->Print(variables_,
"{\n"
" int dataSize = 0;\n");
- printer->Indent();
-
- printer->Print(variables_,
+ printer->Indent();
+
+ printer->Print(variables_,
"for (int i = 0; i < $name$_.size(); i++) {\n"
" dataSize += computeStringSizeNoTag($name$_.getRaw(i));\n"
"}\n");
-
+
printer->Print("size += dataSize;\n");
-
- printer->Print(variables_,
+
+ printer->Print(variables_,
"size += $tag_size$ * get$capitalized_name$List().size();\n");
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateEqualsCode(
io::Printer* printer) const {
printer->Print(
variables_,
"if (!get$capitalized_name$List()\n"
" .equals(other.get$capitalized_name$List())) return false;\n");
-}
-
+}
+
void RepeatedImmutableStringFieldGenerator::GenerateHashCode(
io::Printer* printer) const {
printer->Print(
@@ -1174,13 +1174,13 @@ void RepeatedImmutableStringFieldGenerator::GenerateHashCode(
" hash = (37 * hash) + $constant_name$;\n"
" hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
"}\n");
-}
-
+}
+
TProtoStringType RepeatedImmutableStringFieldGenerator::GetBoxedType() const {
- return "String";
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return "String";
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
index f6fb38b354..d209975918 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h
@@ -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: kenton@google.com (Kenton Varda)
-// Author: jonp@google.com (Jon Perlow)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_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: kenton@google.com (Kenton Varda)
+// Author: jonp@google.com (Jon Perlow)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
+
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -50,78 +50,78 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
+ public:
explicit ImmutableStringFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
int builderBitIndex, Context* context);
- ~ImmutableStringFieldGenerator();
-
+ ~ImmutableStringFieldGenerator();
+
// implements ImmutableFieldGenerator
// ---------------------------------------
- int GetNumBitsForMessage() const;
- int GetNumBitsForBuilder() const;
- void GenerateInterfaceMembers(io::Printer* printer) const;
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateInitializationCode(io::Printer* printer) const;
- void GenerateBuilderClearCode(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateBuildingCode(io::Printer* printer) const;
- void GenerateParsingCode(io::Printer* printer) const;
- void GenerateParsingDoneCode(io::Printer* printer) const;
- void GenerateSerializationCode(io::Printer* printer) const;
- void GenerateSerializedSizeCode(io::Printer* printer) const;
- void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;
- void GenerateEqualsCode(io::Printer* printer) const;
- void GenerateHashCode(io::Printer* printer) const;
+ int GetNumBitsForMessage() const;
+ int GetNumBitsForBuilder() const;
+ void GenerateInterfaceMembers(io::Printer* printer) const;
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateInitializationCode(io::Printer* printer) const;
+ void GenerateBuilderClearCode(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateBuildingCode(io::Printer* printer) const;
+ void GenerateParsingCode(io::Printer* printer) const;
+ void GenerateParsingDoneCode(io::Printer* printer) const;
+ void GenerateSerializationCode(io::Printer* printer) const;
+ void GenerateSerializedSizeCode(io::Printer* printer) const;
+ void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;
+ void GenerateEqualsCode(io::Printer* printer) const;
+ void GenerateHashCode(io::Printer* printer) const;
void GenerateKotlinDslMembers(io::Printer* printer) const;
-
+
TProtoStringType GetBoxedType() const;
-
- protected:
- const FieldDescriptor* descriptor_;
+
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldGenerator);
-};
-
-class ImmutableStringOneofFieldGenerator
- : public ImmutableStringFieldGenerator {
- public:
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldGenerator);
+};
+
+class ImmutableStringOneofFieldGenerator
+ : public ImmutableStringFieldGenerator {
+ public:
ImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
Context* context);
- ~ImmutableStringOneofFieldGenerator();
-
- private:
- void GenerateMembers(io::Printer* printer) const;
- void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateMergingCode(io::Printer* printer) const;
- void GenerateBuildingCode(io::Printer* printer) const;
- void GenerateParsingCode(io::Printer* printer) const;
- void GenerateSerializationCode(io::Printer* printer) const;
- void GenerateSerializedSizeCode(io::Printer* printer) const;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldGenerator);
-};
-
-class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
- public:
- explicit RepeatedImmutableStringFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, Context* context);
+ ~ImmutableStringOneofFieldGenerator();
+
+ private:
+ void GenerateMembers(io::Printer* printer) const;
+ void GenerateBuilderMembers(io::Printer* printer) const;
+ void GenerateMergingCode(io::Printer* printer) const;
+ void GenerateBuildingCode(io::Printer* printer) const;
+ void GenerateParsingCode(io::Printer* printer) const;
+ void GenerateSerializationCode(io::Printer* printer) const;
+ void GenerateSerializedSizeCode(io::Printer* printer) const;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldGenerator);
+};
+
+class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
+ public:
+ explicit RepeatedImmutableStringFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, Context* context);
~RepeatedImmutableStringFieldGenerator() override;
-
- // implements ImmutableFieldGenerator ---------------------------------------
+
+ // implements ImmutableFieldGenerator ---------------------------------------
int GetNumBitsForMessage() const override;
int GetNumBitsForBuilder() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
@@ -140,20 +140,20 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateEqualsCode(io::Printer* printer) const override;
void GenerateHashCode(io::Printer* printer) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
-
- private:
- const FieldDescriptor* descriptor_;
+
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
index dedd68fa9b..bfaedeba9a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -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: kenton@google.com (Kenton Varda)
-// Author: jonp@google.com (Jon Perlow)
-// 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: kenton@google.com (Kenton Varda)
+// Author: jonp@google.com (Jon Perlow)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
#include <google/protobuf/compiler/java/java_string_field_lite.h>
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/java/java_context.h>
@@ -48,42 +48,42 @@
#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 java {
-
-using internal::WireFormat;
-using internal::WireFormatLite;
-
-namespace {
-
-void SetPrimitiveVariables(const FieldDescriptor* descriptor,
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+using internal::WireFormat;
+using internal::WireFormatLite;
+
+namespace {
+
+void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int messageBitIndex, int builderBitIndex,
- const FieldGeneratorInfo* info,
- ClassNameResolver* name_resolver,
+ const FieldGeneratorInfo* info,
+ ClassNameResolver* name_resolver,
std::map<TProtoStringType, TProtoStringType>* variables) {
- SetCommonFieldVariables(descriptor, info, variables);
-
- (*variables)["empty_list"] =
- "com.google.protobuf.GeneratedMessageLite.emptyProtobufList()";
-
- (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["default_init"] =
- "= " + ImmutableDefaultValue(descriptor, name_resolver);
+ SetCommonFieldVariables(descriptor, info, variables);
+
+ (*variables)["empty_list"] =
+ "com.google.protobuf.GeneratedMessageLite.emptyProtobufList()";
+
+ (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default_init"] =
+ "= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "java.lang.String";
(*variables)["tag"] =
StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = StrCat(
- WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
+ WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// We use `x.getClass()` as a null check because it generates less bytecode
// than an `if (x == null) { throw ... }` statement.
(*variables)["null_check"] =
" java.lang.Class<?> valueClass = value.getClass();\n";
-
- // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
- // by the proto compiler
+
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
+ // by the proto compiler
(*variables)["deprecation"] =
descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
(*variables)["kt_deprecation"] =
@@ -92,98 +92,98 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
" is deprecated\") "
: "";
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
-
+
if (HasHasbit(descriptor)) {
- // For singular messages and builders, one bit is used for the hasField bit.
- (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
-
- // Note that these have a trailing ";".
- (*variables)["set_has_field_bit_message"] =
- GenerateSetBit(messageBitIndex) + ";";
- (*variables)["clear_has_field_bit_message"] =
- GenerateClearBit(messageBitIndex) + ";";
-
- (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
- } else {
- (*variables)["set_has_field_bit_message"] = "";
- (*variables)["clear_has_field_bit_message"] = "";
-
- (*variables)["is_field_present_message"] =
- "!" + (*variables)["name"] + "_.isEmpty()";
- }
-
- (*variables)["get_has_field_bit_from_local"] =
- GenerateGetBitFromLocal(builderBitIndex);
- (*variables)["set_has_field_bit_to_local"] =
- GenerateSetBitToLocal(messageBitIndex);
-}
-
-} // namespace
-
-// ===================================================================
-
+ // For singular messages and builders, one bit is used for the hasField bit.
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
+
+ // Note that these have a trailing ";".
+ (*variables)["set_has_field_bit_message"] =
+ GenerateSetBit(messageBitIndex) + ";";
+ (*variables)["clear_has_field_bit_message"] =
+ GenerateClearBit(messageBitIndex) + ";";
+
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
+ } else {
+ (*variables)["set_has_field_bit_message"] = "";
+ (*variables)["clear_has_field_bit_message"] = "";
+
+ (*variables)["is_field_present_message"] =
+ "!" + (*variables)["name"] + "_.isEmpty()";
+ }
+
+ (*variables)["get_has_field_bit_from_local"] =
+ GenerateGetBitFromLocal(builderBitIndex);
+ (*variables)["set_has_field_bit_to_local"] =
+ GenerateSetBitToLocal(messageBitIndex);
+}
+
+} // namespace
+
+// ===================================================================
+
ImmutableStringFieldLiteGenerator::ImmutableStringFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: descriptor_(descriptor),
messageBitIndex_(messageBitIndex),
name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-ImmutableStringFieldLiteGenerator::~ImmutableStringFieldLiteGenerator() {}
-
-int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+ImmutableStringFieldLiteGenerator::~ImmutableStringFieldLiteGenerator() {}
+
+int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
return HasHasbit(descriptor_) ? 1 : 0;
-}
-
-// A note about how strings are handled. In the SPEED and CODE_SIZE runtimes,
-// strings are not stored as java.lang.String in the Message because of two
-// issues:
-//
+}
+
+// A note about how strings are handled. In the SPEED and CODE_SIZE runtimes,
+// strings are not stored as java.lang.String in the Message because of two
+// issues:
+//
// 1. It wouldn't roundtrip byte arrays that were not valid UTF-8 encoded
-// strings, but rather fields that were raw bytes incorrectly marked
-// as strings in the proto file. This is common because in the proto1
-// syntax, string was the way to indicate bytes and C++ engineers can
-// easily make this mistake without affecting the C++ API. By converting to
-// strings immediately, some java code might corrupt these byte arrays as
-// it passes through a java server even if the field was never accessed by
-// application code.
-//
-// 2. There's a performance hit to converting between bytes and strings and
-// it many cases, the field is never even read by the application code. This
-// avoids unnecessary conversions in the common use cases.
-//
-// In the LITE_RUNTIME, we store strings as java.lang.String because we assume
-// that the users of this runtime are not subject to proto1 constraints and are
-// running code on devices that are user facing. That is, the developers are
-// properly incentivized to only fetch the data they need to read and wish to
-// reduce the number of allocations incurred when running on a user's device.
-
-// TODO(dweis): Consider dropping all of the *Bytes() methods. They really
-// shouldn't be necessary or used on devices.
+// strings, but rather fields that were raw bytes incorrectly marked
+// as strings in the proto file. This is common because in the proto1
+// syntax, string was the way to indicate bytes and C++ engineers can
+// easily make this mistake without affecting the C++ API. By converting to
+// strings immediately, some java code might corrupt these byte arrays as
+// it passes through a java server even if the field was never accessed by
+// application code.
+//
+// 2. There's a performance hit to converting between bytes and strings and
+// it many cases, the field is never even read by the application code. This
+// avoids unnecessary conversions in the common use cases.
+//
+// In the LITE_RUNTIME, we store strings as java.lang.String because we assume
+// that the users of this runtime are not subject to proto1 constraints and are
+// running code on devices that are user facing. That is, the developers are
+// properly incentivized to only fetch the data they need to read and wish to
+// reduce the number of allocations incurred when running on a user's device.
+
+// TODO(dweis): Consider dropping all of the *Bytes() methods. They really
+// shouldn't be necessary or used on devices.
void ImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$boolean has$capitalized_name$();\n");
- }
+ }
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.lang.String get$capitalized_name$();\n");
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$com.google.protobuf.ByteString\n"
" get$capitalized_name$Bytes();\n");
-}
-
+}
+
void ImmutableStringFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(variables_, "private java.lang.String $name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
-
+ PrintExtraFieldInfo(variables_, printer);
+
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(
@@ -193,8 +193,8 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers(
" return $get_has_field_bit_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -212,9 +212,9 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers(
" return com.google.protobuf.ByteString.copyFromUtf8($name$_);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$(\n"
" java.lang.String value) {\n"
"$null_check$"
@@ -222,7 +222,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers(
" $name$_ = value;\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $clear_has_field_bit_message$\n"
// The default value is not a simple literal so we want to
@@ -230,20 +230,20 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers(
// out of the default instance.
" $name$_ = getDefaultInstance().get$capitalized_name$();\n"
"}\n");
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$Bytes(\n"
" com.google.protobuf.ByteString value) {\n");
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" $name$_ = value.toStringUtf8();\n"
" $set_has_field_bit_message$\n"
"}\n");
-}
-
+}
+
void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
if (HasHazzer(descriptor_)) {
@@ -255,8 +255,8 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- }
-
+ }
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -265,19 +265,19 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
" return instance.get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
" return instance.get$capitalized_name$Bytes();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
" copyOnWrite();\n"
@@ -295,7 +295,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
printer->Print(
@@ -307,8 +307,8 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
@@ -346,42 +346,42 @@ void ImmutableStringFieldLiteGenerator::GenerateFieldInfo(
WriteIntToUtf16CharSequence(messageBitIndex_, output);
}
printer->Print(variables_, "\"$name$_\",\n");
-}
-
+}
+
void ImmutableStringFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $default$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $default$;\n");
+}
+
TProtoStringType ImmutableStringFieldLiteGenerator::GetBoxedType() const {
- return "java.lang.String";
-}
-
-// ===================================================================
-
+ return "java.lang.String";
+}
+
+// ===================================================================
+
ImmutableStringOneofFieldLiteGenerator::ImmutableStringOneofFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
: ImmutableStringFieldLiteGenerator(descriptor, messageBitIndex, context) {
- const OneofGeneratorInfo* info =
- context->GetOneofGeneratorInfo(descriptor->containing_oneof());
- SetCommonOneofVariables(descriptor, info, &variables_);
-}
-
-ImmutableStringOneofFieldLiteGenerator::
+ const OneofGeneratorInfo* info =
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
+ SetCommonOneofVariables(descriptor, info, &variables_);
+}
+
+ImmutableStringOneofFieldLiteGenerator::
~ImmutableStringOneofFieldLiteGenerator() {}
-
+
void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return $has_oneof_case_message$;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -394,9 +394,9 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
" return ref;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
@@ -407,9 +407,9 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
" return com.google.protobuf.ByteString.copyFromUtf8(ref);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
"$null_check$"
@@ -418,7 +418,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void ${$clear$capitalized_name$$}$() {\n"
" if ($has_oneof_case_message$) {\n"
" $clear_oneof_case_message$;\n"
@@ -426,21 +426,21 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
" }\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void ${$set$capitalized_name$Bytes$}$(\n"
" com.google.protobuf.ByteString value) {\n");
printer->Annotate("{", "}", descriptor_);
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" $oneof_name$_ = value.toStringUtf8();\n"
" $set_oneof_case_message$;\n"
"}\n");
-}
-
+}
+
void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo(
io::Printer* printer, std::vector<uint16_t>* output) const {
WriteIntToUtf16CharSequence(descriptor_->number(), output);
@@ -453,13 +453,13 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
GOOGLE_DCHECK(HasHazzer(descriptor_));
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
" return instance.has$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(
variables_,
@@ -468,9 +468,9 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
" return instance.get$capitalized_name$();\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$() {\n"
@@ -480,7 +480,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
" copyOnWrite();\n"
@@ -498,7 +498,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
/* builder */ true);
printer->Print(
@@ -510,55 +510,55 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
-// ===================================================================
-
-RepeatedImmutableStringFieldLiteGenerator::
+}
+
+// ===================================================================
+
+RepeatedImmutableStringFieldLiteGenerator::
RepeatedImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context)
: descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
SetPrimitiveVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
-}
-
-RepeatedImmutableStringFieldLiteGenerator::
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
+}
+
+RepeatedImmutableStringFieldLiteGenerator::
~RepeatedImmutableStringFieldLiteGenerator() {}
-
-int RepeatedImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
- return 0;
-}
-
+
+int RepeatedImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
+ return 0;
+}
+
void RepeatedImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$java.util.List<java.lang.String>\n"
" get$capitalized_name$List();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$int get$capitalized_name$Count();\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(
variables_,
"$deprecation$java.lang.String get$capitalized_name$(int index);\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$com.google.protobuf.ByteString\n"
" get$capitalized_name$Bytes(int index);\n");
-}
-
+}
+
void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
io::Printer* printer) const {
printer->Print(
variables_,
"private com.google.protobuf.Internal.ProtobufList<java.lang.String> "
"$name$_;\n");
- PrintExtraFieldInfo(variables_, printer);
+ PrintExtraFieldInfo(variables_, printer);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<java.lang.String> "
"${$get$capitalized_name$List$}$() {\n"
@@ -574,7 +574,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.lang.String "
"${$get$capitalized_name$$}$(int index) {\n"
@@ -583,7 +583,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$(int index) {\n"
@@ -591,7 +591,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
" $name$_.get(index));\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
printer->Print(
variables_,
"private void ensure$capitalized_name$IsMutable() {\n"
@@ -603,9 +603,9 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
" com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
" }\n"
"}\n");
-
+
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void set$capitalized_name$(\n"
" int index, java.lang.String value) {\n"
"$null_check$"
@@ -613,7 +613,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
" $name$_.set(index, value);\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void add$capitalized_name$(\n"
" java.lang.String value) {\n"
"$null_check$"
@@ -621,7 +621,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
" $name$_.add(value);\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void addAll$capitalized_name$(\n"
" java.lang.Iterable<java.lang.String> values) {\n"
" ensure$capitalized_name$IsMutable();\n"
@@ -629,28 +629,28 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
" values, $name$_);\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void clear$capitalized_name$() {\n"
" $name$_ = $empty_list$;\n"
"}\n");
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
+ printer->Print(variables_,
"private void add$capitalized_name$Bytes(\n"
" com.google.protobuf.ByteString value) {\n");
- if (CheckUtf8(descriptor_)) {
+ if (CheckUtf8(descriptor_)) {
printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
- }
- printer->Print(variables_,
+ }
+ printer->Print(variables_,
" ensure$capitalized_name$IsMutable();\n"
" $name$_.add(value.toStringUtf8());\n"
"}\n");
-}
-
+}
+
void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
io::Printer* printer) const {
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.util.List<java.lang.String>\n"
" ${$get$capitalized_name$List$}$() {\n"
@@ -667,7 +667,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public java.lang.String "
"${$get$capitalized_name$$}$(int index) {\n"
@@ -676,7 +676,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
LIST_INDEXED_GETTER);
- printer->Print(variables_,
+ printer->Print(variables_,
"@java.lang.Override\n"
"$deprecation$public com.google.protobuf.ByteString\n"
" ${$get$capitalized_name$Bytes$}$(int index) {\n"
@@ -685,7 +685,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
" int index, java.lang.String value) {\n"
" copyOnWrite();\n"
@@ -695,7 +695,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
" java.lang.String value) {\n"
" copyOnWrite();\n"
@@ -705,7 +705,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ true);
- printer->Print(variables_,
+ printer->Print(variables_,
"$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
" java.lang.Iterable<java.lang.String> values) {\n"
" copyOnWrite();\n"
@@ -723,7 +723,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-
+
WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ true);
printer->Print(
@@ -735,8 +735,8 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
" return this;\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
-}
-
+}
+
void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
printer->Print(
@@ -844,18 +844,18 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateFieldInfo(
WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
output);
printer->Print(variables_, "\"$name$_\",\n");
-}
-
+}
+
void RepeatedImmutableStringFieldLiteGenerator::GenerateInitializationCode(
io::Printer* printer) const {
- printer->Print(variables_, "$name$_ = $empty_list$;\n");
-}
-
+ printer->Print(variables_, "$name$_ = $empty_list$;\n");
+}
+
TProtoStringType RepeatedImmutableStringFieldLiteGenerator::GetBoxedType() const {
return "java.lang.String";
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h
index 1e6e5f3dfb..02cf5c1657 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h
@@ -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: kenton@google.com (Kenton Varda)
-// Author: jonp@google.com (Jon Perlow)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_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: kenton@google.com (Kenton Varda)
+// Author: jonp@google.com (Jon Perlow)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
+
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
#include <google/protobuf/compiler/java/java_field.h>
-
-namespace google {
-namespace protobuf {
+
+namespace google {
+namespace protobuf {
namespace compiler {
namespace java {
class Context; // context.h
@@ -52,19 +52,19 @@ class ClassNameResolver; // name_resolver.h
} // namespace compiler
} // namespace protobuf
} // namespace google
-
+
namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
- public:
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
+ public:
explicit ImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex,
Context* context);
~ImmutableStringFieldLiteGenerator() override;
-
+
// implements ImmutableFieldLiteGenerator
// ------------------------------------
int GetNumBitsForMessage() const override;
@@ -75,43 +75,43 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
- protected:
- const FieldDescriptor* descriptor_;
+ protected:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- const int messageBitIndex_;
- ClassNameResolver* name_resolver_;
-
- private:
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldLiteGenerator);
-};
-
-class ImmutableStringOneofFieldLiteGenerator
- : public ImmutableStringFieldLiteGenerator {
- public:
+ const int messageBitIndex_;
+ ClassNameResolver* name_resolver_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldLiteGenerator);
+};
+
+class ImmutableStringOneofFieldLiteGenerator
+ : public ImmutableStringFieldLiteGenerator {
+ public:
ImmutableStringOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
int messageBitIndex, Context* context);
~ImmutableStringOneofFieldLiteGenerator() override;
-
- private:
+
+ private:
void GenerateMembers(io::Printer* printer) const override;
void GenerateBuilderMembers(io::Printer* printer) const override;
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldLiteGenerator);
-};
-
-class RepeatedImmutableStringFieldLiteGenerator
- : public ImmutableFieldLiteGenerator {
- public:
- explicit RepeatedImmutableStringFieldLiteGenerator(
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldLiteGenerator);
+};
+
+class RepeatedImmutableStringFieldLiteGenerator
+ : public ImmutableFieldLiteGenerator {
+ public:
+ explicit RepeatedImmutableStringFieldLiteGenerator(
const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
~RepeatedImmutableStringFieldLiteGenerator() override;
-
- // implements ImmutableFieldLiteGenerator ------------------------------------
+
+ // implements ImmutableFieldLiteGenerator ------------------------------------
int GetNumBitsForMessage() const override;
void GenerateInterfaceMembers(io::Printer* printer) const override;
void GenerateMembers(io::Printer* printer) const override;
@@ -120,20 +120,20 @@ class RepeatedImmutableStringFieldLiteGenerator
void GenerateFieldInfo(io::Printer* printer,
std::vector<uint16_t>* output) const override;
void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
+
TProtoStringType GetBoxedType() const override;
- private:
- const FieldDescriptor* descriptor_;
+ private:
+ const FieldDescriptor* descriptor_;
std::map<TProtoStringType, TProtoStringType> variables_;
- ClassNameResolver* name_resolver_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldLiteGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
+ ClassNameResolver* name_resolver_;
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldLiteGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
index 5273b81278..10de997f0c 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc
@@ -1,33 +1,33 @@
-// 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_generator.h>
#include <google/protobuf/compiler/java/java_generator.h>
#include <google/protobuf/compiler/java/java_kotlin_generator.h>
@@ -39,9 +39,9 @@
#include <google/protobuf/compiler/objectivec/objectivec_generator.h>
#include <google/protobuf/compiler/php/php_generator.h>
#include <google/protobuf/compiler/ruby/ruby_generator.h>
-
+
#include <google/protobuf/port_def.inc>
-
+
namespace google {
namespace protobuf {
namespace compiler {
@@ -49,34 +49,34 @@ namespace compiler {
int ProtobufMain(int argc, char* argv[]) {
CommandLineInterface cli;
- cli.AllowPlugins("protoc-");
-
- // Proto2 C++
+ cli.AllowPlugins("protoc-");
+
+ // Proto2 C++
cpp::CppGenerator cpp_generator;
- cli.RegisterGenerator("--cpp_out", "--cpp_opt", &cpp_generator,
- "Generate C++ header and source.");
-
+ cli.RegisterGenerator("--cpp_out", "--cpp_opt", &cpp_generator,
+ "Generate C++ header and source.");
+
#ifdef GOOGLE_PROTOBUF_RUNTIME_INCLUDE_BASE
cpp_generator.set_opensource_runtime(true);
cpp_generator.set_runtime_include_base(GOOGLE_PROTOBUF_RUNTIME_INCLUDE_BASE);
#endif
- // Proto2 Java
+ // Proto2 Java
java::JavaGenerator java_generator;
cli.RegisterGenerator("--java_out", "--java_opt", &java_generator,
- "Generate Java source file.");
-
+ "Generate Java source file.");
+
// Proto2 Kotlin
java::KotlinGenerator kt_generator;
cli.RegisterGenerator("--kotlin_out", "--kotlin_opt", &kt_generator,
"Generate Kotlin file.");
- // Proto2 Python
+ // Proto2 Python
python::Generator py_generator;
cli.RegisterGenerator("--python_out", "--python_opt", &py_generator,
- "Generate Python source file.");
-
+ "Generate Python source file.");
+
// PHP
php::Generator php_generator;
cli.RegisterGenerator("--php_out", "--php_opt", &php_generator,
@@ -106,9 +106,9 @@ int ProtobufMain(int argc, char* argv[]) {
js::Generator js_generator;
cli.RegisterGenerator("--js_out", "--js_opt", &js_generator,
"Generate JavaScript source.");
-
- return cli.Run(argc, argv);
-}
+
+ return cli.Run(argc, argv);
+}
} // namespace compiler
} // namespace protobuf
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
index 8b42ffbc99..41d70aa255 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc
@@ -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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Recursive descent FTW.
-
+// 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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Recursive descent FTW.
+
#include <google/protobuf/compiler/parser.h>
-#include <float.h>
+#include <float.h>
#include <cstdint>
-#include <limits>
+#include <limits>
#include <unordered_map>
#include <unordered_set>
-
+
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
@@ -53,20 +53,20 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/hash.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-
-using internal::WireFormat;
-
-namespace {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+using internal::WireFormat;
+
+namespace {
+
typedef std::unordered_map<TProtoStringType, FieldDescriptorProto::Type> TypeNameMap;
-
-TypeNameMap MakeTypeNameTable() {
- TypeNameMap result;
-
+
+TypeNameMap MakeTypeNameTable() {
+ TypeNameMap result;
+
result["double"] = FieldDescriptorProto::TYPE_DOUBLE;
result["float"] = FieldDescriptorProto::TYPE_FLOAT;
result["uint64"] = FieldDescriptorProto::TYPE_UINT64;
@@ -75,47 +75,47 @@ TypeNameMap MakeTypeNameTable() {
result["bool"] = FieldDescriptorProto::TYPE_BOOL;
result["string"] = FieldDescriptorProto::TYPE_STRING;
result["group"] = FieldDescriptorProto::TYPE_GROUP;
-
+
result["bytes"] = FieldDescriptorProto::TYPE_BYTES;
result["uint32"] = FieldDescriptorProto::TYPE_UINT32;
- result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32;
- result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64;
+ result["sfixed32"] = FieldDescriptorProto::TYPE_SFIXED32;
+ result["sfixed64"] = FieldDescriptorProto::TYPE_SFIXED64;
result["int32"] = FieldDescriptorProto::TYPE_INT32;
result["int64"] = FieldDescriptorProto::TYPE_INT64;
result["sint32"] = FieldDescriptorProto::TYPE_SINT32;
result["sint64"] = FieldDescriptorProto::TYPE_SINT64;
-
- return result;
-}
-
-const TypeNameMap kTypeNames = MakeTypeNameTable();
-
-// Camel-case the field name and append "Entry" for generated map entry name.
+
+ return result;
+}
+
+const TypeNameMap kTypeNames = MakeTypeNameTable();
+
+// Camel-case the field name and append "Entry" for generated map entry name.
// e.g. map<KeyType, ValueType> foo_map => FooMapEntry
TProtoStringType MapEntryName(const TProtoStringType& field_name) {
TProtoStringType result;
- static const char kSuffix[] = "Entry";
- result.reserve(field_name.size() + sizeof(kSuffix));
- bool cap_next = true;
- for (int i = 0; i < field_name.size(); ++i) {
- if (field_name[i] == '_') {
- cap_next = true;
- } else if (cap_next) {
- // Note: Do not use ctype.h due to locales.
- if ('a' <= field_name[i] && field_name[i] <= 'z') {
- result.push_back(field_name[i] - 'a' + 'A');
- } else {
- result.push_back(field_name[i]);
- }
- cap_next = false;
- } else {
- result.push_back(field_name[i]);
- }
- }
- result.append(kSuffix);
- return result;
-}
-
+ static const char kSuffix[] = "Entry";
+ result.reserve(field_name.size() + sizeof(kSuffix));
+ bool cap_next = true;
+ for (int i = 0; i < field_name.size(); ++i) {
+ if (field_name[i] == '_') {
+ cap_next = true;
+ } else if (cap_next) {
+ // Note: Do not use ctype.h due to locales.
+ if ('a' <= field_name[i] && field_name[i] <= 'z') {
+ result.push_back(field_name[i] - 'a' + 'A');
+ } else {
+ result.push_back(field_name[i]);
+ }
+ cap_next = false;
+ } else {
+ result.push_back(field_name[i]);
+ }
+ }
+ result.append(kSuffix);
+ return result;
+}
+
bool IsUppercase(char c) { return c >= 'A' && c <= 'Z'; }
bool IsLowercase(char c) { return c >= 'a' && c <= 'z'; }
@@ -169,231 +169,231 @@ bool IsNumberFollowUnderscore(const TProtoStringType& name) {
return false;
}
-} // anonymous namespace
-
-// Makes code slightly more readable. The meaning of "DO(foo)" is
-// "Execute foo and fail if it fails.", where failure is indicated by
-// returning false.
+} // anonymous namespace
+
+// Makes code slightly more readable. The meaning of "DO(foo)" is
+// "Execute foo and fail if it fails.", where failure is indicated by
+// returning false.
#define DO(STATEMENT) \
if (STATEMENT) { \
} else \
return false
-
-// ===================================================================
-
-Parser::Parser()
+
+// ===================================================================
+
+Parser::Parser()
: input_(NULL),
error_collector_(NULL),
source_location_table_(NULL),
had_errors_(false),
require_syntax_identifier_(false),
stop_after_syntax_identifier_(false) {
-}
-
+}
+
Parser::~Parser() {}
-
-// ===================================================================
-
-inline bool Parser::LookingAt(const char* text) {
- return input_->current().text == text;
-}
-
-inline bool Parser::LookingAtType(io::Tokenizer::TokenType token_type) {
- return input_->current().type == token_type;
-}
-
+
+// ===================================================================
+
+inline bool Parser::LookingAt(const char* text) {
+ return input_->current().text == text;
+}
+
+inline bool Parser::LookingAtType(io::Tokenizer::TokenType token_type) {
+ return input_->current().type == token_type;
+}
+
inline bool Parser::AtEnd() { return LookingAtType(io::Tokenizer::TYPE_END); }
-
-bool Parser::TryConsume(const char* text) {
- if (LookingAt(text)) {
- input_->Next();
- return true;
- } else {
- return false;
- }
-}
-
-bool Parser::Consume(const char* text, const char* error) {
- if (TryConsume(text)) {
- return true;
- } else {
- AddError(error);
- return false;
- }
-}
-
-bool Parser::Consume(const char* text) {
- if (TryConsume(text)) {
- return true;
- } else {
+
+bool Parser::TryConsume(const char* text) {
+ if (LookingAt(text)) {
+ input_->Next();
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool Parser::Consume(const char* text, const char* error) {
+ if (TryConsume(text)) {
+ return true;
+ } else {
+ AddError(error);
+ return false;
+ }
+}
+
+bool Parser::Consume(const char* text) {
+ if (TryConsume(text)) {
+ return true;
+ } else {
AddError("Expected \"" + TProtoStringType(text) + "\".");
- return false;
- }
-}
-
+ return false;
+ }
+}
+
bool Parser::ConsumeIdentifier(TProtoStringType* output, const char* error) {
- if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
- *output = input_->current().text;
- input_->Next();
- return true;
- } else {
- AddError(error);
- return false;
- }
-}
-
-bool Parser::ConsumeInteger(int* output, const char* error) {
- if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
- uint64 value = 0;
+ if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
+ *output = input_->current().text;
+ input_->Next();
+ return true;
+ } else {
+ AddError(error);
+ return false;
+ }
+}
+
+bool Parser::ConsumeInteger(int* output, const char* error) {
+ if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
+ uint64 value = 0;
if (!io::Tokenizer::ParseInteger(input_->current().text,
std::numeric_limits<int32_t>::max(),
&value)) {
- AddError("Integer out of range.");
- // We still return true because we did, in fact, parse an integer.
- }
- *output = value;
- input_->Next();
- return true;
- } else {
- AddError(error);
- return false;
- }
-}
-
-bool Parser::ConsumeSignedInteger(int* output, const char* error) {
- bool is_negative = false;
+ AddError("Integer out of range.");
+ // We still return true because we did, in fact, parse an integer.
+ }
+ *output = value;
+ input_->Next();
+ return true;
+ } else {
+ AddError(error);
+ return false;
+ }
+}
+
+bool Parser::ConsumeSignedInteger(int* output, const char* error) {
+ bool is_negative = false;
uint64_t max_value = std::numeric_limits<int32_t>::max();
- if (TryConsume("-")) {
- is_negative = true;
- max_value += 1;
- }
+ if (TryConsume("-")) {
+ is_negative = true;
+ max_value += 1;
+ }
uint64_t value = 0;
- DO(ConsumeInteger64(max_value, &value, error));
- if (is_negative) value *= -1;
- *output = value;
- return true;
-}
-
+ DO(ConsumeInteger64(max_value, &value, error));
+ if (is_negative) value *= -1;
+ *output = value;
+ return true;
+}
+
bool Parser::ConsumeInteger64(uint64_t max_value, uint64_t* output,
- const char* error) {
- if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
+ const char* error) {
+ if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
uint64 parsed;
- if (!io::Tokenizer::ParseInteger(input_->current().text, max_value,
+ if (!io::Tokenizer::ParseInteger(input_->current().text, max_value,
&parsed)) {
- AddError("Integer out of range.");
- // We still return true because we did, in fact, parse an integer.
+ AddError("Integer out of range.");
+ // We still return true because we did, in fact, parse an integer.
parsed = 0;
- }
+ }
*output = parsed;
- input_->Next();
- return true;
- } else {
- AddError(error);
- return false;
- }
-}
-
-bool Parser::ConsumeNumber(double* output, const char* error) {
- if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) {
- *output = io::Tokenizer::ParseFloat(input_->current().text);
- input_->Next();
- return true;
- } else if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
- // Also accept integers.
- uint64 value = 0;
+ input_->Next();
+ return true;
+ } else {
+ AddError(error);
+ return false;
+ }
+}
+
+bool Parser::ConsumeNumber(double* output, const char* error) {
+ if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) {
+ *output = io::Tokenizer::ParseFloat(input_->current().text);
+ input_->Next();
+ return true;
+ } else if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {
+ // Also accept integers.
+ uint64 value = 0;
if (!io::Tokenizer::ParseInteger(input_->current().text,
std::numeric_limits<uint64_t>::max(),
&value)) {
- AddError("Integer out of range.");
- // We still return true because we did, in fact, parse a number.
- }
- *output = value;
- input_->Next();
- return true;
- } else if (LookingAt("inf")) {
+ AddError("Integer out of range.");
+ // We still return true because we did, in fact, parse a number.
+ }
+ *output = value;
+ input_->Next();
+ return true;
+ } else if (LookingAt("inf")) {
*output = std::numeric_limits<double>::infinity();
- input_->Next();
- return true;
- } else if (LookingAt("nan")) {
+ input_->Next();
+ return true;
+ } else if (LookingAt("nan")) {
*output = std::numeric_limits<double>::quiet_NaN();
- input_->Next();
- return true;
- } else {
- AddError(error);
- return false;
- }
-}
-
+ input_->Next();
+ return true;
+ } else {
+ AddError(error);
+ return false;
+ }
+}
+
bool Parser::ConsumeString(TProtoStringType* output, const char* error) {
- if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
- io::Tokenizer::ParseString(input_->current().text, output);
- input_->Next();
- // Allow C++ like concatenation of adjacent string tokens.
- while (LookingAtType(io::Tokenizer::TYPE_STRING)) {
- io::Tokenizer::ParseStringAppend(input_->current().text, output);
- input_->Next();
- }
- return true;
- } else {
- AddError(error);
- return false;
- }
-}
-
+ if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
+ io::Tokenizer::ParseString(input_->current().text, output);
+ input_->Next();
+ // Allow C++ like concatenation of adjacent string tokens.
+ while (LookingAtType(io::Tokenizer::TYPE_STRING)) {
+ io::Tokenizer::ParseStringAppend(input_->current().text, output);
+ input_->Next();
+ }
+ return true;
+ } else {
+ AddError(error);
+ return false;
+ }
+}
+
bool Parser::TryConsumeEndOfDeclaration(const char* text,
const LocationRecorder* location) {
- if (LookingAt(text)) {
+ if (LookingAt(text)) {
TProtoStringType leading, trailing;
std::vector<TProtoStringType> detached;
- input_->NextWithComments(&trailing, &detached, &leading);
-
- // Save the leading comments for next time, and recall the leading comments
- // from last time.
- leading.swap(upcoming_doc_comments_);
-
- if (location != NULL) {
- upcoming_detached_comments_.swap(detached);
- location->AttachComments(&leading, &trailing, &detached);
- } else if (strcmp(text, "}") == 0) {
- // If the current location is null and we are finishing the current scope,
- // drop pending upcoming detached comments.
- upcoming_detached_comments_.swap(detached);
- } else {
- // Otherwise, append the new detached comments to the existing upcoming
- // detached comments.
- upcoming_detached_comments_.insert(upcoming_detached_comments_.end(),
- detached.begin(), detached.end());
- }
-
- return true;
- } else {
- return false;
- }
-}
-
+ input_->NextWithComments(&trailing, &detached, &leading);
+
+ // Save the leading comments for next time, and recall the leading comments
+ // from last time.
+ leading.swap(upcoming_doc_comments_);
+
+ if (location != NULL) {
+ upcoming_detached_comments_.swap(detached);
+ location->AttachComments(&leading, &trailing, &detached);
+ } else if (strcmp(text, "}") == 0) {
+ // If the current location is null and we are finishing the current scope,
+ // drop pending upcoming detached comments.
+ upcoming_detached_comments_.swap(detached);
+ } else {
+ // Otherwise, append the new detached comments to the existing upcoming
+ // detached comments.
+ upcoming_detached_comments_.insert(upcoming_detached_comments_.end(),
+ detached.begin(), detached.end());
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+}
+
bool Parser::ConsumeEndOfDeclaration(const char* text,
const LocationRecorder* location) {
- if (TryConsumeEndOfDeclaration(text, location)) {
- return true;
- } else {
+ if (TryConsumeEndOfDeclaration(text, location)) {
+ return true;
+ } else {
AddError("Expected \"" + TProtoStringType(text) + "\".");
- return false;
- }
-}
-
-// -------------------------------------------------------------------
-
+ return false;
+ }
+}
+
+// -------------------------------------------------------------------
+
void Parser::AddError(int line, int column, const TProtoStringType& error) {
- if (error_collector_ != NULL) {
- error_collector_->AddError(line, column, error);
- }
- had_errors_ = true;
-}
-
+ if (error_collector_ != NULL) {
+ error_collector_->AddError(line, column, error);
+ }
+ had_errors_ = true;
+}
+
void Parser::AddError(const TProtoStringType& error) {
- AddError(input_->current().line, input_->current().column, error);
-}
-
+ AddError(input_->current().line, input_->current().column, error);
+}
+
void Parser::AddWarning(const TProtoStringType& warning) {
if (error_collector_ != nullptr) {
error_collector_->AddWarning(input_->current().line,
@@ -401,21 +401,21 @@ void Parser::AddWarning(const TProtoStringType& warning) {
}
}
-// -------------------------------------------------------------------
-
-Parser::LocationRecorder::LocationRecorder(Parser* parser)
+// -------------------------------------------------------------------
+
+Parser::LocationRecorder::LocationRecorder(Parser* parser)
: parser_(parser),
source_code_info_(parser->source_code_info_),
location_(parser_->source_code_info_->add_location()) {
- location_->add_span(parser_->input_->current().line);
- location_->add_span(parser_->input_->current().column);
-}
-
-Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent) {
+ location_->add_span(parser_->input_->current().line);
+ location_->add_span(parser_->input_->current().column);
+}
+
+Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent) {
Init(parent, parent.source_code_info_);
-}
-
-Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,
+}
+
+Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,
int path1,
SourceCodeInfo* source_code_info) {
Init(parent, source_code_info);
@@ -423,66 +423,66 @@ Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,
}
Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,
- int path1) {
+ int path1) {
Init(parent, parent.source_code_info_);
- AddPath(path1);
-}
-
-Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,
- int path1, int path2) {
+ AddPath(path1);
+}
+
+Parser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,
+ int path1, int path2) {
Init(parent, parent.source_code_info_);
- AddPath(path1);
- AddPath(path2);
-}
-
+ AddPath(path1);
+ AddPath(path2);
+}
+
void Parser::LocationRecorder::Init(const LocationRecorder& parent,
SourceCodeInfo* source_code_info) {
- parser_ = parent.parser_;
+ parser_ = parent.parser_;
source_code_info_ = source_code_info;
location_ = source_code_info_->add_location();
- location_->mutable_path()->CopyFrom(parent.location_->path());
-
- location_->add_span(parser_->input_->current().line);
- location_->add_span(parser_->input_->current().column);
-}
-
-Parser::LocationRecorder::~LocationRecorder() {
- if (location_->span_size() <= 2) {
- EndAt(parser_->input_->previous());
- }
-}
-
-void Parser::LocationRecorder::AddPath(int path_component) {
- location_->add_path(path_component);
-}
-
-void Parser::LocationRecorder::StartAt(const io::Tokenizer::Token& token) {
- location_->set_span(0, token.line);
- location_->set_span(1, token.column);
-}
-
-void Parser::LocationRecorder::StartAt(const LocationRecorder& other) {
- location_->set_span(0, other.location_->span(0));
- location_->set_span(1, other.location_->span(1));
-}
-
-void Parser::LocationRecorder::EndAt(const io::Tokenizer::Token& token) {
- if (token.line != location_->span(0)) {
- location_->add_span(token.line);
- }
- location_->add_span(token.end_column);
-}
-
+ location_->mutable_path()->CopyFrom(parent.location_->path());
+
+ location_->add_span(parser_->input_->current().line);
+ location_->add_span(parser_->input_->current().column);
+}
+
+Parser::LocationRecorder::~LocationRecorder() {
+ if (location_->span_size() <= 2) {
+ EndAt(parser_->input_->previous());
+ }
+}
+
+void Parser::LocationRecorder::AddPath(int path_component) {
+ location_->add_path(path_component);
+}
+
+void Parser::LocationRecorder::StartAt(const io::Tokenizer::Token& token) {
+ location_->set_span(0, token.line);
+ location_->set_span(1, token.column);
+}
+
+void Parser::LocationRecorder::StartAt(const LocationRecorder& other) {
+ location_->set_span(0, other.location_->span(0));
+ location_->set_span(1, other.location_->span(1));
+}
+
+void Parser::LocationRecorder::EndAt(const io::Tokenizer::Token& token) {
+ if (token.line != location_->span(0)) {
+ location_->add_span(token.line);
+ }
+ location_->add_span(token.end_column);
+}
+
void Parser::LocationRecorder::RecordLegacyLocation(
const Message* descriptor,
- DescriptorPool::ErrorCollector::ErrorLocation location) {
- if (parser_->source_location_table_ != NULL) {
- parser_->source_location_table_->Add(
- descriptor, location, location_->span(0), location_->span(1));
- }
-}
-
+ DescriptorPool::ErrorCollector::ErrorLocation location) {
+ if (parser_->source_location_table_ != NULL) {
+ parser_->source_location_table_->Add(
+ descriptor, location, location_->span(0), location_->span(1));
+ }
+}
+
void Parser::LocationRecorder::RecordLegacyImportLocation(
const Message* descriptor, const TProtoStringType& name) {
if (parser_->source_location_table_ != nullptr) {
@@ -495,113 +495,113 @@ int Parser::LocationRecorder::CurrentPathSize() const {
return location_->path_size();
}
-void Parser::LocationRecorder::AttachComments(
+void Parser::LocationRecorder::AttachComments(
TProtoStringType* leading, TProtoStringType* trailing,
std::vector<TProtoStringType>* detached_comments) const {
- GOOGLE_CHECK(!location_->has_leading_comments());
- GOOGLE_CHECK(!location_->has_trailing_comments());
-
- if (!leading->empty()) {
- location_->mutable_leading_comments()->swap(*leading);
- }
- if (!trailing->empty()) {
- location_->mutable_trailing_comments()->swap(*trailing);
- }
- for (int i = 0; i < detached_comments->size(); ++i) {
+ GOOGLE_CHECK(!location_->has_leading_comments());
+ GOOGLE_CHECK(!location_->has_trailing_comments());
+
+ if (!leading->empty()) {
+ location_->mutable_leading_comments()->swap(*leading);
+ }
+ if (!trailing->empty()) {
+ location_->mutable_trailing_comments()->swap(*trailing);
+ }
+ for (int i = 0; i < detached_comments->size(); ++i) {
location_->add_leading_detached_comments()->swap((*detached_comments)[i]);
- }
- detached_comments->clear();
-}
-
-// -------------------------------------------------------------------
-
-void Parser::SkipStatement() {
- while (true) {
- if (AtEnd()) {
- return;
- } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
- return;
- } else if (TryConsume("{")) {
- SkipRestOfBlock();
- return;
- } else if (LookingAt("}")) {
- return;
- }
- }
- input_->Next();
- }
-}
-
-void Parser::SkipRestOfBlock() {
- while (true) {
- if (AtEnd()) {
- return;
- } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {
- if (TryConsumeEndOfDeclaration("}", NULL)) {
- return;
- } else if (TryConsume("{")) {
- SkipRestOfBlock();
- }
- }
- input_->Next();
- }
-}
-
-// ===================================================================
-
-bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
- bool has_allow_alias = false;
- bool allow_alias = false;
-
- for (int i = 0; i < proto->options().uninterpreted_option_size(); i++) {
- const UninterpretedOption option = proto->options().uninterpreted_option(i);
- if (option.name_size() > 1) {
- continue;
- }
- if (!option.name(0).is_extension() &&
- option.name(0).name_part() == "allow_alias") {
- has_allow_alias = true;
- if (option.identifier_value() == "true") {
- allow_alias = true;
- }
- break;
- }
- }
-
- if (has_allow_alias && !allow_alias) {
+ }
+ detached_comments->clear();
+}
+
+// -------------------------------------------------------------------
+
+void Parser::SkipStatement() {
+ while (true) {
+ if (AtEnd()) {
+ return;
+ } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {
+ if (TryConsumeEndOfDeclaration(";", NULL)) {
+ return;
+ } else if (TryConsume("{")) {
+ SkipRestOfBlock();
+ return;
+ } else if (LookingAt("}")) {
+ return;
+ }
+ }
+ input_->Next();
+ }
+}
+
+void Parser::SkipRestOfBlock() {
+ while (true) {
+ if (AtEnd()) {
+ return;
+ } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {
+ if (TryConsumeEndOfDeclaration("}", NULL)) {
+ return;
+ } else if (TryConsume("{")) {
+ SkipRestOfBlock();
+ }
+ }
+ input_->Next();
+ }
+}
+
+// ===================================================================
+
+bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
+ bool has_allow_alias = false;
+ bool allow_alias = false;
+
+ for (int i = 0; i < proto->options().uninterpreted_option_size(); i++) {
+ const UninterpretedOption option = proto->options().uninterpreted_option(i);
+ if (option.name_size() > 1) {
+ continue;
+ }
+ if (!option.name(0).is_extension() &&
+ option.name(0).name_part() == "allow_alias") {
+ has_allow_alias = true;
+ if (option.identifier_value() == "true") {
+ allow_alias = true;
+ }
+ break;
+ }
+ }
+
+ if (has_allow_alias && !allow_alias) {
TProtoStringType error =
- "\"" + proto->name() +
- "\" declares 'option allow_alias = false;' which has no effect. "
- "Please remove the declaration.";
- // This needlessly clutters declarations with nops.
- AddError(error);
- return false;
- }
-
+ "\"" + proto->name() +
+ "\" declares 'option allow_alias = false;' which has no effect. "
+ "Please remove the declaration.";
+ // This needlessly clutters declarations with nops.
+ AddError(error);
+ return false;
+ }
+
std::set<int> used_values;
- bool has_duplicates = false;
- for (int i = 0; i < proto->value_size(); ++i) {
+ bool has_duplicates = false;
+ for (int i = 0; i < proto->value_size(); ++i) {
const EnumValueDescriptorProto& enum_value = proto->value(i);
- if (used_values.find(enum_value.number()) != used_values.end()) {
- has_duplicates = true;
- break;
- } else {
- used_values.insert(enum_value.number());
- }
- }
- if (allow_alias && !has_duplicates) {
+ if (used_values.find(enum_value.number()) != used_values.end()) {
+ has_duplicates = true;
+ break;
+ } else {
+ used_values.insert(enum_value.number());
+ }
+ }
+ if (allow_alias && !has_duplicates) {
TProtoStringType error =
- "\"" + proto->name() +
- "\" declares support for enum aliases but no enum values share field "
- "numbers. Please remove the unnecessary 'option allow_alias = true;' "
- "declaration.";
- // Generate an error if an enum declares support for duplicate enum values
- // and does not use it protect future authors.
- AddError(error);
- return false;
- }
-
+ "\"" + proto->name() +
+ "\" declares support for enum aliases but no enum values share field "
+ "numbers. Please remove the unnecessary 'option allow_alias = true;' "
+ "declaration.";
+ // Generate an error if an enum declares support for duplicate enum values
+ // and does not use it protect future authors.
+ AddError(error);
+ return false;
+ }
+
// Enforce that enum constants must be UPPER_CASE except in case of
// enum_alias.
if (!allow_alias) {
@@ -615,159 +615,159 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) {
}
}
- return true;
-}
-
-bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
- input_ = input;
- had_errors_ = false;
- syntax_identifier_.clear();
-
- // Note that |file| could be NULL at this point if
- // stop_after_syntax_identifier_ is true. So, we conservatively allocate
- // SourceCodeInfo on the stack, then swap it into the FileDescriptorProto
- // later on.
- SourceCodeInfo source_code_info;
- source_code_info_ = &source_code_info;
-
- if (LookingAtType(io::Tokenizer::TYPE_START)) {
- // Advance to first token.
- input_->NextWithComments(NULL, &upcoming_detached_comments_,
- &upcoming_doc_comments_);
- }
-
- {
- LocationRecorder root_location(this);
+ return true;
+}
+
+bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
+ input_ = input;
+ had_errors_ = false;
+ syntax_identifier_.clear();
+
+ // Note that |file| could be NULL at this point if
+ // stop_after_syntax_identifier_ is true. So, we conservatively allocate
+ // SourceCodeInfo on the stack, then swap it into the FileDescriptorProto
+ // later on.
+ SourceCodeInfo source_code_info;
+ source_code_info_ = &source_code_info;
+
+ if (LookingAtType(io::Tokenizer::TYPE_START)) {
+ // Advance to first token.
+ input_->NextWithComments(NULL, &upcoming_detached_comments_,
+ &upcoming_doc_comments_);
+ }
+
+ {
+ LocationRecorder root_location(this);
root_location.RecordLegacyLocation(file,
DescriptorPool::ErrorCollector::OTHER);
-
- if (require_syntax_identifier_ || LookingAt("syntax")) {
- if (!ParseSyntaxIdentifier(root_location)) {
- // Don't attempt to parse the file if we didn't recognize the syntax
- // identifier.
- return false;
- }
- // Store the syntax into the file.
- if (file != NULL) file->set_syntax(syntax_identifier_);
- } else if (!stop_after_syntax_identifier_) {
- syntax_identifier_ = "proto2";
- }
-
- if (stop_after_syntax_identifier_) return !had_errors_;
-
- // Repeatedly parse statements until we reach the end of the file.
- while (!AtEnd()) {
- if (!ParseTopLevelStatement(file, root_location)) {
- // This statement failed to parse. Skip it, but keep looping to parse
- // other statements.
- SkipStatement();
-
- if (LookingAt("}")) {
- AddError("Unmatched \"}\".");
- input_->NextWithComments(NULL, &upcoming_detached_comments_,
- &upcoming_doc_comments_);
- }
- }
- }
- }
-
- input_ = NULL;
- source_code_info_ = NULL;
+
+ if (require_syntax_identifier_ || LookingAt("syntax")) {
+ if (!ParseSyntaxIdentifier(root_location)) {
+ // Don't attempt to parse the file if we didn't recognize the syntax
+ // identifier.
+ return false;
+ }
+ // Store the syntax into the file.
+ if (file != NULL) file->set_syntax(syntax_identifier_);
+ } else if (!stop_after_syntax_identifier_) {
+ syntax_identifier_ = "proto2";
+ }
+
+ if (stop_after_syntax_identifier_) return !had_errors_;
+
+ // Repeatedly parse statements until we reach the end of the file.
+ while (!AtEnd()) {
+ if (!ParseTopLevelStatement(file, root_location)) {
+ // This statement failed to parse. Skip it, but keep looping to parse
+ // other statements.
+ SkipStatement();
+
+ if (LookingAt("}")) {
+ AddError("Unmatched \"}\".");
+ input_->NextWithComments(NULL, &upcoming_detached_comments_,
+ &upcoming_doc_comments_);
+ }
+ }
+ }
+ }
+
+ input_ = NULL;
+ source_code_info_ = NULL;
assert(file != NULL);
- source_code_info.Swap(file->mutable_source_code_info());
- return !had_errors_;
-}
-
-bool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) {
- LocationRecorder syntax_location(parent,
- FileDescriptorProto::kSyntaxFieldNumber);
- DO(Consume(
- "syntax",
- "File must begin with a syntax statement, e.g. 'syntax = \"proto2\";'."));
- DO(Consume("="));
- io::Tokenizer::Token syntax_token = input_->current();
+ source_code_info.Swap(file->mutable_source_code_info());
+ return !had_errors_;
+}
+
+bool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) {
+ LocationRecorder syntax_location(parent,
+ FileDescriptorProto::kSyntaxFieldNumber);
+ DO(Consume(
+ "syntax",
+ "File must begin with a syntax statement, e.g. 'syntax = \"proto2\";'."));
+ DO(Consume("="));
+ io::Tokenizer::Token syntax_token = input_->current();
TProtoStringType syntax;
- DO(ConsumeString(&syntax, "Expected syntax identifier."));
- DO(ConsumeEndOfDeclaration(";", &syntax_location));
-
- syntax_identifier_ = syntax;
-
- if (syntax != "proto2" && syntax != "proto3" &&
- !stop_after_syntax_identifier_) {
- AddError(syntax_token.line, syntax_token.column,
+ DO(ConsumeString(&syntax, "Expected syntax identifier."));
+ DO(ConsumeEndOfDeclaration(";", &syntax_location));
+
+ syntax_identifier_ = syntax;
+
+ if (syntax != "proto2" && syntax != "proto3" &&
+ !stop_after_syntax_identifier_) {
+ AddError(syntax_token.line, syntax_token.column,
"Unrecognized syntax identifier \"" + syntax +
"\". This parser "
"only recognizes \"proto2\" and \"proto3\".");
- return false;
- }
-
- return true;
-}
-
-bool Parser::ParseTopLevelStatement(FileDescriptorProto* file,
- const LocationRecorder& root_location) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
- // empty statement; ignore
- return true;
- } else if (LookingAt("message")) {
- LocationRecorder location(root_location,
+ return false;
+ }
+
+ return true;
+}
+
+bool Parser::ParseTopLevelStatement(FileDescriptorProto* file,
+ const LocationRecorder& root_location) {
+ if (TryConsumeEndOfDeclaration(";", NULL)) {
+ // empty statement; ignore
+ return true;
+ } else if (LookingAt("message")) {
+ LocationRecorder location(root_location,
FileDescriptorProto::kMessageTypeFieldNumber,
file->message_type_size());
- return ParseMessageDefinition(file->add_message_type(), location, file);
- } else if (LookingAt("enum")) {
- LocationRecorder location(root_location,
+ return ParseMessageDefinition(file->add_message_type(), location, file);
+ } else if (LookingAt("enum")) {
+ LocationRecorder location(root_location,
FileDescriptorProto::kEnumTypeFieldNumber,
file->enum_type_size());
- return ParseEnumDefinition(file->add_enum_type(), location, file);
- } else if (LookingAt("service")) {
- LocationRecorder location(root_location,
+ return ParseEnumDefinition(file->add_enum_type(), location, file);
+ } else if (LookingAt("service")) {
+ LocationRecorder location(root_location,
FileDescriptorProto::kServiceFieldNumber,
file->service_size());
- return ParseServiceDefinition(file->add_service(), location, file);
- } else if (LookingAt("extend")) {
- LocationRecorder location(root_location,
+ return ParseServiceDefinition(file->add_service(), location, file);
+ } else if (LookingAt("extend")) {
+ LocationRecorder location(root_location,
FileDescriptorProto::kExtensionFieldNumber);
return ParseExtend(
file->mutable_extension(), file->mutable_message_type(), root_location,
FileDescriptorProto::kMessageTypeFieldNumber, location, file);
- } else if (LookingAt("import")) {
- return ParseImport(file->mutable_dependency(),
- file->mutable_public_dependency(),
+ } else if (LookingAt("import")) {
+ return ParseImport(file->mutable_dependency(),
+ file->mutable_public_dependency(),
file->mutable_weak_dependency(), root_location, file);
- } else if (LookingAt("package")) {
- return ParsePackage(file, root_location, file);
- } else if (LookingAt("option")) {
- LocationRecorder location(root_location,
+ } else if (LookingAt("package")) {
+ return ParsePackage(file, root_location, file);
+ } else if (LookingAt("option")) {
+ LocationRecorder location(root_location,
FileDescriptorProto::kOptionsFieldNumber);
- return ParseOption(file->mutable_options(), location, file,
- OPTION_STATEMENT);
- } else {
- AddError("Expected top-level statement (e.g. \"message\").");
- return false;
- }
-}
-
-// -------------------------------------------------------------------
-// Messages
-
-bool Parser::ParseMessageDefinition(
+ return ParseOption(file->mutable_options(), location, file,
+ OPTION_STATEMENT);
+ } else {
+ AddError("Expected top-level statement (e.g. \"message\").");
+ return false;
+ }
+}
+
+// -------------------------------------------------------------------
+// Messages
+
+bool Parser::ParseMessageDefinition(
DescriptorProto* message, const LocationRecorder& message_location,
- const FileDescriptorProto* containing_file) {
- DO(Consume("message"));
- {
- LocationRecorder location(message_location,
- DescriptorProto::kNameFieldNumber);
+ const FileDescriptorProto* containing_file) {
+ DO(Consume("message"));
+ {
+ LocationRecorder location(message_location,
+ DescriptorProto::kNameFieldNumber);
location.RecordLegacyLocation(message,
DescriptorPool::ErrorCollector::NAME);
- DO(ConsumeIdentifier(message->mutable_name(), "Expected message name."));
+ DO(ConsumeIdentifier(message->mutable_name(), "Expected message name."));
if (!IsUpperCamelCase(message->name())) {
AddWarning(
"Message name should be in UpperCamelCase. Found: " +
message->name() +
". See https://developers.google.com/protocol-buffers/docs/style");
}
- }
- DO(ParseMessageBlock(message, message_location, containing_file));
+ }
+ DO(ParseMessageBlock(message, message_location, containing_file));
if (syntax_identifier_ == "proto3") {
// Add synthetic one-field oneofs for optional fields, except messages which
@@ -805,41 +805,41 @@ bool Parser::ParseMessageDefinition(
}
}
- return true;
-}
-
-namespace {
-
+ return true;
+}
+
+namespace {
+
const int kMaxRangeSentinel = -1;
-
-bool IsMessageSetWireFormatMessage(const DescriptorProto& message) {
- const MessageOptions& options = message.options();
- for (int i = 0; i < options.uninterpreted_option_size(); ++i) {
- const UninterpretedOption& uninterpreted = options.uninterpreted_option(i);
- if (uninterpreted.name_size() == 1 &&
- uninterpreted.name(0).name_part() == "message_set_wire_format" &&
- uninterpreted.identifier_value() == "true") {
- return true;
- }
- }
- return false;
-}
-
-// Modifies any extension ranges that specified 'max' as the end of the
-// extension range, and sets them to the type-specific maximum. The actual max
-// tag number can only be determined after all options have been parsed.
-void AdjustExtensionRangesWithMaxEndNumber(DescriptorProto* message) {
- const bool is_message_set = IsMessageSetWireFormatMessage(*message);
+
+bool IsMessageSetWireFormatMessage(const DescriptorProto& message) {
+ const MessageOptions& options = message.options();
+ for (int i = 0; i < options.uninterpreted_option_size(); ++i) {
+ const UninterpretedOption& uninterpreted = options.uninterpreted_option(i);
+ if (uninterpreted.name_size() == 1 &&
+ uninterpreted.name(0).name_part() == "message_set_wire_format" &&
+ uninterpreted.identifier_value() == "true") {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Modifies any extension ranges that specified 'max' as the end of the
+// extension range, and sets them to the type-specific maximum. The actual max
+// tag number can only be determined after all options have been parsed.
+void AdjustExtensionRangesWithMaxEndNumber(DescriptorProto* message) {
+ const bool is_message_set = IsMessageSetWireFormatMessage(*message);
const int max_extension_number = is_message_set
? std::numeric_limits<int32_t>::max()
: FieldDescriptor::kMaxNumber + 1;
- for (int i = 0; i < message->extension_range_size(); ++i) {
+ for (int i = 0; i < message->extension_range_size(); ++i) {
if (message->extension_range(i).end() == kMaxRangeSentinel) {
- message->mutable_extension_range(i)->set_end(max_extension_number);
- }
- }
-}
-
+ message->mutable_extension_range(i)->set_end(max_extension_number);
+ }
+ }
+}
+
// Modifies any reserved ranges that specified 'max' as the end of the
// reserved range, and sets them to the type-specific maximum. The actual max
// tag number can only be determined after all options have been parsed.
@@ -855,195 +855,195 @@ void AdjustReservedRangesWithMaxEndNumber(DescriptorProto* message) {
}
}
-} // namespace
-
-bool Parser::ParseMessageBlock(DescriptorProto* message,
- const LocationRecorder& message_location,
- const FileDescriptorProto* containing_file) {
- DO(ConsumeEndOfDeclaration("{", &message_location));
-
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
- if (AtEnd()) {
- AddError("Reached end of input in message definition (missing '}').");
- return false;
- }
-
- if (!ParseMessageStatement(message, message_location, containing_file)) {
- // This statement failed to parse. Skip it, but keep looping to parse
- // other statements.
- SkipStatement();
- }
- }
-
- if (message->extension_range_size() > 0) {
- AdjustExtensionRangesWithMaxEndNumber(message);
- }
+} // namespace
+
+bool Parser::ParseMessageBlock(DescriptorProto* message,
+ const LocationRecorder& message_location,
+ const FileDescriptorProto* containing_file) {
+ DO(ConsumeEndOfDeclaration("{", &message_location));
+
+ while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ if (AtEnd()) {
+ AddError("Reached end of input in message definition (missing '}').");
+ return false;
+ }
+
+ if (!ParseMessageStatement(message, message_location, containing_file)) {
+ // This statement failed to parse. Skip it, but keep looping to parse
+ // other statements.
+ SkipStatement();
+ }
+ }
+
+ if (message->extension_range_size() > 0) {
+ AdjustExtensionRangesWithMaxEndNumber(message);
+ }
if (message->reserved_range_size() > 0) {
AdjustReservedRangesWithMaxEndNumber(message);
}
- return true;
-}
-
-bool Parser::ParseMessageStatement(DescriptorProto* message,
- const LocationRecorder& message_location,
- const FileDescriptorProto* containing_file) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
- // empty statement; ignore
- return true;
- } else if (LookingAt("message")) {
- LocationRecorder location(message_location,
- DescriptorProto::kNestedTypeFieldNumber,
- message->nested_type_size());
- return ParseMessageDefinition(message->add_nested_type(), location,
- containing_file);
- } else if (LookingAt("enum")) {
- LocationRecorder location(message_location,
- DescriptorProto::kEnumTypeFieldNumber,
- message->enum_type_size());
- return ParseEnumDefinition(message->add_enum_type(), location,
- containing_file);
- } else if (LookingAt("extensions")) {
- LocationRecorder location(message_location,
- DescriptorProto::kExtensionRangeFieldNumber);
- return ParseExtensions(message, location, containing_file);
- } else if (LookingAt("reserved")) {
- return ParseReserved(message, message_location);
- } else if (LookingAt("extend")) {
- LocationRecorder location(message_location,
- DescriptorProto::kExtensionFieldNumber);
- return ParseExtend(message->mutable_extension(),
+ return true;
+}
+
+bool Parser::ParseMessageStatement(DescriptorProto* message,
+ const LocationRecorder& message_location,
+ const FileDescriptorProto* containing_file) {
+ if (TryConsumeEndOfDeclaration(";", NULL)) {
+ // empty statement; ignore
+ return true;
+ } else if (LookingAt("message")) {
+ LocationRecorder location(message_location,
+ DescriptorProto::kNestedTypeFieldNumber,
+ message->nested_type_size());
+ return ParseMessageDefinition(message->add_nested_type(), location,
+ containing_file);
+ } else if (LookingAt("enum")) {
+ LocationRecorder location(message_location,
+ DescriptorProto::kEnumTypeFieldNumber,
+ message->enum_type_size());
+ return ParseEnumDefinition(message->add_enum_type(), location,
+ containing_file);
+ } else if (LookingAt("extensions")) {
+ LocationRecorder location(message_location,
+ DescriptorProto::kExtensionRangeFieldNumber);
+ return ParseExtensions(message, location, containing_file);
+ } else if (LookingAt("reserved")) {
+ return ParseReserved(message, message_location);
+ } else if (LookingAt("extend")) {
+ LocationRecorder location(message_location,
+ DescriptorProto::kExtensionFieldNumber);
+ return ParseExtend(message->mutable_extension(),
message->mutable_nested_type(), message_location,
DescriptorProto::kNestedTypeFieldNumber, location,
containing_file);
- } else if (LookingAt("option")) {
- LocationRecorder location(message_location,
- DescriptorProto::kOptionsFieldNumber);
+ } else if (LookingAt("option")) {
+ LocationRecorder location(message_location,
+ DescriptorProto::kOptionsFieldNumber);
return ParseOption(message->mutable_options(), location, containing_file,
OPTION_STATEMENT);
- } else if (LookingAt("oneof")) {
- int oneof_index = message->oneof_decl_size();
+ } else if (LookingAt("oneof")) {
+ int oneof_index = message->oneof_decl_size();
LocationRecorder oneof_location(
message_location, DescriptorProto::kOneofDeclFieldNumber, oneof_index);
-
+
return ParseOneof(message->add_oneof_decl(), message, oneof_index,
oneof_location, message_location, containing_file);
- } else {
- LocationRecorder location(message_location,
- DescriptorProto::kFieldFieldNumber,
- message->field_size());
+ } else {
+ LocationRecorder location(message_location,
+ DescriptorProto::kFieldFieldNumber,
+ message->field_size());
return ParseMessageField(
message->add_field(), message->mutable_nested_type(), message_location,
DescriptorProto::kNestedTypeFieldNumber, location, containing_file);
- }
-}
-
-bool Parser::ParseMessageField(FieldDescriptorProto* field,
- RepeatedPtrField<DescriptorProto>* messages,
- const LocationRecorder& parent_location,
- int location_field_number_for_nested_type,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file) {
- {
- FieldDescriptorProto::Label label;
+ }
+}
+
+bool Parser::ParseMessageField(FieldDescriptorProto* field,
+ RepeatedPtrField<DescriptorProto>* messages,
+ const LocationRecorder& parent_location,
+ int location_field_number_for_nested_type,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file) {
+ {
+ FieldDescriptorProto::Label label;
if (ParseLabel(&label, field_location, containing_file)) {
- field->set_label(label);
- if (label == FieldDescriptorProto::LABEL_OPTIONAL &&
- syntax_identifier_ == "proto3") {
+ field->set_label(label);
+ if (label == FieldDescriptorProto::LABEL_OPTIONAL &&
+ syntax_identifier_ == "proto3") {
field->set_proto3_optional(true);
- }
- }
- }
-
- return ParseMessageFieldNoLabel(field, messages, parent_location,
- location_field_number_for_nested_type,
+ }
+ }
+ }
+
+ return ParseMessageFieldNoLabel(field, messages, parent_location,
+ location_field_number_for_nested_type,
field_location, containing_file);
-}
-
-bool Parser::ParseMessageFieldNoLabel(
+}
+
+bool Parser::ParseMessageFieldNoLabel(
FieldDescriptorProto* field, RepeatedPtrField<DescriptorProto>* messages,
- const LocationRecorder& parent_location,
- int location_field_number_for_nested_type,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file) {
- MapField map_field;
- // Parse type.
- {
- LocationRecorder location(field_location); // add path later
- location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::TYPE);
-
- bool type_parsed = false;
- FieldDescriptorProto::Type type = FieldDescriptorProto::TYPE_INT32;
+ const LocationRecorder& parent_location,
+ int location_field_number_for_nested_type,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file) {
+ MapField map_field;
+ // Parse type.
+ {
+ LocationRecorder location(field_location); // add path later
+ location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::TYPE);
+
+ bool type_parsed = false;
+ FieldDescriptorProto::Type type = FieldDescriptorProto::TYPE_INT32;
TProtoStringType type_name;
-
- // Special case map field. We only treat the field as a map field if the
- // field type name starts with the word "map" with a following "<".
- if (TryConsume("map")) {
- if (LookingAt("<")) {
- map_field.is_map_field = true;
- } else {
- // False positive
- type_parsed = true;
- type_name = "map";
- }
- }
- if (map_field.is_map_field) {
- if (field->has_oneof_index()) {
- AddError("Map fields are not allowed in oneofs.");
- return false;
- }
- if (field->has_label()) {
- AddError(
- "Field labels (required/optional/repeated) are not allowed on "
- "map fields.");
- return false;
- }
- if (field->has_extendee()) {
- AddError("Map fields are not allowed to be extensions.");
- return false;
- }
- field->set_label(FieldDescriptorProto::LABEL_REPEATED);
- DO(Consume("<"));
- DO(ParseType(&map_field.key_type, &map_field.key_type_name));
- DO(Consume(","));
- DO(ParseType(&map_field.value_type, &map_field.value_type_name));
- DO(Consume(">"));
- // Defer setting of the type name of the map field until the
- // field name is parsed. Add the source location though.
- location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);
- } else {
- // Handle the case where no explicit label is given for a non-map field.
- if (!field->has_label() && DefaultToOptionalFields()) {
- field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
- }
- if (!field->has_label()) {
- AddError("Expected \"required\", \"optional\", or \"repeated\".");
- // We can actually reasonably recover here by just assuming the user
- // forgot the label altogether.
- field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
- }
-
- // Handle the case where the actual type is a message or enum named "map",
- // which we already consumed in the code above.
- if (!type_parsed) {
- DO(ParseType(&type, &type_name));
- }
- if (type_name.empty()) {
- location.AddPath(FieldDescriptorProto::kTypeFieldNumber);
- field->set_type(type);
- } else {
- location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);
- field->set_type_name(type_name);
- }
- }
- }
-
- // Parse name and '='.
- io::Tokenizer::Token name_token = input_->current();
- {
- LocationRecorder location(field_location,
- FieldDescriptorProto::kNameFieldNumber);
- location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::NAME);
- DO(ConsumeIdentifier(field->mutable_name(), "Expected field name."));
+
+ // Special case map field. We only treat the field as a map field if the
+ // field type name starts with the word "map" with a following "<".
+ if (TryConsume("map")) {
+ if (LookingAt("<")) {
+ map_field.is_map_field = true;
+ } else {
+ // False positive
+ type_parsed = true;
+ type_name = "map";
+ }
+ }
+ if (map_field.is_map_field) {
+ if (field->has_oneof_index()) {
+ AddError("Map fields are not allowed in oneofs.");
+ return false;
+ }
+ if (field->has_label()) {
+ AddError(
+ "Field labels (required/optional/repeated) are not allowed on "
+ "map fields.");
+ return false;
+ }
+ if (field->has_extendee()) {
+ AddError("Map fields are not allowed to be extensions.");
+ return false;
+ }
+ field->set_label(FieldDescriptorProto::LABEL_REPEATED);
+ DO(Consume("<"));
+ DO(ParseType(&map_field.key_type, &map_field.key_type_name));
+ DO(Consume(","));
+ DO(ParseType(&map_field.value_type, &map_field.value_type_name));
+ DO(Consume(">"));
+ // Defer setting of the type name of the map field until the
+ // field name is parsed. Add the source location though.
+ location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);
+ } else {
+ // Handle the case where no explicit label is given for a non-map field.
+ if (!field->has_label() && DefaultToOptionalFields()) {
+ field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
+ }
+ if (!field->has_label()) {
+ AddError("Expected \"required\", \"optional\", or \"repeated\".");
+ // We can actually reasonably recover here by just assuming the user
+ // forgot the label altogether.
+ field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
+ }
+
+ // Handle the case where the actual type is a message or enum named "map",
+ // which we already consumed in the code above.
+ if (!type_parsed) {
+ DO(ParseType(&type, &type_name));
+ }
+ if (type_name.empty()) {
+ location.AddPath(FieldDescriptorProto::kTypeFieldNumber);
+ field->set_type(type);
+ } else {
+ location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);
+ field->set_type_name(type_name);
+ }
+ }
+ }
+
+ // Parse name and '='.
+ io::Tokenizer::Token name_token = input_->current();
+ {
+ LocationRecorder location(field_location,
+ FieldDescriptorProto::kNameFieldNumber);
+ location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::NAME);
+ DO(ConsumeIdentifier(field->mutable_name(), "Expected field name."));
if (!IsLowerUnderscore(field->name())) {
AddWarning(
@@ -1056,596 +1056,596 @@ bool Parser::ParseMessageFieldNoLabel(
field->name() +
". See: https://developers.google.com/protocol-buffers/docs/style");
}
- }
- DO(Consume("=", "Missing field number."));
-
- // Parse field number.
- {
- LocationRecorder location(field_location,
- FieldDescriptorProto::kNumberFieldNumber);
+ }
+ DO(Consume("=", "Missing field number."));
+
+ // Parse field number.
+ {
+ LocationRecorder location(field_location,
+ FieldDescriptorProto::kNumberFieldNumber);
location.RecordLegacyLocation(field,
DescriptorPool::ErrorCollector::NUMBER);
- int number;
- DO(ConsumeInteger(&number, "Expected field number."));
- field->set_number(number);
- }
-
- // Parse options.
- DO(ParseFieldOptions(field, field_location, containing_file));
-
- // Deal with groups.
- if (field->has_type() && field->type() == FieldDescriptorProto::TYPE_GROUP) {
- // Awkward: Since a group declares both a message type and a field, we
- // have to create overlapping locations.
- LocationRecorder group_location(parent_location);
- group_location.StartAt(field_location);
- group_location.AddPath(location_field_number_for_nested_type);
- group_location.AddPath(messages->size());
-
- DescriptorProto* group = messages->Add();
- group->set_name(field->name());
-
- // Record name location to match the field name's location.
- {
- LocationRecorder location(group_location,
- DescriptorProto::kNameFieldNumber);
- location.StartAt(name_token);
- location.EndAt(name_token);
+ int number;
+ DO(ConsumeInteger(&number, "Expected field number."));
+ field->set_number(number);
+ }
+
+ // Parse options.
+ DO(ParseFieldOptions(field, field_location, containing_file));
+
+ // Deal with groups.
+ if (field->has_type() && field->type() == FieldDescriptorProto::TYPE_GROUP) {
+ // Awkward: Since a group declares both a message type and a field, we
+ // have to create overlapping locations.
+ LocationRecorder group_location(parent_location);
+ group_location.StartAt(field_location);
+ group_location.AddPath(location_field_number_for_nested_type);
+ group_location.AddPath(messages->size());
+
+ DescriptorProto* group = messages->Add();
+ group->set_name(field->name());
+
+ // Record name location to match the field name's location.
+ {
+ LocationRecorder location(group_location,
+ DescriptorProto::kNameFieldNumber);
+ location.StartAt(name_token);
+ location.EndAt(name_token);
location.RecordLegacyLocation(group,
DescriptorPool::ErrorCollector::NAME);
- }
-
- // The field's type_name also comes from the name. Confusing!
- {
- LocationRecorder location(field_location,
- FieldDescriptorProto::kTypeNameFieldNumber);
- location.StartAt(name_token);
- location.EndAt(name_token);
- }
-
- // As a hack for backwards-compatibility, we force the group name to start
- // with a capital letter and lower-case the field name. New code should
- // not use groups; it should use nested messages.
- if (group->name()[0] < 'A' || 'Z' < group->name()[0]) {
- AddError(name_token.line, name_token.column,
+ }
+
+ // The field's type_name also comes from the name. Confusing!
+ {
+ LocationRecorder location(field_location,
+ FieldDescriptorProto::kTypeNameFieldNumber);
+ location.StartAt(name_token);
+ location.EndAt(name_token);
+ }
+
+ // As a hack for backwards-compatibility, we force the group name to start
+ // with a capital letter and lower-case the field name. New code should
+ // not use groups; it should use nested messages.
+ if (group->name()[0] < 'A' || 'Z' < group->name()[0]) {
+ AddError(name_token.line, name_token.column,
"Group names must start with a capital letter.");
- }
- LowerString(field->mutable_name());
-
- field->set_type_name(group->name());
- if (LookingAt("{")) {
- DO(ParseMessageBlock(group, group_location, containing_file));
- } else {
- AddError("Missing group body.");
- return false;
- }
- } else {
- DO(ConsumeEndOfDeclaration(";", &field_location));
- }
-
- // Create a map entry type if this is a map field.
- if (map_field.is_map_field) {
- GenerateMapEntry(map_field, field, messages);
- }
-
- return true;
-}
-
-void Parser::GenerateMapEntry(const MapField& map_field,
- FieldDescriptorProto* field,
- RepeatedPtrField<DescriptorProto>* messages) {
- DescriptorProto* entry = messages->Add();
+ }
+ LowerString(field->mutable_name());
+
+ field->set_type_name(group->name());
+ if (LookingAt("{")) {
+ DO(ParseMessageBlock(group, group_location, containing_file));
+ } else {
+ AddError("Missing group body.");
+ return false;
+ }
+ } else {
+ DO(ConsumeEndOfDeclaration(";", &field_location));
+ }
+
+ // Create a map entry type if this is a map field.
+ if (map_field.is_map_field) {
+ GenerateMapEntry(map_field, field, messages);
+ }
+
+ return true;
+}
+
+void Parser::GenerateMapEntry(const MapField& map_field,
+ FieldDescriptorProto* field,
+ RepeatedPtrField<DescriptorProto>* messages) {
+ DescriptorProto* entry = messages->Add();
TProtoStringType entry_name = MapEntryName(field->name());
- field->set_type_name(entry_name);
- entry->set_name(entry_name);
- entry->mutable_options()->set_map_entry(true);
- FieldDescriptorProto* key_field = entry->add_field();
- key_field->set_name("key");
- key_field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
- key_field->set_number(1);
- if (map_field.key_type_name.empty()) {
- key_field->set_type(map_field.key_type);
- } else {
- key_field->set_type_name(map_field.key_type_name);
- }
- FieldDescriptorProto* value_field = entry->add_field();
- value_field->set_name("value");
- value_field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
- value_field->set_number(2);
- if (map_field.value_type_name.empty()) {
- value_field->set_type(map_field.value_type);
- } else {
- value_field->set_type_name(map_field.value_type_name);
- }
- // Propagate the "enforce_utf8" option to key and value fields if they
- // are strings. This helps simplify the implementation of code generators
- // and also reflection-based parsing code.
- //
- // The following definition:
- // message Foo {
+ field->set_type_name(entry_name);
+ entry->set_name(entry_name);
+ entry->mutable_options()->set_map_entry(true);
+ FieldDescriptorProto* key_field = entry->add_field();
+ key_field->set_name("key");
+ key_field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
+ key_field->set_number(1);
+ if (map_field.key_type_name.empty()) {
+ key_field->set_type(map_field.key_type);
+ } else {
+ key_field->set_type_name(map_field.key_type_name);
+ }
+ FieldDescriptorProto* value_field = entry->add_field();
+ value_field->set_name("value");
+ value_field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
+ value_field->set_number(2);
+ if (map_field.value_type_name.empty()) {
+ value_field->set_type(map_field.value_type);
+ } else {
+ value_field->set_type_name(map_field.value_type_name);
+ }
+ // Propagate the "enforce_utf8" option to key and value fields if they
+ // are strings. This helps simplify the implementation of code generators
+ // and also reflection-based parsing code.
+ //
+ // The following definition:
+ // message Foo {
// map<string, string> value = 1 [enforce_utf8 = false];
- // }
- // will be interpreted as:
- // message Foo {
- // message ValueEntry {
- // option map_entry = true;
- // string key = 1 [enforce_utf8 = false];
- // string value = 2 [enforce_utf8 = false];
- // }
- // repeated ValueEntry value = 1 [enforce_utf8 = false];
- // }
- //
- // TODO(xiaofeng): Remove this when the "enforce_utf8" option is removed
- // from protocol compiler.
- for (int i = 0; i < field->options().uninterpreted_option_size(); ++i) {
- const UninterpretedOption& option =
- field->options().uninterpreted_option(i);
- if (option.name_size() == 1 &&
- option.name(0).name_part() == "enforce_utf8" &&
- !option.name(0).is_extension()) {
- if (key_field->type() == FieldDescriptorProto::TYPE_STRING) {
+ // }
+ // will be interpreted as:
+ // message Foo {
+ // message ValueEntry {
+ // option map_entry = true;
+ // string key = 1 [enforce_utf8 = false];
+ // string value = 2 [enforce_utf8 = false];
+ // }
+ // repeated ValueEntry value = 1 [enforce_utf8 = false];
+ // }
+ //
+ // TODO(xiaofeng): Remove this when the "enforce_utf8" option is removed
+ // from protocol compiler.
+ for (int i = 0; i < field->options().uninterpreted_option_size(); ++i) {
+ const UninterpretedOption& option =
+ field->options().uninterpreted_option(i);
+ if (option.name_size() == 1 &&
+ option.name(0).name_part() == "enforce_utf8" &&
+ !option.name(0).is_extension()) {
+ if (key_field->type() == FieldDescriptorProto::TYPE_STRING) {
key_field->mutable_options()->add_uninterpreted_option()->CopyFrom(
option);
- }
- if (value_field->type() == FieldDescriptorProto::TYPE_STRING) {
+ }
+ if (value_field->type() == FieldDescriptorProto::TYPE_STRING) {
value_field->mutable_options()->add_uninterpreted_option()->CopyFrom(
option);
- }
- }
- }
-}
-
-bool Parser::ParseFieldOptions(FieldDescriptorProto* field,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file) {
- if (!LookingAt("[")) return true;
-
- LocationRecorder location(field_location,
- FieldDescriptorProto::kOptionsFieldNumber);
-
- DO(Consume("["));
-
- // Parse field options.
- do {
- if (LookingAt("default")) {
- // We intentionally pass field_location rather than location here, since
- // the default value is not actually an option.
- DO(ParseDefaultAssignment(field, field_location, containing_file));
- } else if (LookingAt("json_name")) {
- // Like default value, this "json_name" is not an actual option.
- DO(ParseJsonName(field, field_location, containing_file));
- } else {
+ }
+ }
+ }
+}
+
+bool Parser::ParseFieldOptions(FieldDescriptorProto* field,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file) {
+ if (!LookingAt("[")) return true;
+
+ LocationRecorder location(field_location,
+ FieldDescriptorProto::kOptionsFieldNumber);
+
+ DO(Consume("["));
+
+ // Parse field options.
+ do {
+ if (LookingAt("default")) {
+ // We intentionally pass field_location rather than location here, since
+ // the default value is not actually an option.
+ DO(ParseDefaultAssignment(field, field_location, containing_file));
+ } else if (LookingAt("json_name")) {
+ // Like default value, this "json_name" is not an actual option.
+ DO(ParseJsonName(field, field_location, containing_file));
+ } else {
DO(ParseOption(field->mutable_options(), location, containing_file,
OPTION_ASSIGNMENT));
- }
- } while (TryConsume(","));
-
- DO(Consume("]"));
- return true;
-}
-
-bool Parser::ParseDefaultAssignment(
+ }
+ } while (TryConsume(","));
+
+ DO(Consume("]"));
+ return true;
+}
+
+bool Parser::ParseDefaultAssignment(
FieldDescriptorProto* field, const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file) {
- if (field->has_default_value()) {
- AddError("Already set option \"default\".");
- field->clear_default_value();
- }
-
- DO(Consume("default"));
- DO(Consume("="));
-
- LocationRecorder location(field_location,
- FieldDescriptorProto::kDefaultValueFieldNumber);
+ const FileDescriptorProto* containing_file) {
+ if (field->has_default_value()) {
+ AddError("Already set option \"default\".");
+ field->clear_default_value();
+ }
+
+ DO(Consume("default"));
+ DO(Consume("="));
+
+ LocationRecorder location(field_location,
+ FieldDescriptorProto::kDefaultValueFieldNumber);
location.RecordLegacyLocation(field,
DescriptorPool::ErrorCollector::DEFAULT_VALUE);
TProtoStringType* default_value = field->mutable_default_value();
-
- if (!field->has_type()) {
- // The field has a type name, but we don't know if it is a message or an
- // enum yet. (If it were a primitive type, |field| would have a type set
- // already.) In this case, simply take the current string as the default
- // value; we will catch the error later if it is not a valid enum value.
- // (N.B. that we do not check whether the current token is an identifier:
- // doing so throws strange errors when the user mistypes a primitive
- // typename and we assume it's an enum. E.g.: "optional int foo = 1 [default
- // = 42]". In such a case the fundamental error is really that "int" is not
- // a type, not that "42" is not an identifier. See b/12533582.)
- *default_value = input_->current().text;
- input_->Next();
- return true;
- }
-
- switch (field->type()) {
- case FieldDescriptorProto::TYPE_INT32:
- case FieldDescriptorProto::TYPE_INT64:
- case FieldDescriptorProto::TYPE_SINT32:
- case FieldDescriptorProto::TYPE_SINT64:
- case FieldDescriptorProto::TYPE_SFIXED32:
- case FieldDescriptorProto::TYPE_SFIXED64: {
+
+ if (!field->has_type()) {
+ // The field has a type name, but we don't know if it is a message or an
+ // enum yet. (If it were a primitive type, |field| would have a type set
+ // already.) In this case, simply take the current string as the default
+ // value; we will catch the error later if it is not a valid enum value.
+ // (N.B. that we do not check whether the current token is an identifier:
+ // doing so throws strange errors when the user mistypes a primitive
+ // typename and we assume it's an enum. E.g.: "optional int foo = 1 [default
+ // = 42]". In such a case the fundamental error is really that "int" is not
+ // a type, not that "42" is not an identifier. See b/12533582.)
+ *default_value = input_->current().text;
+ input_->Next();
+ return true;
+ }
+
+ switch (field->type()) {
+ case FieldDescriptorProto::TYPE_INT32:
+ case FieldDescriptorProto::TYPE_INT64:
+ case FieldDescriptorProto::TYPE_SINT32:
+ case FieldDescriptorProto::TYPE_SINT64:
+ case FieldDescriptorProto::TYPE_SFIXED32:
+ case FieldDescriptorProto::TYPE_SFIXED64: {
uint64_t max_value = std::numeric_limits<int64_t>::max();
- if (field->type() == FieldDescriptorProto::TYPE_INT32 ||
- field->type() == FieldDescriptorProto::TYPE_SINT32 ||
- field->type() == FieldDescriptorProto::TYPE_SFIXED32) {
+ if (field->type() == FieldDescriptorProto::TYPE_INT32 ||
+ field->type() == FieldDescriptorProto::TYPE_SINT32 ||
+ field->type() == FieldDescriptorProto::TYPE_SFIXED32) {
max_value = std::numeric_limits<int32_t>::max();
- }
-
- // These types can be negative.
- if (TryConsume("-")) {
- default_value->append("-");
- // Two's complement always has one more negative value than positive.
- ++max_value;
- }
- // Parse the integer to verify that it is not out-of-range.
+ }
+
+ // These types can be negative.
+ if (TryConsume("-")) {
+ default_value->append("-");
+ // Two's complement always has one more negative value than positive.
+ ++max_value;
+ }
+ // Parse the integer to verify that it is not out-of-range.
uint64_t value;
- DO(ConsumeInteger64(max_value, &value,
- "Expected integer for field default value."));
- // And stringify it again.
+ DO(ConsumeInteger64(max_value, &value,
+ "Expected integer for field default value."));
+ // And stringify it again.
default_value->append(StrCat(value));
- break;
- }
-
- case FieldDescriptorProto::TYPE_UINT32:
- case FieldDescriptorProto::TYPE_UINT64:
- case FieldDescriptorProto::TYPE_FIXED32:
- case FieldDescriptorProto::TYPE_FIXED64: {
+ break;
+ }
+
+ case FieldDescriptorProto::TYPE_UINT32:
+ case FieldDescriptorProto::TYPE_UINT64:
+ case FieldDescriptorProto::TYPE_FIXED32:
+ case FieldDescriptorProto::TYPE_FIXED64: {
uint64_t max_value = std::numeric_limits<uint64_t>::max();
- if (field->type() == FieldDescriptorProto::TYPE_UINT32 ||
- field->type() == FieldDescriptorProto::TYPE_FIXED32) {
+ if (field->type() == FieldDescriptorProto::TYPE_UINT32 ||
+ field->type() == FieldDescriptorProto::TYPE_FIXED32) {
max_value = std::numeric_limits<uint32_t>::max();
- }
-
- // Numeric, not negative.
- if (TryConsume("-")) {
- AddError("Unsigned field can't have negative default value.");
- }
- // Parse the integer to verify that it is not out-of-range.
+ }
+
+ // Numeric, not negative.
+ if (TryConsume("-")) {
+ AddError("Unsigned field can't have negative default value.");
+ }
+ // Parse the integer to verify that it is not out-of-range.
uint64_t value;
- DO(ConsumeInteger64(max_value, &value,
- "Expected integer for field default value."));
- // And stringify it again.
+ DO(ConsumeInteger64(max_value, &value,
+ "Expected integer for field default value."));
+ // And stringify it again.
default_value->append(StrCat(value));
- break;
- }
-
- case FieldDescriptorProto::TYPE_FLOAT:
- case FieldDescriptorProto::TYPE_DOUBLE:
- // These types can be negative.
- if (TryConsume("-")) {
- default_value->append("-");
- }
- // Parse the integer because we have to convert hex integers to decimal
- // floats.
- double value;
- DO(ConsumeNumber(&value, "Expected number."));
- // And stringify it again.
- default_value->append(SimpleDtoa(value));
- break;
-
- case FieldDescriptorProto::TYPE_BOOL:
- if (TryConsume("true")) {
- default_value->assign("true");
- } else if (TryConsume("false")) {
- default_value->assign("false");
- } else {
- AddError("Expected \"true\" or \"false\".");
- return false;
- }
- break;
-
- case FieldDescriptorProto::TYPE_STRING:
+ break;
+ }
+
+ case FieldDescriptorProto::TYPE_FLOAT:
+ case FieldDescriptorProto::TYPE_DOUBLE:
+ // These types can be negative.
+ if (TryConsume("-")) {
+ default_value->append("-");
+ }
+ // Parse the integer because we have to convert hex integers to decimal
+ // floats.
+ double value;
+ DO(ConsumeNumber(&value, "Expected number."));
+ // And stringify it again.
+ default_value->append(SimpleDtoa(value));
+ break;
+
+ case FieldDescriptorProto::TYPE_BOOL:
+ if (TryConsume("true")) {
+ default_value->assign("true");
+ } else if (TryConsume("false")) {
+ default_value->assign("false");
+ } else {
+ AddError("Expected \"true\" or \"false\".");
+ return false;
+ }
+ break;
+
+ case FieldDescriptorProto::TYPE_STRING:
// Note: When file option java_string_check_utf8 is true, if a
- // non-string representation (eg byte[]) is later supported, it must
- // be checked for UTF-8-ness.
+ // non-string representation (eg byte[]) is later supported, it must
+ // be checked for UTF-8-ness.
DO(ConsumeString(default_value,
"Expected string for field default "
- "value."));
- break;
-
- case FieldDescriptorProto::TYPE_BYTES:
- DO(ConsumeString(default_value, "Expected string."));
- *default_value = CEscape(*default_value);
- break;
-
- case FieldDescriptorProto::TYPE_ENUM:
+ "value."));
+ break;
+
+ case FieldDescriptorProto::TYPE_BYTES:
+ DO(ConsumeString(default_value, "Expected string."));
+ *default_value = CEscape(*default_value);
+ break;
+
+ case FieldDescriptorProto::TYPE_ENUM:
DO(ConsumeIdentifier(default_value,
"Expected enum identifier for field "
"default value."));
- break;
-
- case FieldDescriptorProto::TYPE_MESSAGE:
- case FieldDescriptorProto::TYPE_GROUP:
- AddError("Messages can't have default values.");
- return false;
- }
-
- return true;
-}
-
+ break;
+
+ case FieldDescriptorProto::TYPE_MESSAGE:
+ case FieldDescriptorProto::TYPE_GROUP:
+ AddError("Messages can't have default values.");
+ return false;
+ }
+
+ return true;
+}
+
bool Parser::ParseJsonName(FieldDescriptorProto* field,
const LocationRecorder& field_location,
const FileDescriptorProto* containing_file) {
- if (field->has_json_name()) {
- AddError("Already set option \"json_name\".");
- field->clear_json_name();
- }
-
+ if (field->has_json_name()) {
+ AddError("Already set option \"json_name\".");
+ field->clear_json_name();
+ }
+
LocationRecorder location(field_location,
FieldDescriptorProto::kJsonNameFieldNumber);
location.RecordLegacyLocation(field,
DescriptorPool::ErrorCollector::OPTION_NAME);
- DO(Consume("json_name"));
- DO(Consume("="));
-
+ DO(Consume("json_name"));
+ DO(Consume("="));
+
LocationRecorder value_location(location);
value_location.RecordLegacyLocation(
- field, DescriptorPool::ErrorCollector::OPTION_VALUE);
-
- DO(ConsumeString(field->mutable_json_name(),
- "Expected string for JSON name."));
- return true;
-}
-
-bool Parser::ParseOptionNamePart(UninterpretedOption* uninterpreted_option,
- const LocationRecorder& part_location,
- const FileDescriptorProto* containing_file) {
- UninterpretedOption::NamePart* name = uninterpreted_option->add_name();
+ field, DescriptorPool::ErrorCollector::OPTION_VALUE);
+
+ DO(ConsumeString(field->mutable_json_name(),
+ "Expected string for JSON name."));
+ return true;
+}
+
+bool Parser::ParseOptionNamePart(UninterpretedOption* uninterpreted_option,
+ const LocationRecorder& part_location,
+ const FileDescriptorProto* containing_file) {
+ UninterpretedOption::NamePart* name = uninterpreted_option->add_name();
TProtoStringType identifier; // We parse identifiers into this string.
if (LookingAt("(")) { // This is an extension.
- DO(Consume("("));
-
- {
- LocationRecorder location(
- part_location, UninterpretedOption::NamePart::kNamePartFieldNumber);
- // An extension name consists of dot-separated identifiers, and may begin
- // with a dot.
- if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
- DO(ConsumeIdentifier(&identifier, "Expected identifier."));
- name->mutable_name_part()->append(identifier);
- }
- while (LookingAt(".")) {
- DO(Consume("."));
- name->mutable_name_part()->append(".");
- DO(ConsumeIdentifier(&identifier, "Expected identifier."));
- name->mutable_name_part()->append(identifier);
- }
- }
-
- DO(Consume(")"));
- name->set_is_extension(true);
- } else { // This is a regular field.
- LocationRecorder location(
- part_location, UninterpretedOption::NamePart::kNamePartFieldNumber);
- DO(ConsumeIdentifier(&identifier, "Expected identifier."));
- name->mutable_name_part()->append(identifier);
- name->set_is_extension(false);
- }
- return true;
-}
-
+ DO(Consume("("));
+
+ {
+ LocationRecorder location(
+ part_location, UninterpretedOption::NamePart::kNamePartFieldNumber);
+ // An extension name consists of dot-separated identifiers, and may begin
+ // with a dot.
+ if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {
+ DO(ConsumeIdentifier(&identifier, "Expected identifier."));
+ name->mutable_name_part()->append(identifier);
+ }
+ while (LookingAt(".")) {
+ DO(Consume("."));
+ name->mutable_name_part()->append(".");
+ DO(ConsumeIdentifier(&identifier, "Expected identifier."));
+ name->mutable_name_part()->append(identifier);
+ }
+ }
+
+ DO(Consume(")"));
+ name->set_is_extension(true);
+ } else { // This is a regular field.
+ LocationRecorder location(
+ part_location, UninterpretedOption::NamePart::kNamePartFieldNumber);
+ DO(ConsumeIdentifier(&identifier, "Expected identifier."));
+ name->mutable_name_part()->append(identifier);
+ name->set_is_extension(false);
+ }
+ return true;
+}
+
bool Parser::ParseUninterpretedBlock(TProtoStringType* value) {
- // Note that enclosing braces are not added to *value.
- // We do NOT use ConsumeEndOfStatement for this brace because it's delimiting
- // an expression, not a block of statements.
- DO(Consume("{"));
- int brace_depth = 1;
- while (!AtEnd()) {
- if (LookingAt("{")) {
- brace_depth++;
- } else if (LookingAt("}")) {
- brace_depth--;
- if (brace_depth == 0) {
- input_->Next();
- return true;
- }
- }
- // TODO(sanjay): Interpret line/column numbers to preserve formatting
- if (!value->empty()) value->push_back(' ');
- value->append(input_->current().text);
- input_->Next();
- }
- AddError("Unexpected end of stream while parsing aggregate value.");
- return false;
-}
-
-// We don't interpret the option here. Instead we store it in an
-// UninterpretedOption, to be interpreted later.
-bool Parser::ParseOption(Message* options,
- const LocationRecorder& options_location,
- const FileDescriptorProto* containing_file,
- OptionStyle style) {
- // Create an entry in the uninterpreted_option field.
+ // Note that enclosing braces are not added to *value.
+ // We do NOT use ConsumeEndOfStatement for this brace because it's delimiting
+ // an expression, not a block of statements.
+ DO(Consume("{"));
+ int brace_depth = 1;
+ while (!AtEnd()) {
+ if (LookingAt("{")) {
+ brace_depth++;
+ } else if (LookingAt("}")) {
+ brace_depth--;
+ if (brace_depth == 0) {
+ input_->Next();
+ return true;
+ }
+ }
+ // TODO(sanjay): Interpret line/column numbers to preserve formatting
+ if (!value->empty()) value->push_back(' ');
+ value->append(input_->current().text);
+ input_->Next();
+ }
+ AddError("Unexpected end of stream while parsing aggregate value.");
+ return false;
+}
+
+// We don't interpret the option here. Instead we store it in an
+// UninterpretedOption, to be interpreted later.
+bool Parser::ParseOption(Message* options,
+ const LocationRecorder& options_location,
+ const FileDescriptorProto* containing_file,
+ OptionStyle style) {
+ // Create an entry in the uninterpreted_option field.
const FieldDescriptor* uninterpreted_option_field =
options->GetDescriptor()->FindFieldByName("uninterpreted_option");
- GOOGLE_CHECK(uninterpreted_option_field != NULL)
- << "No field named \"uninterpreted_option\" in the Options proto.";
-
- const Reflection* reflection = options->GetReflection();
-
- LocationRecorder location(
- options_location, uninterpreted_option_field->number(),
- reflection->FieldSize(*options, uninterpreted_option_field));
-
- if (style == OPTION_STATEMENT) {
- DO(Consume("option"));
- }
-
+ GOOGLE_CHECK(uninterpreted_option_field != NULL)
+ << "No field named \"uninterpreted_option\" in the Options proto.";
+
+ const Reflection* reflection = options->GetReflection();
+
+ LocationRecorder location(
+ options_location, uninterpreted_option_field->number(),
+ reflection->FieldSize(*options, uninterpreted_option_field));
+
+ if (style == OPTION_STATEMENT) {
+ DO(Consume("option"));
+ }
+
UninterpretedOption* uninterpreted_option =
down_cast<UninterpretedOption*>(options->GetReflection()->AddMessage(
options, uninterpreted_option_field));
-
- // Parse dot-separated name.
- {
- LocationRecorder name_location(location,
- UninterpretedOption::kNameFieldNumber);
- name_location.RecordLegacyLocation(
- uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_NAME);
-
- {
- LocationRecorder part_location(name_location,
- uninterpreted_option->name_size());
- DO(ParseOptionNamePart(uninterpreted_option, part_location,
- containing_file));
- }
-
- while (LookingAt(".")) {
- DO(Consume("."));
- LocationRecorder part_location(name_location,
- uninterpreted_option->name_size());
- DO(ParseOptionNamePart(uninterpreted_option, part_location,
- containing_file));
- }
- }
-
- DO(Consume("="));
-
- {
- LocationRecorder value_location(location);
- value_location.RecordLegacyLocation(
- uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_VALUE);
-
- // All values are a single token, except for negative numbers, which consist
- // of a single '-' symbol, followed by a positive number.
- bool is_negative = TryConsume("-");
-
- switch (input_->current().type) {
- case io::Tokenizer::TYPE_START:
- GOOGLE_LOG(FATAL) << "Trying to read value before any tokens have been read.";
- return false;
-
- case io::Tokenizer::TYPE_END:
- AddError("Unexpected end of stream while parsing option value.");
- return false;
-
- case io::Tokenizer::TYPE_IDENTIFIER: {
- value_location.AddPath(
- UninterpretedOption::kIdentifierValueFieldNumber);
- if (is_negative) {
- AddError("Invalid '-' symbol before identifier.");
- return false;
- }
+
+ // Parse dot-separated name.
+ {
+ LocationRecorder name_location(location,
+ UninterpretedOption::kNameFieldNumber);
+ name_location.RecordLegacyLocation(
+ uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_NAME);
+
+ {
+ LocationRecorder part_location(name_location,
+ uninterpreted_option->name_size());
+ DO(ParseOptionNamePart(uninterpreted_option, part_location,
+ containing_file));
+ }
+
+ while (LookingAt(".")) {
+ DO(Consume("."));
+ LocationRecorder part_location(name_location,
+ uninterpreted_option->name_size());
+ DO(ParseOptionNamePart(uninterpreted_option, part_location,
+ containing_file));
+ }
+ }
+
+ DO(Consume("="));
+
+ {
+ LocationRecorder value_location(location);
+ value_location.RecordLegacyLocation(
+ uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_VALUE);
+
+ // All values are a single token, except for negative numbers, which consist
+ // of a single '-' symbol, followed by a positive number.
+ bool is_negative = TryConsume("-");
+
+ switch (input_->current().type) {
+ case io::Tokenizer::TYPE_START:
+ GOOGLE_LOG(FATAL) << "Trying to read value before any tokens have been read.";
+ return false;
+
+ case io::Tokenizer::TYPE_END:
+ AddError("Unexpected end of stream while parsing option value.");
+ return false;
+
+ case io::Tokenizer::TYPE_IDENTIFIER: {
+ value_location.AddPath(
+ UninterpretedOption::kIdentifierValueFieldNumber);
+ if (is_negative) {
+ AddError("Invalid '-' symbol before identifier.");
+ return false;
+ }
TProtoStringType value;
- DO(ConsumeIdentifier(&value, "Expected identifier."));
- uninterpreted_option->set_identifier_value(value);
- break;
- }
-
- case io::Tokenizer::TYPE_INTEGER: {
+ DO(ConsumeIdentifier(&value, "Expected identifier."));
+ uninterpreted_option->set_identifier_value(value);
+ break;
+ }
+
+ case io::Tokenizer::TYPE_INTEGER: {
uint64_t value;
uint64_t max_value =
is_negative
? static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) + 1
: std::numeric_limits<uint64_t>::max();
- DO(ConsumeInteger64(max_value, &value, "Expected integer."));
- if (is_negative) {
- value_location.AddPath(
- UninterpretedOption::kNegativeIntValueFieldNumber);
- uninterpreted_option->set_negative_int_value(
+ DO(ConsumeInteger64(max_value, &value, "Expected integer."));
+ if (is_negative) {
+ value_location.AddPath(
+ UninterpretedOption::kNegativeIntValueFieldNumber);
+ uninterpreted_option->set_negative_int_value(
static_cast<int64_t>(-value));
- } else {
- value_location.AddPath(
- UninterpretedOption::kPositiveIntValueFieldNumber);
- uninterpreted_option->set_positive_int_value(value);
- }
- break;
- }
-
- case io::Tokenizer::TYPE_FLOAT: {
- value_location.AddPath(UninterpretedOption::kDoubleValueFieldNumber);
- double value;
- DO(ConsumeNumber(&value, "Expected number."));
- uninterpreted_option->set_double_value(is_negative ? -value : value);
- break;
- }
-
- case io::Tokenizer::TYPE_STRING: {
- value_location.AddPath(UninterpretedOption::kStringValueFieldNumber);
- if (is_negative) {
- AddError("Invalid '-' symbol before string.");
- return false;
- }
+ } else {
+ value_location.AddPath(
+ UninterpretedOption::kPositiveIntValueFieldNumber);
+ uninterpreted_option->set_positive_int_value(value);
+ }
+ break;
+ }
+
+ case io::Tokenizer::TYPE_FLOAT: {
+ value_location.AddPath(UninterpretedOption::kDoubleValueFieldNumber);
+ double value;
+ DO(ConsumeNumber(&value, "Expected number."));
+ uninterpreted_option->set_double_value(is_negative ? -value : value);
+ break;
+ }
+
+ case io::Tokenizer::TYPE_STRING: {
+ value_location.AddPath(UninterpretedOption::kStringValueFieldNumber);
+ if (is_negative) {
+ AddError("Invalid '-' symbol before string.");
+ return false;
+ }
TProtoStringType value;
- DO(ConsumeString(&value, "Expected string."));
- uninterpreted_option->set_string_value(value);
- break;
- }
-
- case io::Tokenizer::TYPE_SYMBOL:
- if (LookingAt("{")) {
- value_location.AddPath(
- UninterpretedOption::kAggregateValueFieldNumber);
- DO(ParseUninterpretedBlock(
- uninterpreted_option->mutable_aggregate_value()));
- } else {
- AddError("Expected option value.");
- return false;
- }
- break;
- }
- }
-
- if (style == OPTION_STATEMENT) {
- DO(ConsumeEndOfDeclaration(";", &location));
- }
-
- return true;
-}
-
-bool Parser::ParseExtensions(DescriptorProto* message,
- const LocationRecorder& extensions_location,
- const FileDescriptorProto* containing_file) {
- // Parse the declaration.
- DO(Consume("extensions"));
-
+ DO(ConsumeString(&value, "Expected string."));
+ uninterpreted_option->set_string_value(value);
+ break;
+ }
+
+ case io::Tokenizer::TYPE_SYMBOL:
+ if (LookingAt("{")) {
+ value_location.AddPath(
+ UninterpretedOption::kAggregateValueFieldNumber);
+ DO(ParseUninterpretedBlock(
+ uninterpreted_option->mutable_aggregate_value()));
+ } else {
+ AddError("Expected option value.");
+ return false;
+ }
+ break;
+ }
+ }
+
+ if (style == OPTION_STATEMENT) {
+ DO(ConsumeEndOfDeclaration(";", &location));
+ }
+
+ return true;
+}
+
+bool Parser::ParseExtensions(DescriptorProto* message,
+ const LocationRecorder& extensions_location,
+ const FileDescriptorProto* containing_file) {
+ // Parse the declaration.
+ DO(Consume("extensions"));
+
int old_range_size = message->extension_range_size();
- do {
- // Note that kExtensionRangeFieldNumber was already pushed by the parent.
- LocationRecorder location(extensions_location,
- message->extension_range_size());
-
- DescriptorProto::ExtensionRange* range = message->add_extension_range();
+ do {
+ // Note that kExtensionRangeFieldNumber was already pushed by the parent.
+ LocationRecorder location(extensions_location,
+ message->extension_range_size());
+
+ DescriptorProto::ExtensionRange* range = message->add_extension_range();
location.RecordLegacyLocation(range,
DescriptorPool::ErrorCollector::NUMBER);
-
- int start, end;
- io::Tokenizer::Token start_token;
-
- {
- LocationRecorder start_location(
- location, DescriptorProto::ExtensionRange::kStartFieldNumber);
- start_token = input_->current();
- DO(ConsumeInteger(&start, "Expected field number range."));
- }
-
- if (TryConsume("to")) {
- LocationRecorder end_location(
- location, DescriptorProto::ExtensionRange::kEndFieldNumber);
- if (TryConsume("max")) {
- // Set to the sentinel value - 1 since we increment the value below.
- // The actual value of the end of the range should be set with
- // AdjustExtensionRangesWithMaxEndNumber.
+
+ int start, end;
+ io::Tokenizer::Token start_token;
+
+ {
+ LocationRecorder start_location(
+ location, DescriptorProto::ExtensionRange::kStartFieldNumber);
+ start_token = input_->current();
+ DO(ConsumeInteger(&start, "Expected field number range."));
+ }
+
+ if (TryConsume("to")) {
+ LocationRecorder end_location(
+ location, DescriptorProto::ExtensionRange::kEndFieldNumber);
+ if (TryConsume("max")) {
+ // Set to the sentinel value - 1 since we increment the value below.
+ // The actual value of the end of the range should be set with
+ // AdjustExtensionRangesWithMaxEndNumber.
end = kMaxRangeSentinel - 1;
- } else {
- DO(ConsumeInteger(&end, "Expected integer."));
- }
- } else {
- LocationRecorder end_location(
- location, DescriptorProto::ExtensionRange::kEndFieldNumber);
- end_location.StartAt(start_token);
- end_location.EndAt(start_token);
- end = start;
- }
-
- // Users like to specify inclusive ranges, but in code we like the end
- // number to be exclusive.
- ++end;
-
- range->set_start(start);
- range->set_end(end);
- } while (TryConsume(","));
-
+ } else {
+ DO(ConsumeInteger(&end, "Expected integer."));
+ }
+ } else {
+ LocationRecorder end_location(
+ location, DescriptorProto::ExtensionRange::kEndFieldNumber);
+ end_location.StartAt(start_token);
+ end_location.EndAt(start_token);
+ end = start;
+ }
+
+ // Users like to specify inclusive ranges, but in code we like the end
+ // number to be exclusive.
+ ++end;
+
+ range->set_start(start);
+ range->set_end(end);
+ } while (TryConsume(","));
+
if (LookingAt("[")) {
int range_number_index = extensions_location.CurrentPathSize();
SourceCodeInfo info;
@@ -1690,60 +1690,60 @@ bool Parser::ParseExtensions(DescriptorProto* message,
}
}
- DO(ConsumeEndOfDeclaration(";", &extensions_location));
- return true;
-}
-
+ DO(ConsumeEndOfDeclaration(";", &extensions_location));
+ return true;
+}
+
// This is similar to extension range parsing, except that it accepts field
// name literals.
-bool Parser::ParseReserved(DescriptorProto* message,
- const LocationRecorder& message_location) {
+bool Parser::ParseReserved(DescriptorProto* message,
+ const LocationRecorder& message_location) {
io::Tokenizer::Token start_token = input_->current();
- // Parse the declaration.
- DO(Consume("reserved"));
- if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
- LocationRecorder location(message_location,
- DescriptorProto::kReservedNameFieldNumber);
+ // Parse the declaration.
+ DO(Consume("reserved"));
+ if (LookingAtType(io::Tokenizer::TYPE_STRING)) {
+ LocationRecorder location(message_location,
+ DescriptorProto::kReservedNameFieldNumber);
location.StartAt(start_token);
- return ParseReservedNames(message, location);
- } else {
- LocationRecorder location(message_location,
- DescriptorProto::kReservedRangeFieldNumber);
+ return ParseReservedNames(message, location);
+ } else {
+ LocationRecorder location(message_location,
+ DescriptorProto::kReservedRangeFieldNumber);
location.StartAt(start_token);
- return ParseReservedNumbers(message, location);
- }
-}
-
-bool Parser::ParseReservedNames(DescriptorProto* message,
- const LocationRecorder& parent_location) {
- do {
- LocationRecorder location(parent_location, message->reserved_name_size());
- DO(ConsumeString(message->add_reserved_name(), "Expected field name."));
- } while (TryConsume(","));
- DO(ConsumeEndOfDeclaration(";", &parent_location));
- return true;
-}
-
-bool Parser::ParseReservedNumbers(DescriptorProto* message,
- const LocationRecorder& parent_location) {
- bool first = true;
- do {
- LocationRecorder location(parent_location, message->reserved_range_size());
-
- DescriptorProto::ReservedRange* range = message->add_reserved_range();
- int start, end;
- io::Tokenizer::Token start_token;
- {
- LocationRecorder start_location(
- location, DescriptorProto::ReservedRange::kStartFieldNumber);
- start_token = input_->current();
+ return ParseReservedNumbers(message, location);
+ }
+}
+
+bool Parser::ParseReservedNames(DescriptorProto* message,
+ const LocationRecorder& parent_location) {
+ do {
+ LocationRecorder location(parent_location, message->reserved_name_size());
+ DO(ConsumeString(message->add_reserved_name(), "Expected field name."));
+ } while (TryConsume(","));
+ DO(ConsumeEndOfDeclaration(";", &parent_location));
+ return true;
+}
+
+bool Parser::ParseReservedNumbers(DescriptorProto* message,
+ const LocationRecorder& parent_location) {
+ bool first = true;
+ do {
+ LocationRecorder location(parent_location, message->reserved_range_size());
+
+ DescriptorProto::ReservedRange* range = message->add_reserved_range();
+ int start, end;
+ io::Tokenizer::Token start_token;
+ {
+ LocationRecorder start_location(
+ location, DescriptorProto::ReservedRange::kStartFieldNumber);
+ start_token = input_->current();
DO(ConsumeInteger(&start, (first ? "Expected field name or number range."
: "Expected field number range.")));
- }
-
- if (TryConsume("to")) {
- LocationRecorder end_location(
- location, DescriptorProto::ReservedRange::kEndFieldNumber);
+ }
+
+ if (TryConsume("to")) {
+ LocationRecorder end_location(
+ location, DescriptorProto::ReservedRange::kEndFieldNumber);
if (TryConsume("max")) {
// Set to the sentinel value - 1 since we increment the value below.
// The actual value of the end of the range should be set with
@@ -1752,27 +1752,27 @@ bool Parser::ParseReservedNumbers(DescriptorProto* message,
} else {
DO(ConsumeInteger(&end, "Expected integer."));
}
- } else {
- LocationRecorder end_location(
- location, DescriptorProto::ReservedRange::kEndFieldNumber);
- end_location.StartAt(start_token);
- end_location.EndAt(start_token);
- end = start;
- }
-
- // Users like to specify inclusive ranges, but in code we like the end
- // number to be exclusive.
- ++end;
-
- range->set_start(start);
- range->set_end(end);
- first = false;
- } while (TryConsume(","));
-
- DO(ConsumeEndOfDeclaration(";", &parent_location));
- return true;
-}
-
+ } else {
+ LocationRecorder end_location(
+ location, DescriptorProto::ReservedRange::kEndFieldNumber);
+ end_location.StartAt(start_token);
+ end_location.EndAt(start_token);
+ end = start;
+ }
+
+ // Users like to specify inclusive ranges, but in code we like the end
+ // number to be exclusive.
+ ++end;
+
+ range->set_start(start);
+ range->set_end(end);
+ first = false;
+ } while (TryConsume(","));
+
+ DO(ConsumeEndOfDeclaration(";", &parent_location));
+ return true;
+}
+
bool Parser::ParseReserved(EnumDescriptorProto* message,
const LocationRecorder& message_location) {
io::Tokenizer::Token start_token = input_->current();
@@ -1847,487 +1847,487 @@ bool Parser::ParseReservedNumbers(EnumDescriptorProto* message,
return true;
}
-bool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
- RepeatedPtrField<DescriptorProto>* messages,
- const LocationRecorder& parent_location,
- int location_field_number_for_nested_type,
- const LocationRecorder& extend_location,
- const FileDescriptorProto* containing_file) {
- DO(Consume("extend"));
-
- // Parse the extendee type.
- io::Tokenizer::Token extendee_start = input_->current();
+bool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
+ RepeatedPtrField<DescriptorProto>* messages,
+ const LocationRecorder& parent_location,
+ int location_field_number_for_nested_type,
+ const LocationRecorder& extend_location,
+ const FileDescriptorProto* containing_file) {
+ DO(Consume("extend"));
+
+ // Parse the extendee type.
+ io::Tokenizer::Token extendee_start = input_->current();
TProtoStringType extendee;
- DO(ParseUserDefinedType(&extendee));
- io::Tokenizer::Token extendee_end = input_->previous();
-
- // Parse the block.
- DO(ConsumeEndOfDeclaration("{", &extend_location));
-
- bool is_first = true;
-
- do {
- if (AtEnd()) {
- AddError("Reached end of input in extend definition (missing '}').");
- return false;
- }
-
- // Note that kExtensionFieldNumber was already pushed by the parent.
- LocationRecorder location(extend_location, extensions->size());
-
- FieldDescriptorProto* field = extensions->Add();
-
- {
- LocationRecorder extendee_location(
- location, FieldDescriptorProto::kExtendeeFieldNumber);
- extendee_location.StartAt(extendee_start);
- extendee_location.EndAt(extendee_end);
-
- if (is_first) {
- extendee_location.RecordLegacyLocation(
- field, DescriptorPool::ErrorCollector::EXTENDEE);
- is_first = false;
- }
- }
-
- field->set_extendee(extendee);
-
- if (!ParseMessageField(field, messages, parent_location,
+ DO(ParseUserDefinedType(&extendee));
+ io::Tokenizer::Token extendee_end = input_->previous();
+
+ // Parse the block.
+ DO(ConsumeEndOfDeclaration("{", &extend_location));
+
+ bool is_first = true;
+
+ do {
+ if (AtEnd()) {
+ AddError("Reached end of input in extend definition (missing '}').");
+ return false;
+ }
+
+ // Note that kExtensionFieldNumber was already pushed by the parent.
+ LocationRecorder location(extend_location, extensions->size());
+
+ FieldDescriptorProto* field = extensions->Add();
+
+ {
+ LocationRecorder extendee_location(
+ location, FieldDescriptorProto::kExtendeeFieldNumber);
+ extendee_location.StartAt(extendee_start);
+ extendee_location.EndAt(extendee_end);
+
+ if (is_first) {
+ extendee_location.RecordLegacyLocation(
+ field, DescriptorPool::ErrorCollector::EXTENDEE);
+ is_first = false;
+ }
+ }
+
+ field->set_extendee(extendee);
+
+ if (!ParseMessageField(field, messages, parent_location,
location_field_number_for_nested_type, location,
- containing_file)) {
- // This statement failed to parse. Skip it, but keep looping to parse
- // other statements.
- SkipStatement();
- }
- } while (!TryConsumeEndOfDeclaration("}", NULL));
-
- return true;
-}
-
-bool Parser::ParseOneof(OneofDescriptorProto* oneof_decl,
+ containing_file)) {
+ // This statement failed to parse. Skip it, but keep looping to parse
+ // other statements.
+ SkipStatement();
+ }
+ } while (!TryConsumeEndOfDeclaration("}", NULL));
+
+ return true;
+}
+
+bool Parser::ParseOneof(OneofDescriptorProto* oneof_decl,
DescriptorProto* containing_type, int oneof_index,
- const LocationRecorder& oneof_location,
- const LocationRecorder& containing_type_location,
- const FileDescriptorProto* containing_file) {
- DO(Consume("oneof"));
-
- {
- LocationRecorder name_location(oneof_location,
- OneofDescriptorProto::kNameFieldNumber);
- DO(ConsumeIdentifier(oneof_decl->mutable_name(), "Expected oneof name."));
- }
-
- DO(ConsumeEndOfDeclaration("{", &oneof_location));
-
- do {
- if (AtEnd()) {
- AddError("Reached end of input in oneof definition (missing '}').");
- return false;
- }
-
- if (LookingAt("option")) {
- LocationRecorder option_location(
- oneof_location, OneofDescriptorProto::kOptionsFieldNumber);
- if (!ParseOption(oneof_decl->mutable_options(), option_location,
- containing_file, OPTION_STATEMENT)) {
- return false;
- }
- continue;
- }
-
- // Print a nice error if the user accidentally tries to place a label
- // on an individual member of a oneof.
+ const LocationRecorder& oneof_location,
+ const LocationRecorder& containing_type_location,
+ const FileDescriptorProto* containing_file) {
+ DO(Consume("oneof"));
+
+ {
+ LocationRecorder name_location(oneof_location,
+ OneofDescriptorProto::kNameFieldNumber);
+ DO(ConsumeIdentifier(oneof_decl->mutable_name(), "Expected oneof name."));
+ }
+
+ DO(ConsumeEndOfDeclaration("{", &oneof_location));
+
+ do {
+ if (AtEnd()) {
+ AddError("Reached end of input in oneof definition (missing '}').");
+ return false;
+ }
+
+ if (LookingAt("option")) {
+ LocationRecorder option_location(
+ oneof_location, OneofDescriptorProto::kOptionsFieldNumber);
+ if (!ParseOption(oneof_decl->mutable_options(), option_location,
+ containing_file, OPTION_STATEMENT)) {
+ return false;
+ }
+ continue;
+ }
+
+ // Print a nice error if the user accidentally tries to place a label
+ // on an individual member of a oneof.
if (LookingAt("required") || LookingAt("optional") ||
- LookingAt("repeated")) {
+ LookingAt("repeated")) {
AddError(
"Fields in oneofs must not have labels (required / optional "
"/ repeated).");
- // We can continue parsing here because we understand what the user
- // meant. The error report will still make parsing fail overall.
- input_->Next();
- }
-
- LocationRecorder field_location(containing_type_location,
- DescriptorProto::kFieldFieldNumber,
- containing_type->field_size());
-
- FieldDescriptorProto* field = containing_type->add_field();
- field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
- field->set_oneof_index(oneof_index);
-
+ // We can continue parsing here because we understand what the user
+ // meant. The error report will still make parsing fail overall.
+ input_->Next();
+ }
+
+ LocationRecorder field_location(containing_type_location,
+ DescriptorProto::kFieldFieldNumber,
+ containing_type->field_size());
+
+ FieldDescriptorProto* field = containing_type->add_field();
+ field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);
+ field->set_oneof_index(oneof_index);
+
if (!ParseMessageFieldNoLabel(field, containing_type->mutable_nested_type(),
- containing_type_location,
- DescriptorProto::kNestedTypeFieldNumber,
+ containing_type_location,
+ DescriptorProto::kNestedTypeFieldNumber,
field_location, containing_file)) {
- // This statement failed to parse. Skip it, but keep looping to parse
- // other statements.
- SkipStatement();
- }
- } while (!TryConsumeEndOfDeclaration("}", NULL));
-
- return true;
-}
-
-// -------------------------------------------------------------------
-// Enums
-
-bool Parser::ParseEnumDefinition(EnumDescriptorProto* enum_type,
- const LocationRecorder& enum_location,
- const FileDescriptorProto* containing_file) {
- DO(Consume("enum"));
-
- {
- LocationRecorder location(enum_location,
- EnumDescriptorProto::kNameFieldNumber);
+ // This statement failed to parse. Skip it, but keep looping to parse
+ // other statements.
+ SkipStatement();
+ }
+ } while (!TryConsumeEndOfDeclaration("}", NULL));
+
+ return true;
+}
+
+// -------------------------------------------------------------------
+// Enums
+
+bool Parser::ParseEnumDefinition(EnumDescriptorProto* enum_type,
+ const LocationRecorder& enum_location,
+ const FileDescriptorProto* containing_file) {
+ DO(Consume("enum"));
+
+ {
+ LocationRecorder location(enum_location,
+ EnumDescriptorProto::kNameFieldNumber);
location.RecordLegacyLocation(enum_type,
DescriptorPool::ErrorCollector::NAME);
- DO(ConsumeIdentifier(enum_type->mutable_name(), "Expected enum name."));
- }
-
- DO(ParseEnumBlock(enum_type, enum_location, containing_file));
-
- DO(ValidateEnum(enum_type));
-
- return true;
-}
-
-bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type,
- const LocationRecorder& enum_location,
- const FileDescriptorProto* containing_file) {
- DO(ConsumeEndOfDeclaration("{", &enum_location));
-
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
- if (AtEnd()) {
- AddError("Reached end of input in enum definition (missing '}').");
- return false;
- }
-
- if (!ParseEnumStatement(enum_type, enum_location, containing_file)) {
- // This statement failed to parse. Skip it, but keep looping to parse
- // other statements.
- SkipStatement();
- }
- }
-
- return true;
-}
-
-bool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type,
- const LocationRecorder& enum_location,
- const FileDescriptorProto* containing_file) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
- // empty statement; ignore
- return true;
- } else if (LookingAt("option")) {
- LocationRecorder location(enum_location,
- EnumDescriptorProto::kOptionsFieldNumber);
+ DO(ConsumeIdentifier(enum_type->mutable_name(), "Expected enum name."));
+ }
+
+ DO(ParseEnumBlock(enum_type, enum_location, containing_file));
+
+ DO(ValidateEnum(enum_type));
+
+ return true;
+}
+
+bool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type,
+ const LocationRecorder& enum_location,
+ const FileDescriptorProto* containing_file) {
+ DO(ConsumeEndOfDeclaration("{", &enum_location));
+
+ while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ if (AtEnd()) {
+ AddError("Reached end of input in enum definition (missing '}').");
+ return false;
+ }
+
+ if (!ParseEnumStatement(enum_type, enum_location, containing_file)) {
+ // This statement failed to parse. Skip it, but keep looping to parse
+ // other statements.
+ SkipStatement();
+ }
+ }
+
+ return true;
+}
+
+bool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type,
+ const LocationRecorder& enum_location,
+ const FileDescriptorProto* containing_file) {
+ if (TryConsumeEndOfDeclaration(";", NULL)) {
+ // empty statement; ignore
+ return true;
+ } else if (LookingAt("option")) {
+ LocationRecorder location(enum_location,
+ EnumDescriptorProto::kOptionsFieldNumber);
return ParseOption(enum_type->mutable_options(), location, containing_file,
OPTION_STATEMENT);
} else if (LookingAt("reserved")) {
return ParseReserved(enum_type, enum_location);
- } else {
- LocationRecorder location(enum_location,
+ } else {
+ LocationRecorder location(enum_location,
EnumDescriptorProto::kValueFieldNumber,
enum_type->value_size());
- return ParseEnumConstant(enum_type->add_value(), location, containing_file);
- }
-}
-
-bool Parser::ParseEnumConstant(EnumValueDescriptorProto* enum_value,
- const LocationRecorder& enum_value_location,
- const FileDescriptorProto* containing_file) {
- // Parse name.
- {
- LocationRecorder location(enum_value_location,
- EnumValueDescriptorProto::kNameFieldNumber);
+ return ParseEnumConstant(enum_type->add_value(), location, containing_file);
+ }
+}
+
+bool Parser::ParseEnumConstant(EnumValueDescriptorProto* enum_value,
+ const LocationRecorder& enum_value_location,
+ const FileDescriptorProto* containing_file) {
+ // Parse name.
+ {
+ LocationRecorder location(enum_value_location,
+ EnumValueDescriptorProto::kNameFieldNumber);
location.RecordLegacyLocation(enum_value,
DescriptorPool::ErrorCollector::NAME);
- DO(ConsumeIdentifier(enum_value->mutable_name(),
- "Expected enum constant name."));
- }
-
- DO(Consume("=", "Missing numeric value for enum constant."));
-
- // Parse value.
- {
+ DO(ConsumeIdentifier(enum_value->mutable_name(),
+ "Expected enum constant name."));
+ }
+
+ DO(Consume("=", "Missing numeric value for enum constant."));
+
+ // Parse value.
+ {
LocationRecorder location(enum_value_location,
EnumValueDescriptorProto::kNumberFieldNumber);
location.RecordLegacyLocation(enum_value,
DescriptorPool::ErrorCollector::NUMBER);
-
- int number;
- DO(ConsumeSignedInteger(&number, "Expected integer."));
- enum_value->set_number(number);
- }
-
- DO(ParseEnumConstantOptions(enum_value, enum_value_location,
- containing_file));
-
- DO(ConsumeEndOfDeclaration(";", &enum_value_location));
-
- return true;
-}
-
-bool Parser::ParseEnumConstantOptions(
- EnumValueDescriptorProto* value,
- const LocationRecorder& enum_value_location,
- const FileDescriptorProto* containing_file) {
- if (!LookingAt("[")) return true;
-
+
+ int number;
+ DO(ConsumeSignedInteger(&number, "Expected integer."));
+ enum_value->set_number(number);
+ }
+
+ DO(ParseEnumConstantOptions(enum_value, enum_value_location,
+ containing_file));
+
+ DO(ConsumeEndOfDeclaration(";", &enum_value_location));
+
+ return true;
+}
+
+bool Parser::ParseEnumConstantOptions(
+ EnumValueDescriptorProto* value,
+ const LocationRecorder& enum_value_location,
+ const FileDescriptorProto* containing_file) {
+ if (!LookingAt("[")) return true;
+
LocationRecorder location(enum_value_location,
EnumValueDescriptorProto::kOptionsFieldNumber);
-
- DO(Consume("["));
-
- do {
+
+ DO(Consume("["));
+
+ do {
DO(ParseOption(value->mutable_options(), location, containing_file,
OPTION_ASSIGNMENT));
- } while (TryConsume(","));
-
- DO(Consume("]"));
- return true;
-}
-
-// -------------------------------------------------------------------
-// Services
-
-bool Parser::ParseServiceDefinition(
+ } while (TryConsume(","));
+
+ DO(Consume("]"));
+ return true;
+}
+
+// -------------------------------------------------------------------
+// Services
+
+bool Parser::ParseServiceDefinition(
ServiceDescriptorProto* service, const LocationRecorder& service_location,
- const FileDescriptorProto* containing_file) {
- DO(Consume("service"));
-
- {
- LocationRecorder location(service_location,
- ServiceDescriptorProto::kNameFieldNumber);
+ const FileDescriptorProto* containing_file) {
+ DO(Consume("service"));
+
+ {
+ LocationRecorder location(service_location,
+ ServiceDescriptorProto::kNameFieldNumber);
location.RecordLegacyLocation(service,
DescriptorPool::ErrorCollector::NAME);
- DO(ConsumeIdentifier(service->mutable_name(), "Expected service name."));
- }
-
- DO(ParseServiceBlock(service, service_location, containing_file));
- return true;
-}
-
-bool Parser::ParseServiceBlock(ServiceDescriptorProto* service,
- const LocationRecorder& service_location,
- const FileDescriptorProto* containing_file) {
- DO(ConsumeEndOfDeclaration("{", &service_location));
-
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
- if (AtEnd()) {
- AddError("Reached end of input in service definition (missing '}').");
- return false;
- }
-
- if (!ParseServiceStatement(service, service_location, containing_file)) {
- // This statement failed to parse. Skip it, but keep looping to parse
- // other statements.
- SkipStatement();
- }
- }
-
- return true;
-}
-
-bool Parser::ParseServiceStatement(ServiceDescriptorProto* service,
- const LocationRecorder& service_location,
- const FileDescriptorProto* containing_file) {
- if (TryConsumeEndOfDeclaration(";", NULL)) {
- // empty statement; ignore
- return true;
- } else if (LookingAt("option")) {
+ DO(ConsumeIdentifier(service->mutable_name(), "Expected service name."));
+ }
+
+ DO(ParseServiceBlock(service, service_location, containing_file));
+ return true;
+}
+
+bool Parser::ParseServiceBlock(ServiceDescriptorProto* service,
+ const LocationRecorder& service_location,
+ const FileDescriptorProto* containing_file) {
+ DO(ConsumeEndOfDeclaration("{", &service_location));
+
+ while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ if (AtEnd()) {
+ AddError("Reached end of input in service definition (missing '}').");
+ return false;
+ }
+
+ if (!ParseServiceStatement(service, service_location, containing_file)) {
+ // This statement failed to parse. Skip it, but keep looping to parse
+ // other statements.
+ SkipStatement();
+ }
+ }
+
+ return true;
+}
+
+bool Parser::ParseServiceStatement(ServiceDescriptorProto* service,
+ const LocationRecorder& service_location,
+ const FileDescriptorProto* containing_file) {
+ if (TryConsumeEndOfDeclaration(";", NULL)) {
+ // empty statement; ignore
+ return true;
+ } else if (LookingAt("option")) {
LocationRecorder location(service_location,
ServiceDescriptorProto::kOptionsFieldNumber);
return ParseOption(service->mutable_options(), location, containing_file,
OPTION_STATEMENT);
- } else {
- LocationRecorder location(service_location,
+ } else {
+ LocationRecorder location(service_location,
ServiceDescriptorProto::kMethodFieldNumber,
service->method_size());
- return ParseServiceMethod(service->add_method(), location, containing_file);
- }
-}
-
-bool Parser::ParseServiceMethod(MethodDescriptorProto* method,
- const LocationRecorder& method_location,
- const FileDescriptorProto* containing_file) {
- DO(Consume("rpc"));
-
- {
- LocationRecorder location(method_location,
- MethodDescriptorProto::kNameFieldNumber);
+ return ParseServiceMethod(service->add_method(), location, containing_file);
+ }
+}
+
+bool Parser::ParseServiceMethod(MethodDescriptorProto* method,
+ const LocationRecorder& method_location,
+ const FileDescriptorProto* containing_file) {
+ DO(Consume("rpc"));
+
+ {
+ LocationRecorder location(method_location,
+ MethodDescriptorProto::kNameFieldNumber);
location.RecordLegacyLocation(method, DescriptorPool::ErrorCollector::NAME);
- DO(ConsumeIdentifier(method->mutable_name(), "Expected method name."));
- }
-
- // Parse input type.
- DO(Consume("("));
- {
- if (LookingAt("stream")) {
- LocationRecorder location(
- method_location, MethodDescriptorProto::kClientStreamingFieldNumber);
+ DO(ConsumeIdentifier(method->mutable_name(), "Expected method name."));
+ }
+
+ // Parse input type.
+ DO(Consume("("));
+ {
+ if (LookingAt("stream")) {
+ LocationRecorder location(
+ method_location, MethodDescriptorProto::kClientStreamingFieldNumber);
location.RecordLegacyLocation(method,
DescriptorPool::ErrorCollector::OTHER);
- method->set_client_streaming(true);
- DO(Consume("stream"));
-
- }
- LocationRecorder location(method_location,
- MethodDescriptorProto::kInputTypeFieldNumber);
+ method->set_client_streaming(true);
+ DO(Consume("stream"));
+
+ }
+ LocationRecorder location(method_location,
+ MethodDescriptorProto::kInputTypeFieldNumber);
location.RecordLegacyLocation(method,
DescriptorPool::ErrorCollector::INPUT_TYPE);
- DO(ParseUserDefinedType(method->mutable_input_type()));
- }
- DO(Consume(")"));
-
- // Parse output type.
- DO(Consume("returns"));
- DO(Consume("("));
- {
- if (LookingAt("stream")) {
- LocationRecorder location(
- method_location, MethodDescriptorProto::kServerStreamingFieldNumber);
+ DO(ParseUserDefinedType(method->mutable_input_type()));
+ }
+ DO(Consume(")"));
+
+ // Parse output type.
+ DO(Consume("returns"));
+ DO(Consume("("));
+ {
+ if (LookingAt("stream")) {
+ LocationRecorder location(
+ method_location, MethodDescriptorProto::kServerStreamingFieldNumber);
location.RecordLegacyLocation(method,
DescriptorPool::ErrorCollector::OTHER);
- DO(Consume("stream"));
- method->set_server_streaming(true);
-
- }
- LocationRecorder location(method_location,
- MethodDescriptorProto::kOutputTypeFieldNumber);
+ DO(Consume("stream"));
+ method->set_server_streaming(true);
+
+ }
+ LocationRecorder location(method_location,
+ MethodDescriptorProto::kOutputTypeFieldNumber);
location.RecordLegacyLocation(method,
DescriptorPool::ErrorCollector::OUTPUT_TYPE);
- DO(ParseUserDefinedType(method->mutable_output_type()));
- }
- DO(Consume(")"));
-
- if (LookingAt("{")) {
- // Options!
- DO(ParseMethodOptions(method_location, containing_file,
- MethodDescriptorProto::kOptionsFieldNumber,
- method->mutable_options()));
- } else {
- DO(ConsumeEndOfDeclaration(";", &method_location));
- }
-
- return true;
-}
-
-bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
- const FileDescriptorProto* containing_file,
- const int optionsFieldNumber,
- Message* mutable_options) {
- // Options!
- ConsumeEndOfDeclaration("{", &parent_location);
- while (!TryConsumeEndOfDeclaration("}", NULL)) {
- if (AtEnd()) {
- AddError("Reached end of input in method options (missing '}').");
- return false;
- }
-
- if (TryConsumeEndOfDeclaration(";", NULL)) {
- // empty statement; ignore
- } else {
+ DO(ParseUserDefinedType(method->mutable_output_type()));
+ }
+ DO(Consume(")"));
+
+ if (LookingAt("{")) {
+ // Options!
+ DO(ParseMethodOptions(method_location, containing_file,
+ MethodDescriptorProto::kOptionsFieldNumber,
+ method->mutable_options()));
+ } else {
+ DO(ConsumeEndOfDeclaration(";", &method_location));
+ }
+
+ return true;
+}
+
+bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
+ const FileDescriptorProto* containing_file,
+ const int optionsFieldNumber,
+ Message* mutable_options) {
+ // Options!
+ ConsumeEndOfDeclaration("{", &parent_location);
+ while (!TryConsumeEndOfDeclaration("}", NULL)) {
+ if (AtEnd()) {
+ AddError("Reached end of input in method options (missing '}').");
+ return false;
+ }
+
+ if (TryConsumeEndOfDeclaration(";", NULL)) {
+ // empty statement; ignore
+ } else {
LocationRecorder location(parent_location, optionsFieldNumber);
if (!ParseOption(mutable_options, location, containing_file,
OPTION_STATEMENT)) {
- // This statement failed to parse. Skip it, but keep looping to
- // parse other statements.
- SkipStatement();
- }
- }
- }
-
- return true;
-}
-
-// -------------------------------------------------------------------
-
-bool Parser::ParseLabel(FieldDescriptorProto::Label* label,
+ // This statement failed to parse. Skip it, but keep looping to
+ // parse other statements.
+ SkipStatement();
+ }
+ }
+ }
+
+ return true;
+}
+
+// -------------------------------------------------------------------
+
+bool Parser::ParseLabel(FieldDescriptorProto::Label* label,
const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file) {
+ const FileDescriptorProto* containing_file) {
if (!LookingAt("optional") && !LookingAt("repeated") &&
!LookingAt("required")) {
return false;
}
LocationRecorder location(field_location,
FieldDescriptorProto::kLabelFieldNumber);
- if (TryConsume("optional")) {
- *label = FieldDescriptorProto::LABEL_OPTIONAL;
- } else if (TryConsume("repeated")) {
- *label = FieldDescriptorProto::LABEL_REPEATED;
+ if (TryConsume("optional")) {
+ *label = FieldDescriptorProto::LABEL_OPTIONAL;
+ } else if (TryConsume("repeated")) {
+ *label = FieldDescriptorProto::LABEL_REPEATED;
} else {
Consume("required");
- *label = FieldDescriptorProto::LABEL_REQUIRED;
- }
+ *label = FieldDescriptorProto::LABEL_REQUIRED;
+ }
return true;
-}
-
-bool Parser::ParseType(FieldDescriptorProto::Type* type,
+}
+
+bool Parser::ParseType(FieldDescriptorProto::Type* type,
TProtoStringType* type_name) {
- TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);
- if (iter != kTypeNames.end()) {
- *type = iter->second;
- input_->Next();
- } else {
- DO(ParseUserDefinedType(type_name));
- }
- return true;
-}
-
+ TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);
+ if (iter != kTypeNames.end()) {
+ *type = iter->second;
+ input_->Next();
+ } else {
+ DO(ParseUserDefinedType(type_name));
+ }
+ return true;
+}
+
bool Parser::ParseUserDefinedType(TProtoStringType* type_name) {
- type_name->clear();
-
- TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);
- if (iter != kTypeNames.end()) {
- // Note: The only place enum types are allowed is for field types, but
- // if we are parsing a field type then we would not get here because
- // primitives are allowed there as well. So this error message doesn't
- // need to account for enums.
- AddError("Expected message type.");
-
- // Pretend to accept this type so that we can go on parsing.
- *type_name = input_->current().text;
- input_->Next();
- return true;
- }
-
- // A leading "." means the name is fully-qualified.
- if (TryConsume(".")) type_name->append(".");
-
- // Consume the first part of the name.
+ type_name->clear();
+
+ TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);
+ if (iter != kTypeNames.end()) {
+ // Note: The only place enum types are allowed is for field types, but
+ // if we are parsing a field type then we would not get here because
+ // primitives are allowed there as well. So this error message doesn't
+ // need to account for enums.
+ AddError("Expected message type.");
+
+ // Pretend to accept this type so that we can go on parsing.
+ *type_name = input_->current().text;
+ input_->Next();
+ return true;
+ }
+
+ // A leading "." means the name is fully-qualified.
+ if (TryConsume(".")) type_name->append(".");
+
+ // Consume the first part of the name.
TProtoStringType identifier;
- DO(ConsumeIdentifier(&identifier, "Expected type name."));
- type_name->append(identifier);
-
- // Consume more parts.
- while (TryConsume(".")) {
- type_name->append(".");
- DO(ConsumeIdentifier(&identifier, "Expected identifier."));
- type_name->append(identifier);
- }
-
- return true;
-}
-
-// ===================================================================
-
-bool Parser::ParsePackage(FileDescriptorProto* file,
- const LocationRecorder& root_location,
- const FileDescriptorProto* containing_file) {
- if (file->has_package()) {
- AddError("Multiple package definitions.");
- // Don't append the new package to the old one. Just replace it. Not
- // that it really matters since this is an error anyway.
- file->clear_package();
- }
-
+ DO(ConsumeIdentifier(&identifier, "Expected type name."));
+ type_name->append(identifier);
+
+ // Consume more parts.
+ while (TryConsume(".")) {
+ type_name->append(".");
+ DO(ConsumeIdentifier(&identifier, "Expected identifier."));
+ type_name->append(identifier);
+ }
+
+ return true;
+}
+
+// ===================================================================
+
+bool Parser::ParsePackage(FileDescriptorProto* file,
+ const LocationRecorder& root_location,
+ const FileDescriptorProto* containing_file) {
+ if (file->has_package()) {
+ AddError("Multiple package definitions.");
+ // Don't append the new package to the old one. Just replace it. Not
+ // that it really matters since this is an error anyway.
+ file->clear_package();
+ }
+
LocationRecorder location(root_location,
FileDescriptorProto::kPackageFieldNumber);
location.RecordLegacyLocation(file, DescriptorPool::ErrorCollector::NAME);
- DO(Consume("package"));
-
+ DO(Consume("package"));
+
while (true) {
TProtoStringType identifier;
DO(ConsumeIdentifier(&identifier, "Expected identifier."));
@@ -2335,71 +2335,71 @@ bool Parser::ParsePackage(FileDescriptorProto* file,
if (!TryConsume(".")) break;
file->mutable_package()->append(".");
}
-
+
DO(ConsumeEndOfDeclaration(";", &location));
-
- return true;
-}
-
+
+ return true;
+}
+
bool Parser::ParseImport(RepeatedPtrField<TProtoStringType>* dependency,
RepeatedField<int32_t>* public_dependency,
RepeatedField<int32_t>* weak_dependency,
- const LocationRecorder& root_location,
- const FileDescriptorProto* containing_file) {
+ const LocationRecorder& root_location,
+ const FileDescriptorProto* containing_file) {
LocationRecorder location(root_location,
FileDescriptorProto::kDependencyFieldNumber,
dependency->size());
- DO(Consume("import"));
+ DO(Consume("import"));
- if (LookingAt("public")) {
+ if (LookingAt("public")) {
LocationRecorder public_location(
- root_location, FileDescriptorProto::kPublicDependencyFieldNumber,
- public_dependency->size());
- DO(Consume("public"));
- *public_dependency->Add() = dependency->size();
- } else if (LookingAt("weak")) {
+ root_location, FileDescriptorProto::kPublicDependencyFieldNumber,
+ public_dependency->size());
+ DO(Consume("public"));
+ *public_dependency->Add() = dependency->size();
+ } else if (LookingAt("weak")) {
LocationRecorder weak_location(
- root_location, FileDescriptorProto::kWeakDependencyFieldNumber,
- weak_dependency->size());
+ root_location, FileDescriptorProto::kWeakDependencyFieldNumber,
+ weak_dependency->size());
weak_location.RecordLegacyImportLocation(containing_file, "weak");
- DO(Consume("weak"));
- *weak_dependency->Add() = dependency->size();
- }
-
+ DO(Consume("weak"));
+ *weak_dependency->Add() = dependency->size();
+ }
+
TProtoStringType import_file;
DO(ConsumeString(&import_file,
"Expected a string naming the file to import."));
*dependency->Add() = import_file;
location.RecordLegacyImportLocation(containing_file, import_file);
-
+
DO(ConsumeEndOfDeclaration(";", &location));
- return true;
-}
-
-// ===================================================================
-
-SourceLocationTable::SourceLocationTable() {}
-SourceLocationTable::~SourceLocationTable() {}
-
-bool SourceLocationTable::Find(
- const Message* descriptor,
+ return true;
+}
+
+// ===================================================================
+
+SourceLocationTable::SourceLocationTable() {}
+SourceLocationTable::~SourceLocationTable() {}
+
+bool SourceLocationTable::Find(
+ const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, int* line,
int* column) const {
const std::pair<int, int>* result =
- FindOrNull(location_map_, std::make_pair(descriptor, location));
- if (result == NULL) {
+ FindOrNull(location_map_, std::make_pair(descriptor, location));
+ if (result == NULL) {
*line = -1;
- *column = 0;
- return false;
- } else {
+ *column = 0;
+ return false;
+ } else {
*line = result->first;
- *column = result->second;
- return true;
- }
-}
-
+ *column = result->second;
+ return true;
+ }
+}
+
bool SourceLocationTable::FindImport(const Message* descriptor,
const TProtoStringType& name, int* line,
int* column) const {
@@ -2416,23 +2416,23 @@ bool SourceLocationTable::FindImport(const Message* descriptor,
}
}
-void SourceLocationTable::Add(
- const Message* descriptor,
+void SourceLocationTable::Add(
+ const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, int line,
int column) {
- location_map_[std::make_pair(descriptor, location)] =
- std::make_pair(line, column);
-}
-
+ location_map_[std::make_pair(descriptor, location)] =
+ std::make_pair(line, column);
+}
+
void SourceLocationTable::AddImport(const Message* descriptor,
const TProtoStringType& name, int line,
int column) {
import_location_map_[std::make_pair(descriptor, name)] =
std::make_pair(line, column);
-}
-
+}
+
void SourceLocationTable::Clear() { location_map_.clear(); }
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
index 0f7509a7eb..ca42449a95 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.h
@@ -1,603 +1,603 @@
-// 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: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
-//
-// Implements parsing of .proto files to FileDescriptorProtos.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__
-#define GOOGLE_PROTOBUF_COMPILER_PARSER_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: kenton@google.com (Kenton Varda)
+// Based on original Protocol Buffers design by
+// Sanjay Ghemawat, Jeff Dean, and others.
+//
+// Implements parsing of .proto files to FileDescriptorProtos.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__
+#define GOOGLE_PROTOBUF_COMPILER_PARSER_H__
+
#include <cstdint>
-#include <map>
+#include <map>
#include <string>
-#include <utility>
+#include <utility>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/repeated_field.h>
-
+
// Must be included last.
#include <google/protobuf/port_def.inc>
-namespace google {
+namespace google {
namespace protobuf {
-
+
class Message;
-namespace compiler {
-
-// Defined in this file.
-class Parser;
-class SourceLocationTable;
-
-// Implements parsing of protocol definitions (such as .proto files).
-//
-// Note that most users will be more interested in the Importer class.
-// Parser is a lower-level class which simply converts a single .proto file
-// to a FileDescriptorProto. It does not resolve import directives or perform
-// many other kinds of validation needed to construct a complete
-// FileDescriptor.
+namespace compiler {
+
+// Defined in this file.
+class Parser;
+class SourceLocationTable;
+
+// Implements parsing of protocol definitions (such as .proto files).
+//
+// Note that most users will be more interested in the Importer class.
+// Parser is a lower-level class which simply converts a single .proto file
+// to a FileDescriptorProto. It does not resolve import directives or perform
+// many other kinds of validation needed to construct a complete
+// FileDescriptor.
class PROTOBUF_EXPORT Parser {
- public:
- Parser();
- ~Parser();
-
- // Parse the entire input and construct a FileDescriptorProto representing
- // it. Returns true if no errors occurred, false otherwise.
- bool Parse(io::Tokenizer* input, FileDescriptorProto* file);
-
- // Optional features:
-
- // DEPRECATED: New code should use the SourceCodeInfo embedded in the
- // FileDescriptorProto.
- //
- // Requests that locations of certain definitions be recorded to the given
- // SourceLocationTable while parsing. This can be used to look up exact line
- // and column numbers for errors reported by DescriptorPool during validation.
- // Set to NULL (the default) to discard source location information.
- void RecordSourceLocationsTo(SourceLocationTable* location_table) {
- source_location_table_ = location_table;
- }
-
- // Requests that errors be recorded to the given ErrorCollector while
- // parsing. Set to NULL (the default) to discard error messages.
- void RecordErrorsTo(io::ErrorCollector* error_collector) {
- error_collector_ = error_collector;
- }
-
- // Returns the identifier used in the "syntax = " declaration, if one was
- // seen during the last call to Parse(), or the empty string otherwise.
+ public:
+ Parser();
+ ~Parser();
+
+ // Parse the entire input and construct a FileDescriptorProto representing
+ // it. Returns true if no errors occurred, false otherwise.
+ bool Parse(io::Tokenizer* input, FileDescriptorProto* file);
+
+ // Optional features:
+
+ // DEPRECATED: New code should use the SourceCodeInfo embedded in the
+ // FileDescriptorProto.
+ //
+ // Requests that locations of certain definitions be recorded to the given
+ // SourceLocationTable while parsing. This can be used to look up exact line
+ // and column numbers for errors reported by DescriptorPool during validation.
+ // Set to NULL (the default) to discard source location information.
+ void RecordSourceLocationsTo(SourceLocationTable* location_table) {
+ source_location_table_ = location_table;
+ }
+
+ // Requests that errors be recorded to the given ErrorCollector while
+ // parsing. Set to NULL (the default) to discard error messages.
+ void RecordErrorsTo(io::ErrorCollector* error_collector) {
+ error_collector_ = error_collector;
+ }
+
+ // Returns the identifier used in the "syntax = " declaration, if one was
+ // seen during the last call to Parse(), or the empty string otherwise.
const TProtoStringType& GetSyntaxIdentifier() { return syntax_identifier_; }
-
- // If set true, input files will be required to begin with a syntax
- // identifier. Otherwise, files may omit this. If a syntax identifier
- // is provided, it must be 'syntax = "proto2";' and must appear at the
- // top of this file regardless of whether or not it was required.
- void SetRequireSyntaxIdentifier(bool value) {
- require_syntax_identifier_ = value;
- }
-
- // Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop
- // parsing as soon as it has seen the syntax identifier, or lack thereof.
- // This is useful for quickly identifying the syntax of the file without
- // parsing the whole thing. If this is enabled, no error will be recorded
- // if the syntax identifier is something other than "proto2" (since
- // presumably the caller intends to deal with that), but other kinds of
- // errors (e.g. parse errors) will still be reported. When this is enabled,
- // you may pass a NULL FileDescriptorProto to Parse().
- void SetStopAfterSyntaxIdentifier(bool value) {
- stop_after_syntax_identifier_ = value;
- }
-
- private:
- class LocationRecorder;
-
- // =================================================================
- // Error recovery helpers
-
- // Consume the rest of the current statement. This consumes tokens
- // until it sees one of:
- // ';' Consumes the token and returns.
- // '{' Consumes the brace then calls SkipRestOfBlock().
- // '}' Returns without consuming.
- // EOF Returns (can't consume).
- // The Parser often calls SkipStatement() after encountering a syntax
- // error. This allows it to go on parsing the following lines, allowing
- // it to report more than just one error in the file.
- void SkipStatement();
-
- // Consume the rest of the current block, including nested blocks,
- // ending after the closing '}' is encountered and consumed, or at EOF.
- void SkipRestOfBlock();
-
- // -----------------------------------------------------------------
- // Single-token consuming helpers
- //
- // These make parsing code more readable.
-
- // True if the current token is TYPE_END.
- inline bool AtEnd();
-
- // True if the next token matches the given text.
- inline bool LookingAt(const char* text);
- // True if the next token is of the given type.
- inline bool LookingAtType(io::Tokenizer::TokenType token_type);
-
- // If the next token exactly matches the text given, consume it and return
- // true. Otherwise, return false without logging an error.
- bool TryConsume(const char* text);
-
- // These attempt to read some kind of token from the input. If successful,
- // they return true. Otherwise they return false and add the given error
- // to the error list.
-
- // Consume a token with the exact text given.
- bool Consume(const char* text, const char* error);
- // Same as above, but automatically generates the error "Expected \"text\".",
- // where "text" is the expected token text.
- bool Consume(const char* text);
- // Consume a token of type IDENTIFIER and store its text in "output".
+
+ // If set true, input files will be required to begin with a syntax
+ // identifier. Otherwise, files may omit this. If a syntax identifier
+ // is provided, it must be 'syntax = "proto2";' and must appear at the
+ // top of this file regardless of whether or not it was required.
+ void SetRequireSyntaxIdentifier(bool value) {
+ require_syntax_identifier_ = value;
+ }
+
+ // Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop
+ // parsing as soon as it has seen the syntax identifier, or lack thereof.
+ // This is useful for quickly identifying the syntax of the file without
+ // parsing the whole thing. If this is enabled, no error will be recorded
+ // if the syntax identifier is something other than "proto2" (since
+ // presumably the caller intends to deal with that), but other kinds of
+ // errors (e.g. parse errors) will still be reported. When this is enabled,
+ // you may pass a NULL FileDescriptorProto to Parse().
+ void SetStopAfterSyntaxIdentifier(bool value) {
+ stop_after_syntax_identifier_ = value;
+ }
+
+ private:
+ class LocationRecorder;
+
+ // =================================================================
+ // Error recovery helpers
+
+ // Consume the rest of the current statement. This consumes tokens
+ // until it sees one of:
+ // ';' Consumes the token and returns.
+ // '{' Consumes the brace then calls SkipRestOfBlock().
+ // '}' Returns without consuming.
+ // EOF Returns (can't consume).
+ // The Parser often calls SkipStatement() after encountering a syntax
+ // error. This allows it to go on parsing the following lines, allowing
+ // it to report more than just one error in the file.
+ void SkipStatement();
+
+ // Consume the rest of the current block, including nested blocks,
+ // ending after the closing '}' is encountered and consumed, or at EOF.
+ void SkipRestOfBlock();
+
+ // -----------------------------------------------------------------
+ // Single-token consuming helpers
+ //
+ // These make parsing code more readable.
+
+ // True if the current token is TYPE_END.
+ inline bool AtEnd();
+
+ // True if the next token matches the given text.
+ inline bool LookingAt(const char* text);
+ // True if the next token is of the given type.
+ inline bool LookingAtType(io::Tokenizer::TokenType token_type);
+
+ // If the next token exactly matches the text given, consume it and return
+ // true. Otherwise, return false without logging an error.
+ bool TryConsume(const char* text);
+
+ // These attempt to read some kind of token from the input. If successful,
+ // they return true. Otherwise they return false and add the given error
+ // to the error list.
+
+ // Consume a token with the exact text given.
+ bool Consume(const char* text, const char* error);
+ // Same as above, but automatically generates the error "Expected \"text\".",
+ // where "text" is the expected token text.
+ bool Consume(const char* text);
+ // Consume a token of type IDENTIFIER and store its text in "output".
bool ConsumeIdentifier(TProtoStringType* output, const char* error);
- // Consume an integer and store its value in "output".
- bool ConsumeInteger(int* output, const char* error);
- // Consume a signed integer and store its value in "output".
- bool ConsumeSignedInteger(int* output, const char* error);
- // Consume a 64-bit integer and store its value in "output". If the value
- // is greater than max_value, an error will be reported.
+ // Consume an integer and store its value in "output".
+ bool ConsumeInteger(int* output, const char* error);
+ // Consume a signed integer and store its value in "output".
+ bool ConsumeSignedInteger(int* output, const char* error);
+ // Consume a 64-bit integer and store its value in "output". If the value
+ // is greater than max_value, an error will be reported.
bool ConsumeInteger64(uint64_t max_value, uint64_t* output,
const char* error);
- // Consume a number and store its value in "output". This will accept
- // tokens of either INTEGER or FLOAT type.
- bool ConsumeNumber(double* output, const char* error);
- // Consume a string literal and store its (unescaped) value in "output".
+ // Consume a number and store its value in "output". This will accept
+ // tokens of either INTEGER or FLOAT type.
+ bool ConsumeNumber(double* output, const char* error);
+ // Consume a string literal and store its (unescaped) value in "output".
bool ConsumeString(TProtoStringType* output, const char* error);
-
- // Consume a token representing the end of the statement. Comments between
- // this token and the next will be harvested for documentation. The given
- // LocationRecorder should refer to the declaration that was just parsed;
- // it will be populated with these comments.
- //
- // TODO(kenton): The LocationRecorder is const because historically locations
- // have been passed around by const reference, for no particularly good
- // reason. We should probably go through and change them all to mutable
- // pointer to make this more intuitive.
+
+ // Consume a token representing the end of the statement. Comments between
+ // this token and the next will be harvested for documentation. The given
+ // LocationRecorder should refer to the declaration that was just parsed;
+ // it will be populated with these comments.
+ //
+ // TODO(kenton): The LocationRecorder is const because historically locations
+ // have been passed around by const reference, for no particularly good
+ // reason. We should probably go through and change them all to mutable
+ // pointer to make this more intuitive.
bool TryConsumeEndOfDeclaration(const char* text,
const LocationRecorder* location);
bool TryConsumeEndOfDeclarationFinishScope(const char* text,
const LocationRecorder* location);
-
+
bool ConsumeEndOfDeclaration(const char* text,
const LocationRecorder* location);
-
- // -----------------------------------------------------------------
- // Error logging helpers
-
- // Invokes error_collector_->AddError(), if error_collector_ is not NULL.
+
+ // -----------------------------------------------------------------
+ // Error logging helpers
+
+ // Invokes error_collector_->AddError(), if error_collector_ is not NULL.
void AddError(int line, int column, const TProtoStringType& error);
-
- // Invokes error_collector_->AddError() with the line and column number
- // of the current token.
+
+ // Invokes error_collector_->AddError() with the line and column number
+ // of the current token.
void AddError(const TProtoStringType& error);
-
+
// Invokes error_collector_->AddWarning() with the line and column number
// of the current token.
void AddWarning(const TProtoStringType& warning);
- // Records a location in the SourceCodeInfo.location table (see
- // descriptor.proto). We use RAII to ensure that the start and end locations
- // are recorded -- the constructor records the start location and the
- // destructor records the end location. Since the parser is
- // recursive-descent, this works out beautifully.
+ // Records a location in the SourceCodeInfo.location table (see
+ // descriptor.proto). We use RAII to ensure that the start and end locations
+ // are recorded -- the constructor records the start location and the
+ // destructor records the end location. Since the parser is
+ // recursive-descent, this works out beautifully.
class PROTOBUF_EXPORT LocationRecorder {
- public:
- // Construct the file's "root" location.
- LocationRecorder(Parser* parser);
-
- // Construct a location that represents a declaration nested within the
- // given parent. E.g. a field's location is nested within the location
- // for a message type. The parent's path will be copied, so you should
- // call AddPath() only to add the path components leading from the parent
- // to the child (as opposed to leading from the root to the child).
- LocationRecorder(const LocationRecorder& parent);
-
- // Convenience constructors that call AddPath() one or two times.
- LocationRecorder(const LocationRecorder& parent, int path1);
- LocationRecorder(const LocationRecorder& parent, int path1, int path2);
-
+ public:
+ // Construct the file's "root" location.
+ LocationRecorder(Parser* parser);
+
+ // Construct a location that represents a declaration nested within the
+ // given parent. E.g. a field's location is nested within the location
+ // for a message type. The parent's path will be copied, so you should
+ // call AddPath() only to add the path components leading from the parent
+ // to the child (as opposed to leading from the root to the child).
+ LocationRecorder(const LocationRecorder& parent);
+
+ // Convenience constructors that call AddPath() one or two times.
+ LocationRecorder(const LocationRecorder& parent, int path1);
+ LocationRecorder(const LocationRecorder& parent, int path1, int path2);
+
// Creates a recorder that generates locations into given source code info.
LocationRecorder(const LocationRecorder& parent, int path1,
SourceCodeInfo* source_code_info);
- ~LocationRecorder();
-
- // Add a path component. See SourceCodeInfo.Location.path in
- // descriptor.proto.
- void AddPath(int path_component);
-
- // By default the location is considered to start at the current token at
- // the time the LocationRecorder is created. StartAt() sets the start
- // location to the given token instead.
- void StartAt(const io::Tokenizer::Token& token);
-
- // Start at the same location as some other LocationRecorder.
- void StartAt(const LocationRecorder& other);
-
- // By default the location is considered to end at the previous token at
- // the time the LocationRecorder is destroyed. EndAt() sets the end
- // location to the given token instead.
- void EndAt(const io::Tokenizer::Token& token);
-
- // Records the start point of this location to the SourceLocationTable that
- // was passed to RecordSourceLocationsTo(), if any. SourceLocationTable
- // is an older way of keeping track of source locations which is still
- // used in some places.
+ ~LocationRecorder();
+
+ // Add a path component. See SourceCodeInfo.Location.path in
+ // descriptor.proto.
+ void AddPath(int path_component);
+
+ // By default the location is considered to start at the current token at
+ // the time the LocationRecorder is created. StartAt() sets the start
+ // location to the given token instead.
+ void StartAt(const io::Tokenizer::Token& token);
+
+ // Start at the same location as some other LocationRecorder.
+ void StartAt(const LocationRecorder& other);
+
+ // By default the location is considered to end at the previous token at
+ // the time the LocationRecorder is destroyed. EndAt() sets the end
+ // location to the given token instead.
+ void EndAt(const io::Tokenizer::Token& token);
+
+ // Records the start point of this location to the SourceLocationTable that
+ // was passed to RecordSourceLocationsTo(), if any. SourceLocationTable
+ // is an older way of keeping track of source locations which is still
+ // used in some places.
void RecordLegacyLocation(
const Message* descriptor,
- DescriptorPool::ErrorCollector::ErrorLocation location);
+ DescriptorPool::ErrorCollector::ErrorLocation location);
void RecordLegacyImportLocation(const Message* descriptor,
const TProtoStringType& name);
-
+
// Returns the number of path components in the recorder's current location.
int CurrentPathSize() const;
- // Attaches leading and trailing comments to the location. The two strings
- // will be swapped into place, so after this is called *leading and
- // *trailing will be empty.
- //
- // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for
- // why this is const.
+ // Attaches leading and trailing comments to the location. The two strings
+ // will be swapped into place, so after this is called *leading and
+ // *trailing will be empty.
+ //
+ // TODO(kenton): See comment on TryConsumeEndOfDeclaration(), above, for
+ // why this is const.
void AttachComments(TProtoStringType* leading, TProtoStringType* trailing,
std::vector<TProtoStringType>* detached_comments) const;
-
- private:
- // Indexes of parent and current location in the parent
- // SourceCodeInfo.location repeated field. For top-level elements,
- // parent_index_ is -1.
- Parser* parser_;
+
+ private:
+ // Indexes of parent and current location in the parent
+ // SourceCodeInfo.location repeated field. For top-level elements,
+ // parent_index_ is -1.
+ Parser* parser_;
SourceCodeInfo* source_code_info_;
- SourceCodeInfo::Location* location_;
-
+ SourceCodeInfo::Location* location_;
+
void Init(const LocationRecorder& parent, SourceCodeInfo* source_code_info);
- };
-
- // =================================================================
- // Parsers for various language constructs
-
- // Parses the "syntax = \"proto2\";" line at the top of the file. Returns
- // false if it failed to parse or if the syntax identifier was not
- // recognized.
- bool ParseSyntaxIdentifier(const LocationRecorder& parent);
-
- // These methods parse various individual bits of code. They return
- // false if they completely fail to parse the construct. In this case,
- // it is probably necessary to skip the rest of the statement to recover.
- // However, if these methods return true, it does NOT mean that there
- // were no errors; only that there were no *syntax* errors. For instance,
- // if a service method is defined using proper syntax but uses a primitive
- // type as its input or output, ParseMethodField() still returns true
- // and only reports the error by calling AddError(). In practice, this
- // makes logic much simpler for the caller.
-
- // Parse a top-level message, enum, service, etc.
- bool ParseTopLevelStatement(FileDescriptorProto* file,
- const LocationRecorder& root_location);
-
- // Parse various language high-level language construrcts.
- bool ParseMessageDefinition(DescriptorProto* message,
- const LocationRecorder& message_location,
- const FileDescriptorProto* containing_file);
- bool ParseEnumDefinition(EnumDescriptorProto* enum_type,
- const LocationRecorder& enum_location,
- const FileDescriptorProto* containing_file);
- bool ParseServiceDefinition(ServiceDescriptorProto* service,
- const LocationRecorder& service_location,
- const FileDescriptorProto* containing_file);
- bool ParsePackage(FileDescriptorProto* file,
- const LocationRecorder& root_location,
- const FileDescriptorProto* containing_file);
+ };
+
+ // =================================================================
+ // Parsers for various language constructs
+
+ // Parses the "syntax = \"proto2\";" line at the top of the file. Returns
+ // false if it failed to parse or if the syntax identifier was not
+ // recognized.
+ bool ParseSyntaxIdentifier(const LocationRecorder& parent);
+
+ // These methods parse various individual bits of code. They return
+ // false if they completely fail to parse the construct. In this case,
+ // it is probably necessary to skip the rest of the statement to recover.
+ // However, if these methods return true, it does NOT mean that there
+ // were no errors; only that there were no *syntax* errors. For instance,
+ // if a service method is defined using proper syntax but uses a primitive
+ // type as its input or output, ParseMethodField() still returns true
+ // and only reports the error by calling AddError(). In practice, this
+ // makes logic much simpler for the caller.
+
+ // Parse a top-level message, enum, service, etc.
+ bool ParseTopLevelStatement(FileDescriptorProto* file,
+ const LocationRecorder& root_location);
+
+ // Parse various language high-level language construrcts.
+ bool ParseMessageDefinition(DescriptorProto* message,
+ const LocationRecorder& message_location,
+ const FileDescriptorProto* containing_file);
+ bool ParseEnumDefinition(EnumDescriptorProto* enum_type,
+ const LocationRecorder& enum_location,
+ const FileDescriptorProto* containing_file);
+ bool ParseServiceDefinition(ServiceDescriptorProto* service,
+ const LocationRecorder& service_location,
+ const FileDescriptorProto* containing_file);
+ bool ParsePackage(FileDescriptorProto* file,
+ const LocationRecorder& root_location,
+ const FileDescriptorProto* containing_file);
bool ParseImport(RepeatedPtrField<TProtoStringType>* dependency,
RepeatedField<int32_t>* public_dependency,
RepeatedField<int32_t>* weak_dependency,
- const LocationRecorder& root_location,
- const FileDescriptorProto* containing_file);
-
- // These methods parse the contents of a message, enum, or service type and
- // add them to the given object. They consume the entire block including
- // the beginning and ending brace.
- bool ParseMessageBlock(DescriptorProto* message,
- const LocationRecorder& message_location,
- const FileDescriptorProto* containing_file);
- bool ParseEnumBlock(EnumDescriptorProto* enum_type,
- const LocationRecorder& enum_location,
- const FileDescriptorProto* containing_file);
- bool ParseServiceBlock(ServiceDescriptorProto* service,
- const LocationRecorder& service_location,
- const FileDescriptorProto* containing_file);
-
- // Parse one statement within a message, enum, or service block, including
- // final semicolon.
- bool ParseMessageStatement(DescriptorProto* message,
- const LocationRecorder& message_location,
- const FileDescriptorProto* containing_file);
- bool ParseEnumStatement(EnumDescriptorProto* message,
- const LocationRecorder& enum_location,
- const FileDescriptorProto* containing_file);
- bool ParseServiceStatement(ServiceDescriptorProto* message,
- const LocationRecorder& service_location,
- const FileDescriptorProto* containing_file);
-
- // Parse a field of a message. If the field is a group, its type will be
- // added to "messages".
- //
- // parent_location and location_field_number_for_nested_type are needed when
- // parsing groups -- we need to generate a nested message type within the
- // parent and record its location accordingly. Since the parent could be
- // either a FileDescriptorProto or a DescriptorProto, we must pass in the
- // correct field number to use.
- bool ParseMessageField(FieldDescriptorProto* field,
- RepeatedPtrField<DescriptorProto>* messages,
- const LocationRecorder& parent_location,
- int location_field_number_for_nested_type,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
-
- // Like ParseMessageField() but expects the label has already been filled in
- // by the caller.
- bool ParseMessageFieldNoLabel(FieldDescriptorProto* field,
- RepeatedPtrField<DescriptorProto>* messages,
- const LocationRecorder& parent_location,
- int location_field_number_for_nested_type,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
-
- // Parse an "extensions" declaration.
- bool ParseExtensions(DescriptorProto* message,
- const LocationRecorder& extensions_location,
- const FileDescriptorProto* containing_file);
-
- // Parse a "reserved" declaration.
- bool ParseReserved(DescriptorProto* message,
- const LocationRecorder& message_location);
- bool ParseReservedNames(DescriptorProto* message,
- const LocationRecorder& parent_location);
- bool ParseReservedNumbers(DescriptorProto* message,
- const LocationRecorder& parent_location);
+ const LocationRecorder& root_location,
+ const FileDescriptorProto* containing_file);
+
+ // These methods parse the contents of a message, enum, or service type and
+ // add them to the given object. They consume the entire block including
+ // the beginning and ending brace.
+ bool ParseMessageBlock(DescriptorProto* message,
+ const LocationRecorder& message_location,
+ const FileDescriptorProto* containing_file);
+ bool ParseEnumBlock(EnumDescriptorProto* enum_type,
+ const LocationRecorder& enum_location,
+ const FileDescriptorProto* containing_file);
+ bool ParseServiceBlock(ServiceDescriptorProto* service,
+ const LocationRecorder& service_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse one statement within a message, enum, or service block, including
+ // final semicolon.
+ bool ParseMessageStatement(DescriptorProto* message,
+ const LocationRecorder& message_location,
+ const FileDescriptorProto* containing_file);
+ bool ParseEnumStatement(EnumDescriptorProto* message,
+ const LocationRecorder& enum_location,
+ const FileDescriptorProto* containing_file);
+ bool ParseServiceStatement(ServiceDescriptorProto* message,
+ const LocationRecorder& service_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse a field of a message. If the field is a group, its type will be
+ // added to "messages".
+ //
+ // parent_location and location_field_number_for_nested_type are needed when
+ // parsing groups -- we need to generate a nested message type within the
+ // parent and record its location accordingly. Since the parent could be
+ // either a FileDescriptorProto or a DescriptorProto, we must pass in the
+ // correct field number to use.
+ bool ParseMessageField(FieldDescriptorProto* field,
+ RepeatedPtrField<DescriptorProto>* messages,
+ const LocationRecorder& parent_location,
+ int location_field_number_for_nested_type,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file);
+
+ // Like ParseMessageField() but expects the label has already been filled in
+ // by the caller.
+ bool ParseMessageFieldNoLabel(FieldDescriptorProto* field,
+ RepeatedPtrField<DescriptorProto>* messages,
+ const LocationRecorder& parent_location,
+ int location_field_number_for_nested_type,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse an "extensions" declaration.
+ bool ParseExtensions(DescriptorProto* message,
+ const LocationRecorder& extensions_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse a "reserved" declaration.
+ bool ParseReserved(DescriptorProto* message,
+ const LocationRecorder& message_location);
+ bool ParseReservedNames(DescriptorProto* message,
+ const LocationRecorder& parent_location);
+ bool ParseReservedNumbers(DescriptorProto* message,
+ const LocationRecorder& parent_location);
bool ParseReserved(EnumDescriptorProto* message,
const LocationRecorder& message_location);
bool ParseReservedNames(EnumDescriptorProto* message,
const LocationRecorder& parent_location);
bool ParseReservedNumbers(EnumDescriptorProto* message,
const LocationRecorder& parent_location);
-
- // Parse an "extend" declaration. (See also comments for
- // ParseMessageField().)
- bool ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
- RepeatedPtrField<DescriptorProto>* messages,
- const LocationRecorder& parent_location,
- int location_field_number_for_nested_type,
- const LocationRecorder& extend_location,
- const FileDescriptorProto* containing_file);
-
- // Parse a "oneof" declaration. The caller is responsible for setting
- // oneof_decl->label() since it will have had to parse the label before it
- // knew it was parsing a oneof.
- bool ParseOneof(OneofDescriptorProto* oneof_decl,
+
+ // Parse an "extend" declaration. (See also comments for
+ // ParseMessageField().)
+ bool ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,
+ RepeatedPtrField<DescriptorProto>* messages,
+ const LocationRecorder& parent_location,
+ int location_field_number_for_nested_type,
+ const LocationRecorder& extend_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse a "oneof" declaration. The caller is responsible for setting
+ // oneof_decl->label() since it will have had to parse the label before it
+ // knew it was parsing a oneof.
+ bool ParseOneof(OneofDescriptorProto* oneof_decl,
DescriptorProto* containing_type, int oneof_index,
- const LocationRecorder& oneof_location,
- const LocationRecorder& containing_type_location,
- const FileDescriptorProto* containing_file);
-
- // Parse a single enum value within an enum block.
- bool ParseEnumConstant(EnumValueDescriptorProto* enum_value,
- const LocationRecorder& enum_value_location,
- const FileDescriptorProto* containing_file);
-
- // Parse enum constant options, i.e. the list in square brackets at the end
- // of the enum constant value definition.
- bool ParseEnumConstantOptions(EnumValueDescriptorProto* value,
- const LocationRecorder& enum_value_location,
- const FileDescriptorProto* containing_file);
-
- // Parse a single method within a service definition.
- bool ParseServiceMethod(MethodDescriptorProto* method,
- const LocationRecorder& method_location,
- const FileDescriptorProto* containing_file);
-
-
- // Parse options of a single method or stream.
- bool ParseMethodOptions(const LocationRecorder& parent_location,
- const FileDescriptorProto* containing_file,
- const int optionsFieldNumber,
- Message* mutable_options);
-
- // Parse "required", "optional", or "repeated" and fill in "label"
- // with the value. Returns true if such a label is consumed.
- bool ParseLabel(FieldDescriptorProto::Label* label,
+ const LocationRecorder& oneof_location,
+ const LocationRecorder& containing_type_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse a single enum value within an enum block.
+ bool ParseEnumConstant(EnumValueDescriptorProto* enum_value,
+ const LocationRecorder& enum_value_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse enum constant options, i.e. the list in square brackets at the end
+ // of the enum constant value definition.
+ bool ParseEnumConstantOptions(EnumValueDescriptorProto* value,
+ const LocationRecorder& enum_value_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse a single method within a service definition.
+ bool ParseServiceMethod(MethodDescriptorProto* method,
+ const LocationRecorder& method_location,
+ const FileDescriptorProto* containing_file);
+
+
+ // Parse options of a single method or stream.
+ bool ParseMethodOptions(const LocationRecorder& parent_location,
+ const FileDescriptorProto* containing_file,
+ const int optionsFieldNumber,
+ Message* mutable_options);
+
+ // Parse "required", "optional", or "repeated" and fill in "label"
+ // with the value. Returns true if such a label is consumed.
+ bool ParseLabel(FieldDescriptorProto::Label* label,
const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
-
- // Parse a type name and fill in "type" (if it is a primitive) or
- // "type_name" (if it is not) with the type parsed.
+ const FileDescriptorProto* containing_file);
+
+ // Parse a type name and fill in "type" (if it is a primitive) or
+ // "type_name" (if it is not) with the type parsed.
bool ParseType(FieldDescriptorProto::Type* type, TProtoStringType* type_name);
- // Parse a user-defined type and fill in "type_name" with the name.
- // If a primitive type is named, it is treated as an error.
+ // Parse a user-defined type and fill in "type_name" with the name.
+ // If a primitive type is named, it is treated as an error.
bool ParseUserDefinedType(TProtoStringType* type_name);
-
- // Parses field options, i.e. the stuff in square brackets at the end
- // of a field definition. Also parses default value.
- bool ParseFieldOptions(FieldDescriptorProto* field,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
-
- // Parse the "default" option. This needs special handling because its
- // type is the field's type.
- bool ParseDefaultAssignment(FieldDescriptorProto* field,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
-
- bool ParseJsonName(FieldDescriptorProto* field,
- const LocationRecorder& field_location,
- const FileDescriptorProto* containing_file);
-
- enum OptionStyle {
- OPTION_ASSIGNMENT, // just "name = value"
- OPTION_STATEMENT // "option name = value;"
- };
-
- // Parse a single option name/value pair, e.g. "ctype = CORD". The name
- // identifies a field of the given Message, and the value of that field
- // is set to the parsed value.
+
+ // Parses field options, i.e. the stuff in square brackets at the end
+ // of a field definition. Also parses default value.
+ bool ParseFieldOptions(FieldDescriptorProto* field,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parse the "default" option. This needs special handling because its
+ // type is the field's type.
+ bool ParseDefaultAssignment(FieldDescriptorProto* field,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file);
+
+ bool ParseJsonName(FieldDescriptorProto* field,
+ const LocationRecorder& field_location,
+ const FileDescriptorProto* containing_file);
+
+ enum OptionStyle {
+ OPTION_ASSIGNMENT, // just "name = value"
+ OPTION_STATEMENT // "option name = value;"
+ };
+
+ // Parse a single option name/value pair, e.g. "ctype = CORD". The name
+ // identifies a field of the given Message, and the value of that field
+ // is set to the parsed value.
bool ParseOption(Message* options, const LocationRecorder& options_location,
- const FileDescriptorProto* containing_file,
- OptionStyle style);
-
- // Parses a single part of a multipart option name. A multipart name consists
- // of names separated by dots. Each name is either an identifier or a series
- // of identifiers separated by dots and enclosed in parentheses. E.g.,
- // "foo.(bar.baz).qux".
- bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option,
- const LocationRecorder& part_location,
- const FileDescriptorProto* containing_file);
-
- // Parses a string surrounded by balanced braces. Strips off the outer
- // braces and stores the enclosed string in *value.
- // E.g.,
- // { foo } *value gets 'foo'
- // { foo { bar: box } } *value gets 'foo { bar: box }'
- // {} *value gets ''
- //
- // REQUIRES: LookingAt("{")
- // When finished successfully, we are looking at the first token past
- // the ending brace.
+ const FileDescriptorProto* containing_file,
+ OptionStyle style);
+
+ // Parses a single part of a multipart option name. A multipart name consists
+ // of names separated by dots. Each name is either an identifier or a series
+ // of identifiers separated by dots and enclosed in parentheses. E.g.,
+ // "foo.(bar.baz).qux".
+ bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option,
+ const LocationRecorder& part_location,
+ const FileDescriptorProto* containing_file);
+
+ // Parses a string surrounded by balanced braces. Strips off the outer
+ // braces and stores the enclosed string in *value.
+ // E.g.,
+ // { foo } *value gets 'foo'
+ // { foo { bar: box } } *value gets 'foo { bar: box }'
+ // {} *value gets ''
+ //
+ // REQUIRES: LookingAt("{")
+ // When finished successfully, we are looking at the first token past
+ // the ending brace.
bool ParseUninterpretedBlock(TProtoStringType* value);
-
- struct MapField {
- // Whether the field is a map field.
- bool is_map_field;
- // The types of the key and value if they are primitive types.
- FieldDescriptorProto::Type key_type;
- FieldDescriptorProto::Type value_type;
- // Or the type names string if the types are customized types.
+
+ struct MapField {
+ // Whether the field is a map field.
+ bool is_map_field;
+ // The types of the key and value if they are primitive types.
+ FieldDescriptorProto::Type key_type;
+ FieldDescriptorProto::Type value_type;
+ // Or the type names string if the types are customized types.
TProtoStringType key_type_name;
TProtoStringType value_type_name;
-
- MapField() : is_map_field(false) {}
- };
- // Desugar the map syntax to generate a nested map entry message.
- void GenerateMapEntry(const MapField& map_field, FieldDescriptorProto* field,
- RepeatedPtrField<DescriptorProto>* messages);
-
- // Whether fields without label default to optional fields.
- bool DefaultToOptionalFields() const {
- return syntax_identifier_ == "proto3";
- }
-
- bool ValidateEnum(const EnumDescriptorProto* proto);
-
- // =================================================================
-
- io::Tokenizer* input_;
- io::ErrorCollector* error_collector_;
- SourceCodeInfo* source_code_info_;
- SourceLocationTable* source_location_table_; // legacy
- bool had_errors_;
- bool require_syntax_identifier_;
- bool stop_after_syntax_identifier_;
+
+ MapField() : is_map_field(false) {}
+ };
+ // Desugar the map syntax to generate a nested map entry message.
+ void GenerateMapEntry(const MapField& map_field, FieldDescriptorProto* field,
+ RepeatedPtrField<DescriptorProto>* messages);
+
+ // Whether fields without label default to optional fields.
+ bool DefaultToOptionalFields() const {
+ return syntax_identifier_ == "proto3";
+ }
+
+ bool ValidateEnum(const EnumDescriptorProto* proto);
+
+ // =================================================================
+
+ io::Tokenizer* input_;
+ io::ErrorCollector* error_collector_;
+ SourceCodeInfo* source_code_info_;
+ SourceLocationTable* source_location_table_; // legacy
+ bool had_errors_;
+ bool require_syntax_identifier_;
+ bool stop_after_syntax_identifier_;
TProtoStringType syntax_identifier_;
-
- // Leading doc comments for the next declaration. These are not complete
- // yet; use ConsumeEndOfDeclaration() to get the complete comments.
+
+ // Leading doc comments for the next declaration. These are not complete
+ // yet; use ConsumeEndOfDeclaration() to get the complete comments.
TProtoStringType upcoming_doc_comments_;
-
- // Detached comments are not connected to any syntax entities. Elements in
- // this vector are paragraphs of comments separated by empty lines. The
- // detached comments will be put into the leading_detached_comments field for
- // the next element (See SourceCodeInfo.Location in descriptor.proto), when
- // ConsumeEndOfDeclaration() is called.
+
+ // Detached comments are not connected to any syntax entities. Elements in
+ // this vector are paragraphs of comments separated by empty lines. The
+ // detached comments will be put into the leading_detached_comments field for
+ // the next element (See SourceCodeInfo.Location in descriptor.proto), when
+ // ConsumeEndOfDeclaration() is called.
std::vector<TProtoStringType> upcoming_detached_comments_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);
-};
-
-// A table mapping (descriptor, ErrorLocation) pairs -- as reported by
-// DescriptorPool when validating descriptors -- to line and column numbers
-// within the original source code.
-//
-// This is semi-obsolete: FileDescriptorProto.source_code_info now contains
-// far more complete information about source locations. However, as of this
-// writing you still need to use SourceLocationTable when integrating with
-// DescriptorPool.
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);
+};
+
+// A table mapping (descriptor, ErrorLocation) pairs -- as reported by
+// DescriptorPool when validating descriptors -- to line and column numbers
+// within the original source code.
+//
+// This is semi-obsolete: FileDescriptorProto.source_code_info now contains
+// far more complete information about source locations. However, as of this
+// writing you still need to use SourceLocationTable when integrating with
+// DescriptorPool.
class PROTOBUF_EXPORT SourceLocationTable {
- public:
- SourceLocationTable();
- ~SourceLocationTable();
-
- // Finds the precise location of the given error and fills in *line and
- // *column with the line and column numbers. If not found, sets *line to
- // -1 and *column to 0 (since line = -1 is used to mean "error has no exact
- // location" in the ErrorCollector interface). Returns true if found, false
- // otherwise.
- bool Find(const Message* descriptor,
+ public:
+ SourceLocationTable();
+ ~SourceLocationTable();
+
+ // Finds the precise location of the given error and fills in *line and
+ // *column with the line and column numbers. If not found, sets *line to
+ // -1 and *column to 0 (since line = -1 is used to mean "error has no exact
+ // location" in the ErrorCollector interface). Returns true if found, false
+ // otherwise.
+ bool Find(const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, int* line,
int* column) const;
bool FindImport(const Message* descriptor, const TProtoStringType& name, int* line,
int* column) const;
-
- // Adds a location to the table.
- void Add(const Message* descriptor,
+
+ // Adds a location to the table.
+ void Add(const Message* descriptor,
DescriptorPool::ErrorCollector::ErrorLocation location, int line,
int column);
void AddImport(const Message* descriptor, const TProtoStringType& name, int line,
int column);
-
- // Clears the contents of the table.
- void Clear();
-
- private:
+
+ // Clears the contents of the table.
+ void Clear();
+
+ private:
typedef std::map<
std::pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>,
std::pair<int, int> >
LocationMap;
- LocationMap location_map_;
+ LocationMap location_map_;
std::map<std::pair<const Message*, TProtoStringType>, std::pair<int, int> >
import_location_map_;
-};
-
-} // namespace compiler
-} // namespace protobuf
+};
+
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_PARSER_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
index 665fe57f5b..d05aef210a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc
@@ -1,46 +1,46 @@
-// 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: kenton@google.com (Kenton Varda)
-
+// 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: kenton@google.com (Kenton Varda)
+
#include <google/protobuf/compiler/plugin.h>
-
-#include <iostream>
-#include <set>
-
-#ifdef _WIN32
-#include <fcntl.h>
-#else
-#include <unistd.h>
-#endif
-
+
+#include <iostream>
+#include <set>
+
+#ifdef _WIN32
+#include <fcntl.h>
+#else
+#include <unistd.h>
+#endif
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/plugin.pb.h>
@@ -48,44 +48,44 @@
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/io_win32.h>
-
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-
+
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
#if defined(_WIN32)
// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import
// them like we do below.
using google::protobuf::io::win32::setmode;
#endif
-class GeneratorResponseContext : public GeneratorContext {
- public:
+class GeneratorResponseContext : public GeneratorContext {
+ public:
GeneratorResponseContext(
const Version& compiler_version, CodeGeneratorResponse* response,
const std::vector<const FileDescriptor*>& parsed_files)
: compiler_version_(compiler_version),
response_(response),
- parsed_files_(parsed_files) {}
- virtual ~GeneratorResponseContext() {}
-
- // implements GeneratorContext --------------------------------------
-
+ parsed_files_(parsed_files) {}
+ virtual ~GeneratorResponseContext() {}
+
+ // implements GeneratorContext --------------------------------------
+
virtual io::ZeroCopyOutputStream* Open(const TProtoStringType& filename) {
- CodeGeneratorResponse::File* file = response_->add_file();
- file->set_name(filename);
- return new io::StringOutputStream(file->mutable_content());
- }
-
- virtual io::ZeroCopyOutputStream* OpenForInsert(
+ CodeGeneratorResponse::File* file = response_->add_file();
+ file->set_name(filename);
+ return new io::StringOutputStream(file->mutable_content());
+ }
+
+ virtual io::ZeroCopyOutputStream* OpenForInsert(
const TProtoStringType& filename, const TProtoStringType& insertion_point) {
- CodeGeneratorResponse::File* file = response_->add_file();
- file->set_name(filename);
- file->set_insertion_point(insertion_point);
- return new io::StringOutputStream(file->mutable_content());
- }
-
+ CodeGeneratorResponse::File* file = response_->add_file();
+ file->set_name(filename);
+ file->set_insertion_point(insertion_point);
+ return new io::StringOutputStream(file->mutable_content());
+ }
+
virtual io::ZeroCopyOutputStream* OpenForInsertWithGeneratedCodeInfo(
const TProtoStringType& filename, const TProtoStringType& insertion_point,
const google::protobuf::GeneratedCodeInfo& info) {
@@ -97,102 +97,102 @@ class GeneratorResponseContext : public GeneratorContext {
}
void ListParsedFiles(std::vector<const FileDescriptor*>* output) {
- *output = parsed_files_;
- }
-
+ *output = parsed_files_;
+ }
+
void GetCompilerVersion(Version* version) const {
*version = compiler_version_;
}
- private:
+ private:
Version compiler_version_;
- CodeGeneratorResponse* response_;
+ CodeGeneratorResponse* response_;
const std::vector<const FileDescriptor*>& parsed_files_;
-};
-
-bool GenerateCode(const CodeGeneratorRequest& request,
+};
+
+bool GenerateCode(const CodeGeneratorRequest& request,
const CodeGenerator& generator,
CodeGeneratorResponse* response, TProtoStringType* error_msg) {
- DescriptorPool pool;
- for (int i = 0; i < request.proto_file_size(); i++) {
- const FileDescriptor* file = pool.BuildFile(request.proto_file(i));
- if (file == NULL) {
- // BuildFile() already wrote an error message.
- return false;
- }
- }
-
+ DescriptorPool pool;
+ for (int i = 0; i < request.proto_file_size(); i++) {
+ const FileDescriptor* file = pool.BuildFile(request.proto_file(i));
+ if (file == NULL) {
+ // BuildFile() already wrote an error message.
+ return false;
+ }
+ }
+
std::vector<const FileDescriptor*> parsed_files;
- for (int i = 0; i < request.file_to_generate_size(); i++) {
- parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i)));
- if (parsed_files.back() == NULL) {
+ for (int i = 0; i < request.file_to_generate_size(); i++) {
+ parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i)));
+ if (parsed_files.back() == NULL) {
*error_msg =
"protoc asked plugin to generate a file but "
"did not provide a descriptor for the file: " +
request.file_to_generate(i);
- return false;
- }
- }
-
+ return false;
+ }
+ }
+
GeneratorResponseContext context(request.compiler_version(), response,
parsed_files);
-
+
TProtoStringType error;
bool succeeded = generator.GenerateAll(parsed_files, request.parameter(),
&context, &error);
-
+
response->set_supported_features(generator.GetSupportedFeatures());
if (!succeeded && error.empty()) {
error =
"Code generator returned false but provided no error "
"description.";
- }
+ }
if (!error.empty()) {
response->set_error(error);
}
-
- return true;
-}
-
-int PluginMain(int argc, char* argv[], const CodeGenerator* generator) {
-
- if (argc > 1) {
- std::cerr << argv[0] << ": Unknown option: " << argv[1] << std::endl;
- return 1;
- }
-
-#ifdef _WIN32
+
+ return true;
+}
+
+int PluginMain(int argc, char* argv[], const CodeGenerator* generator) {
+
+ if (argc > 1) {
+ std::cerr << argv[0] << ": Unknown option: " << argv[1] << std::endl;
+ return 1;
+ }
+
+#ifdef _WIN32
setmode(STDIN_FILENO, _O_BINARY);
setmode(STDOUT_FILENO, _O_BINARY);
-#endif
-
- CodeGeneratorRequest request;
- if (!request.ParseFromFileDescriptor(STDIN_FILENO)) {
- std::cerr << argv[0] << ": protoc sent unparseable request to plugin."
- << std::endl;
- return 1;
- }
-
+#endif
+
+ CodeGeneratorRequest request;
+ if (!request.ParseFromFileDescriptor(STDIN_FILENO)) {
+ std::cerr << argv[0] << ": protoc sent unparseable request to plugin."
+ << std::endl;
+ return 1;
+ }
+
TProtoStringType error_msg;
- CodeGeneratorResponse response;
-
- if (GenerateCode(request, *generator, &response, &error_msg)) {
- if (!response.SerializeToFileDescriptor(STDOUT_FILENO)) {
- std::cerr << argv[0] << ": Error writing to stdout." << std::endl;
- return 1;
- }
- } else {
- if (!error_msg.empty()) {
- std::cerr << argv[0] << ": " << error_msg << std::endl;
- }
- return 1;
- }
-
- return 0;
-}
-
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ CodeGeneratorResponse response;
+
+ if (GenerateCode(request, *generator, &response, &error_msg)) {
+ if (!response.SerializeToFileDescriptor(STDOUT_FILENO)) {
+ std::cerr << argv[0] << ": Error writing to stdout." << std::endl;
+ return 1;
+ }
+ } else {
+ if (!error_msg.empty()) {
+ std::cerr << argv[0] << ": " << error_msg << std::endl;
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
index cb7f67fbbe..13e98f02c3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.h
@@ -1,95 +1,95 @@
-// 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: kenton@google.com (Kenton Varda)
-//
-// Front-end for protoc code generator plugins written in C++.
-//
-// To implement a protoc plugin in C++, simply write an implementation of
-// CodeGenerator, then create a main() function like:
-// int main(int argc, char* argv[]) {
-// MyCodeGenerator generator;
-// return google::protobuf::compiler::PluginMain(argc, argv, &generator);
-// }
-// You must link your plugin against libprotobuf and libprotoc.
-//
-// The core part of PluginMain is to invoke the given CodeGenerator on a
-// CodeGeneratorRequest to generate a CodeGeneratorResponse. This part is
-// abstracted out and made into function GenerateCode so that it can be reused,
-// for example, to implement a variant of PluginMain that does some
-// preprocessing on the input CodeGeneratorRequest before feeding the request
-// to the given code generator.
-//
-// To get protoc to use the plugin, do one of the following:
-// * Place the plugin binary somewhere in the PATH and give it the name
-// "protoc-gen-NAME" (replacing "NAME" with the name of your plugin). If you
-// then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace
-// "NAME" with your plugin's name), protoc will invoke your plugin to generate
-// the output, which will be placed in OUT_DIR.
-// * Place the plugin binary anywhere, with any name, and pass the --plugin
-// parameter to protoc to direct it to your plugin like so:
-// protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR
-// On Windows, make sure to include the .exe suffix:
-// protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
-#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_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: kenton@google.com (Kenton Varda)
+//
+// Front-end for protoc code generator plugins written in C++.
+//
+// To implement a protoc plugin in C++, simply write an implementation of
+// CodeGenerator, then create a main() function like:
+// int main(int argc, char* argv[]) {
+// MyCodeGenerator generator;
+// return google::protobuf::compiler::PluginMain(argc, argv, &generator);
+// }
+// You must link your plugin against libprotobuf and libprotoc.
+//
+// The core part of PluginMain is to invoke the given CodeGenerator on a
+// CodeGeneratorRequest to generate a CodeGeneratorResponse. This part is
+// abstracted out and made into function GenerateCode so that it can be reused,
+// for example, to implement a variant of PluginMain that does some
+// preprocessing on the input CodeGeneratorRequest before feeding the request
+// to the given code generator.
+//
+// To get protoc to use the plugin, do one of the following:
+// * Place the plugin binary somewhere in the PATH and give it the name
+// "protoc-gen-NAME" (replacing "NAME" with the name of your plugin). If you
+// then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace
+// "NAME" with your plugin's name), protoc will invoke your plugin to generate
+// the output, which will be placed in OUT_DIR.
+// * Place the plugin binary anywhere, with any name, and pass the --plugin
+// parameter to protoc to direct it to your plugin like so:
+// protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR
+// On Windows, make sure to include the .exe suffix:
+// protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
+#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
+
#include <string>
#include <google/protobuf/stubs/port.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-namespace compiler {
-
+namespace google {
+namespace protobuf {
+namespace compiler {
+
class CodeGenerator; // code_generator.h
-class CodeGeneratorRequest;
-class CodeGeneratorResponse;
-
-// Implements main() for a protoc plugin exposing the given code generator.
+class CodeGeneratorRequest;
+class CodeGeneratorResponse;
+
+// Implements main() for a protoc plugin exposing the given code generator.
PROTOC_EXPORT int PluginMain(int argc, char* argv[],
const CodeGenerator* generator);
-
-// Generates code using the given code generator. Returns true if the code
+
+// Generates code using the given code generator. Returns true if the code
// generation is successful. If the code generation fails, error_msg may be
-// populated to describe the failure cause.
-bool GenerateCode(const CodeGeneratorRequest& request,
+// populated to describe the failure cause.
+bool GenerateCode(const CodeGeneratorRequest& request,
const CodeGenerator& generator,
CodeGeneratorResponse* response, TProtoStringType* error_msg);
-
-} // namespace compiler
-} // namespace protobuf
+
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
index 4fdddb5c07..f66f854fe9 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc
@@ -1,10 +1,10 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: google/protobuf/compiler/plugin.proto
-
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: google/protobuf/compiler/plugin.proto
+
#include <google/protobuf/compiler/plugin.pb.h>
-
-#include <algorithm>
-
+
+#include <algorithm>
+
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
@@ -12,12 +12,12 @@
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
-// @@protoc_insertion_point(includes)
+// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
-
+
PROTOBUF_PRAGMA_INIT_SEG
PROTOBUF_NAMESPACE_OPEN
-namespace compiler {
+namespace compiler {
constexpr Version::Version(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: suffix_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
@@ -141,7 +141,7 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB
{ 26, 35, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)},
{ 39, 47, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)},
};
-
+
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_),
@@ -192,7 +192,7 @@ namespace compiler {
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor() {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto);
return file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0];
-}
+}
bool CodeGeneratorResponse_Feature_IsValid(int value) {
switch (value) {
case 0:
@@ -201,8 +201,8 @@ bool CodeGeneratorResponse_Feature_IsValid(int value) {
default:
return false;
}
-}
-
+}
+
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900)
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_NONE;
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::FEATURE_PROTO3_OPTIONAL;
@@ -210,7 +210,7 @@ constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MIN;
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MAX;
constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900)
-
+
// ===================================================================
class Version::_Internal {
@@ -218,7 +218,7 @@ class Version::_Internal {
using HasBits = decltype(std::declval<Version>()._has_bits_);
static void set_has_major(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
- }
+ }
static void set_has_minor(HasBits* has_bits) {
(*has_bits)[0] |= 4u;
}
@@ -229,7 +229,7 @@ class Version::_Internal {
(*has_bits)[0] |= 1u;
}
};
-
+
Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
@@ -558,13 +558,13 @@ CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
file_to_generate_(arena),
proto_file_(arena) {
- SharedCtor();
+ SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorRequest)
-}
-CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
+}
+CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_),
file_to_generate_(from.file_to_generate_),
@@ -580,45 +580,45 @@ CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)
} else {
compiler_version_ = nullptr;
}
- // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest)
-}
-
-void CodeGeneratorRequest::SharedCtor() {
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest)
+}
+
+void CodeGeneratorRequest::SharedCtor() {
parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
compiler_version_ = nullptr;
-}
-
-CodeGeneratorRequest::~CodeGeneratorRequest() {
- // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest)
+}
+
+CodeGeneratorRequest::~CodeGeneratorRequest() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest)
if (GetArenaForAllocation() != nullptr) return;
- SharedDtor();
+ SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
-}
-
+}
+
inline void CodeGeneratorRequest::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete compiler_version_;
-}
-
+}
+
void CodeGeneratorRequest::ArenaDtor(void* object) {
CodeGeneratorRequest* _this = reinterpret_cast< CodeGeneratorRequest* >(object);
(void)_this;
-}
+}
void CodeGeneratorRequest::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
+}
void CodeGeneratorRequest::SetCachedSize(int size) const {
_cached_size_.Set(size);
-}
-
-void CodeGeneratorRequest::Clear() {
-// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest)
+}
+
+void CodeGeneratorRequest::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- file_to_generate_.Clear();
- proto_file_.Clear();
+ file_to_generate_.Clear();
+ proto_file_.Clear();
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
@@ -631,8 +631,8 @@ void CodeGeneratorRequest::Clear() {
}
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
-}
-
+}
+
const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
@@ -640,7 +640,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
- // repeated string file_to_generate = 1;
+ // repeated string file_to_generate = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
@@ -656,7 +656,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
- // optional string parameter = 2;
+ // optional string parameter = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
auto str = _internal_mutable_parameter();
@@ -674,7 +674,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM
CHK_(ptr);
} else goto handle_unusual;
continue;
- // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
+ // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
case 15:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) {
ptr -= 1;
@@ -686,57 +686,57 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr));
} else goto handle_unusual;
continue;
- default: {
- handle_unusual:
+ default: {
+ handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
- goto success;
- }
+ goto success;
+ }
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
- }
+ }
} // switch
} // while
-success:
+success:
_has_bits_.Or(has_bits);
return ptr;
-failure:
+failure:
ptr = nullptr;
goto success;
#undef CHK_
-}
-
+}
+
::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorRequest::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
- // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
+ // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
- // repeated string file_to_generate = 1;
+ // repeated string file_to_generate = 1;
for (int i = 0, n = this->_internal_file_to_generate_size(); i < n; i++) {
const auto& s = this->_internal_file_to_generate(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
s.data(), static_cast<int>(s.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
+ "google.protobuf.compiler.CodeGeneratorRequest.file_to_generate");
target = stream->WriteString(1, s, target);
- }
-
+ }
+
cached_has_bits = _has_bits_[0];
- // optional string parameter = 2;
+ // optional string parameter = 2;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_parameter().data(), static_cast<int>(this->_internal_parameter().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorRequest.parameter");
+ "google.protobuf.compiler.CodeGeneratorRequest.parameter");
target = stream->WriteStringMaybeAliased(
2, this->_internal_parameter(), target);
- }
-
+ }
+
// optional .google.protobuf.compiler.Version compiler_version = 3;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
@@ -745,45 +745,45 @@ failure:
3, _Internal::compiler_version(this), target, stream);
}
- // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
+ // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_proto_file_size()); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(15, this->_internal_proto_file(i), target, stream);
- }
-
+ }
+
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
- }
- // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorRequest)
- return target;
-}
-
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorRequest)
+ return target;
+}
+
size_t CodeGeneratorRequest::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest)
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest)
size_t total_size = 0;
-
+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
- // repeated string file_to_generate = 1;
+ // repeated string file_to_generate = 1;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(file_to_generate_.size());
for (int i = 0, n = file_to_generate_.size(); i < n; i++) {
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
file_to_generate_.Get(i));
- }
-
- // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
+ }
+
+ // repeated .google.protobuf.FileDescriptorProto proto_file = 15;
total_size += 1UL * this->_internal_proto_file_size();
for (const auto& msg : this->proto_file_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
- }
-
+ }
+
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional string parameter = 2;
@@ -800,16 +800,16 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
*compiler_version_);
}
- }
+ }
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
- return total_size;
-}
-
+ return total_size;
+}
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorRequest::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
CodeGeneratorRequest::MergeImpl
@@ -820,42 +820,42 @@ void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<CodeGeneratorRequest *>(to)->MergeFrom(
static_cast<const CodeGeneratorRequest &>(from));
-}
-
+}
+
-void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
+void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
file_to_generate_.MergeFrom(from.file_to_generate_);
- proto_file_.MergeFrom(from.proto_file_);
+ proto_file_.MergeFrom(from.proto_file_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
_internal_set_parameter(from._internal_parameter());
- }
+ }
if (cached_has_bits & 0x00000002u) {
_internal_mutable_compiler_version()->PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom(from._internal_compiler_version());
}
- }
+ }
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
-}
-
-void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest)
- if (&from == this) return;
- Clear();
+}
+
+void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest)
+ if (&from == this) return;
+ Clear();
MergeFrom(from);
-}
-
-bool CodeGeneratorRequest::IsInitialized() const {
+}
+
+bool CodeGeneratorRequest::IsInitialized() const {
if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(proto_file_)) return false;
- return true;
-}
-
-void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
+ return true;
+}
+
+void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -867,22 +867,22 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
&other->parameter_, other->GetArenaForAllocation()
);
swap(compiler_version_, other->compiler_version_);
-}
-
+}
+
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]);
-}
-
+}
+
// ===================================================================
-
+
class CodeGeneratorResponse_File::_Internal {
public:
using HasBits = decltype(std::declval<CodeGeneratorResponse_File>()._has_bits_);
static void set_has_name(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
- }
+ }
static void set_has_insertion_point(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
@@ -894,25 +894,25 @@ class CodeGeneratorResponse_File::_Internal {
(*has_bits)[0] |= 8u;
}
};
-
+
const PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo&
CodeGeneratorResponse_File::_Internal::generated_code_info(const CodeGeneratorResponse_File* msg) {
return *msg->generated_code_info_;
-}
+}
void CodeGeneratorResponse_File::clear_generated_code_info() {
if (generated_code_info_ != nullptr) generated_code_info_->Clear();
_has_bits_[0] &= ~0x00000008u;
-}
+}
CodeGeneratorResponse_File::CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
- SharedCtor();
+ SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
-}
-CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)
+}
+CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
@@ -936,43 +936,43 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon
} else {
generated_code_info_ = nullptr;
}
- // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
-}
-
-void CodeGeneratorResponse_File::SharedCtor() {
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)
+}
+
+void CodeGeneratorResponse_File::SharedCtor() {
name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
generated_code_info_ = nullptr;
-}
-
-CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
- // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File)
+}
+
+CodeGeneratorResponse_File::~CodeGeneratorResponse_File() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File)
if (GetArenaForAllocation() != nullptr) return;
- SharedDtor();
+ SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
-}
-
+}
+
inline void CodeGeneratorResponse_File::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
insertion_point_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
content_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (this != internal_default_instance()) delete generated_code_info_;
-}
-
+}
+
void CodeGeneratorResponse_File::ArenaDtor(void* object) {
CodeGeneratorResponse_File* _this = reinterpret_cast< CodeGeneratorResponse_File* >(object);
(void)_this;
-}
+}
void CodeGeneratorResponse_File::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
+}
void CodeGeneratorResponse_File::SetCachedSize(int size) const {
_cached_size_.Set(size);
-}
-
-void CodeGeneratorResponse_File::Clear() {
-// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File)
+}
+
+void CodeGeneratorResponse_File::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -981,22 +981,22 @@ void CodeGeneratorResponse_File::Clear() {
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
name_.ClearNonDefaultToEmpty();
- }
+ }
if (cached_has_bits & 0x00000002u) {
insertion_point_.ClearNonDefaultToEmpty();
- }
+ }
if (cached_has_bits & 0x00000004u) {
content_.ClearNonDefaultToEmpty();
- }
+ }
if (cached_has_bits & 0x00000008u) {
GOOGLE_DCHECK(generated_code_info_ != nullptr);
generated_code_info_->Clear();
}
- }
+ }
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
-}
-
+}
+
const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
@@ -1004,7 +1004,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
- // optional string name = 1;
+ // optional string name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_name();
@@ -1015,7 +1015,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
CHK_(ptr);
} else goto handle_unusual;
continue;
- // optional string insertion_point = 2;
+ // optional string insertion_point = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
auto str = _internal_mutable_insertion_point();
@@ -1026,7 +1026,7 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
CHK_(ptr);
} else goto handle_unusual;
continue;
- // optional string content = 15;
+ // optional string content = 15;
case 15:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) {
auto str = _internal_mutable_content();
@@ -1044,30 +1044,30 @@ const char* CodeGeneratorResponse_File::_InternalParse(const char* ptr, ::PROTOB
CHK_(ptr);
} else goto handle_unusual;
continue;
- default: {
- handle_unusual:
+ default: {
+ handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
- goto success;
- }
+ goto success;
+ }
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
- }
+ }
} // switch
} // while
-success:
+success:
_has_bits_.Or(has_bits);
return ptr;
-failure:
+failure:
ptr = nullptr;
goto success;
#undef CHK_
-}
-
+}
+
::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse_File::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)
@@ -1075,83 +1075,83 @@ failure:
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
- // optional string name = 1;
+ // optional string name = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.File.name");
+ "google.protobuf.compiler.CodeGeneratorResponse.File.name");
target = stream->WriteStringMaybeAliased(
1, this->_internal_name(), target);
- }
-
- // optional string insertion_point = 2;
+ }
+
+ // optional string insertion_point = 2;
if (cached_has_bits & 0x00000002u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_insertion_point().data(), static_cast<int>(this->_internal_insertion_point().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
+ "google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point");
target = stream->WriteStringMaybeAliased(
2, this->_internal_insertion_point(), target);
- }
-
- // optional string content = 15;
+ }
+
+ // optional string content = 15;
if (cached_has_bits & 0x00000004u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_content().data(), static_cast<int>(this->_internal_content().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.File.content");
+ "google.protobuf.compiler.CodeGeneratorResponse.File.content");
target = stream->WriteStringMaybeAliased(
15, this->_internal_content(), target);
- }
-
+ }
+
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
if (cached_has_bits & 0x00000008u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(
16, _Internal::generated_code_info(this), target, stream);
- }
-
+ }
+
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
- }
- // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse.File)
- return target;
-}
-
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse.File)
+ return target;
+}
+
size_t CodeGeneratorResponse_File::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File)
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File)
size_t total_size = 0;
-
+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x0000000fu) {
- // optional string name = 1;
+ // optional string name = 1;
if (cached_has_bits & 0x00000001u) {
- total_size += 1 +
+ total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_name());
- }
-
- // optional string insertion_point = 2;
+ }
+
+ // optional string insertion_point = 2;
if (cached_has_bits & 0x00000002u) {
- total_size += 1 +
+ total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_insertion_point());
- }
-
- // optional string content = 15;
+ }
+
+ // optional string content = 15;
if (cached_has_bits & 0x00000004u) {
- total_size += 1 +
+ total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_content());
- }
-
+ }
+
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
if (cached_has_bits & 0x00000008u) {
total_size += 2 +
@@ -1159,16 +1159,16 @@ size_t CodeGeneratorResponse_File::ByteSizeLong() const {
*generated_code_info_);
}
- }
+ }
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
- return total_size;
-}
-
+ return total_size;
+}
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorResponse_File::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
CodeGeneratorResponse_File::MergeImpl
@@ -1179,11 +1179,11 @@ void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<CodeGeneratorResponse_File *>(to)->MergeFrom(
static_cast<const CodeGeneratorResponse_File &>(from));
-}
-
+}
+
-void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
+void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
@@ -1192,32 +1192,32 @@ void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& fro
if (cached_has_bits & 0x0000000fu) {
if (cached_has_bits & 0x00000001u) {
_internal_set_name(from._internal_name());
- }
+ }
if (cached_has_bits & 0x00000002u) {
_internal_set_insertion_point(from._internal_insertion_point());
- }
+ }
if (cached_has_bits & 0x00000004u) {
_internal_set_content(from._internal_content());
- }
+ }
if (cached_has_bits & 0x00000008u) {
_internal_mutable_generated_code_info()->PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo::MergeFrom(from._internal_generated_code_info());
}
- }
+ }
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
-}
-
-void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
- if (&from == this) return;
- Clear();
+}
+
+void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
+ if (&from == this) return;
+ Clear();
MergeFrom(from);
-}
-
-bool CodeGeneratorResponse_File::IsInitialized() const {
- return true;
-}
-
-void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) {
+}
+
+bool CodeGeneratorResponse_File::IsInitialized() const {
+ return true;
+}
+
+void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -1237,16 +1237,16 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
&other->content_, other->GetArenaForAllocation()
);
swap(generated_code_info_, other->generated_code_info_);
-}
-
+}
+
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse_File::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]);
-}
-
+}
+
// ===================================================================
-
+
class CodeGeneratorResponse::_Internal {
public:
using HasBits = decltype(std::declval<CodeGeneratorResponse>()._has_bits_);
@@ -1262,13 +1262,13 @@ CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* are
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned),
file_(arena) {
- SharedCtor();
+ SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.CodeGeneratorResponse)
-}
-CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
+}
+CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
_has_bits_(from._has_bits_),
file_(from.file_) {
@@ -1279,38 +1279,38 @@ CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)
GetArenaForAllocation());
}
supported_features_ = from.supported_features_;
- // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)
-}
-
-void CodeGeneratorResponse::SharedCtor() {
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)
+}
+
+void CodeGeneratorResponse::SharedCtor() {
error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
supported_features_ = uint64_t{0u};
-}
-
-CodeGeneratorResponse::~CodeGeneratorResponse() {
- // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse)
+}
+
+CodeGeneratorResponse::~CodeGeneratorResponse() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse)
if (GetArenaForAllocation() != nullptr) return;
- SharedDtor();
+ SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
-}
-
+}
+
inline void CodeGeneratorResponse::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
error_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
-}
-
+}
+
void CodeGeneratorResponse::ArenaDtor(void* object) {
CodeGeneratorResponse* _this = reinterpret_cast< CodeGeneratorResponse* >(object);
(void)_this;
-}
+}
void CodeGeneratorResponse::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
-}
+}
void CodeGeneratorResponse::SetCachedSize(int size) const {
_cached_size_.Set(size);
-}
-
-void CodeGeneratorResponse::Clear() {
-// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse)
+}
+
+void CodeGeneratorResponse::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1319,12 +1319,12 @@ void CodeGeneratorResponse::Clear() {
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000001u) {
error_.ClearNonDefaultToEmpty();
- }
+ }
supported_features_ = uint64_t{0u};
_has_bits_.Clear();
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
-}
-
+}
+
const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
@@ -1332,7 +1332,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
- // optional string error = 1;
+ // optional string error = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_error();
@@ -1351,7 +1351,7 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA
CHK_(ptr);
} else goto handle_unusual;
continue;
- // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
+ // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
case 15:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122)) {
ptr -= 1;
@@ -1363,30 +1363,30 @@ const char* CodeGeneratorResponse::_InternalParse(const char* ptr, ::PROTOBUF_NA
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<122>(ptr));
} else goto handle_unusual;
continue;
- default: {
- handle_unusual:
+ default: {
+ handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
- goto success;
- }
+ goto success;
+ }
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
- }
+ }
} // switch
} // while
-success:
+success:
_has_bits_.Or(has_bits);
return ptr;
-failure:
+failure:
ptr = nullptr;
goto success;
#undef CHK_
-}
-
+}
+
::PROTOBUF_NAMESPACE_ID::uint8* CodeGeneratorResponse::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)
@@ -1394,42 +1394,42 @@ failure:
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
- // optional string error = 1;
+ // optional string error = 1;
if (cached_has_bits & 0x00000001u) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
this->_internal_error().data(), static_cast<int>(this->_internal_error().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
- "google.protobuf.compiler.CodeGeneratorResponse.error");
+ "google.protobuf.compiler.CodeGeneratorResponse.error");
target = stream->WriteStringMaybeAliased(
1, this->_internal_error(), target);
- }
-
+ }
+
// optional uint64 supported_features = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(2, this->_internal_supported_features(), target);
- }
-
- // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
+ }
+
+ // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_file_size()); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(15, this->_internal_file(i), target, stream);
- }
-
+ }
+
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
- }
- // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse)
- return target;
-}
-
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse)
+ return target;
+}
+
size_t CodeGeneratorResponse::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse)
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse)
size_t total_size = 0;
-
+
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
@@ -1439,7 +1439,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
for (const auto& msg : this->file_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
- }
+ }
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
@@ -1449,7 +1449,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_error());
}
-
+
// optional uint64 supported_features = 2;
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
@@ -1457,16 +1457,16 @@ size_t CodeGeneratorResponse::ByteSizeLong() const {
this->_internal_supported_features());
}
- }
+ }
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
- return total_size;
-}
-
+ return total_size;
+}
+
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData CodeGeneratorResponse::_class_data_ = {
::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck,
CodeGeneratorResponse::MergeImpl
@@ -1477,16 +1477,16 @@ void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to,
const ::PROTOBUF_NAMESPACE_ID::Message&from) {
static_cast<CodeGeneratorResponse *>(to)->MergeFrom(
static_cast<const CodeGeneratorResponse &>(from));
-}
-
+}
-void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
+
+void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
GOOGLE_DCHECK_NE(&from, this);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
- file_.MergeFrom(from.file_);
+ file_.MergeFrom(from.file_);
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
@@ -1496,22 +1496,22 @@ void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {
supported_features_ = from.supported_features_;
}
_has_bits_[0] |= cached_has_bits;
- }
+ }
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
-}
-
-void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse)
- if (&from == this) return;
- Clear();
+}
+
+void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse)
+ if (&from == this) return;
+ Clear();
MergeFrom(from);
-}
-
-bool CodeGeneratorResponse::IsInitialized() const {
- return true;
-}
-
-void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
+}
+
+bool CodeGeneratorResponse::IsInitialized() const {
+ return true;
+}
+
+void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
@@ -1522,31 +1522,31 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
&other->error_, other->GetArenaForAllocation()
);
swap(supported_features_, other->supported_features_);
-}
-
+}
+
::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorResponse::GetMetadata() const {
return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(
&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once,
file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]);
-}
-
+}
+
// @@protoc_insertion_point(namespace_scope)
} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::Version >(Arena* arena) {
return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::Version >(arena);
-}
+}
template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(Arena* arena) {
return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest >(arena);
-}
+}
template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(Arena* arena) {
return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >(arena);
-}
+}
template<> PROTOBUF_NOINLINE PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(Arena* arena) {
return Arena::CreateMessageInternal< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena);
-}
+}
PROTOBUF_NAMESPACE_CLOSE
-
-// @@protoc_insertion_point(global_scope)
+
+// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
index a3cd057c3a..6da6c31dad 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h
@@ -1,24 +1,24 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: google/protobuf/compiler/plugin.proto
-
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: google/protobuf/compiler/plugin.proto
+
#ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto
-
+
#include <limits>
#include <string>
-
+
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3017000
-#error This file was generated by a newer version of protoc which is
+#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
-#error your headers.
-#endif
+#error your headers.
+#endif
#if 3017003 < PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
+#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
+#error regenerate this file with a newer version of protoc.
+#endif
+
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
@@ -33,7 +33,7 @@
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/descriptor.pb.h>
-// @@protoc_insertion_point(includes)
+// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT
#ifdef major
@@ -84,8 +84,8 @@ template<> PROTOC_EXPORT PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_
template<> PROTOC_EXPORT PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
PROTOBUF_NAMESPACE_OPEN
-namespace compiler {
-
+namespace compiler {
+
enum CodeGeneratorResponse_Feature : int {
CodeGeneratorResponse_Feature_FEATURE_NONE = 0,
CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1
@@ -94,7 +94,7 @@ PROTOC_EXPORT bool CodeGeneratorResponse_Feature_IsValid(int value);
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MIN = CodeGeneratorResponse_Feature_FEATURE_NONE;
constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MAX = CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL;
constexpr int CodeGeneratorResponse_Feature_Feature_ARRAYSIZE = CodeGeneratorResponse_Feature_Feature_MAX + 1;
-
+
PROTOC_EXPORT const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor();
template<typename T>
inline const TProtoStringType& CodeGeneratorResponse_Feature_Name(T enum_t_value) {
@@ -109,8 +109,8 @@ inline bool CodeGeneratorResponse_Feature_Parse(
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<CodeGeneratorResponse_Feature>(
CodeGeneratorResponse_Feature_descriptor(), name, value);
}
-// ===================================================================
-
+// ===================================================================
+
class PROTOC_EXPORT Version final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ {
public:
@@ -314,21 +314,21 @@ class PROTOC_EXPORT Version final :
class PROTOC_EXPORT CodeGeneratorRequest final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {
- public:
+ public:
inline CodeGeneratorRequest() : CodeGeneratorRequest(nullptr) {}
~CodeGeneratorRequest() override;
explicit constexpr CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
-
- CodeGeneratorRequest(const CodeGeneratorRequest& from);
+
+ CodeGeneratorRequest(const CodeGeneratorRequest& from);
CodeGeneratorRequest(CodeGeneratorRequest&& from) noexcept
: CodeGeneratorRequest() {
*this = ::std::move(from);
}
-
- inline CodeGeneratorRequest& operator=(const CodeGeneratorRequest& from) {
- CopyFrom(from);
- return *this;
- }
+
+ inline CodeGeneratorRequest& operator=(const CodeGeneratorRequest& from) {
+ CopyFrom(from);
+ return *this;
+ }
inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
@@ -341,11 +341,11 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
- }
+ }
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
- }
-
+ }
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
@@ -381,37 +381,37 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
-
- // implements Message ----------------------------------------------
-
+
+ // implements Message ----------------------------------------------
+
inline CodeGeneratorRequest* New() const final {
return new CodeGeneratorRequest();
}
-
+
CodeGeneratorRequest* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<CodeGeneratorRequest>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
- void CopyFrom(const CodeGeneratorRequest& from);
+ void CopyFrom(const CodeGeneratorRequest& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const CodeGeneratorRequest& from);
+ void MergeFrom(const CodeGeneratorRequest& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
-
+
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
- private:
- void SharedCtor();
- void SharedDtor();
+ private:
+ void SharedCtor();
+ void SharedDtor();
void SetCachedSize(int size) const final;
- void InternalSwap(CodeGeneratorRequest* other);
+ void InternalSwap(CodeGeneratorRequest* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "google.protobuf.compiler.CodeGeneratorRequest";
@@ -419,7 +419,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
protected:
explicit CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
+ private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
@@ -429,40 +429,40 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
enum : int {
kFileToGenerateFieldNumber = 1,
kProtoFileFieldNumber = 15,
kParameterFieldNumber = 2,
kCompilerVersionFieldNumber = 3,
};
- // repeated string file_to_generate = 1;
- int file_to_generate_size() const;
+ // repeated string file_to_generate = 1;
+ int file_to_generate_size() const;
private:
int _internal_file_to_generate_size() const;
public:
- void clear_file_to_generate();
+ void clear_file_to_generate();
const TProtoStringType& file_to_generate(int index) const;
TProtoStringType* mutable_file_to_generate(int index);
void set_file_to_generate(int index, const TProtoStringType& value);
void set_file_to_generate(int index, TProtoStringType&& value);
- void set_file_to_generate(int index, const char* value);
- void set_file_to_generate(int index, const char* value, size_t size);
+ void set_file_to_generate(int index, const char* value);
+ void set_file_to_generate(int index, const char* value, size_t size);
TProtoStringType* add_file_to_generate();
void add_file_to_generate(const TProtoStringType& value);
void add_file_to_generate(TProtoStringType&& value);
- void add_file_to_generate(const char* value);
- void add_file_to_generate(const char* value, size_t size);
+ void add_file_to_generate(const char* value);
+ void add_file_to_generate(const char* value, size_t size);
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& file_to_generate() const;
::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>* mutable_file_to_generate();
private:
const TProtoStringType& _internal_file_to_generate(int index) const;
TProtoStringType* _internal_add_file_to_generate();
public:
-
+
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
int proto_file_size() const;
private:
@@ -481,12 +481,12 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >&
proto_file() const;
- // optional string parameter = 2;
- bool has_parameter() const;
+ // optional string parameter = 2;
+ bool has_parameter() const;
private:
bool _internal_has_parameter() const;
public:
- void clear_parameter();
+ void clear_parameter();
const TProtoStringType& parameter() const;
template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
void set_parameter(ArgT0&& arg0, ArgT... args);
@@ -498,7 +498,7 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
inline PROTOBUF_ALWAYS_INLINE void _internal_set_parameter(const TProtoStringType& value);
TProtoStringType* _internal_mutable_parameter();
public:
-
+
// optional .google.protobuf.compiler.Version compiler_version = 3;
bool has_compiler_version() const;
private:
@@ -516,11 +516,11 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
void unsafe_arena_set_allocated_compiler_version(
PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version);
PROTOBUF_NAMESPACE_ID::compiler::Version* unsafe_arena_release_compiler_version();
-
- // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest)
- private:
+
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest)
+ private:
class _Internal;
-
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
@@ -531,26 +531,26 @@ class PROTOC_EXPORT CodeGeneratorRequest final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr parameter_;
PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version_;
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-};
-// -------------------------------------------------------------------
-
+};
+// -------------------------------------------------------------------
+
class PROTOC_EXPORT CodeGeneratorResponse_File final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {
- public:
+ public:
inline CodeGeneratorResponse_File() : CodeGeneratorResponse_File(nullptr) {}
~CodeGeneratorResponse_File() override;
explicit constexpr CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
-
- CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from);
+
+ CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from);
CodeGeneratorResponse_File(CodeGeneratorResponse_File&& from) noexcept
: CodeGeneratorResponse_File() {
*this = ::std::move(from);
}
-
- inline CodeGeneratorResponse_File& operator=(const CodeGeneratorResponse_File& from) {
- CopyFrom(from);
- return *this;
- }
+
+ inline CodeGeneratorResponse_File& operator=(const CodeGeneratorResponse_File& from) {
+ CopyFrom(from);
+ return *this;
+ }
inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
@@ -563,11 +563,11 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
- }
+ }
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
- }
-
+ }
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
@@ -603,37 +603,37 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
-
- // implements Message ----------------------------------------------
-
+
+ // implements Message ----------------------------------------------
+
inline CodeGeneratorResponse_File* New() const final {
return new CodeGeneratorResponse_File();
}
-
+
CodeGeneratorResponse_File* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<CodeGeneratorResponse_File>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
- void CopyFrom(const CodeGeneratorResponse_File& from);
+ void CopyFrom(const CodeGeneratorResponse_File& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const CodeGeneratorResponse_File& from);
+ void MergeFrom(const CodeGeneratorResponse_File& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
-
+
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
- private:
- void SharedCtor();
- void SharedDtor();
+ private:
+ void SharedCtor();
+ void SharedDtor();
void SetCachedSize(int size) const final;
- void InternalSwap(CodeGeneratorResponse_File* other);
+ void InternalSwap(CodeGeneratorResponse_File* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "google.protobuf.compiler.CodeGeneratorResponse.File";
@@ -641,7 +641,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
protected:
explicit CodeGeneratorResponse_File(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
+ private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
@@ -651,22 +651,22 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
enum : int {
kNameFieldNumber = 1,
kInsertionPointFieldNumber = 2,
kContentFieldNumber = 15,
kGeneratedCodeInfoFieldNumber = 16,
};
- // optional string name = 1;
- bool has_name() const;
+ // optional string name = 1;
+ bool has_name() const;
private:
bool _internal_has_name() const;
public:
- void clear_name();
+ void clear_name();
const TProtoStringType& name() const;
template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
void set_name(ArgT0&& arg0, ArgT... args);
@@ -678,13 +678,13 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
inline PROTOBUF_ALWAYS_INLINE void _internal_set_name(const TProtoStringType& value);
TProtoStringType* _internal_mutable_name();
public:
-
- // optional string insertion_point = 2;
- bool has_insertion_point() const;
+
+ // optional string insertion_point = 2;
+ bool has_insertion_point() const;
private:
bool _internal_has_insertion_point() const;
public:
- void clear_insertion_point();
+ void clear_insertion_point();
const TProtoStringType& insertion_point() const;
template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
void set_insertion_point(ArgT0&& arg0, ArgT... args);
@@ -696,13 +696,13 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
inline PROTOBUF_ALWAYS_INLINE void _internal_set_insertion_point(const TProtoStringType& value);
TProtoStringType* _internal_mutable_insertion_point();
public:
-
- // optional string content = 15;
- bool has_content() const;
+
+ // optional string content = 15;
+ bool has_content() const;
private:
bool _internal_has_content() const;
public:
- void clear_content();
+ void clear_content();
const TProtoStringType& content() const;
template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
void set_content(ArgT0&& arg0, ArgT... args);
@@ -714,7 +714,7 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
inline PROTOBUF_ALWAYS_INLINE void _internal_set_content(const TProtoStringType& value);
TProtoStringType* _internal_mutable_content();
public:
-
+
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
bool has_generated_code_info() const;
private:
@@ -733,10 +733,10 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info);
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* unsafe_arena_release_generated_code_info();
- // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File)
- private:
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File)
+ private:
class _Internal;
-
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
@@ -747,26 +747,26 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr content_;
PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* generated_code_info_;
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-};
-// -------------------------------------------------------------------
-
+};
+// -------------------------------------------------------------------
+
class PROTOC_EXPORT CodeGeneratorResponse final :
public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {
- public:
+ public:
inline CodeGeneratorResponse() : CodeGeneratorResponse(nullptr) {}
~CodeGeneratorResponse() override;
explicit constexpr CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
-
- CodeGeneratorResponse(const CodeGeneratorResponse& from);
+
+ CodeGeneratorResponse(const CodeGeneratorResponse& from);
CodeGeneratorResponse(CodeGeneratorResponse&& from) noexcept
: CodeGeneratorResponse() {
*this = ::std::move(from);
}
-
- inline CodeGeneratorResponse& operator=(const CodeGeneratorResponse& from) {
- CopyFrom(from);
- return *this;
- }
+
+ inline CodeGeneratorResponse& operator=(const CodeGeneratorResponse& from) {
+ CopyFrom(from);
+ return *this;
+ }
inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()) {
@@ -779,11 +779,11 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const {
return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance);
- }
+ }
inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
- }
-
+ }
+
static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() {
return GetDescriptor();
}
@@ -819,37 +819,37 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
-
- // implements Message ----------------------------------------------
-
+
+ // implements Message ----------------------------------------------
+
inline CodeGeneratorResponse* New() const final {
return new CodeGeneratorResponse();
}
-
+
CodeGeneratorResponse* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final {
return CreateMaybeMessage<CodeGeneratorResponse>(arena);
}
using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom;
- void CopyFrom(const CodeGeneratorResponse& from);
+ void CopyFrom(const CodeGeneratorResponse& from);
using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom;
- void MergeFrom(const CodeGeneratorResponse& from);
+ void MergeFrom(const CodeGeneratorResponse& from);
private:
static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from);
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
-
+
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
- private:
- void SharedCtor();
- void SharedDtor();
+ private:
+ void SharedCtor();
+ void SharedDtor();
void SetCachedSize(int size) const final;
- void InternalSwap(CodeGeneratorResponse* other);
+ void InternalSwap(CodeGeneratorResponse* other);
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "google.protobuf.compiler.CodeGeneratorResponse";
@@ -857,7 +857,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
protected:
explicit CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
- private:
+ private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
@@ -867,10 +867,10 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final;
- // nested types ----------------------------------------------------
-
- typedef CodeGeneratorResponse_File File;
-
+ // nested types ----------------------------------------------------
+
+ typedef CodeGeneratorResponse_File File;
+
typedef CodeGeneratorResponse_Feature Feature;
static constexpr Feature FEATURE_NONE =
CodeGeneratorResponse_Feature_FEATURE_NONE;
@@ -901,8 +901,8 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
return CodeGeneratorResponse_Feature_Parse(name, value);
}
- // accessors -------------------------------------------------------
-
+ // accessors -------------------------------------------------------
+
enum : int {
kFileFieldNumber = 15,
kErrorFieldNumber = 1,
@@ -926,12 +926,12 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >&
file() const;
- // optional string error = 1;
- bool has_error() const;
+ // optional string error = 1;
+ bool has_error() const;
private:
bool _internal_has_error() const;
public:
- void clear_error();
+ void clear_error();
const TProtoStringType& error() const;
template <typename ArgT0 = const TProtoStringType&, typename... ArgT>
void set_error(ArgT0&& arg0, ArgT... args);
@@ -943,7 +943,7 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
inline PROTOBUF_ALWAYS_INLINE void _internal_set_error(const TProtoStringType& value);
TProtoStringType* _internal_mutable_error();
public:
-
+
// optional uint64 supported_features = 2;
bool has_supported_features() const;
private:
@@ -957,10 +957,10 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
void _internal_set_supported_features(::PROTOBUF_NAMESPACE_ID::uint64 value);
public:
- // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse)
- private:
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse)
+ private:
class _Internal;
-
+
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
@@ -970,12 +970,12 @@ class PROTOC_EXPORT CodeGeneratorResponse final :
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_;
::PROTOBUF_NAMESPACE_ID::uint64 supported_features_;
friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto;
-};
-// ===================================================================
-
-
-// ===================================================================
-
+};
+// ===================================================================
+
+
+// ===================================================================
+
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
@@ -1126,18 +1126,18 @@ inline void Version::set_allocated_suffix(TProtoStringType* suffix) {
// -------------------------------------------------------------------
-// CodeGeneratorRequest
-
-// repeated string file_to_generate = 1;
+// CodeGeneratorRequest
+
+// repeated string file_to_generate = 1;
inline int CodeGeneratorRequest::_internal_file_to_generate_size() const {
- return file_to_generate_.size();
-}
+ return file_to_generate_.size();
+}
inline int CodeGeneratorRequest::file_to_generate_size() const {
return _internal_file_to_generate_size();
}
-inline void CodeGeneratorRequest::clear_file_to_generate() {
- file_to_generate_.Clear();
-}
+inline void CodeGeneratorRequest::clear_file_to_generate() {
+ file_to_generate_.Clear();
+}
inline TProtoStringType* CodeGeneratorRequest::add_file_to_generate() {
TProtoStringType* _s = _internal_add_file_to_generate();
// @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
@@ -1147,85 +1147,85 @@ inline const TProtoStringType& CodeGeneratorRequest::_internal_file_to_generate(
return file_to_generate_.Get(index);
}
inline const TProtoStringType& CodeGeneratorRequest::file_to_generate(int index) const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
return _internal_file_to_generate(index);
-}
+}
inline TProtoStringType* CodeGeneratorRequest::mutable_file_to_generate(int index) {
- // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
- return file_to_generate_.Mutable(index);
-}
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+ return file_to_generate_.Mutable(index);
+}
inline void CodeGeneratorRequest::set_file_to_generate(int index, const TProtoStringType& value) {
file_to_generate_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
-}
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
inline void CodeGeneratorRequest::set_file_to_generate(int index, TProtoStringType&& value) {
file_to_generate_.Mutable(index)->assign(std::move(value));
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
-inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
+inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
GOOGLE_DCHECK(value != nullptr);
- file_to_generate_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
-}
-inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) {
- file_to_generate_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
-}
+ file_to_generate_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
+inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) {
+ file_to_generate_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
inline TProtoStringType* CodeGeneratorRequest::_internal_add_file_to_generate() {
- return file_to_generate_.Add();
-}
+ return file_to_generate_.Add();
+}
inline void CodeGeneratorRequest::add_file_to_generate(const TProtoStringType& value) {
- file_to_generate_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
-}
+ file_to_generate_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
inline void CodeGeneratorRequest::add_file_to_generate(TProtoStringType&& value) {
file_to_generate_.Add(std::move(value));
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
-inline void CodeGeneratorRequest::add_file_to_generate(const char* value) {
+inline void CodeGeneratorRequest::add_file_to_generate(const char* value) {
GOOGLE_DCHECK(value != nullptr);
- file_to_generate_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
-}
-inline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) {
- file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
-}
+ file_to_generate_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
+inline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) {
+ file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>&
-CodeGeneratorRequest::file_to_generate() const {
- // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
- return file_to_generate_;
-}
+CodeGeneratorRequest::file_to_generate() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+ return file_to_generate_;
+}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>*
-CodeGeneratorRequest::mutable_file_to_generate() {
- // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
- return &file_to_generate_;
-}
-
-// optional string parameter = 2;
+CodeGeneratorRequest::mutable_file_to_generate() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
+ return &file_to_generate_;
+}
+
+// optional string parameter = 2;
inline bool CodeGeneratorRequest::_internal_has_parameter() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool CodeGeneratorRequest::has_parameter() const {
+inline bool CodeGeneratorRequest::has_parameter() const {
return _internal_has_parameter();
-}
+}
inline void CodeGeneratorRequest::clear_parameter() {
parameter_.ClearToEmpty();
_has_bits_[0] &= ~0x00000001u;
-}
+}
inline const TProtoStringType& CodeGeneratorRequest::parameter() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)
return _internal_parameter();
-}
+}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorRequest::set_parameter(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
-}
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+}
inline TProtoStringType* CodeGeneratorRequest::mutable_parameter() {
TProtoStringType* _s = _internal_mutable_parameter();
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@@ -1241,42 +1241,42 @@ inline void CodeGeneratorRequest::_internal_set_parameter(const TProtoStringType
inline TProtoStringType* CodeGeneratorRequest::_internal_mutable_parameter() {
_has_bits_[0] |= 0x00000001u;
return parameter_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
-}
+}
inline TProtoStringType* CodeGeneratorRequest::release_parameter() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)
if (!_internal_has_parameter()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
return parameter_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
-}
+}
inline void CodeGeneratorRequest::set_allocated_parameter(TProtoStringType* parameter) {
if (parameter != nullptr) {
_has_bits_[0] |= 0x00000001u;
- } else {
+ } else {
_has_bits_[0] &= ~0x00000001u;
- }
+ }
parameter_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), parameter,
GetArenaForAllocation());
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
-}
-
-// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)
+}
+
+// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
inline int CodeGeneratorRequest::_internal_proto_file_size() const {
- return proto_file_.size();
-}
+ return proto_file_.size();
+}
inline int CodeGeneratorRequest::proto_file_size() const {
return _internal_proto_file_size();
-}
+}
inline PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) {
- // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return proto_file_.Mutable(index);
-}
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
+ return proto_file_.Mutable(index);
+}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >*
-CodeGeneratorRequest::mutable_proto_file() {
- // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return &proto_file_;
-}
+CodeGeneratorRequest::mutable_proto_file() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
+ return &proto_file_;
+}
inline const PROTOBUF_NAMESPACE_ID::FileDescriptorProto& CodeGeneratorRequest::_internal_proto_file(int index) const {
return proto_file_.Get(index);
}
@@ -1293,11 +1293,11 @@ inline PROTOBUF_NAMESPACE_ID::FileDescriptorProto* CodeGeneratorRequest::add_pro
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >&
-CodeGeneratorRequest::proto_file() const {
- // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
- return proto_file_;
-}
-
+CodeGeneratorRequest::proto_file() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)
+ return proto_file_;
+}
+
// optional .google.protobuf.compiler.Version compiler_version = 3;
inline bool CodeGeneratorRequest::_internal_has_compiler_version() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
@@ -1388,33 +1388,33 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESP
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version)
}
-// -------------------------------------------------------------------
-
-// CodeGeneratorResponse_File
-
-// optional string name = 1;
+// -------------------------------------------------------------------
+
+// CodeGeneratorResponse_File
+
+// optional string name = 1;
inline bool CodeGeneratorResponse_File::_internal_has_name() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool CodeGeneratorResponse_File::has_name() const {
+inline bool CodeGeneratorResponse_File::has_name() const {
return _internal_has_name();
-}
+}
inline void CodeGeneratorResponse_File::clear_name() {
name_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000001u;
-}
+ _has_bits_[0] &= ~0x00000001u;
+}
inline const TProtoStringType& CodeGeneratorResponse_File::name() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)
return _internal_name();
-}
+}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_name(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_name() {
TProtoStringType* _s = _internal_mutable_name();
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@@ -1430,49 +1430,49 @@ inline void CodeGeneratorResponse_File::_internal_set_name(const TProtoStringTyp
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_name() {
_has_bits_[0] |= 0x00000001u;
return name_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
-}
+}
inline TProtoStringType* CodeGeneratorResponse_File::release_name() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)
if (!_internal_has_name()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
return name_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
-}
+}
inline void CodeGeneratorResponse_File::set_allocated_name(TProtoStringType* name) {
if (name != nullptr) {
_has_bits_[0] |= 0x00000001u;
- } else {
+ } else {
_has_bits_[0] &= ~0x00000001u;
- }
+ }
name_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), name,
GetArenaForAllocation());
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
-}
-
-// optional string insertion_point = 2;
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)
+}
+
+// optional string insertion_point = 2;
inline bool CodeGeneratorResponse_File::_internal_has_insertion_point() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
return value;
}
-inline bool CodeGeneratorResponse_File::has_insertion_point() const {
+inline bool CodeGeneratorResponse_File::has_insertion_point() const {
return _internal_has_insertion_point();
-}
+}
inline void CodeGeneratorResponse_File::clear_insertion_point() {
insertion_point_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000002u;
-}
+ _has_bits_[0] &= ~0x00000002u;
+}
inline const TProtoStringType& CodeGeneratorResponse_File::insertion_point() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
return _internal_insertion_point();
-}
+}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_insertion_point(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_insertion_point() {
TProtoStringType* _s = _internal_mutable_insertion_point();
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@@ -1488,49 +1488,49 @@ inline void CodeGeneratorResponse_File::_internal_set_insertion_point(const TPro
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_insertion_point() {
_has_bits_[0] |= 0x00000002u;
return insertion_point_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
-}
+}
inline TProtoStringType* CodeGeneratorResponse_File::release_insertion_point() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
if (!_internal_has_insertion_point()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
return insertion_point_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
-}
+}
inline void CodeGeneratorResponse_File::set_allocated_insertion_point(TProtoStringType* insertion_point) {
if (insertion_point != nullptr) {
_has_bits_[0] |= 0x00000002u;
- } else {
+ } else {
_has_bits_[0] &= ~0x00000002u;
- }
+ }
insertion_point_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), insertion_point,
GetArenaForAllocation());
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
-}
-
-// optional string content = 15;
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
+}
+
+// optional string content = 15;
inline bool CodeGeneratorResponse_File::_internal_has_content() const {
bool value = (_has_bits_[0] & 0x00000004u) != 0;
return value;
}
-inline bool CodeGeneratorResponse_File::has_content() const {
+inline bool CodeGeneratorResponse_File::has_content() const {
return _internal_has_content();
-}
+}
inline void CodeGeneratorResponse_File::clear_content() {
content_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000004u;
-}
+ _has_bits_[0] &= ~0x00000004u;
+}
inline const TProtoStringType& CodeGeneratorResponse_File::content() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)
return _internal_content();
-}
+}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse_File::set_content(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000004u;
content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
inline TProtoStringType* CodeGeneratorResponse_File::mutable_content() {
TProtoStringType* _s = _internal_mutable_content();
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@@ -1546,26 +1546,26 @@ inline void CodeGeneratorResponse_File::_internal_set_content(const TProtoString
inline TProtoStringType* CodeGeneratorResponse_File::_internal_mutable_content() {
_has_bits_[0] |= 0x00000004u;
return content_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
-}
+}
inline TProtoStringType* CodeGeneratorResponse_File::release_content() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)
if (!_internal_has_content()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000004u;
return content_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
-}
+}
inline void CodeGeneratorResponse_File::set_allocated_content(TProtoStringType* content) {
if (content != nullptr) {
_has_bits_[0] |= 0x00000004u;
- } else {
+ } else {
_has_bits_[0] &= ~0x00000004u;
- }
+ }
content_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), content,
GetArenaForAllocation());
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
-}
-
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)
+}
+
// optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
inline bool CodeGeneratorResponse_File::_internal_has_generated_code_info() const {
bool value = (_has_bits_[0] & 0x00000008u) != 0;
@@ -1654,33 +1654,33 @@ inline void CodeGeneratorResponse_File::set_allocated_generated_code_info(PROTOB
// @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.generated_code_info)
}
-// -------------------------------------------------------------------
-
-// CodeGeneratorResponse
-
-// optional string error = 1;
+// -------------------------------------------------------------------
+
+// CodeGeneratorResponse
+
+// optional string error = 1;
inline bool CodeGeneratorResponse::_internal_has_error() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
-inline bool CodeGeneratorResponse::has_error() const {
+inline bool CodeGeneratorResponse::has_error() const {
return _internal_has_error();
-}
+}
inline void CodeGeneratorResponse::clear_error() {
error_.ClearToEmpty();
- _has_bits_[0] &= ~0x00000001u;
-}
+ _has_bits_[0] &= ~0x00000001u;
+}
inline const TProtoStringType& CodeGeneratorResponse::error() const {
- // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)
return _internal_error();
-}
+}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void CodeGeneratorResponse::set_error(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
- // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
-}
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)
+}
inline TProtoStringType* CodeGeneratorResponse::mutable_error() {
TProtoStringType* _s = _internal_mutable_error();
// @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error)
@@ -1696,26 +1696,26 @@ inline void CodeGeneratorResponse::_internal_set_error(const TProtoStringType& v
inline TProtoStringType* CodeGeneratorResponse::_internal_mutable_error() {
_has_bits_[0] |= 0x00000001u;
return error_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
-}
+}
inline TProtoStringType* CodeGeneratorResponse::release_error() {
- // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)
if (!_internal_has_error()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
return error_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
-}
+}
inline void CodeGeneratorResponse::set_allocated_error(TProtoStringType* error) {
if (error != nullptr) {
_has_bits_[0] |= 0x00000001u;
- } else {
+ } else {
_has_bits_[0] &= ~0x00000001u;
- }
+ }
error_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error,
GetArenaForAllocation());
- // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)
-}
-
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)
+}
+
// optional uint64 supported_features = 2;
inline bool CodeGeneratorResponse::_internal_has_supported_features() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
@@ -1744,25 +1744,25 @@ inline void CodeGeneratorResponse::set_supported_features(::PROTOBUF_NAMESPACE_I
// @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.supported_features)
}
-// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
+// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;
inline int CodeGeneratorResponse::_internal_file_size() const {
- return file_.size();
-}
+ return file_.size();
+}
inline int CodeGeneratorResponse::file_size() const {
return _internal_file_size();
}
-inline void CodeGeneratorResponse::clear_file() {
- file_.Clear();
-}
+inline void CodeGeneratorResponse::clear_file() {
+ file_.Clear();
+}
inline PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) {
- // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file)
- return file_.Mutable(index);
-}
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file)
+ return file_.Mutable(index);
+}
inline ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >*
-CodeGeneratorResponse::mutable_file() {
- // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file)
- return &file_;
-}
+CodeGeneratorResponse::mutable_file() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file)
+ return &file_;
+}
inline const PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::_internal_file(int index) const {
return file_.Get(index);
}
@@ -1779,26 +1779,26 @@ inline PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* CodeGenerato
return _add;
}
inline const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >&
-CodeGeneratorResponse::file() const {
- // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file)
- return file_;
-}
-
+CodeGeneratorResponse::file() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file)
+ return file_;
+}
+
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
// -------------------------------------------------------------------
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace compiler
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace compiler
PROTOBUF_NAMESPACE_CLOSE
-
+
PROTOBUF_NAMESPACE_OPEN
template <> struct is_proto_enum< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : ::std::true_type {};
@@ -1809,7 +1809,7 @@ inline const EnumDescriptor* GetEnumDescriptor< PROTOBUF_NAMESPACE_ID::compiler:
PROTOBUF_NAMESPACE_CLOSE
-// @@protoc_insertion_point(global_scope)
-
+// @@protoc_insertion_point(global_scope)
+
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto
index 8d72f549a3..9242aacc5b 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto
@@ -1,59 +1,59 @@
-// 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: kenton@google.com (Kenton Varda)
-//
-// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
-// change.
-//
-// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
-// just a program that reads a CodeGeneratorRequest from stdin and writes a
-// CodeGeneratorResponse to stdout.
-//
-// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
-// of dealing with the raw protocol defined here.
-//
-// A plugin executable needs only to be placed somewhere in the path. The
-// plugin should be named "protoc-gen-$NAME", and will then be used when the
-// flag "--${NAME}_out" is passed to protoc.
-
-syntax = "proto2";
-
-package google.protobuf.compiler;
-option java_package = "com.google.protobuf.compiler";
-option java_outer_classname = "PluginProtos";
-
+// 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: kenton@google.com (Kenton Varda)
+//
+// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to
+// change.
+//
+// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
+// just a program that reads a CodeGeneratorRequest from stdin and writes a
+// CodeGeneratorResponse to stdout.
+//
+// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
+// of dealing with the raw protocol defined here.
+//
+// A plugin executable needs only to be placed somewhere in the path. The
+// plugin should be named "protoc-gen-$NAME", and will then be used when the
+// flag "--${NAME}_out" is passed to protoc.
+
+syntax = "proto2";
+
+package google.protobuf.compiler;
+option java_package = "com.google.protobuf.compiler";
+option java_outer_classname = "PluginProtos";
+
option go_package = "google.golang.org/protobuf/types/pluginpb";
-
-import "google/protobuf/descriptor.proto";
-
+
+import "google/protobuf/descriptor.proto";
+
// The version number of protocol compiler.
message Version {
optional int32 major = 1;
@@ -64,49 +64,49 @@ message Version {
optional string suffix = 4;
}
-// An encoded CodeGeneratorRequest is written to the plugin's stdin.
-message CodeGeneratorRequest {
- // The .proto files that were explicitly listed on the command-line. The
- // code generator should generate code only for these files. Each file's
- // descriptor will be included in proto_file, below.
- repeated string file_to_generate = 1;
-
- // The generator parameter passed on the command-line.
- optional string parameter = 2;
-
- // FileDescriptorProtos for all files in files_to_generate and everything
- // they import. The files will appear in topological order, so each file
- // appears before any file that imports it.
- //
- // protoc guarantees that all proto_files will be written after
- // the fields above, even though this is not technically guaranteed by the
- // protobuf wire format. This theoretically could allow a plugin to stream
- // in the FileDescriptorProtos and handle them one by one rather than read
- // the entire set into memory at once. However, as of this writing, this
- // is not similarly optimized on protoc's end -- it will store all fields in
- // memory at once before sending them to the plugin.
+// An encoded CodeGeneratorRequest is written to the plugin's stdin.
+message CodeGeneratorRequest {
+ // The .proto files that were explicitly listed on the command-line. The
+ // code generator should generate code only for these files. Each file's
+ // descriptor will be included in proto_file, below.
+ repeated string file_to_generate = 1;
+
+ // The generator parameter passed on the command-line.
+ optional string parameter = 2;
+
+ // FileDescriptorProtos for all files in files_to_generate and everything
+ // they import. The files will appear in topological order, so each file
+ // appears before any file that imports it.
+ //
+ // protoc guarantees that all proto_files will be written after
+ // the fields above, even though this is not technically guaranteed by the
+ // protobuf wire format. This theoretically could allow a plugin to stream
+ // in the FileDescriptorProtos and handle them one by one rather than read
+ // the entire set into memory at once. However, as of this writing, this
+ // is not similarly optimized on protoc's end -- it will store all fields in
+ // memory at once before sending them to the plugin.
//
// Type names of fields and extensions in the FileDescriptorProto are always
// fully qualified.
- repeated FileDescriptorProto proto_file = 15;
+ repeated FileDescriptorProto proto_file = 15;
// The version number of protocol compiler.
optional Version compiler_version = 3;
-}
-
-// The plugin writes an encoded CodeGeneratorResponse to stdout.
-message CodeGeneratorResponse {
- // Error message. If non-empty, code generation failed. The plugin process
- // should exit with status code zero even if it reports an error in this way.
- //
- // This should be used to indicate errors in .proto files which prevent the
- // code generator from generating correct code. Errors which indicate a
- // problem in protoc itself -- such as the input CodeGeneratorRequest being
- // unparseable -- should be reported by writing a message to stderr and
- // exiting with a non-zero status code.
- optional string error = 1;
-
+}
+
+// The plugin writes an encoded CodeGeneratorResponse to stdout.
+message CodeGeneratorResponse {
+ // Error message. If non-empty, code generation failed. The plugin process
+ // should exit with status code zero even if it reports an error in this way.
+ //
+ // This should be used to indicate errors in .proto files which prevent the
+ // code generator from generating correct code. Errors which indicate a
+ // problem in protoc itself -- such as the input CodeGeneratorRequest being
+ // unparseable -- should be reported by writing a message to stderr and
+ // exiting with a non-zero status code.
+ optional string error = 1;
+
// A bitmask of supported features that the code generator supports.
// This is a bitwise "or" of values from the Feature enum.
optional uint64 supported_features = 2;
@@ -117,67 +117,67 @@ message CodeGeneratorResponse {
FEATURE_PROTO3_OPTIONAL = 1;
}
- // Represents a single generated file.
- message File {
- // The file name, relative to the output directory. The name must not
- // contain "." or ".." components and must be relative, not be absolute (so,
- // the file cannot lie outside the output directory). "/" must be used as
- // the path separator, not "\".
- //
- // If the name is omitted, the content will be appended to the previous
- // file. This allows the generator to break large files into small chunks,
- // and allows the generated text to be streamed back to protoc so that large
- // files need not reside completely in memory at one time. Note that as of
- // this writing protoc does not optimize for this -- it will read the entire
- // CodeGeneratorResponse before writing files to disk.
- optional string name = 1;
-
- // If non-empty, indicates that the named file should already exist, and the
- // content here is to be inserted into that file at a defined insertion
- // point. This feature allows a code generator to extend the output
- // produced by another code generator. The original generator may provide
- // insertion points by placing special annotations in the file that look
- // like:
- // @@protoc_insertion_point(NAME)
- // The annotation can have arbitrary text before and after it on the line,
- // which allows it to be placed in a comment. NAME should be replaced with
- // an identifier naming the point -- this is what other generators will use
- // as the insertion_point. Code inserted at this point will be placed
- // immediately above the line containing the insertion point (thus multiple
- // insertions to the same point will come out in the order they were added).
- // The double-@ is intended to make it unlikely that the generated code
- // could contain things that look like insertion points by accident.
- //
- // For example, the C++ code generator places the following line in the
- // .pb.h files that it generates:
- // // @@protoc_insertion_point(namespace_scope)
- // This line appears within the scope of the file's package namespace, but
- // outside of any particular class. Another plugin can then specify the
- // insertion_point "namespace_scope" to generate additional classes or
- // other declarations that should be placed in this scope.
- //
- // Note that if the line containing the insertion point begins with
- // whitespace, the same whitespace will be added to every line of the
- // inserted text. This is useful for languages like Python, where
- // indentation matters. In these languages, the insertion point comment
- // should be indented the same amount as any inserted code will need to be
- // in order to work correctly in that context.
- //
- // The code generator that generates the initial file and the one which
- // inserts into it must both run as part of a single invocation of protoc.
- // Code generators are executed in the order in which they appear on the
- // command line.
- //
- // If |insertion_point| is present, |name| must also be present.
- optional string insertion_point = 2;
-
- // The file contents.
- optional string content = 15;
+ // Represents a single generated file.
+ message File {
+ // The file name, relative to the output directory. The name must not
+ // contain "." or ".." components and must be relative, not be absolute (so,
+ // the file cannot lie outside the output directory). "/" must be used as
+ // the path separator, not "\".
+ //
+ // If the name is omitted, the content will be appended to the previous
+ // file. This allows the generator to break large files into small chunks,
+ // and allows the generated text to be streamed back to protoc so that large
+ // files need not reside completely in memory at one time. Note that as of
+ // this writing protoc does not optimize for this -- it will read the entire
+ // CodeGeneratorResponse before writing files to disk.
+ optional string name = 1;
+
+ // If non-empty, indicates that the named file should already exist, and the
+ // content here is to be inserted into that file at a defined insertion
+ // point. This feature allows a code generator to extend the output
+ // produced by another code generator. The original generator may provide
+ // insertion points by placing special annotations in the file that look
+ // like:
+ // @@protoc_insertion_point(NAME)
+ // The annotation can have arbitrary text before and after it on the line,
+ // which allows it to be placed in a comment. NAME should be replaced with
+ // an identifier naming the point -- this is what other generators will use
+ // as the insertion_point. Code inserted at this point will be placed
+ // immediately above the line containing the insertion point (thus multiple
+ // insertions to the same point will come out in the order they were added).
+ // The double-@ is intended to make it unlikely that the generated code
+ // could contain things that look like insertion points by accident.
+ //
+ // For example, the C++ code generator places the following line in the
+ // .pb.h files that it generates:
+ // // @@protoc_insertion_point(namespace_scope)
+ // This line appears within the scope of the file's package namespace, but
+ // outside of any particular class. Another plugin can then specify the
+ // insertion_point "namespace_scope" to generate additional classes or
+ // other declarations that should be placed in this scope.
+ //
+ // Note that if the line containing the insertion point begins with
+ // whitespace, the same whitespace will be added to every line of the
+ // inserted text. This is useful for languages like Python, where
+ // indentation matters. In these languages, the insertion point comment
+ // should be indented the same amount as any inserted code will need to be
+ // in order to work correctly in that context.
+ //
+ // The code generator that generates the initial file and the one which
+ // inserts into it must both run as part of a single invocation of protoc.
+ // Code generators are executed in the order in which they appear on the
+ // command line.
+ //
+ // If |insertion_point| is present, |name| must also be present.
+ optional string insertion_point = 2;
+
+ // The file contents.
+ optional string content = 15;
// Information describing the file content being inserted. If an insertion
// point is used, this information will be appropriately offset and inserted
// into the code generation metadata for the generated files.
optional GeneratedCodeInfo generated_code_info = 16;
- }
- repeated File file = 15;
-}
+ }
+ repeated File file = 15;
+}
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc
index 55a6c3a49a..471cc46ef6 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.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: robinson@google.com (Will Robinson)
-//
-// This module outputs pure-Python protocol message classes that will
-// largely be constructed at runtime via the metaclass in reflection.py.
-// In other words, our job is basically to output a Python equivalent
-// of the C++ *Descriptor objects, and fix up all circular references
-// within these objects.
-//
-// Note that the runtime performance of protocol message classes created in
-// this way is expected to be lousy. The plan is to create an alternate
-// generator that outputs a Python/C extension module that lets
-// performance-minded Python code leverage the fast C++ implementation
-// directly.
-
+// 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: robinson@google.com (Will Robinson)
+//
+// This module outputs pure-Python protocol message classes that will
+// largely be constructed at runtime via the metaclass in reflection.py.
+// In other words, our job is basically to output a Python equivalent
+// of the C++ *Descriptor objects, and fix up all circular references
+// within these objects.
+//
+// Note that the runtime performance of protocol message classes created in
+// this way is expected to be lousy. The plan is to create an alternate
+// generator that outputs a Python/C extension module that lets
+// performance-minded Python code leverage the fast C++ implementation
+// directly.
+
#include <google/protobuf/compiler/python/python_generator.h>
-#include <algorithm>
-#include <limits>
-#include <map>
-#include <memory>
+#include <algorithm>
+#include <limits>
+#include <map>
+#include <memory>
#include <string>
-#include <utility>
-#include <vector>
-
+#include <utility>
+#include <vector>
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/stringprintf.h>
@@ -61,69 +61,69 @@
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace python {
-
-namespace {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace python {
+
+namespace {
+
TProtoStringType FixEv(const TProtoStringType& filename) {
if (HasSuffixString(filename, ".ev")) {
return StripSuffixString(filename, ".ev") + "_ev.proto";
}
return filename;
}
-
-// Returns the Python module name expected for a given .proto filename.
+
+// Returns the Python module name expected for a given .proto filename.
TProtoStringType ModuleName(const TProtoStringType& filename) {
TProtoStringType basename = StripProto(FixEv(filename));
ReplaceCharacters(&basename, "-", '_');
ReplaceCharacters(&basename, "/", '.');
- return basename + "_pb2";
-}
-
-// Returns the alias we assign to the module of the given .proto filename
-// when importing. See testPackageInitializationImport in
+ return basename + "_pb2";
+}
+
+// Returns the alias we assign to the module of the given .proto filename
+// when importing. See testPackageInitializationImport in
// net/proto2/python/internal/reflection_test.py
-// to see why we need the alias.
+// to see why we need the alias.
TProtoStringType ModuleAlias(const TProtoStringType& filename) {
TProtoStringType module_name = ModuleName(filename);
- // We can't have dots in the module name, so we replace each with _dot_.
- // But that could lead to a collision between a.b and a_dot_b, so we also
- // duplicate each underscore.
- GlobalReplaceSubstring("_", "__", &module_name);
- GlobalReplaceSubstring(".", "_dot_", &module_name);
- return module_name;
-}
-
-// Keywords reserved by the Python language.
-const char* const kKeywords[] = {
+ // We can't have dots in the module name, so we replace each with _dot_.
+ // But that could lead to a collision between a.b and a_dot_b, so we also
+ // duplicate each underscore.
+ GlobalReplaceSubstring("_", "__", &module_name);
+ GlobalReplaceSubstring(".", "_dot_", &module_name);
+ return module_name;
+}
+
+// Keywords reserved by the Python language.
+const char* const kKeywords[] = {
"False", "None", "True", "and", "as", "assert",
"async", "await", "break", "class", "continue", "def",
"del", "elif", "else", "except", "finally", "for",
"from", "global", "if", "import", "in", "is",
"lambda", "nonlocal", "not", "or", "pass", "raise",
"return", "try", "while", "with", "yield", "print",
-};
-const char* const* kKeywordsEnd =
- kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
-
+};
+const char* const* kKeywordsEnd =
+ kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));
+
bool ContainsPythonKeyword(const TProtoStringType& module_name) {
std::vector<TProtoStringType> tokens = Split(module_name, ".");
- for (int i = 0; i < tokens.size(); ++i) {
- if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {
- return true;
- }
- }
- return false;
-}
-
+ for (int i = 0; i < tokens.size(); ++i) {
+ if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {
+ return true;
+ }
+ }
+ return false;
+}
+
inline bool IsPythonKeyword(const TProtoStringType& name) {
return (std::find(kKeywords, kKeywordsEnd, name) != kKeywordsEnd);
}
-
+
TProtoStringType ResolveKeyword(const TProtoStringType& name) {
if (IsPythonKeyword(name)) {
return "globals()['" + name + "']";
@@ -131,10 +131,10 @@ TProtoStringType ResolveKeyword(const TProtoStringType& name) {
return name;
}
-// Returns the name of all containing types for descriptor,
-// in order from outermost to innermost, followed by descriptor's
-// own name. Each name is separated by |separator|.
-template <typename DescriptorT>
+// Returns the name of all containing types for descriptor,
+// in order from outermost to innermost, followed by descriptor's
+// own name. Each name is separated by |separator|.
+template <typename DescriptorT>
TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
const TProtoStringType& separator) {
TProtoStringType name = descriptor.name();
@@ -146,167 +146,167 @@ TProtoStringType NamePrefixedWithNestedTypes(const DescriptorT& descriptor,
} else {
return prefix + separator + name;
}
- }
+ }
if (separator == ".") {
name = ResolveKeyword(name);
}
- return name;
-}
-
-// Name of the class attribute where we store the Python
-// descriptor.Descriptor instance for the generated class.
-// Must stay consistent with the _DESCRIPTOR_KEY constant
-// in proto2/public/reflection.py.
-const char kDescriptorKey[] = "DESCRIPTOR";
-
-// Does the file have top-level enums?
+ return name;
+}
+
+// Name of the class attribute where we store the Python
+// descriptor.Descriptor instance for the generated class.
+// Must stay consistent with the _DESCRIPTOR_KEY constant
+// in proto2/public/reflection.py.
+const char kDescriptorKey[] = "DESCRIPTOR";
+
+// Does the file have top-level enums?
inline bool HasTopLevelEnums(const FileDescriptor* file) {
- return file->enum_type_count() > 0;
-}
-
-// Should we generate generic services for this file?
+ return file->enum_type_count() > 0;
+}
+
+// Should we generate generic services for this file?
inline bool HasGenericServices(const FileDescriptor* file) {
return file->service_count() > 0 && file->options().py_generic_services();
-}
-
-// Prints the common boilerplate needed at the top of every .py
-// file output by this generator.
+}
+
+// Prints the common boilerplate needed at the top of every .py
+// file output by this generator.
void PrintTopBoilerplate(io::Printer* printer, const FileDescriptor* file,
bool descriptor_proto) {
- // TODO(robinson): Allow parameterization of Python version?
- printer->Print(
+ // TODO(robinson): Allow parameterization of Python version?
+ printer->Print(
"# -*- coding: utf-8 -*-\n"
- "# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
- "# source: $filename$\n"
+ "# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "# source: $filename$\n"
"\"\"\"Generated protocol buffer code.\"\"\"\n",
- "filename", file->name());
- if (HasTopLevelEnums(file)) {
- printer->Print(
- "from google.protobuf.internal import enum_type_wrapper\n");
- }
- printer->Print(
- "from google.protobuf import descriptor as _descriptor\n"
- "from google.protobuf import message as _message\n"
- "from google.protobuf import reflection as _reflection\n"
- "from google.protobuf import symbol_database as "
- "_symbol_database\n");
- if (HasGenericServices(file)) {
- printer->Print(
- "from google.protobuf import service as _service\n"
- "from google.protobuf import service_reflection\n");
- }
-
- printer->Print(
- "# @@protoc_insertion_point(imports)\n\n"
- "_sym_db = _symbol_database.Default()\n");
- printer->Print("\n\n");
-}
-
-// Returns a Python literal giving the default value for a field.
-// If the field specifies no explicit default value, we'll return
-// the default default value for the field type (zero for numbers,
-// empty string for strings, empty list for repeated fields, and
-// None for non-repeated, composite fields).
-//
-// TODO(robinson): Unify with code from
-// //compiler/cpp/internal/primitive_field.cc
-// //compiler/cpp/internal/enum_field.cc
-// //compiler/cpp/internal/string_field.cc
+ "filename", file->name());
+ if (HasTopLevelEnums(file)) {
+ printer->Print(
+ "from google.protobuf.internal import enum_type_wrapper\n");
+ }
+ printer->Print(
+ "from google.protobuf import descriptor as _descriptor\n"
+ "from google.protobuf import message as _message\n"
+ "from google.protobuf import reflection as _reflection\n"
+ "from google.protobuf import symbol_database as "
+ "_symbol_database\n");
+ if (HasGenericServices(file)) {
+ printer->Print(
+ "from google.protobuf import service as _service\n"
+ "from google.protobuf import service_reflection\n");
+ }
+
+ printer->Print(
+ "# @@protoc_insertion_point(imports)\n\n"
+ "_sym_db = _symbol_database.Default()\n");
+ printer->Print("\n\n");
+}
+
+// Returns a Python literal giving the default value for a field.
+// If the field specifies no explicit default value, we'll return
+// the default default value for the field type (zero for numbers,
+// empty string for strings, empty list for repeated fields, and
+// None for non-repeated, composite fields).
+//
+// TODO(robinson): Unify with code from
+// //compiler/cpp/internal/primitive_field.cc
+// //compiler/cpp/internal/enum_field.cc
+// //compiler/cpp/internal/string_field.cc
TProtoStringType StringifyDefaultValue(const FieldDescriptor& field) {
- if (field.is_repeated()) {
- return "[]";
- }
-
- switch (field.cpp_type()) {
- case FieldDescriptor::CPPTYPE_INT32:
+ if (field.is_repeated()) {
+ return "[]";
+ }
+
+ switch (field.cpp_type()) {
+ case FieldDescriptor::CPPTYPE_INT32:
return StrCat(field.default_value_int32());
- case FieldDescriptor::CPPTYPE_UINT32:
+ case FieldDescriptor::CPPTYPE_UINT32:
return StrCat(field.default_value_uint32());
- case FieldDescriptor::CPPTYPE_INT64:
+ case FieldDescriptor::CPPTYPE_INT64:
return StrCat(field.default_value_int64());
- case FieldDescriptor::CPPTYPE_UINT64:
+ case FieldDescriptor::CPPTYPE_UINT64:
return StrCat(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()) {
- // Python pre-2.6 on Windows does not parse "inf" correctly. However,
- // a numeric literal that is too big for a double will become infinity.
- return "1e10000";
+ // Python pre-2.6 on Windows does not parse "inf" correctly. However,
+ // a numeric literal that is too big for a double will become infinity.
+ return "1e10000";
} else if (value == -std::numeric_limits<double>::infinity()) {
- // See above.
- return "-1e10000";
- } else if (value != value) {
- // infinity * 0 = nan
- return "(1e10000 * 0)";
- } else {
- return "float(" + SimpleDtoa(value) + ")";
- }
- }
- case FieldDescriptor::CPPTYPE_FLOAT: {
- float value = field.default_value_float();
+ // See above.
+ return "-1e10000";
+ } else if (value != value) {
+ // infinity * 0 = nan
+ return "(1e10000 * 0)";
+ } else {
+ return "float(" + SimpleDtoa(value) + ")";
+ }
+ }
+ case FieldDescriptor::CPPTYPE_FLOAT: {
+ float value = field.default_value_float();
if (value == std::numeric_limits<float>::infinity()) {
- // Python pre-2.6 on Windows does not parse "inf" correctly. However,
- // a numeric literal that is too big for a double will become infinity.
- return "1e10000";
+ // Python pre-2.6 on Windows does not parse "inf" correctly. However,
+ // a numeric literal that is too big for a double will become infinity.
+ return "1e10000";
} else if (value == -std::numeric_limits<float>::infinity()) {
- // See above.
- return "-1e10000";
- } else if (value != value) {
- // infinity - infinity = nan
- return "(1e10000 * 0)";
- } else {
- return "float(" + SimpleFtoa(value) + ")";
- }
- }
- case FieldDescriptor::CPPTYPE_BOOL:
- return field.default_value_bool() ? "True" : "False";
- case FieldDescriptor::CPPTYPE_ENUM:
+ // See above.
+ return "-1e10000";
+ } else if (value != value) {
+ // infinity - infinity = nan
+ return "(1e10000 * 0)";
+ } else {
+ return "float(" + SimpleFtoa(value) + ")";
+ }
+ }
+ case FieldDescriptor::CPPTYPE_BOOL:
+ return field.default_value_bool() ? "True" : "False";
+ case FieldDescriptor::CPPTYPE_ENUM:
return StrCat(field.default_value_enum()->number());
- case FieldDescriptor::CPPTYPE_STRING:
+ case FieldDescriptor::CPPTYPE_STRING:
return "b\"" + CEscape(field.default_value_string()) +
(field.type() != FieldDescriptor::TYPE_STRING
? "\""
: "\".decode('utf-8')");
- case FieldDescriptor::CPPTYPE_MESSAGE:
- return "None";
- }
- // (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) << "Not reached.";
- return "";
-}
-
+ case FieldDescriptor::CPPTYPE_MESSAGE:
+ return "None";
+ }
+ // (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) << "Not reached.";
+ return "";
+}
+
TProtoStringType StringifySyntax(FileDescriptor::Syntax syntax) {
- switch (syntax) {
- case FileDescriptor::SYNTAX_PROTO2:
- return "proto2";
- case FileDescriptor::SYNTAX_PROTO3:
- return "proto3";
- case FileDescriptor::SYNTAX_UNKNOWN:
- default:
- GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports proto2 "
- "and proto3 syntax.";
- return "";
- }
-}
-
-} // namespace
-
+ switch (syntax) {
+ case FileDescriptor::SYNTAX_PROTO2:
+ return "proto2";
+ case FileDescriptor::SYNTAX_PROTO3:
+ return "proto3";
+ case FileDescriptor::SYNTAX_UNKNOWN:
+ default:
+ GOOGLE_LOG(FATAL) << "Unsupported syntax; this generator only supports proto2 "
+ "and proto3 syntax.";
+ return "";
+ }
+}
+
+} // namespace
+
Generator::Generator() : file_(nullptr) {}
-
+
Generator::~Generator() {}
-
+
uint64_t Generator::GetSupportedFeatures() const {
return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
-}
-
-bool Generator::Generate(const FileDescriptor* file,
+}
+
+bool Generator::Generate(const FileDescriptor* file,
const TProtoStringType& parameter,
GeneratorContext* context, TProtoStringType* error) const {
// -----------------------------------------------------------------
// parse generator options
bool cpp_generated_lib_linked = false;
-
+
std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
ParseGeneratorParameter(parameter, &options);
@@ -319,48 +319,48 @@ bool Generator::Generate(const FileDescriptor* file,
}
}
- // Completely serialize all Generate() calls on this instance. The
- // thread-safety constraints of the CodeGenerator interface aren't clear so
- // just be as conservative as possible. It's easier to relax this later if
- // we need to, but I doubt it will be an issue.
- // TODO(kenton): The proper thing to do would be to allocate any state on
- // the stack and use that, so that the Generator class itself does not need
- // to have any mutable members. Then it is implicitly thread-safe.
- MutexLock lock(&mutex_);
- file_ = file;
+ // Completely serialize all Generate() calls on this instance. The
+ // thread-safety constraints of the CodeGenerator interface aren't clear so
+ // just be as conservative as possible. It's easier to relax this later if
+ // we need to, but I doubt it will be an issue.
+ // TODO(kenton): The proper thing to do would be to allocate any state on
+ // the stack and use that, so that the Generator class itself does not need
+ // to have any mutable members. Then it is implicitly thread-safe.
+ MutexLock lock(&mutex_);
+ file_ = file;
TProtoStringType module_name = ModuleName(file->name());
TProtoStringType filename = module_name;
ReplaceCharacters(&filename, ".", '/');
filename += ".py";
-
+
pure_python_workable_ = !cpp_generated_lib_linked;
if (HasPrefixString(file->name(), "google/protobuf/")) {
pure_python_workable_ = true;
}
- FileDescriptorProto fdp;
- file_->CopyTo(&fdp);
- fdp.SerializeToString(&file_descriptor_serialized_);
-
-
+ FileDescriptorProto fdp;
+ file_->CopyTo(&fdp);
+ fdp.SerializeToString(&file_descriptor_serialized_);
+
+
std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
- GOOGLE_CHECK(output.get());
- io::Printer printer(output.get(), '$');
- printer_ = &printer;
-
- PrintTopBoilerplate(printer_, file_, GeneratingDescriptorProto());
+ GOOGLE_CHECK(output.get());
+ io::Printer printer(output.get(), '$');
+ printer_ = &printer;
+
+ PrintTopBoilerplate(printer_, file_, GeneratingDescriptorProto());
if (pure_python_workable_) {
PrintImports();
}
- PrintFileDescriptor();
- PrintTopLevelEnums();
- PrintTopLevelExtensions();
+ PrintFileDescriptor();
+ PrintTopLevelEnums();
+ PrintTopLevelExtensions();
if (pure_python_workable_) {
PrintAllNestedEnumsInFile();
PrintMessageDescriptors();
FixForeignFieldsInDescriptors();
}
- PrintMessages();
+ PrintMessages();
if (pure_python_workable_) {
// We have to fix up the extensions after the message classes themselves,
// since they need to call static RegisterExtension() methods on these
@@ -374,75 +374,75 @@ bool Generator::Generate(const FileDescriptor* file,
FixAllDescriptorOptions();
PrintServiceDescriptors();
}
- if (HasGenericServices(file)) {
- PrintServices();
- }
-
+ if (HasGenericServices(file)) {
+ PrintServices();
+ }
+
printer.Print("# @@protoc_insertion_point(module_scope)\n");
-
- return !printer.failed();
-}
-
-
-// Prints Python imports for all modules imported by |file|.
-void Generator::PrintImports() const {
- for (int i = 0; i < file_->dependency_count(); ++i) {
+
+ return !printer.failed();
+}
+
+
+// Prints Python imports for all modules imported by |file|.
+void Generator::PrintImports() const {
+ for (int i = 0; i < file_->dependency_count(); ++i) {
const TProtoStringType& filename = file_->dependency(i)->name();
-
+
TProtoStringType module_name = ModuleName(filename);
TProtoStringType module_alias = ModuleAlias(filename);
- if (ContainsPythonKeyword(module_name)) {
- // If the module path contains a Python keyword, we have to quote the
- // module name and import it using importlib. Otherwise the usual kind of
- // import statement would result in a syntax error from the presence of
- // the keyword.
- printer_->Print("import importlib\n");
- printer_->Print("$alias$ = importlib.import_module('$name$')\n", "alias",
- module_alias, "name", module_name);
- } else {
- int last_dot_pos = module_name.rfind('.');
+ if (ContainsPythonKeyword(module_name)) {
+ // If the module path contains a Python keyword, we have to quote the
+ // module name and import it using importlib. Otherwise the usual kind of
+ // import statement would result in a syntax error from the presence of
+ // the keyword.
+ printer_->Print("import importlib\n");
+ printer_->Print("$alias$ = importlib.import_module('$name$')\n", "alias",
+ module_alias, "name", module_name);
+ } else {
+ int last_dot_pos = module_name.rfind('.');
TProtoStringType import_statement;
if (last_dot_pos == TProtoStringType::npos) {
- // NOTE(petya): this is not tested as it would require a protocol buffer
- // outside of any package, and I don't think that is easily achievable.
- import_statement = "import " + module_name;
- } else {
- import_statement = "from " + module_name.substr(0, last_dot_pos) +
- " import " + module_name.substr(last_dot_pos + 1);
- }
- printer_->Print("$statement$ as $alias$\n", "statement", import_statement,
- "alias", module_alias);
- }
-
- CopyPublicDependenciesAliases(module_alias, file_->dependency(i));
- }
- printer_->Print("\n");
-
- // Print public imports.
- for (int i = 0; i < file_->public_dependency_count(); ++i) {
+ // NOTE(petya): this is not tested as it would require a protocol buffer
+ // outside of any package, and I don't think that is easily achievable.
+ import_statement = "import " + module_name;
+ } else {
+ import_statement = "from " + module_name.substr(0, last_dot_pos) +
+ " import " + module_name.substr(last_dot_pos + 1);
+ }
+ printer_->Print("$statement$ as $alias$\n", "statement", import_statement,
+ "alias", module_alias);
+ }
+
+ CopyPublicDependenciesAliases(module_alias, file_->dependency(i));
+ }
+ printer_->Print("\n");
+
+ // Print public imports.
+ for (int i = 0; i < file_->public_dependency_count(); ++i) {
TProtoStringType module_name = ModuleName(file_->public_dependency(i)->name());
- printer_->Print("from $module$ import *\n", "module", module_name);
- }
- printer_->Print("\n");
-}
-
-// Prints the single file descriptor for this file.
-void Generator::PrintFileDescriptor() const {
+ printer_->Print("from $module$ import *\n", "module", module_name);
+ }
+ printer_->Print("\n");
+}
+
+// Prints the single file descriptor for this file.
+void Generator::PrintFileDescriptor() const {
std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_name"] = kDescriptorKey;
- m["name"] = file_->name();
- m["package"] = file_->package();
- m["syntax"] = StringifySyntax(file_->syntax());
+ m["descriptor_name"] = kDescriptorKey;
+ m["name"] = file_->name();
+ m["package"] = file_->package();
+ m["syntax"] = StringifySyntax(file_->syntax());
m["options"] = OptionsValue(file_->options().SerializeAsString());
- const char file_descriptor_template[] =
- "$descriptor_name$ = _descriptor.FileDescriptor(\n"
- " name='$name$',\n"
- " package='$package$',\n"
+ const char file_descriptor_template[] =
+ "$descriptor_name$ = _descriptor.FileDescriptor(\n"
+ " name='$name$',\n"
+ " package='$package$',\n"
" syntax='$syntax$',\n"
" serialized_options=$options$,\n"
" create_key=_descriptor._internal_create_key,\n";
- printer_->Print(m, file_descriptor_template);
- printer_->Indent();
+ printer_->Print(m, file_descriptor_template);
+ printer_->Indent();
if (pure_python_workable_) {
printer_->Print("serialized_pb=b'$value$'\n", "value",
strings::CHexEscape(file_descriptor_serialized_));
@@ -454,7 +454,7 @@ void Generator::PrintFileDescriptor() const {
module_alias);
}
printer_->Print("]");
- }
+ }
if (file_->public_dependency_count() > 0) {
printer_->Print(",\npublic_dependencies=[");
for (int i = 0; i < file_->public_dependency_count(); ++i) {
@@ -468,115 +468,115 @@ void Generator::PrintFileDescriptor() const {
} else {
printer_->Print("serialized_pb=''\n");
}
-
- // TODO(falk): Also print options and fix the message_type, enum_type,
- // service and extension later in the generation.
-
- printer_->Outdent();
- printer_->Print(")\n");
- printer_->Print("\n");
-}
-
-// Prints descriptors and module-level constants for all top-level
-// enums defined in |file|.
-void Generator::PrintTopLevelEnums() const {
+
+ // TODO(falk): Also print options and fix the message_type, enum_type,
+ // service and extension later in the generation.
+
+ printer_->Outdent();
+ printer_->Print(")\n");
+ printer_->Print("\n");
+}
+
+// Prints descriptors and module-level constants for all top-level
+// enums defined in |file|.
+void Generator::PrintTopLevelEnums() const {
std::vector<std::pair<TProtoStringType, int> > top_level_enum_values;
- for (int i = 0; i < file_->enum_type_count(); ++i) {
- const EnumDescriptor& enum_descriptor = *file_->enum_type(i);
- PrintEnum(enum_descriptor);
+ for (int i = 0; i < file_->enum_type_count(); ++i) {
+ const EnumDescriptor& enum_descriptor = *file_->enum_type(i);
+ PrintEnum(enum_descriptor);
printer_->Print(
"$name$ = "
"enum_type_wrapper.EnumTypeWrapper($descriptor_name$)",
"name", ResolveKeyword(enum_descriptor.name()), "descriptor_name",
ModuleLevelDescriptorName(enum_descriptor));
- printer_->Print("\n");
-
- for (int j = 0; j < enum_descriptor.value_count(); ++j) {
- const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(j);
- top_level_enum_values.push_back(
- std::make_pair(value_descriptor.name(), value_descriptor.number()));
- }
- }
-
- for (int i = 0; i < top_level_enum_values.size(); ++i) {
+ printer_->Print("\n");
+
+ for (int j = 0; j < enum_descriptor.value_count(); ++j) {
+ const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(j);
+ top_level_enum_values.push_back(
+ std::make_pair(value_descriptor.name(), value_descriptor.number()));
+ }
+ }
+
+ for (int i = 0; i < top_level_enum_values.size(); ++i) {
printer_->Print("$name$ = $value$\n", "name",
ResolveKeyword(top_level_enum_values[i].first), "value",
StrCat(top_level_enum_values[i].second));
- }
- printer_->Print("\n");
-}
-
-// Prints all enums contained in all message types in |file|.
-void Generator::PrintAllNestedEnumsInFile() const {
- for (int i = 0; i < file_->message_type_count(); ++i) {
- PrintNestedEnums(*file_->message_type(i));
- }
-}
-
-// Prints a Python statement assigning the appropriate module-level
-// enum name to a Python EnumDescriptor object equivalent to
-// enum_descriptor.
-void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
+ }
+ printer_->Print("\n");
+}
+
+// Prints all enums contained in all message types in |file|.
+void Generator::PrintAllNestedEnumsInFile() const {
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ PrintNestedEnums(*file_->message_type(i));
+ }
+}
+
+// Prints a Python statement assigning the appropriate module-level
+// enum name to a Python EnumDescriptor object equivalent to
+// enum_descriptor.
+void Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
TProtoStringType module_level_descriptor_name =
- ModuleLevelDescriptorName(enum_descriptor);
- m["descriptor_name"] = module_level_descriptor_name;
- m["name"] = enum_descriptor.name();
- m["full_name"] = enum_descriptor.full_name();
- m["file"] = kDescriptorKey;
- const char enum_descriptor_template[] =
- "$descriptor_name$ = _descriptor.EnumDescriptor(\n"
- " name='$name$',\n"
- " full_name='$full_name$',\n"
- " filename=None,\n"
- " file=$file$,\n"
+ ModuleLevelDescriptorName(enum_descriptor);
+ m["descriptor_name"] = module_level_descriptor_name;
+ m["name"] = enum_descriptor.name();
+ m["full_name"] = enum_descriptor.full_name();
+ m["file"] = kDescriptorKey;
+ const char enum_descriptor_template[] =
+ "$descriptor_name$ = _descriptor.EnumDescriptor(\n"
+ " name='$name$',\n"
+ " full_name='$full_name$',\n"
+ " filename=None,\n"
+ " file=$file$,\n"
" create_key=_descriptor._internal_create_key,\n"
- " values=[\n";
+ " values=[\n";
TProtoStringType options_string;
- enum_descriptor.options().SerializeToString(&options_string);
- printer_->Print(m, enum_descriptor_template);
- printer_->Indent();
- printer_->Indent();
+ enum_descriptor.options().SerializeToString(&options_string);
+ printer_->Print(m, enum_descriptor_template);
+ printer_->Indent();
+ printer_->Indent();
if (pure_python_workable_) {
for (int i = 0; i < enum_descriptor.value_count(); ++i) {
PrintEnumValueDescriptor(*enum_descriptor.value(i));
printer_->Print(",\n");
}
- }
+ }
- printer_->Outdent();
- printer_->Print("],\n");
- printer_->Print("containing_type=None,\n");
+ printer_->Outdent();
+ printer_->Print("],\n");
+ printer_->Print("containing_type=None,\n");
printer_->Print("serialized_options=$options_value$,\n", "options_value",
OptionsValue(options_string));
- EnumDescriptorProto edp;
- PrintSerializedPbInterval(enum_descriptor, edp);
- printer_->Outdent();
- printer_->Print(")\n");
+ EnumDescriptorProto edp;
+ PrintSerializedPbInterval(enum_descriptor, edp);
+ printer_->Outdent();
+ printer_->Print(")\n");
if (pure_python_workable_) {
printer_->Print("_sym_db.RegisterEnumDescriptor($name$)\n", "name",
module_level_descriptor_name);
}
- printer_->Print("\n");
-}
-
-// Recursively prints enums in nested types within descriptor, then
-// prints enums contained at the top level in descriptor.
-void Generator::PrintNestedEnums(const Descriptor& descriptor) const {
- for (int i = 0; i < descriptor.nested_type_count(); ++i) {
- PrintNestedEnums(*descriptor.nested_type(i));
- }
-
- for (int i = 0; i < descriptor.enum_type_count(); ++i) {
- PrintEnum(*descriptor.enum_type(i));
- }
-}
-
-void Generator::PrintTopLevelExtensions() const {
- const bool is_extension = true;
- for (int i = 0; i < file_->extension_count(); ++i) {
- const FieldDescriptor& extension_field = *file_->extension(i);
+ printer_->Print("\n");
+}
+
+// Recursively prints enums in nested types within descriptor, then
+// prints enums contained at the top level in descriptor.
+void Generator::PrintNestedEnums(const Descriptor& descriptor) const {
+ for (int i = 0; i < descriptor.nested_type_count(); ++i) {
+ PrintNestedEnums(*descriptor.nested_type(i));
+ }
+
+ for (int i = 0; i < descriptor.enum_type_count(); ++i) {
+ PrintEnum(*descriptor.enum_type(i));
+ }
+}
+
+void Generator::PrintTopLevelExtensions() const {
+ const bool is_extension = true;
+ for (int i = 0; i < file_->extension_count(); ++i) {
+ const FieldDescriptor& extension_field = *file_->extension(i);
TProtoStringType constant_name = extension_field.name() + "_FIELD_NUMBER";
ToUpper(&constant_name);
printer_->Print("$constant_name$ = $number$\n", "constant_name",
@@ -584,20 +584,20 @@ void Generator::PrintTopLevelExtensions() const {
StrCat(extension_field.number()));
printer_->Print("$name$ = ", "name",
ResolveKeyword(extension_field.name()));
- PrintFieldDescriptor(extension_field, is_extension);
- printer_->Print("\n");
- }
- printer_->Print("\n");
-}
-
-// Prints Python equivalents of all Descriptors in |file|.
-void Generator::PrintMessageDescriptors() const {
- for (int i = 0; i < file_->message_type_count(); ++i) {
- PrintDescriptor(*file_->message_type(i));
- printer_->Print("\n");
- }
-}
-
+ PrintFieldDescriptor(extension_field, is_extension);
+ printer_->Print("\n");
+ }
+ printer_->Print("\n");
+}
+
+// Prints Python equivalents of all Descriptors in |file|.
+void Generator::PrintMessageDescriptors() const {
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ PrintDescriptor(*file_->message_type(i));
+ printer_->Print("\n");
+ }
+}
+
void Generator::PrintServiceDescriptors() const {
for (int i = 0; i < file_->service_count(); ++i) {
PrintServiceDescriptor(*file_->service(i));
@@ -606,57 +606,57 @@ void Generator::PrintServiceDescriptors() const {
}
}
-void Generator::PrintServices() const {
- for (int i = 0; i < file_->service_count(); ++i) {
- PrintServiceClass(*file_->service(i));
- PrintServiceStub(*file_->service(i));
- printer_->Print("\n");
- }
-}
-
-void Generator::PrintServiceDescriptor(
- const ServiceDescriptor& descriptor) const {
- printer_->Print("\n");
+void Generator::PrintServices() const {
+ for (int i = 0; i < file_->service_count(); ++i) {
+ PrintServiceClass(*file_->service(i));
+ PrintServiceStub(*file_->service(i));
+ printer_->Print("\n");
+ }
+}
+
+void Generator::PrintServiceDescriptor(
+ const ServiceDescriptor& descriptor) const {
+ printer_->Print("\n");
TProtoStringType service_name = ModuleLevelServiceDescriptorName(descriptor);
TProtoStringType options_string;
- descriptor.options().SerializeToString(&options_string);
-
+ descriptor.options().SerializeToString(&options_string);
+
printer_->Print("$service_name$ = _descriptor.ServiceDescriptor(\n",
"service_name", service_name);
- printer_->Indent();
+ printer_->Indent();
std::map<TProtoStringType, TProtoStringType> m;
- m["name"] = descriptor.name();
- m["full_name"] = descriptor.full_name();
- m["file"] = kDescriptorKey;
+ m["name"] = descriptor.name();
+ m["full_name"] = descriptor.full_name();
+ m["file"] = kDescriptorKey;
m["index"] = StrCat(descriptor.index());
m["options_value"] = OptionsValue(options_string);
- const char required_function_arguments[] =
- "name='$name$',\n"
- "full_name='$full_name$',\n"
- "file=$file$,\n"
- "index=$index$,\n"
+ const char required_function_arguments[] =
+ "name='$name$',\n"
+ "full_name='$full_name$',\n"
+ "file=$file$,\n"
+ "index=$index$,\n"
"serialized_options=$options_value$,\n"
"create_key=_descriptor._internal_create_key,\n";
- printer_->Print(m, required_function_arguments);
-
- ServiceDescriptorProto sdp;
- PrintSerializedPbInterval(descriptor, sdp);
-
- printer_->Print("methods=[\n");
- for (int i = 0; i < descriptor.method_count(); ++i) {
- const MethodDescriptor* method = descriptor.method(i);
- method->options().SerializeToString(&options_string);
-
- m.clear();
- m["name"] = method->name();
- m["full_name"] = method->full_name();
+ printer_->Print(m, required_function_arguments);
+
+ ServiceDescriptorProto sdp;
+ PrintSerializedPbInterval(descriptor, sdp);
+
+ printer_->Print("methods=[\n");
+ for (int i = 0; i < descriptor.method_count(); ++i) {
+ const MethodDescriptor* method = descriptor.method(i);
+ method->options().SerializeToString(&options_string);
+
+ m.clear();
+ m["name"] = method->name();
+ m["full_name"] = method->full_name();
m["index"] = StrCat(method->index());
- m["serialized_options"] = CEscape(options_string);
- m["input_type"] = ModuleLevelDescriptorName(*(method->input_type()));
- m["output_type"] = ModuleLevelDescriptorName(*(method->output_type()));
+ m["serialized_options"] = CEscape(options_string);
+ m["input_type"] = ModuleLevelDescriptorName(*(method->input_type()));
+ m["output_type"] = ModuleLevelDescriptorName(*(method->output_type()));
m["options_value"] = OptionsValue(options_string);
- printer_->Print("_descriptor.MethodDescriptor(\n");
- printer_->Indent();
+ printer_->Print("_descriptor.MethodDescriptor(\n");
+ printer_->Indent();
printer_->Print(m,
"name='$name$',\n"
"full_name='$full_name$',\n"
@@ -666,19 +666,19 @@ void Generator::PrintServiceDescriptor(
"output_type=$output_type$,\n"
"serialized_options=$options_value$,\n"
"create_key=_descriptor._internal_create_key,\n");
- printer_->Outdent();
- printer_->Print("),\n");
- }
-
- printer_->Outdent();
+ printer_->Outdent();
+ printer_->Print("),\n");
+ }
+
+ printer_->Outdent();
printer_->Print("])\n");
printer_->Print("_sym_db.RegisterServiceDescriptor($name$)\n", "name",
service_name);
printer_->Print("\n");
-}
-
-void Generator::PrintDescriptorKeyAndModuleName(
- const ServiceDescriptor& descriptor) const {
+}
+
+void Generator::PrintDescriptorKeyAndModuleName(
+ const ServiceDescriptor& descriptor) const {
TProtoStringType name = ModuleLevelServiceDescriptorName(descriptor);
if (!pure_python_workable_) {
name = "_descriptor.ServiceDescriptor(full_name='" +
@@ -688,165 +688,165 @@ void Generator::PrintDescriptorKeyAndModuleName(
kDescriptorKey, "descriptor_name", name);
TProtoStringType module_name = ModuleName(file_->name());
printer_->Print("__module__ = '$module_name$'\n", "module_name", module_name);
-}
-
-void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
- // Print the service.
+}
+
+void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
+ // Print the service.
printer_->Print(
"$class_name$ = service_reflection.GeneratedServiceType("
"'$class_name$', (_service.Service,), dict(\n",
"class_name", descriptor.name());
- printer_->Indent();
- Generator::PrintDescriptorKeyAndModuleName(descriptor);
- printer_->Print("))\n\n");
- printer_->Outdent();
-}
-
-void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
- // Print the service stub.
+ printer_->Indent();
+ Generator::PrintDescriptorKeyAndModuleName(descriptor);
+ printer_->Print("))\n\n");
+ printer_->Outdent();
+}
+
+void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
+ // Print the service stub.
printer_->Print(
"$class_name$_Stub = "
"service_reflection.GeneratedServiceStubType("
"'$class_name$_Stub', ($class_name$,), dict(\n",
"class_name", descriptor.name());
- printer_->Indent();
- Generator::PrintDescriptorKeyAndModuleName(descriptor);
- printer_->Print("))\n\n");
- printer_->Outdent();
-}
-
-// Prints statement assigning ModuleLevelDescriptorName(message_descriptor)
-// to a Python Descriptor object for message_descriptor.
-//
-// Mutually recursive with PrintNestedDescriptors().
-void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
- PrintNestedDescriptors(message_descriptor);
-
- printer_->Print("\n");
- printer_->Print("$descriptor_name$ = _descriptor.Descriptor(\n",
- "descriptor_name",
- ModuleLevelDescriptorName(message_descriptor));
- printer_->Indent();
+ printer_->Indent();
+ Generator::PrintDescriptorKeyAndModuleName(descriptor);
+ printer_->Print("))\n\n");
+ printer_->Outdent();
+}
+
+// Prints statement assigning ModuleLevelDescriptorName(message_descriptor)
+// to a Python Descriptor object for message_descriptor.
+//
+// Mutually recursive with PrintNestedDescriptors().
+void Generator::PrintDescriptor(const Descriptor& message_descriptor) const {
+ PrintNestedDescriptors(message_descriptor);
+
+ printer_->Print("\n");
+ printer_->Print("$descriptor_name$ = _descriptor.Descriptor(\n",
+ "descriptor_name",
+ ModuleLevelDescriptorName(message_descriptor));
+ printer_->Indent();
std::map<TProtoStringType, TProtoStringType> m;
- m["name"] = message_descriptor.name();
- m["full_name"] = message_descriptor.full_name();
- m["file"] = kDescriptorKey;
- const char required_function_arguments[] =
- "name='$name$',\n"
- "full_name='$full_name$',\n"
- "filename=None,\n"
- "file=$file$,\n"
+ m["name"] = message_descriptor.name();
+ m["full_name"] = message_descriptor.full_name();
+ m["file"] = kDescriptorKey;
+ const char required_function_arguments[] =
+ "name='$name$',\n"
+ "full_name='$full_name$',\n"
+ "filename=None,\n"
+ "file=$file$,\n"
"containing_type=None,\n"
"create_key=_descriptor._internal_create_key,\n";
- printer_->Print(m, required_function_arguments);
- PrintFieldsInDescriptor(message_descriptor);
- PrintExtensionsInDescriptor(message_descriptor);
-
- // Nested types
- printer_->Print("nested_types=[");
- for (int i = 0; i < message_descriptor.nested_type_count(); ++i) {
+ printer_->Print(m, required_function_arguments);
+ PrintFieldsInDescriptor(message_descriptor);
+ PrintExtensionsInDescriptor(message_descriptor);
+
+ // Nested types
+ printer_->Print("nested_types=[");
+ for (int i = 0; i < message_descriptor.nested_type_count(); ++i) {
const TProtoStringType nested_name =
ModuleLevelDescriptorName(*message_descriptor.nested_type(i));
- printer_->Print("$name$, ", "name", nested_name);
- }
- printer_->Print("],\n");
-
- // Enum types
- printer_->Print("enum_types=[\n");
- printer_->Indent();
- for (int i = 0; i < message_descriptor.enum_type_count(); ++i) {
+ printer_->Print("$name$, ", "name", nested_name);
+ }
+ printer_->Print("],\n");
+
+ // Enum types
+ printer_->Print("enum_types=[\n");
+ printer_->Indent();
+ for (int i = 0; i < message_descriptor.enum_type_count(); ++i) {
const TProtoStringType descriptor_name =
ModuleLevelDescriptorName(*message_descriptor.enum_type(i));
- printer_->Print(descriptor_name.c_str());
- printer_->Print(",\n");
- }
- printer_->Outdent();
- printer_->Print("],\n");
+ printer_->Print(descriptor_name.c_str());
+ printer_->Print(",\n");
+ }
+ printer_->Outdent();
+ printer_->Print("],\n");
TProtoStringType options_string;
- message_descriptor.options().SerializeToString(&options_string);
- printer_->Print(
+ message_descriptor.options().SerializeToString(&options_string);
+ printer_->Print(
"serialized_options=$options_value$,\n"
- "is_extendable=$extendable$,\n"
- "syntax='$syntax$'",
+ "is_extendable=$extendable$,\n"
+ "syntax='$syntax$'",
"options_value", OptionsValue(options_string), "extendable",
message_descriptor.extension_range_count() > 0 ? "True" : "False",
- "syntax", StringifySyntax(message_descriptor.file()->syntax()));
- printer_->Print(",\n");
-
- // Extension ranges
- printer_->Print("extension_ranges=[");
- for (int i = 0; i < message_descriptor.extension_range_count(); ++i) {
- const Descriptor::ExtensionRange* range =
- message_descriptor.extension_range(i);
+ "syntax", StringifySyntax(message_descriptor.file()->syntax()));
+ printer_->Print(",\n");
+
+ // Extension ranges
+ printer_->Print("extension_ranges=[");
+ for (int i = 0; i < message_descriptor.extension_range_count(); ++i) {
+ const Descriptor::ExtensionRange* range =
+ message_descriptor.extension_range(i);
printer_->Print("($start$, $end$), ", "start", StrCat(range->start),
"end", StrCat(range->end));
- }
- printer_->Print("],\n");
- printer_->Print("oneofs=[\n");
- printer_->Indent();
- for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) {
- const OneofDescriptor* desc = message_descriptor.oneof_decl(i);
+ }
+ printer_->Print("],\n");
+ printer_->Print("oneofs=[\n");
+ printer_->Indent();
+ for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) {
+ const OneofDescriptor* desc = message_descriptor.oneof_decl(i);
std::map<TProtoStringType, TProtoStringType> m;
- m["name"] = desc->name();
- m["full_name"] = desc->full_name();
+ m["name"] = desc->name();
+ m["full_name"] = desc->full_name();
m["index"] = StrCat(desc->index());
TProtoStringType options_string =
OptionsValue(desc->options().SerializeAsString());
- if (options_string == "None") {
+ if (options_string == "None") {
m["serialized_options"] = "";
- } else {
+ } else {
m["serialized_options"] = ", serialized_options=" + options_string;
- }
+ }
printer_->Print(m,
"_descriptor.OneofDescriptor(\n"
" name='$name$', full_name='$full_name$',\n"
" index=$index$, containing_type=None,\n"
" create_key=_descriptor._internal_create_key,\n"
"fields=[]$serialized_options$),\n");
- }
- printer_->Outdent();
- printer_->Print("],\n");
- // Serialization of proto
- DescriptorProto edp;
- PrintSerializedPbInterval(message_descriptor, edp);
-
- printer_->Outdent();
- printer_->Print(")\n");
-}
-
-// Prints Python Descriptor objects for all nested types contained in
-// message_descriptor.
-//
-// Mutually recursive with PrintDescriptor().
-void Generator::PrintNestedDescriptors(
- const Descriptor& containing_descriptor) const {
- for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
- PrintDescriptor(*containing_descriptor.nested_type(i));
- }
-}
-
-// Prints all messages in |file|.
-void Generator::PrintMessages() const {
- for (int i = 0; i < file_->message_type_count(); ++i) {
+ }
+ printer_->Outdent();
+ printer_->Print("],\n");
+ // Serialization of proto
+ DescriptorProto edp;
+ PrintSerializedPbInterval(message_descriptor, edp);
+
+ printer_->Outdent();
+ printer_->Print(")\n");
+}
+
+// Prints Python Descriptor objects for all nested types contained in
+// message_descriptor.
+//
+// Mutually recursive with PrintDescriptor().
+void Generator::PrintNestedDescriptors(
+ const Descriptor& containing_descriptor) const {
+ for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
+ PrintDescriptor(*containing_descriptor.nested_type(i));
+ }
+}
+
+// Prints all messages in |file|.
+void Generator::PrintMessages() const {
+ for (int i = 0; i < file_->message_type_count(); ++i) {
std::vector<TProtoStringType> to_register;
PrintMessage(*file_->message_type(i), "", &to_register, false);
- for (int j = 0; j < to_register.size(); ++j) {
- printer_->Print("_sym_db.RegisterMessage($name$)\n", "name",
+ for (int j = 0; j < to_register.size(); ++j) {
+ printer_->Print("_sym_db.RegisterMessage($name$)\n", "name",
ResolveKeyword(to_register[j]));
- }
- printer_->Print("\n");
- }
-}
-
-// Prints a Python class for the given message descriptor. We defer to the
-// metaclass to do almost all of the work of actually creating a useful class.
-// The purpose of this function and its many helper functions above is merely
-// to output a Python version of the descriptors, which the metaclass in
-// reflection.py will use to construct the meat of the class itself.
-//
-// Mutually recursive with PrintNestedMessages().
-// Collect nested message names to_register for the symbol_database.
-void Generator::PrintMessage(const Descriptor& message_descriptor,
+ }
+ printer_->Print("\n");
+ }
+}
+
+// Prints a Python class for the given message descriptor. We defer to the
+// metaclass to do almost all of the work of actually creating a useful class.
+// The purpose of this function and its many helper functions above is merely
+// to output a Python version of the descriptors, which the metaclass in
+// reflection.py will use to construct the meat of the class itself.
+//
+// Mutually recursive with PrintNestedMessages().
+// Collect nested message names to_register for the symbol_database.
+void Generator::PrintMessage(const Descriptor& message_descriptor,
const TProtoStringType& prefix,
std::vector<TProtoStringType>* to_register,
bool is_nested) const {
@@ -869,13 +869,13 @@ void Generator::PrintMessage(const Descriptor& message_descriptor,
"(_message.Message,), {\n",
"qualified_name", qualified_name, "name", message_descriptor.name());
}
- printer_->Indent();
-
+ printer_->Indent();
+
to_register->push_back(qualified_name);
PrintNestedMessages(message_descriptor, qualified_name, to_register);
std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_key"] = kDescriptorKey;
+ m["descriptor_key"] = kDescriptorKey;
if (pure_python_workable_) {
m["descriptor_name"] = ModuleLevelDescriptorName(message_descriptor);
} else {
@@ -886,79 +886,79 @@ void Generator::PrintMessage(const Descriptor& message_descriptor,
TProtoStringType module_name = ModuleName(file_->name());
printer_->Print("'__module__' : '$module_name$'\n", "module_name",
module_name);
- printer_->Print("# @@protoc_insertion_point(class_scope:$full_name$)\n",
- "full_name", message_descriptor.full_name());
+ printer_->Print("# @@protoc_insertion_point(class_scope:$full_name$)\n",
+ "full_name", message_descriptor.full_name());
printer_->Print("})\n");
- printer_->Outdent();
-}
-
-// Prints all nested messages within |containing_descriptor|.
-// Mutually recursive with PrintMessage().
+ printer_->Outdent();
+}
+
+// Prints all nested messages within |containing_descriptor|.
+// Mutually recursive with PrintMessage().
void Generator::PrintNestedMessages(
const Descriptor& containing_descriptor, const TProtoStringType& prefix,
std::vector<TProtoStringType>* to_register) const {
- for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
- printer_->Print("\n");
+ for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {
+ printer_->Print("\n");
PrintMessage(*containing_descriptor.nested_type(i), prefix, to_register,
true);
- printer_->Print(",\n");
- }
-}
-
-// Recursively fixes foreign fields in all nested types in |descriptor|, then
-// sets the message_type and enum_type of all message and enum fields to point
-// to their respective descriptors.
-// Args:
-// descriptor: descriptor to print fields for.
-// containing_descriptor: if descriptor is a nested type, this is its
-// containing type, or NULL if this is a root/top-level type.
-void Generator::FixForeignFieldsInDescriptor(
- const Descriptor& descriptor,
- const Descriptor* containing_descriptor) const {
- for (int i = 0; i < descriptor.nested_type_count(); ++i) {
- FixForeignFieldsInDescriptor(*descriptor.nested_type(i), &descriptor);
- }
-
- for (int i = 0; i < descriptor.field_count(); ++i) {
- const FieldDescriptor& field_descriptor = *descriptor.field(i);
- FixForeignFieldsInField(&descriptor, field_descriptor, "fields_by_name");
- }
-
- FixContainingTypeInDescriptor(descriptor, containing_descriptor);
- for (int i = 0; i < descriptor.enum_type_count(); ++i) {
- const EnumDescriptor& enum_descriptor = *descriptor.enum_type(i);
- FixContainingTypeInDescriptor(enum_descriptor, &descriptor);
- }
- for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {
+ printer_->Print(",\n");
+ }
+}
+
+// Recursively fixes foreign fields in all nested types in |descriptor|, then
+// sets the message_type and enum_type of all message and enum fields to point
+// to their respective descriptors.
+// Args:
+// descriptor: descriptor to print fields for.
+// containing_descriptor: if descriptor is a nested type, this is its
+// containing type, or NULL if this is a root/top-level type.
+void Generator::FixForeignFieldsInDescriptor(
+ const Descriptor& descriptor,
+ const Descriptor* containing_descriptor) const {
+ for (int i = 0; i < descriptor.nested_type_count(); ++i) {
+ FixForeignFieldsInDescriptor(*descriptor.nested_type(i), &descriptor);
+ }
+
+ for (int i = 0; i < descriptor.field_count(); ++i) {
+ const FieldDescriptor& field_descriptor = *descriptor.field(i);
+ FixForeignFieldsInField(&descriptor, field_descriptor, "fields_by_name");
+ }
+
+ FixContainingTypeInDescriptor(descriptor, containing_descriptor);
+ for (int i = 0; i < descriptor.enum_type_count(); ++i) {
+ const EnumDescriptor& enum_descriptor = *descriptor.enum_type(i);
+ FixContainingTypeInDescriptor(enum_descriptor, &descriptor);
+ }
+ for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {
std::map<TProtoStringType, TProtoStringType> m;
- const OneofDescriptor* oneof = descriptor.oneof_decl(i);
- m["descriptor_name"] = ModuleLevelDescriptorName(descriptor);
- m["oneof_name"] = oneof->name();
- for (int j = 0; j < oneof->field_count(); ++j) {
- m["field_name"] = oneof->field(j)->name();
- printer_->Print(
- m,
- "$descriptor_name$.oneofs_by_name['$oneof_name$'].fields.append(\n"
- " $descriptor_name$.fields_by_name['$field_name$'])\n");
- printer_->Print(
- m,
- "$descriptor_name$.fields_by_name['$field_name$'].containing_oneof = "
- "$descriptor_name$.oneofs_by_name['$oneof_name$']\n");
- }
- }
-}
-
-void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {
+ const OneofDescriptor* oneof = descriptor.oneof_decl(i);
+ m["descriptor_name"] = ModuleLevelDescriptorName(descriptor);
+ m["oneof_name"] = oneof->name();
+ for (int j = 0; j < oneof->field_count(); ++j) {
+ m["field_name"] = oneof->field(j)->name();
+ printer_->Print(
+ m,
+ "$descriptor_name$.oneofs_by_name['$oneof_name$'].fields.append(\n"
+ " $descriptor_name$.fields_by_name['$field_name$'])\n");
+ printer_->Print(
+ m,
+ "$descriptor_name$.fields_by_name['$field_name$'].containing_oneof = "
+ "$descriptor_name$.oneofs_by_name['$oneof_name$']\n");
+ }
+ }
+}
+
+void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_name"] = kDescriptorKey;
- m["message_name"] = descriptor.name();
- m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
- const char file_descriptor_template[] =
- "$descriptor_name$.message_types_by_name['$message_name$'] = "
- "$message_descriptor_name$\n";
- printer_->Print(m, file_descriptor_template);
-}
-
+ m["descriptor_name"] = kDescriptorKey;
+ m["message_name"] = descriptor.name();
+ m["message_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
+ const char file_descriptor_template[] =
+ "$descriptor_name$.message_types_by_name['$message_name$'] = "
+ "$message_descriptor_name$\n";
+ printer_->Print(m, file_descriptor_template);
+}
+
void Generator::AddServiceToFileDescriptor(
const ServiceDescriptor& descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
@@ -971,178 +971,178 @@ void Generator::AddServiceToFileDescriptor(
printer_->Print(m, file_descriptor_template);
}
-void Generator::AddEnumToFileDescriptor(
- const EnumDescriptor& descriptor) const {
+void Generator::AddEnumToFileDescriptor(
+ const EnumDescriptor& descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_name"] = kDescriptorKey;
- m["enum_name"] = descriptor.name();
- m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
- const char file_descriptor_template[] =
- "$descriptor_name$.enum_types_by_name['$enum_name$'] = "
- "$enum_descriptor_name$\n";
- printer_->Print(m, file_descriptor_template);
-}
-
-void Generator::AddExtensionToFileDescriptor(
- const FieldDescriptor& descriptor) const {
+ m["descriptor_name"] = kDescriptorKey;
+ m["enum_name"] = descriptor.name();
+ m["enum_descriptor_name"] = ModuleLevelDescriptorName(descriptor);
+ const char file_descriptor_template[] =
+ "$descriptor_name$.enum_types_by_name['$enum_name$'] = "
+ "$enum_descriptor_name$\n";
+ printer_->Print(m, file_descriptor_template);
+}
+
+void Generator::AddExtensionToFileDescriptor(
+ const FieldDescriptor& descriptor) const {
std::map<TProtoStringType, TProtoStringType> m;
- m["descriptor_name"] = kDescriptorKey;
- m["field_name"] = descriptor.name();
+ m["descriptor_name"] = kDescriptorKey;
+ m["field_name"] = descriptor.name();
m["resolved_name"] = ResolveKeyword(descriptor.name());
- const char file_descriptor_template[] =
- "$descriptor_name$.extensions_by_name['$field_name$'] = "
+ const char file_descriptor_template[] =
+ "$descriptor_name$.extensions_by_name['$field_name$'] = "
"$resolved_name$\n";
- printer_->Print(m, file_descriptor_template);
-}
-
-// Sets any necessary message_type and enum_type attributes
-// for the Python version of |field|.
-//
-// containing_type may be NULL, in which case this is a module-level field.
-//
-// python_dict_name is the name of the Python dict where we should
-// look the field up in the containing type. (e.g., fields_by_name
-// or extensions_by_name). We ignore python_dict_name if containing_type
-// is NULL.
+ printer_->Print(m, file_descriptor_template);
+}
+
+// Sets any necessary message_type and enum_type attributes
+// for the Python version of |field|.
+//
+// containing_type may be NULL, in which case this is a module-level field.
+//
+// python_dict_name is the name of the Python dict where we should
+// look the field up in the containing type. (e.g., fields_by_name
+// or extensions_by_name). We ignore python_dict_name if containing_type
+// is NULL.
void Generator::FixForeignFieldsInField(
const Descriptor* containing_type, const FieldDescriptor& field,
const TProtoStringType& python_dict_name) const {
const TProtoStringType field_referencing_expression =
FieldReferencingExpression(containing_type, field, python_dict_name);
std::map<TProtoStringType, TProtoStringType> m;
- m["field_ref"] = field_referencing_expression;
- const Descriptor* foreign_message_type = field.message_type();
- if (foreign_message_type) {
- m["foreign_type"] = ModuleLevelDescriptorName(*foreign_message_type);
- printer_->Print(m, "$field_ref$.message_type = $foreign_type$\n");
- }
- const EnumDescriptor* enum_type = field.enum_type();
- if (enum_type) {
- m["enum_type"] = ModuleLevelDescriptorName(*enum_type);
- printer_->Print(m, "$field_ref$.enum_type = $enum_type$\n");
- }
-}
-
-// Returns the module-level expression for the given FieldDescriptor.
-// Only works for fields in the .proto file this Generator is generating for.
-//
-// containing_type may be NULL, in which case this is a module-level field.
-//
-// python_dict_name is the name of the Python dict where we should
-// look the field up in the containing type. (e.g., fields_by_name
-// or extensions_by_name). We ignore python_dict_name if containing_type
-// is NULL.
+ m["field_ref"] = field_referencing_expression;
+ const Descriptor* foreign_message_type = field.message_type();
+ if (foreign_message_type) {
+ m["foreign_type"] = ModuleLevelDescriptorName(*foreign_message_type);
+ printer_->Print(m, "$field_ref$.message_type = $foreign_type$\n");
+ }
+ const EnumDescriptor* enum_type = field.enum_type();
+ if (enum_type) {
+ m["enum_type"] = ModuleLevelDescriptorName(*enum_type);
+ printer_->Print(m, "$field_ref$.enum_type = $enum_type$\n");
+ }
+}
+
+// Returns the module-level expression for the given FieldDescriptor.
+// Only works for fields in the .proto file this Generator is generating for.
+//
+// containing_type may be NULL, in which case this is a module-level field.
+//
+// python_dict_name is the name of the Python dict where we should
+// look the field up in the containing type. (e.g., fields_by_name
+// or extensions_by_name). We ignore python_dict_name if containing_type
+// is NULL.
TProtoStringType Generator::FieldReferencingExpression(
const Descriptor* containing_type, const FieldDescriptor& field,
const TProtoStringType& python_dict_name) const {
- // We should only ever be looking up fields in the current file.
- // The only things we refer to from other files are message descriptors.
+ // We should only ever be looking up fields in the current file.
+ // The only things we refer to from other files are message descriptors.
GOOGLE_CHECK_EQ(field.file(), file_)
<< field.file()->name() << " vs. " << file_->name();
- if (!containing_type) {
+ if (!containing_type) {
return ResolveKeyword(field.name());
- }
+ }
return strings::Substitute("$0.$1['$2']",
ModuleLevelDescriptorName(*containing_type),
python_dict_name, field.name());
-}
-
-// Prints containing_type for nested descriptors or enum descriptors.
-template <typename DescriptorT>
-void Generator::FixContainingTypeInDescriptor(
- const DescriptorT& descriptor,
- const Descriptor* containing_descriptor) const {
+}
+
+// Prints containing_type for nested descriptors or enum descriptors.
+template <typename DescriptorT>
+void Generator::FixContainingTypeInDescriptor(
+ const DescriptorT& descriptor,
+ const Descriptor* containing_descriptor) const {
if (containing_descriptor != nullptr) {
const TProtoStringType nested_name = ModuleLevelDescriptorName(descriptor);
const TProtoStringType parent_name =
ModuleLevelDescriptorName(*containing_descriptor);
printer_->Print("$nested_name$.containing_type = $parent_name$\n",
"nested_name", nested_name, "parent_name", parent_name);
- }
-}
-
-// Prints statements setting the message_type and enum_type fields in the
+ }
+}
+
+// Prints statements setting the message_type and enum_type fields in the
// Python descriptor objects we've already output in the file. We must
-// do this in a separate step due to circular references (otherwise, we'd
-// just set everything in the initial assignment statements).
-void Generator::FixForeignFieldsInDescriptors() const {
- for (int i = 0; i < file_->message_type_count(); ++i) {
+// do this in a separate step due to circular references (otherwise, we'd
+// just set everything in the initial assignment statements).
+void Generator::FixForeignFieldsInDescriptors() const {
+ for (int i = 0; i < file_->message_type_count(); ++i) {
FixForeignFieldsInDescriptor(*file_->message_type(i), nullptr);
- }
- for (int i = 0; i < file_->message_type_count(); ++i) {
- AddMessageToFileDescriptor(*file_->message_type(i));
- }
- for (int i = 0; i < file_->enum_type_count(); ++i) {
- AddEnumToFileDescriptor(*file_->enum_type(i));
- }
- for (int i = 0; i < file_->extension_count(); ++i) {
- AddExtensionToFileDescriptor(*file_->extension(i));
- }
+ }
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ AddMessageToFileDescriptor(*file_->message_type(i));
+ }
+ for (int i = 0; i < file_->enum_type_count(); ++i) {
+ AddEnumToFileDescriptor(*file_->enum_type(i));
+ }
+ for (int i = 0; i < file_->extension_count(); ++i) {
+ AddExtensionToFileDescriptor(*file_->extension(i));
+ }
// TODO(jieluo): Move this register to PrintFileDescriptor() when
// FieldDescriptor.file is added in generated file.
printer_->Print("_sym_db.RegisterFileDescriptor($name$)\n", "name",
kDescriptorKey);
- printer_->Print("\n");
-}
-
-// We need to not only set any necessary message_type fields, but
-// also need to call RegisterExtension() on each message we're
-// extending.
-void Generator::FixForeignFieldsInExtensions() const {
- // Top-level extensions.
- for (int i = 0; i < file_->extension_count(); ++i) {
- FixForeignFieldsInExtension(*file_->extension(i));
- }
- // Nested extensions.
- for (int i = 0; i < file_->message_type_count(); ++i) {
- FixForeignFieldsInNestedExtensions(*file_->message_type(i));
- }
- printer_->Print("\n");
-}
-
-void Generator::FixForeignFieldsInExtension(
- const FieldDescriptor& extension_field) const {
- GOOGLE_CHECK(extension_field.is_extension());
- // extension_scope() will be NULL for top-level extensions, which is
- // exactly what FixForeignFieldsInField() wants.
- FixForeignFieldsInField(extension_field.extension_scope(), extension_field,
- "extensions_by_name");
-
+ printer_->Print("\n");
+}
+
+// We need to not only set any necessary message_type fields, but
+// also need to call RegisterExtension() on each message we're
+// extending.
+void Generator::FixForeignFieldsInExtensions() const {
+ // Top-level extensions.
+ for (int i = 0; i < file_->extension_count(); ++i) {
+ FixForeignFieldsInExtension(*file_->extension(i));
+ }
+ // Nested extensions.
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ FixForeignFieldsInNestedExtensions(*file_->message_type(i));
+ }
+ printer_->Print("\n");
+}
+
+void Generator::FixForeignFieldsInExtension(
+ const FieldDescriptor& extension_field) const {
+ GOOGLE_CHECK(extension_field.is_extension());
+ // extension_scope() will be NULL for top-level extensions, which is
+ // exactly what FixForeignFieldsInField() wants.
+ FixForeignFieldsInField(extension_field.extension_scope(), extension_field,
+ "extensions_by_name");
+
std::map<TProtoStringType, TProtoStringType> m;
- // Confusingly, for FieldDescriptors that happen to be extensions,
- // containing_type() means "extended type."
- // On the other hand, extension_scope() will give us what we normally
- // mean by containing_type().
+ // Confusingly, for FieldDescriptors that happen to be extensions,
+ // containing_type() means "extended type."
+ // On the other hand, extension_scope() will give us what we normally
+ // mean by containing_type().
m["extended_message_class"] =
ModuleLevelMessageName(*extension_field.containing_type());
m["field"] = FieldReferencingExpression(
extension_field.extension_scope(), extension_field, "extensions_by_name");
- printer_->Print(m, "$extended_message_class$.RegisterExtension($field$)\n");
-}
-
-void Generator::FixForeignFieldsInNestedExtensions(
- const Descriptor& descriptor) const {
- // Recursively fix up extensions in all nested types.
- for (int i = 0; i < descriptor.nested_type_count(); ++i) {
- FixForeignFieldsInNestedExtensions(*descriptor.nested_type(i));
- }
- // Fix up extensions directly contained within this type.
- for (int i = 0; i < descriptor.extension_count(); ++i) {
- FixForeignFieldsInExtension(*descriptor.extension(i));
- }
-}
-
-// Returns a Python expression that instantiates a Python EnumValueDescriptor
-// object for the given C++ descriptor.
-void Generator::PrintEnumValueDescriptor(
- const EnumValueDescriptor& descriptor) const {
- // TODO(robinson): Fix up EnumValueDescriptor "type" fields.
- // More circular references. ::sigh::
+ printer_->Print(m, "$extended_message_class$.RegisterExtension($field$)\n");
+}
+
+void Generator::FixForeignFieldsInNestedExtensions(
+ const Descriptor& descriptor) const {
+ // Recursively fix up extensions in all nested types.
+ for (int i = 0; i < descriptor.nested_type_count(); ++i) {
+ FixForeignFieldsInNestedExtensions(*descriptor.nested_type(i));
+ }
+ // Fix up extensions directly contained within this type.
+ for (int i = 0; i < descriptor.extension_count(); ++i) {
+ FixForeignFieldsInExtension(*descriptor.extension(i));
+ }
+}
+
+// Returns a Python expression that instantiates a Python EnumValueDescriptor
+// object for the given C++ descriptor.
+void Generator::PrintEnumValueDescriptor(
+ const EnumValueDescriptor& descriptor) const {
+ // TODO(robinson): Fix up EnumValueDescriptor "type" fields.
+ // More circular references. ::sigh::
TProtoStringType options_string;
- descriptor.options().SerializeToString(&options_string);
+ descriptor.options().SerializeToString(&options_string);
std::map<TProtoStringType, TProtoStringType> m;
- m["name"] = descriptor.name();
+ m["name"] = descriptor.name();
m["index"] = StrCat(descriptor.index());
m["number"] = StrCat(descriptor.number());
m["options"] = OptionsValue(options_string);
@@ -1152,41 +1152,41 @@ void Generator::PrintEnumValueDescriptor(
" serialized_options=$options$,\n"
" type=None,\n"
" create_key=_descriptor._internal_create_key)");
-}
-
+}
+
// Returns a CEscaped string of serialized_options.
TProtoStringType Generator::OptionsValue(
const TProtoStringType& serialized_options) const {
- if (serialized_options.length() == 0 || GeneratingDescriptorProto()) {
- return "None";
- } else {
+ if (serialized_options.length() == 0 || GeneratingDescriptorProto()) {
+ return "None";
+ } else {
return "b'" + CEscape(serialized_options) + "'";
- }
-}
-
-// Prints an expression for a Python FieldDescriptor for |field|.
+ }
+}
+
+// Prints an expression for a Python FieldDescriptor for |field|.
void Generator::PrintFieldDescriptor(const FieldDescriptor& field,
bool is_extension) const {
TProtoStringType options_string;
- field.options().SerializeToString(&options_string);
+ field.options().SerializeToString(&options_string);
std::map<TProtoStringType, TProtoStringType> m;
- m["name"] = field.name();
- m["full_name"] = field.full_name();
+ m["name"] = field.name();
+ m["full_name"] = field.full_name();
m["index"] = StrCat(field.index());
m["number"] = StrCat(field.number());
m["type"] = StrCat(field.type());
m["cpp_type"] = StrCat(field.cpp_type());
m["label"] = StrCat(field.label());
- m["has_default_value"] = field.has_default_value() ? "True" : "False";
- m["default_value"] = StringifyDefaultValue(field);
- m["is_extension"] = is_extension ? "True" : "False";
+ m["has_default_value"] = field.has_default_value() ? "True" : "False";
+ m["default_value"] = StringifyDefaultValue(field);
+ m["is_extension"] = is_extension ? "True" : "False";
m["serialized_options"] = OptionsValue(options_string);
m["json_name"] =
field.has_json_name() ? ", json_name='" + field.json_name() + "'" : "";
- // We always set message_type and enum_type to None at this point, and then
- // these fields in correctly after all referenced descriptors have been
- // defined and/or imported (see FixForeignFieldsInDescriptors()).
- const char field_descriptor_decl[] =
+ // We always set message_type and enum_type to None at this point, and then
+ // these fields in correctly after all referenced descriptors have been
+ // defined and/or imported (see FixForeignFieldsInDescriptors()).
+ const char field_descriptor_decl[] =
"_descriptor.FieldDescriptor(\n"
" name='$name$', full_name='$full_name$', index=$index$,\n"
" number=$number$, type=$type$, cpp_type=$cpp_type$, label=$label$,\n"
@@ -1196,258 +1196,258 @@ void Generator::PrintFieldDescriptor(const FieldDescriptor& field,
" is_extension=$is_extension$, extension_scope=None,\n"
" serialized_options=$serialized_options$$json_name$, file=DESCRIPTOR,"
" create_key=_descriptor._internal_create_key)";
- printer_->Print(m, field_descriptor_decl);
-}
-
-// Helper for Print{Fields,Extensions}InDescriptor().
-void Generator::PrintFieldDescriptorsInDescriptor(
+ printer_->Print(m, field_descriptor_decl);
+}
+
+// Helper for Print{Fields,Extensions}InDescriptor().
+void Generator::PrintFieldDescriptorsInDescriptor(
const Descriptor& message_descriptor, bool is_extension,
const TProtoStringType& list_variable_name, int (Descriptor::*CountFn)() const,
const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const {
- printer_->Print("$list$=[\n", "list", list_variable_name);
- printer_->Indent();
- for (int i = 0; i < (message_descriptor.*CountFn)(); ++i) {
+ printer_->Print("$list$=[\n", "list", list_variable_name);
+ printer_->Indent();
+ for (int i = 0; i < (message_descriptor.*CountFn)(); ++i) {
PrintFieldDescriptor(*(message_descriptor.*GetterFn)(i), is_extension);
- printer_->Print(",\n");
- }
- printer_->Outdent();
- printer_->Print("],\n");
-}
-
-// Prints a statement assigning "fields" to a list of Python FieldDescriptors,
-// one for each field present in message_descriptor.
-void Generator::PrintFieldsInDescriptor(
- const Descriptor& message_descriptor) const {
- const bool is_extension = false;
+ printer_->Print(",\n");
+ }
+ printer_->Outdent();
+ printer_->Print("],\n");
+}
+
+// Prints a statement assigning "fields" to a list of Python FieldDescriptors,
+// one for each field present in message_descriptor.
+void Generator::PrintFieldsInDescriptor(
+ const Descriptor& message_descriptor) const {
+ const bool is_extension = false;
PrintFieldDescriptorsInDescriptor(message_descriptor, is_extension, "fields",
&Descriptor::field_count,
&Descriptor::field);
-}
-
-// Prints a statement assigning "extensions" to a list of Python
-// FieldDescriptors, one for each extension present in message_descriptor.
-void Generator::PrintExtensionsInDescriptor(
- const Descriptor& message_descriptor) const {
- const bool is_extension = true;
+}
+
+// Prints a statement assigning "extensions" to a list of Python
+// FieldDescriptors, one for each extension present in message_descriptor.
+void Generator::PrintExtensionsInDescriptor(
+ const Descriptor& message_descriptor) const {
+ const bool is_extension = true;
PrintFieldDescriptorsInDescriptor(message_descriptor, is_extension,
"extensions", &Descriptor::extension_count,
&Descriptor::extension);
-}
-
-bool Generator::GeneratingDescriptorProto() const {
+}
+
+bool Generator::GeneratingDescriptorProto() const {
return file_->name() == "net/proto2/proto/descriptor.proto" ||
file_->name() == "google/protobuf/descriptor.proto";
-}
-
-// Returns the unique Python module-level identifier given to a descriptor.
-// This name is module-qualified iff the given descriptor describes an
-// entity that doesn't come from the current file.
-template <typename DescriptorT>
+}
+
+// Returns the unique Python module-level identifier given to a descriptor.
+// This name is module-qualified iff the given descriptor describes an
+// entity that doesn't come from the current file.
+template <typename DescriptorT>
TProtoStringType Generator::ModuleLevelDescriptorName(
- const DescriptorT& descriptor) const {
- // FIXME(robinson):
- // We currently don't worry about collisions with underscores in the type
- // names, so these would collide in nasty ways if found in the same file:
- // OuterProto.ProtoA.ProtoB
- // OuterProto_ProtoA.ProtoB # Underscore instead of period.
- // As would these:
- // OuterProto.ProtoA_.ProtoB
- // OuterProto.ProtoA._ProtoB # Leading vs. trailing underscore.
- // (Contrived, but certainly possible).
- //
- // The C++ implementation doesn't guard against this either. Leaving
- // it for now...
+ const DescriptorT& descriptor) const {
+ // FIXME(robinson):
+ // We currently don't worry about collisions with underscores in the type
+ // names, so these would collide in nasty ways if found in the same file:
+ // OuterProto.ProtoA.ProtoB
+ // OuterProto_ProtoA.ProtoB # Underscore instead of period.
+ // As would these:
+ // OuterProto.ProtoA_.ProtoB
+ // OuterProto.ProtoA._ProtoB # Leading vs. trailing underscore.
+ // (Contrived, but certainly possible).
+ //
+ // The C++ implementation doesn't guard against this either. Leaving
+ // it for now...
TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, "_");
ToUpper(&name);
- // Module-private for now. Easy to make public later; almost impossible
- // to make private later.
- name = "_" + name;
- // We now have the name relative to its own module. Also qualify with
- // the module name iff this descriptor is from a different .proto file.
- if (descriptor.file() != file_) {
+ // Module-private for now. Easy to make public later; almost impossible
+ // to make private later.
+ name = "_" + name;
+ // We now have the name relative to its own module. Also qualify with
+ // the module name iff this descriptor is from a different .proto file.
+ if (descriptor.file() != file_) {
name = ModuleAlias(descriptor.file()->name()) + "." + name;
- }
- return name;
-}
-
-// Returns the name of the message class itself, not the descriptor.
-// Like ModuleLevelDescriptorName(), module-qualifies the name iff
-// the given descriptor describes an entity that doesn't come from
-// the current file.
+ }
+ return name;
+}
+
+// Returns the name of the message class itself, not the descriptor.
+// Like ModuleLevelDescriptorName(), module-qualifies the name iff
+// the given descriptor describes an entity that doesn't come from
+// the current file.
TProtoStringType Generator::ModuleLevelMessageName(
const Descriptor& descriptor) const {
TProtoStringType name = NamePrefixedWithNestedTypes(descriptor, ".");
- if (descriptor.file() != file_) {
+ if (descriptor.file() != file_) {
name = ModuleAlias(descriptor.file()->name()) + "." + name;
- }
- return name;
-}
-
-// Returns the unique Python module-level identifier given to a service
-// descriptor.
+ }
+ return name;
+}
+
+// Returns the unique Python module-level identifier given to a service
+// descriptor.
TProtoStringType Generator::ModuleLevelServiceDescriptorName(
- const ServiceDescriptor& descriptor) const {
+ const ServiceDescriptor& descriptor) const {
TProtoStringType name = descriptor.name();
ToUpper(&name);
- name = "_" + name;
- if (descriptor.file() != file_) {
+ name = "_" + name;
+ if (descriptor.file() != file_) {
name = ModuleAlias(descriptor.file()->name()) + "." + name;
- }
- return name;
-}
-
-// Prints standard constructor arguments serialized_start and serialized_end.
-// Args:
-// descriptor: The cpp descriptor to have a serialized reference.
-// proto: A proto
-// Example printer output:
-// serialized_start=41,
-// serialized_end=43,
-//
-template <typename DescriptorT, typename DescriptorProtoT>
+ }
+ return name;
+}
+
+// Prints standard constructor arguments serialized_start and serialized_end.
+// Args:
+// descriptor: The cpp descriptor to have a serialized reference.
+// proto: A proto
+// Example printer output:
+// serialized_start=41,
+// serialized_end=43,
+//
+template <typename DescriptorT, typename DescriptorProtoT>
void Generator::PrintSerializedPbInterval(const DescriptorT& descriptor,
DescriptorProtoT& proto) const {
- descriptor.CopyTo(&proto);
+ descriptor.CopyTo(&proto);
TProtoStringType sp;
- proto.SerializeToString(&sp);
- int offset = file_descriptor_serialized_.find(sp);
- GOOGLE_CHECK_GE(offset, 0);
-
+ proto.SerializeToString(&sp);
+ int offset = file_descriptor_serialized_.find(sp);
+ GOOGLE_CHECK_GE(offset, 0);
+
printer_->Print(
"serialized_start=$serialized_start$,\n"
"serialized_end=$serialized_end$,\n",
"serialized_start", StrCat(offset), "serialized_end",
StrCat(offset + sp.size()));
-}
-
-namespace {
+}
+
+namespace {
void PrintDescriptorOptionsFixingCode(const TProtoStringType& descriptor,
const TProtoStringType& options,
- io::Printer* printer) {
+ io::Printer* printer) {
// Reset the _options to None thus DescriptorBase.GetOptions() can
// parse _options again after extensions are registered.
printer->Print("$descriptor$._options = None\n", "descriptor", descriptor);
-}
-} // namespace
-
-// Prints expressions that set the options field of all descriptors.
-void Generator::FixAllDescriptorOptions() const {
- // Prints an expression that sets the file descriptor's options.
+}
+} // namespace
+
+// Prints expressions that set the options field of all descriptors.
+void Generator::FixAllDescriptorOptions() const {
+ // Prints an expression that sets the file descriptor's options.
TProtoStringType file_options = OptionsValue(file_->options().SerializeAsString());
- if (file_options != "None") {
- PrintDescriptorOptionsFixingCode(kDescriptorKey, file_options, printer_);
- }
- // Prints expressions that set the options for all top level enums.
- for (int i = 0; i < file_->enum_type_count(); ++i) {
- const EnumDescriptor& enum_descriptor = *file_->enum_type(i);
- FixOptionsForEnum(enum_descriptor);
- }
- // Prints expressions that set the options for all top level extensions.
- for (int i = 0; i < file_->extension_count(); ++i) {
- const FieldDescriptor& field = *file_->extension(i);
- FixOptionsForField(field);
- }
- // Prints expressions that set the options for all messages, nested enums,
- // nested extensions and message fields.
- for (int i = 0; i < file_->message_type_count(); ++i) {
- FixOptionsForMessage(*file_->message_type(i));
- }
-}
-
-void Generator::FixOptionsForOneof(const OneofDescriptor& oneof) const {
+ if (file_options != "None") {
+ PrintDescriptorOptionsFixingCode(kDescriptorKey, file_options, printer_);
+ }
+ // Prints expressions that set the options for all top level enums.
+ for (int i = 0; i < file_->enum_type_count(); ++i) {
+ const EnumDescriptor& enum_descriptor = *file_->enum_type(i);
+ FixOptionsForEnum(enum_descriptor);
+ }
+ // Prints expressions that set the options for all top level extensions.
+ for (int i = 0; i < file_->extension_count(); ++i) {
+ const FieldDescriptor& field = *file_->extension(i);
+ FixOptionsForField(field);
+ }
+ // Prints expressions that set the options for all messages, nested enums,
+ // nested extensions and message fields.
+ for (int i = 0; i < file_->message_type_count(); ++i) {
+ FixOptionsForMessage(*file_->message_type(i));
+ }
+}
+
+void Generator::FixOptionsForOneof(const OneofDescriptor& oneof) const {
TProtoStringType oneof_options = OptionsValue(oneof.options().SerializeAsString());
- if (oneof_options != "None") {
+ if (oneof_options != "None") {
TProtoStringType oneof_name = strings::Substitute(
"$0.$1['$2']", ModuleLevelDescriptorName(*oneof.containing_type()),
- "oneofs_by_name", oneof.name());
- PrintDescriptorOptionsFixingCode(oneof_name, oneof_options, printer_);
- }
-}
-
-// Prints expressions that set the options for an enum descriptor and its
-// value descriptors.
-void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const {
+ "oneofs_by_name", oneof.name());
+ PrintDescriptorOptionsFixingCode(oneof_name, oneof_options, printer_);
+ }
+}
+
+// Prints expressions that set the options for an enum descriptor and its
+// value descriptors.
+void Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const {
TProtoStringType descriptor_name = ModuleLevelDescriptorName(enum_descriptor);
TProtoStringType enum_options =
OptionsValue(enum_descriptor.options().SerializeAsString());
- if (enum_options != "None") {
- PrintDescriptorOptionsFixingCode(descriptor_name, enum_options, printer_);
- }
- for (int i = 0; i < enum_descriptor.value_count(); ++i) {
- const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(i);
+ if (enum_options != "None") {
+ PrintDescriptorOptionsFixingCode(descriptor_name, enum_options, printer_);
+ }
+ for (int i = 0; i < enum_descriptor.value_count(); ++i) {
+ const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(i);
TProtoStringType value_options =
OptionsValue(value_descriptor.options().SerializeAsString());
- if (value_options != "None") {
- PrintDescriptorOptionsFixingCode(
- StringPrintf("%s.values_by_name[\"%s\"]", descriptor_name.c_str(),
- value_descriptor.name().c_str()),
- value_options, printer_);
- }
- }
-}
-
-// Prints expressions that set the options for field descriptors (including
-// extensions).
+ if (value_options != "None") {
+ PrintDescriptorOptionsFixingCode(
+ StringPrintf("%s.values_by_name[\"%s\"]", descriptor_name.c_str(),
+ value_descriptor.name().c_str()),
+ value_options, printer_);
+ }
+ }
+}
+
+// Prints expressions that set the options for field descriptors (including
+// extensions).
void Generator::FixOptionsForField(const FieldDescriptor& field) const {
TProtoStringType field_options = OptionsValue(field.options().SerializeAsString());
- if (field_options != "None") {
+ if (field_options != "None") {
TProtoStringType field_name;
- if (field.is_extension()) {
+ if (field.is_extension()) {
if (field.extension_scope() == nullptr) {
- // Top level extensions.
- field_name = field.name();
- } else {
+ // Top level extensions.
+ field_name = field.name();
+ } else {
field_name = FieldReferencingExpression(field.extension_scope(), field,
"extensions_by_name");
- }
- } else {
+ }
+ } else {
field_name = FieldReferencingExpression(field.containing_type(), field,
"fields_by_name");
- }
- PrintDescriptorOptionsFixingCode(field_name, field_options, printer_);
- }
-}
-
-// Prints expressions that set the options for a message and all its inner
-// types (nested messages, nested enums, extensions, fields).
-void Generator::FixOptionsForMessage(const Descriptor& descriptor) const {
- // Nested messages.
- for (int i = 0; i < descriptor.nested_type_count(); ++i) {
- FixOptionsForMessage(*descriptor.nested_type(i));
- }
- // Oneofs.
- for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {
- FixOptionsForOneof(*descriptor.oneof_decl(i));
- }
- // Enums.
- for (int i = 0; i < descriptor.enum_type_count(); ++i) {
- FixOptionsForEnum(*descriptor.enum_type(i));
- }
- // Fields.
- for (int i = 0; i < descriptor.field_count(); ++i) {
- const FieldDescriptor& field = *descriptor.field(i);
- FixOptionsForField(field);
- }
- // Extensions.
- for (int i = 0; i < descriptor.extension_count(); ++i) {
- const FieldDescriptor& field = *descriptor.extension(i);
- FixOptionsForField(field);
- }
- // Message option for this message.
+ }
+ PrintDescriptorOptionsFixingCode(field_name, field_options, printer_);
+ }
+}
+
+// Prints expressions that set the options for a message and all its inner
+// types (nested messages, nested enums, extensions, fields).
+void Generator::FixOptionsForMessage(const Descriptor& descriptor) const {
+ // Nested messages.
+ for (int i = 0; i < descriptor.nested_type_count(); ++i) {
+ FixOptionsForMessage(*descriptor.nested_type(i));
+ }
+ // Oneofs.
+ for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {
+ FixOptionsForOneof(*descriptor.oneof_decl(i));
+ }
+ // Enums.
+ for (int i = 0; i < descriptor.enum_type_count(); ++i) {
+ FixOptionsForEnum(*descriptor.enum_type(i));
+ }
+ // Fields.
+ for (int i = 0; i < descriptor.field_count(); ++i) {
+ const FieldDescriptor& field = *descriptor.field(i);
+ FixOptionsForField(field);
+ }
+ // Extensions.
+ for (int i = 0; i < descriptor.extension_count(); ++i) {
+ const FieldDescriptor& field = *descriptor.extension(i);
+ FixOptionsForField(field);
+ }
+ // Message option for this message.
TProtoStringType message_options =
OptionsValue(descriptor.options().SerializeAsString());
- if (message_options != "None") {
+ if (message_options != "None") {
TProtoStringType descriptor_name = ModuleLevelDescriptorName(descriptor);
PrintDescriptorOptionsFixingCode(descriptor_name, message_options,
- printer_);
- }
-}
-
-// If a dependency forwards other files through public dependencies, let's
-// copy over the corresponding module aliases.
-void Generator::CopyPublicDependenciesAliases(
+ printer_);
+ }
+}
+
+// If a dependency forwards other files through public dependencies, let's
+// copy over the corresponding module aliases.
+void Generator::CopyPublicDependenciesAliases(
const TProtoStringType& copy_from, const FileDescriptor* file) const {
- for (int i = 0; i < file->public_dependency_count(); ++i) {
+ for (int i = 0; i < file->public_dependency_count(); ++i) {
TProtoStringType module_name = ModuleName(file->public_dependency(i)->name());
TProtoStringType module_alias = ModuleAlias(file->public_dependency(i)->name());
// There's no module alias in the dependent file if it was generated by
@@ -1459,11 +1459,11 @@ void Generator::CopyPublicDependenciesAliases(
"except AttributeError:\n"
" $alias$ = $copy_from$.$module$\n",
"alias", module_alias, "module", module_name, "copy_from", copy_from);
- CopyPublicDependenciesAliases(copy_from, file->public_dependency(i));
- }
-}
-
-} // namespace python
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ CopyPublicDependenciesAliases(copy_from, file->public_dependency(i));
+ }
+}
+
+} // namespace python
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
index f479399ef7..83dbce951a 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h
@@ -1,182 +1,182 @@
-// 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: robinson@google.com (Will Robinson)
-//
-// Generates Python code for a given .proto file.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_PYTHON_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: robinson@google.com (Will Robinson)
+//
+// Generates Python code for a given .proto file.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
+
#include <string>
-
+
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/stubs/mutex.h>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-
-class Descriptor;
-class EnumDescriptor;
-class EnumValueDescriptor;
-class FieldDescriptor;
-class OneofDescriptor;
-class ServiceDescriptor;
-
+namespace google {
+namespace protobuf {
+
+class Descriptor;
+class EnumDescriptor;
+class EnumValueDescriptor;
+class FieldDescriptor;
+class OneofDescriptor;
+class ServiceDescriptor;
+
namespace io {
class Printer;
}
-
-namespace compiler {
-namespace python {
-
-// CodeGenerator implementation for generated Python protocol buffer classes.
-// If you create your own protocol compiler binary and you want it to support
-// Python output, you can do so by registering an instance of this
-// CodeGenerator with the CommandLineInterface in your main() function.
+
+namespace compiler {
+namespace python {
+
+// CodeGenerator implementation for generated Python protocol buffer classes.
+// If you create your own protocol compiler binary and you want it to support
+// Python output, you can do so by registering an instance of this
+// CodeGenerator with the CommandLineInterface in your main() function.
class PROTOC_EXPORT Generator : public CodeGenerator {
- public:
- Generator();
- virtual ~Generator();
-
- // CodeGenerator methods.
+ public:
+ Generator();
+ virtual ~Generator();
+
+ // CodeGenerator methods.
bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
GeneratorContext* generator_context,
TProtoStringType* error) const override;
-
+
uint64_t GetSupportedFeatures() const override;
- private:
- void PrintImports() const;
- void PrintFileDescriptor() const;
- void PrintTopLevelEnums() const;
- void PrintAllNestedEnumsInFile() const;
- void PrintNestedEnums(const Descriptor& descriptor) const;
- void PrintEnum(const EnumDescriptor& enum_descriptor) const;
-
- void PrintTopLevelExtensions() const;
-
+ private:
+ void PrintImports() const;
+ void PrintFileDescriptor() const;
+ void PrintTopLevelEnums() const;
+ void PrintAllNestedEnumsInFile() const;
+ void PrintNestedEnums(const Descriptor& descriptor) const;
+ void PrintEnum(const EnumDescriptor& enum_descriptor) const;
+
+ void PrintTopLevelExtensions() const;
+
void PrintFieldDescriptor(const FieldDescriptor& field,
bool is_extension) const;
- void PrintFieldDescriptorsInDescriptor(
+ void PrintFieldDescriptorsInDescriptor(
const Descriptor& message_descriptor, bool is_extension,
const TProtoStringType& list_variable_name, int (Descriptor::*CountFn)() const,
const FieldDescriptor* (Descriptor::*GetterFn)(int)const) const;
- void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const;
- void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const;
- void PrintMessageDescriptors() const;
- void PrintDescriptor(const Descriptor& message_descriptor) const;
- void PrintNestedDescriptors(const Descriptor& containing_descriptor) const;
-
- void PrintMessages() const;
+ void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const;
+ void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const;
+ void PrintMessageDescriptors() const;
+ void PrintDescriptor(const Descriptor& message_descriptor) const;
+ void PrintNestedDescriptors(const Descriptor& containing_descriptor) const;
+
+ void PrintMessages() const;
void PrintMessage(const Descriptor& message_descriptor,
const TProtoStringType& prefix,
std::vector<TProtoStringType>* to_register,
bool is_nested) const;
- void PrintNestedMessages(const Descriptor& containing_descriptor,
+ void PrintNestedMessages(const Descriptor& containing_descriptor,
const TProtoStringType& prefix,
std::vector<TProtoStringType>* to_register) const;
-
- void FixForeignFieldsInDescriptors() const;
- void FixForeignFieldsInDescriptor(
- const Descriptor& descriptor,
- const Descriptor* containing_descriptor) const;
- void FixForeignFieldsInField(const Descriptor* containing_type,
- const FieldDescriptor& field,
+
+ void FixForeignFieldsInDescriptors() const;
+ void FixForeignFieldsInDescriptor(
+ const Descriptor& descriptor,
+ const Descriptor* containing_descriptor) const;
+ void FixForeignFieldsInField(const Descriptor* containing_type,
+ const FieldDescriptor& field,
const TProtoStringType& python_dict_name) const;
- void AddMessageToFileDescriptor(const Descriptor& descriptor) const;
- void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const;
- void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const;
+ void AddMessageToFileDescriptor(const Descriptor& descriptor) const;
+ void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const;
+ void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const;
void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const;
TProtoStringType FieldReferencingExpression(
const Descriptor* containing_type, const FieldDescriptor& field,
const TProtoStringType& python_dict_name) const;
- template <typename DescriptorT>
- void FixContainingTypeInDescriptor(
- const DescriptorT& descriptor,
- const Descriptor* containing_descriptor) const;
-
- void FixForeignFieldsInExtensions() const;
- void FixForeignFieldsInExtension(
- const FieldDescriptor& extension_field) const;
- void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const;
-
- void PrintServices() const;
+ template <typename DescriptorT>
+ void FixContainingTypeInDescriptor(
+ const DescriptorT& descriptor,
+ const Descriptor* containing_descriptor) const;
+
+ void FixForeignFieldsInExtensions() const;
+ void FixForeignFieldsInExtension(
+ const FieldDescriptor& extension_field) const;
+ void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const;
+
+ void PrintServices() const;
void PrintServiceDescriptors() const;
- void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const;
- void PrintServiceClass(const ServiceDescriptor& descriptor) const;
- void PrintServiceStub(const ServiceDescriptor& descriptor) const;
- void PrintDescriptorKeyAndModuleName(
+ void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const;
+ void PrintServiceClass(const ServiceDescriptor& descriptor) const;
+ void PrintServiceStub(const ServiceDescriptor& descriptor) const;
+ void PrintDescriptorKeyAndModuleName(
const ServiceDescriptor& descriptor) const;
-
- void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;
+
+ void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;
TProtoStringType OptionsValue(const TProtoStringType& serialized_options) const;
- bool GeneratingDescriptorProto() const;
-
- template <typename DescriptorT>
+ bool GeneratingDescriptorProto() const;
+
+ template <typename DescriptorT>
TProtoStringType ModuleLevelDescriptorName(const DescriptorT& descriptor) const;
TProtoStringType ModuleLevelMessageName(const Descriptor& descriptor) const;
TProtoStringType ModuleLevelServiceDescriptorName(
- const ServiceDescriptor& descriptor) const;
-
- template <typename DescriptorT, typename DescriptorProtoT>
+ const ServiceDescriptor& descriptor) const;
+
+ template <typename DescriptorT, typename DescriptorProtoT>
void PrintSerializedPbInterval(const DescriptorT& descriptor,
DescriptorProtoT& proto) const;
-
- void FixAllDescriptorOptions() const;
- void FixOptionsForField(const FieldDescriptor& field) const;
- void FixOptionsForOneof(const OneofDescriptor& oneof) const;
- void FixOptionsForEnum(const EnumDescriptor& descriptor) const;
- void FixOptionsForMessage(const Descriptor& descriptor) const;
-
+
+ void FixAllDescriptorOptions() const;
+ void FixOptionsForField(const FieldDescriptor& field) const;
+ void FixOptionsForOneof(const OneofDescriptor& oneof) const;
+ void FixOptionsForEnum(const EnumDescriptor& descriptor) const;
+ void FixOptionsForMessage(const Descriptor& descriptor) const;
+
void CopyPublicDependenciesAliases(const TProtoStringType& copy_from,
const FileDescriptor* file) const;
-
- // Very coarse-grained lock to ensure that Generate() is reentrant.
- // Guards file_, printer_ and file_descriptor_serialized_.
- mutable Mutex mutex_;
- mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_.
+
+ // Very coarse-grained lock to ensure that Generate() is reentrant.
+ // Guards file_, printer_ and file_descriptor_serialized_.
+ mutable Mutex mutex_;
+ mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_.
mutable TProtoStringType file_descriptor_serialized_;
- mutable io::Printer* printer_; // Set in Generate(). Under mutex_.
+ mutable io::Printer* printer_; // Set in Generate(). Under mutex_.
mutable bool pure_python_workable_;
-
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);
-};
-
-} // namespace python
-} // namespace compiler
-} // namespace protobuf
+
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);
+};
+
+} // namespace python
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
index 2c00918aa3..9a660733b3 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.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: kenton@google.com (Kenton Varda)
-
+// 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: kenton@google.com (Kenton Varda)
+
#include <google/protobuf/compiler/subprocess.h>
-
-#include <algorithm>
+
+#include <algorithm>
#include <cstring>
-#include <iostream>
-
-#ifndef _WIN32
-#include <errno.h>
+#include <iostream>
+
+#ifndef _WIN32
+#include <errno.h>
#include <signal.h>
-#include <sys/select.h>
-#include <sys/wait.h>
-#endif
-
+#include <sys/select.h>
+#include <sys/wait.h>
+#endif
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/message.h>
#include <google/protobuf/stubs/substitute.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
namespace {
char* portable_strdup(const char* s) {
char* ns = (char*)malloc(strlen(s) + 1);
@@ -62,414 +62,414 @@ char* portable_strdup(const char* s) {
}
} // namespace
-#ifdef _WIN32
-
-static void CloseHandleOrDie(HANDLE handle) {
- if (!CloseHandle(handle)) {
- GOOGLE_LOG(FATAL) << "CloseHandle: "
- << Subprocess::Win32ErrorMessage(GetLastError());
- }
-}
-
-Subprocess::Subprocess()
- : process_start_error_(ERROR_SUCCESS),
+#ifdef _WIN32
+
+static void CloseHandleOrDie(HANDLE handle) {
+ if (!CloseHandle(handle)) {
+ GOOGLE_LOG(FATAL) << "CloseHandle: "
+ << Subprocess::Win32ErrorMessage(GetLastError());
+ }
+}
+
+Subprocess::Subprocess()
+ : process_start_error_(ERROR_SUCCESS),
child_handle_(NULL),
child_stdin_(NULL),
child_stdout_(NULL) {}
-
-Subprocess::~Subprocess() {
- if (child_stdin_ != NULL) {
- CloseHandleOrDie(child_stdin_);
- }
- if (child_stdout_ != NULL) {
- CloseHandleOrDie(child_stdout_);
- }
-}
-
+
+Subprocess::~Subprocess() {
+ if (child_stdin_ != NULL) {
+ CloseHandleOrDie(child_stdin_);
+ }
+ if (child_stdout_ != NULL) {
+ CloseHandleOrDie(child_stdout_);
+ }
+}
+
void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode) {
- // Create the pipes.
- HANDLE stdin_pipe_read;
- HANDLE stdin_pipe_write;
- HANDLE stdout_pipe_read;
- HANDLE stdout_pipe_write;
-
- if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) {
- GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
- }
- if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) {
- GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
- }
-
- // Make child side of the pipes inheritable.
+ // Create the pipes.
+ HANDLE stdin_pipe_read;
+ HANDLE stdin_pipe_write;
+ HANDLE stdout_pipe_read;
+ HANDLE stdout_pipe_write;
+
+ if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) {
+ GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
+ }
+ if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) {
+ GOOGLE_LOG(FATAL) << "CreatePipe: " << Win32ErrorMessage(GetLastError());
+ }
+
+ // Make child side of the pipes inheritable.
if (!SetHandleInformation(stdin_pipe_read, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT)) {
- GOOGLE_LOG(FATAL) << "SetHandleInformation: "
- << Win32ErrorMessage(GetLastError());
- }
+ GOOGLE_LOG(FATAL) << "SetHandleInformation: "
+ << Win32ErrorMessage(GetLastError());
+ }
if (!SetHandleInformation(stdout_pipe_write, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT)) {
- GOOGLE_LOG(FATAL) << "SetHandleInformation: "
- << Win32ErrorMessage(GetLastError());
- }
-
- // Setup STARTUPINFO to redirect handles.
- STARTUPINFOA startup_info;
- ZeroMemory(&startup_info, sizeof(startup_info));
- startup_info.cb = sizeof(startup_info);
- startup_info.dwFlags = STARTF_USESTDHANDLES;
- startup_info.hStdInput = stdin_pipe_read;
- startup_info.hStdOutput = stdout_pipe_write;
- startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
-
- if (startup_info.hStdError == INVALID_HANDLE_VALUE) {
+ GOOGLE_LOG(FATAL) << "SetHandleInformation: "
+ << Win32ErrorMessage(GetLastError());
+ }
+
+ // Setup STARTUPINFO to redirect handles.
+ STARTUPINFOA startup_info;
+ ZeroMemory(&startup_info, sizeof(startup_info));
+ startup_info.cb = sizeof(startup_info);
+ startup_info.dwFlags = STARTF_USESTDHANDLES;
+ startup_info.hStdInput = stdin_pipe_read;
+ startup_info.hStdOutput = stdout_pipe_write;
+ startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+
+ if (startup_info.hStdError == INVALID_HANDLE_VALUE) {
GOOGLE_LOG(FATAL) << "GetStdHandle: " << Win32ErrorMessage(GetLastError());
- }
-
+ }
+
// Invoking cmd.exe allows for '.bat' files from the path as well as '.exe'.
// Using a malloc'ed string because CreateProcess() can mutate its second
// parameter.
char* command_line =
portable_strdup(("cmd.exe /c \"" + program + "\"").c_str());
-
- // Create the process.
- PROCESS_INFORMATION process_info;
-
- if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(),
+
+ // Create the process.
+ PROCESS_INFORMATION process_info;
+
+ if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(),
(search_mode == SEARCH_PATH) ? command_line : NULL,
- NULL, // process security attributes
- NULL, // thread security attributes
- TRUE, // inherit handles?
- 0, // obscure creation flags
- NULL, // environment (inherit from parent)
- NULL, // current directory (inherit from parent)
+ NULL, // process security attributes
+ NULL, // thread security attributes
+ TRUE, // inherit handles?
+ 0, // obscure creation flags
+ NULL, // environment (inherit from parent)
+ NULL, // current directory (inherit from parent)
&startup_info, &process_info)) {
- child_handle_ = process_info.hProcess;
- CloseHandleOrDie(process_info.hThread);
- child_stdin_ = stdin_pipe_write;
- child_stdout_ = stdout_pipe_read;
- } else {
- process_start_error_ = GetLastError();
- CloseHandleOrDie(stdin_pipe_write);
- CloseHandleOrDie(stdout_pipe_read);
- }
-
- CloseHandleOrDie(stdin_pipe_read);
- CloseHandleOrDie(stdout_pipe_write);
+ child_handle_ = process_info.hProcess;
+ CloseHandleOrDie(process_info.hThread);
+ child_stdin_ = stdin_pipe_write;
+ child_stdout_ = stdout_pipe_read;
+ } else {
+ process_start_error_ = GetLastError();
+ CloseHandleOrDie(stdin_pipe_write);
+ CloseHandleOrDie(stdout_pipe_read);
+ }
+
+ CloseHandleOrDie(stdin_pipe_read);
+ CloseHandleOrDie(stdout_pipe_write);
free(command_line);
-}
-
-bool Subprocess::Communicate(const Message& input, Message* output,
+}
+
+bool Subprocess::Communicate(const Message& input, Message* output,
TProtoStringType* error) {
- if (process_start_error_ != ERROR_SUCCESS) {
- *error = Win32ErrorMessage(process_start_error_);
- return false;
- }
-
- GOOGLE_CHECK(child_handle_ != NULL) << "Must call Start() first.";
-
+ if (process_start_error_ != ERROR_SUCCESS) {
+ *error = Win32ErrorMessage(process_start_error_);
+ return false;
+ }
+
+ GOOGLE_CHECK(child_handle_ != NULL) << "Must call Start() first.";
+
TProtoStringType input_data = input.SerializeAsString();
TProtoStringType output_data;
-
- int input_pos = 0;
-
- while (child_stdout_ != NULL) {
- HANDLE handles[2];
- int handle_count = 0;
-
- if (child_stdin_ != NULL) {
- handles[handle_count++] = child_stdin_;
- }
- if (child_stdout_ != NULL) {
- handles[handle_count++] = child_stdout_;
- }
-
- DWORD wait_result =
- WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE);
-
- HANDLE signaled_handle = NULL;
- if (wait_result >= WAIT_OBJECT_0 &&
- wait_result < WAIT_OBJECT_0 + handle_count) {
- signaled_handle = handles[wait_result - WAIT_OBJECT_0];
- } else if (wait_result == WAIT_FAILED) {
- GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: "
- << Win32ErrorMessage(GetLastError());
- } else {
- GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: "
- << wait_result;
- }
-
- if (signaled_handle == child_stdin_) {
- DWORD n;
+
+ int input_pos = 0;
+
+ while (child_stdout_ != NULL) {
+ HANDLE handles[2];
+ int handle_count = 0;
+
+ if (child_stdin_ != NULL) {
+ handles[handle_count++] = child_stdin_;
+ }
+ if (child_stdout_ != NULL) {
+ handles[handle_count++] = child_stdout_;
+ }
+
+ DWORD wait_result =
+ WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE);
+
+ HANDLE signaled_handle = NULL;
+ if (wait_result >= WAIT_OBJECT_0 &&
+ wait_result < WAIT_OBJECT_0 + handle_count) {
+ signaled_handle = handles[wait_result - WAIT_OBJECT_0];
+ } else if (wait_result == WAIT_FAILED) {
+ GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: "
+ << Win32ErrorMessage(GetLastError());
+ } else {
+ GOOGLE_LOG(FATAL) << "WaitForMultipleObjects: Unexpected return code: "
+ << wait_result;
+ }
+
+ if (signaled_handle == child_stdin_) {
+ DWORD n;
if (!WriteFile(child_stdin_, input_data.data() + input_pos,
input_data.size() - input_pos, &n, NULL)) {
- // Child closed pipe. Presumably it will report an error later.
- // Pretend we're done for now.
- input_pos = input_data.size();
- } else {
- input_pos += n;
- }
-
- if (input_pos == input_data.size()) {
- // We're done writing. Close.
- CloseHandleOrDie(child_stdin_);
- child_stdin_ = NULL;
- }
- } else if (signaled_handle == child_stdout_) {
- char buffer[4096];
- DWORD n;
-
- if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) {
- // We're done reading. Close.
- CloseHandleOrDie(child_stdout_);
- child_stdout_ = NULL;
- } else {
- output_data.append(buffer, n);
- }
- }
- }
-
- if (child_stdin_ != NULL) {
- // Child did not finish reading input before it closed the output.
- // Presumably it exited with an error.
- CloseHandleOrDie(child_stdin_);
- child_stdin_ = NULL;
- }
-
- DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);
-
- if (wait_result == WAIT_FAILED) {
- GOOGLE_LOG(FATAL) << "WaitForSingleObject: "
- << Win32ErrorMessage(GetLastError());
- } else if (wait_result != WAIT_OBJECT_0) {
- GOOGLE_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: "
- << wait_result;
- }
-
- DWORD exit_code;
- if (!GetExitCodeProcess(child_handle_, &exit_code)) {
- GOOGLE_LOG(FATAL) << "GetExitCodeProcess: "
- << Win32ErrorMessage(GetLastError());
- }
-
- CloseHandleOrDie(child_handle_);
- child_handle_ = NULL;
-
- if (exit_code != 0) {
+ // Child closed pipe. Presumably it will report an error later.
+ // Pretend we're done for now.
+ input_pos = input_data.size();
+ } else {
+ input_pos += n;
+ }
+
+ if (input_pos == input_data.size()) {
+ // We're done writing. Close.
+ CloseHandleOrDie(child_stdin_);
+ child_stdin_ = NULL;
+ }
+ } else if (signaled_handle == child_stdout_) {
+ char buffer[4096];
+ DWORD n;
+
+ if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) {
+ // We're done reading. Close.
+ CloseHandleOrDie(child_stdout_);
+ child_stdout_ = NULL;
+ } else {
+ output_data.append(buffer, n);
+ }
+ }
+ }
+
+ if (child_stdin_ != NULL) {
+ // Child did not finish reading input before it closed the output.
+ // Presumably it exited with an error.
+ CloseHandleOrDie(child_stdin_);
+ child_stdin_ = NULL;
+ }
+
+ DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);
+
+ if (wait_result == WAIT_FAILED) {
+ GOOGLE_LOG(FATAL) << "WaitForSingleObject: "
+ << Win32ErrorMessage(GetLastError());
+ } else if (wait_result != WAIT_OBJECT_0) {
+ GOOGLE_LOG(FATAL) << "WaitForSingleObject: Unexpected return code: "
+ << wait_result;
+ }
+
+ DWORD exit_code;
+ if (!GetExitCodeProcess(child_handle_, &exit_code)) {
+ GOOGLE_LOG(FATAL) << "GetExitCodeProcess: "
+ << Win32ErrorMessage(GetLastError());
+ }
+
+ CloseHandleOrDie(child_handle_);
+ child_handle_ = NULL;
+
+ if (exit_code != 0) {
*error = strings::Substitute("Plugin failed with status code $0.", exit_code);
- return false;
- }
-
- if (!output->ParseFromString(output_data)) {
- *error = "Plugin output is unparseable: " + CEscape(output_data);
- return false;
- }
-
- return true;
-}
-
+ return false;
+ }
+
+ if (!output->ParseFromString(output_data)) {
+ *error = "Plugin output is unparseable: " + CEscape(output_data);
+ return false;
+ }
+
+ return true;
+}
+
TProtoStringType Subprocess::Win32ErrorMessage(DWORD error_code) {
- char* message;
-
- // WTF?
+ char* message;
+
+ // WTF?
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPSTR)&message, // NOT A BUG!
0, NULL);
-
+
TProtoStringType result = message;
- LocalFree(message);
- return result;
-}
-
-// ===================================================================
-
-#else // _WIN32
-
-Subprocess::Subprocess()
- : child_pid_(-1), child_stdin_(-1), child_stdout_(-1) {}
-
-Subprocess::~Subprocess() {
- if (child_stdin_ != -1) {
- close(child_stdin_);
- }
- if (child_stdout_ != -1) {
- close(child_stdout_);
- }
-}
-
+ LocalFree(message);
+ return result;
+}
+
+// ===================================================================
+
+#else // _WIN32
+
+Subprocess::Subprocess()
+ : child_pid_(-1), child_stdin_(-1), child_stdout_(-1) {}
+
+Subprocess::~Subprocess() {
+ if (child_stdin_ != -1) {
+ close(child_stdin_);
+ }
+ if (child_stdout_ != -1) {
+ close(child_stdout_);
+ }
+}
+
void Subprocess::Start(const TProtoStringType& program, SearchMode search_mode) {
- // Note that we assume that there are no other threads, thus we don't have to
- // do crazy stuff like using socket pairs or avoiding libc locks.
-
- // [0] is read end, [1] is write end.
- int stdin_pipe[2];
- int stdout_pipe[2];
-
- GOOGLE_CHECK(pipe(stdin_pipe) != -1);
- GOOGLE_CHECK(pipe(stdout_pipe) != -1);
-
+ // Note that we assume that there are no other threads, thus we don't have to
+ // do crazy stuff like using socket pairs or avoiding libc locks.
+
+ // [0] is read end, [1] is write end.
+ int stdin_pipe[2];
+ int stdout_pipe[2];
+
+ GOOGLE_CHECK(pipe(stdin_pipe) != -1);
+ GOOGLE_CHECK(pipe(stdout_pipe) != -1);
+
char* argv[2] = {portable_strdup(program.c_str()), NULL};
-
- child_pid_ = fork();
- if (child_pid_ == -1) {
- GOOGLE_LOG(FATAL) << "fork: " << strerror(errno);
- } else if (child_pid_ == 0) {
- // We are the child.
- dup2(stdin_pipe[0], STDIN_FILENO);
- dup2(stdout_pipe[1], STDOUT_FILENO);
-
- close(stdin_pipe[0]);
- close(stdin_pipe[1]);
- close(stdout_pipe[0]);
- close(stdout_pipe[1]);
-
- switch (search_mode) {
- case SEARCH_PATH:
- execvp(argv[0], argv);
- break;
- case EXACT_NAME:
- execv(argv[0], argv);
- break;
- }
-
- // Write directly to STDERR_FILENO to avoid stdio code paths that may do
- // stuff that is unsafe here.
- int ignored;
- ignored = write(STDERR_FILENO, argv[0], strlen(argv[0]));
+
+ child_pid_ = fork();
+ if (child_pid_ == -1) {
+ GOOGLE_LOG(FATAL) << "fork: " << strerror(errno);
+ } else if (child_pid_ == 0) {
+ // We are the child.
+ dup2(stdin_pipe[0], STDIN_FILENO);
+ dup2(stdout_pipe[1], STDOUT_FILENO);
+
+ close(stdin_pipe[0]);
+ close(stdin_pipe[1]);
+ close(stdout_pipe[0]);
+ close(stdout_pipe[1]);
+
+ switch (search_mode) {
+ case SEARCH_PATH:
+ execvp(argv[0], argv);
+ break;
+ case EXACT_NAME:
+ execv(argv[0], argv);
+ break;
+ }
+
+ // Write directly to STDERR_FILENO to avoid stdio code paths that may do
+ // stuff that is unsafe here.
+ int ignored;
+ ignored = write(STDERR_FILENO, argv[0], strlen(argv[0]));
const char* message =
": program not found or is not executable\n"
"Please specify a program using absolute path or make sure "
"the program is available in your PATH system variable\n";
- ignored = write(STDERR_FILENO, message, strlen(message));
+ ignored = write(STDERR_FILENO, message, strlen(message));
(void)ignored;
-
- // Must use _exit() rather than exit() to avoid flushing output buffers
- // that will also be flushed by the parent.
- _exit(1);
- } else {
+
+ // Must use _exit() rather than exit() to avoid flushing output buffers
+ // that will also be flushed by the parent.
+ _exit(1);
+ } else {
free(argv[0]);
- close(stdin_pipe[0]);
- close(stdout_pipe[1]);
-
- child_stdin_ = stdin_pipe[1];
- child_stdout_ = stdout_pipe[0];
- }
-}
-
-bool Subprocess::Communicate(const Message& input, Message* output,
+ close(stdin_pipe[0]);
+ close(stdout_pipe[1]);
+
+ child_stdin_ = stdin_pipe[1];
+ child_stdout_ = stdout_pipe[0];
+ }
+}
+
+bool Subprocess::Communicate(const Message& input, Message* output,
TProtoStringType* error) {
- GOOGLE_CHECK_NE(child_stdin_, -1) << "Must call Start() first.";
-
- // The "sighandler_t" typedef is GNU-specific, so define our own.
- typedef void SignalHandler(int);
-
- // Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us.
- SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN);
-
+ GOOGLE_CHECK_NE(child_stdin_, -1) << "Must call Start() first.";
+
+ // The "sighandler_t" typedef is GNU-specific, so define our own.
+ typedef void SignalHandler(int);
+
+ // Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us.
+ SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN);
+
TProtoStringType input_data = input.SerializeAsString();
TProtoStringType output_data;
-
- int input_pos = 0;
- int max_fd = std::max(child_stdin_, child_stdout_);
-
- while (child_stdout_ != -1) {
- fd_set read_fds;
- fd_set write_fds;
- FD_ZERO(&read_fds);
- FD_ZERO(&write_fds);
- if (child_stdout_ != -1) {
- FD_SET(child_stdout_, &read_fds);
- }
- if (child_stdin_ != -1) {
- FD_SET(child_stdin_, &write_fds);
- }
-
- if (select(max_fd + 1, &read_fds, &write_fds, NULL, NULL) < 0) {
- if (errno == EINTR) {
- // Interrupted by signal. Try again.
- continue;
- } else {
- GOOGLE_LOG(FATAL) << "select: " << strerror(errno);
- }
- }
-
- if (child_stdin_ != -1 && FD_ISSET(child_stdin_, &write_fds)) {
- int n = write(child_stdin_, input_data.data() + input_pos,
+
+ int input_pos = 0;
+ int max_fd = std::max(child_stdin_, child_stdout_);
+
+ while (child_stdout_ != -1) {
+ fd_set read_fds;
+ fd_set write_fds;
+ FD_ZERO(&read_fds);
+ FD_ZERO(&write_fds);
+ if (child_stdout_ != -1) {
+ FD_SET(child_stdout_, &read_fds);
+ }
+ if (child_stdin_ != -1) {
+ FD_SET(child_stdin_, &write_fds);
+ }
+
+ if (select(max_fd + 1, &read_fds, &write_fds, NULL, NULL) < 0) {
+ if (errno == EINTR) {
+ // Interrupted by signal. Try again.
+ continue;
+ } else {
+ GOOGLE_LOG(FATAL) << "select: " << strerror(errno);
+ }
+ }
+
+ if (child_stdin_ != -1 && FD_ISSET(child_stdin_, &write_fds)) {
+ int n = write(child_stdin_, input_data.data() + input_pos,
input_data.size() - input_pos);
- if (n < 0) {
- // Child closed pipe. Presumably it will report an error later.
- // Pretend we're done for now.
- input_pos = input_data.size();
- } else {
- input_pos += n;
- }
-
- if (input_pos == input_data.size()) {
- // We're done writing. Close.
- close(child_stdin_);
- child_stdin_ = -1;
- }
- }
-
- if (child_stdout_ != -1 && FD_ISSET(child_stdout_, &read_fds)) {
- char buffer[4096];
- int n = read(child_stdout_, buffer, sizeof(buffer));
-
- if (n > 0) {
- output_data.append(buffer, n);
- } else {
- // We're done reading. Close.
- close(child_stdout_);
- child_stdout_ = -1;
- }
- }
- }
-
- if (child_stdin_ != -1) {
- // Child did not finish reading input before it closed the output.
- // Presumably it exited with an error.
- close(child_stdin_);
- child_stdin_ = -1;
- }
-
- int status;
- while (waitpid(child_pid_, &status, 0) == -1) {
- if (errno != EINTR) {
- GOOGLE_LOG(FATAL) << "waitpid: " << strerror(errno);
- }
- }
-
- // Restore SIGPIPE handling.
- signal(SIGPIPE, old_pipe_handler);
-
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0) {
- int error_code = WEXITSTATUS(status);
+ if (n < 0) {
+ // Child closed pipe. Presumably it will report an error later.
+ // Pretend we're done for now.
+ input_pos = input_data.size();
+ } else {
+ input_pos += n;
+ }
+
+ if (input_pos == input_data.size()) {
+ // We're done writing. Close.
+ close(child_stdin_);
+ child_stdin_ = -1;
+ }
+ }
+
+ if (child_stdout_ != -1 && FD_ISSET(child_stdout_, &read_fds)) {
+ char buffer[4096];
+ int n = read(child_stdout_, buffer, sizeof(buffer));
+
+ if (n > 0) {
+ output_data.append(buffer, n);
+ } else {
+ // We're done reading. Close.
+ close(child_stdout_);
+ child_stdout_ = -1;
+ }
+ }
+ }
+
+ if (child_stdin_ != -1) {
+ // Child did not finish reading input before it closed the output.
+ // Presumably it exited with an error.
+ close(child_stdin_);
+ child_stdin_ = -1;
+ }
+
+ int status;
+ while (waitpid(child_pid_, &status, 0) == -1) {
+ if (errno != EINTR) {
+ GOOGLE_LOG(FATAL) << "waitpid: " << strerror(errno);
+ }
+ }
+
+ // Restore SIGPIPE handling.
+ signal(SIGPIPE, old_pipe_handler);
+
+ if (WIFEXITED(status)) {
+ if (WEXITSTATUS(status) != 0) {
+ int error_code = WEXITSTATUS(status);
*error =
strings::Substitute("Plugin failed with status code $0.", error_code);
- return false;
- }
- } else if (WIFSIGNALED(status)) {
- int signal = WTERMSIG(status);
+ return false;
+ }
+ } else if (WIFSIGNALED(status)) {
+ int signal = WTERMSIG(status);
*error = strings::Substitute("Plugin killed by signal $0.", signal);
- return false;
- } else {
- *error = "Neither WEXITSTATUS nor WTERMSIG is true?";
- return false;
- }
-
- if (!output->ParseFromString(output_data)) {
- *error = "Plugin output is unparseable: " + CEscape(output_data);
- return false;
- }
-
- return true;
-}
-
-#endif // !_WIN32
-
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+ return false;
+ } else {
+ *error = "Neither WEXITSTATUS nor WTERMSIG is true?";
+ return false;
+ }
+
+ if (!output->ParseFromString(output_data)) {
+ *error = "Plugin output is unparseable: " + CEscape(output_data);
+ return false;
+ }
+
+ return true;
+}
+
+#endif // !_WIN32
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
index f8d9ae36dd..ed9790f9b5 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.h
@@ -1,113 +1,113 @@
-// 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: kenton@google.com (Kenton Varda)
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
-#define GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
-
-#ifdef _WIN32
+// 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: kenton@google.com (Kenton Varda)
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
+#define GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
+
+#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN // right...
#endif
-#include <windows.h>
-#else // _WIN32
-#include <sys/types.h>
-#include <unistd.h>
-#endif // !_WIN32
+#include <windows.h>
+#else // _WIN32
+#include <sys/types.h>
+#include <unistd.h>
+#endif // !_WIN32
#include <google/protobuf/stubs/common.h>
-
+
#include <string>
-
+
#include <google/protobuf/port_def.inc>
-namespace google {
-namespace protobuf {
-
-class Message;
-
-namespace compiler {
-
-// Utility class for launching sub-processes.
+namespace google {
+namespace protobuf {
+
+class Message;
+
+namespace compiler {
+
+// Utility class for launching sub-processes.
class PROTOC_EXPORT Subprocess {
- public:
- Subprocess();
- ~Subprocess();
-
- enum SearchMode {
+ public:
+ Subprocess();
+ ~Subprocess();
+
+ enum SearchMode {
SEARCH_PATH, // Use PATH environment variable.
EXACT_NAME // Program is an exact file name; don't use the PATH.
- };
-
- // Start the subprocess. Currently we don't provide a way to specify
- // arguments as protoc plugins don't have any.
+ };
+
+ // Start the subprocess. Currently we don't provide a way to specify
+ // arguments as protoc plugins don't have any.
void Start(const TProtoStringType& program, SearchMode search_mode);
-
- // Serialize the input message and pipe it to the subprocess's stdin, then
- // close the pipe. Meanwhile, read from the subprocess's stdout and parse
- // the data into *output. All this is done carefully to avoid deadlocks.
- // Returns true if successful. On any sort of error, returns false and sets
- // *error to a description of the problem.
+
+ // Serialize the input message and pipe it to the subprocess's stdin, then
+ // close the pipe. Meanwhile, read from the subprocess's stdout and parse
+ // the data into *output. All this is done carefully to avoid deadlocks.
+ // Returns true if successful. On any sort of error, returns false and sets
+ // *error to a description of the problem.
bool Communicate(const Message& input, Message* output, TProtoStringType* error);
-
-#ifdef _WIN32
- // Given an error code, returns a human-readable error message. This is
- // defined here so that CommandLineInterface can share it.
+
+#ifdef _WIN32
+ // Given an error code, returns a human-readable error message. This is
+ // defined here so that CommandLineInterface can share it.
static TProtoStringType Win32ErrorMessage(DWORD error_code);
-#endif
-
- private:
-#ifdef _WIN32
- DWORD process_start_error_;
- HANDLE child_handle_;
-
- // The file handles for our end of the child's pipes. We close each and
- // set it to NULL when no longer needed.
- HANDLE child_stdin_;
- HANDLE child_stdout_;
-
-#else // _WIN32
- pid_t child_pid_;
-
- // The file descriptors for our end of the child's pipes. We close each and
- // set it to -1 when no longer needed.
- int child_stdin_;
- int child_stdout_;
-
-#endif // !_WIN32
-};
-
-} // namespace compiler
-} // namespace protobuf
+#endif
+
+ private:
+#ifdef _WIN32
+ DWORD process_start_error_;
+ HANDLE child_handle_;
+
+ // The file handles for our end of the child's pipes. We close each and
+ // set it to NULL when no longer needed.
+ HANDLE child_stdin_;
+ HANDLE child_stdout_;
+
+#else // _WIN32
+ pid_t child_pid_;
+
+ // The file descriptors for our end of the child's pipes. We close each and
+ // set it to -1 when no longer needed.
+ int child_stdin_;
+ int child_stdout_;
+
+#endif // !_WIN32
+};
+
+} // namespace compiler
+} // namespace protobuf
} // namespace google
-
+
#include <google/protobuf/port_undef.inc>
-#endif // GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
+#endif // GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc
index 2e89a2a740..40bac12e40 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc
@@ -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: ambrose@google.com (Ambrose Feinstein),
-// kenton@google.com (Kenton Varda)
-//
-// Based on http://www.pkware.com/documents/casestudies/APPNOTE.TXT
-
+// 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: ambrose@google.com (Ambrose Feinstein),
+// kenton@google.com (Kenton Varda)
+//
+// Based on http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+
#include <google/protobuf/compiler/zip_writer.h>
#include <cstdint>
#include <google/protobuf/io/coded_stream.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
// January 1, 1980 as a DOS date.
// see https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx
static const uint16_t kDosEpoch = 1 << 5 | 1;
@@ -91,72 +91,72 @@ static const uint32_t kCRC32Table[256] = {
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
-
+
static uint32_t ComputeCRC32(const TProtoStringType& buf) {
uint32_t x = ~0U;
- for (int i = 0; i < buf.size(); ++i) {
- unsigned char c = buf[i];
- x = kCRC32Table[(x ^ c) & 0xff] ^ (x >> 8);
- }
- return ~x;
-}
-
+ for (int i = 0; i < buf.size(); ++i) {
+ unsigned char c = buf[i];
+ x = kCRC32Table[(x ^ c) & 0xff] ^ (x >> 8);
+ }
+ return ~x;
+}
+
static void WriteShort(io::CodedOutputStream* out, uint16_t val) {
uint8_t p[2];
p[0] = static_cast<uint8_t>(val);
p[1] = static_cast<uint8_t>(val >> 8);
- out->WriteRaw(p, 2);
-}
-
-ZipWriter::ZipWriter(io::ZeroCopyOutputStream* raw_output)
+ out->WriteRaw(p, 2);
+}
+
+ZipWriter::ZipWriter(io::ZeroCopyOutputStream* raw_output)
: raw_output_(raw_output) {}
-ZipWriter::~ZipWriter() {}
-
+ZipWriter::~ZipWriter() {}
+
bool ZipWriter::Write(const TProtoStringType& filename,
const TProtoStringType& contents) {
- FileInfo info;
-
- info.name = filename;
+ FileInfo info;
+
+ info.name = filename;
uint16_t filename_size = filename.size();
- info.offset = raw_output_->ByteCount();
- info.size = contents.size();
- info.crc32 = ComputeCRC32(contents);
-
- files_.push_back(info);
-
- // write file header
- io::CodedOutputStream output(raw_output_);
- output.WriteLittleEndian32(0x04034b50); // magic
+ info.offset = raw_output_->ByteCount();
+ info.size = contents.size();
+ info.crc32 = ComputeCRC32(contents);
+
+ files_.push_back(info);
+
+ // write file header
+ io::CodedOutputStream output(raw_output_);
+ output.WriteLittleEndian32(0x04034b50); // magic
WriteShort(&output, 10); // version needed to extract
WriteShort(&output, 0); // flags
WriteShort(&output, 0); // compression method: stored
WriteShort(&output, 0); // last modified time
WriteShort(&output, kDosEpoch); // last modified date
- output.WriteLittleEndian32(info.crc32); // crc-32
+ output.WriteLittleEndian32(info.crc32); // crc-32
output.WriteLittleEndian32(info.size); // compressed size
output.WriteLittleEndian32(info.size); // uncompressed size
WriteShort(&output, filename_size); // file name length
WriteShort(&output, 0); // extra field length
output.WriteString(filename); // file name
output.WriteString(contents); // file data
-
- return !output.HadError();
-}
-
-bool ZipWriter::WriteDirectory() {
+
+ return !output.HadError();
+}
+
+bool ZipWriter::WriteDirectory() {
uint16_t num_entries = files_.size();
uint32_t dir_ofs = raw_output_->ByteCount();
-
- // write central directory
- io::CodedOutputStream output(raw_output_);
- for (int i = 0; i < num_entries; ++i) {
+
+ // write central directory
+ io::CodedOutputStream output(raw_output_);
+ for (int i = 0; i < num_entries; ++i) {
const TProtoStringType& filename = files_[i].name;
uint16_t filename_size = filename.size();
uint32_t crc32 = files_[i].crc32;
uint32_t size = files_[i].size;
uint32_t offset = files_[i].offset;
-
- output.WriteLittleEndian32(0x02014b50); // magic
+
+ output.WriteLittleEndian32(0x02014b50); // magic
WriteShort(&output, 10); // version made by
WriteShort(&output, 10); // version needed to extract
WriteShort(&output, 0); // flags
@@ -174,22 +174,22 @@ bool ZipWriter::WriteDirectory() {
output.WriteLittleEndian32(0); // external file attributes
output.WriteLittleEndian32(offset); // local header offset
output.WriteString(filename); // file name
- }
+ }
uint32_t dir_len = output.ByteCount();
-
- // write end of central directory marker
- output.WriteLittleEndian32(0x06054b50); // magic
+
+ // write end of central directory marker
+ output.WriteLittleEndian32(0x06054b50); // magic
WriteShort(&output, 0); // disk number
WriteShort(&output, 0); // disk with start of central directory
WriteShort(&output, num_entries); // central directory entries (this disk)
WriteShort(&output, num_entries); // central directory entries (total)
- output.WriteLittleEndian32(dir_len); // central directory byte size
- output.WriteLittleEndian32(dir_ofs); // central directory offset
+ output.WriteLittleEndian32(dir_len); // central directory byte size
+ output.WriteLittleEndian32(dir_ofs); // central directory offset
WriteShort(&output, 0); // comment length
-
- return output.HadError();
-}
-
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+
+ return output.HadError();
+}
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
index 147ec39194..a1ce179d89 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.h
@@ -1,65 +1,65 @@
-// 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: kenton@google.com (Kenton Varda)
-
+// 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: kenton@google.com (Kenton Varda)
+
#include <cstdint>
-#include <vector>
+#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/io/zero_copy_stream.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-
-class ZipWriter {
- public:
- ZipWriter(io::ZeroCopyOutputStream* raw_output);
- ~ZipWriter();
-
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+class ZipWriter {
+ public:
+ ZipWriter(io::ZeroCopyOutputStream* raw_output);
+ ~ZipWriter();
+
bool Write(const TProtoStringType& filename, const TProtoStringType& contents);
- bool WriteDirectory();
-
- private:
- struct FileInfo {
+ bool WriteDirectory();
+
+ private:
+ struct FileInfo {
TProtoStringType name;
uint32_t offset;
uint32_t size;
uint32_t crc32;
- };
-
- io::ZeroCopyOutputStream* raw_output_;
+ };
+
+ io::ZeroCopyOutputStream* raw_output_;
std::vector<FileInfo> files_;
-};
-
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+};
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google