aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/objectivec/objectivec_field.cc
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2015-05-21 17:14:52 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2015-05-22 14:27:31 -0400
commit1dcc329427fd103a0abd96ab787270f5d0a31861 (patch)
treecf1c52df0e1effa3d0985a3406a71c38c3a4e487 /src/google/protobuf/compiler/objectivec/objectivec_field.cc
parentc3480926f98eb7c45224daae5cf0373e120b3b8d (diff)
Objective C Second Alpha Drop
- Style fixups in the code. - map<> serialization fixes and more tests. - Autocreation of map<> fields (to match repeated fields). - @@protoc_insertion_point(global_scope|imports). - Fixup proto2 syntax extension support. - Move all startup code to +initialize so it happen on class usage and not app startup. - Have generated headers use forward declarations and move imports into generated code, reduces what is need at compile time to speed up compiled and avoid pointless rippling of rebuilds.
Diffstat (limited to 'src/google/protobuf/compiler/objectivec/objectivec_field.cc')
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_field.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc
index 93fffe0e..ee5253a5 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc
@@ -80,7 +80,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
if (descriptor->is_repeated()) field_flags.push_back("GPBFieldRepeated");
if (descriptor->is_required()) field_flags.push_back("GPBFieldRequired");
if (descriptor->is_optional()) field_flags.push_back("GPBFieldOptional");
- if (descriptor->options().packed()) field_flags.push_back("GPBFieldPacked");
+ if (descriptor->is_packed()) field_flags.push_back("GPBFieldPacked");
// ObjC custom flags.
if (descriptor->has_default_value())
@@ -235,6 +235,11 @@ void FieldGenerator::GenerateCFunctionImplementations(
// Nothing
}
+void FieldGenerator::DetermineForwardDeclarations(
+ set<string>* fwd_decls) const {
+ // Nothing
+}
+
void FieldGenerator::GenerateFieldDescription(
io::Printer* printer) const {
printer->Print(
@@ -282,12 +287,16 @@ void FieldGenerator::SetOneofIndexBase(int index_base) {
if (descriptor_->containing_oneof() != NULL) {
int index = descriptor_->containing_oneof()->index() + index_base;
// Flip the sign to mark it as a oneof.
- variables_["has_index"] = SimpleItoa(-index);;
+ variables_["has_index"] = SimpleItoa(-index);
}
}
void FieldGenerator::FinishInitialization(void) {
- // Nothing
+ // If "property_type" wasn't set, make it "storage_type".
+ if ((variables_.find("property_type") == variables_.end()) &&
+ (variables_.find("storage_type") != variables_.end())) {
+ variables_["property_type"] = variable("storage_type");
+ }
}
SingleFieldGenerator::SingleFieldGenerator(
@@ -313,7 +322,7 @@ void SingleFieldGenerator::GeneratePropertyDeclaration(
}
printer->Print(
variables_,
- "@property(nonatomic, readwrite) $storage_type$ $name$;\n"
+ "@property(nonatomic, readwrite) $property_type$ $name$;\n"
"\n");
}
@@ -369,12 +378,12 @@ void ObjCObjFieldGenerator::GeneratePropertyDeclaration(
}
printer->Print(
variables_,
- "@property(nonatomic, readwrite, $property_storage_attribute$) $storage_type$ *$name$$storage_attribute$;\n");
+ "@property(nonatomic, readwrite, $property_storage_attribute$) $property_type$ *$name$$storage_attribute$;\n");
if (IsInitName(variables_.at("name"))) {
// If property name starts with init we need to annotate it to get past ARC.
// http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227
printer->Print(variables_,
- "- ($storage_type$ *)$name$ GPB_METHOD_FAMILY_NONE;\n");
+ "- ($property_type$ *)$name$ GPB_METHOD_FAMILY_NONE;\n");
}
printer->Print("\n");
}