aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/objectivec/objectivec_message.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_message.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_message.cc')
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_message.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
index f6a5852d..52e583bf 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
@@ -120,6 +120,8 @@ int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) {
return 1;
}
+ // Some compilers report reaching end of function even though all cases of
+ // the enum are handed in the switch.
GOOGLE_LOG(FATAL) << "Can't get here.";
return 0;
}
@@ -188,7 +190,7 @@ MessageGenerator::MessageGenerator(const string& root_classname,
extension_generators_.push_back(
new ExtensionGenerator(class_name_, descriptor_->extension(i)));
}
- // No need to oneofs if this message is filtered
+ // No need to generate oneofs if this message is filtered.
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
OneofGenerator* generator = new OneofGenerator(descriptor_->oneof_decl(i));
oneof_generators_.push_back(generator);
@@ -253,15 +255,24 @@ void MessageGenerator::GenerateStaticVariablesInitialization(
}
}
-void MessageGenerator::DetermineDependencies(set<string>* dependencies) {
+void MessageGenerator::DetermineForwardDeclarations(set<string>* fwd_decls) {
if (!IsFiltered() && !IsMapEntryMessage(descriptor_)) {
- dependencies->insert("@class " + class_name_);
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* fieldDescriptor = descriptor_->field(i);
+ // If it is a the field is repeated, the type will be and *Array,
+ // and we don't need any forward decl.
+ if (fieldDescriptor->is_repeated()) {
+ continue;
+ }
+ field_generators_.get(fieldDescriptor)
+ .DetermineForwardDeclarations(fwd_decls);
+ }
}
for (vector<MessageGenerator*>::iterator iter =
nested_message_generators_.begin();
iter != nested_message_generators_.end(); ++iter) {
- (*iter)->DetermineDependencies(dependencies);
+ (*iter)->DetermineForwardDeclarations(fwd_decls);
}
}
@@ -361,13 +372,13 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
"classname", class_name_,
"comments", message_comments);
- vector<bool> seen_oneofs(descriptor_->oneof_decl_count(), false);
+ vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0);
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (field->containing_oneof() != NULL) {
const int oneof_index = field->containing_oneof()->index();
if (!seen_oneofs[oneof_index]) {
- seen_oneofs[oneof_index] = true;
+ seen_oneofs[oneof_index] = 1;
oneof_generators_[oneof_index]->GeneratePublicCasePropertyDeclaration(
printer);
}