| OLD | NEW |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { | 182 void EnumGenerator::GenerateSymbolImports(io::Printer* printer) { |
| 183 map<string, string> vars; | 183 map<string, string> vars; |
| 184 vars["nested_name"] = descriptor_->name(); | 184 vars["nested_name"] = descriptor_->name(); |
| 185 vars["classname"] = classname_; | 185 vars["classname"] = classname_; |
| 186 vars["constexpr"] = options_.proto_h ? "constexpr " : ""; | 186 vars["constexpr"] = options_.proto_h ? "constexpr " : ""; |
| 187 printer->Print(vars, "typedef $classname$ $nested_name$;\n"); | 187 printer->Print(vars, "typedef $classname$ $nested_name$;\n"); |
| 188 | 188 |
| 189 for (int j = 0; j < descriptor_->value_count(); j++) { | 189 for (int j = 0; j < descriptor_->value_count(); j++) { |
| 190 vars["tag"] = EnumValueName(descriptor_->value(j)); | 190 vars["tag"] = EnumValueName(descriptor_->value(j)); |
| 191 vars["deprecated_attr"] = descriptor_->value(j)->options().deprecated() ? | 191 vars["deprecated_attr"] = descriptor_->value(j)->options().deprecated() ? |
| 192 "PROTOBUF_DEPRECATED_ATTR " : ""; | 192 "GOOGLE_PROTOBUF_DEPRECATED_ATTR " : ""; |
| 193 printer->Print(vars, | 193 printer->Print(vars, |
| 194 "$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\n" | 194 "$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\n" |
| 195 " $classname$_$tag$;\n"); | 195 " $classname$_$tag$;\n"); |
| 196 } | 196 } |
| 197 | 197 |
| 198 printer->Print(vars, | 198 printer->Print(vars, |
| 199 "static inline bool $nested_name$_IsValid(int value) {\n" | 199 "static inline bool $nested_name$_IsValid(int value) {\n" |
| 200 " return $classname$_IsValid(value);\n" | 200 " return $classname$_IsValid(value);\n" |
| 201 "}\n" | 201 "}\n" |
| 202 "static const $nested_name$ $nested_name$_MIN =\n" | 202 "static const $nested_name$ $nested_name$_MIN =\n" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if (HasDescriptorMethods(descriptor_->file(), options_)) { | 253 if (HasDescriptorMethods(descriptor_->file(), options_)) { |
| 254 printer->Print(vars, | 254 printer->Print(vars, |
| 255 "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" | 255 "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" |
| 256 " protobuf_AssignDescriptorsOnce();\n" | 256 " protobuf_AssignDescriptorsOnce();\n" |
| 257 " return $classname$_descriptor_;\n" | 257 " return $classname$_descriptor_;\n" |
| 258 "}\n"); | 258 "}\n"); |
| 259 } | 259 } |
| 260 | 260 |
| 261 printer->Print(vars, | 261 printer->Print(vars, |
| 262 "bool $classname$_IsValid(int value) {\n" | 262 "bool $classname$_IsValid(int value) {\n" |
| 263 " switch(value) {\n"); | 263 " switch (value) {\n"); |
| 264 | 264 |
| 265 // Multiple values may have the same number. Make sure we only cover | 265 // Multiple values may have the same number. Make sure we only cover |
| 266 // each number once by first constructing a set containing all valid | 266 // each number once by first constructing a set containing all valid |
| 267 // numbers, then printing a case statement for each element. | 267 // numbers, then printing a case statement for each element. |
| 268 | 268 |
| 269 set<int> numbers; | 269 set<int> numbers; |
| 270 for (int j = 0; j < descriptor_->value_count(); j++) { | 270 for (int j = 0; j < descriptor_->value_count(); j++) { |
| 271 const EnumValueDescriptor* value = descriptor_->value(j); | 271 const EnumValueDescriptor* value = descriptor_->value(j); |
| 272 numbers.insert(value->number()); | 272 numbers.insert(value->number()); |
| 273 } | 273 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 310 } |
| 311 | 311 |
| 312 printer->Print("#endif // !defined(_MSC_VER) || _MSC_VER >= 1900\n"); | 312 printer->Print("#endif // !defined(_MSC_VER) || _MSC_VER >= 1900\n"); |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace cpp | 316 } // namespace cpp |
| 317 } // namespace compiler | 317 } // namespace compiler |
| 318 } // namespace protobuf | 318 } // namespace protobuf |
| 319 } // namespace google | 319 } // namespace google |
| OLD | NEW |