Index: third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc b/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc |
index 30a13ddb9032677a5a522720bf6e2b295216ba2c..b63bc0de6322bd307ee1f756ada42b919e605784 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc |
@@ -44,6 +44,7 @@ namespace compiler { |
namespace objectivec { |
namespace { |
+ |
void SetEnumVariables(const FieldDescriptor* descriptor, |
map<string, string>* variables) { |
string type = EnumName(descriptor->enum_type()); |
@@ -58,25 +59,22 @@ void SetEnumVariables(const FieldDescriptor* descriptor, |
(*variables)["enum_verifier"] = type + "_IsValidValue"; |
(*variables)["enum_desc_func"] = type + "_EnumDescriptor"; |
+ (*variables)["dataTypeSpecific_name"] = "enumDescFunc"; |
+ (*variables)["dataTypeSpecific_value"] = (*variables)["enum_desc_func"]; |
+ |
const Descriptor* msg_descriptor = descriptor->containing_type(); |
(*variables)["owning_message_class"] = ClassName(msg_descriptor); |
} |
} // namespace |
-EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor) |
- : SingleFieldGenerator(descriptor) { |
+EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor, |
+ const Options& options) |
+ : SingleFieldGenerator(descriptor, options) { |
SetEnumVariables(descriptor, &variables_); |
} |
EnumFieldGenerator::~EnumFieldGenerator() {} |
-void EnumFieldGenerator::GenerateFieldDescriptionTypeSpecific( |
- io::Printer* printer) const { |
- printer->Print( |
- variables_, |
- " .dataTypeSpecific.enumDescFunc = $enum_desc_func$,\n"); |
-} |
- |
void EnumFieldGenerator::GenerateCFunctionDeclarations( |
io::Printer* printer) const { |
if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) { |
@@ -85,7 +83,12 @@ void EnumFieldGenerator::GenerateCFunctionDeclarations( |
printer->Print( |
variables_, |
+ "/// Fetches the raw value of a @c $owning_message_class$'s @c $name$ property, even\n" |
+ "/// if the value was not defined by the enum at the time the code was generated.\n" |
"int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message);\n" |
+ "/// Sets the raw value of an @c $owning_message_class$'s @c $name$ property, allowing\n" |
+ "/// it to be set to a value that was not defined by the enum at the time the code\n" |
+ "/// was generated.\n" |
"void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value);\n" |
"\n"); |
} |
@@ -112,6 +115,7 @@ void EnumFieldGenerator::GenerateCFunctionImplementations( |
void EnumFieldGenerator::DetermineForwardDeclarations( |
set<string>* fwd_decls) const { |
+ SingleFieldGenerator::DetermineForwardDeclarations(fwd_decls); |
// If it is an enum defined in a different file, then we'll need a forward |
// declaration for it. When it is in our file, all the enums are output |
// before the message, so it will be declared before it is needed. |
@@ -123,19 +127,18 @@ void EnumFieldGenerator::DetermineForwardDeclarations( |
} |
RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator( |
- const FieldDescriptor* descriptor) |
- : RepeatedFieldGenerator(descriptor) { |
+ const FieldDescriptor* descriptor, const Options& options) |
+ : RepeatedFieldGenerator(descriptor, options) { |
SetEnumVariables(descriptor, &variables_); |
variables_["array_storage_type"] = "GPBEnumArray"; |
} |
RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {} |
-void RepeatedEnumFieldGenerator::GenerateFieldDescriptionTypeSpecific( |
- io::Printer* printer) const { |
- printer->Print( |
- variables_, |
- " .dataTypeSpecific.enumDescFunc = $enum_desc_func$,\n"); |
+void RepeatedEnumFieldGenerator::FinishInitialization(void) { |
+ RepeatedFieldGenerator::FinishInitialization(); |
+ variables_["array_comment"] = |
+ "// |" + variables_["name"] + "| contains |" + variables_["storage_type"] + "|\n"; |
} |
} // namespace objectivec |