aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf/compiler/java
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:12 +0300
commit49116032d905455a7b1c994e4a696afc885c1e71 (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/protoc/src/google/protobuf/compiler/java
parent4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff)
downloadydb-49116032d905455a7b1c994e4a696afc885c1e71.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/java')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc42
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.cc446
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_doc_comment.h76
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc338
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.h34
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc1556
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.h134
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc1300
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.h104
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc154
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.h34
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc70
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.h48
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.cc30
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension_lite.h10
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc186
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h102
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc460
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.h78
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc74
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.h24
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.cc24
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator_factory.h34
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc1144
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h308
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc324
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h144
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc724
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.h52
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc736
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h38
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc1856
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.h68
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc746
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.h32
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.cc124
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder_lite.h34
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc1858
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.h118
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc1040
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h84
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc1282
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.h24
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.cc398
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_name_resolver.h116
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_names.h38
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h4
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc1336
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.h136
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc936
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h96
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc374
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h28
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc104
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h38
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc1488
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.h92
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc1268
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h104
60 files changed, 11341 insertions, 11341 deletions
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 f638f6b02b..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
@@ -28,14 +28,14 @@
// (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_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>
+#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 {
@@ -47,7 +47,7 @@ Context::Context(const FileDescriptor* file, const Options& options)
InitializeFieldGeneratorInfo(file);
}
-Context::~Context() {}
+Context::~Context() {}
ClassNameResolver* Context::GetNameResolver() const {
return name_resolver_.get();
@@ -57,9 +57,9 @@ 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) {
+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.
@@ -68,14 +68,14 @@ bool IsConflicting(const FieldDescriptor* field1, const TProtoStringType& name1,
// 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()\"";
+ "field \"" + field2->name() + "\" generate the method \"" +
+ "get" + name1 + "Count()\"";
return true;
}
if (name1 + "List" == name2) {
*info = "both repeated field \"" + field1->name() + "\" and singular " +
- "field \"" + field2->name() + "\" generate the method \"" +
- "get" + name1 + "List()\"";
+ "field \"" + field2->name() + "\" generate the method \"" +
+ "get" + name1 + "List()\"";
return true;
}
// Well, there are obviously many more conflicting cases, but it probably
@@ -108,7 +108,7 @@ void Context::InitializeFieldGeneratorInfoForMessage(
InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
}
std::vector<const FieldDescriptor*> fields;
- fields.reserve(message->field_count());
+ fields.reserve(message->field_count());
for (int i = 0; i < message->field_count(); ++i) {
fields.push_back(message->field(i));
}
@@ -128,13 +128,13 @@ void Context::InitializeFieldGeneratorInfoForFields(
// 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());
+ std::vector<TProtoStringType> conflict_reason(fields.size());
for (int i = 0; i < fields.size(); ++i) {
const FieldDescriptor* field = fields[i];
- const TProtoStringType& name = UnderscoresToCapitalizedCamelCase(field);
+ const TProtoStringType& name = UnderscoresToCapitalizedCamelCase(field);
for (int j = i + 1; j < fields.size(); ++j) {
const FieldDescriptor* other = fields[j];
- const TProtoStringType& other_name = UnderscoresToCapitalizedCamelCase(other);
+ const TProtoStringType& other_name = UnderscoresToCapitalizedCamelCase(other);
if (name == other_name) {
is_conflict[i] = is_conflict[j] = true;
conflict_reason[i] = conflict_reason[j] =
@@ -159,8 +159,8 @@ void Context::InitializeFieldGeneratorInfoForFields(
// 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.name += StrCat(field->number());
+ info.capitalized_name += StrCat(field->number());
info.disambiguated_reason = conflict_reason[i];
}
field_generator_info_map_[field] = info;
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 e8d9f341d4..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
@@ -35,25 +35,25 @@
#include <memory>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/compiler/java/java_options.h>
namespace google {
namespace protobuf {
-class FileDescriptor;
-class FieldDescriptor;
-class OneofDescriptor;
-class Descriptor;
-class EnumDescriptor;
-namespace compiler {
-namespace java {
-class ClassNameResolver; // name_resolver.h
-}
-} // namespace compiler
+class FileDescriptor;
+class FieldDescriptor;
+class OneofDescriptor;
+class Descriptor;
+class EnumDescriptor;
+namespace compiler {
+namespace java {
+class ClassNameResolver; // name_resolver.h
+}
+} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -96,7 +96,7 @@ class Context {
void InitializeFieldGeneratorInfoForFields(
const std::vector<const FieldDescriptor*>& fields);
- std::unique_ptr<ClassNameResolver> name_resolver_;
+ std::unique_ptr<ClassNameResolver> name_resolver_;
std::map<const FieldDescriptor*, FieldGeneratorInfo>
field_generator_info_map_;
std::map<const OneofDescriptor*, OneofGeneratorInfo>
@@ -108,6 +108,6 @@ class Context {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 f7dbd50c40..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
@@ -32,25 +32,25 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_doc_comment.h>
+#include <google/protobuf/compiler/java/java_doc_comment.h>
#include <vector>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
namespace compiler {
namespace java {
-TProtoStringType EscapeJavadoc(const TProtoStringType& input) {
- TProtoStringType result;
+TProtoStringType EscapeJavadoc(const TProtoStringType& input) {
+ TProtoStringType result;
result.reserve(input.size() * 2);
char prev = '*';
- for (TProtoStringType::size_type i = 0; i < input.size(); i++) {
+ for (TProtoStringType::size_type i = 0; i < input.size(); i++) {
char c = input[i];
switch (c) {
case '*':
@@ -102,11 +102,11 @@ TProtoStringType EscapeJavadoc(const TProtoStringType& input) {
return result;
}
-static void WriteDocCommentBodyForLocation(io::Printer* printer,
- const SourceLocation& location) {
- TProtoStringType comments = location.leading_comments.empty()
- ? location.trailing_comments
- : location.leading_comments;
+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
@@ -116,7 +116,7 @@ static void WriteDocCommentBodyForLocation(io::Printer* printer,
// HTML-escape them so that they don't accidentally close the doc comment.
comments = EscapeJavadoc(comments);
- std::vector<TProtoStringType> lines = Split(comments, "\n");
+ std::vector<TProtoStringType> lines = Split(comments, "\n");
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
}
@@ -139,19 +139,19 @@ static void WriteDocCommentBodyForLocation(io::Printer* printer,
}
template <typename DescriptorType>
-static void WriteDocCommentBody(io::Printer* printer,
- const DescriptorType* descriptor) {
+static void WriteDocCommentBody(io::Printer* printer,
+ const DescriptorType* descriptor) {
SourceLocation location;
if (descriptor->GetSourceLocation(&location)) {
WriteDocCommentBodyForLocation(printer, location);
}
}
-static TProtoStringType FirstLineOf(const TProtoStringType& value) {
- TProtoStringType result = value;
+static TProtoStringType FirstLineOf(const TProtoStringType& value) {
+ TProtoStringType result = value;
- TProtoStringType::size_type pos = result.find_first_of('\n');
- if (pos != TProtoStringType::npos) {
+ TProtoStringType::size_type pos = result.find_first_of('\n');
+ if (pos != TProtoStringType::npos) {
result.erase(pos);
}
@@ -167,217 +167,217 @@ 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()));
+ " * 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
- // .proto file (if present). We then continue with the field declaration,
- // e.g.:
+ // .proto file (if present). We then continue with the field declaration,
+ // e.g.:
// optional string foo = 5;
- // And then we end with the javadoc tags if applicable.
+ // 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);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
+ printer->Print(" * <code>$def$</code>\n", "def",
+ EscapeJavadoc(FirstLineOf(field->DebugString())));
printer->Print(" */\n");
}
-void WriteFieldAccessorDocComment(io::Printer* printer,
- const FieldDescriptor* field,
- const FieldAccessorType type,
- const bool builder) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
- switch (type) {
- case HAZZER:
- printer->Print(" * @return Whether the $name$ field is set.\n", "name",
- field->camelcase_name());
- break;
- case GETTER:
- printer->Print(" * @return The $name$.\n", "name",
- field->camelcase_name());
- break;
- case SETTER:
- printer->Print(" * @param value The $name$ to set.\n", "name",
- field->camelcase_name());
- break;
- case CLEARER:
- // Print nothing
- break;
- // Repeated
- case LIST_COUNT:
- printer->Print(" * @return The count of $name$.\n", "name",
- field->camelcase_name());
- break;
- case LIST_GETTER:
- printer->Print(" * @return A list containing the $name$.\n", "name",
- field->camelcase_name());
- break;
- case LIST_INDEXED_GETTER:
- printer->Print(" * @param index The index of the element to return.\n");
- printer->Print(" * @return The $name$ at the given index.\n", "name",
- field->camelcase_name());
- break;
- case LIST_INDEXED_SETTER:
- printer->Print(" * @param index The index to set the value at.\n");
- printer->Print(" * @param value The $name$ to set.\n", "name",
- field->camelcase_name());
- break;
- case LIST_ADDER:
- printer->Print(" * @param value The $name$ to add.\n", "name",
- field->camelcase_name());
- break;
- case LIST_MULTI_ADDER:
- printer->Print(" * @param values The $name$ to add.\n", "name",
- field->camelcase_name());
- break;
- }
- if (builder) {
- printer->Print(" * @return This builder for chaining.\n");
- }
- printer->Print(" */\n");
-}
-
-void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
- const FieldDescriptor* field,
- const FieldAccessorType type,
- const bool builder) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
- switch (type) {
- case HAZZER:
- // Should never happen
- break;
- case GETTER:
- printer->Print(
- " * @return The enum numeric value on the wire for $name$.\n", "name",
- field->camelcase_name());
- break;
- case SETTER:
- printer->Print(
- " * @param value The enum numeric value on the wire for $name$ to "
- "set.\n",
- "name", field->camelcase_name());
- break;
- case CLEARER:
- // Print nothing
- break;
- // Repeated
- case LIST_COUNT:
- // Should never happen
- break;
- case LIST_GETTER:
- printer->Print(
- " * @return A list containing the enum numeric values on the wire "
- "for $name$.\n",
- "name", field->camelcase_name());
- break;
- case LIST_INDEXED_GETTER:
- printer->Print(" * @param index The index of the value to return.\n");
- printer->Print(
- " * @return The enum numeric value on the wire of $name$ at the "
- "given index.\n",
- "name", field->camelcase_name());
- break;
- case LIST_INDEXED_SETTER:
- printer->Print(" * @param index The index to set the value at.\n");
- printer->Print(
- " * @param value The enum numeric value on the wire for $name$ to "
- "set.\n",
- "name", field->camelcase_name());
- break;
- case LIST_ADDER:
- printer->Print(
- " * @param value The enum numeric value on the wire for $name$ to "
- "add.\n",
- "name", field->camelcase_name());
- break;
- case LIST_MULTI_ADDER:
- printer->Print(
- " * @param values The enum numeric values on the wire for $name$ to "
- "add.\n",
- "name", field->camelcase_name());
- break;
- }
- if (builder) {
- printer->Print(" * @return This builder for chaining.\n");
- }
- printer->Print(" */\n");
-}
-
-void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
- const FieldDescriptor* field,
- const FieldAccessorType type,
- const bool builder) {
- printer->Print("/**\n");
- WriteDocCommentBody(printer, field);
- printer->Print(" * <code>$def$</code>\n", "def",
- EscapeJavadoc(FirstLineOf(field->DebugString())));
- switch (type) {
- case HAZZER:
- // Should never happen
- break;
- case GETTER:
- printer->Print(" * @return The bytes for $name$.\n", "name",
- field->camelcase_name());
- break;
- case SETTER:
- printer->Print(" * @param value The bytes for $name$ to set.\n", "name",
- field->camelcase_name());
- break;
- case CLEARER:
- // Print nothing
- break;
- // Repeated
- case LIST_COUNT:
- // Should never happen
- break;
- case LIST_GETTER:
- printer->Print(" * @return A list containing the bytes for $name$.\n",
- "name", field->camelcase_name());
- break;
- case LIST_INDEXED_GETTER:
- printer->Print(" * @param index The index of the value to return.\n");
- printer->Print(" * @return The bytes of the $name$ at the given index.\n",
- "name", field->camelcase_name());
- break;
- case LIST_INDEXED_SETTER:
- printer->Print(" * @param index The index to set the value at.\n");
- printer->Print(" * @param value The bytes of the $name$ to set.\n",
- "name", field->camelcase_name());
- break;
- case LIST_ADDER:
- printer->Print(" * @param value The bytes of the $name$ to add.\n",
- "name", field->camelcase_name());
- break;
- case LIST_MULTI_ADDER:
- printer->Print(" * @param values The bytes of the $name$ to add.\n",
- "name", field->camelcase_name());
- break;
- }
- if (builder) {
- printer->Print(" * @return This builder for chaining.\n");
- }
- printer->Print(" */\n");
-}
-
-// Enum
-
+void WriteFieldAccessorDocComment(io::Printer* printer,
+ const FieldDescriptor* field,
+ const FieldAccessorType type,
+ const bool builder) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, field);
+ printer->Print(" * <code>$def$</code>\n", "def",
+ EscapeJavadoc(FirstLineOf(field->DebugString())));
+ switch (type) {
+ case HAZZER:
+ printer->Print(" * @return Whether the $name$ field is set.\n", "name",
+ field->camelcase_name());
+ break;
+ case GETTER:
+ printer->Print(" * @return The $name$.\n", "name",
+ field->camelcase_name());
+ break;
+ case SETTER:
+ printer->Print(" * @param value The $name$ to set.\n", "name",
+ field->camelcase_name());
+ break;
+ case CLEARER:
+ // Print nothing
+ break;
+ // Repeated
+ case LIST_COUNT:
+ printer->Print(" * @return The count of $name$.\n", "name",
+ field->camelcase_name());
+ break;
+ case LIST_GETTER:
+ printer->Print(" * @return A list containing the $name$.\n", "name",
+ field->camelcase_name());
+ break;
+ case LIST_INDEXED_GETTER:
+ printer->Print(" * @param index The index of the element to return.\n");
+ printer->Print(" * @return The $name$ at the given index.\n", "name",
+ field->camelcase_name());
+ break;
+ case LIST_INDEXED_SETTER:
+ printer->Print(" * @param index The index to set the value at.\n");
+ printer->Print(" * @param value The $name$ to set.\n", "name",
+ field->camelcase_name());
+ break;
+ case LIST_ADDER:
+ printer->Print(" * @param value The $name$ to add.\n", "name",
+ field->camelcase_name());
+ break;
+ case LIST_MULTI_ADDER:
+ printer->Print(" * @param values The $name$ to add.\n", "name",
+ field->camelcase_name());
+ break;
+ }
+ if (builder) {
+ printer->Print(" * @return This builder for chaining.\n");
+ }
+ printer->Print(" */\n");
+}
+
+void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
+ const FieldDescriptor* field,
+ const FieldAccessorType type,
+ const bool builder) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, field);
+ printer->Print(" * <code>$def$</code>\n", "def",
+ EscapeJavadoc(FirstLineOf(field->DebugString())));
+ switch (type) {
+ case HAZZER:
+ // Should never happen
+ break;
+ case GETTER:
+ printer->Print(
+ " * @return The enum numeric value on the wire for $name$.\n", "name",
+ field->camelcase_name());
+ break;
+ case SETTER:
+ printer->Print(
+ " * @param value The enum numeric value on the wire for $name$ to "
+ "set.\n",
+ "name", field->camelcase_name());
+ break;
+ case CLEARER:
+ // Print nothing
+ break;
+ // Repeated
+ case LIST_COUNT:
+ // Should never happen
+ break;
+ case LIST_GETTER:
+ printer->Print(
+ " * @return A list containing the enum numeric values on the wire "
+ "for $name$.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_INDEXED_GETTER:
+ printer->Print(" * @param index The index of the value to return.\n");
+ printer->Print(
+ " * @return The enum numeric value on the wire of $name$ at the "
+ "given index.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_INDEXED_SETTER:
+ printer->Print(" * @param index The index to set the value at.\n");
+ printer->Print(
+ " * @param value The enum numeric value on the wire for $name$ to "
+ "set.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_ADDER:
+ printer->Print(
+ " * @param value The enum numeric value on the wire for $name$ to "
+ "add.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_MULTI_ADDER:
+ printer->Print(
+ " * @param values The enum numeric values on the wire for $name$ to "
+ "add.\n",
+ "name", field->camelcase_name());
+ break;
+ }
+ if (builder) {
+ printer->Print(" * @return This builder for chaining.\n");
+ }
+ printer->Print(" */\n");
+}
+
+void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
+ const FieldDescriptor* field,
+ const FieldAccessorType type,
+ const bool builder) {
+ printer->Print("/**\n");
+ WriteDocCommentBody(printer, field);
+ printer->Print(" * <code>$def$</code>\n", "def",
+ EscapeJavadoc(FirstLineOf(field->DebugString())));
+ switch (type) {
+ case HAZZER:
+ // Should never happen
+ break;
+ case GETTER:
+ printer->Print(" * @return The bytes for $name$.\n", "name",
+ field->camelcase_name());
+ break;
+ case SETTER:
+ printer->Print(" * @param value The bytes for $name$ to set.\n", "name",
+ field->camelcase_name());
+ break;
+ case CLEARER:
+ // Print nothing
+ break;
+ // Repeated
+ case LIST_COUNT:
+ // Should never happen
+ break;
+ case LIST_GETTER:
+ printer->Print(" * @return A list containing the bytes for $name$.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_INDEXED_GETTER:
+ printer->Print(" * @param index The index of the value to return.\n");
+ printer->Print(" * @return The bytes of the $name$ at the given index.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_INDEXED_SETTER:
+ printer->Print(" * @param index The index to set the value at.\n");
+ printer->Print(" * @param value The bytes of the $name$ to set.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_ADDER:
+ printer->Print(" * @param value The bytes of the $name$ to add.\n",
+ "name", field->camelcase_name());
+ break;
+ case LIST_MULTI_ADDER:
+ printer->Print(" * @param values The bytes of the $name$ to add.\n",
+ "name", field->camelcase_name());
+ break;
+ }
+ if (builder) {
+ printer->Print(" * @return This builder for chaining.\n");
+ }
+ printer->Print(" */\n");
+}
+
+// Enum
+
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()));
+ " * Protobuf enum {@code $fullname$}\n"
+ " */\n",
+ "fullname", EscapeJavadoc(enum_->full_name()));
}
void WriteEnumValueDocComment(io::Printer* printer,
@@ -385,9 +385,9 @@ void WriteEnumValueDocComment(io::Printer* printer,
printer->Print("/**\n");
WriteDocCommentBody(printer, value);
printer->Print(
- " * <code>$def$</code>\n"
- " */\n",
- "def", EscapeJavadoc(FirstLineOf(value->DebugString())));
+ " * <code>$def$</code>\n"
+ " */\n",
+ "def", EscapeJavadoc(FirstLineOf(value->DebugString())));
}
void WriteServiceDocComment(io::Printer* printer,
@@ -395,9 +395,9 @@ void WriteServiceDocComment(io::Printer* printer,
printer->Print("/**\n");
WriteDocCommentBody(printer, service);
printer->Print(
- " * Protobuf service {@code $fullname$}\n"
- " */\n",
- "fullname", EscapeJavadoc(service->full_name()));
+ " * Protobuf service {@code $fullname$}\n"
+ " */\n",
+ "fullname", EscapeJavadoc(service->full_name()));
}
void WriteMethodDocComment(io::Printer* printer,
@@ -405,9 +405,9 @@ void WriteMethodDocComment(io::Printer* printer,
printer->Print("/**\n");
WriteDocCommentBody(printer, method);
printer->Print(
- " * <code>$def$</code>\n"
- " */\n",
- "def", EscapeJavadoc(FirstLineOf(method->DebugString())));
+ " * <code>$def$</code>\n"
+ " */\n",
+ "def", EscapeJavadoc(FirstLineOf(method->DebugString())));
}
} // namespace java
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 9712b153b9..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
@@ -35,51 +35,51 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__
-#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.h>
+
+#include <google/protobuf/port_def.inc>
-#include <google/protobuf/port_def.inc>
-
namespace google {
namespace protobuf {
-namespace io {
-class Printer; // printer.h
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
-enum FieldAccessorType {
- HAZZER,
- GETTER,
- SETTER,
- CLEARER,
- // Repeated
- LIST_COUNT,
- LIST_GETTER,
- LIST_INDEXED_GETTER,
- LIST_INDEXED_SETTER,
- LIST_ADDER,
- LIST_MULTI_ADDER
-};
-
+enum FieldAccessorType {
+ HAZZER,
+ GETTER,
+ SETTER,
+ CLEARER,
+ // Repeated
+ LIST_COUNT,
+ LIST_GETTER,
+ LIST_INDEXED_GETTER,
+ LIST_INDEXED_SETTER,
+ LIST_ADDER,
+ LIST_MULTI_ADDER
+};
+
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,
- const bool builder = false);
-void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
- const FieldDescriptor* field,
- const FieldAccessorType type,
- const bool builder = false);
-void WriteFieldStringBytesAccessorDocComment(io::Printer* printer,
- const FieldDescriptor* field,
- const FieldAccessorType type,
- const bool builder = false);
+void WriteFieldAccessorDocComment(io::Printer* printer,
+ const FieldDescriptor* field,
+ const FieldAccessorType type,
+ const bool builder = false);
+void WriteFieldEnumValueAccessorDocComment(io::Printer* printer,
+ const FieldDescriptor* field,
+ const FieldAccessorType type,
+ const bool builder = false);
+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);
@@ -89,13 +89,13 @@ void WriteMethodDocComment(io::Printer* printer,
const MethodDescriptor* method);
// Exposed for testing only.
-PROTOC_EXPORT TProtoStringType EscapeJavadoc(const TProtoStringType& input);
+PROTOC_EXPORT TProtoStringType EscapeJavadoc(const TProtoStringType& input);
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
+
+#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/port_undef.inc>
-
#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 064b49e905..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
@@ -33,16 +33,16 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <map>
-#include <string>
+#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>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
+#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>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -50,15 +50,15 @@ 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()) {
+ 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());
+ descriptor_->FindValueByNumber(value->number());
if (value == canonical_value) {
canonical_values_.push_back(value);
@@ -77,15 +77,15 @@ void EnumGenerator::Generate(io::Printer* printer) {
WriteEnumDocComment(printer, descriptor_);
MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
printer->Print(
- "$deprecation$public enum $classname$\n"
+ "$deprecation$public enum $classname$\n"
" implements com.google.protobuf.ProtocolMessageEnum {\n",
- "classname", descriptor_->name(), "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "");
+ "classname", descriptor_->name(), "deprecation",
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "");
printer->Annotate("classname", descriptor_);
printer->Indent();
bool ordinal_is_index = true;
- TProtoStringType index_text = "ordinal()";
+ TProtoStringType index_text = "ordinal()";
for (int i = 0; i < canonical_values_.size(); i++) {
if (canonical_values_[i]->index() != i) {
ordinal_is_index = false;
@@ -95,18 +95,18 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < canonical_values_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["name"] = canonical_values_[i]->name();
- vars["index"] = StrCat(canonical_values_[i]->index());
- vars["number"] = StrCat(canonical_values_[i]->number());
+ 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) {
- printer->Print(vars, "$name$($number$),\n");
+ printer->Print(vars, "$name$($number$),\n");
} else {
- printer->Print(vars, "$name$($index$, $number$),\n");
+ printer->Print(vars, "$name$($index$, $number$),\n");
}
printer->Annotate("name", canonical_values_[i]);
}
@@ -121,35 +121,35 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
printer->Print(
- ";\n"
- "\n");
+ ";\n"
+ "\n");
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ 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);
- printer->Print(
- vars, "public static final $classname$ $name$ = $canonical_name$;\n");
+ 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++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["name"] = descriptor_->value(i)->name();
- vars["number"] = StrCat(descriptor_->value(i)->number());
+ vars["number"] = StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
- vars["deprecation"] = descriptor_->value(i)->options().deprecated()
- ? "@java.lang.Deprecated "
- : "";
+ vars["deprecation"] = descriptor_->value(i)->options().deprecated()
+ ? "@java.lang.Deprecated "
+ : "";
WriteEnumValueDocComment(printer, descriptor_->value(i));
printer->Print(vars,
- "$deprecation$public static final int ${$$name$_VALUE$}$ = "
- "$number$;\n");
+ "$deprecation$public static final int ${$$name$_VALUE$}$ = "
+ "$number$;\n");
printer->Annotate("{", "}", descriptor_->value(i));
}
printer->Print("\n");
@@ -157,110 +157,110 @@ void EnumGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
printer->Print(
- "\n"
- "public final int getNumber() {\n");
+ "\n"
+ "public final int getNumber() {\n");
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");
+ " 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(
- " if (index == -1) {\n"
- " throw new java.lang.IllegalArgumentException(\n"
- " \"Can't get the number of an unknown enum value.\");\n"
- " }\n");
+ " if (index == -1) {\n"
+ " throw new java.lang.IllegalArgumentException(\n"
+ " \"Can't get the number of an unknown enum value.\");\n"
+ " }\n");
}
}
printer->Print(
- " return value;\n"
- "}\n"
- "\n"
- "/**\n"
- " * @param value The numeric wire value of the corresponding enum "
- "entry.\n"
- " * @return The enum associated with the given numeric wire value.\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $classname$ valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
- "/**\n"
- " * @param value The numeric wire value of the corresponding enum "
- "entry.\n"
- " * @return The enum associated with the given numeric wire value.\n"
- " */\n"
- "public static $classname$ forNumber(int value) {\n"
- " switch (value) {\n",
- "classname", descriptor_->name());
+ " return value;\n"
+ "}\n"
+ "\n"
+ "/**\n"
+ " * @param value The numeric wire value of the corresponding enum "
+ "entry.\n"
+ " * @return The enum associated with the given numeric wire value.\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $classname$ valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n"
+ "/**\n"
+ " * @param value The numeric wire value of the corresponding enum "
+ "entry.\n"
+ " * @return The enum associated with the given numeric wire value.\n"
+ " */\n"
+ "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->Print("case $number$: return $name$;\n", "name",
- canonical_values_[i]->name(), "number",
- StrCat(canonical_values_[i]->number()));
+ printer->Print("case $number$: return $name$;\n", "name",
+ canonical_values_[i]->name(), "number",
+ StrCat(canonical_values_[i]->number()));
}
printer->Outdent();
printer->Outdent();
printer->Print(
- " default: return null;\n"
- " }\n"
- "}\n"
- "\n"
- "public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\n"
- " internalGetValueMap() {\n"
- " return internalValueMap;\n"
- "}\n"
- "private static final com.google.protobuf.Internal.EnumLiteMap<\n"
- " $classname$> internalValueMap =\n"
- " new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
- " public $classname$ findValueByNumber(int number) {\n"
- " return $classname$.forNumber(number);\n"
- " }\n"
- " };\n"
- "\n",
- "classname", descriptor_->name());
+ " default: return null;\n"
+ " }\n"
+ "}\n"
+ "\n"
+ "public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\n"
+ " internalGetValueMap() {\n"
+ " return internalValueMap;\n"
+ "}\n"
+ "private static final com.google.protobuf.Internal.EnumLiteMap<\n"
+ " $classname$> internalValueMap =\n"
+ " new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
+ " public $classname$ findValueByNumber(int number) {\n"
+ " return $classname$.forNumber(number);\n"
+ " }\n"
+ " };\n"
+ "\n",
+ "classname", descriptor_->name());
// -----------------------------------------------------------------
// Reflection
if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) {
printer->Print(
- "public final com.google.protobuf.Descriptors.EnumValueDescriptor\n"
- " getValueDescriptor() {\n");
- if (SupportUnknownEnumValue(descriptor_->file())) {
- if (ordinal_is_index) {
- printer->Print(
- " if (this == UNRECOGNIZED) {\n"
- " throw new java.lang.IllegalStateException(\n"
- " \"Can't get the descriptor of an unrecognized enum "
- "value.\");\n"
- " }\n");
- } else {
- printer->Print(
- " if (index == -1) {\n"
- " throw new java.lang.IllegalStateException(\n"
- " \"Can't get the descriptor of an unrecognized enum "
- "value.\");\n"
- " }\n");
- }
- }
- printer->Print(
- " return getDescriptor().getValues().get($index_text$);\n"
- "}\n"
- "public final com.google.protobuf.Descriptors.EnumDescriptor\n"
- " getDescriptorForType() {\n"
- " return getDescriptor();\n"
- "}\n"
- "public static final com.google.protobuf.Descriptors.EnumDescriptor\n"
- " getDescriptor() {\n",
- "index_text", index_text);
+ "public final com.google.protobuf.Descriptors.EnumValueDescriptor\n"
+ " getValueDescriptor() {\n");
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ if (ordinal_is_index) {
+ printer->Print(
+ " if (this == UNRECOGNIZED) {\n"
+ " throw new java.lang.IllegalStateException(\n"
+ " \"Can't get the descriptor of an unrecognized enum "
+ "value.\");\n"
+ " }\n");
+ } else {
+ printer->Print(
+ " if (index == -1) {\n"
+ " throw new java.lang.IllegalStateException(\n"
+ " \"Can't get the descriptor of an unrecognized enum "
+ "value.\");\n"
+ " }\n");
+ }
+ }
+ printer->Print(
+ " return getDescriptor().getValues().get($index_text$);\n"
+ "}\n"
+ "public final com.google.protobuf.Descriptors.EnumDescriptor\n"
+ " getDescriptorForType() {\n"
+ " return getDescriptor();\n"
+ "}\n"
+ "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
@@ -270,30 +270,30 @@ void EnumGenerator::Generate(io::Printer* printer) {
// extensions in both the mutable and immutable cases. (In the mutable api
// this is accomplished by attempting to load the immutable outer class).
printer->Print(
- " return $file$.getDescriptor().getEnumTypes().get($index$);\n",
- "file",
- name_resolver_->GetClassName(descriptor_->file(), immutable_api_),
- "index", StrCat(descriptor_->index()));
+ " return $file$.getDescriptor().getEnumTypes().get($index$);\n",
+ "file",
+ name_resolver_->GetClassName(descriptor_->file(), immutable_api_),
+ "index", StrCat(descriptor_->index()));
} else {
printer->Print(
" return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
- "parent",
- name_resolver_->GetClassName(descriptor_->containing_type(),
- immutable_api_),
- "descriptor",
- descriptor_->containing_type()
- ->options()
- .no_standard_descriptor_accessor()
- ? "getDefaultInstance().getDescriptorForType()"
- : "getDescriptor()",
- "index", StrCat(descriptor_->index()));
+ "parent",
+ name_resolver_->GetClassName(descriptor_->containing_type(),
+ immutable_api_),
+ "descriptor",
+ descriptor_->containing_type()
+ ->options()
+ .no_standard_descriptor_accessor()
+ ? "getDefaultInstance().getDescriptorForType()"
+ : "getDescriptor()",
+ "index", StrCat(descriptor_->index()));
}
printer->Print(
- "}\n"
- "\n"
- "private static final $classname$[] VALUES = ",
- "classname", descriptor_->name());
+ "}\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
@@ -302,43 +302,43 @@ void EnumGenerator::Generate(io::Printer* printer) {
// 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("getStaticValuesArray();\n");
+ printer->Print("private static $classname$[] getStaticValuesArray() {\n",
+ "classname", descriptor_->name());
+ printer->Indent();
printer->Print(
- "return new $classname$[] {\n"
- " ",
- "classname", descriptor_->name());
+ "return new $classname$[] {\n"
+ " ",
+ "classname", descriptor_->name());
for (int i = 0; i < descriptor_->value_count(); i++) {
- printer->Print("$name$, ", "name", descriptor_->value(i)->name());
+ printer->Print("$name$, ", "name", descriptor_->value(i)->name());
}
printer->Print(
"\n"
"};\n");
- printer->Outdent();
- printer->Print("}");
+ printer->Outdent();
+ printer->Print("}");
}
printer->Print(
- "\n"
- "public static $classname$ valueOf(\n"
- " com.google.protobuf.Descriptors.EnumValueDescriptor desc) {\n"
- " if (desc.getType() != getDescriptor()) {\n"
- " throw new java.lang.IllegalArgumentException(\n"
- " \"EnumValueDescriptor is not for this type.\");\n"
- " }\n",
- "classname", descriptor_->name());
+ "\n"
+ "public static $classname$ valueOf(\n"
+ " com.google.protobuf.Descriptors.EnumValueDescriptor desc) {\n"
+ " if (desc.getType() != getDescriptor()) {\n"
+ " throw new java.lang.IllegalArgumentException(\n"
+ " \"EnumValueDescriptor is not for this type.\");\n"
+ " }\n",
+ "classname", descriptor_->name());
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(
- " if (desc.getIndex() == -1) {\n"
- " return UNRECOGNIZED;\n"
- " }\n");
+ " if (desc.getIndex() == -1) {\n"
+ " return UNRECOGNIZED;\n"
+ " }\n");
}
printer->Print(
- " return VALUES[desc.getIndex()];\n"
- "}\n"
- "\n");
+ " return VALUES[desc.getIndex()];\n"
+ "}\n"
+ "\n");
if (!ordinal_is_index) {
printer->Print("private final int index;\n");
@@ -347,27 +347,27 @@ void EnumGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
- printer->Print("private final int value;\n\n");
+ printer->Print("private final int value;\n\n");
if (ordinal_is_index) {
- printer->Print("private $classname$(int value) {\n", "classname",
- descriptor_->name());
+ printer->Print("private $classname$(int value) {\n", "classname",
+ descriptor_->name());
} else {
- printer->Print("private $classname$(int index, int value) {\n", "classname",
- descriptor_->name());
+ 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(
- " this.value = value;\n"
- "}\n");
+ " this.value = value;\n"
+ "}\n");
printer->Print(
- "\n"
- "// @@protoc_insertion_point(enum_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\n"
+ "// @@protoc_insertion_point(enum_scope:$full_name$)\n",
+ "full_name", descriptor_->full_name());
printer->Outdent();
printer->Print("}\n\n");
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 6dbd9a36e1..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
@@ -35,25 +35,25 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
-#include <string>
+#include <string>
#include <vector>
-#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -69,9 +69,9 @@ class EnumGenerator {
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
+ // 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.
std::vector<const EnumValueDescriptor*> canonical_values_;
@@ -95,6 +95,6 @@ class EnumGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 f0ab4ed804..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
@@ -32,21 +32,21 @@
// 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 <google/protobuf/compiler/java/java_enum_field.h>
+
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <string>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -55,41 +55,41 @@ namespace java {
namespace {
-void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
+void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->enum_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ (*variables)["kt_type"] = (*variables)["type"];
(*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(
+ (*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
- (*variables)["deprecation"] =
- descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@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
- // with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations.
+ // with v2.5.0/v2.6.1, and remove the @SuppressWarnings annotations.
(*variables)["for_number"] = "valueOf";
- if (HasHasbit(descriptor)) {
+ 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);
@@ -109,11 +109,11 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["clear_has_field_bit_builder"] = "";
(*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"] +
- ".getNumber()";
+ (*variables)["name"] + "_ != " + (*variables)["default"] +
+ ".getNumber()";
}
- // For repeated builders, one bit is used for whether the array is immutable.
+ // 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);
@@ -141,499 +141,499 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// ===================================================================
-ImmutableEnumFieldGenerator::ImmutableEnumFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ImmutableEnumFieldGenerator::ImmutableEnumFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ Context* context)
+ : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ context->GetFieldGeneratorInfo(descriptor), name_resolver_,
+ &variables_);
}
ImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {}
int ImmutableEnumFieldGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ return HasHasbit(descriptor_) ? 1 : 0;
}
int ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
+ return GetNumBitsForMessage();
}
-void ImmutableEnumFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutableEnumFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean has$capitalized_name$();\n");
}
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Value();\n");
+ "$deprecation$int get$capitalized_name$Value();\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\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");
+void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const {
+ printer->Print(variables_, "private int $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "@java.lang.Override $deprecation$public boolean "
- "${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ "@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())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override $deprecation$public int "
- "${$get$capitalized_name$Value$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@java.lang.Override $deprecation$public int "
+ "${$get$capitalized_name$Value$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override $deprecation$public $type$ "
- "${$get$capitalized_name$$}$() {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$($name$_);\n"
- " return result == null ? $unknown$ : result;\n"
- "}\n");
+ "@java.lang.Override $deprecation$public $type$ "
+ "${$get$capitalized_name$$}$() {\n"
+ " @SuppressWarnings(\"deprecation\")\n"
+ " $type$ result = $type$.$for_number$($name$_);\n"
+ " 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);
+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_,
- "@java.lang.Override $deprecation$public boolean "
- "${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_builder$;\n"
- "}\n");
+ "@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())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override $deprecation$public int "
- "${$get$capitalized_name$Value$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@java.lang.Override $deprecation$public int "
+ "${$get$capitalized_name$Value$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$Value$}$(int value) {\n"
- " $set_has_field_bit_builder$\n"
- " $name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$Value$}$(int value) {\n"
+ " $set_has_field_bit_builder$\n"
+ " $name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$($name$_);\n"
- " return result == null ? $unknown$ : result;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " @SuppressWarnings(\"deprecation\")\n"
+ " $type$ result = $type$.$for_number$($name$_);\n"
+ " return result == null ? $unknown$ : result;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n"
- " $set_has_field_bit_builder$\n"
- " $name$_ = value.getNumber();\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ " }\n"
+ " $set_has_field_bit_builder$\n"
+ " $name$_ = value.getNumber();\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " $clear_has_field_bit_builder$\n"
+ " $name$_ = $default_number$;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $clear_has_field_bit_builder$\n"
- " $name$_ = $default_number$;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
}
-void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
- }
-}
-
-void ImmutableEnumFieldGenerator::GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+ }
+}
+
+void ImmutableEnumFieldGenerator::GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const {
// noop for enums
}
-void ImmutableEnumFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $default_number$;\n");
}
-void ImmutableEnumFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = $default_number$;\n"
- "$clear_has_field_bit_builder$\n");
+ "$name$_ = $default_number$;\n"
+ "$clear_has_field_bit_builder$\n");
}
-void ImmutableEnumFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
+void ImmutableEnumFieldGenerator::GenerateMergingCode(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
printer->Print(variables_,
- "if (other.has$capitalized_name$()) {\n"
- " set$capitalized_name$(other.get$capitalized_name$());\n"
- "}\n");
+ "if (other.has$capitalized_name$()) {\n"
+ " set$capitalized_name$(other.get$capitalized_name$());\n"
+ "}\n");
} 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");
+ 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.";
}
}
-void ImmutableEnumFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
+void ImmutableEnumFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
+ "if ($get_has_field_bit_from_local$) {\n"
+ " $set_has_field_bit_to_local$;\n"
+ "}\n");
}
- printer->Print(variables_, "result.$name$_ = $name$_;\n");
+ printer->Print(variables_, "result.$name$_ = $name$_;\n");
}
-void ImmutableEnumFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = rawValue;\n");
+ "int rawValue = input.readEnum();\n"
+ "$set_has_field_bit_message$\n"
+ "$name$_ = rawValue;\n");
} else {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- " @SuppressWarnings(\"deprecation\")\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
- "if (value == null) {\n"
- " unknownFields.mergeVarintField($number$, rawValue);\n"
- "} else {\n"
- " $set_has_field_bit_message$\n"
- " $name$_ = rawValue;\n"
- "}\n");
+ "int rawValue = input.readEnum();\n"
+ " @SuppressWarnings(\"deprecation\")\n"
+ "$type$ value = $type$.$for_number$(rawValue);\n"
+ "if (value == null) {\n"
+ " unknownFields.mergeVarintField($number$, rawValue);\n"
+ "} else {\n"
+ " $set_has_field_bit_message$\n"
+ " $name$_ = rawValue;\n"
+ "}\n");
}
}
-void ImmutableEnumFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
// noop for enums
}
-void ImmutableEnumFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($is_field_present_message$) {\n"
- " output.writeEnum($number$, $name$_);\n"
- "}\n");
+ "if ($is_field_present_message$) {\n"
+ " output.writeEnum($number$, $name$_);\n"
+ "}\n");
}
-void ImmutableEnumFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($is_field_present_message$) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .computeEnumSize($number$, $name$_);\n"
- "}\n");
+ "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::GenerateEqualsCode(
+ io::Printer* printer) const {
+ printer->Print(variables_, "if ($name$_ != other.$name$_) return false;\n");
}
-void ImmutableEnumFieldGenerator::GenerateHashCode(io::Printer* printer) const {
+void ImmutableEnumFieldGenerator::GenerateHashCode(io::Printer* printer) const {
printer->Print(variables_,
- "hash = (37 * hash) + $constant_name$;\n"
- "hash = (53 * hash) + $name$_;\n");
+ "hash = (37 * hash) + $constant_name$;\n"
+ "hash = (53 * hash) + $name$_;\n");
}
-TProtoStringType ImmutableEnumFieldGenerator::GetBoxedType() const {
+TProtoStringType ImmutableEnumFieldGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
}
// ===================================================================
-ImmutableEnumOneofFieldGenerator::ImmutableEnumOneofFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : ImmutableEnumFieldGenerator(descriptor, messageBitIndex, builderBitIndex,
- context) {
+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_);
}
-ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {}
+ImmutableEnumOneofFieldGenerator::~ImmutableEnumOneofFieldGenerator() {}
-void ImmutableEnumOneofFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $has_oneof_case_message$;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return (java.lang.Integer) $oneof_name$_;\n"
- " }\n"
- " return $default_number$;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return (java.lang.Integer) $oneof_name$_;\n"
+ " }\n"
+ " return $default_number$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$(\n"
- " (java.lang.Integer) $oneof_name$_);\n"
- " return result == null ? $unknown$ : result;\n"
- " }\n"
- " return $default$;\n"
- "}\n");
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " @SuppressWarnings(\"deprecation\")\n"
+ " $type$ result = $type$.$for_number$(\n"
+ " (java.lang.Integer) $oneof_name$_);\n"
+ " return result == null ? $unknown$ : result;\n"
+ " }\n"
+ " return $default$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
+void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $has_oneof_case_message$;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ((java.lang.Integer) $oneof_name$_).intValue();\n"
- " }\n"
- " return $default_number$;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ((java.lang.Integer) $oneof_name$_).intValue();\n"
+ " }\n"
+ " return $default_number$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$Value$}$(int value) {\n"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$Value$}$(int value) {\n"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$(\n"
- " (java.lang.Integer) $oneof_name$_);\n"
- " return result == null ? $unknown$ : result;\n"
- " }\n"
- " return $default$;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " @SuppressWarnings(\"deprecation\")\n"
+ " $type$ result = $type$.$for_number$(\n"
+ " (java.lang.Integer) $oneof_name$_);\n"
+ " return result == null ? $unknown$ : result;\n"
+ " }\n"
+ " return $default$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value.getNumber();\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ " }\n"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value.getNumber();\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " $clear_oneof_case_message$;\n"
- " $oneof_name$_ = null;\n"
- " $on_changed$\n"
- " }\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " $clear_oneof_case_message$;\n"
+ " $oneof_name$_ = null;\n"
+ " $on_changed$\n"
+ " }\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableEnumOneofFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " result.$oneof_name$_ = $oneof_name$_;\n"
- "}\n");
+ "if ($has_oneof_case_message$) {\n"
+ " result.$oneof_name$_ = $oneof_name$_;\n"
+ "}\n");
}
-void ImmutableEnumOneofFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldGenerator::GenerateMergingCode(
+ io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "set$capitalized_name$Value(other.get$capitalized_name$Value());\n");
+ printer->Print(
+ variables_,
+ "set$capitalized_name$Value(other.get$capitalized_name$Value());\n");
} else {
printer->Print(variables_,
- "set$capitalized_name$(other.get$capitalized_name$());\n");
+ "set$capitalized_name$(other.get$capitalized_name$());\n");
}
}
-void ImmutableEnumOneofFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- "$set_oneof_case_message$;\n"
- "$oneof_name$_ = rawValue;\n");
+ "int rawValue = input.readEnum();\n"
+ "$set_oneof_case_message$;\n"
+ "$oneof_name$_ = rawValue;\n");
} else {
printer->Print(variables_,
- "int rawValue = input.readEnum();\n"
- "@SuppressWarnings(\"deprecation\")\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
- "if (value == null) {\n"
- " unknownFields.mergeVarintField($number$, rawValue);\n"
- "} else {\n"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = rawValue;\n"
- "}\n");
+ "int rawValue = input.readEnum();\n"
+ "@SuppressWarnings(\"deprecation\")\n"
+ "$type$ value = $type$.$for_number$(rawValue);\n"
+ "if (value == null) {\n"
+ " unknownFields.mergeVarintField($number$, rawValue);\n"
+ "} else {\n"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = rawValue;\n"
+ "}\n");
}
}
-void ImmutableEnumOneofFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "if ($has_oneof_case_message$) {\n"
- " output.writeEnum($number$, ((java.lang.Integer) $oneof_name$_));\n"
- "}\n");
+void ImmutableEnumOneofFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "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(
- variables_,
- "if ($has_oneof_case_message$) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .computeEnumSize($number$, ((java.lang.Integer) $oneof_name$_));\n"
- "}\n");
+void ImmutableEnumOneofFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if ($has_oneof_case_message$) {\n"
+ " size += com.google.protobuf.CodedOutputStream\n"
+ " .computeEnumSize($number$, ((java.lang.Integer) $oneof_name$_));\n"
+ "}\n");
}
-void ImmutableEnumOneofFieldGenerator::GenerateEqualsCode(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldGenerator::GenerateEqualsCode(
+ io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
- printer->Print(
- variables_,
- "if (get$capitalized_name$Value()\n"
- " != other.get$capitalized_name$Value()) return false;\n");
+ printer->Print(
+ variables_,
+ "if (get$capitalized_name$Value()\n"
+ " != other.get$capitalized_name$Value()) return false;\n");
} else {
- printer->Print(
- variables_,
- "if (!get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$())) return false;\n");
+ printer->Print(
+ variables_,
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
}
}
-void ImmutableEnumOneofFieldGenerator::GenerateHashCode(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(variables_,
- "hash = (37 * hash) + $constant_name$;\n"
- "hash = (53 * hash) + get$capitalized_name$Value();\n");
+ "hash = (37 * hash) + $constant_name$;\n"
+ "hash = (53 * hash) + get$capitalized_name$Value();\n");
} else {
- printer->Print(
- variables_,
- "hash = (37 * hash) + $constant_name$;\n"
- "hash = (53 * hash) + get$capitalized_name$().getNumber();\n");
+ 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()) {
+RepeatedImmutableEnumFieldGenerator::RepeatedImmutableEnumFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ Context* context)
+ : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ context->GetFieldGeneratorInfo(descriptor), name_resolver_,
+ &variables_);
}
RepeatedImmutableEnumFieldGenerator::~RepeatedImmutableEnumFieldGenerator() {}
@@ -646,524 +646,524 @@ int RepeatedImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {
return 1;
}
-void RepeatedImmutableEnumFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+void RepeatedImmutableEnumFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ "$deprecation$int get$capitalized_name$Count();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$java.util.List<java.lang.Integer>\n"
- "get$capitalized_name$ValueList();\n");
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ "$deprecation$java.util.List<java.lang.Integer>\n"
+ "get$capitalized_name$ValueList();\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Value(int index);\n");
+ "$deprecation$int get$capitalized_name$Value(int index);\n");
}
}
-void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "private java.util.List<java.lang.Integer> $name$_;\n"
- "private static final "
- "com.google.protobuf.Internal.ListAdapter.Converter<\n"
- " java.lang.Integer, $type$> $name$_converter_ =\n"
- " new com.google.protobuf.Internal.ListAdapter.Converter<\n"
- " java.lang.Integer, $type$>() {\n"
- " public $type$ convert(java.lang.Integer from) {\n"
- " @SuppressWarnings(\"deprecation\")\n"
- " $type$ result = $type$.$for_number$(from);\n"
- " return result == null ? $unknown$ : result;\n"
- " }\n"
- " };\n");
+void RepeatedImmutableEnumFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "private java.util.List<java.lang.Integer> $name$_;\n"
+ "private static final "
+ "com.google.protobuf.Internal.ListAdapter.Converter<\n"
+ " java.lang.Integer, $type$> $name$_converter_ =\n"
+ " new com.google.protobuf.Internal.ListAdapter.Converter<\n"
+ " java.lang.Integer, $type$>() {\n"
+ " public $type$ convert(java.lang.Integer from) {\n"
+ " @SuppressWarnings(\"deprecation\")\n"
+ " $type$ result = $type$.$for_number$(from);\n"
+ " return result == null ? $unknown$ : result;\n"
+ " }\n"
+ " };\n");
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return new com.google.protobuf.Internal.ListAdapter<\n"
- " java.lang.Integer, $type$>($name$_, $name$_converter_);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$() {\n"
+ " return new com.google.protobuf.Internal.ListAdapter<\n"
+ " java.lang.Integer, $type$>($name$_, $name$_converter_);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_converter_.convert($name$_.get(index));\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_converter_.convert($name$_.get(index));\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<java.lang.Integer>\n"
- "${$get$capitalized_name$ValueList$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<java.lang.Integer>\n"
+ "${$get$capitalized_name$ValueList$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public int "
- "${$get$capitalized_name$Value$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ "@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");
+ if (descriptor_->is_packed()) {
+ printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n");
}
}
-void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- // One field is the list and the other 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.
- "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_,
- // 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.
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return new com.google.protobuf.Internal.ListAdapter<\n"
- " java.lang.Integer, $type$>($name$_, $name$_converter_);\n"
- "}\n");
+void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ // One field is the list and the other 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.
+ "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_,
+ // 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.
+ "$deprecation$public java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$() {\n"
+ " return new com.google.protobuf.Internal.ListAdapter<\n"
+ " java.lang.Integer, $type$>($name$_, $name$_converter_);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_converter_.convert($name$_.get(index));\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_converter_.convert($name$_.get(index));\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, $type$ value) {\n"
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.set(index, value.getNumber());\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$ value) {\n"
+ " if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ " }\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.set(index, value.getNumber());\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$$}$($type$ value) {\n"
- " if (value == null) {\n"
- " throw new NullPointerException();\n"
- " }\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value.getNumber());\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$$}$($type$ value) {\n"
+ " if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ " }\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.add(value.getNumber());\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<? extends $type$> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " for ($type$ value : values) {\n"
- " $name$_.add(value.getNumber());\n"
- " }\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<? extends $type$> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " for ($type$ value : values) {\n"
+ " $name$_.add(value.getNumber());\n"
+ " }\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $name$_ = java.util.Collections.emptyList();\n"
- " $clear_mutable_bit_builder$;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " $name$_ = java.util.Collections.emptyList();\n"
+ " $clear_mutable_bit_builder$;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$public java.util.List<java.lang.Integer>\n"
- "${$get$capitalized_name$ValueList$}$() {\n"
- " return java.util.Collections.unmodifiableList($name$_);\n"
- "}\n");
+ "$deprecation$public java.util.List<java.lang.Integer>\n"
+ "${$get$capitalized_name$ValueList$}$() {\n"
+ " return java.util.Collections.unmodifiableList($name$_);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$public int "
- "${$get$capitalized_name$Value$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ "$deprecation$public int "
+ "${$get$capitalized_name$Value$}$(int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$set$capitalized_name$Value$}$(\n"
- " int index, int value) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.set(index, value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$Value$}$(\n"
+ " int index, int value) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.set(index, value);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$Value$}$(int value) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$Value$}$(int value) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.add(value);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_MULTI_ADDER, /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$Value$}$(\n"
- " java.lang.Iterable<java.lang.Integer> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " for (int value : values) {\n"
- " $name$_.add(value);\n"
- " }\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_MULTI_ADDER, /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$addAll$capitalized_name$Value$}$(\n"
+ " java.lang.Iterable<java.lang.Integer> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " for (int value : values) {\n"
+ " $name$_.add(value);\n"
+ " }\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
}
void RepeatedImmutableEnumFieldGenerator::
- GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
+ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for enums
}
-void RepeatedImmutableEnumFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = java.util.Collections.emptyList();\n"
- "$clear_mutable_bit_builder$;\n");
+ "$name$_ = java.util.Collections.emptyList();\n"
+ "$clear_mutable_bit_builder$;\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+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_,
- "if (!other.$name$_.isEmpty()) {\n"
- " if ($name$_.isEmpty()) {\n"
- " $name$_ = other.$name$_;\n"
- " $clear_mutable_bit_builder$;\n"
- " } else {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.addAll(other.$name$_);\n"
- " }\n"
- " $on_changed$\n"
- "}\n");
+ "if (!other.$name$_.isEmpty()) {\n"
+ " if ($name$_.isEmpty()) {\n"
+ " $name$_ = other.$name$_;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " } else {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.addAll(other.$name$_);\n"
+ " }\n"
+ " $on_changed$\n"
+ "}\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+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.
- printer->Print(
- variables_,
- "if ($get_mutable_bit_builder$) {\n"
- " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
- " $clear_mutable_bit_builder$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n");
+ printer->Print(
+ variables_,
+ "if ($get_mutable_bit_builder$) {\n"
+ " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
+ " $clear_mutable_bit_builder$;\n"
+ "}\n"
+ "result.$name$_ = $name$_;\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
// 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");
+ "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 {
- printer->Print(
- variables_,
- "int rawValue = input.readEnum();\n"
- "@SuppressWarnings(\"deprecation\")\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
- "if (value == null) {\n"
- " unknownFields.mergeVarintField($number$, rawValue);\n"
- "} else {\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"
- "}\n");
+ printer->Print(
+ variables_,
+ "int rawValue = input.readEnum();\n"
+ "@SuppressWarnings(\"deprecation\")\n"
+ "$type$ value = $type$.$for_number$(rawValue);\n"
+ "if (value == null) {\n"
+ " unknownFields.mergeVarintField($number$, rawValue);\n"
+ "} else {\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"
+ "}\n");
}
}
-void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateParsingCodeFromPacked(
+ io::Printer* printer) const {
// 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");
+ "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_,
- "}\n"
- "input.popLimit(oldLimit);\n");
+ "}\n"
+ "input.popLimit(oldLimit);\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
- "}\n");
+void RepeatedImmutableEnumFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if ($get_mutable_bit_parser$) {\n"
+ " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
+ "}\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
if (descriptor_->is_packed()) {
printer->Print(variables_,
- "if (get$capitalized_name$List().size() > 0) {\n"
- " output.writeUInt32NoTag($tag$);\n"
- " output.writeUInt32NoTag($name$MemoizedSerializedSize);\n"
- "}\n"
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " output.writeEnumNoTag($name$_.get(i));\n"
- "}\n");
+ "if (get$capitalized_name$List().size() > 0) {\n"
+ " output.writeUInt32NoTag($tag$);\n"
+ " output.writeUInt32NoTag($name$MemoizedSerializedSize);\n"
+ "}\n"
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
+ " output.writeEnumNoTag($name$_.get(i));\n"
+ "}\n");
} else {
printer->Print(variables_,
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " output.writeEnum($number$, $name$_.get(i));\n"
- "}\n");
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
+ " output.writeEnum($number$, $name$_.get(i));\n"
+ "}\n");
}
}
-void RepeatedImmutableEnumFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "{\n"
- " int dataSize = 0;\n");
+ "{\n"
+ " int dataSize = 0;\n");
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");
+ "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 (!get$capitalized_name$List().isEmpty()) {"
- " size += $tag_size$;\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .computeUInt32SizeNoTag(dataSize);\n"
- "}");
+ "if (!get$capitalized_name$List().isEmpty()) {"
+ " size += $tag_size$;\n"
+ " size += com.google.protobuf.CodedOutputStream\n"
+ " .computeUInt32SizeNoTag(dataSize);\n"
+ "}");
} else {
- printer->Print(variables_, "size += $tag_size$ * $name$_.size();\n");
+ printer->Print(variables_, "size += $tag_size$ * $name$_.size();\n");
}
// cache the data size for packed fields.
if (descriptor_->is_packed()) {
- printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n");
+ printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n");
}
printer->Outdent();
printer->Print("}\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateEqualsCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateEqualsCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if (!$name$_.equals(other.$name$_)) return false;\n");
+ "if (!$name$_.equals(other.$name$_)) return false;\n");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateHashCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
+ 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(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: $kt_type$) {\n"
+ " add(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " addAll(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
printer->Print(variables_,
- "if (get$capitalized_name$Count() > 0) {\n"
- " hash = (37 * hash) + $constant_name$;\n"
- " hash = (53 * hash) + $name$_.hashCode();\n"
- "}\n");
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
}
-void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: $kt_type$) {\n"
- " add(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " addAll(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
-TProtoStringType RepeatedImmutableEnumFieldGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutableEnumFieldGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
}
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 bdb4bc22f1..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
@@ -36,58 +36,58 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
#include <map>
-#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
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;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- 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;
+ explicit ImmutableEnumFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex, int builderBitIndex,
+ Context* context);
+ ~ImmutableEnumFieldGenerator() override;
+
+ // implements ImmutableFieldGenerator
+ // ---------------------------------------
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
private:
@@ -96,9 +96,9 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
class ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {
public:
- ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- Context* context);
+ ImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex, int builderBitIndex,
+ Context* context);
~ImmutableEnumOneofFieldGenerator();
void GenerateMembers(io::Printer* printer) const;
@@ -120,34 +120,34 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
explicit RepeatedImmutableEnumFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
- ~RepeatedImmutableEnumFieldGenerator() override;
+ ~RepeatedImmutableEnumFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
- int GetNumBitsForMessage() const override;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingCodeFromPacked(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- 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;
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingCodeFromPacked(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldGenerator);
@@ -156,6 +156,6 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 e7877f5f78..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
@@ -32,21 +32,21 @@
// 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 <google/protobuf/compiler/java/java_enum_field_lite.h>
+
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <string>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -54,44 +54,44 @@ namespace compiler {
namespace java {
namespace {
-bool EnableExperimentalRuntimeForLite() {
-#ifdef PROTOBUF_EXPERIMENT
- return PROTOBUF_EXPERIMENT;
-#else // PROTOBUF_EXPERIMENT
- return false;
-#endif // !PROTOBUF_EXPERIMENT
-}
-
-void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
+bool EnableExperimentalRuntimeForLite() {
+#ifdef PROTOBUF_EXPERIMENT
+ return PROTOBUF_EXPERIMENT;
+#else // PROTOBUF_EXPERIMENT
+ return false;
+#endif // !PROTOBUF_EXPERIMENT
+}
+
+void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->enum_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ (*variables)["kt_type"] = (*variables)["type"];
(*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(
+ (*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
- (*variables)["deprecation"] =
- descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
- if (HasHasbit(descriptor)) {
+ if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
@@ -107,8 +107,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["clear_has_field_bit_message"] = "";
(*variables)["is_field_present_message"] =
- (*variables)["name"] + "_ != " + (*variables)["default"] +
- ".getNumber()";
+ (*variables)["name"] + "_ != " + (*variables)["default"] +
+ ".getNumber()";
}
(*variables)["get_has_field_bit_from_local"] =
@@ -121,786 +121,786 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex,
} 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";
+
+ // 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
// ===================================================================
-ImmutableEnumFieldLiteGenerator::ImmutableEnumFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : descriptor_(descriptor),
- messageBitIndex_(messageBitIndex),
- context_(context),
- name_resolver_(context->GetNameResolver()) {
- SetEnumVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ImmutableEnumFieldLiteGenerator::ImmutableEnumFieldLiteGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
+ : descriptor_(descriptor),
+ messageBitIndex_(messageBitIndex),
+ context_(context),
+ name_resolver_(context->GetNameResolver()) {
+ SetEnumVariables(descriptor, messageBitIndex, 0,
+ context->GetFieldGeneratorInfo(descriptor), name_resolver_,
+ &variables_);
}
ImmutableEnumFieldLiteGenerator::~ImmutableEnumFieldLiteGenerator() {}
int ImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ return HasHasbit(descriptor_) ? 1 : 0;
}
-void ImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean has$capitalized_name$();\n");
}
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Value();\n");
+ "$deprecation$int get$capitalized_name$Value();\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\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");
+void ImmutableEnumFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private int $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
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");
+ "@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())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
printer->Print(variables_,
- "private void set$capitalized_name$Value(int value) {\n"
- " $set_has_field_bit_message$"
- " $name$_ = value;\n"
- "}\n");
+ "private void set$capitalized_name$Value(int value) {\n"
+ " $set_has_field_bit_message$"
+ " $name$_ = value;\n"
+ "}\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
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);
+ "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_,
- "private void clear$capitalized_name$() {\n"
- " $clear_has_field_bit_message$\n"
- " $name$_ = $default_number$;\n"
- "}\n");
+ "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_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
+void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return instance.has$capitalized_name$();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
- " return instance.get$capitalized_name$Value();\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
+ " return instance.get$capitalized_name$Value();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$Value$}$(int value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$Value(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$Value$}$(int value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$Value(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return instance.get$capitalized_name$();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
- }
-}
-
-void ImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+ }
+}
+
+void ImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
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);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- if (HasHasbit(descriptor_)) {
- WriteIntToUtf16CharSequence(messageBitIndex_, output);
+void ImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ 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());
+ 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 {
+TProtoStringType ImmutableEnumFieldLiteGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
}
// ===================================================================
-ImmutableEnumOneofFieldLiteGenerator::ImmutableEnumOneofFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : ImmutableEnumFieldLiteGenerator(descriptor, messageBitIndex, context) {
+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_);
}
-ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {}
+ImmutableEnumOneofFieldLiteGenerator::~ImmutableEnumOneofFieldLiteGenerator() {}
-void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $has_oneof_case_message$;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return (java.lang.Integer) $oneof_name$_;\n"
- " }\n"
- " return $default_number$;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return (java.lang.Integer) $oneof_name$_;\n"
+ " }\n"
+ " return $default_number$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " $type$ result = $type$.forNumber((java.lang.Integer) "
- "$oneof_name$_);\n"
- " return result == null ? $unknown$ : result;\n"
- " }\n"
- " return $default$;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " $type$ result = $type$.forNumber((java.lang.Integer) "
+ "$oneof_name$_);\n"
+ " return result == null ? $unknown$ : result;\n"
+ " }\n"
+ " return $default$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Generate private setters for the builder to proxy into.
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
printer->Print(variables_,
- "private void set$capitalized_name$Value(int value) {\n"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- "}\n");
+ "private void set$capitalized_name$Value(int value) {\n"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ "}\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
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);
+ "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_,
- "private void clear$capitalized_name$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " $clear_oneof_case_message$;\n"
- " $oneof_name$_ = null;\n"
- " }\n"
- "}\n");
+ "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);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
+ if (!SupportUnknownEnumValue(descriptor_)) {
+ PrintEnumVerifierLogic(printer, descriptor_, variables_,
+ /*var_name=*/"$type$",
+ /*terminating_string=*/",\n",
+ /*enforce_lite=*/context_->EnforceLite());
+ }
}
-void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
- if (!SupportUnknownEnumValue(descriptor_)) {
- PrintEnumVerifierLogic(printer, descriptor_, variables_,
- /*var_name=*/"$type$",
- /*terminating_string=*/",\n",
- /*enforce_lite=*/context_->EnforceLite());
- }
-}
-
-void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
+void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return instance.has$capitalized_name$();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
- " return instance.get$capitalized_name$Value();\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n"
+ " return instance.get$capitalized_name$Value();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$Value$}$(int value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$Value(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$Value$}$(int value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$Value(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
+ "@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);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
// ===================================================================
RepeatedImmutableEnumFieldLiteGenerator::
- RepeatedImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context)
- : descriptor_(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()) {
- SetEnumVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor), name_resolver_,
- &variables_);
+ RepeatedImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context)
+ : descriptor_(descriptor),
+ context_(context),
+ name_resolver_(context->GetNameResolver()) {
+ SetEnumVariables(descriptor, messageBitIndex, 0,
+ context->GetFieldGeneratorInfo(descriptor), name_resolver_,
+ &variables_);
}
RepeatedImmutableEnumFieldLiteGenerator::
- ~RepeatedImmutableEnumFieldLiteGenerator() {}
+ ~RepeatedImmutableEnumFieldLiteGenerator() {}
int RepeatedImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {
return 0;
}
-void RepeatedImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+void RepeatedImmutableEnumFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$java.util.List<$type$> get$capitalized_name$List();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ "$deprecation$int get$capitalized_name$Count();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$java.util.List<java.lang.Integer>\n"
- "get$capitalized_name$ValueList();\n");
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ "$deprecation$java.util.List<java.lang.Integer>\n"
+ "get$capitalized_name$ValueList();\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Value(int index);\n");
+ "$deprecation$int get$capitalized_name$Value(int index);\n");
}
}
-void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "private com.google.protobuf.Internal.IntList $name$_;\n"
- "private static final "
- "com.google.protobuf.Internal.ListAdapter.Converter<\n"
- " java.lang.Integer, $type$> $name$_converter_ =\n"
- " new com.google.protobuf.Internal.ListAdapter.Converter<\n"
- " java.lang.Integer, $type$>() {\n"
- " @java.lang.Override\n"
- " public $type$ convert(java.lang.Integer from) {\n"
- " $type$ result = $type$.forNumber(from);\n"
- " return result == null ? $unknown$ : result;\n"
- " }\n"
- " };\n");
+void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "private com.google.protobuf.Internal.IntList $name$_;\n"
+ "private static final "
+ "com.google.protobuf.Internal.ListAdapter.Converter<\n"
+ " java.lang.Integer, $type$> $name$_converter_ =\n"
+ " new com.google.protobuf.Internal.ListAdapter.Converter<\n"
+ " java.lang.Integer, $type$>() {\n"
+ " @java.lang.Override\n"
+ " public $type$ convert(java.lang.Integer from) {\n"
+ " $type$ result = $type$.forNumber(from);\n"
+ " return result == null ? $unknown$ : result;\n"
+ " }\n"
+ " };\n");
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return new com.google.protobuf.Internal.ListAdapter<\n"
- " java.lang.Integer, $type$>($name$_, $name$_converter_);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$() {\n"
+ " return new com.google.protobuf.Internal.ListAdapter<\n"
+ " java.lang.Integer, $type$>($name$_, $name$_converter_);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_converter_.convert($name$_.getInt(index));\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_converter_.convert($name$_.getInt(index));\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<java.lang.Integer>\n"
- "${$get$capitalized_name$ValueList$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<java.lang.Integer>\n"
+ "${$get$capitalized_name$ValueList$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public int "
- "${$get$capitalized_name$Value$}$(int index) {\n"
- " return $name$_.getInt(index);\n"
- "}\n");
+ "@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() &&
+ if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() &&
context_->HasGeneratedMethods(descriptor_->containing_type())) {
- printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n");
+ printer->Print(variables_, "private int $name$MemoizedSerializedSize;\n");
}
// Generate private setters for the builder to proxy into.
- printer->Print(
- variables_,
- "private void ensure$capitalized_name$IsMutable() {\n"
- // Use a temporary to avoid a redundant iget-object.
- " com.google.protobuf.Internal.IntList tmp = $name$_;\n"
- " if (!tmp.isModifiable()) {\n"
- " $name$_ =\n"
- " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
- " }\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
+ printer->Print(
+ variables_,
+ "private void ensure$capitalized_name$IsMutable() {\n"
+ // Use a temporary to avoid a redundant iget-object.
+ " com.google.protobuf.Internal.IntList tmp = $name$_;\n"
+ " if (!tmp.isModifiable()) {\n"
+ " $name$_ =\n"
+ " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
+ " }\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
printer->Print(variables_,
- "private void set$capitalized_name$(\n"
- " int index, $type$ value) {\n"
- " $null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.setInt(index, value.getNumber());\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
+ "private void set$capitalized_name$(\n"
+ " int index, $type$ value) {\n"
+ " $null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.setInt(index, value.getNumber());\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
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);
+ "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_,
- "private void addAll$capitalized_name$(\n"
- " java.lang.Iterable<? extends $type$> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " for ($type$ value : values) {\n"
- " $name$_.addInt(value.getNumber());\n"
- " }\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ "private void addAll$capitalized_name$(\n"
+ " java.lang.Iterable<? extends $type$> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " for ($type$ value : values) {\n"
+ " $name$_.addInt(value.getNumber());\n"
+ " }\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
printer->Print(variables_,
- "private void clear$capitalized_name$() {\n"
- " $name$_ = emptyIntList();\n"
- "}\n");
+ "private void clear$capitalized_name$() {\n"
+ " $name$_ = emptyIntList();\n"
+ "}\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER);
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);
+ "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_,
- "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);
+ "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_,
- "private void addAll$capitalized_name$Value(\n"
- " java.lang.Iterable<java.lang.Integer> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " for (int value : values) {\n"
- " $name$_.addInt(value);\n"
- " }\n"
- "}\n");
+ "private void addAll$capitalized_name$Value(\n"
+ " java.lang.Iterable<java.lang.Integer> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " for (int value : values) {\n"
+ " $name$_.addInt(value);\n"
+ " }\n"
+ "}\n");
+ }
+}
+
+void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ printer->Print(variables_, "\"$name$_\",\n");
+ if (!SupportUnknownEnumValue(descriptor_->file())) {
+ PrintEnumVerifierLogic(printer, descriptor_, variables_,
+ /*var_name=*/"$type$",
+ /*terminating_string=*/",\n",
+ /*enforce_lite=*/context_->EnforceLite());
}
}
-void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- printer->Print(variables_, "\"$name$_\",\n");
- if (!SupportUnknownEnumValue(descriptor_->file())) {
- PrintEnumVerifierLogic(printer, descriptor_, variables_,
- /*var_name=*/"$type$",
- /*terminating_string=*/",\n",
- /*enforce_lite=*/context_->EnforceLite());
- }
-}
-
-void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return instance.get$capitalized_name$List();\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$() {\n"
+ " return instance.get$capitalized_name$List();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return instance.get$capitalized_name$Count();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return instance.get$capitalized_name$Count();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return instance.get$capitalized_name$(index);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return instance.get$capitalized_name$(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, $type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(index, value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(index, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.add$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<? extends $type$> values) {\n"
- " copyOnWrite();\n"
- " instance.addAll$capitalized_name$(values);"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<? extends $type$> values) {\n"
+ " copyOnWrite();\n"
+ " instance.addAll$capitalized_name$(values);"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (SupportUnknownEnumValue(descriptor_->file())) {
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<java.lang.Integer>\n"
- "${$get$capitalized_name$ValueList$}$() {\n"
- " return java.util.Collections.unmodifiableList(\n"
- " instance.get$capitalized_name$ValueList());\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<java.lang.Integer>\n"
+ "${$get$capitalized_name$ValueList$}$() {\n"
+ " return java.util.Collections.unmodifiableList(\n"
+ " instance.get$capitalized_name$ValueList());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public int "
- "${$get$capitalized_name$Value$}$(int index) {\n"
- " return instance.get$capitalized_name$Value(index);\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public int "
+ "${$get$capitalized_name$Value$}$(int index) {\n"
+ " return instance.get$capitalized_name$Value(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_SETTER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$set$capitalized_name$Value$}$(\n"
- " int index, int value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$Value(index, value);\n"
- " return this;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_SETTER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$Value$}$(\n"
+ " int index, int value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$Value(index, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$Value$}$(int value) {\n"
- " instance.add$capitalized_name$Value(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$Value$}$(int value) {\n"
+ " instance.add$capitalized_name$Value(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
- LIST_MULTI_ADDER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$Value$}$(\n"
- " java.lang.Iterable<java.lang.Integer> values) {\n"
- " copyOnWrite();\n"
- " instance.addAll$capitalized_name$Value(values);\n"
- " return this;\n"
- "}\n");
+ WriteFieldEnumValueAccessorDocComment(printer, descriptor_,
+ LIST_MULTI_ADDER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$addAll$capitalized_name$Value$}$(\n"
+ " java.lang.Iterable<java.lang.Integer> values) {\n"
+ " copyOnWrite();\n"
+ " instance.addAll$capitalized_name$Value(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
}
-void RepeatedImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableEnumFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = emptyIntList();\n");
}
-void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: $kt_type$) {\n"
- " add(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " addAll(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
-TProtoStringType RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const {
+void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: $kt_type$) {\n"
+ " add(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " addAll(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
+}
+
+TProtoStringType RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->enum_type());
}
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 ff257a3301..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
@@ -35,51 +35,51 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__
-#include <cstdint>
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
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;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
- TProtoStringType GetBoxedType() const override;
+ explicit ImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context);
+ ~ImmutableEnumFieldLiteGenerator() override;
+
+ // implements ImmutableFieldLiteGenerator
+ // ------------------------------------
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
const int messageBitIndex_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -91,14 +91,14 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
class ImmutableEnumOneofFieldLiteGenerator
: public ImmutableEnumFieldLiteGenerator {
public:
- ImmutableEnumOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex, Context* context);
- ~ImmutableEnumOneofFieldLiteGenerator() override;
+ 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;
+ 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);
@@ -108,24 +108,24 @@ class RepeatedImmutableEnumFieldLiteGenerator
: public ImmutableFieldLiteGenerator {
public:
explicit RepeatedImmutableEnumFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
- ~RepeatedImmutableEnumFieldLiteGenerator() override;
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ ~RepeatedImmutableEnumFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
- int GetNumBitsForMessage() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const override;
+ void GenerateKotlinDslMembers(io::Printer* printer) const override;
- TProtoStringType GetBoxedType() const override;
+ TProtoStringType GetBoxedType() const override;
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -135,6 +135,6 @@ class RepeatedImmutableEnumFieldLiteGenerator
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 d81a5e7d0a..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
@@ -33,17 +33,17 @@
// 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>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/map_util.h>
+#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>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/map_util.h>
namespace google {
namespace protobuf {
@@ -59,7 +59,7 @@ EnumLiteGenerator::EnumLiteGenerator(const EnumDescriptor* descriptor,
for (int i = 0; i < descriptor_->value_count(); i++) {
const EnumValueDescriptor* value = descriptor_->value(i);
const EnumValueDescriptor* canonical_value =
- descriptor_->FindValueByNumber(value->number());
+ descriptor_->FindValueByNumber(value->number());
if (value == canonical_value) {
canonical_values_.push_back(value);
@@ -78,22 +78,22 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
WriteEnumDocComment(printer, descriptor_);
MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);
printer->Print(
- "$deprecation$public enum $classname$\n"
+ "$deprecation$public enum $classname$\n"
" implements com.google.protobuf.Internal.EnumLite {\n",
- "classname", descriptor_->name(), "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "");
+ "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++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["name"] = canonical_values_[i]->name();
- vars["number"] = StrCat(canonical_values_[i]->number());
+ vars["number"] = StrCat(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
if (canonical_values_[i]->options().deprecated()) {
printer->Print("@java.lang.Deprecated\n");
}
- printer->Print(vars, "$name$($number$),\n");
+ printer->Print(vars, "$name$($number$),\n");
printer->Annotate("name", canonical_values_[i]);
}
@@ -103,35 +103,35 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
}
printer->Print(
- ";\n"
- "\n");
+ ";\n"
+ "\n");
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ 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);
- printer->Print(
- vars, "public static final $classname$ $name$ = $canonical_name$;\n");
+ 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++) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["name"] = descriptor_->value(i)->name();
- vars["number"] = StrCat(descriptor_->value(i)->number());
+ vars["number"] = StrCat(descriptor_->value(i)->number());
vars["{"] = "";
vars["}"] = "";
- vars["deprecation"] = descriptor_->value(i)->options().deprecated()
- ? "@java.lang.Deprecated "
- : "";
+ vars["deprecation"] = descriptor_->value(i)->options().deprecated()
+ ? "@java.lang.Deprecated "
+ : "";
WriteEnumValueDocComment(printer, descriptor_->value(i));
printer->Print(vars,
- "$deprecation$public static final int ${$$name$_VALUE$}$ = "
- "$number$;\n");
+ "$deprecation$public static final int ${$$name$_VALUE$}$ = "
+ "$number$;\n");
printer->Annotate("{", "}", descriptor_->value(i));
}
printer->Print("\n");
@@ -140,7 +140,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
printer->Print(
"\n"
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"public final int getNumber() {\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
printer->Print(
@@ -154,8 +154,8 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
"}\n"
"\n"
"/**\n"
- " * @param value The number of the enum to look for.\n"
- " * @return The enum associated with the given number.\n"
+ " * @param value The number of the enum to look for.\n"
+ " * @return The enum associated with the given number.\n"
" * @deprecated Use {@link #forNumber(int)} instead.\n"
" */\n"
"@java.lang.Deprecated\n"
@@ -170,60 +170,60 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
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->Print("case $number$: return $name$;\n", "name",
+ canonical_values_[i]->name(), "number",
+ StrCat(canonical_values_[i]->number()));
}
printer->Outdent();
printer->Outdent();
printer->Print(
- " default: return null;\n"
- " }\n"
- "}\n"
- "\n"
- "public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\n"
- " internalGetValueMap() {\n"
- " return internalValueMap;\n"
- "}\n"
- "private static final com.google.protobuf.Internal.EnumLiteMap<\n"
- " $classname$> internalValueMap =\n"
- " new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
- " @java.lang.Override\n"
- " public $classname$ findValueByNumber(int number) {\n"
- " return $classname$.forNumber(number);\n"
- " }\n"
- " };\n"
- "\n"
- "public static com.google.protobuf.Internal.EnumVerifier \n"
- " internalGetVerifier() {\n"
- " return $classname$Verifier.INSTANCE;\n"
- "}\n"
- "\n"
- "private static final class $classname$Verifier implements \n"
- " com.google.protobuf.Internal.EnumVerifier { \n"
- " static final com.google.protobuf.Internal.EnumVerifier "
- " INSTANCE = new $classname$Verifier();\n"
- " @java.lang.Override\n"
- " public boolean isInRange(int number) {\n"
- " return $classname$.forNumber(number) != null;\n"
- " }\n"
- " };\n"
- "\n",
- "classname", descriptor_->name());
+ " default: return null;\n"
+ " }\n"
+ "}\n"
+ "\n"
+ "public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\n"
+ " internalGetValueMap() {\n"
+ " return internalValueMap;\n"
+ "}\n"
+ "private static final com.google.protobuf.Internal.EnumLiteMap<\n"
+ " $classname$> internalValueMap =\n"
+ " new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
+ " @java.lang.Override\n"
+ " public $classname$ findValueByNumber(int number) {\n"
+ " return $classname$.forNumber(number);\n"
+ " }\n"
+ " };\n"
+ "\n"
+ "public static com.google.protobuf.Internal.EnumVerifier \n"
+ " internalGetVerifier() {\n"
+ " return $classname$Verifier.INSTANCE;\n"
+ "}\n"
+ "\n"
+ "private static final class $classname$Verifier implements \n"
+ " com.google.protobuf.Internal.EnumVerifier { \n"
+ " static final com.google.protobuf.Internal.EnumVerifier "
+ " INSTANCE = new $classname$Verifier();\n"
+ " @java.lang.Override\n"
+ " public boolean isInRange(int number) {\n"
+ " return $classname$.forNumber(number) != null;\n"
+ " }\n"
+ " };\n"
+ "\n",
+ "classname", descriptor_->name());
printer->Print(
- "private final int value;\n\n"
- "private $classname$(int value) {\n",
- "classname", descriptor_->name());
+ "private final int value;\n\n"
+ "private $classname$(int value) {\n",
+ "classname", descriptor_->name());
printer->Print(
- " this.value = value;\n"
- "}\n");
+ " this.value = value;\n"
+ "}\n");
printer->Print(
- "\n"
- "// @@protoc_insertion_point(enum_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\n"
+ "// @@protoc_insertion_point(enum_scope:$full_name$)\n",
+ "full_name", descriptor_->full_name());
printer->Outdent();
printer->Print("}\n\n");
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 ca980e1eeb..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
@@ -35,25 +35,25 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__
-#include <string>
+#include <string>
#include <vector>
-#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -69,9 +69,9 @@ class EnumLiteGenerator {
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
+ // 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.
std::vector<const EnumValueDescriptor*> canonical_values_;
@@ -93,6 +93,6 @@ class EnumLiteGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 0ba6feb456..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
@@ -32,14 +32,14 @@
// 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_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>
+#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 {
@@ -48,10 +48,10 @@ namespace java {
ImmutableExtensionGenerator::ImmutableExtensionGenerator(
const FieldDescriptor* descriptor, Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
if (descriptor_->extension_scope() != NULL) {
- scope_ =
- name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
+ scope_ =
+ name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
} else {
scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());
}
@@ -61,36 +61,36 @@ 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;
+ 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["name"] = UnderscoresToCamelCaseCheckReserved(descriptor);
+ vars["name"] = UnderscoresToCamelCaseCheckReserved(descriptor);
vars["containing_type"] =
name_resolver->GetClassName(descriptor->containing_type(), immutable);
- vars["number"] = StrCat(descriptor->number());
+ vars["number"] = StrCat(descriptor->number());
vars["constant_name"] = FieldConstantName(descriptor);
- vars["index"] = StrCat(descriptor->index());
- vars["default"] = descriptor->is_repeated()
- ? ""
- : DefaultValue(descriptor, immutable, name_resolver);
+ vars["index"] = StrCat(descriptor->index());
+ vars["default"] = descriptor->is_repeated()
+ ? ""
+ : DefaultValue(descriptor, immutable, name_resolver);
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);
- TProtoStringType singular_type;
+ TProtoStringType singular_type;
switch (java_type) {
case JAVATYPE_MESSAGE:
- singular_type =
- name_resolver->GetClassName(descriptor->message_type(), immutable);
+ singular_type =
+ name_resolver->GetClassName(descriptor->message_type(), immutable);
vars["prototype"] = singular_type + ".getDefaultInstance()";
break;
case JAVATYPE_ENUM:
- singular_type =
- name_resolver->GetClassName(descriptor->enum_type(), immutable);
+ singular_type =
+ name_resolver->GetClassName(descriptor->enum_type(), immutable);
vars["enum_map"] = singular_type + ".internalGetValueMap()";
break;
case JAVATYPE_STRING:
@@ -103,18 +103,18 @@ void ExtensionGenerator::InitTemplateVars(
singular_type = BoxedPrimitiveTypeName(java_type);
break;
}
- vars["type"] = descriptor->is_repeated()
- ? "java.util.List<" + singular_type + ">"
- : singular_type;
+ vars["type"] = descriptor->is_repeated()
+ ? "java.util.List<" + singular_type + ">"
+ : singular_type;
vars["singular_type"] = singular_type;
}
void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
&vars);
- printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
+ printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
WriteFieldDocComment(printer, descriptor_);
if (descriptor_->extension_scope() == NULL) {
@@ -142,7 +142,7 @@ void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
" $singular_type$.class,\n"
" $prototype$);\n");
}
- printer->Annotate("name", descriptor_);
+ printer->Annotate("name", descriptor_);
}
int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
@@ -152,8 +152,8 @@ int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
// Only applies to non-nested extensions.
printer->Print(
"$name$.internalInit(descriptor.getExtensions().get($index$));\n",
- "name", UnderscoresToCamelCaseCheckReserved(descriptor_), "index",
- StrCat(descriptor_->index()));
+ "name", UnderscoresToCamelCaseCheckReserved(descriptor_), "index",
+ StrCat(descriptor_->index()));
bytecode_estimate += 21;
}
return bytecode_estimate;
@@ -161,8 +161,8 @@ int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
int ImmutableExtensionGenerator::GenerateRegistrationCode(
io::Printer* printer) {
- printer->Print("registry.add($scope$.$name$);\n", "scope", scope_, "name",
- UnderscoresToCamelCaseCheckReserved(descriptor_));
+ printer->Print("registry.add($scope$.$name$);\n", "scope", scope_, "name",
+ UnderscoresToCamelCaseCheckReserved(descriptor_));
return 7;
}
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 1808ec45bf..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
@@ -36,26 +36,26 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
#include <map>
-#include <string>
+#include <string>
-#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
-class FieldDescriptor; // descriptor.h
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+class FieldDescriptor; // descriptor.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -70,19 +70,19 @@ class ExtensionGenerator {
virtual void Generate(io::Printer* printer) = 0;
- // 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
virtual int GenerateNonNestedInitializationCode(io::Printer* printer) = 0;
- // 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
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);
+ 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);
@@ -101,7 +101,7 @@ class ImmutableExtensionGenerator : public ExtensionGenerator {
protected:
const FieldDescriptor* descriptor_;
ClassNameResolver* name_resolver_;
- TProtoStringType scope_;
+ TProtoStringType scope_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);
@@ -110,6 +110,6 @@ class ImmutableExtensionGenerator : public ExtensionGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 6931ffab56..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
@@ -28,14 +28,14 @@
// (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_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>
+#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 {
@@ -44,10 +44,10 @@ namespace java {
ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
const FieldDescriptor* descriptor, Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
if (descriptor_->extension_scope() != NULL) {
- scope_ =
- name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
+ scope_ =
+ name_resolver_->GetImmutableClassName(descriptor_->extension_scope());
} else {
scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());
}
@@ -56,11 +56,11 @@ ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}
void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
&vars);
- printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
+ printer->Print(vars, "public static final int $constant_name$ = $number$;\n");
WriteFieldDocComment(printer, descriptor_);
if (descriptor_->is_repeated()) {
@@ -94,7 +94,7 @@ void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
" com.google.protobuf.WireFormat.FieldType.$type_constant$,\n"
" $singular_type$.class);\n");
}
- printer->Annotate("name", descriptor_);
+ printer->Annotate("name", descriptor_);
}
int ImmutableExtensionLiteGenerator::GenerateNonNestedInitializationCode(
@@ -104,8 +104,8 @@ int ImmutableExtensionLiteGenerator::GenerateNonNestedInitializationCode(
int ImmutableExtensionLiteGenerator::GenerateRegistrationCode(
io::Printer* printer) {
- printer->Print("registry.add($scope$.$name$);\n", "scope", scope_, "name",
- UnderscoresToCamelCaseCheckReserved(descriptor_));
+ printer->Print("registry.add($scope$.$name$);\n", "scope", scope_, "name",
+ UnderscoresToCamelCaseCheckReserved(descriptor_));
return 7;
}
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 3e11ddea11..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
@@ -32,10 +32,10 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
#include <map>
-#include <string>
+#include <string>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/compiler/java/java_extension.h>
namespace google {
namespace protobuf {
@@ -62,7 +62,7 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
private:
const FieldDescriptor* descriptor_;
ClassNameResolver* name_resolver_;
- TProtoStringType scope_;
+ TProtoStringType scope_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionLiteGenerator);
};
@@ -70,6 +70,6 @@ class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 ffc2a31e32..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
@@ -32,27 +32,27 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/java_field.h>
#include <memory>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/compiler/java/java_enum_field.h>
-#include <google/protobuf/compiler/java/java_enum_field_lite.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_map_field.h>
-#include <google/protobuf/compiler/java/java_map_field_lite.h>
-#include <google/protobuf/compiler/java/java_message_field.h>
-#include <google/protobuf/compiler/java/java_message_field_lite.h>
-#include <google/protobuf/compiler/java/java_primitive_field.h>
-#include <google/protobuf/compiler/java/java_primitive_field_lite.h>
-#include <google/protobuf/compiler/java/java_string_field.h>
-#include <google/protobuf/compiler/java/java_string_field_lite.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/compiler/java/java_context.h>
+#include <google/protobuf/compiler/java/java_enum_field.h>
+#include <google/protobuf/compiler/java/java_enum_field_lite.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_map_field.h>
+#include <google/protobuf/compiler/java/java_map_field_lite.h>
+#include <google/protobuf/compiler/java/java_message_field.h>
+#include <google/protobuf/compiler/java/java_message_field_lite.h>
+#include <google/protobuf/compiler/java/java_primitive_field.h>
+#include <google/protobuf/compiler/java/java_primitive_field_lite.h>
+#include <google/protobuf/compiler/java/java_string_field.h>
+#include <google/protobuf/compiler/java/java_string_field_lite.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
namespace google {
@@ -62,16 +62,16 @@ namespace java {
namespace {
-ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field,
- int messageBitIndex,
- int builderBitIndex,
- Context* context) {
+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())) {
- return new ImmutableMapFieldGenerator(field, messageBitIndex,
- builderBitIndex, context);
+ return new ImmutableMapFieldGenerator(field, messageBitIndex,
+ builderBitIndex, context);
} else {
return new RepeatedImmutableMessageFieldGenerator(
field, messageBitIndex, builderBitIndex, context);
@@ -87,14 +87,14 @@ ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field,
field, messageBitIndex, builderBitIndex, context);
}
} else {
- if (IsRealOneof(field)) {
+ if (IsRealOneof(field)) {
switch (GetJavaType(field)) {
case JAVATYPE_MESSAGE:
return new ImmutableMessageOneofFieldGenerator(
field, messageBitIndex, builderBitIndex, context);
case JAVATYPE_ENUM:
- return new ImmutableEnumOneofFieldGenerator(field, messageBitIndex,
- builderBitIndex, context);
+ return new ImmutableEnumOneofFieldGenerator(field, messageBitIndex,
+ builderBitIndex, context);
case JAVATYPE_STRING:
return new ImmutableStringOneofFieldGenerator(
field, messageBitIndex, builderBitIndex, context);
@@ -105,74 +105,74 @@ ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field,
} else {
switch (GetJavaType(field)) {
case JAVATYPE_MESSAGE:
- return new ImmutableMessageFieldGenerator(field, messageBitIndex,
- builderBitIndex, context);
+ return new ImmutableMessageFieldGenerator(field, messageBitIndex,
+ builderBitIndex, context);
case JAVATYPE_ENUM:
- return new ImmutableEnumFieldGenerator(field, messageBitIndex,
- builderBitIndex, context);
+ return new ImmutableEnumFieldGenerator(field, messageBitIndex,
+ builderBitIndex, context);
case JAVATYPE_STRING:
- return new ImmutableStringFieldGenerator(field, messageBitIndex,
- builderBitIndex, context);
+ return new ImmutableStringFieldGenerator(field, messageBitIndex,
+ builderBitIndex, context);
default:
- return new ImmutablePrimitiveFieldGenerator(field, messageBitIndex,
- builderBitIndex, context);
+ return new ImmutablePrimitiveFieldGenerator(field, messageBitIndex,
+ builderBitIndex, context);
}
}
}
}
ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator(
- const FieldDescriptor* field, int messageBitIndex, Context* context) {
+ const FieldDescriptor* field, int messageBitIndex, Context* context) {
if (field->is_repeated()) {
switch (GetJavaType(field)) {
case JAVATYPE_MESSAGE:
if (IsMapEntry(field->message_type())) {
- return new ImmutableMapFieldLiteGenerator(field, messageBitIndex,
- context);
+ return new ImmutableMapFieldLiteGenerator(field, messageBitIndex,
+ context);
} else {
return new RepeatedImmutableMessageFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
}
case JAVATYPE_ENUM:
return new RepeatedImmutableEnumFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
case JAVATYPE_STRING:
return new RepeatedImmutableStringFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
default:
return new RepeatedImmutablePrimitiveFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
}
} else {
- if (IsRealOneof(field)) {
+ if (IsRealOneof(field)) {
switch (GetJavaType(field)) {
case JAVATYPE_MESSAGE:
return new ImmutableMessageOneofFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
case JAVATYPE_ENUM:
return new ImmutableEnumOneofFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
case JAVATYPE_STRING:
return new ImmutableStringOneofFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
default:
return new ImmutablePrimitiveOneofFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
}
} else {
switch (GetJavaType(field)) {
case JAVATYPE_MESSAGE:
- return new ImmutableMessageFieldLiteGenerator(field, messageBitIndex,
- context);
+ return new ImmutableMessageFieldLiteGenerator(field, messageBitIndex,
+ context);
case JAVATYPE_ENUM:
- return new ImmutableEnumFieldLiteGenerator(field, messageBitIndex,
- context);
+ return new ImmutableEnumFieldLiteGenerator(field, messageBitIndex,
+ context);
case JAVATYPE_STRING:
- return new ImmutableStringFieldLiteGenerator(field, messageBitIndex,
- context);
+ return new ImmutableStringFieldLiteGenerator(field, messageBitIndex,
+ context);
default:
return new ImmutablePrimitiveFieldLiteGenerator(
- field, messageBitIndex, context);
+ field, messageBitIndex, context);
}
}
}
@@ -193,8 +193,8 @@ static inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) {
ImmutableFieldGenerator::~ImmutableFieldGenerator() {}
-void ImmutableFieldGenerator::GenerateParsingCodeFromPacked(
- io::Printer* printer) const {
+void ImmutableFieldGenerator::GenerateParsingCodeFromPacked(
+ io::Printer* printer) const {
ReportUnexpectedPackedFieldsCall(printer);
}
@@ -205,7 +205,7 @@ ImmutableFieldLiteGenerator::~ImmutableFieldLiteGenerator() {}
template <>
FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
const Descriptor* descriptor, Context* context)
- : descriptor_(descriptor), field_generators_(descriptor->field_count()) {
+ : descriptor_(descriptor), field_generators_(descriptor->field_count()) {
// Construct all the FieldGenerators and assign them bit indices for their
// bit fields.
int messageBitIndex = 0;
@@ -219,84 +219,84 @@ FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
}
}
-template <>
+template <>
FieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap() {}
template <>
FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(
const Descriptor* descriptor, Context* context)
- : descriptor_(descriptor), field_generators_(descriptor->field_count()) {
+ : 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(
- descriptor->field(i), messageBitIndex, context);
+ descriptor->field(i), messageBitIndex, context);
field_generators_[i].reset(generator);
messageBitIndex += generator->GetNumBitsForMessage();
}
}
-template <>
+template <>
FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
(*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)["number"] = StrCat(descriptor->number());
- (*variables)["kt_dsl_builder"] = "_builder";
+ (*variables)["number"] = StrCat(descriptor->number());
+ (*variables)["kt_dsl_builder"] = "_builder";
// These variables are placeholders to pick out the beginning and ends of
// identifiers for annotations (when doing so with existing variables would
// be ambiguous or impossible). They should never be set to anything but the
// empty string.
(*variables)["{"] = "";
(*variables)["}"] = "";
- (*variables)["kt_name"] =
- IsForbiddenKotlin(info->name) ? info->name + "_" : info->name;
- (*variables)["kt_capitalized_name"] = IsForbiddenKotlin(info->name)
- ? info->capitalized_name + "_"
- : info->capitalized_name;
- if (!descriptor->is_repeated()) {
- (*variables)["annotation_field_type"] = FieldTypeName(descriptor->type());
- } else if (GetJavaType(descriptor) == JAVATYPE_MESSAGE &&
- IsMapEntry(descriptor->message_type())) {
- (*variables)["annotation_field_type"] =
- TProtoStringType(FieldTypeName(descriptor->type())) + "MAP";
- } else {
- (*variables)["annotation_field_type"] =
- TProtoStringType(FieldTypeName(descriptor->type())) + "_LIST";
- if (descriptor->is_packed()) {
- (*variables)["annotation_field_type"] =
- (*variables)["annotation_field_type"] + "_PACKED";
- }
- }
+ (*variables)["kt_name"] =
+ IsForbiddenKotlin(info->name) ? info->name + "_" : info->name;
+ (*variables)["kt_capitalized_name"] = IsForbiddenKotlin(info->name)
+ ? info->capitalized_name + "_"
+ : info->capitalized_name;
+ if (!descriptor->is_repeated()) {
+ (*variables)["annotation_field_type"] = FieldTypeName(descriptor->type());
+ } else if (GetJavaType(descriptor) == JAVATYPE_MESSAGE &&
+ IsMapEntry(descriptor->message_type())) {
+ (*variables)["annotation_field_type"] =
+ TProtoStringType(FieldTypeName(descriptor->type())) + "MAP";
+ } else {
+ (*variables)["annotation_field_type"] =
+ TProtoStringType(FieldTypeName(descriptor->type())) + "_LIST";
+ if (descriptor->is_packed()) {
+ (*variables)["annotation_field_type"] =
+ (*variables)["annotation_field_type"] + "_PACKED";
+ }
+ }
}
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
(*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"] =
- info->name + "Case_ = " + StrCat(descriptor->number());
- (*variables)["clear_oneof_case_message"] = info->name + "Case_ = 0";
- (*variables)["has_oneof_case_message"] =
- info->name + "Case_ == " + StrCat(descriptor->number());
+ StrCat(descriptor->containing_oneof()->index());
+ (*variables)["oneof_stored_type"] = GetOneofStoredType(descriptor);
+ (*variables)["set_oneof_case_message"] =
+ info->name + "Case_ = " + StrCat(descriptor->number());
+ (*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,
+void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
io::Printer* printer) {
- const std::map<TProtoStringType, TProtoStringType>::const_iterator it =
+ const std::map<TProtoStringType, TProtoStringType>::const_iterator it =
variables.find("disambiguated_reason");
if (it != variables.end() && !it->second.empty()) {
printer->Print(
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 82d79c6f65..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
@@ -35,30 +35,30 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
-#include <cstdint>
+#include <cstdint>
#include <map>
#include <memory>
-#include <string>
+#include <string>
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/descriptor.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -82,14 +82,14 @@ class ImmutableFieldGenerator {
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 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 TProtoStringType GetBoxedType() const = 0;
+ virtual TProtoStringType GetBoxedType() const = 0;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldGenerator);
@@ -105,11 +105,11 @@ class ImmutableFieldLiteGenerator {
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 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;
+ virtual TProtoStringType GetBoxedType() const = 0;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldLiteGenerator);
@@ -117,75 +117,75 @@ class ImmutableFieldLiteGenerator {
// Convenience class which constructs FieldGenerators for a Descriptor.
-template <typename FieldGeneratorType>
+template <typename FieldGeneratorType>
class FieldGeneratorMap {
public:
- explicit FieldGeneratorMap(const Descriptor* descriptor, Context* context);
+ explicit FieldGeneratorMap(const Descriptor* descriptor, Context* context);
~FieldGeneratorMap();
const FieldGeneratorType& get(const FieldDescriptor* field) const;
private:
const Descriptor* descriptor_;
- std::vector<std::unique_ptr<FieldGeneratorType>> field_generators_;
+ std::vector<std::unique_ptr<FieldGeneratorType>> field_generators_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);
};
-template <typename FieldGeneratorType>
-inline const FieldGeneratorType& FieldGeneratorMap<FieldGeneratorType>::get(
- const FieldDescriptor* field) const {
+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.
-template <>
-FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
- const Descriptor* descriptor, Context* context);
+template <>
+FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(
+ const Descriptor* descriptor, Context* context);
-template <>
+template <>
FieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap();
-template <>
-FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(
- const Descriptor* descriptor, Context* context);
-
-template <>
-FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap();
-
-
+template <>
+FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(
+ const Descriptor* descriptor, Context* context);
+
+template <>
+FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap();
+
+
// Field information used in FieldGeneartors.
struct FieldGeneratorInfo {
- TProtoStringType name;
- TProtoStringType capitalized_name;
- TProtoStringType disambiguated_reason;
+ TProtoStringType name;
+ TProtoStringType capitalized_name;
+ TProtoStringType disambiguated_reason;
};
// Oneof information used in OneofFieldGenerators.
struct OneofGeneratorInfo {
- TProtoStringType name;
- TProtoStringType capitalized_name;
+ TProtoStringType name;
+ TProtoStringType capitalized_name;
};
// Set some common variables used in variable FieldGenerators.
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables);
+ std::map<TProtoStringType, TProtoStringType>* variables);
// Set some common oneof variables used in OneofFieldGenerators.
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- std::map<TProtoStringType, TProtoStringType>* variables);
+ std::map<TProtoStringType, TProtoStringType>* variables);
// Print useful comments before a field's accessors.
-void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
+void PrintExtraFieldInfo(const std::map<TProtoStringType, TProtoStringType>& variables,
io::Printer* printer);
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 5993a7589b..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
@@ -32,27 +32,27 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_file.h>
+#include <google/protobuf/compiler/java/java_file.h>
#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>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_service.h>
-#include <google/protobuf/compiler/java/java_shared_code_generator.h>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/dynamic_message.h>
-#include <google/protobuf/stubs/strutil.h>
+#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>
+#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/compiler/java/java_generator_factory.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_message.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/compiler/java/java_service.h>
+#include <google/protobuf/compiler/java/java_shared_code_generator.h>
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -62,26 +62,26 @@ namespace java {
namespace {
struct FieldDescriptorCompare {
- bool operator()(const FieldDescriptor* f1, const FieldDescriptor* f2) const {
- if (f1 == NULL) {
+ bool operator()(const FieldDescriptor* f1, const FieldDescriptor* f2) const {
+ if (f1 == NULL) {
return false;
}
- if (f2 == NULL) {
+ if (f2 == NULL) {
return true;
}
return f1->full_name() < f2->full_name();
}
};
-typedef std::set<const FieldDescriptor*, FieldDescriptorCompare>
- FieldDescriptorSet;
+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.
-bool CollectExtensions(const Message& message, FieldDescriptorSet* extensions) {
+bool CollectExtensions(const Message& message, FieldDescriptorSet* extensions) {
const Reflection* reflection = message.GetReflection();
// There are unknown fields that could be extensions, thus this call fails.
@@ -91,16 +91,16 @@ bool CollectExtensions(const Message& message, FieldDescriptorSet* extensions) {
reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
- if (fields[i]->is_extension()) {
- extensions->insert(fields[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 =
- reflection->GetRepeatedMessage(message, fields[i], j);
+ reflection->GetRepeatedMessage(message, fields[i], j);
if (!CollectExtensions(sub_message, extensions)) return false;
}
} else {
@@ -121,7 +121,7 @@ bool CollectExtensions(const Message& message, FieldDescriptorSet* extensions) {
void CollectExtensions(const FileDescriptorProto& file_proto,
const DescriptorPool& alternate_pool,
FieldDescriptorSet* extensions,
- const TProtoStringType& file_data) {
+ 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
@@ -135,7 +135,7 @@ void CollectExtensions(const FileDescriptorProto& file_proto,
"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(
+ 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));
@@ -161,9 +161,9 @@ void CollectExtensions(const FileDescriptorProto& file_proto,
// 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) {
+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
@@ -172,10 +172,10 @@ void MaybeRestartJavaMethod(io::Printer* printer, int* bytecode_estimate,
if ((*bytecode_estimate) > bytesPerMethod) {
++(*method_num);
- printer->Print(chain_statement, "method_num", StrCat(*method_num));
+ printer->Print(chain_statement, "method_num", StrCat(*method_num));
printer->Outdent();
printer->Print("}\n");
- printer->Print(method_decl, "method_num", StrCat(*method_num));
+ printer->Print(method_decl, "method_num", StrCat(*method_num));
printer->Indent();
*bytecode_estimate = 0;
}
@@ -186,14 +186,14 @@ 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()),
+ 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);
- generator_factory_.reset(new ImmutableGeneratorFactory(context_.get()));
+ 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)));
@@ -206,50 +206,50 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options,
FileGenerator::~FileGenerator() {}
-bool FileGenerator::Validate(TProtoStringType* error) {
+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.
- if (name_resolver_->HasConflictingClassName(file_, classname_,
- NameEquality::EXACT_EQUAL)) {
+ if (name_resolver_->HasConflictingClassName(file_, classname_,
+ NameEquality::EXACT_EQUAL)) {
error->assign(file_->name());
error->append(
- ": Cannot generate Java output because the file's outer class name, "
- "\"");
+ ": Cannot generate Java output because the file's outer class name, "
+ "\"");
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.");
+ "\", 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;
}
- // 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.
- if (name_resolver_->HasConflictingClassName(
- file_, classname_, NameEquality::EQUAL_IGNORE_CASE)) {
- GOOGLE_LOG(WARNING)
- << file_->name() << ": The file's outer class name, \"" << classname_
- << "\", matches the name of one of the types declared inside it when "
- << "case is ignored. This can cause compilation issues on Windows / "
- << "MacOS. Please either rename the type or use the "
- << "java_outer_classname option to specify a different outer class "
- << "name for the .proto file to be safe.";
- }
-
- // Print a warning if optimize_for = LITE_RUNTIME is used.
- if (file_->options().optimize_for() == FileOptions::LITE_RUNTIME &&
- !options_.enforce_lite) {
- GOOGLE_LOG(WARNING)
- << "The optimize_for = LITE_RUNTIME option is no longer supported by "
- << "protobuf Java code generator and is ignored--protoc will always "
- << "generate full runtime code for Java. To use Java Lite runtime, "
- << "users should use the Java Lite plugin instead. See:\n"
- << " "
- "https://github.com/protocolbuffers/protobuf/blob/master/java/"
- "lite.md";
- }
+ // 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.
+ if (name_resolver_->HasConflictingClassName(
+ file_, classname_, NameEquality::EQUAL_IGNORE_CASE)) {
+ GOOGLE_LOG(WARNING)
+ << file_->name() << ": The file's outer class name, \"" << classname_
+ << "\", matches the name of one of the types declared inside it when "
+ << "case is ignored. This can cause compilation issues on Windows / "
+ << "MacOS. Please either rename the type or use the "
+ << "java_outer_classname option to specify a different outer class "
+ << "name for the .proto file to be safe.";
+ }
+
+ // Print a warning if optimize_for = LITE_RUNTIME is used.
+ if (file_->options().optimize_for() == FileOptions::LITE_RUNTIME &&
+ !options_.enforce_lite) {
+ GOOGLE_LOG(WARNING)
+ << "The optimize_for = LITE_RUNTIME option is no longer supported by "
+ << "protobuf Java code generator and is ignored--protoc will always "
+ << "generate full runtime code for Java. To use Java Lite runtime, "
+ << "users should use the Java Lite plugin instead. See:\n"
+ << " "
+ "https://github.com/protocolbuffers/protobuf/blob/master/java/"
+ "lite.md";
+ }
return true;
}
@@ -257,24 +257,24 @@ 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());
+ "// 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_);
+ "package $package$;\n"
+ "\n",
+ "package", java_package_);
}
PrintGeneratedAnnotation(
printer, '$', options_.annotate_code ? classname_ + ".java.pb.meta" : "");
-
+
printer->Print(
- "$deprecation$public final class $classname$ {\n"
+ "$deprecation$public final class $classname$ {\n"
" private $ctor$() {}\n",
- "deprecation",
- file_->options().deprecated() ? "@java.lang.Deprecated " : "",
+ "deprecation",
+ file_->options().deprecated() ? "@java.lang.Deprecated " : "",
"classname", classname_, "ctor", classname_);
printer->Annotate("classname", file_->name());
printer->Indent();
@@ -282,8 +282,8 @@ void FileGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
printer->Print(
- "public static void registerAllExtensions(\n"
- " com.google.protobuf.ExtensionRegistryLite registry) {\n");
+ "public static void registerAllExtensions(\n"
+ " com.google.protobuf.ExtensionRegistryLite registry) {\n");
printer->Indent();
@@ -296,7 +296,7 @@ void FileGenerator::Generate(io::Printer* printer) {
}
printer->Outdent();
- printer->Print("}\n");
+ printer->Print("}\n");
if (HasDescriptorMethods(file_, context_->EnforceLite())) {
// Overload registerAllExtensions for the non-lite usage to
// redundantly maintain the original signature (this is
@@ -304,12 +304,12 @@ void FileGenerator::Generate(io::Printer* printer) {
// 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");
+ "\n"
+ "public static void registerAllExtensions(\n"
+ " com.google.protobuf.ExtensionRegistry registry) {\n"
+ " registerAllExtensions(\n"
+ " (com.google.protobuf.ExtensionRegistryLite) registry);\n"
+ "}\n");
}
// -----------------------------------------------------------------
@@ -330,7 +330,7 @@ void FileGenerator::Generate(io::Printer* printer) {
}
if (HasGenericServices(file_, context_->EnforceLite())) {
for (int i = 0; i < file_->service_count(); i++) {
- std::unique_ptr<ServiceGenerator> generator(
+ std::unique_ptr<ServiceGenerator> generator(
generator_factory_->NewServiceGenerator(file_->service(i)));
generator->Generate(printer);
}
@@ -361,27 +361,27 @@ void FileGenerator::Generate(io::Printer* printer) {
GenerateDescriptorInitializationCodeForMutable(printer);
}
} else {
- printer->Print("static {\n");
+ printer->Print("static {\n");
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);
+ bytecode_estimate +=
+ message_generators_[i]->GenerateStaticVariableInitializers(printer);
MaybeRestartJavaMethod(
- printer, &bytecode_estimate, &method_num,
- "_clinit_autosplit_$method_num$();\n",
- "private static void _clinit_autosplit_$method_num$() {\n");
+ printer, &bytecode_estimate, &method_num,
+ "_clinit_autosplit_$method_num$();\n",
+ "private static void _clinit_autosplit_$method_num$() {\n");
}
printer->Outdent();
- printer->Print("}\n");
+ printer->Print("}\n");
}
printer->Print(
- "\n"
- "// @@protoc_insertion_point(outer_class_scope)\n");
+ "\n"
+ "// @@protoc_insertion_point(outer_class_scope)\n");
printer->Outdent();
printer->Print("}\n");
@@ -390,15 +390,15 @@ void FileGenerator::Generate(io::Printer* printer) {
void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
io::Printer* printer) {
printer->Print(
- "public static com.google.protobuf.Descriptors.FileDescriptor\n"
- " getDescriptor() {\n"
- " return descriptor;\n"
- "}\n"
- "private static $final$ com.google.protobuf.Descriptors.FileDescriptor\n"
- " descriptor;\n"
- "static {\n",
- // TODO(dweis): Mark this as final.
- "final", "");
+ "public static com.google.protobuf.Descriptors.FileDescriptor\n"
+ " getDescriptor() {\n"
+ " return descriptor;\n"
+ "}\n"
+ "private static $final$ com.google.protobuf.Descriptors.FileDescriptor\n"
+ " descriptor;\n"
+ "static {\n",
+ // TODO(dweis): Mark this as final.
+ "final", "");
printer->Indent();
SharedCodeGenerator shared_code_generator(file_, options_);
@@ -408,20 +408,20 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
int method_num = 0;
for (int i = 0; i < file_->message_type_count(); i++) {
- bytecode_estimate +=
- message_generators_[i]->GenerateStaticVariableInitializers(printer);
+ bytecode_estimate +=
+ message_generators_[i]->GenerateStaticVariableInitializers(printer);
MaybeRestartJavaMethod(
- printer, &bytecode_estimate, &method_num,
- "_clinit_autosplit_dinit_$method_num$();\n",
- "private static void _clinit_autosplit_dinit_$method_num$() {\n");
+ 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++) {
- bytecode_estimate +=
- extension_generators_[i]->GenerateNonNestedInitializationCode(printer);
+ bytecode_estimate +=
+ extension_generators_[i]->GenerateNonNestedInitializationCode(printer);
MaybeRestartJavaMethod(
- printer, &bytecode_estimate, &method_num,
- "_clinit_autosplit_dinit_$method_num$();\n",
- "private static void _clinit_autosplit_dinit_$method_num$() {\n");
+ 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
@@ -441,7 +441,7 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
// reflections to find all extension fields
FileDescriptorProto file_proto;
file_->CopyTo(&file_proto);
- TProtoStringType file_data;
+ TProtoStringType file_data;
file_proto.SerializeToString(&file_data);
FieldDescriptorSet extensions;
CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
@@ -450,54 +450,54 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
// 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");
+ "com.google.protobuf.ExtensionRegistry registry =\n"
+ " com.google.protobuf.ExtensionRegistry.newInstance();\n");
FieldDescriptorSet::iterator it;
for (it = extensions.begin(); it != extensions.end(); it++) {
- std::unique_ptr<ExtensionGenerator> generator(
+ std::unique_ptr<ExtensionGenerator> generator(
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, &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(
- "com.google.protobuf.Descriptors.FileDescriptor\n"
- " .internalUpdateFileDescriptor(descriptor, registry);\n");
+ "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)) {
- TProtoStringType dependency =
+ TProtoStringType dependency =
name_resolver_->GetImmutableClassName(file_->dependency(i));
- printer->Print("$dependency$.getDescriptor();\n", "dependency",
- dependency);
+ printer->Print("$dependency$.getDescriptor();\n", "dependency",
+ dependency);
}
}
printer->Outdent();
- printer->Print("}\n");
+ printer->Print("}\n");
}
-void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
- io::Printer* printer) {
+void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
+ io::Printer* printer) {
printer->Print(
- "public static com.google.protobuf.Descriptors.FileDescriptor\n"
- " getDescriptor() {\n"
- " return descriptor;\n"
- "}\n"
- "private static final com.google.protobuf.Descriptors.FileDescriptor\n"
- " descriptor;\n"
- "static {\n");
+ "public static com.google.protobuf.Descriptors.FileDescriptor\n"
+ " getDescriptor() {\n"
+ " return descriptor;\n"
+ "}\n"
+ "private static final com.google.protobuf.Descriptors.FileDescriptor\n"
+ " descriptor;\n"
+ "static {\n");
printer->Indent();
printer->Print(
- "descriptor = $immutable_package$.$descriptor_classname$.descriptor;\n",
- "immutable_package", FileJavaPackage(file_, true), "descriptor_classname",
- name_resolver_->GetDescriptorClassName(file_));
+ "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);
@@ -510,7 +510,7 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
// custom options are only represented with immutable messages.
FileDescriptorProto file_proto;
file_->CopyTo(&file_proto);
- TProtoStringType file_data;
+ TProtoStringType file_data;
file_proto.SerializeToString(&file_data);
FieldDescriptorSet extensions;
CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);
@@ -524,7 +524,7 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
// we want the mutable code to be independent from the immutable code
// at compile time. It is required to implement dual-compile for
// mutable and immutable API in blaze.
- " java.lang.Class<?> immutableClass = java.lang.Class.forName(\n"
+ " java.lang.Class<?> immutableClass = java.lang.Class.forName(\n"
" \"$immutable_classname$\");\n"
"} catch (java.lang.ClassNotFoundException e) {\n",
"immutable_classname", name_resolver_->GetImmutableClassName(file_));
@@ -539,7 +539,7 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
FieldDescriptorSet::iterator it;
for (it = extensions.begin(); it != extensions.end(); it++) {
const FieldDescriptor* field = *it;
- TProtoStringType scope;
+ TProtoStringType scope;
if (field->extension_scope() != NULL) {
scope = name_resolver_->GetMutableClassName(field->extension_scope()) +
".getDescriptor()";
@@ -557,11 +557,11 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
" $scope$.getExtensions().get($index$),\n"
" (com.google.protobuf.Message) defaultExtensionInstance);\n"
"}\n",
- "scope", scope, "index", StrCat(field->index()), "class",
+ "scope", scope, "index", StrCat(field->index()), "class",
name_resolver_->GetImmutableClassName(field->message_type()));
} else {
printer->Print("registry.add($scope$.getExtensions().get($index$));\n",
- "scope", scope, "index", StrCat(field->index()));
+ "scope", scope, "index", StrCat(field->index()));
}
}
printer->Print(
@@ -575,63 +575,63 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable(
// 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);
+ TProtoStringType dependency =
+ name_resolver_->GetMutableClassName(file_->dependency(i));
+ printer->Print("$dependency$.getDescriptor();\n", "dependency",
+ dependency);
}
}
printer->Outdent();
- printer->Print("}\n");
+ printer->Print("}\n");
}
template <typename GeneratorClass, typename DescriptorClass>
-static void GenerateSibling(
- const TProtoStringType& package_dir, const TProtoStringType& java_package,
- const DescriptorClass* descriptor, GeneratorContext* context,
- std::vector<TProtoStringType>* file_list, bool annotate_code,
- std::vector<TProtoStringType>* annotation_list, const TProtoStringType& name_suffix,
- GeneratorClass* generator,
- void (GeneratorClass::*pfn)(io::Printer* printer)) {
- TProtoStringType filename =
- package_dir + descriptor->name() + name_suffix + ".java";
+static void GenerateSibling(
+ const TProtoStringType& package_dir, const TProtoStringType& java_package,
+ const DescriptorClass* descriptor, GeneratorContext* context,
+ std::vector<TProtoStringType>* file_list, bool annotate_code,
+ std::vector<TProtoStringType>* annotation_list, const TProtoStringType& name_suffix,
+ GeneratorClass* generator,
+ void (GeneratorClass::*pfn)(io::Printer* printer)) {
+ TProtoStringType filename =
+ package_dir + descriptor->name() + name_suffix + ".java";
file_list->push_back(filename);
- TProtoStringType info_full_path = filename + ".pb.meta";
+ TProtoStringType info_full_path = filename + ".pb.meta";
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
- std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
+ std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
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());
+ "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"
+ "// source: $filename$\n"
+ "\n",
+ "filename", descriptor->file()->name());
if (!java_package.empty()) {
printer.Print(
- "package $package$;\n"
- "\n",
- "package", java_package);
+ "package $package$;\n"
+ "\n",
+ "package", java_package);
}
(generator->*pfn)(&printer);
if (annotate_code) {
- std::unique_ptr<io::ZeroCopyOutputStream> info_output(
+ std::unique_ptr<io::ZeroCopyOutputStream> info_output(
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) {
+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())) {
@@ -664,7 +664,7 @@ void FileGenerator::GenerateSiblings(
}
if (HasGenericServices(file_, context_->EnforceLite())) {
for (int i = 0; i < file_->service_count(); i++) {
- std::unique_ptr<ServiceGenerator> generator(
+ std::unique_ptr<ServiceGenerator> generator(
generator_factory_->NewServiceGenerator(file_->service(i)));
GenerateSibling<ServiceGenerator>(
package_dir, java_package_, file_->service(i), context, file_list,
@@ -675,56 +675,56 @@ void FileGenerator::GenerateSiblings(
}
}
-TProtoStringType FileGenerator::GetKotlinClassname() {
- return name_resolver_->GetFileClassName(file_, immutable_api_, true);
-}
-
-void FileGenerator::GenerateKotlinSiblings(
- const TProtoStringType& package_dir, GeneratorContext* context,
- std::vector<TProtoStringType>* file_list,
- std::vector<TProtoStringType>* annotation_list) {
- for (int i = 0; i < file_->message_type_count(); i++) {
- const Descriptor* descriptor = file_->message_type(i);
- MessageGenerator* generator = message_generators_[i].get();
- auto open_file = [context](const TProtoStringType& filename) {
- return std::unique_ptr<io::ZeroCopyOutputStream>(context->Open(filename));
- };
- TProtoStringType filename = package_dir + descriptor->name() + "Kt.kt";
- file_list->push_back(filename);
- TProtoStringType info_full_path = filename + ".pb.meta";
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- auto output = open_file(filename);
- io::Printer printer(
- output.get(), '$',
- options_.annotate_code ? &annotation_collector : nullptr);
-
- 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(
- "package $package$;\n"
- "\n",
- "package", java_package_);
- }
-
- generator->GenerateKotlinMembers(&printer);
- generator->GenerateTopLevelKotlinMembers(&printer);
-
- if (options_.annotate_code) {
- auto info_output = open_file(info_full_path);
- annotations.SerializeToZeroCopyStream(info_output.get());
- annotation_list->push_back(info_full_path);
- }
- }
-}
-
-bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor,
- bool immutable_api) {
+TProtoStringType FileGenerator::GetKotlinClassname() {
+ return name_resolver_->GetFileClassName(file_, immutable_api_, true);
+}
+
+void FileGenerator::GenerateKotlinSiblings(
+ const TProtoStringType& package_dir, GeneratorContext* context,
+ std::vector<TProtoStringType>* file_list,
+ std::vector<TProtoStringType>* annotation_list) {
+ for (int i = 0; i < file_->message_type_count(); i++) {
+ const Descriptor* descriptor = file_->message_type(i);
+ MessageGenerator* generator = message_generators_[i].get();
+ auto open_file = [context](const TProtoStringType& filename) {
+ return std::unique_ptr<io::ZeroCopyOutputStream>(context->Open(filename));
+ };
+ TProtoStringType filename = package_dir + descriptor->name() + "Kt.kt";
+ file_list->push_back(filename);
+ TProtoStringType info_full_path = filename + ".pb.meta";
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
+ auto output = open_file(filename);
+ io::Printer printer(
+ output.get(), '$',
+ options_.annotate_code ? &annotation_collector : nullptr);
+
+ 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(
+ "package $package$;\n"
+ "\n",
+ "package", java_package_);
+ }
+
+ generator->GenerateKotlinMembers(&printer);
+ generator->GenerateTopLevelKotlinMembers(&printer);
+
+ if (options_.annotate_code) {
+ auto info_output = open_file(info_full_path);
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ annotation_list->push_back(info_full_path);
+ }
+ }
+}
+
+bool FileGenerator::ShouldIncludeDependency(const FileDescriptor* descriptor,
+ bool immutable_api) {
return true;
}
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 fe9e505259..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
@@ -36,31 +36,31 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
#include <memory>
-#include <string>
+#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/compiler/java/java_options.h>
namespace google {
namespace protobuf {
-class FileDescriptor; // descriptor.h
-namespace io {
-class Printer; // printer.h
+class FileDescriptor; // descriptor.h
+namespace io {
+class Printer; // printer.h
}
-namespace compiler {
-class GeneratorContext; // code_generator.h
-namespace java {
-class Context; // context.h
-class MessageGenerator; // message.h
-class GeneratorFactory; // generator_factory.h
-class ExtensionGenerator; // extension.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+class GeneratorContext; // code_generator.h
+namespace java {
+class Context; // context.h
+class MessageGenerator; // message.h
+class GeneratorFactory; // generator_factory.h
+class ExtensionGenerator; // extension.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -74,26 +74,26 @@ class 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);
+ bool Validate(TProtoStringType* error);
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);
-
+ 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).
- void GenerateSiblings(const TProtoStringType& package_dir,
+ void GenerateSiblings(const TProtoStringType& package_dir,
GeneratorContext* generator_context,
- std::vector<TProtoStringType>* file_list,
- std::vector<TProtoStringType>* annotation_list);
+ std::vector<TProtoStringType>* file_list,
+ std::vector<TProtoStringType>* annotation_list);
- const TProtoStringType& java_package() { return java_package_; }
- const TProtoStringType& classname() { return classname_; }
+ const TProtoStringType& java_package() { return java_package_; }
+ const TProtoStringType& classname() { return classname_; }
private:
void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer);
@@ -103,13 +103,13 @@ class FileGenerator {
bool immutable_api_);
const FileDescriptor* file_;
- TProtoStringType java_package_;
- TProtoStringType classname_;
+ 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_;
+ 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_;
@@ -120,6 +120,6 @@ class FileGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 7386464d9c..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
@@ -32,22 +32,22 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_generator.h>
+#include <google/protobuf/compiler/java/java_generator.h>
+
-
#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>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/compiler/java/java_options.h>
-#include <google/protobuf/compiler/java/java_shared_code_generator.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
+#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>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/compiler/java/java_shared_code_generator.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -58,18 +58,18 @@ namespace java {
JavaGenerator::JavaGenerator() {}
JavaGenerator::~JavaGenerator() {}
-uint64_t JavaGenerator::GetSupportedFeatures() const {
- return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
-}
-
+uint64_t JavaGenerator::GetSupportedFeatures() const {
+ return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
+}
+
bool JavaGenerator::Generate(const FileDescriptor* file,
- const TProtoStringType& parameter,
+ const TProtoStringType& parameter,
GeneratorContext* context,
- TProtoStringType* error) const {
+ TProtoStringType* error) const {
// -----------------------------------------------------------------
// parse generator options
- std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
+ std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
ParseGeneratorParameter(parameter, &options);
Options file_options;
@@ -82,10 +82,10 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
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 == "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") {
@@ -112,8 +112,8 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
// -----------------------------------------------------------------
- std::vector<TProtoStringType> all_files;
- std::vector<TProtoStringType> all_annotations;
+ std::vector<TProtoStringType> all_files;
+ std::vector<TProtoStringType> all_annotations;
std::vector<FileGenerator*> file_generators;
@@ -125,7 +125,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
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) {
@@ -138,26 +138,26 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
for (int i = 0; i < file_generators.size(); ++i) {
FileGenerator* file_generator = file_generators[i];
- TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
+ TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
- TProtoStringType java_filename = package_dir;
+ TProtoStringType java_filename = package_dir;
java_filename += file_generator->classname();
java_filename += ".java";
all_files.push_back(java_filename);
- TProtoStringType info_full_path = java_filename + ".pb.meta";
+ TProtoStringType info_full_path = java_filename + ".pb.meta";
if (file_options.annotate_code) {
all_annotations.push_back(info_full_path);
}
// Generate main java file.
- std::unique_ptr<io::ZeroCopyOutputStream> output(
+ std::unique_ptr<io::ZeroCopyOutputStream> output(
context->Open(java_filename));
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
- io::Printer printer(
- output.get(), '$',
- file_options.annotate_code ? &annotation_collector : NULL);
+ io::Printer printer(
+ output.get(), '$',
+ file_options.annotate_code ? &annotation_collector : NULL);
file_generator->Generate(&printer);
@@ -166,13 +166,13 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
&all_annotations);
if (file_options.annotate_code) {
- std::unique_ptr<io::ZeroCopyOutputStream> info_output(
+ 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];
}
@@ -182,7 +182,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
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(
+ 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++) {
@@ -193,7 +193,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
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(
+ 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++) {
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 ba80be7850..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
@@ -37,11 +37,11 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__
-#include <string>
-#include <google/protobuf/compiler/code_generator.h>
+#include <string>
+#include <google/protobuf/compiler/code_generator.h>
+
+#include <google/protobuf/port_def.inc>
-#include <google/protobuf/port_def.inc>
-
namespace google {
namespace protobuf {
namespace compiler {
@@ -51,17 +51,17 @@ namespace java {
// 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 {
+class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
public:
JavaGenerator();
~JavaGenerator();
// implements CodeGenerator ----------------------------------------
- bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
- GeneratorContext* context, TProtoStringType* error) const override;
+ bool Generate(const FileDescriptor* file, const TProtoStringType& parameter,
+ GeneratorContext* context, TProtoStringType* error) const override;
+
+ uint64_t GetSupportedFeatures() const override;
- uint64_t GetSupportedFeatures() const override;
-
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);
};
@@ -69,8 +69,8 @@ class PROTOC_EXPORT JavaGenerator : public CodeGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
+
+#include <google/protobuf/port_undef.inc>
-#include <google/protobuf/port_undef.inc>
-
#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 00756d7a90..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
@@ -30,17 +30,17 @@
// Author: liujisi@google.com (Pherl Liu)
-#include <google/protobuf/compiler/java/java_generator_factory.h>
+#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>
-#include <google/protobuf/compiler/java/java_extension_lite.h>
-#include <google/protobuf/compiler/java/java_field.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#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>
+#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>
+#include <google/protobuf/compiler/java/java_extension_lite.h>
+#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#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 {
@@ -52,8 +52,8 @@ GeneratorFactory::~GeneratorFactory() {}
// ===================================================================
-ImmutableGeneratorFactory::ImmutableGeneratorFactory(Context* context)
- : context_(context) {}
+ImmutableGeneratorFactory::ImmutableGeneratorFactory(Context* context)
+ : context_(context) {}
ImmutableGeneratorFactory::~ImmutableGeneratorFactory() {}
MessageGenerator* ImmutableGeneratorFactory::NewMessageGenerator(
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 f9babbab26..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
@@ -33,25 +33,25 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__
-#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
-class FieldDescriptor; // descriptor.h
-class Descriptor; // descriptor.h
-class ServiceDescriptor; // descriptor.h
-namespace compiler {
-namespace java {
-class MessageGenerator; // message.h
-class ExtensionGenerator; // extension.h
-class ServiceGenerator; // service.h
-class Context; // context.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+class FieldDescriptor; // descriptor.h
+class Descriptor; // descriptor.h
+class ServiceDescriptor; // descriptor.h
+namespace compiler {
+namespace java {
+class MessageGenerator; // message.h
+class ExtensionGenerator; // extension.h
+class ServiceGenerator; // service.h
+class Context; // context.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -98,6 +98,6 @@ class ImmutableGeneratorFactory : public GeneratorFactory {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 40e7d12565..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
@@ -32,22 +32,22 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_helpers.h>
-
+#include <google/protobuf/compiler/java/java_helpers.h>
+
#include <algorithm>
-#include <cstdint>
+#include <cstdint>
#include <limits>
-#include <unordered_set>
+#include <unordered_set>
#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>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
-#include <google/protobuf/stubs/hash.h> // for hash<T *>
+#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/compiler/java/java_names.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/wire_format.h>
+#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 {
@@ -58,9 +58,9 @@ using internal::WireFormat;
using internal::WireFormatLite;
const char kThickSeparator[] =
- "// ===================================================================\n";
+ "// ===================================================================\n";
const char kThinSeparator[] =
- "// -------------------------------------------------------------------\n";
+ "// -------------------------------------------------------------------\n";
namespace {
@@ -70,28 +70,28 @@ const char* kDefaultPackage = "";
// 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",
+ // 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",
- "case", "catch", "char", "class", "const",
- "continue", "default", "do", "double", "else",
- "enum", "extends", "final", "finally", "float",
- "for", "goto", "if", "implements", "import",
- "instanceof", "int", "interface", "long", "native",
- "new", "package", "private", "protected", "public",
- "return", "short", "static", "strictfp", "super",
- "switch", "synchronized", "this", "throw", "throws",
- "transient", "try", "void", "volatile", "while",
- });
-
-bool IsForbidden(const TProtoStringType& field_name) {
+const std::unordered_set<TProtoStringType>* kReservedNames =
+ new std::unordered_set<TProtoStringType>({
+ "abstract", "assert", "boolean", "break", "byte",
+ "case", "catch", "char", "class", "const",
+ "continue", "default", "do", "double", "else",
+ "enum", "extends", "final", "finally", "float",
+ "for", "goto", "if", "implements", "import",
+ "instanceof", "int", "interface", "long", "native",
+ "new", "package", "private", "protected", "public",
+ "return", "short", "static", "strictfp", "super",
+ "switch", "synchronized", "this", "throw", "throws",
+ "transient", "try", "void", "volatile", "while",
+ });
+
+bool IsForbidden(const TProtoStringType& field_name) {
for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {
if (field_name == kForbiddenWordList[i]) {
return true;
@@ -100,8 +100,8 @@ bool IsForbidden(const TProtoStringType& field_name) {
return false;
}
-TProtoStringType FieldName(const FieldDescriptor* field) {
- TProtoStringType field_name;
+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.
@@ -122,11 +122,11 @@ TProtoStringType FieldName(const FieldDescriptor* field) {
} // namespace
void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
- const TProtoStringType& annotation_file) {
+ const TProtoStringType& annotation_file) {
if (annotation_file.empty()) {
return;
}
- TProtoStringType ptemplate =
+ TProtoStringType ptemplate =
"@javax.annotation.Generated(value=\"protoc\", comments=\"annotations:";
ptemplate.push_back(delimiter);
ptemplate.append("annotation_file");
@@ -135,31 +135,31 @@ void PrintGeneratedAnnotation(io::Printer* printer, char delimiter,
printer->Print(ptemplate.c_str(), "annotation_file", annotation_file);
}
-void PrintEnumVerifierLogic(io::Printer* printer,
- const FieldDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& variables,
- const char* var_name,
- const char* terminating_string, bool enforce_lite) {
- TProtoStringType enum_verifier_string =
- enforce_lite ? StrCat(var_name, ".internalGetVerifier()")
- : StrCat(
- "new com.google.protobuf.Internal.EnumVerifier() {\n"
- " @java.lang.Override\n"
- " public boolean isInRange(int number) {\n"
- " return ",
- var_name,
- ".forNumber(number) != null;\n"
- " }\n"
- " }");
- printer->Print(
- variables,
- StrCat(enum_verifier_string, terminating_string).c_str());
-}
-
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
- bool cap_next_letter) {
- GOOGLE_CHECK(!input.empty());
- TProtoStringType result;
+void PrintEnumVerifierLogic(io::Printer* printer,
+ const FieldDescriptor* descriptor,
+ const std::map<TProtoStringType, TProtoStringType>& variables,
+ const char* var_name,
+ const char* terminating_string, bool enforce_lite) {
+ TProtoStringType enum_verifier_string =
+ enforce_lite ? StrCat(var_name, ".internalGetVerifier()")
+ : StrCat(
+ "new com.google.protobuf.Internal.EnumVerifier() {\n"
+ " @java.lang.Override\n"
+ " public boolean isInRange(int number) {\n"
+ " return ",
+ var_name,
+ ".forNumber(number) != null;\n"
+ " }\n"
+ " }");
+ printer->Print(
+ variables,
+ StrCat(enum_verifier_string, terminating_string).c_str());
+}
+
+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') {
@@ -193,97 +193,97 @@ TProtoStringType UnderscoresToCamelCase(const TProtoStringType& input,
return result;
}
-TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
- bool capitalize_next = !lower_first;
- TProtoStringType result;
- result.reserve(input.size());
-
- for (char i : input) {
- if (i == '_') {
- capitalize_next = true;
- } else if (capitalize_next) {
- result.push_back(ToUpperCh(i));
- capitalize_next = false;
- } else {
- result.push_back(i);
- }
- }
-
- // Lower-case the first letter.
- if (lower_first && !result.empty()) {
- result[0] = ToLowerCh(result[0]);
- }
-
- return result;
-}
-
-char ToUpperCh(char ch) {
- return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
-}
-
-char ToLowerCh(char ch) {
- return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
-}
-
-TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field) {
+TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first) {
+ bool capitalize_next = !lower_first;
+ TProtoStringType result;
+ result.reserve(input.size());
+
+ for (char i : input) {
+ if (i == '_') {
+ capitalize_next = true;
+ } else if (capitalize_next) {
+ result.push_back(ToUpperCh(i));
+ capitalize_next = false;
+ } else {
+ result.push_back(i);
+ }
+ }
+
+ // Lower-case the first letter.
+ if (lower_first && !result.empty()) {
+ result[0] = ToLowerCh(result[0]);
+ }
+
+ return result;
+}
+
+char ToUpperCh(char ch) {
+ return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch;
+}
+
+char ToLowerCh(char ch) {
+ return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch;
+}
+
+TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field) {
return UnderscoresToCamelCase(FieldName(field), false);
}
-TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
+TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {
return UnderscoresToCamelCase(FieldName(field), true);
}
-TProtoStringType CapitalizedFieldName(const FieldDescriptor* field) {
- return UnderscoresToCapitalizedCamelCase(field);
-}
-
-TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method) {
+TProtoStringType CapitalizedFieldName(const FieldDescriptor* field) {
+ return UnderscoresToCapitalizedCamelCase(field);
+}
+
+TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method) {
return UnderscoresToCamelCase(method->name(), false);
}
-TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {
- TProtoStringType name = UnderscoresToCamelCase(field);
- if (kReservedNames->find(name) != kReservedNames->end()) {
- return name + "_";
- }
- return name;
-}
-
-bool IsForbiddenKotlin(const TProtoStringType& field_name) {
- // Names that should be avoided as field names in Kotlin.
- // All Kotlin hard keywords are in this list.
- const std::unordered_set<TProtoStringType>* kKotlinForbiddenNames =
- new std::unordered_set<TProtoStringType>({
- "as", "as?", "break", "class", "continue", "do",
- "else", "false", "for", "fun", "if", "in",
- "!in", "interface", "is", "!is", "null", "object",
- "package", "return", "super", "this", "throw", "true",
- "try", "typealias", "typeof", "val", "var", "when",
- "while",
- });
- return kKotlinForbiddenNames->find(field_name) !=
- kKotlinForbiddenNames->end();
-}
-
-TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor) {
+TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field) {
+ TProtoStringType name = UnderscoresToCamelCase(field);
+ if (kReservedNames->find(name) != kReservedNames->end()) {
+ return name + "_";
+ }
+ return name;
+}
+
+bool IsForbiddenKotlin(const TProtoStringType& field_name) {
+ // Names that should be avoided as field names in Kotlin.
+ // All Kotlin hard keywords are in this list.
+ const std::unordered_set<TProtoStringType>* kKotlinForbiddenNames =
+ new std::unordered_set<TProtoStringType>({
+ "as", "as?", "break", "class", "continue", "do",
+ "else", "false", "for", "fun", "if", "in",
+ "!in", "interface", "is", "!is", "null", "object",
+ "package", "return", "super", "this", "throw", "true",
+ "try", "typealias", "typeof", "val", "var", "when",
+ "while",
+ });
+ return kKotlinForbiddenNames->find(field_name) !=
+ kKotlinForbiddenNames->end();
+}
+
+TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor) {
return "static_" + StringReplace(descriptor->full_name(), ".", "_", true);
}
-TProtoStringType CamelCaseFieldName(const FieldDescriptor* field) {
- TProtoStringType fieldName = UnderscoresToCamelCase(field);
+TProtoStringType CamelCaseFieldName(const FieldDescriptor* field) {
+ TProtoStringType fieldName = UnderscoresToCamelCase(field);
if ('0' <= fieldName[0] && fieldName[0] <= '9') {
- return '_' + fieldName;
+ return '_' + fieldName;
}
return fieldName;
}
-TProtoStringType FileClassName(const FileDescriptor* file, bool immutable) {
+TProtoStringType FileClassName(const FileDescriptor* file, bool immutable) {
ClassNameResolver name_resolver;
return name_resolver.GetFileClassName(file, immutable);
}
-TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable) {
- TProtoStringType result;
+TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable) {
+ TProtoStringType result;
if (file->options().has_java_package()) {
result = file->options().java_package();
@@ -298,59 +298,59 @@ TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable) {
return result;
}
-TProtoStringType FileJavaPackage(const FileDescriptor* file) {
- return FileJavaPackage(file, true /* immutable */);
-}
-
-TProtoStringType JavaPackageToDir(TProtoStringType package_name) {
- TProtoStringType package_dir = StringReplace(package_name, ".", "/", true);
+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;
}
-TProtoStringType ClassName(const Descriptor* descriptor) {
+TProtoStringType ClassName(const Descriptor* descriptor) {
ClassNameResolver name_resolver;
return name_resolver.GetClassName(descriptor, true);
}
-TProtoStringType ClassName(const EnumDescriptor* descriptor) {
+TProtoStringType ClassName(const EnumDescriptor* descriptor) {
ClassNameResolver name_resolver;
return name_resolver.GetClassName(descriptor, true);
}
-TProtoStringType ClassName(const ServiceDescriptor* descriptor) {
+TProtoStringType ClassName(const ServiceDescriptor* descriptor) {
ClassNameResolver name_resolver;
return name_resolver.GetClassName(descriptor, true);
}
-TProtoStringType ClassName(const FileDescriptor* descriptor) {
+TProtoStringType ClassName(const FileDescriptor* descriptor) {
ClassNameResolver name_resolver;
return name_resolver.GetClassName(descriptor, true);
}
-TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor) {
- TProtoStringType interfaces = "// @@protoc_insertion_point(message_implements:" +
- descriptor->full_name() + ")";
+TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor) {
+ TProtoStringType interfaces = "// @@protoc_insertion_point(message_implements:" +
+ descriptor->full_name() + ")";
return interfaces;
}
-TProtoStringType ExtraBuilderInterfaces(const Descriptor* descriptor) {
- TProtoStringType interfaces = "// @@protoc_insertion_point(builder_implements:" +
- descriptor->full_name() + ")";
+TProtoStringType ExtraBuilderInterfaces(const Descriptor* descriptor) {
+ TProtoStringType interfaces = "// @@protoc_insertion_point(builder_implements:" +
+ descriptor->full_name() + ")";
return interfaces;
}
-TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor) {
- TProtoStringType interfaces = "// @@protoc_insertion_point(interface_extends:" +
- descriptor->full_name() + ")";
+TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor) {
+ TProtoStringType interfaces = "// @@protoc_insertion_point(interface_extends:" +
+ descriptor->full_name() + ")";
return interfaces;
}
-TProtoStringType FieldConstantName(const FieldDescriptor* field) {
- TProtoStringType name = field->name() + "_FIELD_NUMBER";
- ToUpper(&name);
+TProtoStringType FieldConstantName(const FieldDescriptor* field) {
+ TProtoStringType name = field->name() + "_FIELD_NUMBER";
+ ToUpper(&name);
return name;
}
@@ -396,8 +396,8 @@ JavaType GetJavaType(const FieldDescriptor* field) {
case FieldDescriptor::TYPE_MESSAGE:
return JAVATYPE_MESSAGE;
- // No default because we want the compiler to complain if any new
- // types are added.
+ // No default because we want the compiler to complain if any new
+ // types are added.
}
GOOGLE_LOG(FATAL) << "Can't get here.";
@@ -406,159 +406,159 @@ JavaType GetJavaType(const FieldDescriptor* field) {
const char* PrimitiveTypeName(JavaType type) {
switch (type) {
- case JAVATYPE_INT:
- return "int";
- case JAVATYPE_LONG:
- return "long";
- case JAVATYPE_FLOAT:
- return "float";
- case JAVATYPE_DOUBLE:
- return "double";
- case JAVATYPE_BOOLEAN:
- return "boolean";
- case JAVATYPE_STRING:
- return "java.lang.String";
- case JAVATYPE_BYTES:
- return "com.google.protobuf.ByteString";
- case JAVATYPE_ENUM:
- return NULL;
- case JAVATYPE_MESSAGE:
- return NULL;
-
- // No default because we want the compiler to complain if any new
- // JavaTypes are added.
+ case JAVATYPE_INT:
+ return "int";
+ case JAVATYPE_LONG:
+ return "long";
+ case JAVATYPE_FLOAT:
+ return "float";
+ case JAVATYPE_DOUBLE:
+ return "double";
+ case JAVATYPE_BOOLEAN:
+ return "boolean";
+ case JAVATYPE_STRING:
+ return "java.lang.String";
+ case JAVATYPE_BYTES:
+ return "com.google.protobuf.ByteString";
+ case JAVATYPE_ENUM:
+ 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;
}
-const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
- return PrimitiveTypeName(GetJavaType(descriptor));
-}
-
+const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
+ return PrimitiveTypeName(GetJavaType(descriptor));
+}
+
const char* BoxedPrimitiveTypeName(JavaType type) {
switch (type) {
- case JAVATYPE_INT:
- return "java.lang.Integer";
- case JAVATYPE_LONG:
- return "java.lang.Long";
- case JAVATYPE_FLOAT:
- return "java.lang.Float";
- case JAVATYPE_DOUBLE:
- return "java.lang.Double";
- case JAVATYPE_BOOLEAN:
- return "java.lang.Boolean";
- case JAVATYPE_STRING:
- return "java.lang.String";
- case JAVATYPE_BYTES:
- return "com.google.protobuf.ByteString";
- case JAVATYPE_ENUM:
- return NULL;
- case JAVATYPE_MESSAGE:
- return NULL;
-
- // No default because we want the compiler to complain if any new
- // JavaTypes are added.
+ case JAVATYPE_INT:
+ return "java.lang.Integer";
+ case JAVATYPE_LONG:
+ return "java.lang.Long";
+ case JAVATYPE_FLOAT:
+ return "java.lang.Float";
+ case JAVATYPE_DOUBLE:
+ return "java.lang.Double";
+ case JAVATYPE_BOOLEAN:
+ return "java.lang.Boolean";
+ case JAVATYPE_STRING:
+ return "java.lang.String";
+ case JAVATYPE_BYTES:
+ return "com.google.protobuf.ByteString";
+ case JAVATYPE_ENUM:
+ 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;
+}
+
+const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) {
+ return BoxedPrimitiveTypeName(GetJavaType(descriptor));
+}
+
+const char* KotlinTypeName(JavaType type) {
+ switch (type) {
+ case JAVATYPE_INT:
+ return "kotlin.Int";
+ case JAVATYPE_LONG:
+ return "kotlin.Long";
+ case JAVATYPE_FLOAT:
+ return "kotlin.Float";
+ case JAVATYPE_DOUBLE:
+ return "kotlin.Double";
+ case JAVATYPE_BOOLEAN:
+ return "kotlin.Boolean";
+ case JAVATYPE_STRING:
+ return "kotlin.String";
+ case JAVATYPE_BYTES:
+ return "com.google.protobuf.ByteString";
+ case JAVATYPE_ENUM:
+ 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;
}
-const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) {
- return BoxedPrimitiveTypeName(GetJavaType(descriptor));
-}
-
-const char* KotlinTypeName(JavaType type) {
- switch (type) {
- case JAVATYPE_INT:
- return "kotlin.Int";
- case JAVATYPE_LONG:
- return "kotlin.Long";
- case JAVATYPE_FLOAT:
- return "kotlin.Float";
- case JAVATYPE_DOUBLE:
- return "kotlin.Double";
- case JAVATYPE_BOOLEAN:
- return "kotlin.Boolean";
- case JAVATYPE_STRING:
- return "kotlin.String";
- case JAVATYPE_BYTES:
- return "com.google.protobuf.ByteString";
- case JAVATYPE_ENUM:
- 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;
-}
-
-TProtoStringType GetOneofStoredType(const FieldDescriptor* field) {
- const JavaType javaType = GetJavaType(field);
- switch (javaType) {
- case JAVATYPE_ENUM:
- return "java.lang.Integer";
- case JAVATYPE_MESSAGE:
- return ClassName(field->message_type());
- default:
- return BoxedPrimitiveTypeName(javaType);
- }
-}
-
+TProtoStringType GetOneofStoredType(const FieldDescriptor* field) {
+ const JavaType javaType = GetJavaType(field);
+ switch (javaType) {
+ case JAVATYPE_ENUM:
+ return "java.lang.Integer";
+ case JAVATYPE_MESSAGE:
+ return ClassName(field->message_type());
+ default:
+ return BoxedPrimitiveTypeName(javaType);
+ }
+}
+
const char* FieldTypeName(FieldDescriptor::Type field_type) {
switch (field_type) {
- case FieldDescriptor::TYPE_INT32:
- return "INT32";
- case FieldDescriptor::TYPE_UINT32:
- return "UINT32";
- case FieldDescriptor::TYPE_SINT32:
- return "SINT32";
- case FieldDescriptor::TYPE_FIXED32:
- return "FIXED32";
- case FieldDescriptor::TYPE_SFIXED32:
- return "SFIXED32";
- case FieldDescriptor::TYPE_INT64:
- return "INT64";
- case FieldDescriptor::TYPE_UINT64:
- return "UINT64";
- case FieldDescriptor::TYPE_SINT64:
- return "SINT64";
- case FieldDescriptor::TYPE_FIXED64:
- return "FIXED64";
- case FieldDescriptor::TYPE_SFIXED64:
- return "SFIXED64";
- case FieldDescriptor::TYPE_FLOAT:
- return "FLOAT";
- case FieldDescriptor::TYPE_DOUBLE:
- return "DOUBLE";
- case FieldDescriptor::TYPE_BOOL:
- return "BOOL";
- case FieldDescriptor::TYPE_STRING:
- return "STRING";
- case FieldDescriptor::TYPE_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.
+ case FieldDescriptor::TYPE_INT32:
+ return "INT32";
+ case FieldDescriptor::TYPE_UINT32:
+ return "UINT32";
+ case FieldDescriptor::TYPE_SINT32:
+ return "SINT32";
+ case FieldDescriptor::TYPE_FIXED32:
+ return "FIXED32";
+ case FieldDescriptor::TYPE_SFIXED32:
+ return "SFIXED32";
+ case FieldDescriptor::TYPE_INT64:
+ return "INT64";
+ case FieldDescriptor::TYPE_UINT64:
+ return "UINT64";
+ case FieldDescriptor::TYPE_SINT64:
+ return "SINT64";
+ case FieldDescriptor::TYPE_FIXED64:
+ return "FIXED64";
+ case FieldDescriptor::TYPE_SFIXED64:
+ return "SFIXED64";
+ case FieldDescriptor::TYPE_FLOAT:
+ return "FLOAT";
+ case FieldDescriptor::TYPE_DOUBLE:
+ return "DOUBLE";
+ case FieldDescriptor::TYPE_BOOL:
+ return "BOOL";
+ case FieldDescriptor::TYPE_STRING:
+ return "STRING";
+ case FieldDescriptor::TYPE_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;
}
-bool AllAscii(const TProtoStringType& text) {
+bool AllAscii(const TProtoStringType& text) {
for (int i = 0; i < text.size(); i++) {
if ((text[i] & 0x80) != 0) {
return false;
@@ -567,20 +567,20 @@ bool AllAscii(const TProtoStringType& text) {
return true;
}
-TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
- ClassNameResolver* name_resolver) {
+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:
- return StrCat(field->default_value_int32());
+ return StrCat(field->default_value_int32());
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()));
+ return StrCat(static_cast<int32_t>(field->default_value_uint32()));
case FieldDescriptor::CPPTYPE_INT64:
- return StrCat(field->default_value_int64()) + "L";
+ return StrCat(field->default_value_int64()) + "L";
case FieldDescriptor::CPPTYPE_UINT64:
- return StrCat(static_cast<int64_t>(field->default_value_uint64())) +
+ return StrCat(static_cast<int64_t>(field->default_value_uint64())) +
"L";
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
@@ -613,8 +613,8 @@ TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
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()));
+ "com.google.protobuf.Internal.bytesDefaultValue(\"$0\")",
+ CEscape(field->default_value_string()));
} else {
return "com.google.protobuf.ByteString.EMPTY";
}
@@ -632,14 +632,14 @@ TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
case FieldDescriptor::CPPTYPE_ENUM:
return name_resolver->GetClassName(field->enum_type(), immutable) + "." +
- field->default_value_enum()->name();
+ field->default_value_enum()->name();
case FieldDescriptor::CPPTYPE_MESSAGE:
return name_resolver->GetClassName(field->message_type(), immutable) +
- ".getDefaultInstance()";
+ ".getDefaultInstance()";
- // No default because we want the compiler to complain if any new
- // types are added.
+ // No default because we want the compiler to complain if any new
+ // types are added.
}
GOOGLE_LOG(FATAL) << "Can't get here.";
@@ -670,8 +670,8 @@ bool IsDefaultValueJavaDefault(const FieldDescriptor* field) {
case FieldDescriptor::CPPTYPE_MESSAGE:
return false;
- // No default because we want the compiler to complain if any new
- // types are added.
+ // No default because we want the compiler to complain if any new
+ // types are added.
}
GOOGLE_LOG(FATAL) << "Can't get here.";
@@ -684,108 +684,108 @@ bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) {
}
const char* bit_masks[] = {
- "0x00000001", "0x00000002", "0x00000004", "0x00000008",
- "0x00000010", "0x00000020", "0x00000040", "0x00000080",
+ "0x00000001", "0x00000002", "0x00000004", "0x00000008",
+ "0x00000010", "0x00000020", "0x00000040", "0x00000080",
- "0x00000100", "0x00000200", "0x00000400", "0x00000800",
- "0x00001000", "0x00002000", "0x00004000", "0x00008000",
+ "0x00000100", "0x00000200", "0x00000400", "0x00000800",
+ "0x00001000", "0x00002000", "0x00004000", "0x00008000",
- "0x00010000", "0x00020000", "0x00040000", "0x00080000",
- "0x00100000", "0x00200000", "0x00400000", "0x00800000",
+ "0x00010000", "0x00020000", "0x00040000", "0x00080000",
+ "0x00100000", "0x00200000", "0x00400000", "0x00800000",
- "0x01000000", "0x02000000", "0x04000000", "0x08000000",
- "0x10000000", "0x20000000", "0x40000000", "0x80000000",
+ "0x01000000", "0x02000000", "0x04000000", "0x08000000",
+ "0x10000000", "0x20000000", "0x40000000", "0x80000000",
};
-TProtoStringType GetBitFieldName(int index) {
- TProtoStringType varName = "bitField";
- varName += StrCat(index);
+TProtoStringType GetBitFieldName(int index) {
+ TProtoStringType varName = "bitField";
+ varName += StrCat(index);
varName += "_";
return varName;
}
-TProtoStringType GetBitFieldNameForBit(int bitIndex) {
+TProtoStringType GetBitFieldNameForBit(int bitIndex) {
return GetBitFieldName(bitIndex / 32);
}
namespace {
-TProtoStringType GenerateGetBitInternal(const TProtoStringType& prefix, int bitIndex) {
- TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
+TProtoStringType GenerateGetBitInternal(const TProtoStringType& prefix, int bitIndex) {
+ TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
int bitInVarIndex = bitIndex % 32;
- TProtoStringType mask = bit_masks[bitInVarIndex];
- TProtoStringType result = "((" + varName + " & " + mask + ") != 0)";
+ TProtoStringType mask = bit_masks[bitInVarIndex];
+ TProtoStringType result = "((" + varName + " & " + mask + ") != 0)";
return result;
}
-TProtoStringType GenerateSetBitInternal(const TProtoStringType& prefix, int bitIndex) {
- TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
+TProtoStringType GenerateSetBitInternal(const TProtoStringType& prefix, int bitIndex) {
+ TProtoStringType varName = prefix + GetBitFieldNameForBit(bitIndex);
int bitInVarIndex = bitIndex % 32;
- TProtoStringType mask = bit_masks[bitInVarIndex];
- TProtoStringType result = varName + " |= " + mask;
+ TProtoStringType mask = bit_masks[bitInVarIndex];
+ TProtoStringType result = varName + " |= " + mask;
return result;
}
} // namespace
-TProtoStringType GenerateGetBit(int bitIndex) {
+TProtoStringType GenerateGetBit(int bitIndex) {
return GenerateGetBitInternal("", bitIndex);
}
-TProtoStringType GenerateSetBit(int bitIndex) {
+TProtoStringType GenerateSetBit(int bitIndex) {
return GenerateSetBitInternal("", bitIndex);
}
-TProtoStringType GenerateClearBit(int bitIndex) {
- TProtoStringType varName = GetBitFieldNameForBit(bitIndex);
+TProtoStringType GenerateClearBit(int bitIndex) {
+ TProtoStringType varName = GetBitFieldNameForBit(bitIndex);
int bitInVarIndex = bitIndex % 32;
- TProtoStringType mask = bit_masks[bitInVarIndex];
- TProtoStringType result = varName + " = (" + varName + " & ~" + mask + ")";
+ TProtoStringType mask = bit_masks[bitInVarIndex];
+ TProtoStringType result = varName + " = (" + varName + " & ~" + mask + ")";
return result;
}
-TProtoStringType GenerateGetBitFromLocal(int bitIndex) {
+TProtoStringType GenerateGetBitFromLocal(int bitIndex) {
return GenerateGetBitInternal("from_", bitIndex);
}
-TProtoStringType GenerateSetBitToLocal(int bitIndex) {
+TProtoStringType GenerateSetBitToLocal(int bitIndex) {
return GenerateSetBitInternal("to_", bitIndex);
}
-TProtoStringType GenerateGetBitMutableLocal(int bitIndex) {
+TProtoStringType GenerateGetBitMutableLocal(int bitIndex) {
return GenerateGetBitInternal("mutable_", bitIndex);
}
-TProtoStringType GenerateSetBitMutableLocal(int bitIndex) {
+TProtoStringType GenerateSetBitMutableLocal(int bitIndex) {
return GenerateSetBitInternal("mutable_", bitIndex);
}
bool IsReferenceType(JavaType type) {
switch (type) {
- case JAVATYPE_INT:
- return false;
- case JAVATYPE_LONG:
- return false;
- case JAVATYPE_FLOAT:
- return false;
- case JAVATYPE_DOUBLE:
- return false;
- case JAVATYPE_BOOLEAN:
- return false;
- case JAVATYPE_STRING:
- return true;
- case JAVATYPE_BYTES:
- return true;
- case JAVATYPE_ENUM:
- return true;
- case JAVATYPE_MESSAGE:
- return true;
-
- // No default because we want the compiler to complain if any new
- // JavaTypes are added.
+ case JAVATYPE_INT:
+ return false;
+ case JAVATYPE_LONG:
+ return false;
+ case JAVATYPE_FLOAT:
+ return false;
+ case JAVATYPE_DOUBLE:
+ return false;
+ case JAVATYPE_BOOLEAN:
+ return false;
+ case JAVATYPE_STRING:
+ return true;
+ case JAVATYPE_BYTES:
+ return true;
+ case JAVATYPE_ENUM:
+ 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.";
@@ -794,46 +794,46 @@ bool IsReferenceType(JavaType type) {
const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
switch (GetType(field)) {
- case FieldDescriptor::TYPE_INT32:
- return "Int32";
- case FieldDescriptor::TYPE_UINT32:
- return "UInt32";
- case FieldDescriptor::TYPE_SINT32:
- return "SInt32";
- case FieldDescriptor::TYPE_FIXED32:
- return "Fixed32";
- case FieldDescriptor::TYPE_SFIXED32:
- return "SFixed32";
- case FieldDescriptor::TYPE_INT64:
- return "Int64";
- case FieldDescriptor::TYPE_UINT64:
- return "UInt64";
- case FieldDescriptor::TYPE_SINT64:
- return "SInt64";
- case FieldDescriptor::TYPE_FIXED64:
- return "Fixed64";
- case FieldDescriptor::TYPE_SFIXED64:
- return "SFixed64";
- case FieldDescriptor::TYPE_FLOAT:
- return "Float";
- case FieldDescriptor::TYPE_DOUBLE:
- return "Double";
- case FieldDescriptor::TYPE_BOOL:
- return "Bool";
- case FieldDescriptor::TYPE_STRING:
- return "String";
- case FieldDescriptor::TYPE_BYTES: {
+ case FieldDescriptor::TYPE_INT32:
+ return "Int32";
+ case FieldDescriptor::TYPE_UINT32:
+ return "UInt32";
+ case FieldDescriptor::TYPE_SINT32:
+ return "SInt32";
+ case FieldDescriptor::TYPE_FIXED32:
+ return "Fixed32";
+ case FieldDescriptor::TYPE_SFIXED32:
+ return "SFixed32";
+ case FieldDescriptor::TYPE_INT64:
+ return "Int64";
+ case FieldDescriptor::TYPE_UINT64:
+ return "UInt64";
+ case FieldDescriptor::TYPE_SINT64:
+ return "SInt64";
+ case FieldDescriptor::TYPE_FIXED64:
+ return "Fixed64";
+ case FieldDescriptor::TYPE_SFIXED64:
+ return "SFixed64";
+ case FieldDescriptor::TYPE_FLOAT:
+ return "Float";
+ case FieldDescriptor::TYPE_DOUBLE:
+ return "Double";
+ case FieldDescriptor::TYPE_BOOL:
+ return "Bool";
+ case FieldDescriptor::TYPE_STRING:
+ return "String";
+ case FieldDescriptor::TYPE_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.
+ 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.";
@@ -844,47 +844,47 @@ const char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {
// returns -1.
int FixedSize(FieldDescriptor::Type type) {
switch (type) {
- case FieldDescriptor::TYPE_INT32:
- return -1;
- case FieldDescriptor::TYPE_INT64:
- return -1;
- case FieldDescriptor::TYPE_UINT32:
- return -1;
- case FieldDescriptor::TYPE_UINT64:
- return -1;
- case FieldDescriptor::TYPE_SINT32:
- return -1;
- case FieldDescriptor::TYPE_SINT64:
- return -1;
- case FieldDescriptor::TYPE_FIXED32:
- return WireFormatLite::kFixed32Size;
- case FieldDescriptor::TYPE_FIXED64:
- return WireFormatLite::kFixed64Size;
- case FieldDescriptor::TYPE_SFIXED32:
- return WireFormatLite::kSFixed32Size;
- case FieldDescriptor::TYPE_SFIXED64:
- return WireFormatLite::kSFixed64Size;
- case FieldDescriptor::TYPE_FLOAT:
- 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:
- return -1;
- case FieldDescriptor::TYPE_GROUP:
- return -1;
- case FieldDescriptor::TYPE_MESSAGE:
- return -1;
-
- // No default because we want the compiler to complain if any new
- // types are added.
+ case FieldDescriptor::TYPE_INT32:
+ return -1;
+ case FieldDescriptor::TYPE_INT64:
+ return -1;
+ case FieldDescriptor::TYPE_UINT32:
+ return -1;
+ case FieldDescriptor::TYPE_UINT64:
+ return -1;
+ case FieldDescriptor::TYPE_SINT32:
+ return -1;
+ case FieldDescriptor::TYPE_SINT64:
+ return -1;
+ case FieldDescriptor::TYPE_FIXED32:
+ return WireFormatLite::kFixed32Size;
+ case FieldDescriptor::TYPE_FIXED64:
+ return WireFormatLite::kFixed64Size;
+ case FieldDescriptor::TYPE_SFIXED32:
+ return WireFormatLite::kSFixed32Size;
+ case FieldDescriptor::TYPE_SFIXED64:
+ return WireFormatLite::kSFixed64Size;
+ case FieldDescriptor::TYPE_FLOAT:
+ 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:
+ return -1;
+ case FieldDescriptor::TYPE_GROUP:
+ 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;
@@ -894,7 +894,7 @@ int FixedSize(FieldDescriptor::Type type) {
// 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()];
+ new const FieldDescriptor*[descriptor->field_count()];
for (int i = 0; i < descriptor->field_count(); i++) {
fields[i] = descriptor->field(i);
}
@@ -908,8 +908,8 @@ const FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {
//
// 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) {
+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.
@@ -944,7 +944,7 @@ bool HasRequiredFields(const Descriptor* type,
}
bool HasRequiredFields(const Descriptor* type) {
- std::unordered_set<const Descriptor*> already_seen;
+ std::unordered_set<const Descriptor*> already_seen;
return HasRequiredFields(type, &already_seen);
}
@@ -958,142 +958,142 @@ bool HasRepeatedFields(const Descriptor* descriptor) {
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
-// with the same numeric value.
-//
-// If the value is larger than 0xD7FF, we encode its lowest 13 bits into a
-// character in the range [0xE000, 0xFFFF] by combining these 13 bits with
-// 0xE000 using logic-or. Then we shift the value to the right by 13 bits, and
-// encode the remaining value by repeating this same process until we get to
-// a value in [0x0000, 0xD7FF] where we will encode it using a character with
-// the same numeric value.
-//
-// Note that we only use code points in [0x0000, 0xD7FF] and [0xE000, 0xFFFF].
-// There will be no surrogate pairs in the encoded character sequence.
-void WriteUInt32ToUtf16CharSequence(uint32_t number,
- std::vector<uint16_t>* output) {
- // For values in [0x0000, 0xD7FF], only use one char to encode it.
- if (number < 0xD800) {
- output->push_back(static_cast<uint16_t>(number));
- return;
- }
- // Encode into multiple chars. All except the last char will be in the range
- // [0xE000, 0xFFFF], and the last char will be in the range [0x0000, 0xD7FF].
- // Note that we don't use any value in range [0xD800, 0xDFFF] because they
- // have to come in pairs and the encoding is just more space-efficient w/o
- // them.
- while (number >= 0xD800) {
- // [0xE000, 0xFFFF] can represent 13 bits of info.
- output->push_back(static_cast<uint16_t>(0xE000 | (number & 0x1FFF)));
- number >>= 13;
- }
- output->push_back(static_cast<uint16_t>(number));
-}
-
-int GetExperimentalJavaFieldTypeForSingular(const FieldDescriptor* field) {
- // j/c/g/protobuf/FieldType.java lists field types in a slightly different
- // order from FieldDescriptor::Type so we can't do a simple cast.
- //
- // TODO(xiaofeng): Make j/c/g/protobuf/FieldType.java follow the same order.
- int result = field->type();
- if (result == FieldDescriptor::TYPE_GROUP) {
- return 17;
- } else if (result < FieldDescriptor::TYPE_GROUP) {
- return result - 1;
- } else {
- return result - 2;
- }
-}
-
-int GetExperimentalJavaFieldTypeForRepeated(const FieldDescriptor* field) {
- if (field->type() == FieldDescriptor::TYPE_GROUP) {
- return 49;
- } else {
- return GetExperimentalJavaFieldTypeForSingular(field) + 18;
- }
-}
-
-int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor* field) {
- int result = field->type();
- if (result < FieldDescriptor::TYPE_STRING) {
- return result + 34;
- } else if (result > FieldDescriptor::TYPE_BYTES) {
- return result + 30;
- } else {
- GOOGLE_LOG(FATAL) << field->full_name() << " can't be packed.";
- return 0;
- }
-}
-
-int GetExperimentalJavaFieldType(const FieldDescriptor* field) {
- static const int kMapFieldType = 50;
- static const int kOneofFieldTypeOffset = 51;
- static const int kRequiredBit = 0x100;
- static const int kUtf8CheckBit = 0x200;
- static const int kCheckInitialized = 0x400;
- static const int kMapWithProto2EnumValue = 0x800;
- static const int kHasHasBit = 0x1000;
- int extra_bits = field->is_required() ? kRequiredBit : 0;
- if (field->type() == FieldDescriptor::TYPE_STRING && CheckUtf8(field)) {
- extra_bits |= kUtf8CheckBit;
- }
- if (field->is_required() || (GetJavaType(field) == JAVATYPE_MESSAGE &&
- HasRequiredFields(field->message_type()))) {
- extra_bits |= kCheckInitialized;
- }
- if (HasHasbit(field)) {
- extra_bits |= kHasHasBit;
- }
-
- if (field->is_map()) {
- if (!SupportUnknownEnumValue(field)) {
- const FieldDescriptor* value =
- field->message_type()->FindFieldByName("value");
- if (GetJavaType(value) == JAVATYPE_ENUM) {
- extra_bits |= kMapWithProto2EnumValue;
- }
- }
- return kMapFieldType | extra_bits;
- } else if (field->is_packed()) {
- return GetExperimentalJavaFieldTypeForPacked(field);
- } else if (field->is_repeated()) {
- return GetExperimentalJavaFieldTypeForRepeated(field) | extra_bits;
- } else if (IsRealOneof(field)) {
- return (GetExperimentalJavaFieldTypeForSingular(field) +
- kOneofFieldTypeOffset) |
- extra_bits;
- } else {
- return GetExperimentalJavaFieldTypeForSingular(field) | extra_bits;
- }
-}
-
-// Escape a UTF-16 character to be embedded in a Java string.
-void EscapeUtf16ToString(uint16_t code, TProtoStringType* output) {
- if (code == '\t') {
- output->append("\\t");
- } else if (code == '\b') {
- output->append("\\b");
- } else if (code == '\n') {
- output->append("\\n");
- } else if (code == '\r') {
- output->append("\\r");
- } else if (code == '\f') {
- output->append("\\f");
- } else if (code == '\'') {
- output->append("\\'");
- } else if (code == '\"') {
- output->append("\\\"");
- } else if (code == '\\') {
- output->append("\\\\");
- } else if (code >= 0x20 && code <= 0x7f) {
- output->push_back(static_cast<char>(code));
- } else {
- output->append(StringPrintf("\\u%04x", code));
- }
-}
-
+// 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
+// with the same numeric value.
+//
+// If the value is larger than 0xD7FF, we encode its lowest 13 bits into a
+// character in the range [0xE000, 0xFFFF] by combining these 13 bits with
+// 0xE000 using logic-or. Then we shift the value to the right by 13 bits, and
+// encode the remaining value by repeating this same process until we get to
+// a value in [0x0000, 0xD7FF] where we will encode it using a character with
+// the same numeric value.
+//
+// Note that we only use code points in [0x0000, 0xD7FF] and [0xE000, 0xFFFF].
+// There will be no surrogate pairs in the encoded character sequence.
+void WriteUInt32ToUtf16CharSequence(uint32_t number,
+ std::vector<uint16_t>* output) {
+ // For values in [0x0000, 0xD7FF], only use one char to encode it.
+ if (number < 0xD800) {
+ output->push_back(static_cast<uint16_t>(number));
+ return;
+ }
+ // Encode into multiple chars. All except the last char will be in the range
+ // [0xE000, 0xFFFF], and the last char will be in the range [0x0000, 0xD7FF].
+ // Note that we don't use any value in range [0xD800, 0xDFFF] because they
+ // have to come in pairs and the encoding is just more space-efficient w/o
+ // them.
+ while (number >= 0xD800) {
+ // [0xE000, 0xFFFF] can represent 13 bits of info.
+ output->push_back(static_cast<uint16_t>(0xE000 | (number & 0x1FFF)));
+ number >>= 13;
+ }
+ output->push_back(static_cast<uint16_t>(number));
+}
+
+int GetExperimentalJavaFieldTypeForSingular(const FieldDescriptor* field) {
+ // j/c/g/protobuf/FieldType.java lists field types in a slightly different
+ // order from FieldDescriptor::Type so we can't do a simple cast.
+ //
+ // TODO(xiaofeng): Make j/c/g/protobuf/FieldType.java follow the same order.
+ int result = field->type();
+ if (result == FieldDescriptor::TYPE_GROUP) {
+ return 17;
+ } else if (result < FieldDescriptor::TYPE_GROUP) {
+ return result - 1;
+ } else {
+ return result - 2;
+ }
+}
+
+int GetExperimentalJavaFieldTypeForRepeated(const FieldDescriptor* field) {
+ if (field->type() == FieldDescriptor::TYPE_GROUP) {
+ return 49;
+ } else {
+ return GetExperimentalJavaFieldTypeForSingular(field) + 18;
+ }
+}
+
+int GetExperimentalJavaFieldTypeForPacked(const FieldDescriptor* field) {
+ int result = field->type();
+ if (result < FieldDescriptor::TYPE_STRING) {
+ return result + 34;
+ } else if (result > FieldDescriptor::TYPE_BYTES) {
+ return result + 30;
+ } else {
+ GOOGLE_LOG(FATAL) << field->full_name() << " can't be packed.";
+ return 0;
+ }
+}
+
+int GetExperimentalJavaFieldType(const FieldDescriptor* field) {
+ static const int kMapFieldType = 50;
+ static const int kOneofFieldTypeOffset = 51;
+ static const int kRequiredBit = 0x100;
+ static const int kUtf8CheckBit = 0x200;
+ static const int kCheckInitialized = 0x400;
+ static const int kMapWithProto2EnumValue = 0x800;
+ static const int kHasHasBit = 0x1000;
+ int extra_bits = field->is_required() ? kRequiredBit : 0;
+ if (field->type() == FieldDescriptor::TYPE_STRING && CheckUtf8(field)) {
+ extra_bits |= kUtf8CheckBit;
+ }
+ if (field->is_required() || (GetJavaType(field) == JAVATYPE_MESSAGE &&
+ HasRequiredFields(field->message_type()))) {
+ extra_bits |= kCheckInitialized;
+ }
+ if (HasHasbit(field)) {
+ extra_bits |= kHasHasBit;
+ }
+
+ if (field->is_map()) {
+ if (!SupportUnknownEnumValue(field)) {
+ const FieldDescriptor* value =
+ field->message_type()->FindFieldByName("value");
+ if (GetJavaType(value) == JAVATYPE_ENUM) {
+ extra_bits |= kMapWithProto2EnumValue;
+ }
+ }
+ return kMapFieldType | extra_bits;
+ } else if (field->is_packed()) {
+ return GetExperimentalJavaFieldTypeForPacked(field);
+ } else if (field->is_repeated()) {
+ return GetExperimentalJavaFieldTypeForRepeated(field) | extra_bits;
+ } else if (IsRealOneof(field)) {
+ return (GetExperimentalJavaFieldTypeForSingular(field) +
+ kOneofFieldTypeOffset) |
+ extra_bits;
+ } else {
+ return GetExperimentalJavaFieldTypeForSingular(field) | extra_bits;
+ }
+}
+
+// Escape a UTF-16 character to be embedded in a Java string.
+void EscapeUtf16ToString(uint16_t code, TProtoStringType* output) {
+ if (code == '\t') {
+ output->append("\\t");
+ } else if (code == '\b') {
+ output->append("\\b");
+ } else if (code == '\n') {
+ output->append("\\n");
+ } else if (code == '\r') {
+ output->append("\\r");
+ } else if (code == '\f') {
+ output->append("\\f");
+ } else if (code == '\'') {
+ output->append("\\'");
+ } else if (code == '\"') {
+ output->append("\\\"");
+ } else if (code == '\\') {
+ output->append("\\\\");
+ } else if (code >= 0x20 && code <= 0x7f) {
+ output->push_back(static_cast<char>(code));
+ } else {
+ output->append(StringPrintf("\\u%04x", code));
+ }
+}
+
} // namespace java
} // namespace compiler
} // namespace protobuf
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 695ab77b43..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
@@ -35,13 +35,13 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
-#include <cstdint>
-#include <string>
-
-#include <google/protobuf/compiler/java/java_context.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/descriptor.h>
+#include <cstdint>
+#include <string>
+
+#include <google/protobuf/compiler/java/java_context.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/descriptor.h>
namespace google {
namespace protobuf {
@@ -53,8 +53,8 @@ namespace java {
extern const char kThickSeparator[];
extern const char kThinSeparator[];
-bool IsForbiddenKotlin(const TProtoStringType& field_name);
-
+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
@@ -64,102 +64,102 @@ bool IsForbiddenKotlin(const TProtoStringType& field_name);
// 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,
- const FieldDescriptor* descriptor,
- const std::map<TProtoStringType, TProtoStringType>& variables,
- const char* var_name,
- const char* terminating_string, bool enforce_lite);
-
+ 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,
+ const FieldDescriptor* descriptor,
+ const std::map<TProtoStringType, TProtoStringType>& variables,
+ 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.
+TProtoStringType ToCamelCase(const TProtoStringType& input, bool lower_first);
+
+char ToUpperCh(char ch);
+char ToLowerCh(char ch);
+
// 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);
-char ToLowerCh(char ch);
-
-// Converts a name to camel-case. If cap_first_letter is true, capitalize the
-// first letter.
-TProtoStringType UnderscoresToCamelCase(const TProtoStringType& name,
- bool cap_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.
-TProtoStringType UnderscoresToCamelCase(const FieldDescriptor* field);
-TProtoStringType UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);
+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.)
-TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method);
+TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method);
-// Same as UnderscoresToCamelCase, but checks for reserved keywords
-TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field);
-
-// Similar to UnderscoresToCamelCase, but guarantees that the result is a
+// Same as UnderscoresToCamelCase, but checks for reserved keywords
+TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field);
+
+// Similar to UnderscoresToCamelCase, but guarantees that the result is a
// complete Java identifier by adding a _ if needed.
-TProtoStringType CamelCaseFieldName(const FieldDescriptor* field);
+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.
-TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor);
+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.
-TProtoStringType FileClassName(const FileDescriptor* file, bool immutable = true);
+TProtoStringType FileClassName(const FileDescriptor* file, bool immutable = true);
// Returns the file's Java package name.
-TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable);
+TProtoStringType FileJavaPackage(const FileDescriptor* file, bool immutable);
// Returns output directory for the given package name.
-TProtoStringType JavaPackageToDir(TProtoStringType 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.
-TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor);
+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.
-TProtoStringType ExtraMutableMessageInterfaces(const Descriptor* descriptor);
+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.
-TProtoStringType ExtraBuilderInterfaces(const Descriptor* descriptor);
+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.
-TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor);
+TProtoStringType ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor);
// Get the unqualified Java class name for mutable messages. i.e. without
// package or outer classnames.
-inline TProtoStringType ShortMutableJavaClassName(const Descriptor* descriptor) {
+inline TProtoStringType ShortMutableJavaClassName(const Descriptor* descriptor) {
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.
-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 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.
+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.
-inline bool MultipleJavaFiles(const FileDescriptor* descriptor,
- bool immutable) {
- (void) immutable;
+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>
@@ -178,26 +178,26 @@ inline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) {
// 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) {
+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,
- const TProtoStringType& suffix = "") {
- if (IsOwnFile(descriptor, immutable)) {
+ const TProtoStringType& suffix = "") {
+ if (IsOwnFile(descriptor, immutable)) {
PrintGeneratedAnnotation(printer, '$',
- context->options().annotate_code
- ? AnnotationFileName(descriptor, suffix)
- : "");
+ context->options().annotate_code
+ ? AnnotationFileName(descriptor, suffix)
+ : "");
}
}
// Get the unqualified name that should be used for a field's field
// number constant.
-TProtoStringType FieldConstantName(const FieldDescriptor* field);
+TProtoStringType FieldConstantName(const FieldDescriptor* field);
// Returns the type of the FieldDescriptor.
// This does nothing interesting for the open source release, but is used for
@@ -225,41 +225,41 @@ const char* PrimitiveTypeName(JavaType type);
// 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);
-
+// 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;
-TProtoStringType DefaultValue(const FieldDescriptor* field, bool immutable,
- ClassNameResolver* name_resolver);
-inline TProtoStringType ImmutableDefaultValue(const FieldDescriptor* field,
- ClassNameResolver* name_resolver) {
+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?
-inline bool HasDescriptorMethods(const Descriptor* /* descriptor */,
+inline bool HasDescriptorMethods(const Descriptor* /* descriptor */,
bool enforce_lite) {
- return !enforce_lite;
+ return !enforce_lite;
}
-inline bool HasDescriptorMethods(const EnumDescriptor* /* descriptor */,
+inline bool HasDescriptorMethods(const EnumDescriptor* /* descriptor */,
bool enforce_lite) {
- return !enforce_lite;
+ return !enforce_lite;
}
-inline bool HasDescriptorMethods(const FileDescriptor* /* descriptor */,
+inline bool HasDescriptorMethods(const FileDescriptor* /* descriptor */,
bool enforce_lite) {
- return !enforce_lite;
+ return !enforce_lite;
}
// Should we generate generic services for this file?
-inline bool HasGenericServices(const FileDescriptor* file, bool enforce_lite) {
+inline bool HasGenericServices(const FileDescriptor* file, bool enforce_lite) {
return file->service_count() > 0 &&
HasDescriptorMethods(file, enforce_lite) &&
file->options().java_generic_services();
@@ -268,50 +268,50 @@ inline bool HasGenericServices(const FileDescriptor* file, bool enforce_lite) {
// Methods for shared bitfields.
// Gets the name of the shared bitfield for the given index.
-TProtoStringType GetBitFieldName(int index);
+TProtoStringType GetBitFieldName(int index);
// Gets the name of the shared bitfield for the given bit index.
// Effectively, GetBitFieldName(bitIndex / 32)
-TProtoStringType GetBitFieldNameForBit(int bitIndex);
+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)"
-TProtoStringType GenerateGetBit(int bitIndex);
+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)"
-TProtoStringType GenerateSetBit(int bitIndex);
+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)"
-TProtoStringType GenerateClearBit(int bitIndex);
+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)"
-TProtoStringType GenerateGetBitFromLocal(int bitIndex);
+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)"
-TProtoStringType GenerateSetBitToLocal(int bitIndex);
+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)"
-TProtoStringType GenerateGetBitMutableLocal(int bitIndex);
+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)"
-TProtoStringType GenerateSetBitMutableLocal(int bitIndex);
+TProtoStringType GenerateSetBitMutableLocal(int bitIndex);
// Returns whether the JavaType is a reference type.
bool IsReferenceType(JavaType type);
@@ -357,30 +357,30 @@ inline bool HasPackedFields(const Descriptor* descriptor) {
// 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 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();
+}
+
+inline bool HasHazzer(const FieldDescriptor* descriptor) {
+ return !descriptor->is_repeated() &&
+ (descriptor->message_type() || descriptor->has_optional_keyword() ||
+ IsProto2(descriptor->file()) || IsRealOneof(descriptor));
+}
+
+inline bool HasHasbit(const FieldDescriptor* descriptor) {
+ // Note that currently message fields inside oneofs have hasbits. This is
+ // surprising, as the oneof case should avoid any need for a hasbit. But if
+ // you change this method to remove hasbits for oneofs, a few tests fail.
+ // TODO(b/124347790): remove hasbits for oneofs
+ return !descriptor->is_repeated() &&
+ (descriptor->has_optional_keyword() || IsProto2(descriptor->file()));
}
-inline bool IsRealOneof(const FieldDescriptor* descriptor) {
- return descriptor->containing_oneof() &&
- !descriptor->containing_oneof()->is_synthetic();
-}
-
-inline bool HasHazzer(const FieldDescriptor* descriptor) {
- return !descriptor->is_repeated() &&
- (descriptor->message_type() || descriptor->has_optional_keyword() ||
- IsProto2(descriptor->file()) || IsRealOneof(descriptor));
-}
-
-inline bool HasHasbit(const FieldDescriptor* descriptor) {
- // Note that currently message fields inside oneofs have hasbits. This is
- // surprising, as the oneof case should avoid any need for a hasbit. But if
- // you change this method to remove hasbits for oneofs, a few tests fail.
- // TODO(b/124347790): remove hasbits for oneofs
- return !descriptor->is_repeated() &&
- (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.
@@ -394,11 +394,11 @@ 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.
+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) {
@@ -413,47 +413,47 @@ 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 IsWrappersProtoFile(const FileDescriptor* descriptor) {
+ return descriptor->name() == "google/protobuf/wrappers.proto";
+}
+
inline bool CheckUtf8(const FieldDescriptor* descriptor) {
return descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ||
- descriptor->file()->options().java_string_check_utf8();
+ descriptor->file()->options().java_string_check_utf8();
}
-inline TProtoStringType GeneratedCodeVersionSuffix() {
+inline TProtoStringType GeneratedCodeVersionSuffix() {
return "V3";
}
-
-void WriteUInt32ToUtf16CharSequence(uint32_t number,
- std::vector<uint16_t>* output);
-
-inline void WriteIntToUtf16CharSequence(int value,
- std::vector<uint16_t>* output) {
- WriteUInt32ToUtf16CharSequence(static_cast<uint32_t>(value), output);
-}
-
-// Escape a UTF-16 character so it can be embedded in a Java string literal.
-void EscapeUtf16ToString(uint16_t code, TProtoStringType* output);
-
-// Only the lowest two bytes of the return value are used. The lowest byte
-// is the integer value of a j/c/g/protobuf/FieldType enum. For the other
-// byte:
-// bit 0: whether the field is required.
-// bit 1: whether the field requires UTF-8 validation.
-// bit 2: whether the field needs isInitialized check.
-// bit 3: whether the field is a map field with proto2 enum value.
-// bits 4-7: unused
-int GetExperimentalJavaFieldType(const FieldDescriptor* field);
-
-// To get the total number of entries need to be built for experimental runtime
-// and the first field number that are not in the table part
-std::pair<int, int> GetTableDrivenNumberOfEntriesAndLookUpStartFieldNumber(
- const FieldDescriptor** fields, int count);
+
+void WriteUInt32ToUtf16CharSequence(uint32_t number,
+ std::vector<uint16_t>* output);
+
+inline void WriteIntToUtf16CharSequence(int value,
+ std::vector<uint16_t>* output) {
+ WriteUInt32ToUtf16CharSequence(static_cast<uint32_t>(value), output);
+}
+
+// Escape a UTF-16 character so it can be embedded in a Java string literal.
+void EscapeUtf16ToString(uint16_t code, TProtoStringType* output);
+
+// Only the lowest two bytes of the return value are used. The lowest byte
+// is the integer value of a j/c/g/protobuf/FieldType enum. For the other
+// byte:
+// bit 0: whether the field is required.
+// bit 1: whether the field requires UTF-8 validation.
+// bit 2: whether the field needs isInitialized check.
+// bit 3: whether the field is a map field with proto2 enum value.
+// bits 4-7: unused
+int GetExperimentalJavaFieldType(const FieldDescriptor* field);
+
+// To get the total number of entries need to be built for experimental runtime
+// 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 google
+} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc
index bff90eebed..9a18926275 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.cc
@@ -1,162 +1,162 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (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_kotlin_generator.h>
-
-#include <google/protobuf/compiler/java/java_file.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_options.h>
-#include <google/protobuf/compiler/java/java_generator.h>
-#include <google/protobuf/compiler/code_generator.h>
-
-namespace google {
-namespace protobuf {
-namespace compiler {
-namespace java {
-
-KotlinGenerator::KotlinGenerator() {}
-KotlinGenerator::~KotlinGenerator() {}
-
-uint64_t KotlinGenerator::GetSupportedFeatures() const {
- return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
-}
-
-bool KotlinGenerator::Generate(const FileDescriptor* file,
- const TProtoStringType& parameter,
- GeneratorContext* context,
- TProtoStringType* error) const {
- // -----------------------------------------------------------------
- // parse generator options
-
- std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
- ParseGeneratorParameter(parameter, &options);
- Options file_options;
-
- for (auto& option : options) {
- if (option.first == "output_list_file") {
- file_options.output_list_file = option.second;
- } else if (option.first == "immutable") {
- file_options.generate_immutable_code = true;
- } else if (option.first == "mutable") {
- *error = "Mutable not supported by Kotlin generator";
- return false;
- } else if (option.first == "shared") {
- file_options.generate_shared_code = true;
- } else if (option.first == "lite") {
- file_options.enforce_lite = true;
- } else if (option.first == "annotate_code") {
- file_options.annotate_code = true;
- } else if (option.first == "annotation_list_file") {
- file_options.annotation_list_file = option.second;
- } else {
- *error = "Unknown generator option: " + option.first;
- return false;
- }
- }
-
- // By default we generate immutable code and shared code for immutable API.
- if (!file_options.generate_immutable_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::unique_ptr<FileGenerator> file_generator;
- if (file_options.generate_immutable_code) {
- file_generator.reset(
- new FileGenerator(file, file_options, /* immutable_api = */ true));
- }
-
- if (!file_generator->Validate(error)) {
- return false;
- }
-
- auto open_file = [context](const TProtoStringType& filename) {
- return std::unique_ptr<io::ZeroCopyOutputStream>(context->Open(filename));
- };
- TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
- TProtoStringType kotlin_filename = package_dir;
- kotlin_filename += file_generator->GetKotlinClassname();
- kotlin_filename += ".kt";
- all_files.push_back(kotlin_filename);
- TProtoStringType info_full_path = kotlin_filename + ".pb.meta";
- if (file_options.annotate_code) {
- all_annotations.push_back(info_full_path);
- }
-
- // Generate main kotlin file.
- auto output = open_file(kotlin_filename);
- GeneratedCodeInfo annotations;
- io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
- &annotations);
- io::Printer printer(
- output.get(), '$',
- file_options.annotate_code ? &annotation_collector : nullptr);
-
- file_generator->GenerateKotlinSiblings(package_dir, context, &all_files,
- &all_annotations);
-
- if (file_options.annotate_code) {
- auto info_output = open_file(info_full_path);
- annotations.SerializeToZeroCopyStream(info_output.get());
- }
-
- // 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 .kt files being generated.
- auto srclist_raw_output = open_file(file_options.output_list_file);
- io::Printer srclist_printer(srclist_raw_output.get(), '$');
- for (auto& all_file : all_files) {
- srclist_printer.Print("$filename$\n", "filename", all_file);
- }
- }
-
- 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 .kt files being generated.
- auto annotation_list_raw_output =
- open_file(file_options.annotation_list_file);
- io::Printer annotation_list_printer(annotation_list_raw_output.get(), '$');
- for (auto& all_annotation : all_annotations) {
- annotation_list_printer.Print("$filename$\n", "filename", all_annotation);
- }
- }
-
- return true;
-}
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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_kotlin_generator.h>
+
+#include <google/protobuf/compiler/java/java_file.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/compiler/java/java_generator.h>
+#include <google/protobuf/compiler/code_generator.h>
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+namespace java {
+
+KotlinGenerator::KotlinGenerator() {}
+KotlinGenerator::~KotlinGenerator() {}
+
+uint64_t KotlinGenerator::GetSupportedFeatures() const {
+ return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
+}
+
+bool KotlinGenerator::Generate(const FileDescriptor* file,
+ const TProtoStringType& parameter,
+ GeneratorContext* context,
+ TProtoStringType* error) const {
+ // -----------------------------------------------------------------
+ // parse generator options
+
+ std::vector<std::pair<TProtoStringType, TProtoStringType> > options;
+ ParseGeneratorParameter(parameter, &options);
+ Options file_options;
+
+ for (auto& option : options) {
+ if (option.first == "output_list_file") {
+ file_options.output_list_file = option.second;
+ } else if (option.first == "immutable") {
+ file_options.generate_immutable_code = true;
+ } else if (option.first == "mutable") {
+ *error = "Mutable not supported by Kotlin generator";
+ return false;
+ } else if (option.first == "shared") {
+ file_options.generate_shared_code = true;
+ } else if (option.first == "lite") {
+ file_options.enforce_lite = true;
+ } else if (option.first == "annotate_code") {
+ file_options.annotate_code = true;
+ } else if (option.first == "annotation_list_file") {
+ file_options.annotation_list_file = option.second;
+ } else {
+ *error = "Unknown generator option: " + option.first;
+ return false;
+ }
+ }
+
+ // By default we generate immutable code and shared code for immutable API.
+ if (!file_options.generate_immutable_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::unique_ptr<FileGenerator> file_generator;
+ if (file_options.generate_immutable_code) {
+ file_generator.reset(
+ new FileGenerator(file, file_options, /* immutable_api = */ true));
+ }
+
+ if (!file_generator->Validate(error)) {
+ return false;
+ }
+
+ auto open_file = [context](const TProtoStringType& filename) {
+ return std::unique_ptr<io::ZeroCopyOutputStream>(context->Open(filename));
+ };
+ TProtoStringType package_dir = JavaPackageToDir(file_generator->java_package());
+ TProtoStringType kotlin_filename = package_dir;
+ kotlin_filename += file_generator->GetKotlinClassname();
+ kotlin_filename += ".kt";
+ all_files.push_back(kotlin_filename);
+ TProtoStringType info_full_path = kotlin_filename + ".pb.meta";
+ if (file_options.annotate_code) {
+ all_annotations.push_back(info_full_path);
+ }
+
+ // Generate main kotlin file.
+ auto output = open_file(kotlin_filename);
+ GeneratedCodeInfo annotations;
+ io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
+ &annotations);
+ io::Printer printer(
+ output.get(), '$',
+ file_options.annotate_code ? &annotation_collector : nullptr);
+
+ file_generator->GenerateKotlinSiblings(package_dir, context, &all_files,
+ &all_annotations);
+
+ if (file_options.annotate_code) {
+ auto info_output = open_file(info_full_path);
+ annotations.SerializeToZeroCopyStream(info_output.get());
+ }
+
+ // 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 .kt files being generated.
+ auto srclist_raw_output = open_file(file_options.output_list_file);
+ io::Printer srclist_printer(srclist_raw_output.get(), '$');
+ for (auto& all_file : all_files) {
+ srclist_printer.Print("$filename$\n", "filename", all_file);
+ }
+ }
+
+ 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 .kt files being generated.
+ auto annotation_list_raw_output =
+ open_file(file_options.annotation_list_file);
+ io::Printer annotation_list_printer(annotation_list_raw_output.get(), '$');
+ for (auto& all_annotation : all_annotations) {
+ annotation_list_printer.Print("$filename$\n", "filename", all_annotation);
+ }
+ }
+
+ return true;
+}
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
index 8fac6a4add..6e0fa8c276 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_kotlin_generator.h
@@ -1,72 +1,72 @@
-// Protocol Buffers - Google's data interchange format
-// Copyright 2008 Google Inc. All rights reserved.
-// https://developers.google.com/protocol-buffers/
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Generates Kotlin code for a given .proto file.
-
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_H__
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_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 Kotlin code. If you create your
-// own protocol compiler binary and you want it to support Kotlin output, you
-// can do so by registering an instance of this CodeGenerator with the
-// CommandLineInterface in your main() function.
-class PROTOC_EXPORT KotlinGenerator : public CodeGenerator {
- public:
- KotlinGenerator();
- ~KotlinGenerator() override;
-
- // 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(KotlinGenerator);
-};
-
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-#include <google/protobuf/port_undef.inc>
-
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_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.
+
+// Generates Kotlin code for a given .proto file.
+
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_H__
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_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 Kotlin code. If you create your
+// own protocol compiler binary and you want it to support Kotlin output, you
+// can do so by registering an instance of this CodeGenerator with the
+// CommandLineInterface in your main() function.
+class PROTOC_EXPORT KotlinGenerator : public CodeGenerator {
+ public:
+ KotlinGenerator();
+ ~KotlinGenerator() override;
+
+ // 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(KotlinGenerator);
+};
+
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_KOTLIN_GENERATOR_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 36a763f177..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
@@ -28,13 +28,13 @@
// (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_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>
+#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 {
@@ -57,8 +57,8 @@ const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
return message->FindFieldByName("value");
}
-TProtoStringType TypeName(const FieldDescriptor* field,
- ClassNameResolver* name_resolver, bool boxed) {
+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) {
@@ -69,26 +69,26 @@ TProtoStringType TypeName(const FieldDescriptor* field,
}
}
-TProtoStringType KotlinTypeName(const FieldDescriptor* field,
- ClassNameResolver* name_resolver) {
- 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 KotlinTypeName(GetJavaType(field));
- }
-}
-
-TProtoStringType WireType(const FieldDescriptor* field) {
+TProtoStringType KotlinTypeName(const FieldDescriptor* field,
+ ClassNameResolver* name_resolver) {
+ 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 KotlinTypeName(GetJavaType(field));
+ }
+}
+
+TProtoStringType WireType(const FieldDescriptor* field) {
return "com.google.protobuf.WireFormat.FieldType." +
- TProtoStringType(FieldTypeName(field->type()));
+ TProtoStringType(FieldTypeName(field->type()));
}
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
+void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, const FieldGeneratorInfo* info,
Context* context,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
@@ -100,23 +100,23 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
const JavaType valueJavaType = GetJavaType(value);
(*variables)["key_type"] = TypeName(key, name_resolver, false);
- TProtoStringType boxed_key_type = TypeName(key, name_resolver, true);
+ TProtoStringType boxed_key_type = TypeName(key, name_resolver, true);
(*variables)["boxed_key_type"] = boxed_key_type;
- (*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver);
- (*variables)["kt_value_type"] = KotlinTypeName(value, name_resolver);
+ (*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver);
+ (*variables)["kt_value_type"] = KotlinTypeName(value, name_resolver);
// 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_null_check"] =
- IsReferenceType(keyJavaType)
- ? "if (key == null) { throw new java.lang.NullPointerException(); }"
- : "";
- (*variables)["value_null_check"] =
- IsReferenceType(valueJavaType)
- ? "if (value == null) { throw new java.lang.NullPointerException(); }"
- : "";
+ (*variables)["key_null_check"] =
+ IsReferenceType(keyJavaType)
+ ? "if (key == null) { throw new java.lang.NullPointerException(); }"
+ : "";
+ (*variables)["value_null_check"] =
+ IsReferenceType(valueJavaType)
+ ? "if (value == null) { throw new java.lang.NullPointerException(); }"
+ : "";
if (valueJavaType == JAVATYPE_ENUM) {
// We store enums as Integers internally.
(*variables)["value_type"] = "int";
@@ -147,13 +147,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*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"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@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
@@ -163,51 +163,51 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["set_mutable_bit_parser"] =
GenerateSetBitMutableLocal(builderBitIndex);
- (*variables)["default_entry"] =
- (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
+ (*variables)["default_entry"] =
+ (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
(*variables)["map_field_parameter"] = (*variables)["default_entry"];
(*variables)["descriptor"] =
- name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" +
- UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, ";
+ name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" +
+ UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, ";
(*variables)["ver"] = GeneratedCodeVersionSuffix();
}
} // namespace
-ImmutableMapFieldGenerator::ImmutableMapFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ImmutableMapFieldGenerator::ImmutableMapFieldGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
+ Context* context)
+ : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
- context->GetFieldGeneratorInfo(descriptor), context,
- &variables_);
+ context->GetFieldGeneratorInfo(descriptor), context,
+ &variables_);
}
-ImmutableMapFieldGenerator::~ImmutableMapFieldGenerator() {}
+ImmutableMapFieldGenerator::~ImmutableMapFieldGenerator() {}
-int ImmutableMapFieldGenerator::GetNumBitsForMessage() const { return 0; }
+int ImmutableMapFieldGenerator::GetNumBitsForMessage() const { return 0; }
-int ImmutableMapFieldGenerator::GetNumBitsForBuilder() const { return 1; }
+int ImmutableMapFieldGenerator::GetNumBitsForBuilder() const { return 1; }
-void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
+void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
+ printer->Print(variables_,
+ "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$boolean ${$contains$capitalized_name$$}$(\n"
- " $key_type$ key);\n");
+ printer->Print(variables_,
+ "$deprecation$boolean ${$contains$capitalized_name$$}$(\n"
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$();\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
@@ -239,55 +239,55 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers(
"${$get$capitalized_name$Value$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$ValueMap$}$();\n");
+ printer->Print(variables_,
+ "$deprecation$java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$ValueMap$}$();\n");
printer->Annotate("{", "}", 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->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_);
- printer->Print(variables_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
- " $key_type$ key);\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$$}$();\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$Map$}$();\n");
+ printer->Print(variables_,
+ "$deprecation$java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", 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->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_);
- printer->Print(variables_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key);\n");
+ 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 {
+void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
printer->Print(
variables_,
"private static final class $capitalized_name$DefaultEntryHolder {\n"
@@ -301,17 +301,17 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
" $value_wire_type$,\n"
" $value_default_value$);\n"
"}\n");
- printer->Print(variables_,
- "private com.google.protobuf.MapField<\n"
- " $type_parameters$> $name$_;\n"
- "private com.google.protobuf.MapField<$type_parameters$>\n"
- "internalGet$capitalized_name$() {\n"
- " if ($name$_ == null) {\n"
- " return com.google.protobuf.MapField.emptyMapField(\n"
- " $map_field_parameter$);\n"
- " }\n"
- " return $name$_;\n"
- "}\n");
+ printer->Print(variables_,
+ "private com.google.protobuf.MapField<\n"
+ " $type_parameters$> $name$_;\n"
+ "private com.google.protobuf.MapField<$type_parameters$>\n"
+ "internalGet$capitalized_name$() {\n"
+ " if ($name$_ == null) {\n"
+ " return com.google.protobuf.MapField.emptyMapField(\n"
+ " $map_field_parameter$);\n"
+ " }\n"
+ " return $name$_;\n"
+ "}\n");
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
variables_,
@@ -335,50 +335,50 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const {
GenerateMapGetters(printer);
}
-void ImmutableMapFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- printer->Print(variables_,
- "private com.google.protobuf.MapField<\n"
- " $type_parameters$> $name$_;\n"
- "private com.google.protobuf.MapField<$type_parameters$>\n"
- "internalGet$capitalized_name$() {\n"
- " if ($name$_ == null) {\n"
- " return com.google.protobuf.MapField.emptyMapField(\n"
- " $map_field_parameter$);\n"
- " }\n"
- " return $name$_;\n"
- "}\n"
- "private com.google.protobuf.MapField<$type_parameters$>\n"
- "internalGetMutable$capitalized_name$() {\n"
- " $on_changed$;\n"
- " if ($name$_ == null) {\n"
- " $name$_ = com.google.protobuf.MapField.newMapField(\n"
- " $map_field_parameter$);\n"
- " }\n"
- " if (!$name$_.isMutable()) {\n"
- " $name$_ = $name$_.copy();\n"
- " }\n"
- " return $name$_;\n"
- "}\n");
+void ImmutableMapFieldGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_,
+ "private com.google.protobuf.MapField<\n"
+ " $type_parameters$> $name$_;\n"
+ "private com.google.protobuf.MapField<$type_parameters$>\n"
+ "internalGet$capitalized_name$() {\n"
+ " if ($name$_ == null) {\n"
+ " return com.google.protobuf.MapField.emptyMapField(\n"
+ " $map_field_parameter$);\n"
+ " }\n"
+ " return $name$_;\n"
+ "}\n"
+ "private com.google.protobuf.MapField<$type_parameters$>\n"
+ "internalGetMutable$capitalized_name$() {\n"
+ " $on_changed$;\n"
+ " if ($name$_ == null) {\n"
+ " $name$_ = com.google.protobuf.MapField.newMapField(\n"
+ " $map_field_parameter$);\n"
+ " }\n"
+ " if (!$name$_.isMutable()) {\n"
+ " $name$_ = $name$_.copy();\n"
+ " }\n"
+ " return $name$_;\n"
+ "}\n");
GenerateMapGetters(printer);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$clear$capitalized_name$$}$() {\n"
- " internalGetMutable$capitalized_name$().getMutableMap()\n"
- " .clear();\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder ${$clear$capitalized_name$$}$() {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .clear();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$remove$capitalized_name$$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " internalGetMutable$capitalized_name$().getMutableMap()\n"
- " .remove(key);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder ${$remove$capitalized_name$$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .remove(key);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
@@ -464,44 +464,44 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
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"
- " internalGetMutable$capitalized_name$().getMutableMap()\n"
- " .put(key, value);\n"
- " return this;\n"
- "}\n");
+ 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"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$putAll$capitalized_name$$}$(\n"
- " java.util.Map<$type_parameters$> values) {\n"
- " internalGetMutable$capitalized_name$().getMutableMap()\n"
- " .putAll(values);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder ${$putAll$capitalized_name$$}$(\n"
+ " java.util.Map<$type_parameters$> values) {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .putAll(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
}
-void ImmutableMapFieldGenerator::GenerateMapGetters(
- io::Printer* printer) const {
- printer->Print(variables_,
- "$deprecation$\n"
- "public int ${$get$capitalized_name$Count$}$() {\n"
- " return internalGet$capitalized_name$().getMap().size();\n"
- "}\n");
+void ImmutableMapFieldGenerator::GenerateMapGetters(
+ io::Printer* printer) const {
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public int ${$get$capitalized_name$Count$}$() {\n"
+ " return internalGet$capitalized_name$().getMap().size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
"$deprecation$\n"
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"public boolean ${$contains$capitalized_name$$}$(\n"
" $key_type$ key) {\n"
" $key_null_check$\n"
@@ -509,31 +509,31 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
"}\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$Map$}$() {\n"
- " return internalGetAdapted$capitalized_name$Map(\n"
- " internalGet$capitalized_name$().getMap());"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$Map$}$() {\n"
+ " return internalGetAdapted$capitalized_name$Map(\n"
+ " internalGet$capitalized_name$().getMap());"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
@@ -549,7 +549,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
" $key_type$ key) {\n"
@@ -568,7 +568,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
"/**\n"
" * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
" */\n"
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"@java.lang.Deprecated\n"
"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$Value$}$() {\n"
@@ -578,7 +578,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$ValueMap$}$() {\n"
@@ -588,7 +588,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
@@ -602,7 +602,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
" $key_type$ key) {\n"
@@ -617,30 +617,30 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$Map$}$() {\n"
- " return internalGet$capitalized_name$().getMap();\n"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$Map$}$() {\n"
+ " return internalGet$capitalized_name$().getMap();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
@@ -652,142 +652,142 @@ void ImmutableMapFieldGenerator::GenerateMapGetters(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> 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->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> 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_);
}
}
-void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " @JvmName(\"get$kt_capitalized_name$Map\")\n"
- " get() = com.google.protobuf.kotlin.DslMap(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
- " )\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@JvmName(\"put$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
- " $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"set$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
- " put(key, value)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"remove$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .remove(key: $kt_key_type$) {\n"
- " $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
- "{\n"
- " $kt_dsl_builder$.${$putAll$capitalized_name$$}$(map)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- " }\n");
-}
-
-void ImmutableMapFieldGenerator::GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const {
+void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " @JvmName(\"get$kt_capitalized_name$Map\")\n"
+ " get() = com.google.protobuf.kotlin.DslMap(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
+ " )\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@JvmName(\"put$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
+ " $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"set$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
+ " put(key, value)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"remove$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .remove(key: $kt_key_type$) {\n"
+ " $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"putAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
+ "{\n"
+ " $kt_dsl_builder$.${$putAll$capitalized_name$$}$(map)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ " }\n");
+}
+
+void ImmutableMapFieldGenerator::GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const {
// Nothing to initialize.
}
-void ImmutableMapFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutableMapFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
// Nothing to initialize.
}
-void ImmutableMapFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
- printer->Print(variables_,
- "internalGetMutable$capitalized_name$().clear();\n");
+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::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::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_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = com.google.protobuf.MapField.newMapField(\n"
- " $map_field_parameter$);\n"
- " $set_mutable_bit_parser$;\n"
- "}\n");
+void ImmutableMapFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
+ printer->Print(variables_,
+ "if (!$get_mutable_bit_parser$) {\n"
+ " $name$_ = com.google.protobuf.MapField.newMapField(\n"
+ " $map_field_parameter$);\n"
+ " $set_mutable_bit_parser$;\n"
+ "}\n");
if (!SupportUnknownEnumValue(descriptor_->file()) &&
GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
@@ -814,24 +814,24 @@ void ImmutableMapFieldGenerator::GenerateParsingCode(
}
}
-void ImmutableMapFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void ImmutableMapFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
// Nothing to do here.
}
-void ImmutableMapFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
- printer->Print(variables_,
- "com.google.protobuf.GeneratedMessage$ver$\n"
- " .serialize$short_key_type$MapTo(\n"
- " output,\n"
- " internalGet$capitalized_name$(),\n"
- " $default_entry$,\n"
- " $number$);\n");
+void ImmutableMapFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
+ printer->Print(variables_,
+ "com.google.protobuf.GeneratedMessage$ver$\n"
+ " .serialize$short_key_type$MapTo(\n"
+ " output,\n"
+ " internalGet$capitalized_name$(),\n"
+ " $default_entry$,\n"
+ " $number$);\n");
}
-void ImmutableMapFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void ImmutableMapFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(
variables_,
"for (java.util.Map.Entry<$type_parameters$> entry\n"
@@ -846,14 +846,14 @@ void ImmutableMapFieldGenerator::GenerateSerializedSizeCode(
"}\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::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 {
+void ImmutableMapFieldGenerator::GenerateHashCode(io::Printer* printer) const {
printer->Print(
variables_,
"if (!internalGet$capitalized_name$().getMap().isEmpty()) {\n"
@@ -862,7 +862,7 @@ void ImmutableMapFieldGenerator::GenerateHashCode(io::Printer* printer) const {
"}\n");
}
-TProtoStringType ImmutableMapFieldGenerator::GetBoxedType() const {
+TProtoStringType ImmutableMapFieldGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->message_type());
}
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 bda0e35f00..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
@@ -31,7 +31,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__
-#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
@@ -40,36 +40,36 @@ namespace java {
class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
public:
- explicit ImmutableMapFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- Context* context);
- ~ImmutableMapFieldGenerator() override;
+ explicit ImmutableMapFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex, int builderBitIndex,
+ Context* context);
+ ~ImmutableMapFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
- int GetNumBitsForMessage() const override;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- void GenerateEqualsCode(io::Printer* printer) const override;
- void GenerateHashCode(io::Printer* printer) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ void GenerateEqualsCode(io::Printer* printer) const override;
+ void GenerateHashCode(io::Printer* printer) const override;
+ void GenerateKotlinDslMembers(io::Printer* printer) const override;
- TProtoStringType GetBoxedType() const;
+ TProtoStringType GetBoxedType() const;
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
void GenerateMapGetters(io::Printer* printer) const;
};
@@ -77,6 +77,6 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 878a1b5403..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
@@ -28,15 +28,15 @@
// (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 <google/protobuf/compiler/java/java_map_field_lite.h>
-#include <cstdint>
-
-#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 <cstdint>
+
+#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 {
@@ -59,8 +59,8 @@ const FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {
return message->FindFieldByName("value");
}
-TProtoStringType TypeName(const FieldDescriptor* field,
- ClassNameResolver* name_resolver, bool boxed) {
+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) {
@@ -71,26 +71,26 @@ TProtoStringType TypeName(const FieldDescriptor* field,
}
}
-TProtoStringType KotlinTypeName(const FieldDescriptor* field,
- ClassNameResolver* name_resolver) {
- 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 KotlinTypeName(GetJavaType(field));
- }
-}
-
-TProtoStringType WireType(const FieldDescriptor* field) {
+TProtoStringType KotlinTypeName(const FieldDescriptor* field,
+ ClassNameResolver* name_resolver) {
+ 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 KotlinTypeName(GetJavaType(field));
+ }
+}
+
+TProtoStringType WireType(const FieldDescriptor* field) {
return "com.google.protobuf.WireFormat.FieldType." +
- TProtoStringType(FieldTypeName(field->type()));
+ TProtoStringType(FieldTypeName(field->type()));
}
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
+void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, const FieldGeneratorInfo* info,
Context* context,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
@@ -103,20 +103,20 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*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)["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);
- // We use `x.getClass()` as a null check because it generates less bytecode
- // than an `if (x == null) { throw ... }` statement.
- (*variables)["key_null_check"] =
- IsReferenceType(keyJavaType)
- ? "java.lang.Class<?> keyClass = key.getClass();"
- : "";
- (*variables)["value_null_check"] =
- IsReferenceType(valueJavaType)
- ? "java.lang.Class<?> valueClass = value.getClass();"
- : "";
+ // We use `x.getClass()` as a null check because it generates less bytecode
+ // than an `if (x == null) { throw ... }` statement.
+ (*variables)["key_null_check"] =
+ IsReferenceType(keyJavaType)
+ ? "java.lang.Class<?> keyClass = key.getClass();"
+ : "";
+ (*variables)["value_null_check"] =
+ IsReferenceType(valueJavaType)
+ ? "java.lang.Class<?> valueClass = value.getClass();"
+ : "";
if (GetJavaType(value) == JAVATYPE_ENUM) {
// We store enums as Integers internally.
@@ -148,53 +148,53 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*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"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
-
- (*variables)["default_entry"] =
- (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
+
+ (*variables)["default_entry"] =
+ (*variables)["capitalized_name"] + "DefaultEntryHolder.defaultEntry";
}
} // namespace
-ImmutableMapFieldLiteGenerator::ImmutableMapFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : descriptor_(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()) {
- SetMessageVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor), context,
- &variables_);
+ImmutableMapFieldLiteGenerator::ImmutableMapFieldLiteGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
+ : descriptor_(descriptor),
+ context_(context),
+ name_resolver_(context->GetNameResolver()) {
+ SetMessageVariables(descriptor, messageBitIndex, 0,
+ context->GetFieldGeneratorInfo(descriptor), context,
+ &variables_);
}
-ImmutableMapFieldLiteGenerator::~ImmutableMapFieldLiteGenerator() {}
+ImmutableMapFieldLiteGenerator::~ImmutableMapFieldLiteGenerator() {}
-int ImmutableMapFieldLiteGenerator::GetNumBitsForMessage() const { return 0; }
+int ImmutableMapFieldLiteGenerator::GetNumBitsForMessage() const { return 0; }
-void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
+void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
+ printer->Print(variables_,
+ "$deprecation$int ${$get$capitalized_name$Count$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$boolean ${$contains$capitalized_name$$}$(\n"
- " $key_type$ key);\n");
+ printer->Print(variables_,
+ "$deprecation$boolean ${$contains$capitalized_name$$}$(\n"
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$();\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
@@ -226,56 +226,56 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers(
"${$get$capitalized_name$Value$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$ValueMap$}$();\n");
+ printer->Print(variables_,
+ "$deprecation$java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$ValueMap$}$();\n");
printer->Annotate("{", "}", 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->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_);
- printer->Print(variables_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
- " $key_type$ key);\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
+ " $key_type$ key);\n");
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$$}$();\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$$}$();\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$java.util.Map<$type_parameters$>\n"
- "${$get$capitalized_name$Map$}$();\n");
+ printer->Print(variables_,
+ "$deprecation$java.util.Map<$type_parameters$>\n"
+ "${$get$capitalized_name$Map$}$();\n");
printer->Annotate("{", "}", 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->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_);
- printer->Print(variables_,
- "$deprecation$\n"
- "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key);\n");
+ 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 {
+void ImmutableMapFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
printer->Print(
variables_,
"private static final class $capitalized_name$DefaultEntryHolder {\n"
@@ -288,37 +288,37 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" $value_wire_type$,\n"
" $value_default_value$);\n"
"}\n");
- printer->Print(variables_,
- "private com.google.protobuf.MapFieldLite<\n"
- " $type_parameters$> $name$_ =\n"
- " com.google.protobuf.MapFieldLite.emptyMapField();\n"
- "private com.google.protobuf.MapFieldLite<$type_parameters$>\n"
- "internalGet$capitalized_name$() {\n"
- " return $name$_;\n"
- "}\n"
- "private com.google.protobuf.MapFieldLite<$type_parameters$>\n"
- "internalGetMutable$capitalized_name$() {\n"
- " if (!$name$_.isMutable()) {\n"
- " $name$_ = $name$_.mutableCopy();\n"
- " }\n"
- " return $name$_;\n"
- "}\n");
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public int ${$get$capitalized_name$Count$}$() {\n"
- " return internalGet$capitalized_name$().size();\n"
- "}\n");
+ printer->Print(variables_,
+ "private com.google.protobuf.MapFieldLite<\n"
+ " $type_parameters$> $name$_ =\n"
+ " com.google.protobuf.MapFieldLite.emptyMapField();\n"
+ "private com.google.protobuf.MapFieldLite<$type_parameters$>\n"
+ "internalGet$capitalized_name$() {\n"
+ " return $name$_;\n"
+ "}\n"
+ "private com.google.protobuf.MapFieldLite<$type_parameters$>\n"
+ "internalGetMutable$capitalized_name$() {\n"
+ " if (!$name$_.isMutable()) {\n"
+ " $name$_ = $name$_.mutableCopy();\n"
+ " }\n"
+ " return $name$_;\n"
+ "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public int ${$get$capitalized_name$Count$}$() {\n"
+ " return internalGet$capitalized_name$().size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public boolean ${$contains$capitalized_name$$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " return internalGet$capitalized_name$().containsKey(key);\n"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public boolean ${$contains$capitalized_name$$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " return internalGet$capitalized_name$().containsKey(key);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
@@ -329,20 +329,20 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
" 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"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"${$get$capitalized_name$Map$}$() {\n"
@@ -356,7 +356,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
@@ -372,7 +372,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
" $key_type$ key) {\n"
@@ -391,7 +391,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
"/**\n"
" * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
" */\n"
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"@java.lang.Deprecated\n"
"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$Value$}$() {\n"
@@ -401,7 +401,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$ValueMap$}$() {\n"
@@ -412,7 +412,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
@@ -426,7 +426,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
" $key_type$ key) {\n"
@@ -441,31 +441,31 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$Map$}$() {\n"
- " return java.util.Collections.unmodifiableMap(\n"
- " internalGet$capitalized_name$());\n"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$Map$}$() {\n"
+ " return java.util.Collections.unmodifiableMap(\n"
+ " internalGet$capitalized_name$());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
@@ -477,19 +477,19 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> 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->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> 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_);
}
@@ -516,44 +516,44 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers(
}
} 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");
+ 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);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- printer->Print(variables_,
- "\"$name$_\",\n"
- "$default_entry$,\n");
- if (!SupportUnknownEnumValue(descriptor_) &&
- GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- PrintEnumVerifierLogic(printer, ValueField(descriptor_), variables_,
- /*var_name=*/"$value_enum_type$",
- /*terminating_string=*/",\n",
- /*enforce_lite=*/context_->EnforceLite());
- }
-}
-
-void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public int ${$get$capitalized_name$Count$}$() {\n"
- " return instance.get$capitalized_name$Map().size();\n"
- "}\n");
+void ImmutableMapFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ printer->Print(variables_,
+ "\"$name$_\",\n"
+ "$default_entry$,\n");
+ if (!SupportUnknownEnumValue(descriptor_) &&
+ GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
+ PrintEnumVerifierLogic(printer, ValueField(descriptor_), variables_,
+ /*var_name=*/"$value_enum_type$",
+ /*terminating_string=*/",\n",
+ /*enforce_lite=*/context_->EnforceLite());
+ }
+}
+
+void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public int ${$get$capitalized_name$Count$}$() {\n"
+ " return instance.get$capitalized_name$Map().size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public boolean ${$contains$capitalized_name$$}$(\n"
" $key_type$ key) {\n"
@@ -561,50 +561,50 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
" return instance.get$capitalized_name$Map().containsKey(key);\n"
"}\n");
printer->Annotate("{", "}", descriptor_);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$Map().clear();\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$Map().clear();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$\n"
- "public Builder ${$remove$capitalized_name$$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " copyOnWrite();\n"
- " instance.getMutable$capitalized_name$Map().remove(key);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder ${$remove$capitalized_name$$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " copyOnWrite();\n"
+ " instance.getMutable$capitalized_name$Map().remove(key);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\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"
- " instance.get$capitalized_name$Map());\n"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\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"
+ " instance.get$capitalized_name$Map());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
@@ -620,7 +620,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n"
" $key_type$ key) {\n"
@@ -662,7 +662,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
"/**\n"
" * Use {@link #get$capitalized_name$ValueMap()} instead.\n"
" */\n"
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"@java.lang.Deprecated\n"
"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$Value$}$() {\n"
@@ -672,7 +672,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n"
"${$get$capitalized_name$ValueMap$}$() {\n"
@@ -683,7 +683,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n"
" $key_type$ key,\n"
@@ -697,7 +697,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n"
" $key_type$ key) {\n"
@@ -734,31 +734,31 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
printer->Annotate("{", "}", descriptor_);
}
} else {
- printer->Print(variables_,
- "/**\n"
- " * Use {@link #get$capitalized_name$Map()} instead.\n"
- " */\n"
- "@java.lang.Override\n"
- "@java.lang.Deprecated\n"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$$}$() {\n"
- " return get$capitalized_name$Map();\n"
- "}\n");
+ printer->Print(variables_,
+ "/**\n"
+ " * Use {@link #get$capitalized_name$Map()} instead.\n"
+ " */\n"
+ "@java.lang.Override\n"
+ "@java.lang.Deprecated\n"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$$}$() {\n"
+ " return get$capitalized_name$Map();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$"
- "public java.util.Map<$type_parameters$> "
- "${$get$capitalized_name$Map$}$() {\n"
- " return java.util.Collections.unmodifiableMap(\n"
- " instance.get$capitalized_name$Map());\n"
- "}\n");
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$"
+ "public java.util.Map<$type_parameters$> "
+ "${$get$capitalized_name$Map$}$() {\n"
+ " return java.util.Collections.unmodifiableMap(\n"
+ " instance.get$capitalized_name$Map());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"$deprecation$\n"
"public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n"
" $key_type$ key,\n"
@@ -770,19 +770,19 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
"}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$\n"
- "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " java.util.Map<$type_parameters$> 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->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$\n"
+ "public $value_type$ ${$get$capitalized_name$OrThrow$}$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " java.util.Map<$type_parameters$> 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(
@@ -812,93 +812,93 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers(
}
}
-void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " @JvmName(\"get$kt_capitalized_name$Map\")\n"
- " get() = com.google.protobuf.kotlin.DslMap(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
- " )\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@JvmName(\"put$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
- " $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"set$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
- " put(key, value)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"remove$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .remove(key: $kt_key_type$) {\n"
- " $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
- "{\n"
- " $kt_dsl_builder$.${$putAll$capitalized_name$$}$(map)\n"
- " }\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
- "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " .clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- " }\n");
-}
-
-void ImmutableMapFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " @JvmName(\"get$kt_capitalized_name$Map\")\n"
+ " get() = com.google.protobuf.kotlin.DslMap(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n"
+ " )\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@JvmName(\"put$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
+ " $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"set$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
+ " put(key, value)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"remove$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .remove(key: $kt_key_type$) {\n"
+ " $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"putAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
+ "{\n"
+ " $kt_dsl_builder$.${$putAll$capitalized_name$$}$(map)\n"
+ " }\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslMap"
+ "<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " .clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ " }\n");
+}
+
+void ImmutableMapFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
// Nothing to initialize.
}
-TProtoStringType ImmutableMapFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType ImmutableMapFieldLiteGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->message_type());
}
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 72126ade3f..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
@@ -31,9 +31,9 @@
#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>
+#include <cstdint>
+
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
@@ -42,33 +42,33 @@ namespace java {
class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
public:
- explicit ImmutableMapFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context);
- ~ImmutableMapFieldLiteGenerator() override;
+ explicit ImmutableMapFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context);
+ ~ImmutableMapFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
- int GetNumBitsForMessage() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const override;
+ void GenerateKotlinDslMembers(io::Printer* printer) const override;
- TProtoStringType GetBoxedType() const override;
+ TProtoStringType GetBoxedType() const override;
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
- Context* context_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
+ Context* context_;
ClassNameResolver* name_resolver_;
};
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 6418ba33b7..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
@@ -32,29 +32,29 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message.h>
+#include <google/protobuf/compiler/java/java_message.h>
#include <algorithm>
-#include <cstdint>
+#include <cstdint>
#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>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message_builder.h>
-#include <google/protobuf/compiler/java/java_message_builder_lite.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
+#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>
+#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/compiler/java/java_generator_factory.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_message_builder.h>
+#include <google/protobuf/compiler/java/java_message_builder_lite.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -65,8 +65,8 @@ using internal::WireFormat;
using internal::WireFormatLite;
namespace {
-TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
- ClassNameResolver* name_resolver) {
+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());
@@ -76,23 +76,23 @@ TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
// ===================================================================
MessageGenerator::MessageGenerator(const Descriptor* descriptor)
- : descriptor_(descriptor) {
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
- }
- }
-}
+ : descriptor_(descriptor) {
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (IsRealOneof(descriptor_->field(i))) {
+ oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ }
+ }
+}
MessageGenerator::~MessageGenerator() {}
// ===================================================================
ImmutableMessageGenerator::ImmutableMessageGenerator(
const Descriptor* descriptor, Context* context)
- : MessageGenerator(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()),
- field_generators_(descriptor, 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.";
@@ -109,12 +109,12 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
// the outermost class in the file. This way, they will be initialized in
// a deterministic order.
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- vars["index"] = StrCat(descriptor_->index());
+ vars["index"] = StrCat(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
if (descriptor_->containing_type() != NULL) {
- vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
+ 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
@@ -130,13 +130,13 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
}
// The descriptor for this type.
- printer->Print(
- vars,
- // TODO(teboring): final needs to be added back. The way to fix it is to
- // generate methods that can construct the types, and then still declare
- // 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");
+ printer->Print(
+ vars,
+ // TODO(teboring): final needs to be added back. The way to fix it is to
+ // generate methods that can construct the types, and then still declare
+ // 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.
@@ -153,25 +153,25 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
io::Printer* printer) {
int bytecode_estimate = 0;
- std::map<TProtoStringType, TProtoStringType> vars;
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
- vars["index"] = StrCat(descriptor_->index());
+ vars["index"] = StrCat(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
if (descriptor_->containing_type() != NULL) {
- vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
+ vars["parent"] = UniqueFileScopeIdentifier(descriptor_->containing_type());
}
// The descriptor for this type.
if (descriptor_->containing_type() == NULL) {
printer->Print(vars,
- "internal_$identifier$_descriptor =\n"
- " getDescriptor().getMessageTypes().get($index$);\n");
+ "internal_$identifier$_descriptor =\n"
+ " getDescriptor().getMessageTypes().get($index$);\n");
bytecode_estimate += 30;
} else {
- printer->Print(
- vars,
- "internal_$identifier$_descriptor =\n"
- " internal_$parent$_descriptor.getNestedTypes().get($index$);\n");
+ printer->Print(
+ vars,
+ "internal_$identifier$_descriptor =\n"
+ " internal_$parent$_descriptor.getNestedTypes().get($index$);\n");
bytecode_estimate += 30;
}
@@ -188,9 +188,9 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
return bytecode_estimate;
}
-void ImmutableMessageGenerator::GenerateFieldAccessorTable(
- io::Printer* printer, int* bytecode_estimate) {
- std::map<TProtoStringType, TProtoStringType> vars;
+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
@@ -205,48 +205,48 @@ void ImmutableMessageGenerator::GenerateFieldAccessorTable(
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.
- //
+ 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
- *bytecode_estimate +=
- 10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count();
+ *bytecode_estimate +=
+ 10 + 6 * descriptor_->field_count() + 6 * descriptor_->oneof_decl_count();
}
-int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
- io::Printer* printer) {
+int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
+ io::Printer* printer) {
int bytecode_estimate = 10;
printer->Print(
- "internal_$identifier$_fieldAccessorTable = new\n"
- " com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable(\n"
- " internal_$identifier$_descriptor,\n"
- " new java.lang.String[] { ",
- "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
- // All the bytecode_estimate calculation logic in this method must stay in
- // sync with the similar logic in the GenerateFieldAccessorTable method
- // above. See the corresponding comment in GenerateFieldAccessorTable for
- // details.
+ "internal_$identifier$_fieldAccessorTable = new\n"
+ " com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable(\n"
+ " internal_$identifier$_descriptor,\n"
+ " new java.lang.String[] { ",
+ "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
+ // All the bytecode_estimate calculation logic in this method must stay in
+ // 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;
- printer->Print("\"$field_name$\", ", "field_name", info->capitalized_name);
+ printer->Print("\"$field_name$\", ", "field_name", info->capitalized_name);
}
- // We reproduce synthetic oneofs here since proto reflection needs these.
+ // 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;
- printer->Print("\"$oneof_name$\", ", "oneof_name", info->capitalized_name);
+ printer->Print("\"$oneof_name$\", ", "oneof_name", info->capitalized_name);
}
printer->Print("});\n");
return bytecode_estimate;
@@ -263,38 +263,38 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
" $extra_interfaces$\n"
" com.google.protobuf.GeneratedMessage$ver$.\n"
" ExtendableMessageOrBuilder<$classname$> {\n",
- "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
+ "deprecation",
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
"extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
- "classname", descriptor_->name(), "{", "", "}", "", "ver",
- GeneratedCodeVersionSuffix());
+ "classname", descriptor_->name(), "{", "", "}", "", "ver",
+ GeneratedCodeVersionSuffix());
} else {
printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
" $extra_interfaces$\n"
" com.google.protobuf.MessageOrBuilder {\n",
- "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
+ "deprecation",
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
"extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
- "classname", descriptor_->name(), "{", "", "}", "");
+ "classname", descriptor_->name(), "{", "", "}", "");
}
printer->Annotate("{", "}", descriptor_);
printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("\n");
- field_generators_.get(descriptor_->field(i))
- .GenerateInterfaceMembers(printer);
- }
- for (auto oneof : oneofs_) {
- printer->Print(
- "\n"
- "public $classname$.$oneof_capitalized_name$Case "
- "get$oneof_capitalized_name$Case();\n",
- "oneof_capitalized_name",
- context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
- context_->GetNameResolver()->GetImmutableClassName(descriptor_));
- }
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("\n");
+ field_generators_.get(descriptor_->field(i))
+ .GenerateInterfaceMembers(printer);
+ }
+ for (auto oneof : oneofs_) {
+ printer->Print(
+ "\n"
+ "public $classname$.$oneof_capitalized_name$Case "
+ "get$oneof_capitalized_name$Case();\n",
+ "oneof_capitalized_name",
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
+ context_->GetNameResolver()->GetImmutableClassName(descriptor_));
+ }
printer->Outdent();
printer->Print("}\n");
@@ -305,20 +305,20 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
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 ";
+ std::map<TProtoStringType, TProtoStringType> variables;
+ variables["static"] = is_own_file ? "" : "static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
variables["ver"] = GeneratedCodeVersionSuffix();
- variables["deprecation"] =
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "";
+ 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.
- TProtoStringType builder_type;
+ TProtoStringType builder_type;
if (descriptor_->extension_range_count() > 0) {
printer->Print(
variables,
@@ -340,14 +340,14 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"$deprecation$public $static$final class $classname$ extends\n");
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());
+ " 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->Print("private static final long serialVersionUID = 0L;\n");
printer->Indent();
// Using builder_type, instead of Builder, prevents the Builder class from
@@ -355,34 +355,34 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
// 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());
+ "// 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(
- "}\n"
- "\n");
-
- printer->Print(variables,
- "@java.lang.Override\n"
- "@SuppressWarnings({\"unused\"})\n"
- "protected java.lang.Object newInstance(\n"
- " UnusedPrivateParameter unused) {\n"
- " return new $classname$();\n"
- "}\n"
- "\n");
-
- printer->Print(
- "@java.lang.Override\n"
- "public final com.google.protobuf.UnknownFieldSet\n"
- "getUnknownFields() {\n"
- " return this.unknownFields;\n"
- "}\n");
+ "}\n"
+ "\n");
+
+ printer->Print(variables,
+ "@java.lang.Override\n"
+ "@SuppressWarnings({\"unused\"})\n"
+ "protected java.lang.Object newInstance(\n"
+ " UnusedPrivateParameter unused) {\n"
+ " return new $classname$();\n"
+ "}\n"
+ "\n");
+
+ 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);
@@ -392,104 +392,104 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
// Nested types
for (int i = 0; i < descriptor_->enum_type_count(); i++) {
- EnumGenerator(descriptor_->enum_type(i), true, context_).Generate(printer);
+ 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;
- ImmutableMessageGenerator messageGenerator(descriptor_->nested_type(i),
- context_);
+ ImmutableMessageGenerator messageGenerator(descriptor_->nested_type(i),
+ context_);
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();
+ // 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));
}
- 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
- 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());
+ 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,
- "private int $oneof_name$Case_ = 0;\n"
- "private java.lang.Object $oneof_name$_;\n");
+ "private int $oneof_name$Case_ = 0;\n"
+ "private java.lang.Object $oneof_name$_;\n");
// OneofCase enum
- printer->Print(
- vars,
- "public enum $oneof_capitalized_name$Case\n"
- // TODO(dweis): Remove EnumLite when we want to break compatibility with
- // 3.x users
- " implements com.google.protobuf.Internal.EnumLite,\n"
- " com.google.protobuf.AbstractMessage.InternalOneOfEnum {\n");
+ printer->Print(
+ vars,
+ "public enum $oneof_capitalized_name$Case\n"
+ // TODO(dweis): Remove EnumLite when we want to break compatibility with
+ // 3.x users
+ " implements com.google.protobuf.Internal.EnumLite,\n"
+ " com.google.protobuf.AbstractMessage.InternalOneOfEnum {\n");
printer->Indent();
- for (int j = 0; j < (oneof)->field_count(); j++) {
- const FieldDescriptor* field = (oneof)->field(j);
+ for (int j = 0; j < (oneof)->field_count(); j++) {
+ const FieldDescriptor* field = (oneof)->field(j);
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()));
+ "$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,
- "private final int value;\n"
- "private $oneof_capitalized_name$Case(int value) {\n"
- " this.value = value;\n"
- "}\n");
+ printer->Print("$cap_oneof_name$_NOT_SET(0);\n", "cap_oneof_name",
+ ToUpper(vars["oneof_name"]));
+ printer->Print(vars,
+ "private final int value;\n"
+ "private $oneof_capitalized_name$Case(int value) {\n"
+ " this.value = value;\n"
+ "}\n");
printer->Print(
- vars,
- "/**\n"
- " * @param value The number of the enum to look for.\n"
- " * @return The enum associated with the given number.\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
- "public static $oneof_capitalized_name$Case forNumber(int value) {\n"
- " switch (value) {\n");
- for (int j = 0; j < (oneof)->field_count(); j++) {
- const FieldDescriptor* field = (oneof)->field(j);
- printer->Print(" case $field_number$: return $field_name$;\n",
- "field_number", StrCat(field->number()),
- "field_name", ToUpper(field->name()));
+ vars,
+ "/**\n"
+ " * @param value The number of the enum to look for.\n"
+ " * @return The enum associated with the given number.\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n"
+ "public static $oneof_capitalized_name$Case forNumber(int value) {\n"
+ " switch (value) {\n");
+ for (int j = 0; j < (oneof)->field_count(); j++) {
+ const FieldDescriptor* field = (oneof)->field(j);
+ printer->Print(" case $field_number$: return $field_name$;\n",
+ "field_number", StrCat(field->number()),
+ "field_name", ToUpper(field->name()));
}
printer->Print(
- " case 0: return $cap_oneof_name$_NOT_SET;\n"
- " default: return null;\n"
- " }\n"
- "}\n"
- "public int getNumber() {\n"
- " return this.value;\n"
- "}\n",
- "cap_oneof_name", ToUpper(vars["oneof_name"]));
+ " case 0: return $cap_oneof_name$_NOT_SET;\n"
+ " default: return null;\n"
+ " }\n"
+ "}\n"
+ "public int getNumber() {\n"
+ " return this.value;\n"
+ "}\n",
+ "cap_oneof_name", ToUpper(vars["oneof_name"]));
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");
+ "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_)) {
@@ -499,9 +499,9 @@ void ImmutableMessageGenerator::Generate(io::Printer* 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));
+ "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");
}
@@ -517,21 +517,21 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
GenerateBuilder(printer);
printer->Print(
- "\n"
- "// @@protoc_insertion_point(class_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\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.
- printer->Print("private static final $classname$ DEFAULT_INSTANCE;\n",
- "classname",
- name_resolver_->GetImmutableClassName(descriptor_));
+ printer->Print("private static final $classname$ DEFAULT_INSTANCE;\n",
+ "classname",
+ name_resolver_->GetImmutableClassName(descriptor_));
printer->Print(
- "static {\n"
- " DEFAULT_INSTANCE = new $classname$();\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "static {\n"
+ " DEFAULT_INSTANCE = new $classname$();\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Print(
"public static $classname$ getDefaultInstance() {\n"
@@ -540,26 +540,26 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- // 'of' method for Wrappers
- if (IsWrappersProtoFile(descriptor_->file())) {
- printer->Print(
- "public static $classname$ of($field_type$ value) {\n"
- " return newBuilder().setValue(value).build();\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0))));
- }
-
+ // 'of' method for Wrappers
+ if (IsWrappersProtoFile(descriptor_->file())) {
+ printer->Print(
+ "public static $classname$ of($field_type$ value) {\n"
+ " return newBuilder().setValue(value).build();\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0))));
+ }
+
GenerateParser(printer);
printer->Print(
- "@java.lang.Override\n"
- "public $classname$ getDefaultInstanceForType() {\n"
- " return DEFAULT_INSTANCE;\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "@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
@@ -575,55 +575,55 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
// ===================================================================
-void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
- io::Printer* printer) {
- std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
+void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
+ io::Printer* printer) {
+ std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
SortFieldsByNumber(descriptor_));
std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
- sorted_extensions.reserve(descriptor_->extension_range_count());
+ 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(
- "@java.lang.Override\n"
- "public void writeTo(com.google.protobuf.CodedOutputStream output)\n"
- " throws java.io.IOException {\n");
+ "@java.lang.Override\n"
+ "public void writeTo(com.google.protobuf.CodedOutputStream output)\n"
+ " throws java.io.IOException {\n");
printer->Indent();
-
+
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");
+ // 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(
- "com.google.protobuf.GeneratedMessage$ver$\n"
- " .ExtendableMessage<$classname$>.ExtensionWriter\n"
- " extensionWriter = newMessageSetExtensionWriter();\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "ver", GeneratedCodeVersionSuffix());
+ "com.google.protobuf.GeneratedMessage$ver$\n"
+ " .ExtendableMessage<$classname$>.ExtensionWriter\n"
+ " extensionWriter = newMessageSetExtensionWriter();\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "ver", GeneratedCodeVersionSuffix());
} else {
printer->Print(
- "com.google.protobuf.GeneratedMessage$ver$\n"
- " .ExtendableMessage<$classname$>.ExtensionWriter\n"
- " extensionWriter = newExtensionWriter();\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "ver", GeneratedCodeVersionSuffix());
+ "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;
- i < descriptor_->field_count() || j < sorted_extensions.size();) {
+ i < descriptor_->field_count() || j < sorted_extensions.size();) {
if (i == descriptor_->field_count()) {
GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);
} else if (j == sorted_extensions.size()) {
@@ -636,131 +636,131 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods(
}
if (descriptor_->options().message_set_wire_format()) {
- printer->Print("unknownFields.writeAsMessageSetTo(output);\n");
+ printer->Print("unknownFields.writeAsMessageSetTo(output);\n");
} else {
- printer->Print("unknownFields.writeTo(output);\n");
+ printer->Print("unknownFields.writeTo(output);\n");
}
printer->Outdent();
printer->Print(
- "}\n"
- "\n"
- "@java.lang.Override\n"
- "public int getSerializedSize() {\n"
- " int size = memoizedSize;\n"
- " if (size != -1) return size;\n"
- "\n");
+ "}\n"
+ "\n"
+ "@java.lang.Override\n"
+ "public int getSerializedSize() {\n"
+ " int size = memoizedSize;\n"
+ " if (size != -1) return size;\n"
+ "\n");
printer->Indent();
- printer->Print("size = 0;\n");
-
+ 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()) {
- printer->Print("size += extensionsSerializedSizeAsMessageSet();\n");
+ printer->Print("size += extensionsSerializedSizeAsMessageSet();\n");
} else {
- printer->Print("size += extensionsSerializedSize();\n");
+ printer->Print("size += extensionsSerializedSize();\n");
}
}
if (descriptor_->options().message_set_wire_format()) {
- printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n");
+ printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n");
} else {
- printer->Print("size += unknownFields.getSerializedSize();\n");
+ printer->Print("size += unknownFields.getSerializedSize();\n");
}
- printer->Print(
- "memoizedSize = size;\n"
- "return size;\n");
-
+ printer->Print(
+ "memoizedSize = size;\n"
+ "return size;\n");
+
printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
}
-void ImmutableMessageGenerator::GenerateParseFromMethods(io::Printer* printer) {
+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(
- "public static $classname$ parseFrom(\n"
- " java.nio.ByteBuffer data)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return PARSER.parseFrom(data);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " java.nio.ByteBuffer data,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return PARSER.parseFrom(data, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.ByteString data)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return PARSER.parseFrom(data);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.ByteString data,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return PARSER.parseFrom(data, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(byte[] data)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return PARSER.parseFrom(data);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " byte[] data,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return PARSER.parseFrom(data, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(java.io.InputStream input)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessage$ver$\n"
- " .parseWithIOException(PARSER, input);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " java.io.InputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessage$ver$\n"
- " .parseWithIOException(PARSER, input, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseDelimitedFrom(java.io.InputStream "
- "input)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessage$ver$\n"
- " .parseDelimitedWithIOException(PARSER, input);\n"
- "}\n"
- "public static $classname$ parseDelimitedFrom(\n"
- " java.io.InputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessage$ver$\n"
- " .parseDelimitedWithIOException(PARSER, input, "
- "extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.CodedInputStream input)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessage$ver$\n"
- " .parseWithIOException(PARSER, input);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessage$ver$\n"
- " .parseWithIOException(PARSER, input, extensionRegistry);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ "public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.ByteString data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.ByteString data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(byte[] data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " byte[] data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(java.io.InputStream input)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessage$ver$\n"
+ " .parseWithIOException(PARSER, input);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " java.io.InputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessage$ver$\n"
+ " .parseWithIOException(PARSER, input, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseDelimitedFrom(java.io.InputStream "
+ "input)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessage$ver$\n"
+ " .parseDelimitedWithIOException(PARSER, input);\n"
+ "}\n"
+ "public static $classname$ parseDelimitedFrom(\n"
+ " java.io.InputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessage$ver$\n"
+ " .parseDelimitedWithIOException(PARSER, input, "
+ "extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.CodedInputStream input)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessage$ver$\n"
+ " .parseWithIOException(PARSER, input);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.CodedInputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessage$ver$\n"
+ " .parseWithIOException(PARSER, input, extensionRegistry);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
}
void ImmutableMessageGenerator::GenerateSerializeOneField(
@@ -770,8 +770,8 @@ void ImmutableMessageGenerator::GenerateSerializeOneField(
void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(
io::Printer* printer, const Descriptor::ExtensionRange* range) {
- printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
- StrCat(range->end));
+ printer->Print("extensionWriter.writeUntil($end$, output);\n", "end",
+ StrCat(range->end));
}
// ===================================================================
@@ -779,48 +779,48 @@ void ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(
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(
- "public static Builder newBuilder() {\n"
- " return DEFAULT_INSTANCE.toBuilder();\n"
- "}\n"
- "public static Builder newBuilder($classname$ prototype) {\n"
- " return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder toBuilder() {\n"
- " return this == DEFAULT_INSTANCE\n"
- " ? new Builder() : new Builder().mergeFrom(this);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
-
- printer->Print(
- "@java.lang.Override\n"
- "protected Builder newBuilderForType(\n"
- " com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
- " Builder builder = new Builder(parent);\n"
- " return builder;\n"
- "}\n",
- "ver", GeneratedCodeVersionSuffix());
+ "@java.lang.Override\n"
+ "public Builder newBuilderForType() { return newBuilder(); }\n");
+
+ printer->Print(
+ "public static Builder newBuilder() {\n"
+ " return DEFAULT_INSTANCE.toBuilder();\n"
+ "}\n"
+ "public static Builder newBuilder($classname$ prototype) {\n"
+ " return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public Builder toBuilder() {\n"
+ " return this == DEFAULT_INSTANCE\n"
+ " ? new Builder() : new Builder().mergeFrom(this);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
+
+ printer->Print(
+ "@java.lang.Override\n"
+ "protected Builder newBuilderForType(\n"
+ " com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
+ " Builder builder = new Builder(parent);\n"
+ " return builder;\n"
+ "}\n",
+ "ver", GeneratedCodeVersionSuffix());
MessageBuilderGenerator builderGenerator(descriptor_, context_);
builderGenerator.Generate(printer);
}
-void ImmutableMessageGenerator::GenerateDescriptorMethods(
- io::Printer* printer) {
+void ImmutableMessageGenerator::GenerateDescriptorMethods(
+ io::Printer* printer) {
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"
- "}\n"
- "\n",
- "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "identifier", UniqueFileScopeIdentifier(descriptor_));
+ "public static final com.google.protobuf.Descriptors.Descriptor\n"
+ " getDescriptor() {\n"
+ " return $fileclass$.internal_$identifier$_descriptor;\n"
+ "}\n"
+ "\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++) {
@@ -832,21 +832,21 @@ void ImmutableMessageGenerator::GenerateDescriptorMethods(
}
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");
+ "@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(
- "case $number$:\n"
- " return internalGet$capitalized_name$();\n",
- "number", StrCat(field->number()), "capitalized_name",
- info->capitalized_name);
+ "case $number$:\n"
+ " return internalGet$capitalized_name$();\n",
+ "number", StrCat(field->number()), "capitalized_name",
+ info->capitalized_name);
}
printer->Print(
"default:\n"
@@ -859,38 +859,38 @@ void ImmutableMessageGenerator::GenerateDescriptorMethods(
"}\n");
}
printer->Print(
- "@java.lang.Override\n"
- "protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
- " internalGetFieldAccessorTable() {\n"
- " return $fileclass$.internal_$identifier$_fieldAccessorTable\n"
- " .ensureFieldAccessorsInitialized(\n"
- " $classname$.class, $classname$.Builder.class);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ "@java.lang.Override\n"
+ "protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
+ " internalGetFieldAccessorTable() {\n"
+ " return $fileclass$.internal_$identifier$_fieldAccessorTable\n"
+ " .ensureFieldAccessorsInitialized(\n"
+ " $classname$.class, $classname$.Builder.class);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
+ "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
}
// ===================================================================
-void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
+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.
- printer->Print("private byte memoizedIsInitialized = -1;\n");
+ printer->Print("private byte memoizedIsInitialized = -1;\n");
printer->Print(
- "@java.lang.Override\n"
- "public final boolean isInitialized() {\n");
+ "@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(
- "byte isInitialized = memoizedIsInitialized;\n"
- "if (isInitialized == 1) return true;\n"
- "if (isInitialized == 0) return false;\n"
- "\n");
+ "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
@@ -901,11 +901,11 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
if (field->is_required()) {
printer->Print(
- "if (!has$name$()) {\n"
- " memoizedIsInitialized = 0;\n"
- " return false;\n"
- "}\n",
- "name", info->capitalized_name);
+ "if (!has$name$()) {\n"
+ " memoizedIsInitialized = 0;\n"
+ " return false;\n"
+ "}\n",
+ "name", info->capitalized_name);
}
}
@@ -918,48 +918,48 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
switch (field->label()) {
case FieldDescriptor::LABEL_REQUIRED:
printer->Print(
- "if (!get$name$().isInitialized()) {\n"
- " memoizedIsInitialized = 0;\n"
- " return false;\n"
- "}\n",
- "type",
- name_resolver_->GetImmutableClassName(field->message_type()),
- "name", info->capitalized_name);
+ "if (!get$name$().isInitialized()) {\n"
+ " memoizedIsInitialized = 0;\n"
+ " return false;\n"
+ "}\n",
+ "type",
+ name_resolver_->GetImmutableClassName(field->message_type()),
+ "name", info->capitalized_name);
break;
case FieldDescriptor::LABEL_OPTIONAL:
printer->Print(
- "if (has$name$()) {\n"
- " if (!get$name$().isInitialized()) {\n"
+ "if (has$name$()) {\n"
+ " if (!get$name$().isInitialized()) {\n"
" memoizedIsInitialized = 0;\n"
" return false;\n"
" }\n"
"}\n",
"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"
- " memoizedIsInitialized = 0;\n"
- " return false;\n"
- " }\n"
- "}\n",
- "type",
- MapValueImmutableClassdName(field->message_type(),
- name_resolver_),
- "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"
+ " memoizedIsInitialized = 0;\n"
+ " return false;\n"
+ " }\n"
+ "}\n",
+ "type",
+ MapValueImmutableClassdName(field->message_type(),
+ name_resolver_),
+ "name", info->capitalized_name);
} else {
printer->Print(
- "for (int i = 0; i < get$name$Count(); i++) {\n"
- " if (!get$name$(i).isInitialized()) {\n"
- " memoizedIsInitialized = 0;\n"
- " return false;\n"
- " }\n"
- "}\n",
- "type",
- name_resolver_->GetImmutableClassName(field->message_type()),
- "name", info->capitalized_name);
+ "for (int i = 0; i < get$name$Count(); i++) {\n"
+ " if (!get$name$(i).isInitialized()) {\n"
+ " memoizedIsInitialized = 0;\n"
+ " return false;\n"
+ " }\n"
+ "}\n",
+ "type",
+ name_resolver_->GetImmutableClassName(field->message_type()),
+ "name", info->capitalized_name);
}
break;
}
@@ -968,20 +968,20 @@ void ImmutableMessageGenerator::GenerateIsInitialized(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
printer->Print(
- "if (!extensionsAreInitialized()) {\n"
- " memoizedIsInitialized = 0;\n"
- " return false;\n"
- "}\n");
+ "if (!extensionsAreInitialized()) {\n"
+ " memoizedIsInitialized = 0;\n"
+ " return false;\n"
+ "}\n");
}
printer->Outdent();
- printer->Print(" memoizedIsInitialized = 1;\n");
+ printer->Print(" memoizedIsInitialized = 1;\n");
printer->Print(
- " return true;\n"
- "}\n"
- "\n");
+ " return true;\n"
+ "}\n"
+ "\n");
}
// ===================================================================
@@ -991,73 +991,73 @@ bool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) {
if (field->is_repeated()) {
return false;
}
- if (HasHasbit(field)) {
+ if (HasHasbit(field)) {
return true;
}
- return GetJavaType(field) == JAVATYPE_MESSAGE && !IsRealOneof(field);
+ return GetJavaType(field) == JAVATYPE_MESSAGE && !IsRealOneof(field);
}
} // namespace
-void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
- io::Printer* printer) {
+void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
+ io::Printer* printer) {
printer->Print(
- "@java.lang.Override\n"
- "public boolean equals(");
- printer->Print("final java.lang.Object obj) {\n");
+ "@java.lang.Override\n"
+ "public boolean equals(");
+ printer->Print("final java.lang.Object obj) {\n");
printer->Indent();
printer->Print(
- "if (obj == this) {\n"
- " return true;\n"
- "}\n"
- "if (!(obj instanceof $classname$)) {\n"
- " return super.equals(obj);\n"
- "}\n"
- "$classname$ other = ($classname$) obj;\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "if (obj == this) {\n"
+ " return true;\n"
+ "}\n"
+ "if (!(obj instanceof $classname$)) {\n"
+ " return super.equals(obj);\n"
+ "}\n"
+ "$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);
- if (!IsRealOneof(field)) {
+ if (!IsRealOneof(field)) {
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);
+ "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->Print("}\n");
+ printer->Print("}\n");
}
}
}
// Compare oneofs.
- for (auto oneof : oneofs_) {
+ for (auto oneof : oneofs_) {
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);
+ "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();
- 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()));
+ 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(
- "case 0:\n"
- "default:\n");
+ "case 0:\n"
+ "default:\n");
printer->Outdent();
printer->Print("}\n");
}
@@ -1066,29 +1066,29 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
// 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 (!unknownFields.equals(other.unknownFields)) return false;\n");
if (descriptor_->extension_range_count() > 0) {
printer->Print(
- "if (!getExtensionFields().equals(other.getExtensionFields()))\n"
- " return false;\n");
+ "if (!getExtensionFields().equals(other.getExtensionFields()))\n"
+ " return false;\n");
}
- printer->Print("return true;\n");
+ printer->Print("return true;\n");
printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
printer->Print(
- "@java.lang.Override\n"
- "public int hashCode() {\n");
+ "@java.lang.Override\n"
+ "public int hashCode() {\n");
printer->Indent();
- printer->Print("if (memoizedHashCode != 0) {\n");
+ printer->Print("if (memoizedHashCode != 0) {\n");
printer->Indent();
- printer->Print("return memoizedHashCode;\n");
+ printer->Print("return memoizedHashCode;\n");
printer->Outdent();
printer->Print(
- "}\n"
- "int hash = 41;\n");
+ "}\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()) {
@@ -1100,11 +1100,11 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
// hashCode non-oneofs.
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
- if (!IsRealOneof(field)) {
+ if (!IsRealOneof(field)) {
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->Print("if (has$name$()) {\n", "name", info->capitalized_name);
printer->Indent();
}
field_generators_.get(field).GenerateHashCode(printer);
@@ -1116,59 +1116,59 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode(
}
// hashCode oneofs.
- for (auto oneof : oneofs_) {
- printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name",
- context_->GetOneofGeneratorInfo(oneof)->name);
+ for (auto oneof : oneofs_) {
+ printer->Print("switch ($oneof_name$Case_) {\n", "oneof_name",
+ context_->GetOneofGeneratorInfo(oneof)->name);
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()));
+ 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(
- "case 0:\n"
- "default:\n");
+ "case 0:\n"
+ "default:\n");
printer->Outdent();
printer->Print("}\n");
}
if (descriptor_->extension_range_count() > 0) {
- printer->Print("hash = hashFields(hash, getExtensionFields());\n");
+ printer->Print("hash = hashFields(hash, getExtensionFields());\n");
}
- printer->Print("hash = (29 * hash) + unknownFields.hashCode();\n");
+ printer->Print("hash = (29 * hash) + unknownFields.hashCode();\n");
printer->Print(
- "memoizedHashCode = hash;\n"
- "return hash;\n");
+ "memoizedHashCode = hash;\n"
+ "return hash;\n");
printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
}
// ===================================================================
-void ImmutableMessageGenerator::GenerateExtensionRegistrationCode(
- io::Printer* printer) {
+void ImmutableMessageGenerator::GenerateExtensionRegistrationCode(
+ io::Printer* printer) {
for (int i = 0; i < descriptor_->extension_count(); i++) {
ImmutableExtensionGenerator(descriptor_->extension(i), context_)
- .GenerateRegistrationCode(printer);
+ .GenerateRegistrationCode(printer);
}
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
- .GenerateExtensionRegistrationCode(printer);
+ .GenerateExtensionRegistrationCode(printer);
}
}
// ===================================================================
-void ImmutableMessageGenerator::GenerateParsingConstructor(
- io::Printer* printer) {
- std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
+void ImmutableMessageGenerator::GenerateParsingConstructor(
+ io::Printer* printer) {
+ std::unique_ptr<const FieldDescriptor*[]> sorted_fields(
SortFieldsByNumber(descriptor_));
printer->Print(
@@ -1181,10 +1181,10 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
// Initialize all fields to default.
printer->Print(
- "this();\n"
- "if (extensionRegistry == null) {\n"
- " throw new java.lang.NullPointerException();\n"
- "}\n");
+ "this();\n"
+ "if (extensionRegistry == null) {\n"
+ " throw new java.lang.NullPointerException();\n"
+ "}\n");
// Use builder bits to track mutable repeated fields.
int totalBuilderBits = 0;
@@ -1195,80 +1195,80 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
}
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("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");
- printer->Print("try {\n");
+ printer->Print("try {\n");
printer->Indent();
printer->Print(
- "boolean done = false;\n"
- "while (!done) {\n");
+ "boolean done = false;\n"
+ "while (!done) {\n");
printer->Indent();
printer->Print(
- "int tag = input.readTag();\n"
- "switch (tag) {\n");
+ "int tag = input.readTag();\n"
+ "switch (tag) {\n");
printer->Indent();
printer->Print(
- "case 0:\n" // zero signals EOF / limit reached
- " done = true;\n"
- " break;\n");
+ "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];
- uint32_t tag = WireFormatLite::MakeTag(
- field->number(), WireFormat::WireTypeForFieldType(field->type()));
+ uint32_t tag = WireFormatLite::MakeTag(
+ field->number(), WireFormat::WireTypeForFieldType(field->type()));
- printer->Print("case $tag$: {\n", "tag",
- StrCat(static_cast<int32_t>(tag)));
+ printer->Print("case $tag$: {\n", "tag",
+ StrCat(static_cast<int32_t>(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
printer->Outdent();
printer->Print(
- " break;\n"
- "}\n");
+ " 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().
- 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)));
+ 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(
- " break;\n"
- "}\n");
+ " break;\n"
+ "}\n");
}
}
- printer->Print(
- "default: {\n"
- " if (!parseUnknownField(\n"
- " input, unknownFields, extensionRegistry, tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
-
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownField(\n"
+ " input, unknownFields, extensionRegistry, tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+
printer->Outdent();
printer->Outdent();
printer->Print(
- " }\n" // switch (tag)
- "}\n"); // while (!done)
+ " }\n" // switch (tag)
+ "}\n"); // while (!done)
printer->Outdent();
printer->Print(
@@ -1290,12 +1290,12 @@ void ImmutableMessageGenerator::GenerateParsingConstructor(
printer->Print("this.unknownFields = unknownFields.build();\n");
// Make extensions immutable.
- printer->Print("makeExtensionsImmutable();\n");
+ printer->Print("makeExtensionsImmutable();\n");
printer->Outdent();
printer->Outdent();
printer->Print(
- " }\n" // finally
+ " }\n" // finally
"}\n");
}
@@ -1310,15 +1310,15 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
"classname", descriptor_->name());
printer->Indent();
printer->Print(
- "@java.lang.Override\n"
+ "@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_)) {
- printer->Print(" return new $classname$(input, extensionRegistry);\n",
- "classname", descriptor_->name());
+ 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()
@@ -1338,7 +1338,7 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
"return builder.buildPartial();\n");
printer->Outdent();
}
- printer->Print("}\n");
+ printer->Print("}\n");
printer->Outdent();
printer->Print(
"};\n"
@@ -1360,357 +1360,357 @@ void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
// ===================================================================
void ImmutableMessageGenerator::GenerateInitializers(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!IsRealOneof(descriptor_->field(i))) {
+ if (!IsRealOneof(descriptor_->field(i))) {
field_generators_.get(descriptor_->field(i))
.GenerateInitializationCode(printer);
}
}
}
-// ===================================================================
-void ImmutableMessageGenerator::GenerateMutableCopy(io::Printer* printer) {
- printer->Print(
- "protected com.google.protobuf.MutableMessage\n"
- " internalMutableDefault() {\n"
- " return MutableDefaultLoader.get();\n"
- "}\n"
- "\n"
- "private static final class MutableDefaultLoader {\n"
- " private static final java.lang.Object defaultOrRuntimeException;\n"
- " static {\n"
- " java.lang.Object local;\n"
- " try {\n"
- " local = internalMutableDefault(\"$mutable_name$\");\n"
- " } catch (java.lang.RuntimeException e) {\n"
- " local = e;\n"
- " }\n"
- " defaultOrRuntimeException = local;\n"
- " }\n"
- "\n"
- " private MutableDefaultLoader() {}\n"
- "\n"
- " public static com.google.protobuf.MutableMessage get() {\n"
- " if (defaultOrRuntimeException\n"
- " instanceof java.lang.RuntimeException) {\n"
- " throw (java.lang.RuntimeException) defaultOrRuntimeException;\n"
- " }\n"
- " return\n"
- " (com.google.protobuf.MutableMessage) "
- "defaultOrRuntimeException;\n"
- " }\n"
- "}\n",
- "mutable_name", name_resolver_->GetJavaMutableClassName(descriptor_));
-}
-
-void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
- printer->Print(
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "@com.google.protobuf.kotlin.ProtoDslMarker\n");
- printer->Print(
- "class Dsl private constructor(\n"
- " @kotlin.jvm.JvmField private val _builder: $message$.Builder\n"
- ") {\n"
- " companion object {\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " @kotlin.PublishedApi\n"
- " internal fun _create(builder: $message$.Builder): Dsl = "
- "Dsl(builder)\n"
- " }\n"
- "\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " @kotlin.PublishedApi\n"
- " internal fun _build(): $message$ = _builder.build()\n",
- "message", name_resolver_->GetClassName(descriptor_, true));
-
- printer->Indent();
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("\n");
- field_generators_.get(descriptor_->field(i))
- .GenerateKotlinDslMembers(printer);
- }
-
- for (auto oneof : oneofs_) {
- printer->Print(
- "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
- " @JvmName(\"get$oneof_capitalized_name$Case\")\n"
- " get() = _builder.get$oneof_capitalized_name$Case()\n\n"
- "fun clear$oneof_capitalized_name$() {\n"
- " _builder.clear$oneof_capitalized_name$()\n"
- "}\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
- "oneof_capitalized_name",
- context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "message",
- name_resolver_->GetClassName(descriptor_, true));
- }
-
- if (descriptor_->extension_range_count() > 0) {
- GenerateKotlinExtensions(printer);
- }
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void ImmutableMessageGenerator::GenerateKotlinMembers(
- io::Printer* printer) const {
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> Unit): "
- "$message$ "
- "=\n"
- " $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
- "}._build()\n",
- "camelcase_name", name_resolver_->GetKotlinFactoryName(descriptor_),
- "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
- "message", name_resolver_->GetClassName(descriptor_, true));
-
- printer->Print("object $name$Kt {\n", "name", descriptor_->name());
- printer->Indent();
- GenerateKotlinDsl(printer);
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (IsMapEntry(descriptor_->nested_type(i))) continue;
- ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
- .GenerateKotlinMembers(printer);
- }
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
- io::Printer* printer) const {
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline fun $message$.copy(block: $message_kt$.Dsl.() -> Unit): "
- "$message$ =\n"
- " $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
- "}._build()\n",
- "message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
- name_resolver_->GetKotlinExtensionsClassName(descriptor_));
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (IsMapEntry(descriptor_->nested_type(i))) continue;
- ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
- .GenerateTopLevelKotlinMembers(printer);
- }
-}
-
-void ImmutableMessageGenerator::GenerateKotlinExtensions(
- io::Printer* printer) const {
- TProtoStringType message_name = name_resolver_->GetClassName(descriptor_, true);
-
- printer->Print(
- "@Suppress(\"UNCHECKED_CAST\")\n"
- "@kotlin.jvm.JvmSynthetic\n"
- "operator fun <T> get(extension: "
- "com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
- " return if (extension.isRepeated) {\n"
- " get(extension as com.google.protobuf.ExtensionLite<$message$, "
- "List<*>>) as T\n"
- " } else {\n"
- " _builder.getExtension(extension)\n"
- " }\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "operator fun <E> get(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
- "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
- " return com.google.protobuf.kotlin.ExtensionList(extension, "
- "_builder.getExtension(extension))\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "operator fun contains(extension: "
- "com.google.protobuf.ExtensionLite<$message$, *>): "
- "Boolean {\n"
- " return _builder.hasExtension(extension)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) "
- "{\n"
- " _builder.clearExtension(extension)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.PublishedApi\n"
- "internal fun <T> setExtension(extension: "
- "com.google.protobuf.ExtensionLite<$message$, T>, "
- "value: T) {\n"
- " _builder.setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <T : Comparable<T>> set(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
- " value: T\n"
- ") {\n"
- " setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun set(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, "
- "com.google.protobuf.ByteString>,\n"
- " value: com.google.protobuf.ByteString\n"
- ") {\n"
- " setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
- " value: T\n"
- ") {\n"
- " setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.add(value: E) {\n"
- " _builder.addExtension(this.extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.plusAssign"
- "(value: E) {\n"
- " add(value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.addAll(values: Iterable<E>) {\n"
- " for (value in values) {\n"
- " add(value)\n"
- " }\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.plusAssign(values: "
- "Iterable<E>) {\n"
- " addAll(values)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.set(index: Int, value: "
- "E) {\n"
- " _builder.setExtension(this.extension, index, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
- "$message$>.clear() {\n"
- " clear(extension)\n"
- "}\n\n",
- "message", message_name);
-}
-
+// ===================================================================
+void ImmutableMessageGenerator::GenerateMutableCopy(io::Printer* printer) {
+ printer->Print(
+ "protected com.google.protobuf.MutableMessage\n"
+ " internalMutableDefault() {\n"
+ " return MutableDefaultLoader.get();\n"
+ "}\n"
+ "\n"
+ "private static final class MutableDefaultLoader {\n"
+ " private static final java.lang.Object defaultOrRuntimeException;\n"
+ " static {\n"
+ " java.lang.Object local;\n"
+ " try {\n"
+ " local = internalMutableDefault(\"$mutable_name$\");\n"
+ " } catch (java.lang.RuntimeException e) {\n"
+ " local = e;\n"
+ " }\n"
+ " defaultOrRuntimeException = local;\n"
+ " }\n"
+ "\n"
+ " private MutableDefaultLoader() {}\n"
+ "\n"
+ " public static com.google.protobuf.MutableMessage get() {\n"
+ " if (defaultOrRuntimeException\n"
+ " instanceof java.lang.RuntimeException) {\n"
+ " throw (java.lang.RuntimeException) defaultOrRuntimeException;\n"
+ " }\n"
+ " return\n"
+ " (com.google.protobuf.MutableMessage) "
+ "defaultOrRuntimeException;\n"
+ " }\n"
+ "}\n",
+ "mutable_name", name_resolver_->GetJavaMutableClassName(descriptor_));
+}
+
+void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
+ printer->Print(
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "@com.google.protobuf.kotlin.ProtoDslMarker\n");
+ printer->Print(
+ "class Dsl private constructor(\n"
+ " @kotlin.jvm.JvmField private val _builder: $message$.Builder\n"
+ ") {\n"
+ " companion object {\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " @kotlin.PublishedApi\n"
+ " internal fun _create(builder: $message$.Builder): Dsl = "
+ "Dsl(builder)\n"
+ " }\n"
+ "\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " @kotlin.PublishedApi\n"
+ " internal fun _build(): $message$ = _builder.build()\n",
+ "message", name_resolver_->GetClassName(descriptor_, true));
+
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("\n");
+ field_generators_.get(descriptor_->field(i))
+ .GenerateKotlinDslMembers(printer);
+ }
+
+ for (auto oneof : oneofs_) {
+ printer->Print(
+ "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ " @JvmName(\"get$oneof_capitalized_name$Case\")\n"
+ " get() = _builder.get$oneof_capitalized_name$Case()\n\n"
+ "fun clear$oneof_capitalized_name$() {\n"
+ " _builder.clear$oneof_capitalized_name$()\n"
+ "}\n",
+ "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
+ "oneof_capitalized_name",
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "message",
+ name_resolver_->GetClassName(descriptor_, true));
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ GenerateKotlinExtensions(printer);
+ }
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void ImmutableMessageGenerator::GenerateKotlinMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> Unit): "
+ "$message$ "
+ "=\n"
+ " $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
+ "}._build()\n",
+ "camelcase_name", name_resolver_->GetKotlinFactoryName(descriptor_),
+ "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
+ "message", name_resolver_->GetClassName(descriptor_, true));
+
+ printer->Print("object $name$Kt {\n", "name", descriptor_->name());
+ printer->Indent();
+ GenerateKotlinDsl(printer);
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ if (IsMapEntry(descriptor_->nested_type(i))) continue;
+ ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
+ .GenerateKotlinMembers(printer);
+ }
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline fun $message$.copy(block: $message_kt$.Dsl.() -> Unit): "
+ "$message$ =\n"
+ " $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
+ "}._build()\n",
+ "message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
+ name_resolver_->GetKotlinExtensionsClassName(descriptor_));
+
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ if (IsMapEntry(descriptor_->nested_type(i))) continue;
+ ImmutableMessageGenerator(descriptor_->nested_type(i), context_)
+ .GenerateTopLevelKotlinMembers(printer);
+ }
+}
+
+void ImmutableMessageGenerator::GenerateKotlinExtensions(
+ io::Printer* printer) const {
+ TProtoStringType message_name = name_resolver_->GetClassName(descriptor_, true);
+
+ printer->Print(
+ "@Suppress(\"UNCHECKED_CAST\")\n"
+ "@kotlin.jvm.JvmSynthetic\n"
+ "operator fun <T> get(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
+ " return if (extension.isRepeated) {\n"
+ " get(extension as com.google.protobuf.ExtensionLite<$message$, "
+ "List<*>>) as T\n"
+ " } else {\n"
+ " _builder.getExtension(extension)\n"
+ " }\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
+ "operator fun <E> get(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
+ "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
+ " return com.google.protobuf.kotlin.ExtensionList(extension, "
+ "_builder.getExtension(extension))\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "operator fun contains(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, *>): "
+ "Boolean {\n"
+ " return _builder.hasExtension(extension)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) "
+ "{\n"
+ " _builder.clearExtension(extension)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.PublishedApi\n"
+ "internal fun <T> setExtension(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, T>, "
+ "value: T) {\n"
+ " _builder.setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <T : Comparable<T>> set(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
+ " value: T\n"
+ ") {\n"
+ " setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun set(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, "
+ "com.google.protobuf.ByteString>,\n"
+ " value: com.google.protobuf.ByteString\n"
+ ") {\n"
+ " setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
+ " value: T\n"
+ ") {\n"
+ " setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.add(value: E) {\n"
+ " _builder.addExtension(this.extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.plusAssign"
+ "(value: E) {\n"
+ " add(value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.addAll(values: Iterable<E>) {\n"
+ " for (value in values) {\n"
+ " add(value)\n"
+ " }\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.plusAssign(values: "
+ "Iterable<E>) {\n"
+ " addAll(values)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.set(index: Int, value: "
+ "E) {\n"
+ " _builder.setExtension(this.extension, index, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "$message$>.clear() {\n"
+ " clear(extension)\n"
+ "}\n\n",
+ "message", message_name);
+}
+
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"
- " return typeUrlPrefix.endsWith(\"/\")\n"
- " ? typeUrlPrefix + descriptor.getFullName()\n"
- " : typeUrlPrefix + \"/\" + descriptor.getFullName();\n"
- "}\n"
- "\n"
- "private static String getTypeNameFromTypeUrl(\n"
- " java.lang.String typeUrl) {\n"
- " int pos = typeUrl.lastIndexOf('/');\n"
- " return pos == -1 ? \"\" : typeUrl.substring(pos + 1);\n"
- "}\n"
- "\n"
- "public static <T extends com.google.protobuf.Message> Any pack(\n"
- " T message) {\n"
- " return Any.newBuilder()\n"
- " .setTypeUrl(getTypeUrl(\"type.googleapis.com\",\n"
- " message.getDescriptorForType()))\n"
- " .setValue(message.toByteString())\n"
- " .build();\n"
- "}\n"
- "\n"
- "/**\n"
- " * Packs a message using the given type URL prefix. The type URL will\n"
- " * be constructed by concatenating the message type's full name to the\n"
- " * prefix with an optional \"/\" separator if the prefix doesn't end\n"
- " * with \"/\" already.\n"
- " */\n"
- "public static <T extends com.google.protobuf.Message> Any pack(\n"
- " T message, java.lang.String typeUrlPrefix) {\n"
- " return Any.newBuilder()\n"
- " .setTypeUrl(getTypeUrl(typeUrlPrefix,\n"
- " message.getDescriptorForType()))\n"
- " .setValue(message.toByteString())\n"
- " .build();\n"
- "}\n"
- "\n"
- "public <T extends com.google.protobuf.Message> boolean is(\n"
- " java.lang.Class<T> clazz) {\n"
- " T defaultInstance =\n"
- " com.google.protobuf.Internal.getDefaultInstance(clazz);\n"
- " return getTypeNameFromTypeUrl(getTypeUrl()).equals(\n"
- " defaultInstance.getDescriptorForType().getFullName());\n"
- "}\n"
- "\n"
- "private volatile com.google.protobuf.Message cachedUnpackValue;\n"
- "\n"
- "@java.lang.SuppressWarnings(\"unchecked\")\n"
- "public <T extends com.google.protobuf.Message> T unpack(\n"
- " java.lang.Class<T> clazz)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " boolean invalidClazz = false;\n"
- " if (cachedUnpackValue != null) {\n"
- " if (cachedUnpackValue.getClass() == clazz) {\n"
- " return (T) cachedUnpackValue;\n"
- " }\n"
- " invalidClazz = true;\n"
- " }\n"
- " if (invalidClazz || !is(clazz)) {\n"
- " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
- " \"Type of the Any message does not match the given class.\");\n"
- " }\n"
- " T defaultInstance =\n"
- " com.google.protobuf.Internal.getDefaultInstance(clazz);\n"
- " T result = (T) defaultInstance.getParserForType()\n"
- " .parseFrom(getValue());\n"
- " cachedUnpackValue = result;\n"
- " return result;\n"
- "}\n");
+ "private static String getTypeUrl(\n"
+ " java.lang.String typeUrlPrefix,\n"
+ " com.google.protobuf.Descriptors.Descriptor descriptor) {\n"
+ " return typeUrlPrefix.endsWith(\"/\")\n"
+ " ? typeUrlPrefix + descriptor.getFullName()\n"
+ " : typeUrlPrefix + \"/\" + descriptor.getFullName();\n"
+ "}\n"
+ "\n"
+ "private static String getTypeNameFromTypeUrl(\n"
+ " java.lang.String typeUrl) {\n"
+ " int pos = typeUrl.lastIndexOf('/');\n"
+ " return pos == -1 ? \"\" : typeUrl.substring(pos + 1);\n"
+ "}\n"
+ "\n"
+ "public static <T extends com.google.protobuf.Message> Any pack(\n"
+ " T message) {\n"
+ " return Any.newBuilder()\n"
+ " .setTypeUrl(getTypeUrl(\"type.googleapis.com\",\n"
+ " message.getDescriptorForType()))\n"
+ " .setValue(message.toByteString())\n"
+ " .build();\n"
+ "}\n"
+ "\n"
+ "/**\n"
+ " * Packs a message using the given type URL prefix. The type URL will\n"
+ " * be constructed by concatenating the message type's full name to the\n"
+ " * prefix with an optional \"/\" separator if the prefix doesn't end\n"
+ " * with \"/\" already.\n"
+ " */\n"
+ "public static <T extends com.google.protobuf.Message> Any pack(\n"
+ " T message, java.lang.String typeUrlPrefix) {\n"
+ " return Any.newBuilder()\n"
+ " .setTypeUrl(getTypeUrl(typeUrlPrefix,\n"
+ " message.getDescriptorForType()))\n"
+ " .setValue(message.toByteString())\n"
+ " .build();\n"
+ "}\n"
+ "\n"
+ "public <T extends com.google.protobuf.Message> boolean is(\n"
+ " java.lang.Class<T> clazz) {\n"
+ " T defaultInstance =\n"
+ " com.google.protobuf.Internal.getDefaultInstance(clazz);\n"
+ " return getTypeNameFromTypeUrl(getTypeUrl()).equals(\n"
+ " defaultInstance.getDescriptorForType().getFullName());\n"
+ "}\n"
+ "\n"
+ "private volatile com.google.protobuf.Message cachedUnpackValue;\n"
+ "\n"
+ "@java.lang.SuppressWarnings(\"unchecked\")\n"
+ "public <T extends com.google.protobuf.Message> T unpack(\n"
+ " java.lang.Class<T> clazz)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " boolean invalidClazz = false;\n"
+ " if (cachedUnpackValue != null) {\n"
+ " if (cachedUnpackValue.getClass() == clazz) {\n"
+ " return (T) cachedUnpackValue;\n"
+ " }\n"
+ " invalidClazz = true;\n"
+ " }\n"
+ " if (invalidClazz || !is(clazz)) {\n"
+ " throw new com.google.protobuf.InvalidProtocolBufferException(\n"
+ " \"Type of the Any message does not match the given class.\");\n"
+ " }\n"
+ " T defaultInstance =\n"
+ " com.google.protobuf.Internal.getDefaultInstance(clazz);\n"
+ " T result = (T) defaultInstance.getParserForType()\n"
+ " .parseFrom(getValue());\n"
+ " cachedUnpackValue = result;\n"
+ " return result;\n"
+ "}\n");
}
} // namespace java
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 f57cdf3863..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
@@ -35,25 +35,25 @@
#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>
+#include <map>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -68,8 +68,8 @@ class 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;
+ 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.
@@ -78,20 +78,20 @@ class MessageGenerator {
// Generate the class itself.
virtual void Generate(io::Printer* printer) = 0;
- // Generates the base interface that both the class and its builder
- // implement
+ // 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 GenerateKotlinDsl(io::Printer* printer) const = 0;
- virtual void GenerateKotlinMembers(io::Printer* printer) const = 0;
- virtual void GenerateTopLevelKotlinMembers(io::Printer* printer) const = 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_;
- std::set<const OneofDescriptor*> oneofs_;
+ std::set<const OneofDescriptor*> oneofs_;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
@@ -102,17 +102,17 @@ class ImmutableMessageGenerator : public MessageGenerator {
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;
+ 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
- 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;
+ 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);
@@ -134,8 +134,8 @@ class ImmutableMessageGenerator : public MessageGenerator {
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 GenerateMutableCopy(io::Printer* printer);
+ void GenerateKotlinExtensions(io::Printer* printer) const;
void GenerateAnyMethods(io::Printer* printer);
Context* context_;
@@ -148,6 +148,6 @@ class ImmutableMessageGenerator : public MessageGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 e9b90d7688..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
@@ -32,26 +32,26 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_builder.h>
+#include <google/protobuf/compiler/java/java_message_builder.h>
#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>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
+#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>
+#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/compiler/java/java_generator_factory.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -59,54 +59,54 @@ namespace compiler {
namespace java {
namespace {
-TProtoStringType MapValueImmutableClassdName(const Descriptor* descriptor,
- ClassNameResolver* name_resolver) {
+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
-MessageBuilderGenerator::MessageBuilderGenerator(const Descriptor* descriptor,
- Context* context)
- : descriptor_(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()),
- field_generators_(descriptor, context_) {
+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.";
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
- }
- }
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (IsRealOneof(descriptor_->field(i))) {
+ oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ }
+ }
}
MessageBuilderGenerator::~MessageBuilderGenerator() {}
-void MessageBuilderGenerator::Generate(io::Printer* printer) {
+void MessageBuilderGenerator::Generate(io::Printer* printer) {
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"
- " $extra_interfaces$\n"
- " $classname$OrBuilder {\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ "public static final class Builder extends\n"
+ " com.google.protobuf.GeneratedMessage$ver$.ExtendableBuilder<\n"
+ " $classname$, Builder> implements\n"
+ " $extra_interfaces$\n"
+ " $classname$OrBuilder {\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
} else {
printer->Print(
- "public static final class Builder extends\n"
- " com.google.protobuf.GeneratedMessage$ver$.Builder<Builder> "
- "implements\n"
- " $extra_interfaces$\n"
- " $classname$OrBuilder {\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ "public static final class Builder extends\n"
+ " com.google.protobuf.GeneratedMessage$ver$.Builder<Builder> "
+ "implements\n"
+ " $extra_interfaces$\n"
+ " $classname$OrBuilder {\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
}
printer->Indent();
@@ -119,75 +119,75 @@ void MessageBuilderGenerator::Generate(io::Printer* 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());
+ 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,
- "private int $oneof_name$Case_ = 0;\n"
- "private java.lang.Object $oneof_name$_;\n");
+ "private int $oneof_name$Case_ = 0;\n"
+ "private java.lang.Object $oneof_name$_;\n");
// 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"
- " $oneof_name$Case_);\n"
- "}\n"
- "\n"
- "public Builder clear$oneof_capitalized_name$() {\n"
- " $oneof_name$Case_ = 0;\n"
- " $oneof_name$_ = null;\n");
+ "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"
+ "public Builder clear$oneof_capitalized_name$() {\n"
+ " $oneof_name$Case_ = 0;\n"
+ " $oneof_name$_ = null;\n");
printer->Print(" onChanged();\n");
printer->Print(
- " return this;\n"
- "}\n"
- "\n");
+ " 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();
+ // 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));
}
- 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))
- .GenerateBuilderMembers(printer);
+ .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
- // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release
- // we changed all generated code to subclass GeneratedMessageV3).
+ // 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(
- "@java.lang.Override\n"
- "public final Builder setUnknownFields(\n"
- " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
- " return super.setUnknownFields(unknownFields);\n"
- "}\n"
- "\n"
- "@java.lang.Override\n"
- "public final Builder mergeUnknownFields(\n"
- " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
- " return super.mergeUnknownFields(unknownFields);\n"
- "}\n"
- "\n");
+ "@java.lang.Override\n"
+ "public final Builder setUnknownFields(\n"
+ " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
+ " return super.setUnknownFields(unknownFields);\n"
+ "}\n"
+ "\n"
+ "@java.lang.Override\n"
+ "public final Builder mergeUnknownFields(\n"
+ " final com.google.protobuf.UnknownFieldSet unknownFields) {\n"
+ " return super.mergeUnknownFields(unknownFields);\n"
+ "}\n"
+ "\n");
printer->Print(
- "\n"
- "// @@protoc_insertion_point(builder_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\n"
+ "// @@protoc_insertion_point(builder_scope:$full_name$)\n",
+ "full_name", descriptor_->full_name());
printer->Outdent();
printer->Print("}\n");
@@ -195,16 +195,16 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) {
// ===================================================================
-void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
+void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
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"
- "}\n"
- "\n",
- "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "identifier", UniqueFileScopeIdentifier(descriptor_));
+ "public static final com.google.protobuf.Descriptors.Descriptor\n"
+ " getDescriptor() {\n"
+ " return $fileclass$.internal_$identifier$_descriptor;\n"
+ "}\n"
+ "\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++) {
@@ -216,20 +216,20 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
}
if (!map_fields.empty()) {
printer->Print(
- "@SuppressWarnings({\"rawtypes\"})\n"
- "protected com.google.protobuf.MapField internalGetMapField(\n"
- " int number) {\n"
- " switch (number) {\n");
+ "@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(
- "case $number$:\n"
- " return internalGet$capitalized_name$();\n",
- "number", StrCat(field->number()), "capitalized_name",
- info->capitalized_name);
+ "case $number$:\n"
+ " return internalGet$capitalized_name$();\n",
+ "number", StrCat(field->number()), "capitalized_name",
+ info->capitalized_name);
}
printer->Print(
"default:\n"
@@ -241,20 +241,20 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
" }\n"
"}\n");
printer->Print(
- "@SuppressWarnings({\"rawtypes\"})\n"
- "protected com.google.protobuf.MapField internalGetMutableMapField(\n"
- " int number) {\n"
- " switch (number) {\n");
+ "@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];
- const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
+ const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);
printer->Print(
- "case $number$:\n"
- " return internalGetMutable$capitalized_name$();\n",
- "number", StrCat(field->number()), "capitalized_name",
- info->capitalized_name);
+ "case $number$:\n"
+ " return internalGetMutable$capitalized_name$();\n",
+ "number", StrCat(field->number()), "capitalized_name",
+ info->capitalized_name);
}
printer->Print(
"default:\n"
@@ -267,24 +267,24 @@ void MessageBuilderGenerator::GenerateDescriptorMethods(io::Printer* printer) {
"}\n");
}
printer->Print(
- "@java.lang.Override\n"
- "protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
- " internalGetFieldAccessorTable() {\n"
- " return $fileclass$.internal_$identifier$_fieldAccessorTable\n"
- " .ensureFieldAccessorsInitialized(\n"
- " $classname$.class, $classname$.Builder.class);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ "@java.lang.Override\n"
+ "protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\n"
+ " internalGetFieldAccessorTable() {\n"
+ " return $fileclass$.internal_$identifier$_fieldAccessorTable\n"
+ " .ensureFieldAccessorsInitialized(\n"
+ " $classname$.class, $classname$.Builder.class);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
+ "identifier", UniqueFileScopeIdentifier(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
}
// ===================================================================
-void MessageBuilderGenerator::GenerateCommonBuilderMethods(
- io::Printer* printer) {
+void MessageBuilderGenerator::GenerateCommonBuilderMethods(
+ io::Printer* printer) {
printer->Print(
"// Construct using $classname$.newBuilder()\n"
"private Builder() {\n"
@@ -294,24 +294,24 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
"classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Print(
- "private Builder(\n"
- " com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
- " super(parent);\n"
- " maybeForceBuilderInitialization();\n"
- "}\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
- GeneratedCodeVersionSuffix());
+ "private Builder(\n"
+ " com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\n"
+ " super(parent);\n"
+ " maybeForceBuilderInitialization();\n"
+ "}\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_), "ver",
+ GeneratedCodeVersionSuffix());
printer->Print(
- "private void maybeForceBuilderInitialization() {\n"
- " if (com.google.protobuf.GeneratedMessage$ver$\n"
- " .alwaysUseFieldBuilders) {\n",
- "ver", GeneratedCodeVersionSuffix());
+ "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++) {
- if (!IsRealOneof(descriptor_->field(i))) {
+ if (!IsRealOneof(descriptor_->field(i))) {
field_generators_.get(descriptor_->field(i))
.GenerateFieldBuilderInitializationCode(printer);
}
@@ -320,73 +320,73 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
printer->Outdent();
printer->Print(
- " }\n"
- "}\n");
+ " }\n"
+ "}\n");
printer->Print(
- "@java.lang.Override\n"
- "public Builder clear() {\n"
- " super.clear();\n");
+ "@java.lang.Override\n"
+ "public Builder clear() {\n"
+ " super.clear();\n");
printer->Indent();
for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!IsRealOneof(descriptor_->field(i))) {
+ if (!IsRealOneof(descriptor_->field(i))) {
field_generators_.get(descriptor_->field(i))
.GenerateBuilderClearCode(printer);
}
}
- for (auto oneof : oneofs_) {
+ for (auto oneof : oneofs_) {
printer->Print(
- "$oneof_name$Case_ = 0;\n"
- "$oneof_name$_ = null;\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
+ "$oneof_name$Case_ = 0;\n"
+ "$oneof_name$_ = null;\n",
+ "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
}
printer->Outdent();
printer->Print(
- " return this;\n"
- "}\n"
- "\n");
+ " return this;\n"
+ "}\n"
+ "\n");
printer->Print(
- "@java.lang.Override\n"
- "public com.google.protobuf.Descriptors.Descriptor\n"
- " getDescriptorForType() {\n"
- " return $fileclass$.internal_$identifier$_descriptor;\n"
- "}\n"
- "\n",
- "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "identifier", UniqueFileScopeIdentifier(descriptor_));
+ "@java.lang.Override\n"
+ "public com.google.protobuf.Descriptors.Descriptor\n"
+ " getDescriptorForType() {\n"
+ " return $fileclass$.internal_$identifier$_descriptor;\n"
+ "}\n"
+ "\n",
+ "fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
+ "identifier", UniqueFileScopeIdentifier(descriptor_));
// 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_));
+ "@java.lang.Override\n"
+ "public $classname$ getDefaultInstanceForType() {\n"
+ " return $classname$.getDefaultInstance();\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Print(
- "@java.lang.Override\n"
- "public $classname$ build() {\n"
- " $classname$ result = buildPartial();\n"
- " if (!result.isInitialized()) {\n"
- " throw newUninitializedMessageException(result);\n"
- " }\n"
- " return result;\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "@java.lang.Override\n"
+ "public $classname$ build() {\n"
+ " $classname$ result = buildPartial();\n"
+ " if (!result.isInitialized()) {\n"
+ " throw newUninitializedMessageException(result);\n"
+ " }\n"
+ " return result;\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Print(
- "@java.lang.Override\n"
- "public $classname$ buildPartial() {\n"
- " $classname$ result = new $classname$(this);\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "@java.lang.Override\n"
+ "public $classname$ buildPartial() {\n"
+ " $classname$ result = new $classname$(this);\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Indent();
@@ -401,44 +401,44 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
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
- // code does.
- for (int i = 0; i < totalBuilderInts; i++) {
- printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n",
- "bit_field_name", GetBitFieldName(i));
+ // 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
+ // code does.
+ 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));
}
- 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);
}
- // 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));
+ // 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_) {
+ for (auto oneof : oneofs_) {
printer->Print("result.$oneof_name$Case_ = $oneof_name$Case_;\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
+ "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
}
printer->Outdent();
- printer->Print(" onBuilt();\n");
+ printer->Print(" onBuilt();\n");
printer->Print(
- " return result;\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ " 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
@@ -446,178 +446,178 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods(
// to subclass a different GeneratedMessage class (e.g., in v3.0.0 release
// we changed all generated code to subclass GeneratedMessageV3).
printer->Print(
- "@java.lang.Override\n"
- "public Builder clone() {\n"
- " return super.clone();\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder setField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " java.lang.Object value) {\n"
- " return super.setField(field, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder clearField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field) {\n"
- " return super.clearField(field);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder clearOneof(\n"
- " com.google.protobuf.Descriptors.OneofDescriptor oneof) {\n"
- " return super.clearOneof(oneof);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder setRepeatedField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " int index, java.lang.Object value) {\n"
- " return super.setRepeatedField(field, index, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public Builder addRepeatedField(\n"
- " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
- " java.lang.Object value) {\n"
- " return super.addRepeatedField(field, value);\n"
- "}\n");
+ "@java.lang.Override\n"
+ "public Builder clone() {\n"
+ " return super.clone();\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public Builder setField(\n"
+ " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
+ " java.lang.Object value) {\n"
+ " return super.setField(field, value);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public Builder clearField(\n"
+ " com.google.protobuf.Descriptors.FieldDescriptor field) {\n"
+ " return super.clearField(field);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public Builder clearOneof(\n"
+ " com.google.protobuf.Descriptors.OneofDescriptor oneof) {\n"
+ " return super.clearOneof(oneof);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public Builder setRepeatedField(\n"
+ " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
+ " int index, java.lang.Object value) {\n"
+ " return super.setRepeatedField(field, index, value);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public Builder addRepeatedField(\n"
+ " com.google.protobuf.Descriptors.FieldDescriptor field,\n"
+ " java.lang.Object value) {\n"
+ " return super.addRepeatedField(field, value);\n"
+ "}\n");
if (descriptor_->extension_range_count() > 0) {
printer->Print(
- "@java.lang.Override\n"
- "public <Type> Builder setExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, Type> extension,\n"
- " Type value) {\n"
- " return super.setExtension(extension, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public <Type> Builder setExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, java.util.List<Type>> extension,\n"
- " int index, Type value) {\n"
- " return super.setExtension(extension, index, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public <Type> Builder addExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, java.util.List<Type>> extension,\n"
- " Type value) {\n"
- " return super.addExtension(extension, value);\n"
- "}\n"
- "@java.lang.Override\n"
- "public <Type> Builder clearExtension(\n"
- " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
- " $classname$, ?> extension) {\n"
- " return super.clearExtension(extension);\n"
- "}\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "@java.lang.Override\n"
+ "public <Type> Builder setExtension(\n"
+ " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
+ " $classname$, Type> extension,\n"
+ " Type value) {\n"
+ " return super.setExtension(extension, value);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public <Type> Builder setExtension(\n"
+ " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
+ " $classname$, java.util.List<Type>> extension,\n"
+ " int index, Type value) {\n"
+ " return super.setExtension(extension, index, value);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public <Type> Builder addExtension(\n"
+ " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
+ " $classname$, java.util.List<Type>> extension,\n"
+ " Type value) {\n"
+ " return super.addExtension(extension, value);\n"
+ "}\n"
+ "@java.lang.Override\n"
+ "public <Type> Builder clearExtension(\n"
+ " com.google.protobuf.GeneratedMessage.GeneratedExtension<\n"
+ " $classname$, ?> extension) {\n"
+ " return super.clearExtension(extension);\n"
+ "}\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
}
// -----------------------------------------------------------------
if (context_->HasGeneratedMethods(descriptor_)) {
printer->Print(
- "@java.lang.Override\n"
- "public Builder mergeFrom(com.google.protobuf.Message other) {\n"
- " if (other instanceof $classname$) {\n"
- " return mergeFrom(($classname$)other);\n"
- " } else {\n"
- " super.mergeFrom(other);\n"
- " return this;\n"
- " }\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "@java.lang.Override\n"
+ "public Builder mergeFrom(com.google.protobuf.Message other) {\n"
+ " if (other instanceof $classname$) {\n"
+ " return mergeFrom(($classname$)other);\n"
+ " } else {\n"
+ " super.mergeFrom(other);\n"
+ " return this;\n"
+ " }\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
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_));
+ "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++) {
- if (!IsRealOneof(descriptor_->field(i))) {
- field_generators_.get(descriptor_->field(i))
- .GenerateMergingCode(printer);
+ if (!IsRealOneof(descriptor_->field(i))) {
+ field_generators_.get(descriptor_->field(i))
+ .GenerateMergingCode(printer);
}
}
// 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);
+ for (auto oneof : oneofs_) {
+ printer->Print("switch (other.get$oneof_capitalized_name$Case()) {\n",
+ "oneof_capitalized_name",
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name);
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()));
+ 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->Print("break;\n");
+ printer->Print("break;\n");
printer->Outdent();
- printer->Print("}\n");
+ printer->Print("}\n");
}
printer->Print(
- "case $cap_oneof_name$_NOT_SET: {\n"
- " break;\n"
- "}\n",
- "cap_oneof_name",
- ToUpper(context_->GetOneofGeneratorInfo(oneof)->name));
+ "case $cap_oneof_name$_NOT_SET: {\n"
+ " break;\n"
+ "}\n",
+ "cap_oneof_name",
+ ToUpper(context_->GetOneofGeneratorInfo(oneof)->name));
printer->Outdent();
- printer->Print("}\n");
+ printer->Print("}\n");
}
printer->Outdent();
// if message type has extensions
if (descriptor_->extension_range_count() > 0) {
- printer->Print(" this.mergeExtensionFields(other);\n");
+ printer->Print(" this.mergeExtensionFields(other);\n");
}
- printer->Print(" this.mergeUnknownFields(other.unknownFields);\n");
+ printer->Print(" this.mergeUnknownFields(other.unknownFields);\n");
- printer->Print(" onChanged();\n");
+ printer->Print(" onChanged();\n");
printer->Print(
- " return this;\n"
- "}\n"
- "\n");
+ " return this;\n"
+ "}\n"
+ "\n");
}
}
// ===================================================================
-void MessageBuilderGenerator::GenerateBuilderParsingMethods(
- io::Printer* printer) {
+void MessageBuilderGenerator::GenerateBuilderParsingMethods(
+ io::Printer* printer) {
printer->Print(
- "@java.lang.Override\n"
- "public Builder mergeFrom(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " $classname$ parsedMessage = null;\n"
- " try {\n"
- " parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\n"
- " } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
- " parsedMessage = ($classname$) e.getUnfinishedMessage();\n"
- " throw e.unwrapIOException();\n"
- " } finally {\n"
- " if (parsedMessage != null) {\n"
- " mergeFrom(parsedMessage);\n"
- " }\n"
- " }\n"
- " return this;\n"
- "}\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "@java.lang.Override\n"
+ "public Builder mergeFrom(\n"
+ " com.google.protobuf.CodedInputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " $classname$ parsedMessage = null;\n"
+ " try {\n"
+ " parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\n"
+ " } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
+ " parsedMessage = ($classname$) e.getUnfinishedMessage();\n"
+ " throw e.unwrapIOException();\n"
+ " } finally {\n"
+ " if (parsedMessage != null) {\n"
+ " mergeFrom(parsedMessage);\n"
+ " }\n"
+ " }\n"
+ " return this;\n"
+ "}\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
}
// ===================================================================
-void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
+void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
printer->Print(
- "@java.lang.Override\n"
- "public final boolean isInitialized() {\n");
+ "@java.lang.Override\n"
+ "public final boolean isInitialized() {\n");
printer->Indent();
// Check that all required fields in this message are set.
@@ -629,10 +629,10 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
if (field->is_required()) {
printer->Print(
- "if (!has$name$()) {\n"
- " return false;\n"
- "}\n",
- "name", info->capitalized_name);
+ "if (!has$name$()) {\n"
+ " return false;\n"
+ "}\n",
+ "name", info->capitalized_name);
}
}
@@ -645,44 +645,44 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
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);
+ "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:
- printer->Print(
- "if (has$name$()) {\n"
- " if (!get$name$().isInitialized()) {\n"
- " return false;\n"
- " }\n"
- "}\n",
+ 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(
- "for ($type$ item : get$name$Map().values()) {\n"
- " if (!item.isInitialized()) {\n"
- " return false;\n"
- " }\n"
- "}\n",
- "type",
- MapValueImmutableClassdName(field->message_type(),
- name_resolver_),
- "name", info->capitalized_name);
+ "for ($type$ item : get$name$Map().values()) {\n"
+ " if (!item.isInitialized()) {\n"
+ " return false;\n"
+ " }\n"
+ "}\n",
+ "type",
+ MapValueImmutableClassdName(field->message_type(),
+ name_resolver_),
+ "name", info->capitalized_name);
} else {
printer->Print(
- "for (int i = 0; i < get$name$Count(); i++) {\n"
- " if (!get$name$(i).isInitialized()) {\n"
- " return false;\n"
- " }\n"
- "}\n",
- "type",
- name_resolver_->GetImmutableClassName(field->message_type()),
- "name", info->capitalized_name);
+ "for (int i = 0; i < get$name$Count(); i++) {\n"
+ " if (!get$name$(i).isInitialized()) {\n"
+ " return false;\n"
+ " }\n"
+ "}\n",
+ "type",
+ name_resolver_->GetImmutableClassName(field->message_type()),
+ "name", info->capitalized_name);
}
break;
}
@@ -691,17 +691,17 @@ void MessageBuilderGenerator::GenerateIsInitialized(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
printer->Print(
- "if (!extensionsAreInitialized()) {\n"
- " return false;\n"
- "}\n");
+ "if (!extensionsAreInitialized()) {\n"
+ " return false;\n"
+ "}\n");
}
printer->Outdent();
printer->Print(
- " return true;\n"
- "}\n"
- "\n");
+ " return true;\n"
+ "}\n"
+ "\n");
}
// ===================================================================
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 99deaf6862..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
@@ -35,25 +35,25 @@
#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>
+#include <map>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -76,7 +76,7 @@ class MessageBuilderGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
- std::set<const OneofDescriptor*> oneofs_;
+ std::set<const OneofDescriptor*> oneofs_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderGenerator);
};
@@ -84,6 +84,6 @@ class MessageBuilderGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 148062ad17..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
@@ -32,26 +32,26 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_builder_lite.h>
+#include <google/protobuf/compiler/java/java_message_builder_lite.h>
#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>
-#include <google/protobuf/compiler/java/java_extension.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
+#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>
+#include <google/protobuf/compiler/java/java_extension.h>
+#include <google/protobuf/compiler/java/java_generator_factory.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -60,71 +60,71 @@ namespace java {
MessageBuilderLiteGenerator::MessageBuilderLiteGenerator(
const Descriptor* descriptor, Context* context)
- : descriptor_(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()),
- field_generators_(descriptor, 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.";
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
- }
- }
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (IsRealOneof(descriptor_->field(i))) {
+ oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ }
+ }
}
MessageBuilderLiteGenerator::~MessageBuilderLiteGenerator() {}
-void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
+void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
WriteMessageDocComment(printer, descriptor_);
printer->Print(
- "public static final class Builder extends\n"
- " com.google.protobuf.GeneratedMessageLite.$extendible$Builder<\n"
- " $classname$, Builder> implements\n"
- " $extra_interfaces$\n"
- " $classname$OrBuilder {\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "extendible",
- descriptor_->extension_range_count() > 0 ? "Extendable" : "");
+ "public static final class Builder extends\n"
+ " com.google.protobuf.GeneratedMessageLite.$extendible$Builder<\n"
+ " $classname$, Builder> implements\n"
+ " $extra_interfaces$\n"
+ " $classname$OrBuilder {\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "extra_interfaces", ExtraBuilderInterfaces(descriptor_), "extendible",
+ descriptor_->extension_range_count() > 0 ? "Extendable" : "");
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());
+ 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,
- "@java.lang.Override\n"
- "public $oneof_capitalized_name$Case\n"
- " get$oneof_capitalized_name$Case() {\n"
- " return instance.get$oneof_capitalized_name$Case();\n"
- "}\n"
- "\n"
- "public Builder clear$oneof_capitalized_name$() {\n"
- " copyOnWrite();\n"
- " instance.clear$oneof_capitalized_name$();\n"
- " return this;\n"
- "}\n"
- "\n");
+ "@java.lang.Override\n"
+ "public $oneof_capitalized_name$Case\n"
+ " get$oneof_capitalized_name$Case() {\n"
+ " return instance.get$oneof_capitalized_name$Case();\n"
+ "}\n"
+ "\n"
+ "public Builder clear$oneof_capitalized_name$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$oneof_capitalized_name$();\n"
+ " return this;\n"
+ "}\n"
+ "\n");
}
for (int i = 0; i < descriptor_->field_count(); i++) {
printer->Print("\n");
field_generators_.get(descriptor_->field(i))
- .GenerateBuilderMembers(printer);
+ .GenerateBuilderMembers(printer);
}
printer->Print(
- "\n"
- "// @@protoc_insertion_point(builder_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\n"
+ "// @@protoc_insertion_point(builder_scope:$full_name$)\n",
+ "full_name", descriptor_->full_name());
printer->Outdent();
printer->Print("}\n");
@@ -132,15 +132,15 @@ void MessageBuilderLiteGenerator::Generate(io::Printer* printer) {
// ===================================================================
-void MessageBuilderLiteGenerator::GenerateCommonBuilderMethods(
- io::Printer* printer) {
+void MessageBuilderLiteGenerator::GenerateCommonBuilderMethods(
+ io::Printer* printer) {
printer->Print(
- "// Construct using $classname$.newBuilder()\n"
- "private Builder() {\n"
- " super(DEFAULT_INSTANCE);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "// Construct using $classname$.newBuilder()\n"
+ "private Builder() {\n"
+ " super(DEFAULT_INSTANCE);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
}
// ===================================================================
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 6cfd17a494..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
@@ -35,25 +35,25 @@
#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>
+#include <map>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -61,7 +61,7 @@ namespace java {
class MessageBuilderLiteGenerator {
public:
explicit MessageBuilderLiteGenerator(const Descriptor* descriptor,
- Context* context);
+ Context* context);
virtual ~MessageBuilderLiteGenerator();
virtual void Generate(io::Printer* printer);
@@ -73,7 +73,7 @@ class MessageBuilderLiteGenerator {
Context* context_;
ClassNameResolver* name_resolver_;
FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;
- std::set<const OneofDescriptor*> oneofs_;
+ std::set<const OneofDescriptor*> oneofs_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderLiteGenerator);
};
@@ -81,6 +81,6 @@ class MessageBuilderLiteGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 96030e2fc6..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
@@ -33,55 +33,55 @@
// Sanjay Ghemawat, Jeff Dean, and others.
#include <map>
-#include <string>
+#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>
-#include <google/protobuf/compiler/java/java_message_field.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.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_message_field.h>
+#include <google/protobuf/compiler/java/java_name_resolver.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 java {
-
+
namespace {
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
+void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->message_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ (*variables)["kt_type"] = (*variables)["type"];
(*variables)["mutable_type"] =
name_resolver->GetMutableClassName(descriptor->message_type());
(*variables)["group_or_message"] =
- (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? "Group"
- : "Message";
+ (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? "Group"
+ : "Message";
// 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"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
(*variables)["on_changed"] = "onChanged();";
(*variables)["ver"] = GeneratedCodeVersionSuffix();
(*variables)["get_parser"] =
- ExposePublicParser(descriptor->message_type()->file()) ? "PARSER"
- : "parser()";
+ ExposePublicParser(descriptor->message_type()->file()) ? "PARSER"
+ : "parser()";
- if (HasHasbit(descriptor)) {
+ 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);
@@ -104,7 +104,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["name"] + "_ != null";
}
- // For repeated builders, one bit is used for whether the array is immutable.
+ // 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);
@@ -126,105 +126,105 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
// ===================================================================
-ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator(
- 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_);
+ImmutableMessageFieldGenerator::ImmutableMessageFieldGenerator(
+ 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_);
}
ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {}
int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ return HasHasbit(descriptor_) ? 1 : 0;
}
int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
+ return GetNumBitsForMessage();
}
-void ImmutableMessageFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
+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.
- 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");
+ 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_);
- printer->Print(
- variables_,
- "$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder();\n");
+ 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");
+void ImmutableMessageFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private $type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHasbit(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ if (HasHasbit(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
} else {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $name$_ != null;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $name$_ != null;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
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");
+ "@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(
- io::Printer* printer, const char* regular_case,
+ io::Printer* printer, const char* regular_case,
const char* nested_builder_case) const {
printer->Print(variables_, "if ($name$Builder_ == null) {\n");
printer->Indent();
@@ -238,8 +238,8 @@ void ImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
}
void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
- io::Printer* printer, const char* method_prototype,
- const char* regular_case, const char* nested_builder_case,
+ 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);
printer->Annotate("{", "}", descriptor_);
@@ -253,602 +253,602 @@ void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
printer->Print("}\n");
}
-void ImmutableMessageFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+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.
- bool has_hasbit = HasHasbit(descriptor_);
+ bool has_hasbit = HasHasbit(descriptor_);
- printer->Print(variables_, "private $type$ $name$_;\n");
+ printer->Print(variables_, "private $type$ $name$_;\n");
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");
+ // 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()
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- if (has_hasbit) {
- printer->Print(
- variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_builder$;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ if (has_hasbit) {
+ printer->Print(
+ variables_,
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_builder$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
} else {
- printer->Print(
- variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $name$Builder_ != null || $name$_ != null;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $name$Builder_ != null || $name$_ != null;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
// 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);
+ 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_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value)",
+ 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",
+ "if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ "}\n"
+ "$name$_ = value;\n"
+ "$on_changed$\n",
- "$name$Builder_.setMessage(value);\n",
+ "$name$Builder_.setMessage(value);\n",
- "$set_has_field_bit_builder$\n"
- "return this;\n");
+ "$set_has_field_bit_builder$\n"
+ "return this;\n");
// Field.Builder setField(Field.Builder builderForValue)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " $type$.Builder builderForValue)",
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " $type$.Builder builderForValue)",
- "$name$_ = builderForValue.build();\n"
- "$on_changed$\n",
+ "$name$_ = builderForValue.build();\n"
+ "$on_changed$\n",
- "$name$Builder_.setMessage(builderForValue.build());\n",
+ "$name$Builder_.setMessage(builderForValue.build());\n",
- "$set_has_field_bit_builder$\n"
- "return this;\n");
+ "$set_has_field_bit_builder$\n"
+ "return this;\n");
// 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"
- " $name$_ != $type$.getDefaultInstance()) {\n"
- " $name$_ =\n"
- " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
- "} else {\n"
- " $name$_ = value;\n"
- "}\n"
- "$on_changed$\n"
- : "if ($name$_ != null) {\n"
- " $name$_ =\n"
- " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
- "} else {\n"
- " $name$_ = value;\n"
- "}\n"
- "$on_changed$\n",
-
- "$name$Builder_.mergeFrom(value);\n",
-
- "$set_has_field_bit_builder$\n"
- "return this;\n");
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public Builder ${$merge$capitalized_name$$}$($type$ value)",
+
+ has_hasbit
+ ? "if ($get_has_field_bit_builder$ &&\n"
+ " $name$_ != null &&\n"
+ " $name$_ != $type$.getDefaultInstance()) {\n"
+ " $name$_ =\n"
+ " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
+ "} else {\n"
+ " $name$_ = value;\n"
+ "}\n"
+ "$on_changed$\n"
+ : "if ($name$_ != null) {\n"
+ " $name$_ =\n"
+ " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
+ "} else {\n"
+ " $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_);
- PrintNestedBuilderFunction(
- printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
+ PrintNestedBuilderFunction(
+ printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
- "$name$_ = null;\n"
- "$on_changed$\n",
+ "$name$_ = null;\n"
+ "$on_changed$\n",
- has_hasbit ? "$name$Builder_.clear();\n"
- : "$name$_ = null;\n"
- "$name$Builder_ = null;\n",
+ has_hasbit ? "$name$Builder_.clear();\n"
+ : "$name$_ = null;\n"
+ "$name$Builder_ = null;\n",
- "$clear_has_field_bit_builder$\n"
- "return this;\n");
+ "$clear_has_field_bit_builder$\n"
+ "return this;\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public $type$.Builder "
- "${$get$capitalized_name$Builder$}$() {\n"
- " $set_has_field_bit_builder$\n"
- " $on_changed$\n"
- " return get$capitalized_name$FieldBuilder().getBuilder();\n"
- "}\n");
+ "$deprecation$public $type$.Builder "
+ "${$get$capitalized_name$Builder$}$() {\n"
+ " $set_has_field_bit_builder$\n"
+ " $on_changed$\n"
+ " return get$capitalized_name$FieldBuilder().getBuilder();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$() {\n"
- " if ($name$Builder_ != null) {\n"
- " return $name$Builder_.getMessageOrBuilder();\n"
- " } else {\n"
- " return $name$_ == null ?\n"
- " $type$.getDefaultInstance() : $name$_;\n"
- " }\n"
- "}\n");
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$() {\n"
+ " if ($name$Builder_ != null) {\n"
+ " return $name$Builder_.getMessageOrBuilder();\n"
+ " } else {\n"
+ " return $name$_ == null ?\n"
+ " $type$.getDefaultInstance() : $name$_;\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "private com.google.protobuf.SingleFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder> \n"
- " get$capitalized_name$FieldBuilder() {\n"
- " if ($name$Builder_ == null) {\n"
- " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder>(\n"
- " get$capitalized_name$(),\n"
- " getParentForChildren(),\n"
- " isClean());\n"
- " $name$_ = null;\n"
- " }\n"
- " return $name$Builder_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "private com.google.protobuf.SingleFieldBuilder$ver$<\n"
+ " $type$, $type$.Builder, $type$OrBuilder> \n"
+ " get$capitalized_name$FieldBuilder() {\n"
+ " if ($name$Builder_ == null) {\n"
+ " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\n"
+ " $type$, $type$.Builder, $type$OrBuilder>(\n"
+ " get$capitalized_name$(),\n"
+ " getParentForChildren(),\n"
+ " isClean());\n"
+ " $name$_ = null;\n"
+ " }\n"
+ " return $name$Builder_;\n"
+ "}\n");
+}
+
+void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
-void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
-}
-
-void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const {
- if (HasHasbit(descriptor_)) {
- printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
+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::GenerateInitializationCode(
+ io::Printer* printer) const {}
-void ImmutableMessageFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
- if (HasHasbit(descriptor_)) {
- PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
+void ImmutableMessageFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
+ if (HasHasbit(descriptor_)) {
+ PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
- "$name$Builder_.clear();\n");
+ "$name$Builder_.clear();\n");
printer->Print(variables_, "$clear_has_field_bit_builder$\n");
} else {
- PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
+ PrintNestedBuilderCondition(printer, "$name$_ = null;\n",
- "$name$_ = null;\n"
- "$name$Builder_ = null;\n");
+ "$name$_ = null;\n"
+ "$name$Builder_ = null;\n");
}
}
-void ImmutableMessageFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+void ImmutableMessageFieldGenerator::GenerateMergingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if (other.has$capitalized_name$()) {\n"
- " merge$capitalized_name$(other.get$capitalized_name$());\n"
- "}\n");
+ "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_)) {
- printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n");
- printer->Indent();
- PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
- "result.$name$_ = $name$Builder_.build();\n");
- printer->Outdent();
+void ImmutableMessageFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
+ if (HasHasbit(descriptor_)) {
+ printer->Print(variables_, "if ($get_has_field_bit_from_local$) {\n");
+ printer->Indent();
+ PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
+ "result.$name$_ = $name$Builder_.build();\n");
+ printer->Outdent();
printer->Print(variables_,
- " $set_has_field_bit_to_local$;\n"
- "}\n");
- } else {
- PrintNestedBuilderCondition(printer, "result.$name$_ = $name$_;\n",
- "result.$name$_ = $name$Builder_.build();\n");
+ " $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 {
+void ImmutableMessageFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$type$.Builder subBuilder = null;\n"
- "if ($is_field_present_message$) {\n"
- " subBuilder = $name$_.toBuilder();\n"
- "}\n");
+ "$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_,
- "$name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
- " extensionRegistry);\n");
+ "$name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
+ " extensionRegistry);\n");
} else {
printer->Print(variables_,
- "$name$_ = input.readMessage($type$.$get_parser$, "
- "extensionRegistry);\n");
+ "$name$_ = input.readMessage($type$.$get_parser$, "
+ "extensionRegistry);\n");
}
printer->Print(variables_,
- "if (subBuilder != null) {\n"
- " subBuilder.mergeFrom($name$_);\n"
- " $name$_ = subBuilder.buildPartial();\n"
- "}\n"
- "$set_has_field_bit_message$\n");
+ "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 {
+void ImmutableMessageFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
// noop for messages.
}
-void ImmutableMessageFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "if ($is_field_present_message$) {\n"
- " output.write$group_or_message$($number$, get$capitalized_name$());\n"
- "}\n");
+void ImmutableMessageFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "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(
- variables_,
- "if ($is_field_present_message$) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .compute$group_or_message$Size($number$, get$capitalized_name$());\n"
- "}\n");
+void ImmutableMessageFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if ($is_field_present_message$) {\n"
+ " size += com.google.protobuf.CodedOutputStream\n"
+ " .compute$group_or_message$Size($number$, get$capitalized_name$());\n"
+ "}\n");
}
-void ImmutableMessageFieldGenerator::GenerateEqualsCode(
- io::Printer* printer) const {
+void ImmutableMessageFieldGenerator::GenerateEqualsCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if (!get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$())) return false;\n");
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
}
-void ImmutableMessageFieldGenerator::GenerateHashCode(
- io::Printer* printer) const {
+void ImmutableMessageFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "hash = (37 * hash) + $constant_name$;\n"
- "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
+ "hash = (37 * hash) + $constant_name$;\n"
+ "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
}
-TProtoStringType ImmutableMessageFieldGenerator::GetBoxedType() const {
+TProtoStringType ImmutableMessageFieldGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->message_type());
}
// ===================================================================
-ImmutableMessageOneofFieldGenerator::ImmutableMessageOneofFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : ImmutableMessageFieldGenerator(descriptor, messageBitIndex,
- builderBitIndex, context) {
+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_);
}
-ImmutableMessageOneofFieldGenerator::~ImmutableMessageOneofFieldGenerator() {}
+ImmutableMessageOneofFieldGenerator::~ImmutableMessageOneofFieldGenerator() {}
-void ImmutableMessageOneofFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutableMessageOneofFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
+ "@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);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($type$) $oneof_name$_;\n"
- " }\n"
- " return $type$.getDefaultInstance();\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($type$) $oneof_name$_;\n"
+ " }\n"
+ " return $type$.getDefaultInstance();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($type$) $oneof_name$_;\n"
- " }\n"
- " return $type$.getDefaultInstance();\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($type$) $oneof_name$_;\n"
+ " }\n"
+ " return $type$.getDefaultInstance();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+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_,
- // 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");
+ // 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()
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $has_oneof_case_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Field getField()
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- PrintNestedBuilderFunction(
- printer,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$()",
+ 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 ($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",
+ "if ($has_oneof_case_message$) {\n"
+ " return $name$Builder_.getMessage();\n"
+ "}\n"
+ "return $type$.getDefaultInstance();\n",
- NULL);
+ NULL);
// Field.Builder setField(Field value)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$set$capitalized_name$$}$($type$ value)",
+ 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",
+ "if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ "}\n"
+ "$oneof_name$_ = value;\n"
+ "$on_changed$\n",
- "$name$Builder_.setMessage(value);\n",
+ "$name$Builder_.setMessage(value);\n",
- "$set_oneof_case_message$;\n"
- "return this;\n");
+ "$set_oneof_case_message$;\n"
+ "return this;\n");
// Field.Builder setField(Field.Builder builderForValue)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " $type$.Builder builderForValue)",
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " $type$.Builder builderForValue)",
- "$oneof_name$_ = builderForValue.build();\n"
- "$on_changed$\n",
+ "$oneof_name$_ = builderForValue.build();\n"
+ "$on_changed$\n",
- "$name$Builder_.setMessage(builderForValue.build());\n",
+ "$name$Builder_.setMessage(builderForValue.build());\n",
- "$set_oneof_case_message$;\n"
- "return this;\n");
+ "$set_oneof_case_message$;\n"
+ "return this;\n");
// 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"
- " .mergeFrom(value).buildPartial();\n"
- "} else {\n"
- " $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");
+ 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"
+ " .mergeFrom(value).buildPartial();\n"
+ "} else {\n"
+ " $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_);
- PrintNestedBuilderFunction(
- printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
+ 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"
+ " $on_changed$\n"
+ "}\n",
- "if ($has_oneof_case_message$) {\n"
- " $clear_oneof_case_message$;\n"
- " $oneof_name$_ = null;\n"
- "}\n"
- "$name$Builder_.clear();\n",
+ "if ($has_oneof_case_message$) {\n"
+ " $clear_oneof_case_message$;\n"
+ " $oneof_name$_ = null;\n"
+ "}\n"
+ "$name$Builder_.clear();\n",
- "return this;\n");
+ "return this;\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public $type$.Builder "
- "${$get$capitalized_name$Builder$}$() {\n"
- " return get$capitalized_name$FieldBuilder().getBuilder();\n"
- "}\n");
+ "$deprecation$public $type$.Builder "
+ "${$get$capitalized_name$Builder$}$() {\n"
+ " return get$capitalized_name$FieldBuilder().getBuilder();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$() {\n"
- " if (($has_oneof_case_message$) && ($name$Builder_ != null)) {\n"
- " return $name$Builder_.getMessageOrBuilder();\n"
- " } else {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($type$) $oneof_name$_;\n"
- " }\n"
- " return $type$.getDefaultInstance();\n"
- " }\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$() {\n"
+ " if (($has_oneof_case_message$) && ($name$Builder_ != null)) {\n"
+ " return $name$Builder_.getMessageOrBuilder();\n"
+ " } else {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($type$) $oneof_name$_;\n"
+ " }\n"
+ " return $type$.getDefaultInstance();\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "private com.google.protobuf.SingleFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder> \n"
- " ${$get$capitalized_name$FieldBuilder$}$() {\n"
- " if ($name$Builder_ == null) {\n"
- " if (!($has_oneof_case_message$)) {\n"
- " $oneof_name$_ = $type$.getDefaultInstance();\n"
- " }\n"
- " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder>(\n"
- " ($type$) $oneof_name$_,\n"
- " getParentForChildren(),\n"
- " isClean());\n"
- " $oneof_name$_ = null;\n"
- " }\n"
- " $set_oneof_case_message$;\n"
- " $on_changed$;\n"
- " return $name$Builder_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "private com.google.protobuf.SingleFieldBuilder$ver$<\n"
+ " $type$, $type$.Builder, $type$OrBuilder> \n"
+ " ${$get$capitalized_name$FieldBuilder$}$() {\n"
+ " if ($name$Builder_ == null) {\n"
+ " if (!($has_oneof_case_message$)) {\n"
+ " $oneof_name$_ = $type$.getDefaultInstance();\n"
+ " }\n"
+ " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\n"
+ " $type$, $type$.Builder, $type$OrBuilder>(\n"
+ " ($type$) $oneof_name$_,\n"
+ " getParentForChildren(),\n"
+ " isClean());\n"
+ " $oneof_name$_ = null;\n"
+ " }\n"
+ " $set_oneof_case_message$;\n"
+ " $on_changed$;\n"
+ " return $name$Builder_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
- printer->Print(variables_, "if ($has_oneof_case_message$) {\n");
+void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
+ printer->Print(variables_, "if ($has_oneof_case_message$) {\n");
printer->Indent();
- PrintNestedBuilderCondition(
- printer, "result.$oneof_name$_ = $oneof_name$_;\n",
+ PrintNestedBuilderCondition(
+ printer, "result.$oneof_name$_ = $oneof_name$_;\n",
- "result.$oneof_name$_ = $name$Builder_.build();\n");
+ "result.$oneof_name$_ = $name$Builder_.build();\n");
printer->Outdent();
printer->Print("}\n");
}
-void ImmutableMessageOneofFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+void ImmutableMessageOneofFieldGenerator::GenerateMergingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "merge$capitalized_name$(other.get$capitalized_name$());\n");
+ "merge$capitalized_name$(other.get$capitalized_name$());\n");
}
-void ImmutableMessageOneofFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutableMessageOneofFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$type$.Builder subBuilder = null;\n"
- "if ($has_oneof_case_message$) {\n"
- " subBuilder = (($type$) $oneof_name$_).toBuilder();\n"
- "}\n");
+ "$type$.Builder subBuilder = null;\n"
+ "if ($has_oneof_case_message$) {\n"
+ " subBuilder = (($type$) $oneof_name$_).toBuilder();\n"
+ "}\n");
if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
- printer->Print(
- variables_,
- "$oneof_name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
- " extensionRegistry);\n");
+ printer->Print(
+ variables_,
+ "$oneof_name$_ = input.readGroup($number$, $type$.$get_parser$,\n"
+ " extensionRegistry);\n");
} else {
- printer->Print(
- variables_,
- "$oneof_name$_ =\n"
- " input.readMessage($type$.$get_parser$, extensionRegistry);\n");
+ printer->Print(
+ variables_,
+ "$oneof_name$_ =\n"
+ " input.readMessage($type$.$get_parser$, extensionRegistry);\n");
}
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");
+ "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(
- variables_,
- "if ($has_oneof_case_message$) {\n"
- " output.write$group_or_message$($number$, ($type$) $oneof_name$_);\n"
- "}\n");
+void ImmutableMessageOneofFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "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(
- variables_,
- "if ($has_oneof_case_message$) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .compute$group_or_message$Size($number$, ($type$) $oneof_name$_);\n"
- "}\n");
+void ImmutableMessageOneofFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if ($has_oneof_case_message$) {\n"
+ " 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()) {
+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::
- ~RepeatedImmutableMessageFieldGenerator() {}
+ ~RepeatedImmutableMessageFieldGenerator() {}
int RepeatedImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
return 0;
@@ -858,84 +858,84 @@ int RepeatedImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
return 1;
}
-void RepeatedImmutableMessageFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
+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_,
- "$deprecation$java.util.List<$type$> \n"
- " get$capitalized_name$List();\n");
+ "$deprecation$java.util.List<$type$> \n"
+ " get$capitalized_name$List();\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
+ "$deprecation$int get$capitalized_name$Count();\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$java.util.List<? extends $type$OrBuilder> \n"
- " get$capitalized_name$OrBuilderList();\n");
+ "$deprecation$java.util.List<? extends $type$OrBuilder> \n"
+ " get$capitalized_name$OrBuilderList();\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder(\n"
- " int index);\n");
+ 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");
+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_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return $name$_;\n" // note: unmodifiable list
- "}\n");
+ "@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_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
- " ${$get$capitalized_name$OrBuilderList$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
+ " ${$get$capitalized_name$OrBuilderList$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$(\n"
- " int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$(\n"
+ " int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
- io::Printer* printer, const char* regular_case,
+ io::Printer* printer, const char* regular_case,
const char* nested_builder_case) const {
printer->Print(variables_, "if ($name$Builder_ == null) {\n");
printer->Indent();
@@ -949,8 +949,8 @@ void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
}
void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
- io::Printer* printer, const char* method_prototype,
- const char* regular_case, const char* nested_builder_case,
+ 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);
printer->Annotate("{", "}", descriptor_);
@@ -964,527 +964,527 @@ void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
printer->Print("}\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+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.
- printer->Print(
- variables_,
- // Used when the builder is null.
- // One field is the list and the other 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.
- "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"
- " $set_mutable_bit_builder$;\n"
- " }\n"
- "}\n"
- "\n");
-
- printer->Print(
- variables_,
- // If this builder is non-null, it is used and the other fields are
- // ignored.
- "private com.google.protobuf.RepeatedFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\n"
- "\n");
+ printer->Print(
+ variables_,
+ // Used when the builder is null.
+ // One field is the list and the other 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.
+ "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"
+ " $set_mutable_bit_builder$;\n"
+ " }\n"
+ "}\n"
+ "\n");
+
+ printer->Print(
+ variables_,
+ // If this builder is non-null, it is used and the other fields are
+ // ignored.
+ "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_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$()",
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$()",
- "return java.util.Collections.unmodifiableList($name$_);\n",
- "return $name$Builder_.getMessageList();\n",
+ "return java.util.Collections.unmodifiableList($name$_);\n",
+ "return $name$Builder_.getMessageList();\n",
- NULL);
+ NULL);
// int getRepeatedFieldCount()
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer, "$deprecation$public int ${$get$capitalized_name$Count$}$()",
+ PrintNestedBuilderFunction(
+ printer, "$deprecation$public int ${$get$capitalized_name$Count$}$()",
- "return $name$_.size();\n", "return $name$Builder_.getCount();\n",
+ "return $name$_.size();\n", "return $name$Builder_.getCount();\n",
- NULL);
+ NULL);
// Field getRepeatedField(int index)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index)",
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index)",
- "return $name$_.get(index);\n",
+ "return $name$_.get(index);\n",
- "return $name$Builder_.getMessage(index);\n",
+ "return $name$Builder_.getMessage(index);\n",
- NULL);
+ NULL);
// Builder setRepeatedField(int index, Field value)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, $type$ value)",
- "if (value == null) {\n"
- " throw new NullPointerException();\n"
- "}\n"
- "ensure$capitalized_name$IsMutable();\n"
- "$name$_.set(index, value);\n"
- "$on_changed$\n",
- "$name$Builder_.setMessage(index, value);\n", "return this;\n");
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$ value)",
+ "if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ "}\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "$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_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, $type$.Builder builderForValue)",
+ 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",
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.set(index, builderForValue.build());\n"
+ "$on_changed$\n",
- "$name$Builder_.setMessage(index, builderForValue.build());\n",
+ "$name$Builder_.setMessage(index, builderForValue.build());\n",
- "return this;\n");
+ "return this;\n");
// Builder addRepeatedField(Field value)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$add$capitalized_name$$}$($type$ value)",
+ 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"
+ "if (value == null) {\n"
+ " throw new NullPointerException();\n"
+ "}\n"
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(value);\n"
- "$on_changed$\n",
+ "$on_changed$\n",
- "$name$Builder_.addMessage(value);\n",
+ "$name$Builder_.addMessage(value);\n",
- "return this;\n");
+ "return this;\n");
// Builder addRepeatedField(int index, Field value)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
- " int index, $type$ value)",
+ 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",
+ "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",
+ "$name$Builder_.addMessage(index, value);\n",
- "return this;\n");
+ "return this;\n");
// Builder addRepeatedField(Field.Builder builderForValue)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
- " $type$.Builder builderForValue)",
+ 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",
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(builderForValue.build());\n"
+ "$on_changed$\n",
- "$name$Builder_.addMessage(builderForValue.build());\n",
+ "$name$Builder_.addMessage(builderForValue.build());\n",
- "return this;\n");
+ "return this;\n");
// Builder addRepeatedField(int index, Field.Builder builderForValue)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
- " int index, $type$.Builder builderForValue)",
+ 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",
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.add(index, builderForValue.build());\n"
+ "$on_changed$\n",
- "$name$Builder_.addMessage(index, builderForValue.build());\n",
+ "$name$Builder_.addMessage(index, builderForValue.build());\n",
- "return this;\n");
+ "return this;\n");
// Builder addAllRepeatedField(Iterable<Field> values)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<? extends $type$> values)",
+ 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",
+ "ensure$capitalized_name$IsMutable();\n"
+ "com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
+ " values, $name$_);\n"
+ "$on_changed$\n",
- "$name$Builder_.addAllMessages(values);\n",
+ "$name$Builder_.addAllMessages(values);\n",
- "return this;\n");
+ "return this;\n");
// Builder clearAllRepeatedField()
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
+ PrintNestedBuilderFunction(
+ printer, "$deprecation$public Builder ${$clear$capitalized_name$$}$()",
- "$name$_ = java.util.Collections.emptyList();\n"
- "$clear_mutable_bit_builder$;\n"
- "$on_changed$\n",
+ "$name$_ = java.util.Collections.emptyList();\n"
+ "$clear_mutable_bit_builder$;\n"
+ "$on_changed$\n",
- "$name$Builder_.clear();\n",
+ "$name$Builder_.clear();\n",
- "return this;\n");
+ "return this;\n");
// Builder removeRepeatedField(int index)
WriteFieldDocComment(printer, descriptor_);
- PrintNestedBuilderFunction(
- printer,
- "$deprecation$public Builder ${$remove$capitalized_name$$}$(int index)",
+ PrintNestedBuilderFunction(
+ printer,
+ "$deprecation$public Builder ${$remove$capitalized_name$$}$(int index)",
- "ensure$capitalized_name$IsMutable();\n"
- "$name$_.remove(index);\n"
- "$on_changed$\n",
+ "ensure$capitalized_name$IsMutable();\n"
+ "$name$_.remove(index);\n"
+ "$on_changed$\n",
- "$name$Builder_.remove(index);\n",
+ "$name$Builder_.remove(index);\n",
- "return this;\n");
+ "return this;\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public $type$.Builder ${$get$capitalized_name$Builder$}$(\n"
- " int index) {\n"
- " return get$capitalized_name$FieldBuilder().getBuilder(index);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public $type$.Builder ${$get$capitalized_name$Builder$}$(\n"
+ " int index) {\n"
+ " return get$capitalized_name$FieldBuilder().getBuilder(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$(\n"
- " int index) {\n"
- " if ($name$Builder_ == null) {\n"
- " return $name$_.get(index);"
- " } else {\n"
- " return $name$Builder_.getMessageOrBuilder(index);\n"
- " }\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$public $type$OrBuilder "
+ "${$get$capitalized_name$OrBuilder$}$(\n"
+ " int index) {\n"
+ " if ($name$Builder_ == null) {\n"
+ " return $name$_.get(index);"
+ " } else {\n"
+ " return $name$Builder_.getMessageOrBuilder(index);\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
- " ${$get$capitalized_name$OrBuilderList$}$() {\n"
- " if ($name$Builder_ != null) {\n"
- " return $name$Builder_.getMessageOrBuilderList();\n"
- " } else {\n"
- " return java.util.Collections.unmodifiableList($name$_);\n"
- " }\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
+ " ${$get$capitalized_name$OrBuilderList$}$() {\n"
+ " if ($name$Builder_ != null) {\n"
+ " return $name$Builder_.getMessageOrBuilderList();\n"
+ " } else {\n"
+ " return java.util.Collections.unmodifiableList($name$_);\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$deprecation$public $type$.Builder "
- "${$add$capitalized_name$Builder$}$() {\n"
- " return get$capitalized_name$FieldBuilder().addBuilder(\n"
- " $type$.getDefaultInstance());\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$public $type$.Builder "
+ "${$add$capitalized_name$Builder$}$() {\n"
+ " return get$capitalized_name$FieldBuilder().addBuilder(\n"
+ " $type$.getDefaultInstance());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public $type$.Builder ${$add$capitalized_name$Builder$}$(\n"
- " int index) {\n"
- " return get$capitalized_name$FieldBuilder().addBuilder(\n"
- " index, $type$.getDefaultInstance());\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public $type$.Builder ${$add$capitalized_name$Builder$}$(\n"
+ " int index) {\n"
+ " return get$capitalized_name$FieldBuilder().addBuilder(\n"
+ " index, $type$.getDefaultInstance());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public java.util.List<$type$.Builder> \n"
- " ${$get$capitalized_name$BuilderList$}$() {\n"
- " return get$capitalized_name$FieldBuilder().getBuilderList();\n"
- "}\n"
- "private com.google.protobuf.RepeatedFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder> \n"
- " get$capitalized_name$FieldBuilder() {\n"
- " if ($name$Builder_ == null) {\n"
- " $name$Builder_ = new "
- "com.google.protobuf.RepeatedFieldBuilder$ver$<\n"
- " $type$, $type$.Builder, $type$OrBuilder>(\n"
- " $name$_,\n"
- " $get_mutable_bit_builder$,\n"
- " getParentForChildren(),\n"
- " isClean());\n"
- " $name$_ = null;\n"
- " }\n"
- " return $name$Builder_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public java.util.List<$type$.Builder> \n"
+ " ${$get$capitalized_name$BuilderList$}$() {\n"
+ " return get$capitalized_name$FieldBuilder().getBuilderList();\n"
+ "}\n"
+ "private com.google.protobuf.RepeatedFieldBuilder$ver$<\n"
+ " $type$, $type$.Builder, $type$OrBuilder> \n"
+ " get$capitalized_name$FieldBuilder() {\n"
+ " if ($name$Builder_ == null) {\n"
+ " $name$Builder_ = new "
+ "com.google.protobuf.RepeatedFieldBuilder$ver$<\n"
+ " $type$, $type$.Builder, $type$OrBuilder>(\n"
+ " $name$_,\n"
+ " $get_mutable_bit_builder$,\n"
+ " getParentForChildren(),\n"
+ " isClean());\n"
+ " $name$_ = null;\n"
+ " }\n"
+ " return $name$Builder_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
void RepeatedImmutableMessageFieldGenerator::
- GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
- printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
+ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
+ printer->Print(variables_, "get$capitalized_name$FieldBuilder();\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableMessageFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void RepeatedImmutableMessageFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
PrintNestedBuilderCondition(printer,
- "$name$_ = java.util.Collections.emptyList();\n"
- "$clear_mutable_bit_builder$;\n",
+ "$name$_ = java.util.Collections.emptyList();\n"
+ "$clear_mutable_bit_builder$;\n",
- "$name$Builder_.clear();\n");
+ "$name$Builder_.clear();\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+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.
- PrintNestedBuilderCondition(
- printer,
- "if (!other.$name$_.isEmpty()) {\n"
- " if ($name$_.isEmpty()) {\n"
- " $name$_ = other.$name$_;\n"
- " $clear_mutable_bit_builder$;\n"
- " } else {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.addAll(other.$name$_);\n"
- " }\n"
- " $on_changed$\n"
- "}\n",
-
- "if (!other.$name$_.isEmpty()) {\n"
- " if ($name$Builder_.isEmpty()) {\n"
- " $name$Builder_.dispose();\n"
- " $name$Builder_ = null;\n"
- " $name$_ = other.$name$_;\n"
- " $clear_mutable_bit_builder$;\n"
- " $name$Builder_ = \n"
- " com.google.protobuf.GeneratedMessage$ver$.alwaysUseFieldBuilders "
- "?\n"
- " get$capitalized_name$FieldBuilder() : null;\n"
- " } else {\n"
- " $name$Builder_.addAllMessages(other.$name$_);\n"
- " }\n"
- "}\n");
+ PrintNestedBuilderCondition(
+ printer,
+ "if (!other.$name$_.isEmpty()) {\n"
+ " if ($name$_.isEmpty()) {\n"
+ " $name$_ = other.$name$_;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " } else {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.addAll(other.$name$_);\n"
+ " }\n"
+ " $on_changed$\n"
+ "}\n",
+
+ "if (!other.$name$_.isEmpty()) {\n"
+ " if ($name$Builder_.isEmpty()) {\n"
+ " $name$Builder_.dispose();\n"
+ " $name$Builder_ = null;\n"
+ " $name$_ = other.$name$_;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " $name$Builder_ = \n"
+ " com.google.protobuf.GeneratedMessage$ver$.alwaysUseFieldBuilders "
+ "?\n"
+ " get$capitalized_name$FieldBuilder() : null;\n"
+ " } else {\n"
+ " $name$Builder_.addAllMessages(other.$name$_);\n"
+ " }\n"
+ "}\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+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.
- PrintNestedBuilderCondition(
- printer,
- "if ($get_mutable_bit_builder$) {\n"
- " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
- " $clear_mutable_bit_builder$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n",
-
- "result.$name$_ = $name$Builder_.build();\n");
+ PrintNestedBuilderCondition(
+ printer,
+ "if ($get_mutable_bit_builder$) {\n"
+ " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
+ " $clear_mutable_bit_builder$;\n"
+ "}\n"
+ "result.$name$_ = $name$_;\n",
+
+ "result.$name$_ = $name$Builder_.build();\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void RepeatedImmutableMessageFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = new java.util.ArrayList<$type$>();\n"
- " $set_mutable_bit_parser$;\n"
- "}\n");
+ "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) {
- printer->Print(
- variables_,
- "$name$_.add(input.readGroup($number$, $type$.$get_parser$,\n"
- " extensionRegistry));\n");
+ printer->Print(
+ variables_,
+ "$name$_.add(input.readGroup($number$, $type$.$get_parser$,\n"
+ " extensionRegistry));\n");
} else {
- printer->Print(
- variables_,
- "$name$_.add(\n"
- " input.readMessage($type$.$get_parser$, extensionRegistry));\n");
+ printer->Print(
+ variables_,
+ "$name$_.add(\n"
+ " input.readMessage($type$.$get_parser$, extensionRegistry));\n");
}
}
-void RepeatedImmutableMessageFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
- "}\n");
+void RepeatedImmutableMessageFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if ($get_mutable_bit_parser$) {\n"
+ " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
+ "}\n");
}
-void RepeatedImmutableMessageFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableMessageFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " output.write$group_or_message$($number$, $name$_.get(i));\n"
- "}\n");
+ "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(
- variables_,
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .compute$group_or_message$Size($number$, $name$_.get(i));\n"
- "}\n");
+void RepeatedImmutableMessageFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
+ " 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::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(
- variables_,
- "if (get$capitalized_name$Count() > 0) {\n"
- " hash = (37 * hash) + $constant_name$;\n"
- " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
- "}\n");
+void RepeatedImmutableMessageFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if (get$capitalized_name$Count() > 0) {\n"
+ " hash = (37 * hash) + $constant_name$;\n"
+ " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
+ "}\n");
}
-TProtoStringType RepeatedImmutableMessageFieldGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutableMessageFieldGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->message_type());
}
-void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: $kt_type$) {\n"
- " add(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " addAll(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
+void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: $kt_type$) {\n"
+ " add(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " addAll(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
+}
+
} // namespace java
} // namespace compiler
} // namespace protobuf
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 5d67d64aed..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
@@ -36,35 +36,35 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
#include <map>
-#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
public:
- explicit ImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- int builderBitIndex,
- Context* context);
+ explicit ImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ int builderBitIndex,
+ Context* context);
~ImmutableMessageFieldGenerator();
- // implements ImmutableFieldGenerator
- // ---------------------------------------
+ // implements ImmutableFieldGenerator
+ // ---------------------------------------
int GetNumBitsForMessage() const;
int GetNumBitsForBuilder() const;
void GenerateInterfaceMembers(io::Printer* printer) const;
@@ -81,23 +81,23 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- void GenerateKotlinDslMembers(io::Printer* printer) const;
+ void GenerateKotlinDslMembers(io::Printer* printer) const;
- TProtoStringType GetBoxedType() const;
+ TProtoStringType GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
void PrintNestedBuilderCondition(io::Printer* printer,
- const char* regular_case,
- const char* nested_builder_case) const;
+ const char* regular_case,
+ const char* nested_builder_case) const;
void PrintNestedBuilderFunction(io::Printer* printer,
- const char* method_prototype,
- const char* regular_case,
- const char* nested_builder_case,
- const char* trailing_code) const;
+ const char* method_prototype,
+ const char* regular_case,
+ const char* nested_builder_case,
+ const char* trailing_code) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator);
@@ -106,9 +106,9 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
class ImmutableMessageOneofFieldGenerator
: public ImmutableMessageFieldGenerator {
public:
- ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- Context* context);
+ ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex, int builderBitIndex,
+ Context* context);
~ImmutableMessageOneofFieldGenerator();
void GenerateMembers(io::Printer* printer) const;
@@ -128,43 +128,43 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
explicit RepeatedImmutableMessageFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
- ~RepeatedImmutableMessageFieldGenerator() override;
+ ~RepeatedImmutableMessageFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
- int GetNumBitsForMessage() const override;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- 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;
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
void PrintNestedBuilderCondition(io::Printer* printer,
- const char* regular_case,
- const char* nested_builder_case) const;
+ const char* regular_case,
+ const char* nested_builder_case) const;
void PrintNestedBuilderFunction(io::Printer* printer,
- const char* method_prototype,
- const char* regular_case,
- const char* nested_builder_case,
- const char* trailing_code) const;
+ const char* method_prototype,
+ const char* regular_case,
+ const char* nested_builder_case,
+ const char* trailing_code) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldGenerator);
@@ -173,6 +173,6 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 e9e02b96d5..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
@@ -32,19 +32,19 @@
// 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 <google/protobuf/compiler/java/java_message_field_lite.h>
+
+#include <cstdint>
#include <map>
-#include <string>
+#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>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -53,32 +53,32 @@ namespace java {
namespace {
-void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
- int builderBitIndex, const FieldGeneratorInfo* info,
+void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
+ int builderBitIndex, const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
name_resolver->GetImmutableClassName(descriptor->message_type());
- (*variables)["kt_type"] = (*variables)["type"];
+ (*variables)["kt_type"] = (*variables)["type"];
(*variables)["mutable_type"] =
name_resolver->GetMutableClassName(descriptor->message_type());
(*variables)["group_or_message"] =
- (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? "Group"
- : "Message";
+ (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ? "Group"
+ : "Message";
// 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"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
- if (HasHasbit(descriptor)) {
+ if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
@@ -101,780 +101,780 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
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";
+
+ // 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
// ===================================================================
-ImmutableMessageFieldLiteGenerator::ImmutableMessageFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : descriptor_(descriptor),
- messageBitIndex_(messageBitIndex),
- name_resolver_(context->GetNameResolver()) {
- SetMessageVariables(descriptor, messageBitIndex, 0,
- context->GetFieldGeneratorInfo(descriptor),
- name_resolver_, &variables_);
+ImmutableMessageFieldLiteGenerator::ImmutableMessageFieldLiteGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
+ : descriptor_(descriptor),
+ messageBitIndex_(messageBitIndex),
+ name_resolver_(context->GetNameResolver()) {
+ SetMessageVariables(descriptor, messageBitIndex, 0,
+ context->GetFieldGeneratorInfo(descriptor),
+ name_resolver_, &variables_);
}
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;
+ // 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::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 {
+void ImmutableMessageFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
- printer->Print(variables_, "private $type$ $name$_;\n");
+ printer->Print(variables_, "private $type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHasbit(descriptor_)) {
+ if (HasHasbit(descriptor_)) {
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
} else {
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $name$_ != null;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $name$_ != null;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
// 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");
+ "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_);
- printer->Print(
- variables_,
- "@java.lang.SuppressWarnings({\"ReferenceEquality\"})\n"
- "private void merge$capitalized_name$($type$ value) {\n"
- " $null_check$"
- " if ($name$_ != null &&\n"
- " $name$_ != $type$.getDefaultInstance()) {\n"
- " $name$_ =\n"
- " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
- " } else {\n"
- " $name$_ = value;\n"
- " }\n"
- " $set_has_field_bit_message$\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.SuppressWarnings({\"ReferenceEquality\"})\n"
+ "private void merge$capitalized_name$($type$ value) {\n"
+ " $null_check$"
+ " if ($name$_ != null &&\n"
+ " $name$_ != $type$.getDefaultInstance()) {\n"
+ " $name$_ =\n"
+ " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
+ " } else {\n"
+ " $name$_ = value;\n"
+ " }\n"
+ " $set_has_field_bit_message$\n"
+ "}\n");
// Field.Builder clearField()
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "private void clear$capitalized_name$() {"
- " $name$_ = null;\n"
- " $clear_has_field_bit_message$\n"
- "}\n");
+ "private void clear$capitalized_name$() {"
+ " $name$_ = null;\n"
+ " $clear_has_field_bit_message$\n"
+ "}\n");
}
-void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+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_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
+ "@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_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
+ "@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_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- " }\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ " }\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.set$capitalized_name$(builderForValue.build());\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " $type$.Builder builderForValue) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(builderForValue.build());\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Field.Builder mergeField(Field value)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$merge$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.merge$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$merge$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.merge$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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");
+ "$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_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
-}
-
-void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- if (HasHasbit(descriptor_)) {
- WriteIntToUtf16CharSequence(messageBitIndex_, output);
+void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+}
+
+void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ if (HasHasbit(descriptor_)) {
+ WriteIntToUtf16CharSequence(messageBitIndex_, output);
}
- printer->Print(variables_, "\"$name$_\",\n");
+ printer->Print(variables_, "\"$name$_\",\n");
}
-void ImmutableMessageFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {}
+void ImmutableMessageFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {}
-TProtoStringType ImmutableMessageFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType ImmutableMessageFieldLiteGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->message_type());
}
// ===================================================================
ImmutableMessageOneofFieldLiteGenerator::
- ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context)
- : ImmutableMessageFieldLiteGenerator(descriptor, messageBitIndex, context) {
+ 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::
- ~ImmutableMessageOneofFieldLiteGenerator() {}
+ ~ImmutableMessageOneofFieldLiteGenerator() {}
-void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
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"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $has_oneof_case_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($type$) $oneof_name$_;\n"
- " }\n"
- " return $type$.getDefaultInstance();\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($type$) $oneof_name$_;\n"
+ " }\n"
+ " return $type$.getDefaultInstance();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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");
+ "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_);
- printer->Print(
- variables_,
- "private void merge$capitalized_name$($type$ value) {\n"
- " $null_check$"
- " if ($has_oneof_case_message$ &&\n"
- " $oneof_name$_ != $type$.getDefaultInstance()) {\n"
- " $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_)\n"
- " .mergeFrom(value).buildPartial();\n"
- " } else {\n"
- " $oneof_name$_ = value;\n"
- " }\n"
- " $set_oneof_case_message$;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "private void merge$capitalized_name$($type$ value) {\n"
+ " $null_check$"
+ " if ($has_oneof_case_message$ &&\n"
+ " $oneof_name$_ != $type$.getDefaultInstance()) {\n"
+ " $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_)\n"
+ " .mergeFrom(value).buildPartial();\n"
+ " } else {\n"
+ " $oneof_name$_ = value;\n"
+ " }\n"
+ " $set_oneof_case_message$;\n"
+ "}\n");
// 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");
+ "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);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
- printer->Print(variables_, "$oneof_stored_type$.class,\n");
-}
-
-void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+void ImmutableMessageOneofFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
+ printer->Print(variables_, "$oneof_stored_type$.class,\n");
+}
+
+void ImmutableMessageOneofFieldLiteGenerator::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_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
+ "@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_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
+ "@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_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.set$capitalized_name$(builderForValue.build());\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " $type$.Builder builderForValue) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(builderForValue.build());\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Field.Builder mergeField(Field value)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$merge$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.merge$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$merge$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.merge$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Field.Builder clearField()
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
// ===================================================================
RepeatedImmutableMessageFieldLiteGenerator::
- RepeatedImmutableMessageFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetMessageVariables(descriptor, messageBitIndex, 0,
+ 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::
- ~RepeatedImmutableMessageFieldLiteGenerator() {}
+ ~RepeatedImmutableMessageFieldLiteGenerator() {}
int RepeatedImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {
return 0;
}
-void RepeatedImmutableMessageFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
+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_,
- "$deprecation$java.util.List<$type$> \n"
- " get$capitalized_name$List();\n");
+ "$deprecation$java.util.List<$type$> \n"
+ " get$capitalized_name$List();\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
+ "$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");
+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_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return $name$_;\n" // note: unmodifiable list
- "}\n");
+ "@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_);
- printer->Print(
- variables_,
- "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
- " ${$get$capitalized_name$OrBuilderList$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
+ " ${$get$capitalized_name$OrBuilderList$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public $type$OrBuilder "
- "${$get$capitalized_name$OrBuilder$}$(\n"
- " int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ "$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"
- // Use a temporary to avoid a redundant iget-object.
- " com.google.protobuf.Internal.ProtobufList<$type$> tmp = $name$_;\n"
- " if (!tmp.isModifiable()) {\n"
- " $name$_ =\n"
- " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
- " }\n"
- "}\n"
- "\n");
+ printer->Print(
+ variables_,
+ "private void ensure$capitalized_name$IsMutable() {\n"
+ // Use a temporary to avoid a redundant iget-object.
+ " com.google.protobuf.Internal.ProtobufList<$type$> tmp = $name$_;\n"
+ " if (!tmp.isModifiable()) {\n"
+ " $name$_ =\n"
+ " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
+ " }\n"
+ "}\n"
+ "\n");
// 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");
+ "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_,
- "private void add$capitalized_name$($type$ value) {\n"
- " $null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value);\n"
- "}\n");
+ "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_,
- "private void add$capitalized_name$(\n"
- " int index, $type$ value) {\n"
- " $null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(index, value);\n"
- "}\n");
+ "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_,
- "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");
+ "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_,
- "private void clear$capitalized_name$() {\n"
- " $name$_ = emptyProtobufList();\n"
- "}\n");
+ "private void clear$capitalized_name$() {\n"
+ " $name$_ = emptyProtobufList();\n"
+ "}\n");
// 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");
+ "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 {
+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_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$type$> "
- "${$get$capitalized_name$List$}$() {\n"
- " return java.util.Collections.unmodifiableList(\n"
- " instance.get$capitalized_name$List());\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$type$> "
+ "${$get$capitalized_name$List$}$() {\n"
+ " return java.util.Collections.unmodifiableList(\n"
+ " instance.get$capitalized_name$List());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// int getRepeatedFieldCount()
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return instance.get$capitalized_name$Count();\n"
- "}");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return instance.get$capitalized_name$Count();\n"
+ "}");
printer->Annotate("{", "}", descriptor_);
// Field getRepeatedField(int index)
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return instance.get$capitalized_name$(index);\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return instance.get$capitalized_name$(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.set$capitalized_name$(index, value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(index, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.set$capitalized_name$(index,\n"
- " builderForValue.build());\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$.Builder builderForValue) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(index,\n"
+ " builderForValue.build());\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Builder addRepeatedField(Field value)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.add$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.add$capitalized_name$(index, value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
+ " int index, $type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(index, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Builder addRepeatedField(Field.Builder builderForValue)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
- " $type$.Builder builderForValue) {\n"
- " copyOnWrite();\n"
- " instance.add$capitalized_name$(builderForValue.build());\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
+ " $type$.Builder builderForValue) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(builderForValue.build());\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.add$capitalized_name$(index,\n"
- " builderForValue.build());\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
+ " int index, $type$.Builder builderForValue) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(index,\n"
+ " builderForValue.build());\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// 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"
- " instance.addAll$capitalized_name$(values);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<? extends $type$> values) {\n"
+ " copyOnWrite();\n"
+ " instance.addAll$capitalized_name$(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Builder clearAllRepeatedField()
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
// Builder removeRepeatedField(int index)
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$remove$capitalized_name$$}$(int index) {\n"
- " copyOnWrite();\n"
- " instance.remove$capitalized_name$(index);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$remove$capitalized_name$$}$(int index) {\n"
+ " copyOnWrite();\n"
+ " instance.remove$capitalized_name$(index);\n"
+ " 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);
+void RepeatedImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
printer->Print(variables_,
- "\"$name$_\",\n"
- "$type$.class,\n");
+ "\"$name$_\",\n"
+ "$type$.class,\n");
}
-void RepeatedImmutableMessageFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableMessageFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = emptyProtobufList();\n");
}
-TProtoStringType RepeatedImmutableMessageFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutableMessageFieldLiteGenerator::GetBoxedType() const {
return name_resolver_->GetImmutableClassName(descriptor_->message_type());
}
-void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: $kt_type$) {\n"
- " add(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " addAll(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
+void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: $kt_type$) {\n"
+ " add(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " addAll(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
+}
+
} // namespace java
} // namespace compiler
} // namespace protobuf
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 5898eb6a31..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
@@ -35,51 +35,51 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
-#include <cstdint>
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
public:
- explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context);
+ explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context);
~ImmutableMessageFieldLiteGenerator();
- // implements ImmutableFieldLiteGenerator
- // ------------------------------------
+ // 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;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const;
- void GenerateKotlinDslMembers(io::Printer* printer) const;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const;
+ void GenerateKotlinDslMembers(io::Printer* printer) const;
- TProtoStringType GetBoxedType() const;
+ TProtoStringType GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
const int messageBitIndex_;
ClassNameResolver* name_resolver_;
@@ -90,15 +90,15 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
class ImmutableMessageOneofFieldLiteGenerator
: public ImmutableMessageFieldLiteGenerator {
public:
- ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context);
+ ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context);
~ImmutableMessageOneofFieldLiteGenerator();
void GenerateMembers(io::Printer* printer) const;
void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);
@@ -108,24 +108,24 @@ class RepeatedImmutableMessageFieldLiteGenerator
: public ImmutableFieldLiteGenerator {
public:
explicit RepeatedImmutableMessageFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
- ~RepeatedImmutableMessageFieldLiteGenerator() override;
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ ~RepeatedImmutableMessageFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
- int GetNumBitsForMessage() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const override;
+ void GenerateKotlinDslMembers(io::Printer* printer) const override;
- TProtoStringType GetBoxedType() const override;
+ TProtoStringType GetBoxedType() const override;
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
private:
@@ -135,6 +135,6 @@ class RepeatedImmutableMessageFieldLiteGenerator
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 eacaa6900b..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
@@ -32,29 +32,29 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/java/java_message_lite.h>
+#include <google/protobuf/compiler/java/java_message_lite.h>
#include <algorithm>
-#include <cstdint>
+#include <cstdint>
#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>
-#include <google/protobuf/compiler/java/java_extension_lite.h>
-#include <google/protobuf/compiler/java/java_generator_factory.h>
-#include <google/protobuf/compiler/java/java_helpers.h>
-#include <google/protobuf/compiler/java/java_message_builder.h>
-#include <google/protobuf/compiler/java/java_message_builder_lite.h>
-#include <google/protobuf/compiler/java/java_name_resolver.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
+#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>
+#include <google/protobuf/compiler/java/java_extension_lite.h>
+#include <google/protobuf/compiler/java/java_generator_factory.h>
+#include <google/protobuf/compiler/java/java_helpers.h>
+#include <google/protobuf/compiler/java/java_message_builder.h>
+#include <google/protobuf/compiler/java/java_message_builder_lite.h>
+#include <google/protobuf/compiler/java/java_name_resolver.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
namespace google {
namespace protobuf {
@@ -67,18 +67,18 @@ using internal::WireFormatLite;
// ===================================================================
ImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator(
const Descriptor* descriptor, Context* context)
- : MessageGenerator(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()),
- field_generators_(descriptor, 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.";
- for (int i = 0; i < descriptor_->field_count(); i++) {
- if (IsRealOneof(descriptor_->field(i))) {
- oneofs_.insert(descriptor_->field(i)->containing_oneof());
- }
- }
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ if (IsRealOneof(descriptor_->field(i))) {
+ oneofs_.insert(descriptor_->field(i)->containing_oneof());
+ }
+ }
}
ImmutableMessageLiteGenerator::~ImmutableMessageLiteGenerator() {}
@@ -118,37 +118,37 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
" com.google.protobuf.GeneratedMessageLite.\n"
" ExtendableMessageOrBuilder<\n"
" $classname$, $classname$.Builder> {\n",
- "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
+ "deprecation",
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
"extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
- "classname", descriptor_->name(), "{", "", "}", "");
+ "classname", descriptor_->name(), "{", "", "}", "");
} else {
printer->Print(
"$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n"
" $extra_interfaces$\n"
" com.google.protobuf.MessageLiteOrBuilder {\n",
- "deprecation",
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
+ "deprecation",
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "",
"extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_),
- "classname", descriptor_->name(), "{", "", "}", "");
+ "classname", descriptor_->name(), "{", "", "}", "");
}
printer->Annotate("{", "}", descriptor_);
printer->Indent();
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("\n");
- field_generators_.get(descriptor_->field(i))
- .GenerateInterfaceMembers(printer);
- }
- for (auto oneof : oneofs_) {
- printer->Print(
- "\n"
- "public $classname$.$oneof_capitalized_name$Case "
- "get$oneof_capitalized_name$Case();\n",
- "oneof_capitalized_name",
- context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
- context_->GetNameResolver()->GetImmutableClassName(descriptor_));
- }
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("\n");
+ field_generators_.get(descriptor_->field(i))
+ .GenerateInterfaceMembers(printer);
+ }
+ for (auto oneof : oneofs_) {
+ printer->Print(
+ "\n"
+ "public $classname$.$oneof_capitalized_name$Case "
+ "get$oneof_capitalized_name$Case();\n",
+ "oneof_capitalized_name",
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "classname",
+ context_->GetNameResolver()->GetImmutableClassName(descriptor_));
+ }
printer->Outdent();
printer->Print("}\n");
@@ -159,12 +159,12 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- std::map<TProtoStringType, TProtoStringType> variables;
+ std::map<TProtoStringType, TProtoStringType> variables;
variables["static"] = is_own_file ? " " : " static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
- variables["deprecation"] =
- descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "";
+ variables["deprecation"] =
+ descriptor_->options().deprecated() ? "@java.lang.Deprecated " : "";
WriteMessageDocComment(printer, descriptor_);
MaybePrintGeneratedAnnotation(context_, printer, descriptor_,
@@ -172,21 +172,21 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
// The builder_type stores the super type name of the nested Builder class.
- TProtoStringType builder_type;
+ TProtoStringType builder_type;
if (descriptor_->extension_range_count() > 0) {
- printer->Print(
- variables,
- "$deprecation$public $static$final class $classname$ extends\n"
- " com.google.protobuf.GeneratedMessageLite.ExtendableMessage<\n"
- " $classname$, $classname$.Builder> implements\n"
- " $extra_interfaces$\n"
- " $classname$OrBuilder {\n");
+ printer->Print(
+ variables,
+ "$deprecation$public $static$final class $classname$ extends\n"
+ " com.google.protobuf.GeneratedMessageLite.ExtendableMessage<\n"
+ " $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 {
- printer->Print(
- variables,
+ printer->Print(
+ variables,
"$deprecation$public $static$final class $classname$ extends\n"
" com.google.protobuf.GeneratedMessageLite<\n"
" $classname$, $classname$.Builder> implements\n"
@@ -208,103 +208,103 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* 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_);
+ ImmutableMessageLiteGenerator messageGenerator(descriptor_->nested_type(i),
+ context_);
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();
+ // 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));
}
- 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
- std::map<TProtoStringType, TProtoStringType> vars;
- for (auto oneof : oneofs_) {
+ 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());
+ vars["oneof_capitalized_name"] =
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name;
+ vars["oneof_index"] = StrCat((oneof)->index());
// oneofCase_ and oneof_
printer->Print(vars,
- "private int $oneof_name$Case_ = 0;\n"
- "private java.lang.Object $oneof_name$_;\n");
+ "private int $oneof_name$Case_ = 0;\n"
+ "private java.lang.Object $oneof_name$_;\n");
// OneofCase enum
- printer->Print(vars, "public enum $oneof_capitalized_name$Case {\n");
+ printer->Print(vars, "public enum $oneof_capitalized_name$Case {\n");
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()));
+ 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,
- "private final int value;\n"
- "private $oneof_capitalized_name$Case(int value) {\n"
- " this.value = value;\n"
- "}\n");
+ printer->Print("$cap_oneof_name$_NOT_SET(0);\n", "cap_oneof_name",
+ ToUpper(vars["oneof_name"]));
+ printer->Print(vars,
+ "private final int value;\n"
+ "private $oneof_capitalized_name$Case(int value) {\n"
+ " this.value = value;\n"
+ "}\n");
printer->Print(
- vars,
- "/**\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
- "public static $oneof_capitalized_name$Case forNumber(int value) {\n"
- " switch (value) {\n");
- for (int j = 0; j < (oneof)->field_count(); j++) {
- const FieldDescriptor* field = (oneof)->field(j);
- printer->Print(" case $field_number$: return $field_name$;\n",
- "field_number", StrCat(field->number()),
- "field_name", ToUpper(field->name()));
+ vars,
+ "/**\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $oneof_capitalized_name$Case valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n"
+ "public static $oneof_capitalized_name$Case forNumber(int value) {\n"
+ " switch (value) {\n");
+ for (int j = 0; j < (oneof)->field_count(); j++) {
+ const FieldDescriptor* field = (oneof)->field(j);
+ printer->Print(" case $field_number$: return $field_name$;\n",
+ "field_number", StrCat(field->number()),
+ "field_name", ToUpper(field->name()));
}
printer->Print(
- " case 0: return $cap_oneof_name$_NOT_SET;\n"
- " default: return null;\n"
- " }\n"
- "}\n"
- // TODO(b/135620659): Rename this to "getFieldNumber" or something to
- // disambiguate it from actual proto enums.
- "public int getNumber() {\n"
- " return this.value;\n"
- "}\n",
- "cap_oneof_name", ToUpper(vars["oneof_name"]));
+ " case 0: return $cap_oneof_name$_NOT_SET;\n"
+ " default: return null;\n"
+ " }\n"
+ "}\n"
+ // TODO(b/135620659): Rename this to "getFieldNumber" or something to
+ // disambiguate it from actual proto enums.
+ "public int getNumber() {\n"
+ " return this.value;\n"
+ "}\n",
+ "cap_oneof_name", ToUpper(vars["oneof_name"]));
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"
- " return $oneof_capitalized_name$Case.forNumber(\n"
- " $oneof_name$Case_);\n"
- "}\n"
- "\n"
- "private void clear$oneof_capitalized_name$() {\n"
- " $oneof_name$Case_ = 0;\n"
- " $oneof_name$_ = null;\n"
- "}\n"
- "\n");
+ "@java.lang.Override\n"
+ "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"
+ "private void clear$oneof_capitalized_name$() {\n"
+ " $oneof_name$Case_ = 0;\n"
+ " $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",
- "constant_name", FieldConstantName(descriptor_->field(i)),
- "number", StrCat(descriptor_->field(i)->number()));
+ "constant_name", FieldConstantName(descriptor_->field(i)),
+ "number", StrCat(descriptor_->field(i)->number()));
field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);
printer->Print("\n");
}
@@ -314,13 +314,13 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* 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");
+ // 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(
- "@java.lang.Override\n"
+ "@java.lang.Override\n"
"@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n"
"protected final java.lang.Object dynamicMethod(\n"
" com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n"
@@ -334,105 +334,105 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Indent();
printer->Indent();
- printer->Print("case NEW_BUILDER: {\n");
+ printer->Print("case NEW_BUILDER: {\n");
printer->Indent();
GenerateDynamicMethodNewBuilder(printer);
printer->Outdent();
printer->Print(
- "}\n"
- "case BUILD_MESSAGE_INFO: {\n");
+ "}\n"
+ "case BUILD_MESSAGE_INFO: {\n");
printer->Indent();
- GenerateDynamicMethodNewBuildMessageInfo(printer);
+ GenerateDynamicMethodNewBuildMessageInfo(printer);
printer->Outdent();
printer->Print(
- "}\n"
- "// fall through\n"
- "case GET_DEFAULT_INSTANCE: {\n"
- " return DEFAULT_INSTANCE;\n"
- "}\n"
- "case GET_PARSER: {\n"
- // Generally one would use the lazy initialization holder pattern for
- // manipulating static fields but that has exceptional cost on Android as
- // it will generate an extra class for every message. Instead, use the
- // double-check locking pattern which works just as well.
- //
- // The "parser" temporary mirrors the "PARSER" field to eliminate a read
- // at the final return statement.
- " com.google.protobuf.Parser<$classname$> parser = PARSER;\n"
- " if (parser == null) {\n"
- " synchronized ($classname$.class) {\n"
- " parser = PARSER;\n"
- " if (parser == null) {\n"
- " parser =\n"
- " new DefaultInstanceBasedParser<$classname$>(\n"
- " DEFAULT_INSTANCE);\n"
- " PARSER = parser;\n"
- " }\n"
- " }\n"
- " }\n"
- " return parser;\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "}\n"
+ "// fall through\n"
+ "case GET_DEFAULT_INSTANCE: {\n"
+ " return DEFAULT_INSTANCE;\n"
+ "}\n"
+ "case GET_PARSER: {\n"
+ // Generally one would use the lazy initialization holder pattern for
+ // manipulating static fields but that has exceptional cost on Android as
+ // it will generate an extra class for every message. Instead, use the
+ // double-check locking pattern which works just as well.
+ //
+ // The "parser" temporary mirrors the "PARSER" field to eliminate a read
+ // at the final return statement.
+ " com.google.protobuf.Parser<$classname$> parser = PARSER;\n"
+ " if (parser == null) {\n"
+ " synchronized ($classname$.class) {\n"
+ " parser = PARSER;\n"
+ " if (parser == null) {\n"
+ " parser =\n"
+ " new DefaultInstanceBasedParser<$classname$>(\n"
+ " DEFAULT_INSTANCE);\n"
+ " PARSER = parser;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " return parser;\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Outdent();
- if (HasRequiredFields(descriptor_)) {
- printer->Print(
- "}\n"
- "case GET_MEMOIZED_IS_INITIALIZED: {\n"
- " return memoizedIsInitialized;\n"
- "}\n"
- "case SET_MEMOIZED_IS_INITIALIZED: {\n"
- " memoizedIsInitialized = (byte) (arg0 == null ? 0 : 1);\n"
- " return null;\n"
- "}\n");
- } else {
- printer->Print(
- "}\n"
- "case GET_MEMOIZED_IS_INITIALIZED: {\n"
- " return (byte) 1;\n"
- "}\n"
- "case SET_MEMOIZED_IS_INITIALIZED: {\n"
- " return null;\n"
- "}\n");
- }
+ if (HasRequiredFields(descriptor_)) {
+ printer->Print(
+ "}\n"
+ "case GET_MEMOIZED_IS_INITIALIZED: {\n"
+ " return memoizedIsInitialized;\n"
+ "}\n"
+ "case SET_MEMOIZED_IS_INITIALIZED: {\n"
+ " memoizedIsInitialized = (byte) (arg0 == null ? 0 : 1);\n"
+ " return null;\n"
+ "}\n");
+ } else {
+ printer->Print(
+ "}\n"
+ "case GET_MEMOIZED_IS_INITIALIZED: {\n"
+ " return (byte) 1;\n"
+ "}\n"
+ "case SET_MEMOIZED_IS_INITIALIZED: {\n"
+ " return null;\n"
+ "}\n");
+ }
printer->Outdent();
printer->Print(
- " }\n"
- " throw new UnsupportedOperationException();\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ " }\n"
+ " throw new UnsupportedOperationException();\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Print(
- "\n"
- "// @@protoc_insertion_point(class_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\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.
- printer->Print("private static final $classname$ DEFAULT_INSTANCE;\n",
- "classname",
- name_resolver_->GetImmutableClassName(descriptor_));
-
+ printer->Print("private static final $classname$ DEFAULT_INSTANCE;\n",
+ "classname",
+ name_resolver_->GetImmutableClassName(descriptor_));
+
printer->Print(
- "static {\n"
- " $classname$ defaultInstance = new $classname$();\n"
- " // New instances are implicitly immutable so no need to make\n"
- " // immutable.\n"
- " DEFAULT_INSTANCE = defaultInstance;\n"
- // Register the default instance in a map. This map will be used by
- // experimental runtime to lookup default instance given a class instance
- // without using Java reflection.
- " com.google.protobuf.GeneratedMessageLite.registerDefaultInstance(\n"
- " $classname$.class, defaultInstance);\n"
- "}\n"
- "\n",
- "classname", descriptor_->name());
+ "static {\n"
+ " $classname$ defaultInstance = new $classname$();\n"
+ " // New instances are implicitly immutable so no need to make\n"
+ " // immutable.\n"
+ " DEFAULT_INSTANCE = defaultInstance;\n"
+ // Register the default instance in a map. This map will be used by
+ // experimental runtime to lookup default instance given a class instance
+ // without using Java reflection.
+ " com.google.protobuf.GeneratedMessageLite.registerDefaultInstance(\n"
+ " $classname$.class, defaultInstance);\n"
+ "}\n"
+ "\n",
+ "classname", descriptor_->name());
printer->Print(
"public static $classname$ getDefaultInstance() {\n"
@@ -441,17 +441,17 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
- // 'of' method for Wrappers
- if (IsWrappersProtoFile(descriptor_->file())) {
- printer->Print(
- "public static $classname$ of($field_type$ value) {\n"
- " return newBuilder().setValue(value).build();\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_),
- "field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0))));
- }
-
+ // 'of' method for Wrappers
+ if (IsWrappersProtoFile(descriptor_->file())) {
+ printer->Print(
+ "public static $classname$ of($field_type$ value) {\n"
+ " return newBuilder().setValue(value).build();\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_),
+ "field_type", PrimitiveTypeName(GetJavaType(descriptor_->field(0))));
+ }
+
GenerateParser(printer);
// Extensions must be declared after the DEFAULT_INSTANCE is initialized
@@ -466,203 +466,203 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Print("}\n\n");
}
-void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuildMessageInfo(
- io::Printer* printer) {
- printer->Indent();
+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;
+ // 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;
+ int flags = 0;
+ if (IsProto2(descriptor_->file())) {
+ flags |= 0x1;
}
- if (descriptor_->options().message_set_wire_format()) {
- flags |= 0x2;
+ 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 {
- // A single array of all fields (including oneof, oneofCase, hasBits).
- printer->Print("java.lang.Object[] objects = new java.lang.Object[] {\n");
- printer->Indent();
-
- // Record the number of oneofs.
- WriteIntToUtf16CharSequence(oneofs_.size(), &chars);
- for (auto oneof : oneofs_) {
+ WriteIntToUtf16CharSequence(flags, &chars);
+ WriteIntToUtf16CharSequence(descriptor_->field_count(), &chars);
+
+ if (descriptor_->field_count() == 0) {
+ printer->Print("java.lang.Object[] objects = null;");
+ } else {
+ // A single array of all fields (including oneof, oneofCase, hasBits).
+ printer->Print("java.lang.Object[] objects = new java.lang.Object[] {\n");
+ printer->Indent();
+
+ // Record the number of oneofs.
+ WriteIntToUtf16CharSequence(oneofs_.size(), &chars);
+ for (auto oneof : oneofs_) {
printer->Print(
- "\"$oneof_name$_\",\n"
- "\"$oneof_name$Case_\",\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name);
+ "\"$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(
+ SortFieldsByNumber(descriptor_));
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = sorted_fields[i];
+ if (field->is_map()) {
+ map_count++;
+ } else if (field->is_repeated()) {
+ repeated_count++;
+ }
}
- // 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();
+ 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() ||
+ (GetJavaType(descriptor_->field(i)) == JAVATYPE_MESSAGE &&
+ HasRequiredFields(descriptor_->field(i)->message_type()))) {
+ fields_for_is_initialized_check.push_back(descriptor_->field(i));
+ }
}
- 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(
- SortFieldsByNumber(descriptor_));
- for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* field = sorted_fields[i];
- if (field->is_map()) {
- map_count++;
- } else if (field->is_repeated()) {
- 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() ||
- (GetJavaType(descriptor_->field(i)) == JAVATYPE_MESSAGE &&
- HasRequiredFields(descriptor_->field(i)->message_type()))) {
- fields_for_is_initialized_check.push_back(descriptor_->field(i));
- }
- }
- 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);
+ 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->Outdent();
+ printer->Print("};\n");
}
- printer->Print("java.lang.String info =\n");
- TProtoStringType line;
- for (size_t i = 0; i < chars.size(); i++) {
- uint16_t code = chars[i];
- EscapeUtf16ToString(code, &line);
- if (line.size() >= 80) {
- printer->Print(" \"$string$\" +\n", "string", line);
- line.clear();
- }
+ printer->Print("java.lang.String info =\n");
+ TProtoStringType line;
+ for (size_t i = 0; i < chars.size(); i++) {
+ uint16_t code = chars[i];
+ EscapeUtf16ToString(code, &line);
+ if (line.size() >= 80) {
+ printer->Print(" \"$string$\" +\n", "string", line);
+ line.clear();
+ }
}
- printer->Print(" \"$string$\";\n", "string", line);
+ printer->Print(" \"$string$\";\n", "string", line);
- printer->Print("return newMessageInfo(DEFAULT_INSTANCE, info, objects);\n");
+ printer->Print("return newMessageInfo(DEFAULT_INSTANCE, info, objects);\n");
printer->Outdent();
}
-// ===================================================================
+// ===================================================================
-void ImmutableMessageLiteGenerator::GenerateParseFromMethods(
- io::Printer* printer) {
+void ImmutableMessageLiteGenerator::GenerateParseFromMethods(
+ io::Printer* printer) {
printer->Print(
- "public static $classname$ parseFrom(\n"
- " java.nio.ByteBuffer data)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, data);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " java.nio.ByteBuffer data,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, data, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.ByteString data)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, data);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.ByteString data,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, data, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(byte[] data)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, data);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " byte[] data,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws com.google.protobuf.InvalidProtocolBufferException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, data, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(java.io.InputStream input)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, input);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " java.io.InputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, input, extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseDelimitedFrom(java.io.InputStream "
- "input)\n"
- " throws java.io.IOException {\n"
- " return parseDelimitedFrom(DEFAULT_INSTANCE, input);\n"
- "}\n"
- "public static $classname$ parseDelimitedFrom(\n"
- " java.io.InputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " return parseDelimitedFrom(DEFAULT_INSTANCE, input, "
- "extensionRegistry);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.CodedInputStream input)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, input);\n"
- "}\n"
- "public static $classname$ parseFrom(\n"
- " com.google.protobuf.CodedInputStream input,\n"
- " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
- " throws java.io.IOException {\n"
- " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
- " DEFAULT_INSTANCE, input, extensionRegistry);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.ByteString data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.ByteString data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(byte[] data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " byte[] data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(java.io.InputStream input)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, input);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " java.io.InputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, input, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseDelimitedFrom(java.io.InputStream "
+ "input)\n"
+ " throws java.io.IOException {\n"
+ " return parseDelimitedFrom(DEFAULT_INSTANCE, input);\n"
+ "}\n"
+ "public static $classname$ parseDelimitedFrom(\n"
+ " java.io.InputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " return parseDelimitedFrom(DEFAULT_INSTANCE, input, "
+ "extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.CodedInputStream input)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, input);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " com.google.protobuf.CodedInputStream input,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws java.io.IOException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, input, extensionRegistry);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
}
// ===================================================================
void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
printer->Print(
- "public static Builder newBuilder() {\n"
- " return (Builder) DEFAULT_INSTANCE.createBuilder();\n"
- "}\n"
- "public static Builder newBuilder($classname$ prototype) {\n"
- " return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n"
- "}\n"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "public static Builder newBuilder() {\n"
+ " return (Builder) DEFAULT_INSTANCE.createBuilder();\n"
+ "}\n"
+ "public static Builder newBuilder($classname$ prototype) {\n"
+ " return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n"
+ "}\n"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
MessageBuilderLiteGenerator builderGenerator(descriptor_, context_);
builderGenerator.Generate(printer);
@@ -672,41 +672,41 @@ void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {
void ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuilder(
io::Printer* printer) {
- printer->Print("return new Builder();\n");
+ printer->Print("return new Builder();\n");
}
// ===================================================================
-void ImmutableMessageLiteGenerator::GenerateExtensionRegistrationCode(
+void ImmutableMessageLiteGenerator::GenerateExtensionRegistrationCode(
io::Printer* printer) {
for (int i = 0; i < descriptor_->extension_count(); i++) {
ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)
- .GenerateRegistrationCode(printer);
+ .GenerateRegistrationCode(printer);
}
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
- .GenerateExtensionRegistrationCode(printer);
+ .GenerateExtensionRegistrationCode(printer);
}
}
// ===================================================================
-void ImmutableMessageLiteGenerator::GenerateConstructor(io::Printer* printer) {
- printer->Print("private $classname$() {\n", "classname", descriptor_->name());
+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->Print("}\n");
+ printer->Print("}\n");
}
// ===================================================================
void ImmutableMessageLiteGenerator::GenerateParser(io::Printer* printer) {
printer->Print(
- "private static volatile com.google.protobuf.Parser<$classname$> "
- "PARSER;\n"
+ "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"
@@ -717,249 +717,249 @@ void ImmutableMessageLiteGenerator::GenerateParser(io::Printer* printer) {
// ===================================================================
void ImmutableMessageLiteGenerator::GenerateInitializers(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!IsRealOneof(descriptor_->field(i))) {
+ if (!IsRealOneof(descriptor_->field(i))) {
field_generators_.get(descriptor_->field(i))
.GenerateInitializationCode(printer);
}
}
}
-void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
- io::Printer* printer) const {
- printer->Print(
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "@com.google.protobuf.kotlin.ProtoDslMarker\n");
- printer->Print(
- "class Dsl private constructor(\n"
- " @kotlin.jvm.JvmField private val _builder: $message$.Builder\n"
- ") {\n"
- " companion object {\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " @kotlin.PublishedApi\n"
- " internal fun _create(builder: $message$.Builder): Dsl = "
- "Dsl(builder)\n"
- " }\n"
- "\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " @kotlin.PublishedApi\n"
- " internal fun _build(): $message$ = _builder.build()\n",
- "message", name_resolver_->GetClassName(descriptor_, true));
-
- printer->Indent();
-
- for (int i = 0; i < descriptor_->field_count(); i++) {
- printer->Print("\n");
- field_generators_.get(descriptor_->field(i))
- .GenerateKotlinDslMembers(printer);
- }
-
- for (auto oneof : oneofs_) {
- printer->Print(
- "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
- " @JvmName(\"get$oneof_capitalized_name$Case\")\n"
- " get() = _builder.get$oneof_capitalized_name$Case()\n\n"
- "fun clear$oneof_capitalized_name$() {\n"
- " _builder.clear$oneof_capitalized_name$()\n"
- "}\n",
- "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
- "oneof_capitalized_name",
- context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "message",
- name_resolver_->GetClassName(descriptor_, true));
- }
-
- if (descriptor_->extension_range_count() > 0) {
- GenerateKotlinExtensions(printer);
- }
-
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
- io::Printer* printer) const {
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> Unit): "
- "$message$ =\n"
- " $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
- "}._build()\n",
- "camelcase_name", name_resolver_->GetKotlinFactoryName(descriptor_),
- "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
- "message", name_resolver_->GetClassName(descriptor_, true));
-
- printer->Print("object $name$Kt {\n", "name", descriptor_->name());
- printer->Indent();
- GenerateKotlinDsl(printer);
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (IsMapEntry(descriptor_->nested_type(i))) continue;
- ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
- .GenerateKotlinMembers(printer);
- }
- printer->Outdent();
- printer->Print("}\n");
-}
-
-void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
- io::Printer* printer) const {
- printer->Print(
- "inline fun $message$.copy(block: $message_kt$.Dsl.() -> Unit): "
- "$message$ =\n"
- " $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
- "}._build()\n",
- "message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
- name_resolver_->GetKotlinExtensionsClassName(descriptor_));
-
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (IsMapEntry(descriptor_->nested_type(i))) continue;
- ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
- .GenerateTopLevelKotlinMembers(printer);
- }
-}
-
-void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
- io::Printer* printer) const {
- TProtoStringType message_name = name_resolver_->GetClassName(descriptor_, true);
-
- printer->Print(
- "@Suppress(\"UNCHECKED_CAST\")\n"
- "@kotlin.jvm.JvmSynthetic\n"
- "operator fun <T> get(extension: "
- "com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
- " return if (extension.isRepeated) {\n"
- " get(extension as com.google.protobuf.ExtensionLite<$message$, "
- "List<*>>) as T\n"
- " } else {\n"
- " _builder.getExtension(extension)\n"
- " }\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "operator fun <E> get(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
- "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
- " return com.google.protobuf.kotlin.ExtensionList(extension, "
- "_builder.getExtension(extension))\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "operator fun contains(extension: "
- "com.google.protobuf.ExtensionLite<$message$, *>): "
- "Boolean {\n"
- " return _builder.hasExtension(extension)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) "
- "{\n"
- " _builder.clearExtension(extension)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.PublishedApi\n"
- "internal fun <T> setExtension(extension: "
- "com.google.protobuf.ExtensionLite<$message$, T>, "
- "value: T) {\n"
- " _builder.setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <T : Comparable<T>> set(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
- " value: T\n"
- ") {\n"
- " setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun set(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, "
- "com.google.protobuf.ByteString>,\n"
- " value: com.google.protobuf.ByteString\n"
- ") {\n"
- " setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
- " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
- " value: T\n"
- ") {\n"
- " setExtension(extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.add(value: E) {\n"
- " _builder.addExtension(this.extension, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.plusAssign"
- "(value: E) {\n"
- " add(value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.addAll(values: Iterable<E>) {\n"
- " for (value in values) {\n"
- " add(value)\n"
- " }\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.plusAssign(values: "
- "Iterable<E>) {\n"
- " addAll(values)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
- "$message$>.set(index: Int, value: "
- "E) {\n"
- " _builder.setExtension(this.extension, index, value)\n"
- "}\n\n",
- "message", message_name);
-
- printer->Print(
- "@kotlin.jvm.JvmSynthetic\n"
- "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
- "$message$>.clear() {\n"
- " clear(extension)\n"
- "}\n\n",
- "message", message_name);
-}
-
+void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
+ io::Printer* printer) const {
+ printer->Print(
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "@com.google.protobuf.kotlin.ProtoDslMarker\n");
+ printer->Print(
+ "class Dsl private constructor(\n"
+ " @kotlin.jvm.JvmField private val _builder: $message$.Builder\n"
+ ") {\n"
+ " companion object {\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " @kotlin.PublishedApi\n"
+ " internal fun _create(builder: $message$.Builder): Dsl = "
+ "Dsl(builder)\n"
+ " }\n"
+ "\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " @kotlin.PublishedApi\n"
+ " internal fun _build(): $message$ = _builder.build()\n",
+ "message", name_resolver_->GetClassName(descriptor_, true));
+
+ printer->Indent();
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ printer->Print("\n");
+ field_generators_.get(descriptor_->field(i))
+ .GenerateKotlinDslMembers(printer);
+ }
+
+ for (auto oneof : oneofs_) {
+ printer->Print(
+ "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ " @JvmName(\"get$oneof_capitalized_name$Case\")\n"
+ " get() = _builder.get$oneof_capitalized_name$Case()\n\n"
+ "fun clear$oneof_capitalized_name$() {\n"
+ " _builder.clear$oneof_capitalized_name$()\n"
+ "}\n",
+ "oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
+ "oneof_capitalized_name",
+ context_->GetOneofGeneratorInfo(oneof)->capitalized_name, "message",
+ name_resolver_->GetClassName(descriptor_, true));
+ }
+
+ if (descriptor_->extension_range_count() > 0) {
+ GenerateKotlinExtensions(printer);
+ }
+
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> Unit): "
+ "$message$ =\n"
+ " $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
+ "}._build()\n",
+ "camelcase_name", name_resolver_->GetKotlinFactoryName(descriptor_),
+ "message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
+ "message", name_resolver_->GetClassName(descriptor_, true));
+
+ printer->Print("object $name$Kt {\n", "name", descriptor_->name());
+ printer->Indent();
+ GenerateKotlinDsl(printer);
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ if (IsMapEntry(descriptor_->nested_type(i))) continue;
+ ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
+ .GenerateKotlinMembers(printer);
+ }
+ printer->Outdent();
+ printer->Print("}\n");
+}
+
+void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ "inline fun $message$.copy(block: $message_kt$.Dsl.() -> Unit): "
+ "$message$ =\n"
+ " $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
+ "}._build()\n",
+ "message", name_resolver_->GetClassName(descriptor_, true), "message_kt",
+ name_resolver_->GetKotlinExtensionsClassName(descriptor_));
+
+ for (int i = 0; i < descriptor_->nested_type_count(); i++) {
+ if (IsMapEntry(descriptor_->nested_type(i))) continue;
+ ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)
+ .GenerateTopLevelKotlinMembers(printer);
+ }
+}
+
+void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
+ io::Printer* printer) const {
+ TProtoStringType message_name = name_resolver_->GetClassName(descriptor_, true);
+
+ printer->Print(
+ "@Suppress(\"UNCHECKED_CAST\")\n"
+ "@kotlin.jvm.JvmSynthetic\n"
+ "operator fun <T> get(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
+ " return if (extension.isRepeated) {\n"
+ " get(extension as com.google.protobuf.ExtensionLite<$message$, "
+ "List<*>>) as T\n"
+ " } else {\n"
+ " _builder.getExtension(extension)\n"
+ " }\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
+ "operator fun <E> get(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
+ "): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
+ " return com.google.protobuf.kotlin.ExtensionList(extension, "
+ "_builder.getExtension(extension))\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "operator fun contains(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, *>): "
+ "Boolean {\n"
+ " return _builder.hasExtension(extension)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) "
+ "{\n"
+ " _builder.clearExtension(extension)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.PublishedApi\n"
+ "internal fun <T> setExtension(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, T>, "
+ "value: T) {\n"
+ " _builder.setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <T : Comparable<T>> set(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
+ " value: T\n"
+ ") {\n"
+ " setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun set(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, "
+ "com.google.protobuf.ByteString>,\n"
+ " value: com.google.protobuf.ByteString\n"
+ ") {\n"
+ " setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ " extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
+ " value: T\n"
+ ") {\n"
+ " setExtension(extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.add(value: E) {\n"
+ " _builder.addExtension(this.extension, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.plusAssign"
+ "(value: E) {\n"
+ " add(value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.addAll(values: Iterable<E>) {\n"
+ " for (value in values) {\n"
+ " add(value)\n"
+ " }\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.plusAssign(values: "
+ "Iterable<E>) {\n"
+ " addAll(values)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "$message$>.set(index: Int, value: "
+ "E) {\n"
+ " _builder.setExtension(this.extension, index, value)\n"
+ "}\n\n",
+ "message", message_name);
+
+ printer->Print(
+ "@kotlin.jvm.JvmSynthetic\n"
+ "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "$message$>.clear() {\n"
+ " clear(extension)\n"
+ "}\n\n",
+ "message", message_name);
+}
+
} // namespace java
} // namespace compiler
} // namespace protobuf
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 ace799b002..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
@@ -35,10 +35,10 @@
#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>
+#include <map>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
+#include <google/protobuf/compiler/java/java_message.h>
namespace google {
namespace protobuf {
@@ -53,12 +53,12 @@ class ImmutableMessageLiteGenerator : public MessageGenerator {
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 void GenerateStaticVariables(io::Printer* printer,
+ int* bytecode_estimate);
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;
+ 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);
@@ -68,8 +68,8 @@ class ImmutableMessageLiteGenerator : public MessageGenerator {
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;
+ void GenerateDynamicMethodNewBuildMessageInfo(io::Printer* printer);
+ void GenerateKotlinExtensions(io::Printer* printer) const;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -81,6 +81,6 @@ class ImmutableMessageLiteGenerator : public MessageGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 b5788b9c2f..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
@@ -28,15 +28,15 @@
// (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 <google/protobuf/compiler/java/java_name_resolver.h>
#include <map>
-#include <string>
+#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>
+#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 {
@@ -53,8 +53,8 @@ const char* kOuterClassNameSuffix = "OuterClass";
// Full name : foo.Bar.Baz
// Package name: foo
// After strip : Bar.Baz
-TProtoStringType StripPackageName(const TProtoStringType& full_name,
- const FileDescriptor* file) {
+TProtoStringType StripPackageName(const TProtoStringType& full_name,
+ const FileDescriptor* file) {
if (file->package().empty()) {
return full_name;
} else {
@@ -64,72 +64,72 @@ TProtoStringType StripPackageName(const TProtoStringType& full_name,
}
// 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();
-
- while (temp) {
- result = temp->name() + "Kt." + result;
- temp = temp->containing_type();
- }
- return result;
-}
-
+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();
+
+ while (temp) {
+ result = temp->name() + "Kt." + result;
+ temp = temp->containing_type();
+ }
+ return result;
+}
+
// Get the name of an enum's Java class without package name prefix.
-TProtoStringType ClassNameWithoutPackage(const EnumDescriptor* descriptor,
- bool immutable) {
+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 {
- return ClassNameWithoutPackage(message_descriptor, immutable) + "." +
- descriptor->name();
+ return ClassNameWithoutPackage(message_descriptor, immutable) + "." +
+ descriptor->name();
}
}
// 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());
+TProtoStringType ClassNameWithoutPackage(const ServiceDescriptor* descriptor,
+ bool immutable) {
+ TProtoStringType full_name =
+ StripPackageName(descriptor->full_name(), descriptor->file());
// We don't allow nested service definitions.
- GOOGLE_CHECK(full_name.find('.') == TProtoStringType::npos);
+ GOOGLE_CHECK(full_name.find('.') == TProtoStringType::npos);
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)) {
- if (a == b) {
- return NameEquality::EXACT_EQUAL;
- }
- return NameEquality::EQUAL_IGNORE_CASE;
- }
- return NameEquality::NO_MATCH;
-}
-
+// Return true if a and b are equals (case insensitive).
+NameEquality CheckNameEquality(const TProtoStringType& a, const TProtoStringType& b) {
+ if (ToUpper(a) == ToUpper(b)) {
+ if (a == b) {
+ return NameEquality::EXACT_EQUAL;
+ }
+ return NameEquality::EQUAL_IGNORE_CASE;
+ }
+ return NameEquality::NO_MATCH;
+}
+
// 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;
- }
+ 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) {
- if (MessageHasConflictingClassName(message->nested_type(i), classname,
- equality_mode)) {
+ if (MessageHasConflictingClassName(message->nested_type(i), classname,
+ equality_mode)) {
return true;
}
}
for (int i = 0; i < message->enum_type_count(); ++i) {
- if (CheckNameEquality(message->enum_type(i)->name(), classname) ==
- equality_mode) {
+ if (CheckNameEquality(message->enum_type(i)->name(), classname) ==
+ equality_mode) {
return true;
}
}
@@ -138,15 +138,15 @@ bool MessageHasConflictingClassName(const Descriptor* message,
} // namespace
-ClassNameResolver::ClassNameResolver() {}
+ClassNameResolver::ClassNameResolver() {}
-ClassNameResolver::~ClassNameResolver() {}
+ClassNameResolver::~ClassNameResolver() {}
-TProtoStringType ClassNameResolver::GetFileDefaultImmutableClassName(
+TProtoStringType ClassNameResolver::GetFileDefaultImmutableClassName(
const FileDescriptor* file) {
- TProtoStringType basename;
- TProtoStringType::size_type last_slash = file->name().find_last_of('/');
- if (last_slash == TProtoStringType::npos) {
+ 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);
@@ -154,16 +154,16 @@ TProtoStringType ClassNameResolver::GetFileDefaultImmutableClassName(
return UnderscoresToCamelCase(StripProto(basename), true);
}
-TProtoStringType ClassNameResolver::GetFileImmutableClassName(
+TProtoStringType ClassNameResolver::GetFileImmutableClassName(
const FileDescriptor* file) {
- TProtoStringType& class_name = file_immutable_outer_class_names_[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 (HasConflictingClassName(file, class_name,
- NameEquality::EXACT_EQUAL)) {
+ if (HasConflictingClassName(file, class_name,
+ NameEquality::EXACT_EQUAL)) {
class_name += kOuterClassNameSuffix;
}
}
@@ -171,16 +171,16 @@ TProtoStringType ClassNameResolver::GetFileImmutableClassName(
return class_name;
}
-TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
- bool immutable) {
- return GetFileClassName(file, immutable, false);
-}
-
-TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
- bool immutable, bool kotlin) {
- if (kotlin) {
- return GetFileImmutableClassName(file) + "Kt";
- } else if (immutable) {
+TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
+ bool immutable) {
+ return GetFileClassName(file, immutable, false);
+}
+
+TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* file,
+ bool immutable, bool kotlin) {
+ if (kotlin) {
+ return GetFileImmutableClassName(file) + "Kt";
+ } else if (immutable) {
return GetFileImmutableClassName(file);
} else {
return "Mutable" + GetFileImmutableClassName(file);
@@ -189,191 +189,191 @@ TProtoStringType ClassNameResolver::GetFileClassName(const FileDescriptor* 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) {
+bool ClassNameResolver::HasConflictingClassName(const FileDescriptor* file,
+ const TProtoStringType& classname,
+ NameEquality equality_mode) {
for (int i = 0; i < file->enum_type_count(); i++) {
- if (CheckNameEquality(file->enum_type(i)->name(), classname) ==
- equality_mode) {
+ if (CheckNameEquality(file->enum_type(i)->name(), classname) ==
+ equality_mode) {
return true;
}
}
for (int i = 0; i < file->service_count(); i++) {
- if (CheckNameEquality(file->service(i)->name(), classname) ==
- equality_mode) {
+ if (CheckNameEquality(file->service(i)->name(), classname) ==
+ equality_mode) {
return true;
}
}
for (int i = 0; i < file->message_type_count(); i++) {
- if (MessageHasConflictingClassName(file->message_type(i), classname,
- equality_mode)) {
+ if (MessageHasConflictingClassName(file->message_type(i), classname,
+ equality_mode)) {
return true;
}
}
return false;
}
-TProtoStringType ClassNameResolver::GetDescriptorClassName(
+TProtoStringType ClassNameResolver::GetDescriptorClassName(
const FileDescriptor* descriptor) {
return GetFileImmutableClassName(descriptor);
}
-TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
- bool immutable) {
- return GetClassName(descriptor, immutable, false);
-}
-
-TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
- bool immutable, bool kotlin) {
- TProtoStringType result = FileJavaPackage(descriptor, immutable);
+TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
+ bool immutable) {
+ return GetClassName(descriptor, immutable, false);
+}
+
+TProtoStringType ClassNameResolver::GetClassName(const FileDescriptor* descriptor,
+ bool immutable, bool kotlin) {
+ TProtoStringType result = FileJavaPackage(descriptor, immutable);
if (!result.empty()) result += '.';
- result += GetFileClassName(descriptor, immutable, kotlin);
+ 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.
-TProtoStringType ClassNameResolver::GetClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
- bool immutable, bool is_own_file) {
- return GetClassFullName(name_without_package, file, immutable, is_own_file,
- false);
-}
-
-TProtoStringType ClassNameResolver::GetClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
- bool immutable, bool is_own_file, bool kotlin) {
- TProtoStringType result;
- if (is_own_file) {
+TProtoStringType ClassNameResolver::GetClassFullName(
+ const TProtoStringType& name_without_package, const FileDescriptor* file,
+ bool immutable, bool is_own_file) {
+ return GetClassFullName(name_without_package, file, immutable, is_own_file,
+ false);
+}
+
+TProtoStringType ClassNameResolver::GetClassFullName(
+ const TProtoStringType& name_without_package, const FileDescriptor* file,
+ bool immutable, bool is_own_file, bool kotlin) {
+ TProtoStringType result;
+ if (is_own_file) {
result = FileJavaPackage(file, immutable);
} else {
- result = GetClassName(file, immutable, kotlin);
+ result = GetClassName(file, immutable, kotlin);
}
if (!result.empty()) {
result += '.';
}
result += name_without_package;
- if (kotlin) result += "Kt";
+ if (kotlin) result += "Kt";
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);
-}
-
-TProtoStringType ClassNameResolver::GetClassName(const EnumDescriptor* descriptor,
- bool immutable, bool kotlin) {
- return GetClassFullName(
- ClassNameWithoutPackage(descriptor, immutable), descriptor->file(),
- immutable, MultipleJavaFiles(descriptor->file(), immutable), kotlin);
-}
-
-TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descriptor,
- bool immutable) {
- return GetClassName(descriptor, immutable, false);
-}
-
-TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descriptor,
- bool immutable, bool kotlin) {
+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);
+}
+
+TProtoStringType ClassNameResolver::GetClassName(const EnumDescriptor* descriptor,
+ bool immutable, bool kotlin) {
+ return GetClassFullName(
+ ClassNameWithoutPackage(descriptor, immutable), descriptor->file(),
+ immutable, MultipleJavaFiles(descriptor->file(), immutable), kotlin);
+}
+
+TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descriptor,
+ bool immutable) {
+ return GetClassName(descriptor, immutable, false);
+}
+
+TProtoStringType ClassNameResolver::GetClassName(const ServiceDescriptor* descriptor,
+ bool immutable, bool kotlin) {
return GetClassFullName(ClassNameWithoutPackage(descriptor, immutable),
descriptor->file(), immutable,
- IsOwnFile(descriptor, immutable), kotlin);
+ IsOwnFile(descriptor, immutable), kotlin);
}
// Get the Java Class style full name of a message.
-TProtoStringType ClassNameResolver::GetJavaClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
+TProtoStringType ClassNameResolver::GetJavaClassFullName(
+ const TProtoStringType& name_without_package, const FileDescriptor* file,
bool immutable) {
- return GetJavaClassFullName(name_without_package, file, immutable, false);
-}
-
-TProtoStringType ClassNameResolver::GetJavaClassFullName(
- const TProtoStringType& name_without_package, const FileDescriptor* file,
- bool immutable, bool kotlin) {
- TProtoStringType result;
+ return GetJavaClassFullName(name_without_package, file, immutable, false);
+}
+
+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 {
- result = GetClassName(file, immutable, kotlin);
+ result = GetClassName(file, immutable, kotlin);
if (!result.empty()) result += '$';
}
result += StringReplace(name_without_package, ".", "$", true);
return result;
}
-TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
+TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
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) + "." +
+ return GetExtensionIdentifierName(descriptor, immutable, false);
+}
+
+TProtoStringType ClassNameResolver::GetExtensionIdentifierName(
+ const FieldDescriptor* descriptor, bool immutable, bool kotlin) {
+ return GetClassName(descriptor->containing_type(), immutable, kotlin) + "." +
descriptor->name();
}
-TProtoStringType ClassNameResolver::GetKotlinFactoryName(
- const Descriptor* descriptor) {
- TProtoStringType name = ToCamelCase(descriptor->name(), /* lower_first = */ true);
- return IsForbiddenKotlin(name) ? name + "_" : name;
-}
-
-TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
+TProtoStringType ClassNameResolver::GetKotlinFactoryName(
+ const Descriptor* descriptor) {
+ TProtoStringType name = ToCamelCase(descriptor->name(), /* lower_first = */ true);
+ return IsForbiddenKotlin(name) ? name + "_" : name;
+}
+
+TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
+ const Descriptor* descriptor) {
+ return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, true),
+ descriptor->file(), true);
+}
+
+TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
+ const EnumDescriptor* descriptor) {
+ return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, true),
+ descriptor->file(), true);
+}
+
+TProtoStringType ClassNameResolver::GetKotlinExtensionsClassName(
const Descriptor* descriptor) {
- return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, true),
- descriptor->file(), true);
+ return GetClassFullName(ClassNameWithoutPackageKotlin(descriptor),
+ descriptor->file(), true, true, true);
}
-TProtoStringType ClassNameResolver::GetJavaImmutableClassName(
+TProtoStringType ClassNameResolver::GetJavaMutableClassName(
+ const Descriptor* descriptor) {
+ return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, false),
+ descriptor->file(), false);
+}
+
+TProtoStringType ClassNameResolver::GetJavaMutableClassName(
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),
- descriptor->file(), false);
-}
-
-TProtoStringType ClassNameResolver::GetJavaMutableClassName(
- const EnumDescriptor* descriptor) {
- return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, false),
- descriptor->file(), false);
-}
-
-TProtoStringType ClassNameResolver::GetDowngradedFileClassName(
- const FileDescriptor* file) {
- return "Downgraded" + GetFileClassName(file, false);
-}
-
-TProtoStringType ClassNameResolver::GetDowngradedClassName(
- const Descriptor* descriptor) {
- return FileJavaPackage(descriptor->file()) + "." +
- GetDowngradedFileClassName(descriptor->file()) + "." +
- ClassNameWithoutPackage(descriptor, false);
-}
-
+ return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, false),
+ descriptor->file(), false);
+}
+
+TProtoStringType ClassNameResolver::GetDowngradedFileClassName(
+ const FileDescriptor* file) {
+ return "Downgraded" + GetFileClassName(file, false);
+}
+
+TProtoStringType ClassNameResolver::GetDowngradedClassName(
+ const Descriptor* descriptor) {
+ return FileJavaPackage(descriptor->file()) + "." +
+ GetDowngradedFileClassName(descriptor->file()) + "." +
+ ClassNameWithoutPackage(descriptor, false);
+}
+
} // namespace java
} // namespace compiler
} // namespace protobuf
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 a48ba2f513..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
@@ -32,9 +32,9 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
#include <map>
-#include <string>
+#include <string>
-#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/common.h>
namespace google {
namespace protobuf {
@@ -47,9 +47,9 @@ class ServiceDescriptor;
namespace compiler {
namespace java {
-// Indicates how closely the two class names match.
-enum NameEquality { NO_MATCH, EXACT_EQUAL, EQUAL_IGNORE_CASE };
-
+// 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.
@@ -59,88 +59,88 @@ class 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);
+ 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.
- TProtoStringType GetFileImmutableClassName(const FileDescriptor* file);
+ TProtoStringType GetFileImmutableClassName(const FileDescriptor* file);
// Gets the unqualified default immutable outer class name of a file
// (converted from the proto file's name).
- TProtoStringType GetFileDefaultImmutableClassName(const FileDescriptor* file);
+ 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,
- const TProtoStringType& classname,
- NameEquality equality_mode);
+ 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.
- TProtoStringType GetDescriptorClassName(const FileDescriptor* file);
+ TProtoStringType GetDescriptorClassName(const FileDescriptor* file);
// 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);
- TProtoStringType GetClassName(const EnumDescriptor* descriptor, bool immutable);
- TProtoStringType GetClassName(const EnumDescriptor* descriptor, bool immutable,
- bool kotlin);
- TProtoStringType GetClassName(const ServiceDescriptor* descriptor, bool immutable);
- TProtoStringType GetClassName(const ServiceDescriptor* descriptor, bool immutable,
- bool kotlin);
- TProtoStringType GetClassName(const FileDescriptor* descriptor, bool immutable);
- TProtoStringType GetClassName(const FileDescriptor* descriptor, bool immutable,
- bool kotlin);
-
- template <class DescriptorType>
- TProtoStringType GetImmutableClassName(const DescriptorType* descriptor) {
+ TProtoStringType GetClassName(const Descriptor* descriptor, bool immutable);
+ TProtoStringType GetClassName(const Descriptor* descriptor, bool immutable,
+ bool kotlin);
+ TProtoStringType GetClassName(const EnumDescriptor* descriptor, bool immutable);
+ TProtoStringType GetClassName(const EnumDescriptor* descriptor, bool immutable,
+ bool kotlin);
+ TProtoStringType GetClassName(const ServiceDescriptor* descriptor, bool immutable);
+ TProtoStringType GetClassName(const ServiceDescriptor* descriptor, bool immutable,
+ bool kotlin);
+ 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);
}
- template <class DescriptorType>
- TProtoStringType GetMutableClassName(const DescriptorType* descriptor) {
+ template <class DescriptorType>
+ TProtoStringType GetMutableClassName(const DescriptorType* descriptor) {
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);
+ 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
- TProtoStringType GetJavaImmutableClassName(const Descriptor* descriptor);
- TProtoStringType GetJavaImmutableClassName(const EnumDescriptor* descriptor);
- TProtoStringType GetKotlinFactoryName(const Descriptor* descriptor);
- TProtoStringType GetKotlinExtensionsClassName(const Descriptor* descriptor);
- TProtoStringType GetJavaMutableClassName(const Descriptor* descriptor);
- TProtoStringType GetJavaMutableClassName(const EnumDescriptor* descriptor);
- // Gets the outer class and the actual class for downgraded mutable messages.
- TProtoStringType GetDowngradedFileClassName(const FileDescriptor* file);
- TProtoStringType GetDowngradedClassName(const Descriptor* descriptor);
-
+ TProtoStringType GetJavaImmutableClassName(const Descriptor* descriptor);
+ TProtoStringType GetJavaImmutableClassName(const EnumDescriptor* descriptor);
+ TProtoStringType GetKotlinFactoryName(const Descriptor* descriptor);
+ TProtoStringType GetKotlinExtensionsClassName(const Descriptor* descriptor);
+ TProtoStringType GetJavaMutableClassName(const Descriptor* descriptor);
+ TProtoStringType GetJavaMutableClassName(const EnumDescriptor* descriptor);
+ // Gets the outer class and the actual class for downgraded mutable messages.
+ 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.
- 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);
+ 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.
- 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);
+ 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.
- std::map<const FileDescriptor*, TProtoStringType>
- file_immutable_outer_class_names_;
+ std::map<const FileDescriptor*, TProtoStringType>
+ file_immutable_outer_class_names_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
};
@@ -148,6 +148,6 @@ class ClassNameResolver {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 2679c70458..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
@@ -38,7 +38,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__
-#include <string>
+#include <string>
namespace google {
namespace protobuf {
@@ -46,7 +46,7 @@ namespace protobuf {
class Descriptor;
class EnumDescriptor;
class FileDescriptor;
-class FieldDescriptor;
+class FieldDescriptor;
class ServiceDescriptor;
namespace compiler {
@@ -57,42 +57,42 @@ namespace java {
//
// Returns:
// The fully-qualified Java class name.
-TProtoStringType ClassName(const Descriptor* descriptor);
+TProtoStringType ClassName(const Descriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified Java class name.
-TProtoStringType ClassName(const EnumDescriptor* descriptor);
+TProtoStringType ClassName(const EnumDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified Java class name.
-TProtoStringType ClassName(const FileDescriptor* descriptor);
+TProtoStringType ClassName(const FileDescriptor* descriptor);
// Requires:
// descriptor != NULL
//
// Returns:
// The fully-qualified Java class name.
-TProtoStringType ClassName(const ServiceDescriptor* descriptor);
+TProtoStringType ClassName(const ServiceDescriptor* descriptor);
+
+// Requires:
+// descriptor != NULL
+//
+// Returns:
+// Java package name.
+TProtoStringType FileJavaPackage(const FileDescriptor* descriptor);
+
+// Requires:
+// descriptor != NULL
+// Returns:
+// Capitalized camel case name field name.
+TProtoStringType CapitalizedFieldName(const FieldDescriptor* descriptor);
-// Requires:
-// descriptor != NULL
-//
-// Returns:
-// Java package name.
-TProtoStringType FileJavaPackage(const FileDescriptor* descriptor);
-
-// Requires:
-// descriptor != NULL
-// Returns:
-// Capitalized camel case name field name.
-TProtoStringType CapitalizedFieldName(const FieldDescriptor* descriptor);
-
} // namespace java
} // namespace compiler
} // namespace protobuf
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 a7f8fbe74d..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
@@ -31,7 +31,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__
-#include <string>
+#include <string>
namespace google {
namespace protobuf {
@@ -68,6 +68,6 @@ struct Options {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 c7aa66b10f..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
@@ -32,21 +32,21 @@
// 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 <google/protobuf/compiler/java/java_primitive_field.h>
+
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <string>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -58,64 +58,64 @@ using internal::WireFormat;
namespace {
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
+ int messageBitIndex, int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
- JavaType javaType = GetJavaType(descriptor);
+ JavaType javaType = GetJavaType(descriptor);
- (*variables)["type"] = PrimitiveTypeName(javaType);
- (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
- (*variables)["kt_type"] = KotlinTypeName(javaType);
+ (*variables)["type"] = PrimitiveTypeName(javaType);
+ (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
+ (*variables)["kt_type"] = KotlinTypeName(javaType);
(*variables)["field_type"] = (*variables)["type"];
-
- if (javaType == JAVATYPE_BOOLEAN || javaType == JAVATYPE_DOUBLE ||
- javaType == JAVATYPE_FLOAT || javaType == JAVATYPE_INT ||
- javaType == JAVATYPE_LONG) {
- TProtoStringType capitalized_type = UnderscoresToCamelCase(
- PrimitiveTypeName(javaType), /*cap_first_letter=*/true);
- (*variables)["field_list_type"] =
- "com.google.protobuf.Internal." + capitalized_type + "List";
- (*variables)["empty_list"] = "empty" + capitalized_type + "List()";
- (*variables)["create_list"] = "new" + capitalized_type + "List()";
- (*variables)["mutable_copy_list"] =
- "mutableCopy(" + (*variables)["name"] + "_)";
- (*variables)["name_make_immutable"] =
- (*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;
- } else {
- (*variables)["field_list_type"] =
- "java.util.List<" + (*variables)["boxed_type"] + ">";
- (*variables)["create_list"] =
- "new java.util.ArrayList<" + (*variables)["boxed_type"] + ">()";
- (*variables)["mutable_copy_list"] = "new java.util.ArrayList<" +
- (*variables)["boxed_type"] + ">(" +
- (*variables)["name"] + "_)";
- (*variables)["empty_list"] = "java.util.Collections.emptyList()";
- (*variables)["name_make_immutable"] =
- (*variables)["name"] + "_ = java.util.Collections.unmodifiableList(" +
- (*variables)["name"] + "_)";
- (*variables)["repeated_get"] = (*variables)["name"] + "_.get";
- (*variables)["repeated_add"] = (*variables)["name"] + "_.add";
- (*variables)["repeated_set"] = (*variables)["name"] + "_.set";
- }
-
+
+ if (javaType == JAVATYPE_BOOLEAN || javaType == JAVATYPE_DOUBLE ||
+ javaType == JAVATYPE_FLOAT || javaType == JAVATYPE_INT ||
+ javaType == JAVATYPE_LONG) {
+ TProtoStringType capitalized_type = UnderscoresToCamelCase(
+ PrimitiveTypeName(javaType), /*cap_first_letter=*/true);
+ (*variables)["field_list_type"] =
+ "com.google.protobuf.Internal." + capitalized_type + "List";
+ (*variables)["empty_list"] = "empty" + capitalized_type + "List()";
+ (*variables)["create_list"] = "new" + capitalized_type + "List()";
+ (*variables)["mutable_copy_list"] =
+ "mutableCopy(" + (*variables)["name"] + "_)";
+ (*variables)["name_make_immutable"] =
+ (*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;
+ } else {
+ (*variables)["field_list_type"] =
+ "java.util.List<" + (*variables)["boxed_type"] + ">";
+ (*variables)["create_list"] =
+ "new java.util.ArrayList<" + (*variables)["boxed_type"] + ">()";
+ (*variables)["mutable_copy_list"] = "new java.util.ArrayList<" +
+ (*variables)["boxed_type"] + ">(" +
+ (*variables)["name"] + "_)";
+ (*variables)["empty_list"] = "java.util.Collections.emptyList()";
+ (*variables)["name_make_immutable"] =
+ (*variables)["name"] + "_ = java.util.Collections.unmodifiableList(" +
+ (*variables)["name"] + "_)";
+ (*variables)["repeated_get"] = (*variables)["name"] + "_.get";
+ (*variables)["repeated_add"] = (*variables)["name"] + "_.add";
+ (*variables)["repeated_set"] = (*variables)["name"] + "_.set";
+ }
+
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
- (*variables)["default_init"] =
- IsDefaultValueJavaDefault(descriptor)
- ? ""
- : ("= " + ImmutableDefaultValue(descriptor, name_resolver));
+ (*variables)["default_init"] =
+ IsDefaultValueJavaDefault(descriptor)
+ ? ""
+ : ("= " + 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(
+ 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"] =
@@ -127,20 +127,20 @@ void SetPrimitiveVariables(const FieldDescriptor* 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"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
int fixed_size = FixedSize(GetType(descriptor));
if (fixed_size != -1) {
- (*variables)["fixed_size"] = StrCat(fixed_size);
+ (*variables)["fixed_size"] = StrCat(fixed_size);
}
(*variables)["on_changed"] = "onChanged();";
- if (HasHasbit(descriptor)) {
+ 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);
@@ -168,7 +168,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
}
}
- // For repeated builders, one bit is used for whether the array is immutable.
+ // 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);
@@ -190,10 +190,10 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// ===================================================================
-ImmutablePrimitiveFieldGenerator::ImmutablePrimitiveFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+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_);
@@ -202,252 +202,252 @@ ImmutablePrimitiveFieldGenerator::ImmutablePrimitiveFieldGenerator(
ImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {}
int ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ return HasHasbit(descriptor_) ? 1 : 0;
}
int ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
+ return GetNumBitsForMessage();
}
-void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean has$capitalized_name$();\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$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");
+void ImmutablePrimitiveFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private $field_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@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(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_builder$;\n"
- "}\n");
+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(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_builder$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- "$null_check$"
- " $set_has_field_bit_builder$\n"
- " $name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ "$null_check$"
+ " $set_has_field_bit_builder$\n"
+ " $name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $clear_has_field_bit_builder$\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$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.
- printer->Print(
- variables_,
- " $name$_ = getDefaultInstance().get$capitalized_name$();\n");
+ printer->Print(
+ variables_,
+ " $name$_ = getDefaultInstance().get$capitalized_name$();\n");
} else {
- printer->Print(variables_, " $name$_ = $default$;\n");
+ printer->Print(variables_, " $name$_ = $default$;\n");
}
printer->Print(variables_,
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
}
-void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
- }
-}
-
-void ImmutablePrimitiveFieldGenerator::GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+ }
+}
+
+void ImmutablePrimitiveFieldGenerator::GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const {
// noop for primitives
}
-void ImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
- if (!IsDefaultValueJavaDefault(descriptor_)) {
- printer->Print(variables_, "$name$_ = $default$;\n");
- }
+void ImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
+ if (!IsDefaultValueJavaDefault(descriptor_)) {
+ printer->Print(variables_, "$name$_ = $default$;\n");
+ }
}
-void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = $default$;\n"
- "$clear_has_field_bit_builder$\n");
+ "$name$_ = $default$;\n"
+ "$clear_has_field_bit_builder$\n");
}
-void ImmutablePrimitiveFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
+void ImmutablePrimitiveFieldGenerator::GenerateMergingCode(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
printer->Print(variables_,
- "if (other.has$capitalized_name$()) {\n"
- " set$capitalized_name$(other.get$capitalized_name$());\n"
- "}\n");
+ "if (other.has$capitalized_name$()) {\n"
+ " set$capitalized_name$(other.get$capitalized_name$());\n"
+ "}\n");
} else {
printer->Print(variables_,
- "if (other.get$capitalized_name$() != $default$) {\n"
- " set$capitalized_name$(other.get$capitalized_name$());\n"
- "}\n");
+ "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_)) {
- if (IsDefaultValueJavaDefault(descriptor_)) {
- printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " result.$name$_ = $name$_;\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
- } else {
- printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n");
- }
- } else {
- printer->Print(variables_, "result.$name$_ = $name$_;\n");
+void ImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ if (IsDefaultValueJavaDefault(descriptor_)) {
+ printer->Print(variables_,
+ "if ($get_has_field_bit_from_local$) {\n"
+ " result.$name$_ = $name$_;\n"
+ " $set_has_field_bit_to_local$;\n"
+ "}\n");
+ } else {
+ printer->Print(variables_,
+ "if ($get_has_field_bit_from_local$) {\n"
+ " $set_has_field_bit_to_local$;\n"
+ "}\n"
+ "result.$name$_ = $name$_;\n");
+ }
+ } else {
+ printer->Print(variables_, "result.$name$_ = $name$_;\n");
}
}
-void ImmutablePrimitiveFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$set_has_field_bit_message$\n"
- "$name$_ = input.read$capitalized_type$();\n");
+ "$set_has_field_bit_message$\n"
+ "$name$_ = input.read$capitalized_type$();\n");
}
-void ImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
// noop for primitives.
}
-void ImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($is_field_present_message$) {\n"
- " output.write$capitalized_type$($number$, $name$_);\n"
- "}\n");
+ "if ($is_field_present_message$) {\n"
+ " output.write$capitalized_type$($number$, $name$_);\n"
+ "}\n");
}
-void ImmutablePrimitiveFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($is_field_present_message$) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .compute$capitalized_type$Size($number$, $name$_);\n"
- "}\n");
+ "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 {
+void ImmutablePrimitiveFieldGenerator::GenerateEqualsCode(
+ io::Printer* printer) const {
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");
+ "if (get$capitalized_name$()\n"
+ " != other.get$capitalized_name$()) return false;\n");
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");
+ 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:
- printer->Print(
- variables_,
- "if (java.lang.Double.doubleToLongBits(get$capitalized_name$())\n"
- " != java.lang.Double.doubleToLongBits(\n"
- " other.get$capitalized_name$())) return false;\n");
+ 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:
- printer->Print(
- variables_,
- "if (!get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$())) return false;\n");
+ printer->Print(
+ variables_,
+ "if (!get$capitalized_name$()\n"
+ " .equals(other.get$capitalized_name$())) return false;\n");
break;
case JAVATYPE_ENUM:
@@ -458,47 +458,47 @@ void ImmutablePrimitiveFieldGenerator::GenerateEqualsCode(
}
}
-void ImmutablePrimitiveFieldGenerator::GenerateHashCode(
- io::Printer* printer) const {
- printer->Print(variables_, "hash = (37 * hash) + $constant_name$;\n");
+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_,
- "hash = (53 * hash) + get$capitalized_name$();\n");
+ "hash = (53 * hash) + get$capitalized_name$();\n");
break;
case JAVATYPE_LONG:
- printer->Print(
- variables_,
- "hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
- " get$capitalized_name$());\n");
+ printer->Print(
+ variables_,
+ "hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
+ " get$capitalized_name$());\n");
break;
case JAVATYPE_BOOLEAN:
- printer->Print(
- variables_,
- "hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\n"
- " get$capitalized_name$());\n");
+ printer->Print(
+ variables_,
+ "hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\n"
+ " get$capitalized_name$());\n");
break;
case JAVATYPE_FLOAT:
printer->Print(variables_,
- "hash = (53 * hash) + java.lang.Float.floatToIntBits(\n"
- " get$capitalized_name$());\n");
+ "hash = (53 * hash) + java.lang.Float.floatToIntBits(\n"
+ " get$capitalized_name$());\n");
break;
case JAVATYPE_DOUBLE:
- printer->Print(
- variables_,
- "hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n"
- " java.lang.Double.doubleToLongBits(get$capitalized_name$()));\n");
+ 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:
- printer->Print(
- variables_,
- "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
+ printer->Print(
+ variables_,
+ "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
break;
case JAVATYPE_ENUM:
@@ -509,168 +509,168 @@ void ImmutablePrimitiveFieldGenerator::GenerateHashCode(
}
}
-TProtoStringType ImmutablePrimitiveFieldGenerator::GetBoxedType() const {
+TProtoStringType ImmutablePrimitiveFieldGenerator::GetBoxedType() const {
return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
}
// ===================================================================
-ImmutablePrimitiveOneofFieldGenerator::ImmutablePrimitiveOneofFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : ImmutablePrimitiveFieldGenerator(descriptor, messageBitIndex,
- builderBitIndex, context) {
+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::
- ~ImmutablePrimitiveOneofFieldGenerator() {}
+ ~ImmutablePrimitiveOneofFieldGenerator() {}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- 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);
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ 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_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($boxed_type$) $oneof_name$_;\n"
- " }\n"
- " return $default$;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($boxed_type$) $oneof_name$_;\n"
+ " }\n"
+ " return $default$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $has_oneof_case_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($boxed_type$) $oneof_name$_;\n"
- " }\n"
- " return $default$;\n"
- "}\n");
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($boxed_type$) $oneof_name$_;\n"
+ " }\n"
+ " return $default$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- "$null_check$"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ "$null_check$"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " $clear_oneof_case_message$;\n"
+ " $oneof_name$_ = null;\n"
+ " $on_changed$\n"
+ " }\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " $clear_oneof_case_message$;\n"
- " $oneof_name$_ = null;\n"
- " $on_changed$\n"
- " }\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " result.$oneof_name$_ = $oneof_name$_;\n"
- "}\n");
+ "if ($has_oneof_case_message$) {\n"
+ " result.$oneof_name$_ = $oneof_name$_;\n"
+ "}\n");
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldGenerator::GenerateMergingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "set$capitalized_name$(other.get$capitalized_name$());\n");
+ "set$capitalized_name$(other.get$capitalized_name$());\n");
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$set_oneof_case_message$;\n"
- "$oneof_name$_ = input.read$capitalized_type$();\n");
+ "$set_oneof_case_message$;\n"
+ "$oneof_name$_ = input.read$capitalized_type$();\n");
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " output.write$capitalized_type$(\n");
+ "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
// do redundant casts.
if (GetJavaType(descriptor_) == JAVATYPE_BYTES) {
- printer->Print(variables_, " $number$, ($type$) $oneof_name$_);\n");
+ printer->Print(variables_, " $number$, ($type$) $oneof_name$_);\n");
} else {
- printer->Print(
- variables_,
- " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n");
+ printer->Print(
+ variables_,
+ " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n");
}
- printer->Print("}\n");
+ printer->Print("}\n");
}
-void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " size += com.google.protobuf.CodedOutputStream\n"
- " .compute$capitalized_type$Size(\n");
+ "if ($has_oneof_case_message$) {\n"
+ " size += com.google.protobuf.CodedOutputStream\n"
+ " .compute$capitalized_type$Size(\n");
// $type$ and $boxed_type$ is the same for bytes fields so we don't need to
// do redundant casts.
if (GetJavaType(descriptor_) == JAVATYPE_BYTES) {
- printer->Print(variables_, " $number$, ($type$) $oneof_name$_);\n");
+ printer->Print(variables_, " $number$, ($type$) $oneof_name$_);\n");
} else {
- printer->Print(
- variables_,
- " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n");
+ printer->Print(
+ variables_,
+ " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n");
}
- printer->Print("}\n");
+ printer->Print("}\n");
}
// ===================================================================
RepeatedImmutablePrimitiveFieldGenerator::
- RepeatedImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- int builderBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+ 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::
- ~RepeatedImmutablePrimitiveFieldGenerator() {}
+ ~RepeatedImmutablePrimitiveFieldGenerator() {}
int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {
return 0;
@@ -680,412 +680,412 @@ int RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {
return 1;
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$java.util.List<$boxed_type$> "
- "get$capitalized_name$List();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ "$deprecation$java.util.List<$boxed_type$> "
+ "get$capitalized_name$List();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ "$deprecation$int get$capitalized_name$Count();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
- printer->Print(variables_, "private $field_list_type$ $name$_;\n");
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private $field_list_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$boxed_type$>\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return $name$_;\n" // note: unmodifiable list
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$boxed_type$>\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return $name$_;\n" // note: unmodifiable list
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $repeated_get$(index);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $repeated_get$(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (descriptor_->is_packed()) {
+ if (descriptor_->is_packed()) {
printer->Print(variables_,
- "private int $name$MemoizedSerializedSize = -1;\n");
+ "private int $name$MemoizedSerializedSize = -1;\n");
}
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+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
- // a reference to the underlying ArrayList. This invariant allows us to
+ // 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_,
- "private $field_list_type$ $name$_ = $empty_list$;\n");
+ "private $field_list_type$ $name$_ = $empty_list$;\n");
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
- // immutable.
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "$deprecation$public java.util.List<$boxed_type$>\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return $get_mutable_bit_builder$ ?\n"
- " java.util.Collections.unmodifiableList($name$_) : $name$_;\n"
- "}\n");
+ "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
+ // immutable.
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public java.util.List<$boxed_type$>\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return $get_mutable_bit_builder$ ?\n"
+ " java.util.Collections.unmodifiableList($name$_) : $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $repeated_get$(index);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $repeated_get$(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, $type$ value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $repeated_set$(index, value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$ value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $repeated_set$(index, value);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$$}$($type$ value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $repeated_add$(value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$$}$($type$ value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $repeated_add$(value);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<? extends $boxed_type$> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
- " values, $name$_);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<? extends $boxed_type$> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
+ " values, $name$_);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $name$_ = $empty_list$;\n"
- " $clear_mutable_bit_builder$;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " $name$_ = $empty_list$;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: $kt_type$) {\n"
- " add(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " addAll(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: $kt_type$) {\n"
+ " add(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " addAll(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
+}
+
void RepeatedImmutablePrimitiveFieldGenerator::
- GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
+ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for primitives
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $empty_list$;\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = $empty_list$;\n"
- "$clear_mutable_bit_builder$;\n");
+ "$name$_ = $empty_list$;\n"
+ "$clear_mutable_bit_builder$;\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+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_,
- "if (!other.$name$_.isEmpty()) {\n"
- " if ($name$_.isEmpty()) {\n"
- " $name$_ = other.$name$_;\n"
- " $clear_mutable_bit_builder$;\n"
- " } else {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.addAll(other.$name$_);\n"
- " }\n"
- " $on_changed$\n"
- "}\n");
+ "if (!other.$name$_.isEmpty()) {\n"
+ " if ($name$_.isEmpty()) {\n"
+ " $name$_ = other.$name$_;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " } else {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.addAll(other.$name$_);\n"
+ " }\n"
+ " $on_changed$\n"
+ "}\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+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_,
- "if ($get_mutable_bit_builder$) {\n"
- " $name_make_immutable$;\n"
- " $clear_mutable_bit_builder$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n");
+ "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 {
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
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");
+ "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(
- variables_,
- "int length = input.readRawVarint32();\n"
- "int limit = input.pushLimit(length);\n"
- "if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n"
- " $name$_ = $create_list$;\n"
- " $set_mutable_bit_parser$;\n"
- "}\n"
- "while (input.getBytesUntilLimit() > 0) {\n"
- " $repeated_add$(input.read$capitalized_type$());\n"
- "}\n"
- "input.popLimit(limit);\n");
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingCodeFromPacked(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "int length = input.readRawVarint32();\n"
+ "int limit = input.pushLimit(length);\n"
+ "if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\n"
+ " $name$_ = $create_list$;\n"
+ " $set_mutable_bit_parser$;\n"
+ "}\n"
+ "while (input.getBytesUntilLimit() > 0) {\n"
+ " $repeated_add$(input.read$capitalized_type$());\n"
+ "}\n"
+ "input.popLimit(limit);\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name_make_immutable$; // C\n"
- "}\n");
+ "if ($get_mutable_bit_parser$) {\n"
+ " $name_make_immutable$; // C\n"
+ "}\n");
}
-void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+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 (get$capitalized_name$List().size() > 0) {\n"
- " output.writeUInt32NoTag($tag$);\n"
- " output.writeUInt32NoTag($name$MemoizedSerializedSize);\n"
- "}\n"
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " output.write$capitalized_type$NoTag($repeated_get$(i));\n"
- "}\n");
+ "if (get$capitalized_name$List().size() > 0) {\n"
+ " output.writeUInt32NoTag($tag$);\n"
+ " output.writeUInt32NoTag($name$MemoizedSerializedSize);\n"
+ "}\n"
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
+ " output.write$capitalized_type$NoTag($repeated_get$(i));\n"
+ "}\n");
} else {
- printer->Print(
- variables_,
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " output.write$capitalized_type$($number$, $repeated_get$(i));\n"
- "}\n");
+ 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 {
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "{\n"
- " int dataSize = 0;\n");
+ "{\n"
+ " int dataSize = 0;\n");
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");
+ 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 {
- printer->Print(
- variables_,
- "dataSize = $fixed_size$ * get$capitalized_name$List().size();\n");
+ printer->Print(
+ variables_,
+ "dataSize = $fixed_size$ * get$capitalized_name$List().size();\n");
}
- printer->Print("size += dataSize;\n");
+ printer->Print("size += dataSize;\n");
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");
+ "if (!get$capitalized_name$List().isEmpty()) {\n"
+ " size += $tag_size$;\n"
+ " size += com.google.protobuf.CodedOutputStream\n"
+ " .computeInt32SizeNoTag(dataSize);\n"
+ "}\n");
} else {
- printer->Print(
- variables_,
- "size += $tag_size$ * get$capitalized_name$List().size();\n");
+ printer->Print(
+ variables_,
+ "size += $tag_size$ * get$capitalized_name$List().size();\n");
}
// cache the data size for packed fields.
if (descriptor_->is_packed()) {
- printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\n");
+ printer->Print(variables_, "$name$MemoizedSerializedSize = dataSize;\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::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(
- variables_,
- "if (get$capitalized_name$Count() > 0) {\n"
- " hash = (37 * hash) + $constant_name$;\n"
- " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
- "}\n");
+void RepeatedImmutablePrimitiveFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if (get$capitalized_name$Count() > 0) {\n"
+ " hash = (37 * hash) + $constant_name$;\n"
+ " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
+ "}\n");
}
-TProtoStringType RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const {
return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
}
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 81d636006c..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
@@ -36,59 +36,59 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__
#include <map>
-#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
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;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- 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;
+ explicit ImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ int builderBitIndex,
+ Context* context);
+ ~ImmutablePrimitiveFieldGenerator() override;
+
+ // implements ImmutableFieldGenerator
+ // ---------------------------------------
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
private:
@@ -98,9 +98,9 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
class ImmutablePrimitiveOneofFieldGenerator
: public ImmutablePrimitiveFieldGenerator {
public:
- ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- int builderBitIndex, Context* context);
+ ImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ int builderBitIndex, Context* context);
~ImmutablePrimitiveOneofFieldGenerator();
void GenerateMembers(io::Printer* printer) const;
@@ -121,34 +121,34 @@ class RepeatedImmutablePrimitiveFieldGenerator
explicit RepeatedImmutablePrimitiveFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
- ~RepeatedImmutablePrimitiveFieldGenerator() override;
+ ~RepeatedImmutablePrimitiveFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
- int GetNumBitsForMessage() const override;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingCodeFromPacked(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- 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;
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingCodeFromPacked(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldGenerator);
@@ -157,6 +157,6 @@ class RepeatedImmutablePrimitiveFieldGenerator
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 1859c6ef20..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
@@ -32,21 +32,21 @@
// 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 <google/protobuf/compiler/java/java_primitive_field_lite.h>
+
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <string>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -57,36 +57,36 @@ using internal::WireFormat;
using internal::WireFormatLite;
namespace {
-bool EnableExperimentalRuntimeForLite() {
-#ifdef PROTOBUF_EXPERIMENT
- return PROTOBUF_EXPERIMENT;
-#else // PROTOBUF_EXPERIMENT
- return false;
-#endif // !PROTOBUF_EXPERIMENT
-}
+bool EnableExperimentalRuntimeForLite() {
+#ifdef PROTOBUF_EXPERIMENT
+ return PROTOBUF_EXPERIMENT;
+#else // PROTOBUF_EXPERIMENT
+ return false;
+#endif // !PROTOBUF_EXPERIMENT
+}
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
+ int messageBitIndex, int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
JavaType javaType = GetJavaType(descriptor);
(*variables)["type"] = PrimitiveTypeName(javaType);
(*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
- (*variables)["kt_type"] = KotlinTypeName(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)["tag"] =
- StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = StrCat(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
- TProtoStringType capitalized_type = UnderscoresToCamelCase(
- PrimitiveTypeName(javaType), true /* cap_next_letter */);
+ TProtoStringType capitalized_type = UnderscoresToCamelCase(
+ PrimitiveTypeName(javaType), true /* cap_next_letter */);
switch (javaType) {
case JAVATYPE_INT:
case JAVATYPE_LONG:
@@ -127,28 +127,28 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
}
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";
+ // 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
- (*variables)["deprecation"] =
- descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
int fixed_size = FixedSize(GetType(descriptor));
if (fixed_size != -1) {
- (*variables)["fixed_size"] = StrCat(fixed_size);
+ (*variables)["fixed_size"] = StrCat(fixed_size);
}
- if (HasHasbit(descriptor)) {
+ if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
@@ -183,12 +183,12 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// ===================================================================
-ImmutablePrimitiveFieldLiteGenerator::ImmutablePrimitiveFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : descriptor_(descriptor),
- messageBitIndex_(messageBitIndex),
- name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, 0,
+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_);
}
@@ -196,22 +196,22 @@ ImmutablePrimitiveFieldLiteGenerator::ImmutablePrimitiveFieldLiteGenerator(
ImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {}
int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ return HasHasbit(descriptor_) ? 1 : 0;
}
-void ImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean has$capitalized_name$();\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(variables_, "$deprecation$$type$ get$capitalized_name$();\n");
}
-void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
+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.
@@ -219,137 +219,137 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
variables_,
"private static final $field_type$ $bytes_default$ = $default$;\n");
}
- printer->Print(variables_, "private $field_type$ $name$_;\n");
+ printer->Print(variables_, "private $field_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return $name$_;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
printer->Print(variables_,
- "private void set$capitalized_name$($type$ value) {\n"
- "$null_check$"
- " $set_has_field_bit_message$\n"
- " $name$_ = value;\n"
- "}\n");
+ "private void set$capitalized_name$($type$ value) {\n"
+ "$null_check$"
+ " $set_has_field_bit_message$\n"
+ " $name$_ = value;\n"
+ "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
printer->Print(variables_,
- "private void clear$capitalized_name$() {\n"
- " $clear_has_field_bit_message$\n");
+ "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.
- printer->Print(
- variables_,
- " $name$_ = getDefaultInstance().get$capitalized_name$();\n");
+ printer->Print(
+ variables_,
+ " $name$_ = getDefaultInstance().get$capitalized_name$();\n");
} else {
- printer->Print(variables_, " $name$_ = $default$;\n");
+ printer->Print(variables_, " $name$_ = $default$;\n");
}
- printer->Print(variables_, "}\n");
+ printer->Print(variables_, "}\n");
}
-void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
+void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ 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);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
+ "@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);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
- }
-}
-
-void ImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- if (HasHasbit(descriptor_)) {
- WriteIntToUtf16CharSequence(messageBitIndex_, output);
- }
- printer->Print(variables_, "\"$name$_\",\n");
+void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+ }
}
-void ImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ if (HasHasbit(descriptor_)) {
+ 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_)) {
@@ -357,403 +357,403 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
}
}
-TProtoStringType ImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType ImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
}
// ===================================================================
ImmutablePrimitiveOneofFieldLiteGenerator::
- ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context)
- : ImmutablePrimitiveFieldLiteGenerator(descriptor, messageBitIndex,
- context) {
+ 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::
- ~ImmutablePrimitiveOneofFieldLiteGenerator() {}
+ ~ImmutablePrimitiveOneofFieldLiteGenerator() {}
-void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- 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);
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ 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_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " return ($boxed_type$) $oneof_name$_;\n"
- " }\n"
- " return $default$;\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " return ($boxed_type$) $oneof_name$_;\n"
+ " }\n"
+ " return $default$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
printer->Print(variables_,
- "private void set$capitalized_name$($type$ value) {\n"
- "$null_check$"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- "}\n");
+ "private void set$capitalized_name$($type$ value) {\n"
+ "$null_check$"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
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");
+ "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);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
-}
-
-void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ 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_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
+ "@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);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
+ "@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);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$set$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$set$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
}
// ===================================================================
RepeatedImmutablePrimitiveFieldLiteGenerator::
- RepeatedImmutablePrimitiveFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex,
- Context* context)
- : descriptor_(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, 0,
+ RepeatedImmutablePrimitiveFieldLiteGenerator(
+ const FieldDescriptor* descriptor, int messageBitIndex,
+ Context* context)
+ : descriptor_(descriptor),
+ context_(context),
+ name_resolver_(context->GetNameResolver()) {
+ SetPrimitiveVariables(descriptor, messageBitIndex, 0,
context->GetFieldGeneratorInfo(descriptor),
name_resolver_, &variables_);
}
RepeatedImmutablePrimitiveFieldLiteGenerator::
- ~RepeatedImmutablePrimitiveFieldLiteGenerator() {}
+ ~RepeatedImmutablePrimitiveFieldLiteGenerator() {}
int RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {
return 0;
}
-void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$java.util.List<$boxed_type$> "
- "get$capitalized_name$List();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ "$deprecation$java.util.List<$boxed_type$> "
+ "get$capitalized_name$List();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
printer->Print(variables_,
- "$deprecation$int get$capitalized_name$Count();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ "$deprecation$int get$capitalized_name$Count();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$$type$ get$capitalized_name$(int index);\n");
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
}
-void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
- printer->Print(variables_, "private $field_list_type$ $name$_;\n");
+void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private $field_list_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$boxed_type$>\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return $name$_;\n" // note: unmodifiable list
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$boxed_type$>\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return $name$_;\n" // note: unmodifiable list
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return $repeated_get$(index);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return $repeated_get$(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() &&
+ if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() &&
context_->HasGeneratedMethods(descriptor_->containing_type())) {
printer->Print(variables_,
- "private int $name$MemoizedSerializedSize = -1;\n");
+ "private int $name$MemoizedSerializedSize = -1;\n");
}
- printer->Print(
- variables_,
- "private void ensure$capitalized_name$IsMutable() {\n"
- // Use a temporary to avoid a redundant iget-object.
- " $field_list_type$ tmp = $name$_;\n"
- " if (!tmp.isModifiable()) {\n"
- " $name$_ =\n"
- " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
- " }\n"
- "}\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
+ printer->Print(
+ variables_,
+ "private void ensure$capitalized_name$IsMutable() {\n"
+ // Use a temporary to avoid a redundant iget-object.
+ " $field_list_type$ tmp = $name$_;\n"
+ " if (!tmp.isModifiable()) {\n"
+ " $name$_ =\n"
+ " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
+ " }\n"
+ "}\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
printer->Print(variables_,
- "private void set$capitalized_name$(\n"
- " int index, $type$ value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $repeated_set$(index, value);\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
+ "private void set$capitalized_name$(\n"
+ " int index, $type$ value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $repeated_set$(index, value);\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
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);
+ "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_,
- "private void addAll$capitalized_name$(\n"
- " java.lang.Iterable<? extends $boxed_type$> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " com.google.protobuf.AbstractMessageLite.addAll(\n"
- " values, $name$_);\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ "private void addAll$capitalized_name$(\n"
+ " java.lang.Iterable<? extends $boxed_type$> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " com.google.protobuf.AbstractMessageLite.addAll(\n"
+ " values, $name$_);\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
printer->Print(variables_,
- "private void clear$capitalized_name$() {\n"
- " $name$_ = $empty_list$;\n"
- "}\n");
+ "private void clear$capitalized_name$() {\n"
+ " $name$_ = $empty_list$;\n"
+ "}\n");
}
-void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<$boxed_type$>\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return java.util.Collections.unmodifiableList(\n"
- " instance.get$capitalized_name$List());\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<$boxed_type$>\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return java.util.Collections.unmodifiableList(\n"
+ " instance.get$capitalized_name$List());\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return instance.get$capitalized_name$Count();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return instance.get$capitalized_name$Count();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
- " return instance.get$capitalized_name$(index);\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n"
+ " return instance.get$capitalized_name$(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, $type$ value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(index, value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, $type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(index, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder "
- "${$add$capitalized_name$$}$($type$ value) {\n"
- " copyOnWrite();\n"
- " instance.add$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder "
+ "${$add$capitalized_name$$}$($type$ value) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<? extends $boxed_type$> values) {\n"
- " copyOnWrite();\n"
- " instance.addAll$capitalized_name$(values);\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<? extends $boxed_type$> values) {\n"
+ " copyOnWrite();\n"
+ " instance.addAll$capitalized_name$(values);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.jvm.JvmSynthetic\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: $kt_type$) {\n"
- " add(value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
- " addAll(values)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: $kt_type$) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
-void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- printer->Print(variables_, "\"$name$_\",\n");
+void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$ val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.jvm.JvmSynthetic\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: $kt_type$) {\n"
+ " add(value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
+ " addAll(values)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: $kt_type$) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
+}
+
+void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ printer->Print(variables_, "\"$name$_\",\n");
}
-void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $empty_list$;\n");
}
-TProtoStringType RepeatedImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {
return BoxedPrimitiveTypeName(GetJavaType(descriptor_));
}
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 59e834056c..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
@@ -35,24 +35,24 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__
-#include <cstdint>
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -61,25 +61,25 @@ class ImmutablePrimitiveFieldLiteGenerator
: public ImmutableFieldLiteGenerator {
public:
explicit ImmutablePrimitiveFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
- ~ImmutablePrimitiveFieldLiteGenerator() override;
-
- // implements ImmutableFieldLiteGenerator
- // ------------------------------------
- int GetNumBitsForMessage() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
- TProtoStringType GetBoxedType() const override;
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ ~ImmutablePrimitiveFieldLiteGenerator() override;
+
+ // implements ImmutableFieldLiteGenerator
+ // ------------------------------------
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
const int messageBitIndex_;
ClassNameResolver* name_resolver_;
@@ -90,16 +90,16 @@ class ImmutablePrimitiveFieldLiteGenerator
class ImmutablePrimitiveOneofFieldLiteGenerator
: public ImmutablePrimitiveFieldLiteGenerator {
public:
- ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context);
+ ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context);
~ImmutablePrimitiveOneofFieldLiteGenerator();
void GenerateMembers(io::Printer* printer) const;
void GenerateBuilderMembers(io::Printer* printer) const;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const;
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator);
@@ -109,24 +109,24 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
: public ImmutableFieldLiteGenerator {
public:
explicit RepeatedImmutablePrimitiveFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
- ~RepeatedImmutablePrimitiveFieldLiteGenerator() override;
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ ~RepeatedImmutablePrimitiveFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
- int GetNumBitsForMessage() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const override;
+ void GenerateKotlinDslMembers(io::Printer* printer) const override;
- TProtoStringType GetBoxedType() const override;
+ TProtoStringType GetBoxedType() const override;
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
Context* context_;
ClassNameResolver* name_resolver_;
@@ -136,6 +136,6 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 3b46e0bb18..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
@@ -32,14 +32,14 @@
// 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_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>
+#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 {
@@ -47,16 +47,16 @@ namespace compiler {
namespace java {
ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor)
- : descriptor_(descriptor) {}
+ : descriptor_(descriptor) {}
ServiceGenerator::~ServiceGenerator() {}
// ===================================================================
ImmutableServiceGenerator::ImmutableServiceGenerator(
const ServiceDescriptor* descriptor, Context* context)
- : ServiceGenerator(descriptor),
- context_(context),
- name_resolver_(context->GetNameResolver()) {}
+ : ServiceGenerator(descriptor),
+ context_(context),
+ name_resolver_(context->GetNameResolver()) {}
ImmutableServiceGenerator::~ImmutableServiceGenerator() {}
@@ -66,13 +66,13 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
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());
+ "public $static$ abstract class $classname$\n"
+ " implements com.google.protobuf.Service {\n",
+ "static", is_own_file ? "" : "static", "classname", descriptor_->name());
printer->Indent();
- printer->Print("protected $classname$() {}\n\n", "classname",
- descriptor_->name());
+ printer->Print("protected $classname$() {}\n\n", "classname",
+ descriptor_->name());
GenerateInterface(printer);
@@ -83,13 +83,13 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
// Generate getDescriptor() and getDescriptorForType().
printer->Print(
- "public static final\n"
- " com.google.protobuf.Descriptors.ServiceDescriptor\n"
- " getDescriptor() {\n"
- " return $file$.getDescriptor().getServices().get($index$);\n"
- "}\n",
- "file", name_resolver_->GetImmutableClassName(descriptor_->file()),
- "index", StrCat(descriptor_->index()));
+ "public static final\n"
+ " com.google.protobuf.Descriptors.ServiceDescriptor\n"
+ " getDescriptor() {\n"
+ " return $file$.getDescriptor().getServices().get($index$);\n"
+ "}\n",
+ "file", name_resolver_->GetImmutableClassName(descriptor_->file()),
+ "index", StrCat(descriptor_->index()));
GenerateGetDescriptorForType(printer);
// Generate more stuff.
@@ -101,9 +101,9 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
// Add an insertion point.
printer->Print(
- "\n"
- "// @@protoc_insertion_point(class_scope:$full_name$)\n",
- "full_name", descriptor_->full_name());
+ "\n"
+ "// @@protoc_insertion_point(class_scope:$full_name$)\n",
+ "full_name", descriptor_->full_name());
printer->Outdent();
printer->Print("}\n\n");
@@ -112,10 +112,10 @@ void ImmutableServiceGenerator::Generate(io::Printer* printer) {
void ImmutableServiceGenerator::GenerateGetDescriptorForType(
io::Printer* printer) {
printer->Print(
- "public final com.google.protobuf.Descriptors.ServiceDescriptor\n"
- " getDescriptorForType() {\n"
- " return getDescriptor();\n"
- "}\n");
+ "public final com.google.protobuf.Descriptors.ServiceDescriptor\n"
+ " getDescriptorForType() {\n"
+ " return getDescriptor();\n"
+ "}\n");
}
void ImmutableServiceGenerator::GenerateInterface(io::Printer* printer) {
@@ -129,10 +129,10 @@ void ImmutableServiceGenerator::GenerateInterface(io::Printer* printer) {
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());
+ "public static com.google.protobuf.Service newReflectiveService(\n"
+ " final Interface impl) {\n"
+ " return new $classname$() {\n",
+ "classname", descriptor_->name());
printer->Indent();
printer->Indent();
@@ -141,10 +141,10 @@ void ImmutableServiceGenerator::GenerateNewReflectiveServiceMethod(
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));
+ " {\n"
+ " impl.$method$(controller, request, done);\n"
+ "}\n\n",
+ "method", UnderscoresToCamelCase(method));
}
printer->Outdent();
@@ -156,9 +156,9 @@ void ImmutableServiceGenerator::GenerateNewReflectiveServiceMethod(
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");
+ "public static com.google.protobuf.BlockingService\n"
+ " newReflectiveBlockingService(final BlockingInterface impl) {\n"
+ " return new com.google.protobuf.BlockingService() {\n");
printer->Indent();
printer->Indent();
@@ -183,170 +183,170 @@ void ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) {
}
}
-TProtoStringType ImmutableServiceGenerator::GetOutput(
- const MethodDescriptor* method) {
+TProtoStringType ImmutableServiceGenerator::GetOutput(
+ const MethodDescriptor* method) {
return name_resolver_->GetImmutableClassName(method->output_type());
}
void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
printer->Print(
- "\n"
- "public final void callMethod(\n"
- " com.google.protobuf.Descriptors.MethodDescriptor method,\n"
- " com.google.protobuf.RpcController controller,\n"
- " com.google.protobuf.Message request,\n"
- " com.google.protobuf.RpcCallback<\n"
- " com.google.protobuf.Message> done) {\n"
- " if (method.getService() != getDescriptor()) {\n"
- " throw new java.lang.IllegalArgumentException(\n"
- " \"Service.callMethod() given method descriptor for wrong \" +\n"
- " \"service type.\");\n"
- " }\n"
- " switch(method.getIndex()) {\n");
+ "\n"
+ "public final void callMethod(\n"
+ " com.google.protobuf.Descriptors.MethodDescriptor method,\n"
+ " com.google.protobuf.RpcController controller,\n"
+ " com.google.protobuf.Message request,\n"
+ " com.google.protobuf.RpcCallback<\n"
+ " com.google.protobuf.Message> done) {\n"
+ " if (method.getService() != getDescriptor()) {\n"
+ " throw new java.lang.IllegalArgumentException(\n"
+ " \"Service.callMethod() given method descriptor for wrong \" +\n"
+ " \"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);
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ std::map<TProtoStringType, TProtoStringType> vars;
+ vars["index"] = StrCat(i);
vars["method"] = UnderscoresToCamelCase(method);
- vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
+ vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
- printer->Print(
- vars,
- "case $index$:\n"
- " this.$method$(controller, ($input$)request,\n"
- " com.google.protobuf.RpcUtil.<$output$>specializeCallback(\n"
- " done));\n"
- " return;\n");
+ printer->Print(
+ vars,
+ "case $index$:\n"
+ " this.$method$(controller, ($input$)request,\n"
+ " com.google.protobuf.RpcUtil.<$output$>specializeCallback(\n"
+ " done));\n"
+ " return;\n");
}
printer->Print(
- "default:\n"
- " throw new java.lang.AssertionError(\"Can't get here.\");\n");
+ "default:\n"
+ " throw new java.lang.AssertionError(\"Can't get here.\");\n");
printer->Outdent();
printer->Outdent();
printer->Print(
- " }\n"
- "}\n"
- "\n");
+ " }\n"
+ "}\n"
+ "\n");
}
void ImmutableServiceGenerator::GenerateCallBlockingMethod(
io::Printer* printer) {
printer->Print(
- "\n"
- "public final com.google.protobuf.Message callBlockingMethod(\n"
- " com.google.protobuf.Descriptors.MethodDescriptor method,\n"
- " com.google.protobuf.RpcController controller,\n"
- " com.google.protobuf.Message request)\n"
- " throws com.google.protobuf.ServiceException {\n"
- " if (method.getService() != getDescriptor()) {\n"
- " throw new java.lang.IllegalArgumentException(\n"
- " \"Service.callBlockingMethod() given method descriptor for \" +\n"
- " \"wrong service type.\");\n"
- " }\n"
- " switch(method.getIndex()) {\n");
+ "\n"
+ "public final com.google.protobuf.Message callBlockingMethod(\n"
+ " com.google.protobuf.Descriptors.MethodDescriptor method,\n"
+ " com.google.protobuf.RpcController controller,\n"
+ " com.google.protobuf.Message request)\n"
+ " throws com.google.protobuf.ServiceException {\n"
+ " if (method.getService() != getDescriptor()) {\n"
+ " throw new java.lang.IllegalArgumentException(\n"
+ " \"Service.callBlockingMethod() given method descriptor for \" +\n"
+ " \"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);
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ std::map<TProtoStringType, TProtoStringType> vars;
+ vars["index"] = StrCat(i);
vars["method"] = UnderscoresToCamelCase(method);
- vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
+ vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
printer->Print(vars,
- "case $index$:\n"
- " return impl.$method$(controller, ($input$)request);\n");
+ "case $index$:\n"
+ " return impl.$method$(controller, ($input$)request);\n");
}
printer->Print(
- "default:\n"
- " throw new java.lang.AssertionError(\"Can't get here.\");\n");
+ "default:\n"
+ " throw new java.lang.AssertionError(\"Can't get here.\");\n");
printer->Outdent();
printer->Outdent();
printer->Print(
- " }\n"
- "}\n"
- "\n");
+ " }\n"
+ "}\n"
+ "\n");
}
void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
- io::Printer* printer) {
+ io::Printer* printer) {
/*
* 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"
- " if (method.getService() != getDescriptor()) {\n"
- " throw new java.lang.IllegalArgumentException(\n"
- " \"Service.get$request_or_response$Prototype() given method \" +\n"
- " \"descriptor for wrong service type.\");\n"
- " }\n"
- " switch(method.getIndex()) {\n",
- "request_or_response", (which == REQUEST) ? "Request" : "Response");
+ "public final com.google.protobuf.Message\n"
+ " get$request_or_response$Prototype(\n"
+ " com.google.protobuf.Descriptors.MethodDescriptor method) {\n"
+ " if (method.getService() != getDescriptor()) {\n"
+ " throw new java.lang.IllegalArgumentException(\n"
+ " \"Service.get$request_or_response$Prototype() given method \" +\n"
+ " \"descriptor for wrong service type.\");\n"
+ " }\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);
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
- vars["type"] =
- (which == REQUEST)
- ? name_resolver_->GetImmutableClassName(method->input_type())
- : GetOutput(method);
+ std::map<TProtoStringType, TProtoStringType> vars;
+ vars["index"] = StrCat(i);
+ vars["type"] =
+ (which == REQUEST)
+ ? name_resolver_->GetImmutableClassName(method->input_type())
+ : GetOutput(method);
printer->Print(vars,
- "case $index$:\n"
- " return $type$.getDefaultInstance();\n");
+ "case $index$:\n"
+ " return $type$.getDefaultInstance();\n");
}
printer->Print(
- "default:\n"
- " throw new java.lang.AssertionError(\"Can't get here.\");\n");
+ "default:\n"
+ " throw new java.lang.AssertionError(\"Can't get here.\");\n");
printer->Outdent();
printer->Outdent();
printer->Print(
- " }\n"
- "}\n"
- "\n");
+ " }\n"
+ "}\n"
+ "\n");
}
void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Print(
- "public static Stub newStub(\n"
- " com.google.protobuf.RpcChannel channel) {\n"
- " return new Stub(channel);\n"
- "}\n"
- "\n"
- "public static final class Stub extends $classname$ implements Interface "
- "{"
- "\n",
- "classname", name_resolver_->GetImmutableClassName(descriptor_));
+ "public static Stub newStub(\n"
+ " com.google.protobuf.RpcChannel channel) {\n"
+ " return new Stub(channel);\n"
+ "}\n"
+ "\n"
+ "public static final class Stub extends $classname$ implements Interface "
+ "{"
+ "\n",
+ "classname", name_resolver_->GetImmutableClassName(descriptor_));
printer->Indent();
printer->Print(
- "private Stub(com.google.protobuf.RpcChannel channel) {\n"
- " this.channel = channel;\n"
- "}\n"
- "\n"
- "private final com.google.protobuf.RpcChannel channel;\n"
- "\n"
- "public com.google.protobuf.RpcChannel getChannel() {\n"
- " return channel;\n"
- "}\n");
+ "private Stub(com.google.protobuf.RpcChannel channel) {\n"
+ " this.channel = channel;\n"
+ "}\n"
+ "\n"
+ "private final com.google.protobuf.RpcChannel channel;\n"
+ "\n"
+ "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);
@@ -355,19 +355,19 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ std::map<TProtoStringType, TProtoStringType> vars;
+ vars["index"] = StrCat(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
- "channel.callMethod(\n"
- " getDescriptor().getMethods().get($index$),\n"
- " controller,\n"
- " request,\n"
- " $output$.getDefaultInstance(),\n"
- " com.google.protobuf.RpcUtil.generalizeCallback(\n"
- " done,\n"
- " $output$.class,\n"
- " $output$.getDefaultInstance()));\n");
+ "channel.callMethod(\n"
+ " getDescriptor().getMethods().get($index$),\n"
+ " controller,\n"
+ " request,\n"
+ " $output$.getDefaultInstance(),\n"
+ " com.google.protobuf.RpcUtil.generalizeCallback(\n"
+ " done,\n"
+ " $output$.class,\n"
+ " $output$.getDefaultInstance()));\n");
printer->Outdent();
printer->Print("}\n");
@@ -375,19 +375,19 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
}
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");
+ "public static BlockingInterface newBlockingStub(\n"
+ " com.google.protobuf.BlockingRpcChannel channel) {\n"
+ " return new BlockingStub(channel);\n"
+ "}\n"
+ "\n");
- printer->Print("public interface BlockingInterface {");
+ printer->Print("public interface BlockingInterface {");
printer->Indent();
for (int i = 0; i < descriptor_->method_count(); i++) {
@@ -398,20 +398,20 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
printer->Print(
- "private static final class BlockingStub implements BlockingInterface "
- "{\n");
+ "private static final class BlockingStub implements BlockingInterface "
+ "{\n");
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");
+ "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);
@@ -419,53 +419,53 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- std::map<TProtoStringType, TProtoStringType> vars;
- vars["index"] = StrCat(i);
+ std::map<TProtoStringType, TProtoStringType> vars;
+ vars["index"] = StrCat(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
- "return ($output$) channel.callBlockingMethod(\n"
- " getDescriptor().getMethods().get($index$),\n"
- " controller,\n"
- " request,\n"
- " $output$.getDefaultInstance());\n");
+ "return ($output$) channel.callBlockingMethod(\n"
+ " getDescriptor().getMethods().get($index$),\n"
+ " controller,\n"
+ " request,\n"
+ " $output$.getDefaultInstance());\n");
printer->Outdent();
printer->Print(
- "}\n"
- "\n");
+ "}\n"
+ "\n");
}
printer->Outdent();
printer->Print("}\n");
}
-void ImmutableServiceGenerator::GenerateMethodSignature(
- io::Printer* printer, const MethodDescriptor* method,
- IsAbstract is_abstract) {
- std::map<TProtoStringType, TProtoStringType> vars;
+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["output"] = GetOutput(method);
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)");
+ "public $abstract$ void $name$(\n"
+ " com.google.protobuf.RpcController controller,\n"
+ " $input$ request,\n"
+ " com.google.protobuf.RpcCallback<$output$> done)");
}
void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
- io::Printer* printer, const MethodDescriptor* method) {
- std::map<TProtoStringType, TProtoStringType> vars;
+ io::Printer* printer, const MethodDescriptor* method) {
+ std::map<TProtoStringType, TProtoStringType> vars;
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
printer->Print(vars,
- "\n"
- "public $output$ $method$(\n"
- " com.google.protobuf.RpcController controller,\n"
- " $input$ request)\n"
- " throws com.google.protobuf.ServiceException");
+ "\n"
+ "public $output$ $method$(\n"
+ " com.google.protobuf.RpcController controller,\n"
+ " $input$ request)\n"
+ " throws com.google.protobuf.ServiceException");
}
} // namespace java
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 1acff2f779..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
@@ -36,23 +36,23 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
#include <map>
-#include <google/protobuf/descriptor.h>
+#include <google/protobuf/descriptor.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-namespace io {
-class Printer; // printer.h
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+namespace io {
+class Printer; // printer.h
}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -124,7 +124,7 @@ class ImmutableServiceGenerator : public ServiceGenerator {
const MethodDescriptor* method);
// Return the output type of the method.
- TProtoStringType GetOutput(const MethodDescriptor* method);
+ TProtoStringType GetOutput(const MethodDescriptor* method);
Context* context_;
ClassNameResolver* name_resolver_;
@@ -134,6 +134,6 @@ class ImmutableServiceGenerator : public ServiceGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 4a0f62f197..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
@@ -30,19 +30,19 @@
// Author: xiaofeng@google.com (Feng Xiao)
-#include <google/protobuf/compiler/java/java_shared_code_generator.h>
+#include <google/protobuf/compiler/java/java_shared_code_generator.h>
#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>
-#include <google/protobuf/compiler/code_generator.h>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/strutil.h>
+#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>
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -53,28 +53,28 @@ SharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file,
const Options& options)
: name_resolver_(new ClassNameResolver), file_(file), options_(options) {}
-SharedCodeGenerator::~SharedCodeGenerator() {}
+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);
+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.
- TProtoStringType classname = name_resolver_->GetDescriptorClassName(file_);
- TProtoStringType filename = package_dir + classname + ".java";
+ TProtoStringType classname = name_resolver_->GetDescriptorClassName(file_);
+ TProtoStringType filename = package_dir + classname + ".java";
file_list->push_back(filename);
- std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
+ std::unique_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));
GeneratedCodeInfo annotations;
io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(
&annotations);
- std::unique_ptr<io::Printer> printer(
+ std::unique_ptr<io::Printer> printer(
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";
+ 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"
@@ -82,9 +82,9 @@ void SharedCodeGenerator::Generate(
"filename", file_->name());
if (!java_package.empty()) {
printer->Print(
- "package $package$;\n"
- "\n",
- "package", java_package);
+ "package $package$;\n"
+ "\n",
+ "package", java_package);
}
PrintGeneratedAnnotation(printer.get(), '$',
options_.annotate_code ? info_relative_path : "");
@@ -101,11 +101,11 @@ void SharedCodeGenerator::Generate(
printer->Outdent();
printer->Outdent();
printer->Print(
- " }\n"
- "}\n");
+ " }\n"
+ "}\n");
if (options_.annotate_code) {
- std::unique_ptr<io::ZeroCopyOutputStream> info_output(
+ 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);
@@ -130,29 +130,29 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
FileDescriptorProto file_proto;
file_->CopyTo(&file_proto);
- TProtoStringType file_data;
+ TProtoStringType file_data;
file_proto.SerializeToString(&file_data);
- printer->Print("java.lang.String[] descriptorData = {\n");
+ printer->Print("java.lang.String[] descriptorData = {\n");
printer->Indent();
- // Limit the number of bytes per line.
+ // Limit the number of bytes per line.
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;
+ // 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) {
- if (i % kBytesPerPart == 0) {
+ if (i % kBytesPerPart == 0) {
printer->Print(",\n");
} else {
printer->Print(" +\n");
}
}
- printer->Print("\"$data$\"", "data",
- CEscape(file_data.substr(i, kBytesPerLine)));
+ printer->Print("\"$data$\"", "data",
+ CEscape(file_data.substr(i, kBytesPerLine)));
}
printer->Outdent();
@@ -160,13 +160,13 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
// -----------------------------------------------------------------
// Find out all dependencies.
- std::vector<std::pair<TProtoStringType, TProtoStringType> > dependencies;
+ std::vector<std::pair<TProtoStringType, TProtoStringType> > dependencies;
for (int i = 0; i < file_->dependency_count(); i++) {
- TProtoStringType filename = file_->dependency(i)->name();
- TProtoStringType package = FileJavaPackage(file_->dependency(i));
- TProtoStringType classname =
- name_resolver_->GetDescriptorClassName(file_->dependency(i));
- TProtoStringType full_name;
+ TProtoStringType filename = file_->dependency(i)->name();
+ TProtoStringType package = FileJavaPackage(file_->dependency(i));
+ TProtoStringType classname =
+ name_resolver_->GetDescriptorClassName(file_->dependency(i));
+ TProtoStringType full_name;
if (package.empty()) {
full_name = classname;
} else {
@@ -178,18 +178,18 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
// -----------------------------------------------------------------
// Invoke internalBuildGeneratedFileFrom() to build the file.
printer->Print(
- "descriptor = com.google.protobuf.Descriptors.FileDescriptor\n"
- " .internalBuildGeneratedFileFrom(descriptorData,\n");
+ "descriptor = com.google.protobuf.Descriptors.FileDescriptor\n"
+ " .internalBuildGeneratedFileFrom(descriptorData,\n");
printer->Print(
- " new com.google.protobuf.Descriptors.FileDescriptor[] {\n");
+ " new com.google.protobuf.Descriptors.FileDescriptor[] {\n");
for (int i = 0; i < dependencies.size(); i++) {
- const TProtoStringType& dependency = dependencies[i].second;
- printer->Print(" $dependency$.getDescriptor(),\n", "dependency",
- dependency);
+ const TProtoStringType& dependency = dependencies[i].second;
+ printer->Print(" $dependency$.getDescriptor(),\n", "dependency",
+ dependency);
}
- printer->Print(" });\n");
+ printer->Print(" });\n");
}
} // namespace java
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 268a84a7a7..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
@@ -36,28 +36,28 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__
#include <memory>
-#include <string>
+#include <string>
#include <vector>
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/compiler/java/java_options.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/compiler/java/java_options.h>
namespace google {
namespace protobuf {
-class FileDescriptor; // descriptor.h
-namespace compiler {
-class GeneratorContext; // code_generator.h
-namespace java {
-class ClassNameResolver; // name_resolver.h
+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 compiler
-namespace io {
-class Printer; // printer.h
-}
-} // namespace protobuf
-} // namespace google
+} // namespace protobuf
+} // namespace google
-namespace google {
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
@@ -70,13 +70,13 @@ class SharedCodeGenerator {
~SharedCodeGenerator();
void Generate(GeneratorContext* generator_context,
- std::vector<TProtoStringType>* file_list,
- std::vector<TProtoStringType>* annotation_file_list);
+ std::vector<TProtoStringType>* file_list,
+ std::vector<TProtoStringType>* annotation_file_list);
void GenerateDescriptors(io::Printer* printer);
private:
- std::unique_ptr<ClassNameResolver> name_resolver_;
+ std::unique_ptr<ClassNameResolver> name_resolver_;
const FileDescriptor* file_;
const Options options_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator);
@@ -85,6 +85,6 @@ class SharedCodeGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 e9b7591c78..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
@@ -33,21 +33,21 @@
// 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 <google/protobuf/compiler/java/java_string_field.h>
+
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <string>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -60,10 +60,10 @@ using internal::WireFormatLite;
namespace {
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
+ int messageBitIndex, int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY";
@@ -73,31 +73,31 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "String";
(*variables)["tag"] =
- StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ 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";
- (*variables)["writeString"] = "com.google.protobuf.GeneratedMessage" +
- GeneratedCodeVersionSuffix() + ".writeString";
- (*variables)["computeStringSize"] = "com.google.protobuf.GeneratedMessage" +
- GeneratedCodeVersionSuffix() +
- ".computeStringSize";
+ (*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
- (*variables)["deprecation"] =
- descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
(*variables)["on_changed"] = "onChanged();";
- if (HasHasbit(descriptor)) {
+ 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);
@@ -142,10 +142,10 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// ===================================================================
-ImmutableStringFieldGenerator::ImmutableStringFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
+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_);
@@ -154,17 +154,17 @@ ImmutableStringFieldGenerator::ImmutableStringFieldGenerator(
ImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {}
int ImmutableStringFieldGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ return HasHasbit(descriptor_) ? 1 : 0;
}
int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
- return GetNumBitsForMessage();
+ return GetNumBitsForMessage();
}
// 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
+// 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
@@ -193,566 +193,566 @@ int ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
// 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);
+void ImmutableStringFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean has$capitalized_name$();\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$java.lang.String get$capitalized_name$();\n");
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ "$deprecation$java.lang.String get$capitalized_name$();\n");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$com.google.protobuf.ByteString\n"
- " get$capitalized_name$Bytes();\n");
+ "$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");
+void ImmutableStringFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private volatile java.lang.Object $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " java.lang.Object ref = $name$_;\n"
- " if (ref instanceof java.lang.String) {\n"
- " return (java.lang.String) ref;\n"
- " } else {\n"
- " com.google.protobuf.ByteString bs = \n"
- " (com.google.protobuf.ByteString) ref;\n"
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " java.lang.Object ref = $name$_;\n"
+ " if (ref instanceof java.lang.String) {\n"
+ " return (java.lang.String) ref;\n"
+ " } else {\n"
+ " com.google.protobuf.ByteString bs = \n"
+ " (com.google.protobuf.ByteString) ref;\n"
" java.lang.String s = bs.toStringUtf8();\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " $name$_ = s;\n");
+ printer->Print(variables_, " $name$_ = s;\n");
} else {
printer->Print(variables_,
- " if (bs.isValidUtf8()) {\n"
- " $name$_ = s;\n"
- " }\n");
+ " if (bs.isValidUtf8()) {\n"
+ " $name$_ = s;\n"
+ " }\n");
}
printer->Print(variables_,
- " return s;\n"
- " }\n"
- "}\n");
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ " return s;\n"
+ " }\n"
+ "}\n");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$() {\n"
- " java.lang.Object ref = $name$_;\n"
- " if (ref instanceof java.lang.String) {\n"
- " com.google.protobuf.ByteString b = \n"
- " com.google.protobuf.ByteString.copyFromUtf8(\n"
- " (java.lang.String) ref);\n"
- " $name$_ = b;\n"
- " return b;\n"
- " } else {\n"
- " return (com.google.protobuf.ByteString) ref;\n"
- " }\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$() {\n"
+ " java.lang.Object ref = $name$_;\n"
+ " if (ref instanceof java.lang.String) {\n"
+ " com.google.protobuf.ByteString b = \n"
+ " com.google.protobuf.ByteString.copyFromUtf8(\n"
+ " (java.lang.String) ref);\n"
+ " $name$_ = b;\n"
+ " return b;\n"
+ " } else {\n"
+ " return (com.google.protobuf.ByteString) ref;\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableStringFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
printer->Print(variables_,
- "private java.lang.Object $name$_ $default_init$;\n");
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_builder$;\n"
- "}\n");
+ "private java.lang.Object $name$_ $default_init$;\n");
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_builder$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " java.lang.Object ref = $name$_;\n"
- " if (!(ref instanceof java.lang.String)) {\n"
- " com.google.protobuf.ByteString bs =\n"
- " (com.google.protobuf.ByteString) ref;\n"
- " java.lang.String s = bs.toStringUtf8();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " java.lang.Object ref = $name$_;\n"
+ " if (!(ref instanceof java.lang.String)) {\n"
+ " com.google.protobuf.ByteString bs =\n"
+ " (com.google.protobuf.ByteString) ref;\n"
+ " java.lang.String s = bs.toStringUtf8();\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " $name$_ = s;\n");
+ printer->Print(variables_, " $name$_ = s;\n");
} else {
printer->Print(variables_,
- " if (bs.isValidUtf8()) {\n"
- " $name$_ = s;\n"
- " }\n");
+ " if (bs.isValidUtf8()) {\n"
+ " $name$_ = s;\n"
+ " }\n");
}
printer->Print(variables_,
- " return s;\n"
- " } else {\n"
- " return (java.lang.String) ref;\n"
- " }\n"
- "}\n");
+ " return s;\n"
+ " } else {\n"
+ " return (java.lang.String) ref;\n"
+ " }\n"
+ "}\n");
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$() {\n"
- " java.lang.Object ref = $name$_;\n"
- " if (ref instanceof String) {\n"
- " com.google.protobuf.ByteString b = \n"
- " com.google.protobuf.ByteString.copyFromUtf8(\n"
- " (java.lang.String) ref);\n"
- " $name$_ = b;\n"
- " return b;\n"
- " } else {\n"
- " return (com.google.protobuf.ByteString) ref;\n"
- " }\n"
- "}\n");
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$() {\n"
+ " java.lang.Object ref = $name$_;\n"
+ " if (ref instanceof String) {\n"
+ " com.google.protobuf.ByteString b = \n"
+ " com.google.protobuf.ByteString.copyFromUtf8(\n"
+ " (java.lang.String) ref);\n"
+ " $name$_ = b;\n"
+ " return b;\n"
+ " } else {\n"
+ " return (com.google.protobuf.ByteString) ref;\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- "$null_check$"
- " $set_has_field_bit_builder$\n"
- " $name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ "$null_check$"
+ " $set_has_field_bit_builder$\n"
+ " $name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $clear_has_field_bit_builder$\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$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_,
- " $name$_ = getDefaultInstance().get$capitalized_name$();\n");
+ " $name$_ = getDefaultInstance().get$capitalized_name$();\n");
printer->Print(variables_,
- " $on_changed$\n"
- " return this;\n"
- "}\n");
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n"
- "$null_check$");
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n"
+ "$null_check$");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
+ printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " $set_has_field_bit_builder$\n"
- " $name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ " $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_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: kotlin.String\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+ }
}
-void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: kotlin.String\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
- }
-}
-
-void ImmutableStringFieldGenerator::GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const {
// noop for primitives
}
-void ImmutableStringFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $default$;\n");
}
-void ImmutableStringFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = $default$;\n"
- "$clear_has_field_bit_builder$\n");
+ "$name$_ = $default$;\n"
+ "$clear_has_field_bit_builder$\n");
}
-void ImmutableStringFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
+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_,
- "if (other.has$capitalized_name$()) {\n"
- " $set_has_field_bit_builder$\n"
- " $name$_ = other.$name$_;\n"
- " $on_changed$\n"
- "}\n");
+ "if (other.has$capitalized_name$()) {\n"
+ " $set_has_field_bit_builder$\n"
+ " $name$_ = other.$name$_;\n"
+ " $on_changed$\n"
+ "}\n");
} else {
printer->Print(variables_,
- "if (!other.get$capitalized_name$().isEmpty()) {\n"
- " $name$_ = other.$name$_;\n"
- " $on_changed$\n"
- "}\n");
+ "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_)) {
+void ImmutableStringFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
printer->Print(variables_,
- "if ($get_has_field_bit_from_local$) {\n"
- " $set_has_field_bit_to_local$;\n"
- "}\n");
+ "if ($get_has_field_bit_from_local$) {\n"
+ " $set_has_field_bit_to_local$;\n"
+ "}\n");
}
- printer->Print(variables_, "result.$name$_ = $name$_;\n");
+ printer->Print(variables_, "result.$name$_ = $name$_;\n");
}
-void ImmutableStringFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
- "java.lang.String s = input.readStringRequireUtf8();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = s;\n");
+ "java.lang.String s = input.readStringRequireUtf8();\n"
+ "$set_has_field_bit_message$\n"
+ "$name$_ = s;\n");
} else {
printer->Print(variables_,
- "com.google.protobuf.ByteString bs = input.readBytes();\n"
- "$set_has_field_bit_message$\n"
- "$name$_ = bs;\n");
+ "com.google.protobuf.ByteString bs = input.readBytes();\n"
+ "$set_has_field_bit_message$\n"
+ "$name$_ = bs;\n");
}
}
-void ImmutableStringFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
// noop for strings.
}
-void ImmutableStringFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($is_field_present_message$) {\n"
- " $writeString$(output, $number$, $name$_);\n"
- "}\n");
+ "if ($is_field_present_message$) {\n"
+ " $writeString$(output, $number$, $name$_);\n"
+ "}\n");
}
-void ImmutableStringFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($is_field_present_message$) {\n"
- " size += $computeStringSize$($number$, $name$_);\n"
- "}\n");
+ "if ($is_field_present_message$) {\n"
+ " size += $computeStringSize$($number$, $name$_);\n"
+ "}\n");
}
-void ImmutableStringFieldGenerator::GenerateEqualsCode(
- io::Printer* printer) const {
+void ImmutableStringFieldGenerator::GenerateEqualsCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if (!get$capitalized_name$()\n"
- " .equals(other.get$capitalized_name$())) return false;\n");
+ "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");
+void ImmutableStringFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
+ printer->Print(variables_, "hash = (37 * hash) + $constant_name$;\n");
printer->Print(variables_,
- "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
+ "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
}
-TProtoStringType ImmutableStringFieldGenerator::GetBoxedType() const {
+TProtoStringType ImmutableStringFieldGenerator::GetBoxedType() const {
return "java.lang.String";
}
// ===================================================================
-ImmutableStringOneofFieldGenerator::ImmutableStringOneofFieldGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, int builderBitIndex,
- Context* context)
- : ImmutableStringFieldGenerator(descriptor, messageBitIndex,
- builderBitIndex, context) {
+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_);
}
-ImmutableStringOneofFieldGenerator::~ImmutableStringOneofFieldGenerator() {}
+ImmutableStringOneofFieldGenerator::~ImmutableStringOneofFieldGenerator() {}
-void ImmutableStringOneofFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutableStringOneofFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\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_,
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " java.lang.Object ref $default_init$;\n"
- " if ($has_oneof_case_message$) {\n"
- " ref = $oneof_name$_;\n"
- " }\n"
- " if (ref instanceof java.lang.String) {\n"
- " return (java.lang.String) ref;\n"
- " } else {\n"
- " com.google.protobuf.ByteString bs = \n"
- " (com.google.protobuf.ByteString) ref;\n"
- " java.lang.String s = bs.toStringUtf8();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " java.lang.Object ref $default_init$;\n"
+ " if ($has_oneof_case_message$) {\n"
+ " ref = $oneof_name$_;\n"
+ " }\n"
+ " if (ref instanceof java.lang.String) {\n"
+ " return (java.lang.String) ref;\n"
+ " } else {\n"
+ " com.google.protobuf.ByteString bs = \n"
+ " (com.google.protobuf.ByteString) ref;\n"
+ " java.lang.String s = bs.toStringUtf8();\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
- " if ($has_oneof_case_message$) {\n"
- " $oneof_name$_ = s;\n"
- " }\n");
+ " if ($has_oneof_case_message$) {\n"
+ " $oneof_name$_ = s;\n"
+ " }\n");
} else {
printer->Print(variables_,
- " if (bs.isValidUtf8() && ($has_oneof_case_message$)) {\n"
- " $oneof_name$_ = s;\n"
- " }\n");
+ " if (bs.isValidUtf8() && ($has_oneof_case_message$)) {\n"
+ " $oneof_name$_ = s;\n"
+ " }\n");
}
printer->Print(variables_,
- " return s;\n"
- " }\n"
- "}\n");
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ " return s;\n"
+ " }\n"
+ "}\n");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$() {\n"
- " java.lang.Object ref $default_init$;\n"
- " if ($has_oneof_case_message$) {\n"
- " ref = $oneof_name$_;\n"
- " }\n"
- " if (ref instanceof java.lang.String) {\n"
- " com.google.protobuf.ByteString b = \n"
- " com.google.protobuf.ByteString.copyFromUtf8(\n"
- " (java.lang.String) ref);\n"
- " if ($has_oneof_case_message$) {\n"
- " $oneof_name$_ = b;\n"
- " }\n"
- " return b;\n"
- " } else {\n"
- " return (com.google.protobuf.ByteString) ref;\n"
- " }\n"
- "}\n");
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$() {\n"
+ " java.lang.Object ref $default_init$;\n"
+ " if ($has_oneof_case_message$) {\n"
+ " ref = $oneof_name$_;\n"
+ " }\n"
+ " if (ref instanceof java.lang.String) {\n"
+ " com.google.protobuf.ByteString b = \n"
+ " com.google.protobuf.ByteString.copyFromUtf8(\n"
+ " (java.lang.String) ref);\n"
+ " if ($has_oneof_case_message$) {\n"
+ " $oneof_name$_ = b;\n"
+ " }\n"
+ " return b;\n"
+ " } else {\n"
+ " return (com.google.protobuf.ByteString) ref;\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
+ "@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_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " java.lang.Object ref $default_init$;\n"
+ " if ($has_oneof_case_message$) {\n"
+ " ref = $oneof_name$_;\n"
+ " }\n"
+ " if (!(ref instanceof java.lang.String)) {\n"
+ " com.google.protobuf.ByteString bs =\n"
+ " (com.google.protobuf.ByteString) ref;\n"
+ " java.lang.String s = bs.toStringUtf8();\n"
+ " if ($has_oneof_case_message$) {\n");
printer->Annotate("{", "}", descriptor_);
-
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " java.lang.Object ref $default_init$;\n"
- " if ($has_oneof_case_message$) {\n"
- " ref = $oneof_name$_;\n"
- " }\n"
- " if (!(ref instanceof java.lang.String)) {\n"
- " com.google.protobuf.ByteString bs =\n"
- " (com.google.protobuf.ByteString) ref;\n"
- " java.lang.String s = bs.toStringUtf8();\n"
- " if ($has_oneof_case_message$) {\n");
- printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " $oneof_name$_ = s;\n");
+ printer->Print(variables_, " $oneof_name$_ = s;\n");
} else {
printer->Print(variables_,
- " if (bs.isValidUtf8()) {\n"
- " $oneof_name$_ = s;\n"
- " }\n");
+ " if (bs.isValidUtf8()) {\n"
+ " $oneof_name$_ = s;\n"
+ " }\n");
}
printer->Print(variables_,
- " }\n"
- " return s;\n"
- " } else {\n"
- " return (java.lang.String) ref;\n"
- " }\n"
- "}\n");
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ " }\n"
+ " return s;\n"
+ " } else {\n"
+ " return (java.lang.String) ref;\n"
+ " }\n"
+ "}\n");
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$() {\n"
- " java.lang.Object ref $default_init$;\n"
- " if ($has_oneof_case_message$) {\n"
- " ref = $oneof_name$_;\n"
- " }\n"
- " if (ref instanceof String) {\n"
- " com.google.protobuf.ByteString b = \n"
- " com.google.protobuf.ByteString.copyFromUtf8(\n"
- " (java.lang.String) ref);\n"
- " if ($has_oneof_case_message$) {\n"
- " $oneof_name$_ = b;\n"
- " }\n"
- " return b;\n"
- " } else {\n"
- " return (com.google.protobuf.ByteString) ref;\n"
- " }\n"
- "}\n");
+ "@java.lang.Override\n"
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$() {\n"
+ " java.lang.Object ref $default_init$;\n"
+ " if ($has_oneof_case_message$) {\n"
+ " ref = $oneof_name$_;\n"
+ " }\n"
+ " if (ref instanceof String) {\n"
+ " com.google.protobuf.ByteString b = \n"
+ " com.google.protobuf.ByteString.copyFromUtf8(\n"
+ " (java.lang.String) ref);\n"
+ " if ($has_oneof_case_message$) {\n"
+ " $oneof_name$_ = b;\n"
+ " }\n"
+ " return b;\n"
+ " } else {\n"
+ " return (com.google.protobuf.ByteString) ref;\n"
+ " }\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- "$null_check$"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ "$null_check$"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " if ($has_oneof_case_message$) {\n"
- " $clear_oneof_case_message$;\n"
- " $oneof_name$_ = null;\n"
- " $on_changed$\n"
- " }\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " if ($has_oneof_case_message$) {\n"
+ " $clear_oneof_case_message$;\n"
+ " $oneof_name$_ = null;\n"
+ " $on_changed$\n"
+ " }\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n"
- "$null_check$");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n"
+ "$null_check$");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
+ printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
}
-void ImmutableStringOneofFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+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_,
- "$set_oneof_case_message$;\n"
- "$oneof_name$_ = other.$oneof_name$_;\n"
- "$on_changed$\n");
+ "$set_oneof_case_message$;\n"
+ "$oneof_name$_ = other.$oneof_name$_;\n"
+ "$on_changed$\n");
}
-void ImmutableStringOneofFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+void ImmutableStringOneofFieldGenerator::GenerateBuildingCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " result.$oneof_name$_ = $oneof_name$_;\n"
- "}\n");
+ "if ($has_oneof_case_message$) {\n"
+ " result.$oneof_name$_ = $oneof_name$_;\n"
+ "}\n");
}
-void ImmutableStringOneofFieldGenerator::GenerateParsingCode(
- io::Printer* printer) const {
+void ImmutableStringOneofFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
- "java.lang.String s = input.readStringRequireUtf8();\n"
- "$set_oneof_case_message$;\n"
- "$oneof_name$_ = s;\n");
+ "java.lang.String s = input.readStringRequireUtf8();\n"
+ "$set_oneof_case_message$;\n"
+ "$oneof_name$_ = s;\n");
} else {
printer->Print(variables_,
- "com.google.protobuf.ByteString bs = input.readBytes();\n"
- "$set_oneof_case_message$;\n"
- "$oneof_name$_ = bs;\n");
+ "com.google.protobuf.ByteString bs = input.readBytes();\n"
+ "$set_oneof_case_message$;\n"
+ "$oneof_name$_ = bs;\n");
}
}
-void ImmutableStringOneofFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void ImmutableStringOneofFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " $writeString$(output, $number$, $oneof_name$_);\n"
- "}\n");
+ "if ($has_oneof_case_message$) {\n"
+ " $writeString$(output, $number$, $oneof_name$_);\n"
+ "}\n");
}
-void ImmutableStringOneofFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void ImmutableStringOneofFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($has_oneof_case_message$) {\n"
- " size += $computeStringSize$($number$, $oneof_name$_);\n"
- "}\n");
+ "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()) {
+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::
- ~RepeatedImmutableStringFieldGenerator() {}
+ ~RepeatedImmutableStringFieldGenerator() {}
int RepeatedImmutableStringFieldGenerator::GetNumBitsForMessage() const {
return 0;
@@ -762,421 +762,421 @@ int RepeatedImmutableStringFieldGenerator::GetNumBitsForBuilder() const {
return 1;
}
-void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- // NOTE: the same method in the implementation class actually returns
- // com.google.protobuf.ProtocolStringList (a subclass of List). It's
- // changed between protobuf 2.5.0 release and protobuf 2.6.1 release.
- // To retain binary compatibility with both 2.5.0 and 2.6.1 generated
- // code, we make this interface method return List so both methods
- // with different return types exist in the compiled byte code.
- "$deprecation$java.util.List<java.lang.String>\n"
- " get$capitalized_name$List();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+void RepeatedImmutableStringFieldGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ // NOTE: the same method in the implementation class actually returns
+ // com.google.protobuf.ProtocolStringList (a subclass of List). It's
+ // changed between protobuf 2.5.0 release and protobuf 2.6.1 release.
+ // To retain binary compatibility with both 2.5.0 and 2.6.1 generated
+ // code, we make this interface method return List so both methods
+ // with different return types exist in the compiled byte code.
+ "$deprecation$java.util.List<java.lang.String>\n"
+ " get$capitalized_name$List();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
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");
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ "$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");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$com.google.protobuf.ByteString\n"
- " get$capitalized_name$Bytes(int index);\n");
+ "$deprecation$com.google.protobuf.ByteString\n"
+ " get$capitalized_name$Bytes(int index);\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateMembers(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldGenerator::GenerateMembers(
+ io::Printer* printer) const {
printer->Print(variables_,
- "private com.google.protobuf.LazyStringList $name$_;\n");
+ "private com.google.protobuf.LazyStringList $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$public com.google.protobuf.ProtocolStringList\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return $name$_;\n" // note: unmodifiable list
- "}\n");
+ "$deprecation$public com.google.protobuf.ProtocolStringList\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return $name$_;\n" // note: unmodifiable list
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$public java.lang.String "
- "${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ "$deprecation$public java.lang.String "
+ "${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$(int index) {\n"
- " return $name$_.getByteString(index);\n"
- "}\n");
+ "$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 {
+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
- // a reference to the underlying ArrayList. This invariant allows us to
+ // 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_,
- "private com.google.protobuf.LazyStringList $name$_ = $empty_list$;\n");
-
- printer->Print(
- variables_,
- "private void ensure$capitalized_name$IsMutable() {\n"
- " if (!$get_mutable_bit_builder$) {\n"
- " $name$_ = new com.google.protobuf.LazyStringArrayList($name$_);\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
- // immutable.
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "private com.google.protobuf.LazyStringList $name$_ = $empty_list$;\n");
+
+ printer->Print(
+ variables_,
+ "private void ensure$capitalized_name$IsMutable() {\n"
+ " if (!$get_mutable_bit_builder$) {\n"
+ " $name$_ = new com.google.protobuf.LazyStringArrayList($name$_);\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
+ // immutable.
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$public com.google.protobuf.ProtocolStringList\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return $name$_.getUnmodifiableView();\n"
- "}\n");
+ "$deprecation$public com.google.protobuf.ProtocolStringList\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return $name$_.getUnmodifiableView();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$public java.lang.String "
- "${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
+ "$deprecation$public java.lang.String "
+ "${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
printer->Print(variables_,
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$(int index) {\n"
- " return $name$_.getByteString(index);\n"
- "}\n");
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$(int index) {\n"
+ " return $name$_.getByteString(index);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, java.lang.String value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.set(index, value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, java.lang.String value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.set(index, value);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.add(value);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ true);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ true);
printer->Print(variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<java.lang.String> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
- " values, $name$_);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<java.lang.String> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
+ " values, $name$_);\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " $name$_ = $empty_list$;\n"
- " $clear_mutable_bit_builder$;\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " $name$_ = $empty_list$;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " $on_changed$\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n"
- "$null_check$");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n"
+ "$null_check$");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
+ printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value);\n"
- " $on_changed$\n"
- " return this;\n"
- "}\n");
+ " 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(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ // property for List<String>
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ // List<String>.add(String)
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: kotlin.String) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}\n");
+
+ // List<String> += String
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: kotlin.String) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}\n");
+
+ // List<String>.addAll(Iterable<String>)
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}\n");
+
+ // List<String> += Iterable<String>
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}\n");
+
+ // List<String>[Int] = String
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: kotlin.String) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
}
-void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- // property for List<String>
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- // List<String>.add(String)
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: kotlin.String) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}\n");
-
- // List<String> += String
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: kotlin.String) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}\n");
-
- // List<String>.addAll(Iterable<String>)
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}\n");
-
- // List<String> += Iterable<String>
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}\n");
-
- // List<String>[Int] = String
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: kotlin.String) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
void RepeatedImmutableStringFieldGenerator::
- GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
+ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for primitives
}
-void RepeatedImmutableStringFieldGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $empty_list$;\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateBuilderClearCode(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldGenerator::GenerateBuilderClearCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "$name$_ = $empty_list$;\n"
- "$clear_mutable_bit_builder$;\n");
+ "$name$_ = $empty_list$;\n"
+ "$clear_mutable_bit_builder$;\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateMergingCode(
- io::Printer* printer) const {
+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_,
- "if (!other.$name$_.isEmpty()) {\n"
- " if ($name$_.isEmpty()) {\n"
- " $name$_ = other.$name$_;\n"
- " $clear_mutable_bit_builder$;\n"
- " } else {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.addAll(other.$name$_);\n"
- " }\n"
- " $on_changed$\n"
- "}\n");
+ "if (!other.$name$_.isEmpty()) {\n"
+ " if ($name$_.isEmpty()) {\n"
+ " $name$_ = other.$name$_;\n"
+ " $clear_mutable_bit_builder$;\n"
+ " } else {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.addAll(other.$name$_);\n"
+ " }\n"
+ " $on_changed$\n"
+ "}\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateBuildingCode(
- io::Printer* printer) const {
+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_,
- "if ($get_mutable_bit_builder$) {\n"
- " $name$_ = $name$_.getUnmodifiableView();\n"
- " $clear_mutable_bit_builder$;\n"
- "}\n"
- "result.$name$_ = $name$_;\n");
+ "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 {
+void RepeatedImmutableStringFieldGenerator::GenerateParsingCode(
+ io::Printer* printer) const {
if (CheckUtf8(descriptor_)) {
printer->Print(variables_,
- "java.lang.String s = input.readStringRequireUtf8();\n");
+ "java.lang.String s = input.readStringRequireUtf8();\n");
} else {
printer->Print(variables_,
- "com.google.protobuf.ByteString bs = input.readBytes();\n");
+ "com.google.protobuf.ByteString bs = input.readBytes();\n");
}
printer->Print(variables_,
- "if (!$get_mutable_bit_parser$) {\n"
- " $name$_ = new com.google.protobuf.LazyStringArrayList();\n"
- " $set_mutable_bit_parser$;\n"
- "}\n");
+ "if (!$get_mutable_bit_parser$) {\n"
+ " $name$_ = new com.google.protobuf.LazyStringArrayList();\n"
+ " $set_mutable_bit_parser$;\n"
+ "}\n");
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, "$name$_.add(s);\n");
+ printer->Print(variables_, "$name$_.add(s);\n");
} else {
- printer->Print(variables_, "$name$_.add(bs);\n");
+ printer->Print(variables_, "$name$_.add(bs);\n");
}
}
-void RepeatedImmutableStringFieldGenerator::GenerateParsingDoneCode(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldGenerator::GenerateParsingDoneCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "if ($get_mutable_bit_parser$) {\n"
- " $name$_ = $name$_.getUnmodifiableView();\n"
- "}\n");
+ "if ($get_mutable_bit_parser$) {\n"
+ " $name$_ = $name$_.getUnmodifiableView();\n"
+ "}\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateSerializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldGenerator::GenerateSerializationCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " $writeString$(output, $number$, $name$_.getRaw(i));\n"
- "}\n");
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
+ " $writeString$(output, $number$, $name$_.getRaw(i));\n"
+ "}\n");
}
-void RepeatedImmutableStringFieldGenerator::GenerateSerializedSizeCode(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldGenerator::GenerateSerializedSizeCode(
+ io::Printer* printer) const {
printer->Print(variables_,
- "{\n"
- " int dataSize = 0;\n");
+ "{\n"
+ " int dataSize = 0;\n");
printer->Indent();
printer->Print(variables_,
- "for (int i = 0; i < $name$_.size(); i++) {\n"
- " dataSize += computeStringSizeNoTag($name$_.getRaw(i));\n"
- "}\n");
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
+ " dataSize += computeStringSizeNoTag($name$_.getRaw(i));\n"
+ "}\n");
- printer->Print("size += dataSize;\n");
+ printer->Print("size += dataSize;\n");
printer->Print(variables_,
- "size += $tag_size$ * get$capitalized_name$List().size();\n");
+ "size += $tag_size$ * get$capitalized_name$List().size();\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::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(
- variables_,
- "if (get$capitalized_name$Count() > 0) {\n"
- " hash = (37 * hash) + $constant_name$;\n"
- " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
- "}\n");
+void RepeatedImmutableStringFieldGenerator::GenerateHashCode(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "if (get$capitalized_name$Count() > 0) {\n"
+ " hash = (37 * hash) + $constant_name$;\n"
+ " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
+ "}\n");
}
-TProtoStringType RepeatedImmutableStringFieldGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutableStringFieldGenerator::GetBoxedType() const {
return "String";
}
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 a1966fd616..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
@@ -37,34 +37,34 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__
#include <map>
-#include <string>
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
namespace protobuf {
namespace compiler {
namespace java {
class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
public:
- explicit ImmutableStringFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- int builderBitIndex, Context* context);
+ explicit ImmutableStringFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ int builderBitIndex, Context* context);
~ImmutableStringFieldGenerator();
- // implements ImmutableFieldGenerator
- // ---------------------------------------
+ // implements ImmutableFieldGenerator
+ // ---------------------------------------
int GetNumBitsForMessage() const;
int GetNumBitsForBuilder() const;
void GenerateInterfaceMembers(io::Printer* printer) const;
@@ -81,13 +81,13 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
- void GenerateKotlinDslMembers(io::Printer* printer) const;
+ void GenerateKotlinDslMembers(io::Printer* printer) const;
- TProtoStringType GetBoxedType() const;
+ TProtoStringType GetBoxedType() const;
protected:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
private:
@@ -97,9 +97,9 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
class ImmutableStringOneofFieldGenerator
: public ImmutableStringFieldGenerator {
public:
- ImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
- Context* context);
+ ImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex, int builderBitIndex,
+ Context* context);
~ImmutableStringOneofFieldGenerator();
private:
@@ -119,33 +119,33 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
explicit RepeatedImmutableStringFieldGenerator(
const FieldDescriptor* descriptor, int messageBitIndex,
int builderBitIndex, Context* context);
- ~RepeatedImmutableStringFieldGenerator() override;
+ ~RepeatedImmutableStringFieldGenerator() override;
// implements ImmutableFieldGenerator ---------------------------------------
- int GetNumBitsForMessage() const override;
- int GetNumBitsForBuilder() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateBuilderClearCode(io::Printer* printer) const override;
- void GenerateMergingCode(io::Printer* printer) const override;
- void GenerateBuildingCode(io::Printer* printer) const override;
- void GenerateParsingCode(io::Printer* printer) const override;
- void GenerateParsingDoneCode(io::Printer* printer) const override;
- void GenerateSerializationCode(io::Printer* printer) const override;
- void GenerateSerializedSizeCode(io::Printer* printer) const override;
- void GenerateFieldBuilderInitializationCode(
- io::Printer* printer) const override;
- 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;
+ int GetNumBitsForMessage() const override;
+ int GetNumBitsForBuilder() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateBuilderClearCode(io::Printer* printer) const override;
+ void GenerateMergingCode(io::Printer* printer) const override;
+ void GenerateBuildingCode(io::Printer* printer) const override;
+ void GenerateParsingCode(io::Printer* printer) const override;
+ void GenerateParsingDoneCode(io::Printer* printer) const override;
+ void GenerateSerializationCode(io::Printer* printer) const override;
+ void GenerateSerializedSizeCode(io::Printer* printer) const override;
+ void GenerateFieldBuilderInitializationCode(
+ io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldGenerator);
@@ -154,6 +154,6 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#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 5e2834dfd4..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
@@ -33,21 +33,21 @@
// 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 <google/protobuf/compiler/java/java_string_field_lite.h>
+
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/common.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/wire_format.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <string>
+
+#include <google/protobuf/stubs/logging.h>
+#include <google/protobuf/stubs/common.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/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -60,10 +60,10 @@ using internal::WireFormatLite;
namespace {
void SetPrimitiveVariables(const FieldDescriptor* descriptor,
- int messageBitIndex, int builderBitIndex,
+ int messageBitIndex, int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<TProtoStringType, TProtoStringType>* variables) {
+ std::map<TProtoStringType, TProtoStringType>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] =
@@ -74,26 +74,26 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "java.lang.String";
(*variables)["tag"] =
- StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
- (*variables)["tag_size"] = StrCat(
+ StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag_size"] = StrCat(
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";
+ // 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
- (*variables)["deprecation"] =
- descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
- (*variables)["kt_deprecation"] =
- descriptor->options().deprecated()
- ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
- " is deprecated\") "
- : "";
+ (*variables)["deprecation"] =
+ descriptor->options().deprecated() ? "@java.lang.Deprecated " : "";
+ (*variables)["kt_deprecation"] =
+ descriptor->options().deprecated()
+ ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] +
+ " is deprecated\") "
+ : "";
(*variables)["required"] = descriptor->is_required() ? "true" : "false";
- if (HasHasbit(descriptor)) {
+ if (HasHasbit(descriptor)) {
// For singular messages and builders, one bit is used for the hasField bit.
(*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
@@ -122,12 +122,12 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
// ===================================================================
-ImmutableStringFieldLiteGenerator::ImmutableStringFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : descriptor_(descriptor),
- messageBitIndex_(messageBitIndex),
- name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, 0,
+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_);
}
@@ -135,14 +135,14 @@ ImmutableStringFieldLiteGenerator::ImmutableStringFieldLiteGenerator(
ImmutableStringFieldLiteGenerator::~ImmutableStringFieldLiteGenerator() {}
int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
- return HasHasbit(descriptor_) ? 1 : 0;
+ 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:
//
-// 1. It wouldn't roundtrip byte arrays that were not valid UTF-8 encoded
+// 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
@@ -163,695 +163,695 @@ int ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
// 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);
+void ImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "$deprecation$boolean has$capitalized_name$();\n");
+ "$deprecation$boolean has$capitalized_name$();\n");
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$java.lang.String get$capitalized_name$();\n");
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ "$deprecation$java.lang.String get$capitalized_name$();\n");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
printer->Print(variables_,
- "$deprecation$com.google.protobuf.ByteString\n"
- " get$capitalized_name$Bytes();\n");
+ "$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");
+void ImmutableStringFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(variables_, "private java.lang.String $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $get_has_field_bit_message$;\n"
- "}\n");
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
+ " return $get_has_field_bit_message$;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
- WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " return $name$_;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$() {\n"
- " return com.google.protobuf.ByteString.copyFromUtf8($name$_);\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
- "private void set$capitalized_name$(\n"
- " java.lang.String value) {\n"
- "$null_check$"
- " $set_has_field_bit_message$\n"
- " $name$_ = value;\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- 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
- // avoid executing it multiple times. Instead, get the default
- // out of the default instance.
- " $name$_ = getDefaultInstance().get$capitalized_name$();\n"
- "}\n");
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER);
- printer->Print(variables_,
- "private void set$capitalized_name$Bytes(\n"
- " com.google.protobuf.ByteString value) {\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " return $name$_;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$() {\n"
+ " return com.google.protobuf.ByteString.copyFromUtf8($name$_);\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
+ printer->Print(variables_,
+ "private void set$capitalized_name$(\n"
+ " java.lang.String value) {\n"
+ "$null_check$"
+ " $set_has_field_bit_message$\n"
+ " $name$_ = value;\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ 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
+ // avoid executing it multiple times. Instead, get the default
+ // out of the default instance.
+ " $name$_ = getDefaultInstance().get$capitalized_name$();\n"
+ "}\n");
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER);
+ printer->Print(variables_,
+ "private void set$capitalized_name$Bytes(\n"
+ " com.google.protobuf.ByteString value) {\n");
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
+ printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " $name$_ = value.toStringUtf8();\n"
- " $set_has_field_bit_message$\n"
- "}\n");
+ " $name$_ = value.toStringUtf8();\n"
+ " $set_has_field_bit_message$\n"
+ "}\n");
}
-void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return instance.has$capitalized_name$();\n"
- "}\n");
+void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ 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_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- 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_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$Bytes(value);\n"
- " return this;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " return instance.get$capitalized_name$();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ 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_,
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$Bytes(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
-void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- WriteFieldDocComment(printer, descriptor_);
- printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: kotlin.String\n"
- " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
- " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
- " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
- " set(value) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
- " }\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}\n");
-
- if (HasHazzer(descriptor_)) {
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
- }
-}
-
-void ImmutableStringFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- if (HasHasbit(descriptor_)) {
- WriteIntToUtf16CharSequence(messageBitIndex_, output);
- }
- printer->Print(variables_, "\"$name$_\",\n");
+void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ WriteFieldDocComment(printer, descriptor_);
+ printer->Print(variables_,
+ "$kt_deprecation$var $kt_name$: kotlin.String\n"
+ " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
+ " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
+ " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
+ " set(value) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n"
+ " }\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}\n");
+
+ if (HasHazzer(descriptor_)) {
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ printer->Print(variables_,
+ "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
+ }
}
-void ImmutableStringFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void ImmutableStringFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ if (HasHasbit(descriptor_)) {
+ WriteIntToUtf16CharSequence(messageBitIndex_, output);
+ }
+ printer->Print(variables_, "\"$name$_\",\n");
+}
+
+void ImmutableStringFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $default$;\n");
}
-TProtoStringType ImmutableStringFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType ImmutableStringFieldLiteGenerator::GetBoxedType() const {
return "java.lang.String";
}
// ===================================================================
-ImmutableStringOneofFieldLiteGenerator::ImmutableStringOneofFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context)
- : ImmutableStringFieldLiteGenerator(descriptor, messageBitIndex, context) {
+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::
- ~ImmutableStringOneofFieldLiteGenerator() {}
+ ~ImmutableStringOneofFieldLiteGenerator() {}
-void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
- io::Printer* printer) const {
+void ImmutableStringOneofFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
PrintExtraFieldInfo(variables_, printer);
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n"
- " return $has_oneof_case_message$;\n"
- "}\n");
+ "@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_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " java.lang.String ref $default_init$;\n"
- " if ($has_oneof_case_message$) {\n"
- " ref = (java.lang.String) $oneof_name$_;\n"
- " }\n"
- " return ref;\n"
- "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " java.lang.String ref $default_init$;\n"
+ " if ($has_oneof_case_message$) {\n"
+ " ref = (java.lang.String) $oneof_name$_;\n"
+ " }\n"
+ " return ref;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$() {\n"
- " java.lang.String ref $default_init$;\n"
- " if ($has_oneof_case_message$) {\n"
- " ref = (java.lang.String) $oneof_name$_;\n"
- " }\n"
- " return com.google.protobuf.ByteString.copyFromUtf8(ref);\n"
- "}\n");
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$() {\n"
+ " java.lang.String ref $default_init$;\n"
+ " if ($has_oneof_case_message$) {\n"
+ " ref = (java.lang.String) $oneof_name$_;\n"
+ " }\n"
+ " return com.google.protobuf.ByteString.copyFromUtf8(ref);\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldAccessorDocComment(printer, descriptor_, SETTER);
printer->Print(variables_,
- "private void ${$set$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- "$null_check$"
- " $set_oneof_case_message$;\n"
- " $oneof_name$_ = value;\n"
- "}\n");
+ "private void ${$set$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ "$null_check$"
+ " $set_oneof_case_message$;\n"
+ " $oneof_name$_ = value;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- 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");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ 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");
printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER);
printer->Print(variables_,
- "private void ${$set$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n");
+ "private void ${$set$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n");
printer->Annotate("{", "}", descriptor_);
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
+ printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " $oneof_name$_ = value.toStringUtf8();\n"
- " $set_oneof_case_message$;\n"
- "}\n");
+ " $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);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
-}
-
-void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
- io::Printer* printer) const {
- GOOGLE_DCHECK(HasHazzer(descriptor_));
- WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- 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_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
- " return instance.get$capitalized_name$();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
- 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_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$Bytes(value);\n"
- " return this;\n"
- "}\n");
+void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output);
+}
+
+void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ GOOGLE_DCHECK(HasHazzer(descriptor_));
+ WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
+ 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_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n"
+ " return instance.get$capitalized_name$();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER);
+ 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_,
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$Bytes(value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
}
// ===================================================================
RepeatedImmutableStringFieldLiteGenerator::
- RepeatedImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex,
- Context* context)
- : descriptor_(descriptor), name_resolver_(context->GetNameResolver()) {
- SetPrimitiveVariables(descriptor, messageBitIndex, 0,
+ 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::
- ~RepeatedImmutableStringFieldLiteGenerator() {}
+ ~RepeatedImmutableStringFieldLiteGenerator() {}
int RepeatedImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {
return 0;
}
-void RepeatedImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
- io::Printer* printer) const {
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+void RepeatedImmutableStringFieldLiteGenerator::GenerateInterfaceMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(variables_,
- "$deprecation$java.util.List<java.lang.String>\n"
- " get$capitalized_name$List();\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ "$deprecation$java.util.List<java.lang.String>\n"
+ " get$capitalized_name$List();\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
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);
+ "$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_,
- "$deprecation$com.google.protobuf.ByteString\n"
- " get$capitalized_name$Bytes(int index);\n");
+ "$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");
+void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "private com.google.protobuf.Internal.ProtobufList<java.lang.String> "
+ "$name$_;\n");
PrintExtraFieldInfo(variables_, printer);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<java.lang.String> "
- "${$get$capitalized_name$List$}$() {\n"
- " return $name$_;\n" // note: unmodifiable list
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return $name$_.size();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String "
- "${$get$capitalized_name$$}$(int index) {\n"
- " return $name$_.get(index);\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$(int index) {\n"
- " return com.google.protobuf.ByteString.copyFromUtf8(\n"
- " $name$_.get(index));\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- printer->Print(
- variables_,
- "private void ensure$capitalized_name$IsMutable() {\n"
- // Use a temporary to avoid a redundant iget-object.
- " com.google.protobuf.Internal.ProtobufList<java.lang.String> tmp =\n"
- " $name$_;"
- " if (!tmp.isModifiable()) {\n"
- " $name$_ =\n"
- " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
- " }\n"
- "}\n");
-
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
- printer->Print(variables_,
- "private void set$capitalized_name$(\n"
- " int index, java.lang.String value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.set(index, value);\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
- "private void add$capitalized_name$(\n"
- " java.lang.String value) {\n"
- "$null_check$"
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value);\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER);
- printer->Print(variables_,
- "private void addAll$capitalized_name$(\n"
- " java.lang.Iterable<java.lang.String> values) {\n"
- " ensure$capitalized_name$IsMutable();\n"
- " com.google.protobuf.AbstractMessageLite.addAll(\n"
- " values, $name$_);\n"
- "}\n");
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
- printer->Print(variables_,
- "private void clear$capitalized_name$() {\n"
- " $name$_ = $empty_list$;\n"
- "}\n");
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER);
- printer->Print(variables_,
- "private void add$capitalized_name$Bytes(\n"
- " com.google.protobuf.ByteString value) {\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<java.lang.String> "
+ "${$get$capitalized_name$List$}$() {\n"
+ " return $name$_;\n" // note: unmodifiable list
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return $name$_.size();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String "
+ "${$get$capitalized_name$$}$(int index) {\n"
+ " return $name$_.get(index);\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$(int index) {\n"
+ " return com.google.protobuf.ByteString.copyFromUtf8(\n"
+ " $name$_.get(index));\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ printer->Print(
+ variables_,
+ "private void ensure$capitalized_name$IsMutable() {\n"
+ // Use a temporary to avoid a redundant iget-object.
+ " com.google.protobuf.Internal.ProtobufList<java.lang.String> tmp =\n"
+ " $name$_;"
+ " if (!tmp.isModifiable()) {\n"
+ " $name$_ =\n"
+ " com.google.protobuf.GeneratedMessageLite.mutableCopy(tmp);\n"
+ " }\n"
+ "}\n");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER);
+ printer->Print(variables_,
+ "private void set$capitalized_name$(\n"
+ " int index, java.lang.String value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.set(index, value);\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER);
+ printer->Print(variables_,
+ "private void add$capitalized_name$(\n"
+ " java.lang.String value) {\n"
+ "$null_check$"
+ " ensure$capitalized_name$IsMutable();\n"
+ " $name$_.add(value);\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER);
+ printer->Print(variables_,
+ "private void addAll$capitalized_name$(\n"
+ " java.lang.Iterable<java.lang.String> values) {\n"
+ " ensure$capitalized_name$IsMutable();\n"
+ " com.google.protobuf.AbstractMessageLite.addAll(\n"
+ " values, $name$_);\n"
+ "}\n");
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER);
+ printer->Print(variables_,
+ "private void clear$capitalized_name$() {\n"
+ " $name$_ = $empty_list$;\n"
+ "}\n");
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER);
+ printer->Print(variables_,
+ "private void add$capitalized_name$Bytes(\n"
+ " com.google.protobuf.ByteString value) {\n");
if (CheckUtf8(descriptor_)) {
- printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
+ printer->Print(variables_, " checkByteStringIsUtf8(value);\n");
}
printer->Print(variables_,
- " ensure$capitalized_name$IsMutable();\n"
- " $name$_.add(value.toStringUtf8());\n"
- "}\n");
+ " 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_,
- "@java.lang.Override\n"
- "$deprecation$public java.util.List<java.lang.String>\n"
- " ${$get$capitalized_name$List$}$() {\n"
- " return java.util.Collections.unmodifiableList(\n"
- " instance.get$capitalized_name$List());\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
- printer->Print(
- variables_,
- "@java.lang.Override\n"
- "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
- " return instance.get$capitalized_name$Count();\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public java.lang.String "
- "${$get$capitalized_name$$}$(int index) {\n"
- " return instance.get$capitalized_name$(index);\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
- LIST_INDEXED_GETTER);
- printer->Print(variables_,
- "@java.lang.Override\n"
- "$deprecation$public com.google.protobuf.ByteString\n"
- " ${$get$capitalized_name$Bytes$}$(int index) {\n"
- " return instance.get$capitalized_name$Bytes(index);\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ true);
- printer->Print(variables_,
- "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
- " int index, java.lang.String value) {\n"
- " copyOnWrite();\n"
- " instance.set$capitalized_name$(index, value);\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
- printer->Print(variables_,
- "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
- " java.lang.String value) {\n"
- " copyOnWrite();\n"
- " instance.add$capitalized_name$(value);\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ true);
- printer->Print(variables_,
- "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
- " java.lang.Iterable<java.lang.String> values) {\n"
- " copyOnWrite();\n"
- " instance.addAll$capitalized_name$(values);\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
- " copyOnWrite();\n"
- " instance.clear$capitalized_name$();\n"
- " return this;\n"
- "}\n");
- printer->Annotate("{", "}", descriptor_);
-
- WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ true);
- printer->Print(
- variables_,
- "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n"
- " com.google.protobuf.ByteString value) {\n"
- " copyOnWrite();\n"
- " instance.add$capitalized_name$Bytes(value);\n"
- " return this;\n"
- "}\n");
+void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers(
+ io::Printer* printer) const {
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.util.List<java.lang.String>\n"
+ " ${$get$capitalized_name$List$}$() {\n"
+ " return java.util.Collections.unmodifiableList(\n"
+ " instance.get$capitalized_name$List());\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT);
+ printer->Print(
+ variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n"
+ " return instance.get$capitalized_name$Count();\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public java.lang.String "
+ "${$get$capitalized_name$$}$(int index) {\n"
+ " return instance.get$capitalized_name$(index);\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_,
+ LIST_INDEXED_GETTER);
+ printer->Print(variables_,
+ "@java.lang.Override\n"
+ "$deprecation$public com.google.protobuf.ByteString\n"
+ " ${$get$capitalized_name$Bytes$}$(int index) {\n"
+ " return instance.get$capitalized_name$Bytes(index);\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ true);
+ printer->Print(variables_,
+ "$deprecation$public Builder ${$set$capitalized_name$$}$(\n"
+ " int index, java.lang.String value) {\n"
+ " copyOnWrite();\n"
+ " instance.set$capitalized_name$(index, value);\n"
+ " return this;\n"
+ "}\n");
printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
+ printer->Print(variables_,
+ "$deprecation$public Builder ${$add$capitalized_name$$}$(\n"
+ " java.lang.String value) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$(value);\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ true);
+ printer->Print(variables_,
+ "$deprecation$public Builder ${$addAll$capitalized_name$$}$(\n"
+ " java.lang.Iterable<java.lang.String> values) {\n"
+ " copyOnWrite();\n"
+ " instance.addAll$capitalized_name$(values);\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n"
+ " copyOnWrite();\n"
+ " instance.clear$capitalized_name$();\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+
+ WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ true);
+ printer->Print(
+ variables_,
+ "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n"
+ " com.google.protobuf.ByteString value) {\n"
+ " copyOnWrite();\n"
+ " instance.add$capitalized_name$Bytes(value);\n"
+ " return this;\n"
+ "}\n");
+ printer->Annotate("{", "}", descriptor_);
+}
+
+void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
+ io::Printer* printer) const {
+ printer->Print(
+ variables_,
+ "/**\n"
+ " * An uninstantiable, behaviorless type to represent the field in\n"
+ " * generics.\n"
+ " */\n"
+ "@kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ " : com.google.protobuf.kotlin.DslProxy()\n");
+
+ // property for List<String>
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
+ printer->Print(
+ variables_,
+ "val $kt_name$: "
+ "com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
+ " @kotlin.OptIn"
+ "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
+ " get() = com.google.protobuf.kotlin.DslList(\n"
+ " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
+ " )\n");
+
+ // List<String>.add(String)
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "add(value: kotlin.String) {\n"
+ " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
+ "}\n");
+
+ // List<String> += String
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(value: kotlin.String) {\n"
+ " add(value)\n"
+ "}\n");
+
+ // List<String>.addAll(Iterable<String>)
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
+ " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
+ "}\n");
+
+ // List<String> += Iterable<String>
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
+ "inline operator fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
+ " addAll(values)\n"
+ "}\n");
+
+ // List<String>[Int] = String
+ WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
+ /* builder */ false);
+ printer->Print(
+ variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
+ "operator fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "set(index: kotlin.Int, value: kotlin.String) {\n"
+ " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
+ "}");
+
+ WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
+ /* builder */ false);
+ printer->Print(variables_,
+ "@kotlin.jvm.JvmSynthetic\n"
+ "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
+ "fun com.google.protobuf.kotlin.DslList"
+ "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
+ "clear() {\n"
+ " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
+ "}");
}
-void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
- io::Printer* printer) const {
- printer->Print(
- variables_,
- "/**\n"
- " * An uninstantiable, behaviorless type to represent the field in\n"
- " * generics.\n"
- " */\n"
- "@kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
- " : com.google.protobuf.kotlin.DslProxy()\n");
-
- // property for List<String>
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
- printer->Print(
- variables_,
- "val $kt_name$: "
- "com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
- " @kotlin.OptIn"
- "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- " get() = com.google.protobuf.kotlin.DslList(\n"
- " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
- " )\n");
-
- // List<String>.add(String)
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "add(value: kotlin.String) {\n"
- " $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
- "}\n");
-
- // List<String> += String
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(value: kotlin.String) {\n"
- " add(value)\n"
- "}\n");
-
- // List<String>.addAll(Iterable<String>)
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
- " $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
- "}\n");
-
- // List<String> += Iterable<String>
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
- " addAll(values)\n"
- "}\n");
-
- // List<String>[Int] = String
- WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
- /* builder */ false);
- printer->Print(
- variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "set(index: kotlin.Int, value: kotlin.String) {\n"
- " $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
- "}");
-
- WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
- /* builder */ false);
- printer->Print(variables_,
- "@kotlin.jvm.JvmSynthetic\n"
- "@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
- "<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
- "clear() {\n"
- " $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
- "}");
-}
-
-void RepeatedImmutableStringFieldLiteGenerator::GenerateFieldInfo(
- io::Printer* printer, std::vector<uint16_t>* output) const {
- WriteIntToUtf16CharSequence(descriptor_->number(), output);
- WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
- output);
- printer->Print(variables_, "\"$name$_\",\n");
+void RepeatedImmutableStringFieldLiteGenerator::GenerateFieldInfo(
+ io::Printer* printer, std::vector<uint16_t>* output) const {
+ WriteIntToUtf16CharSequence(descriptor_->number(), output);
+ WriteIntToUtf16CharSequence(GetExperimentalJavaFieldType(descriptor_),
+ output);
+ printer->Print(variables_, "\"$name$_\",\n");
}
-void RepeatedImmutableStringFieldLiteGenerator::GenerateInitializationCode(
- io::Printer* printer) const {
+void RepeatedImmutableStringFieldLiteGenerator::GenerateInitializationCode(
+ io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $empty_list$;\n");
}
-TProtoStringType RepeatedImmutableStringFieldLiteGenerator::GetBoxedType() const {
+TProtoStringType RepeatedImmutableStringFieldLiteGenerator::GetBoxedType() const {
return "java.lang.String";
}
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 1cc9455f05..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
@@ -36,51 +36,51 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__
-#include <cstdint>
+#include <cstdint>
#include <map>
-#include <string>
-
-#include <google/protobuf/compiler/java/java_field.h>
+#include <string>
+
+#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
-namespace compiler {
-namespace java {
-class Context; // context.h
-class ClassNameResolver; // name_resolver.h
-} // namespace java
-} // namespace compiler
-} // namespace protobuf
-} // namespace google
-
-namespace google {
+namespace compiler {
+namespace java {
+class Context; // context.h
+class ClassNameResolver; // name_resolver.h
+} // namespace java
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
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;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
-
- TProtoStringType GetBoxedType() const override;
+ explicit ImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex,
+ Context* context);
+ ~ImmutableStringFieldLiteGenerator() override;
+
+ // implements ImmutableFieldLiteGenerator
+ // ------------------------------------
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ 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_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
const int messageBitIndex_;
ClassNameResolver* name_resolver_;
@@ -91,15 +91,15 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
class ImmutableStringOneofFieldLiteGenerator
: public ImmutableStringFieldLiteGenerator {
public:
- ImmutableStringOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
- int messageBitIndex, Context* context);
- ~ImmutableStringOneofFieldLiteGenerator() override;
+ ImmutableStringOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
+ int messageBitIndex, Context* context);
+ ~ImmutableStringOneofFieldLiteGenerator() override;
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;
+ 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);
};
@@ -108,24 +108,24 @@ class RepeatedImmutableStringFieldLiteGenerator
: public ImmutableFieldLiteGenerator {
public:
explicit RepeatedImmutableStringFieldLiteGenerator(
- const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
- ~RepeatedImmutableStringFieldLiteGenerator() override;
+ const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
+ ~RepeatedImmutableStringFieldLiteGenerator() override;
// implements ImmutableFieldLiteGenerator ------------------------------------
- int GetNumBitsForMessage() const override;
- void GenerateInterfaceMembers(io::Printer* printer) const override;
- void GenerateMembers(io::Printer* printer) const override;
- void GenerateBuilderMembers(io::Printer* printer) const override;
- void GenerateInitializationCode(io::Printer* printer) const override;
- void GenerateFieldInfo(io::Printer* printer,
- std::vector<uint16_t>* output) const override;
- void GenerateKotlinDslMembers(io::Printer* printer) const override;
+ int GetNumBitsForMessage() const override;
+ void GenerateInterfaceMembers(io::Printer* printer) const override;
+ void GenerateMembers(io::Printer* printer) const override;
+ void GenerateBuilderMembers(io::Printer* printer) const override;
+ void GenerateInitializationCode(io::Printer* printer) const override;
+ void GenerateFieldInfo(io::Printer* printer,
+ std::vector<uint16_t>* output) const override;
+ void GenerateKotlinDslMembers(io::Printer* printer) const override;
- TProtoStringType GetBoxedType() const override;
+ TProtoStringType GetBoxedType() const override;
private:
const FieldDescriptor* descriptor_;
- std::map<TProtoStringType, TProtoStringType> variables_;
+ std::map<TProtoStringType, TProtoStringType> variables_;
ClassNameResolver* name_resolver_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldLiteGenerator);
@@ -134,6 +134,6 @@ class RepeatedImmutableStringFieldLiteGenerator
} // namespace java
} // namespace compiler
} // namespace protobuf
-} // namespace google
+} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__