Index: third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc b/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc |
index e24894b1b95b18a019a5429f6467113597cc11fe..efb5fd45655c342dabdc9aa23e18c7799a4979e8 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_helpers.cc |
@@ -101,6 +101,20 @@ string FieldName(const FieldDescriptor* field) { |
} // namespace |
+void PrintGeneratedAnnotation(io::Printer* printer, char delimiter, |
+ const string& annotation_file) { |
+ if (annotation_file.empty()) { |
+ return; |
+ } |
+ string ptemplate = |
+ "@javax.annotation.Generated(value=\"protoc\", comments=\"annotations:"; |
+ ptemplate.push_back(delimiter); |
+ ptemplate.append("annotation_file"); |
+ ptemplate.push_back(delimiter); |
+ ptemplate.append("\")\n"); |
+ printer->Print(ptemplate.c_str(), "annotation_file", annotation_file); |
+} |
+ |
string UnderscoresToCamelCase(const string& input, bool cap_next_letter) { |
string result; |
// Note: I distrust ctype.h due to locales. |
@@ -346,6 +360,7 @@ const char* BoxedPrimitiveTypeName(JavaType type) { |
return NULL; |
} |
+ |
const char* FieldTypeName(FieldDescriptor::Type field_type) { |
switch (field_type) { |
case FieldDescriptor::TYPE_INT32 : return "INT32"; |
@@ -401,9 +416,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable, |
"L"; |
case FieldDescriptor::CPPTYPE_DOUBLE: { |
double value = field->default_value_double(); |
- if (value == numeric_limits<double>::infinity()) { |
+ if (value == std::numeric_limits<double>::infinity()) { |
return "Double.POSITIVE_INFINITY"; |
- } else if (value == -numeric_limits<double>::infinity()) { |
+ } else if (value == -std::numeric_limits<double>::infinity()) { |
return "Double.NEGATIVE_INFINITY"; |
} else if (value != value) { |
return "Double.NaN"; |
@@ -413,9 +428,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable, |
} |
case FieldDescriptor::CPPTYPE_FLOAT: { |
float value = field->default_value_float(); |
- if (value == numeric_limits<float>::infinity()) { |
+ if (value == std::numeric_limits<float>::infinity()) { |
return "Float.POSITIVE_INFINITY"; |
- } else if (value == -numeric_limits<float>::infinity()) { |
+ } else if (value == -std::numeric_limits<float>::infinity()) { |
return "Float.NEGATIVE_INFINITY"; |
} else if (value != value) { |
return "Float.NaN"; |
@@ -481,9 +496,9 @@ bool IsDefaultValueJavaDefault(const FieldDescriptor* field) { |
return field->default_value_float() == 0.0; |
case FieldDescriptor::CPPTYPE_BOOL: |
return field->default_value_bool() == false; |
- |
- case FieldDescriptor::CPPTYPE_STRING: |
case FieldDescriptor::CPPTYPE_ENUM: |
+ return field->default_value_enum()->number() == 0; |
+ case FieldDescriptor::CPPTYPE_STRING: |
case FieldDescriptor::CPPTYPE_MESSAGE: |
return false; |
@@ -495,6 +510,11 @@ bool IsDefaultValueJavaDefault(const FieldDescriptor* field) { |
return false; |
} |
+bool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) { |
+ return GetJavaType(field) == JAVATYPE_BYTES && |
+ field->default_value_string() != ""; |
+} |
+ |
const char* bit_masks[] = { |
"0x00000001", |
"0x00000002", |