Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc b/third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc
index 279b9da4ef7fe80224a3605b1ad4fc44e919ff2b..3e54be3d5a495bfef1bbd1dfdea165d48c992ed9 100644
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<string, string>* variables) {
+ map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
@@ -68,8 +68,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] = SimpleItoa(
descriptor->default_value_enum()->number());
- (*variables)["tag"] =
- SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
+ (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));
(*variables)["tag_size"] = SimpleItoa(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
@@ -77,11 +76,6 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["deprecation"] = descriptor->options().deprecated()
? "@java.lang.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.
- (*variables)["for_number"] = "valueOf";
if (SupportFieldPresence(descriptor->file())) {
// For singular messages and builders, one bit is used for the hasField bit.
@@ -197,7 +191,7 @@ GenerateMembers(io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$ get$capitalized_name$() {\n"
- " $type$ result = $type$.$for_number$($name$_);\n"
+ " $type$ result = $type$.forNumber($name$_);\n"
" return result == null ? $unknown$ : result;\n"
"}\n");
}
@@ -230,7 +224,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
"$deprecation$public $type$ get$capitalized_name$() {\n"
- " $type$ result = $type$.$for_number$($name$_);\n"
+ " $type$ result = $type$.forNumber($name$_);\n"
" return result == null ? $unknown$ : result;\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
@@ -310,7 +304,7 @@ GenerateParsingCode(io::Printer* printer) const {
} else {
printer->Print(variables_,
"int rawValue = input.readEnum();\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
+ "$type$ value = $type$.forNumber(rawValue);\n"
"if (value == null) {\n");
if (PreserveUnknownFields(descriptor_->containing_type())) {
printer->Print(variables_,
@@ -404,8 +398,7 @@ GenerateMembers(io::Printer* printer) const {
printer->Print(variables_,
"$deprecation$public $type$ get$capitalized_name$() {\n"
" if ($has_oneof_case_message$) {\n"
- " $type$ result = $type$.$for_number$(\n"
- " (java.lang.Integer) $oneof_name$_);\n"
+ " $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\n"
" return result == null ? $unknown$ : result;\n"
" }\n"
" return $default$;\n"
@@ -443,8 +436,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
printer->Print(variables_,
"$deprecation$public $type$ get$capitalized_name$() {\n"
" if ($has_oneof_case_message$) {\n"
- " $type$ result = $type$.$for_number$(\n"
- " (java.lang.Integer) $oneof_name$_);\n"
+ " $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\n"
" return result == null ? $unknown$ : result;\n"
" }\n"
" return $default$;\n"
@@ -501,7 +493,7 @@ GenerateParsingCode(io::Printer* printer) const {
} else {
printer->Print(variables_,
"int rawValue = input.readEnum();\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
+ "$type$ value = $type$.forNumber(rawValue);\n"
"if (value == null) {\n");
if (PreserveUnknownFields(descriptor_->containing_type())) {
printer->Print(variables_,
@@ -614,7 +606,7 @@ GenerateMembers(io::Printer* printer) const {
" new com.google.protobuf.Internal.ListAdapter.Converter<\n"
" java.lang.Integer, $type$>() {\n"
" public $type$ convert(java.lang.Integer from) {\n"
- " $type$ result = $type$.$for_number$(from);\n"
+ " $type$ result = $type$.forNumber(from);\n"
" return result == null ? $unknown$ : result;\n"
" }\n"
" };\n");
@@ -847,7 +839,7 @@ GenerateParsingCode(io::Printer* printer) const {
} else {
printer->Print(variables_,
"int rawValue = input.readEnum();\n"
- "$type$ value = $type$.$for_number$(rawValue);\n"
+ "$type$ value = $type$.forNumber(rawValue);\n"
"if (value == null) {\n");
if (PreserveUnknownFields(descriptor_->containing_type())) {
printer->Print(variables_,
@@ -895,8 +887,8 @@ 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"
+ " output.writeRawVarint32($tag$);\n"
+ " output.writeRawVarint32($name$MemoizedSerializedSize);\n"
"}\n"
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.writeEnumNoTag($name$_.get(i));\n"
@@ -928,7 +920,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
"if (!get$capitalized_name$List().isEmpty()) {"
" size += $tag_size$;\n"
" size += com.google.protobuf.CodedOutputStream\n"
- " .computeUInt32SizeNoTag(dataSize);\n"
+ " .computeRawVarint32Size(dataSize);\n"
"}");
} else {
printer->Print(variables_,

Powered by Google App Engine
This is Rietveld 408576698