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

Side by Side Diff: third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Update to new HEAD (b7632464b4) + restore GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 } 240 }
241 241
242 for (vector<MessageGenerator*>::iterator iter = 242 for (vector<MessageGenerator*>::iterator iter =
243 nested_message_generators_.begin(); 243 nested_message_generators_.begin();
244 iter != nested_message_generators_.end(); ++iter) { 244 iter != nested_message_generators_.end(); ++iter) {
245 (*iter)->DetermineForwardDeclarations(fwd_decls); 245 (*iter)->DetermineForwardDeclarations(fwd_decls);
246 } 246 }
247 } 247 }
248 248
249 bool MessageGenerator::IncludesOneOfDefinition() const {
250 if (!oneof_generators_.empty()) {
251 return true;
252 }
253
254 for (vector<MessageGenerator*>::const_iterator iter =
255 nested_message_generators_.begin();
256 iter != nested_message_generators_.end(); ++iter) {
257 if ((*iter)->IncludesOneOfDefinition()) {
258 return true;
259 }
260 }
261
262 return false;
263 }
264
249 void MessageGenerator::GenerateEnumHeader(io::Printer* printer) { 265 void MessageGenerator::GenerateEnumHeader(io::Printer* printer) {
250 for (vector<EnumGenerator*>::iterator iter = enum_generators_.begin(); 266 for (vector<EnumGenerator*>::iterator iter = enum_generators_.begin();
251 iter != enum_generators_.end(); ++iter) { 267 iter != enum_generators_.end(); ++iter) {
252 (*iter)->GenerateHeader(printer); 268 (*iter)->GenerateHeader(printer);
253 } 269 }
254 270
255 for (vector<MessageGenerator*>::iterator iter = 271 for (vector<MessageGenerator*>::iterator iter =
256 nested_message_generators_.begin(); 272 nested_message_generators_.begin();
257 iter != nested_message_generators_.end(); ++iter) { 273 iter != nested_message_generators_.end(); ++iter) {
258 (*iter)->GenerateEnumHeader(printer); 274 (*iter)->GenerateEnumHeader(printer);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 324 }
309 325
310 for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin(); 326 for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();
311 iter != oneof_generators_.end(); ++iter) { 327 iter != oneof_generators_.end(); ++iter) {
312 (*iter)->GenerateCaseEnum(printer); 328 (*iter)->GenerateCaseEnum(printer);
313 } 329 }
314 330
315 string message_comments; 331 string message_comments;
316 SourceLocation location; 332 SourceLocation location;
317 if (descriptor_->GetSourceLocation(&location)) { 333 if (descriptor_->GetSourceLocation(&location)) {
318 message_comments = BuildCommentsString(location); 334 message_comments = BuildCommentsString(location, false);
319 } else { 335 } else {
320 message_comments = ""; 336 message_comments = "";
321 } 337 }
322 338
323 printer->Print( 339 printer->Print(
324 "$comments$$deprecated_attribute$@interface $classname$ : GPBMessage\n\n", 340 "$comments$$deprecated_attribute$@interface $classname$ : GPBMessage\n\n",
325 "classname", class_name_, 341 "classname", class_name_,
326 "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, false, true), 342 "deprecated_attribute", GetOptionalDeprecatedAttribute(descriptor_, false, true),
327 "comments", message_comments); 343 "comments", message_comments);
328 344
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 vars["fields_count"] = "0"; 514 vars["fields_count"] = "0";
499 } 515 }
500 516
501 std::vector<string> init_flags; 517 std::vector<string> init_flags;
502 if (need_defaults) { 518 if (need_defaults) {
503 init_flags.push_back("GPBDescriptorInitializationFlag_FieldsWithDefault"); 519 init_flags.push_back("GPBDescriptorInitializationFlag_FieldsWithDefault");
504 } 520 }
505 if (descriptor_->options().message_set_wire_format()) { 521 if (descriptor_->options().message_set_wire_format()) {
506 init_flags.push_back("GPBDescriptorInitializationFlag_WireFormat"); 522 init_flags.push_back("GPBDescriptorInitializationFlag_WireFormat");
507 } 523 }
508 vars["init_flags"] = BuildFlagsString(init_flags); 524 vars["init_flags"] = BuildFlagsString(FLAGTYPE_DESCRIPTOR_INITIALIZATION,
525 init_flags);
509 526
510 printer->Print( 527 printer->Print(
511 vars, 528 vars,
512 " GPBDescriptor *localDescriptor =\n" 529 " GPBDescriptor *localDescriptor =\n"
513 " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n" 530 " [GPBDescriptor allocDescriptorForClass:[$classname$ class]\n"
514 " rootClass:[$rootclassname$ class]\ n" 531 " rootClass:[$rootclassname$ class]\ n"
515 " file:$rootclassname$_FileDesc riptor()\n" 532 " file:$rootclassname$_FileDesc riptor()\n"
516 " fields:$fields$\n" 533 " fields:$fields$\n"
517 " fieldCount:$fields_count$\n" 534 " fieldCount:$fields_count$\n"
518 " storageSize:sizeof($classname$__stor age_)\n" 535 " storageSize:sizeof($classname$__stor age_)\n"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 for (int i = 0; i < sorted_extensions.size(); i++) { 573 for (int i = 0; i < sorted_extensions.size(); i++) {
557 printer->Print(" { .start = $start$, .end = $end$ },\n", 574 printer->Print(" { .start = $start$, .end = $end$ },\n",
558 "start", SimpleItoa(sorted_extensions[i]->start), 575 "start", SimpleItoa(sorted_extensions[i]->start),
559 "end", SimpleItoa(sorted_extensions[i]->end)); 576 "end", SimpleItoa(sorted_extensions[i]->end));
560 } 577 }
561 printer->Print( 578 printer->Print(
562 " };\n" 579 " };\n"
563 " [localDescriptor setupExtensionRanges:ranges\n" 580 " [localDescriptor setupExtensionRanges:ranges\n"
564 " count:(uint32_t)(sizeof(ranges) / sizeof(GPBExtensionRange))];\n"); 581 " count:(uint32_t)(sizeof(ranges) / sizeof(GPBExtensionRange))];\n");
565 } 582 }
583 if (descriptor_->containing_type() != NULL) {
584 string parent_class_name = ClassName(descriptor_->containing_type());
585 printer->Print(
586 " [localDescriptor setupContainingMessageClassName:GPBStringifySymb ol($parent_name$)];\n",
587 "parent_name", parent_class_name);
588 }
589 string suffix_added;
590 ClassName(descriptor_, &suffix_added);
591 if (suffix_added.size() > 0) {
592 printer->Print(
593 " [localDescriptor setupMessageClassNameSuffix:@\"$suffix$\"];\n",
594 "suffix", suffix_added);
595 }
566 printer->Print( 596 printer->Print(
567 " NSAssert(descriptor == nil, @\"Startup recursed!\");\n" 597 " NSAssert(descriptor == nil, @\"Startup recursed!\");\n"
568 " descriptor = localDescriptor;\n" 598 " descriptor = localDescriptor;\n"
569 " }\n" 599 " }\n"
570 " return descriptor;\n" 600 " return descriptor;\n"
571 "}\n\n" 601 "}\n\n"
572 "@end\n\n"); 602 "@end\n\n");
573 603
574 for (int i = 0; i < descriptor_->field_count(); i++) { 604 for (int i = 0; i < descriptor_->field_count(); i++) {
575 field_generators_.get(descriptor_->field(i)) 605 field_generators_.get(descriptor_->field(i))
(...skipping 15 matching lines...) Expand all
591 nested_message_generators_.begin(); 621 nested_message_generators_.begin();
592 iter != nested_message_generators_.end(); ++iter) { 622 iter != nested_message_generators_.end(); ++iter) {
593 (*iter)->GenerateSource(printer); 623 (*iter)->GenerateSource(printer);
594 } 624 }
595 } 625 }
596 626
597 } // namespace objectivec 627 } // namespace objectivec
598 } // namespace compiler 628 } // namespace compiler
599 } // namespace protobuf 629 } // namespace protobuf
600 } // namespace google 630 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698