| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 class Printer; // printer.h | 51 class Printer; // printer.h |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 namespace protobuf { | 55 namespace protobuf { |
| 56 namespace compiler { | 56 namespace compiler { |
| 57 namespace java { | 57 namespace java { |
| 58 | 58 |
| 59 class EnumLiteGenerator { | 59 class EnumLiteGenerator { |
| 60 public: | 60 public: |
| 61 EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api, | 61 explicit EnumLiteGenerator(const EnumDescriptor* descriptor, |
| 62 Context* context); | 62 bool immutable_api, |
| 63 Context* context); |
| 63 ~EnumLiteGenerator(); | 64 ~EnumLiteGenerator(); |
| 64 | 65 |
| 65 void Generate(io::Printer* printer); | 66 void Generate(io::Printer* printer); |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 const EnumDescriptor* descriptor_; | 69 const EnumDescriptor* descriptor_; |
| 69 | 70 |
| 70 // The proto language allows multiple enum constants to have the same numeric | 71 // The proto language allows multiple enum constants to have the same numeric |
| 71 // value. Java, however, does not allow multiple enum constants to be | 72 // value. Java, however, does not allow multiple enum constants to be |
| 72 // considered equivalent. We treat the first defined constant for any | 73 // considered equivalent. We treat the first defined constant for any |
| 73 // given numeric value as "canonical" and the rest as aliases of that | 74 // given numeric value as "canonical" and the rest as aliases of that |
| 74 // canonical value. | 75 // canonical value. |
| 75 std::vector<const EnumValueDescriptor*> canonical_values_; | 76 vector<const EnumValueDescriptor*> canonical_values_; |
| 76 | 77 |
| 77 struct Alias { | 78 struct Alias { |
| 78 const EnumValueDescriptor* value; | 79 const EnumValueDescriptor* value; |
| 79 const EnumValueDescriptor* canonical_value; | 80 const EnumValueDescriptor* canonical_value; |
| 80 }; | 81 }; |
| 81 std::vector<Alias> aliases_; | 82 vector<Alias> aliases_; |
| 82 | 83 |
| 83 bool immutable_api_; | 84 bool immutable_api_; |
| 84 | 85 |
| 85 Context* context_; | 86 Context* context_; |
| 86 ClassNameResolver* name_resolver_; | 87 ClassNameResolver* name_resolver_; |
| 87 | 88 |
| 88 bool CanUseEnumValues(); | 89 bool CanUseEnumValues(); |
| 89 | 90 |
| 90 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator); | 91 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator); |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 } // namespace java | 94 } // namespace java |
| 94 } // namespace compiler | 95 } // namespace compiler |
| 95 } // namespace protobuf | 96 } // namespace protobuf |
| 96 | 97 |
| 97 } // namespace google | 98 } // namespace google |
| 98 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__ | 99 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__ |
| OLD | NEW |