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

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

Issue 2590803003: Revert "third_party/protobuf: Update to HEAD (83d681ee2c)" (Closed)
Patch Set: Created 3 years, 12 months 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 all_values_.push_back(value); 55 all_values_.push_back(value);
56 } 56 }
57 } 57 }
58 58
59 EnumGenerator::~EnumGenerator() {} 59 EnumGenerator::~EnumGenerator() {}
60 60
61 void EnumGenerator::GenerateHeader(io::Printer* printer) { 61 void EnumGenerator::GenerateHeader(io::Printer* printer) {
62 string enum_comments; 62 string enum_comments;
63 SourceLocation location; 63 SourceLocation location;
64 if (descriptor_->GetSourceLocation(&location)) { 64 if (descriptor_->GetSourceLocation(&location)) {
65 enum_comments = BuildCommentsString(location, true); 65 enum_comments = BuildCommentsString(location);
66 } else { 66 } else {
67 enum_comments = ""; 67 enum_comments = "";
68 } 68 }
69 69
70 printer->Print( 70 printer->Print(
71 "#pragma mark - Enum $name$\n" 71 "#pragma mark - Enum $name$\n"
72 "\n", 72 "\n",
73 "name", name_); 73 "name", name_);
74 74
75 printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n", 75 printer->Print("$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\n",
76 "comments", enum_comments, 76 "comments", enum_comments,
77 "deprecated_attribute", GetOptionalDeprecatedAttribute(descript or_, descriptor_->file()), 77 "deprecated_attribute", GetOptionalDeprecatedAttribute(descript or_),
78 "name", name_); 78 "name", name_);
79 printer->Indent(); 79 printer->Indent();
80 80
81 if (HasPreservingUnknownEnumSemantics(descriptor_->file())) { 81 if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
82 // Include the unknown value. 82 // Include the unknown value.
83 printer->Print( 83 printer->Print(
84 "/**\n" 84 "/// Value used if any message's field encounters a value that is not defi ned\n"
85 " * Value used if any message's field encounters a value that is not defin ed\n" 85 "/// by this enum. The message will also have C functions to get/set the r awValue\n"
86 " * by this enum. The message will also have C functions to get/set the ra wValue\n" 86 "/// of the field.\n"
87 " * of the field.\n"
88 " **/\n"
89 "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\ n", 87 "$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\ n",
90 "name", name_); 88 "name", name_);
91 } 89 }
92 for (int i = 0; i < all_values_.size(); i++) { 90 for (int i = 0; i < all_values_.size(); i++) {
93 SourceLocation location; 91 SourceLocation location;
94 if (all_values_[i]->GetSourceLocation(&location)) { 92 if (all_values_[i]->GetSourceLocation(&location)) {
95 string comments = BuildCommentsString(location, true).c_str(); 93 string comments = BuildCommentsString(location).c_str();
96 if (comments.length() > 0) { 94 if (comments.length() > 0) {
97 if (i > 0) { 95 if (i > 0) {
98 printer->Print("\n"); 96 printer->Print("\n");
99 } 97 }
100 printer->Print(comments.c_str()); 98 printer->Print(comments.c_str());
101 } 99 }
102 } 100 }
103 101
104 printer->Print( 102 printer->Print(
105 "$name$$deprecated_attribute$ = $value$,\n", 103 "$name$$deprecated_attribute$ = $value$,\n",
106 "name", EnumValueName(all_values_[i]), 104 "name", EnumValueName(all_values_[i]),
107 "deprecated_attribute", GetOptionalDeprecatedAttribute(all_values_[i]), 105 "deprecated_attribute", GetOptionalDeprecatedAttribute(all_values_[i]),
108 "value", SimpleItoa(all_values_[i]->number())); 106 "value", SimpleItoa(all_values_[i]->number()));
109 } 107 }
110 printer->Outdent(); 108 printer->Outdent();
111 printer->Print( 109 printer->Print(
112 "};\n" 110 "};\n"
113 "\n" 111 "\n"
114 "GPBEnumDescriptor *$name$_EnumDescriptor(void);\n" 112 "GPBEnumDescriptor *$name$_EnumDescriptor(void);\n"
115 "\n" 113 "\n"
116 "/**\n" 114 "/// Checks to see if the given value is defined by the enum or was not kn own at\n"
117 " * Checks to see if the given value is defined by the enum or was not kno wn at\n" 115 "/// the time this source was generated.\n"
118 " * the time this source was generated.\n"
119 " **/\n"
120 "BOOL $name$_IsValidValue(int32_t value);\n" 116 "BOOL $name$_IsValidValue(int32_t value);\n"
121 "\n", 117 "\n",
122 "name", name_); 118 "name", name_);
123 } 119 }
124 120
125 void EnumGenerator::GenerateSource(io::Printer* printer) { 121 void EnumGenerator::GenerateSource(io::Printer* printer) {
126 printer->Print( 122 printer->Print(
127 "#pragma mark - Enum $name$\n" 123 "#pragma mark - Enum $name$\n"
128 "\n", 124 "\n",
129 "name", name_); 125 "name", name_);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 " return YES;\n" 210 " return YES;\n"
215 " default:\n" 211 " default:\n"
216 " return NO;\n" 212 " return NO;\n"
217 " }\n" 213 " }\n"
218 "}\n\n"); 214 "}\n\n");
219 } 215 }
220 } // namespace objectivec 216 } // namespace objectivec
221 } // namespace compiler 217 } // namespace compiler
222 } // namespace protobuf 218 } // namespace protobuf
223 } // namespace google 219 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698