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

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.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_primitive_field_lite.cc
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index ac39f4cf4d751794a416fe1f00065bd5d4f8e23c..690dad128fc6e48af36e776350c92e08d70cf33c 100644
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -61,23 +61,24 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- std::map<string, string>* variables) {
+ map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
- JavaType javaType = GetJavaType(descriptor);
- (*variables)["type"] = PrimitiveTypeName(javaType);
- (*variables)["boxed_type"] = BoxedPrimitiveTypeName(javaType);
+
+ (*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor));
+ (*variables)["boxed_type"] = BoxedPrimitiveTypeName(GetJavaType(descriptor));
(*variables)["field_type"] = (*variables)["type"];
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
+ (*variables)["default_init"] = IsDefaultValueJavaDefault(descriptor) ?
+ "" : ("= " + ImmutableDefaultValue(descriptor, name_resolver));
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
- (*variables)["tag"] =
- SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
+ (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
- string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(javaType),
- true /* cap_next_letter */);
- switch (javaType) {
+ string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(
+ GetJavaType(descriptor)), true /* cap_next_letter */);
+ switch (GetJavaType(descriptor)) {
case JAVATYPE_INT:
case JAVATYPE_LONG:
case JAVATYPE_FLOAT:
@@ -111,12 +112,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["visit_type_list"] = "visitList";
}
- if (javaType == JAVATYPE_BYTES) {
- (*variables)["bytes_default"] =
- ToUpper((*variables)["name"]) + "_DEFAULT_VALUE";
- }
-
- if (IsReferenceType(javaType)) {
+ if (IsReferenceType(GetJavaType(descriptor))) {
(*variables)["null_check"] =
" if (value == null) {\n"
" throw new NullPointerException();\n"
@@ -208,13 +204,6 @@ GenerateInterfaceMembers(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.
- printer->Print(
- variables_,
- "private static final $field_type$ $bytes_default$ = $default$;\n");
- }
printer->Print(variables_,
"private $field_type$ $name$_;\n");
PrintExtraFieldInfo(variables_, printer);
@@ -298,11 +287,7 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
void ImmutablePrimitiveFieldLiteGenerator::
GenerateInitializationCode(io::Printer* printer) const {
- if (IsByteStringWithCustomDefaultValue(descriptor_)) {
- printer->Print(variables_, "$name$_ = $bytes_default$;\n");
- } else if (!IsDefaultValueJavaDefault(descriptor_)) {
- printer->Print(variables_, "$name$_ = $default$;\n");
- }
+ printer->Print(variables_, "$name$_ = $default$;\n");
}
void ImmutablePrimitiveFieldLiteGenerator::
@@ -832,8 +817,8 @@ GenerateSerializationCode(io::Printer* printer) const {
// 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"
+ " output.writeRawVarint32($tag$);\n"
+ " output.writeRawVarint32($name$MemoizedSerializedSize);\n"
"}\n"
"for (int i = 0; i < $name$_.size(); i++) {\n"
" output.write$capitalized_type$NoTag($repeated_get$(i));\n"

Powered by Google App Engine
This is Rietveld 408576698