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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 ~EnumGenerator(); | 59 ~EnumGenerator(); |
60 | 60 |
61 // Header stuff. | 61 // Header stuff. |
62 | 62 |
63 // Fills the name to use when declaring the enum. This is for use when | 63 // Fills the name to use when declaring the enum. This is for use when |
64 // generating other .proto.h files. This code should be placed within the | 64 // generating other .proto.h files. This code should be placed within the |
65 // enum's package namespace, but NOT within any class, even for nested | 65 // enum's package namespace, but NOT within any class, even for nested |
66 // enums. A given key in enum_names will map from an enum class name to the | 66 // enums. A given key in enum_names will map from an enum class name to the |
67 // EnumDescriptor that was responsible for its inclusion in the map. This can | 67 // EnumDescriptor that was responsible for its inclusion in the map. This can |
68 // be used to associate the descriptor with the code generated for it. | 68 // be used to associate the descriptor with the code generated for it. |
69 void FillForwardDeclaration( | 69 void FillForwardDeclaration(map<string, const EnumDescriptor*>* enum_names); |
70 std::map<string, const EnumDescriptor*>* enum_names); | |
71 | 70 |
72 // Generate header code defining the enum. This code should be placed | 71 // Generate header code defining the enum. This code should be placed |
73 // within the enum's package namespace, but NOT within any class, even for | 72 // within the enum's package namespace, but NOT within any class, even for |
74 // nested enums. | 73 // nested enums. |
75 void GenerateDefinition(io::Printer* printer); | 74 void GenerateDefinition(io::Printer* printer); |
76 | 75 |
77 // Generate specialization of GetEnumDescriptor<MyEnum>(). | 76 // Generate specialization of GetEnumDescriptor<MyEnum>(). |
78 // Precondition: in ::google::protobuf namespace. | 77 // Precondition: in ::google::protobuf namespace. |
79 void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); | 78 void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); |
80 | 79 |
81 // For enums nested within a message, generate code to import all the enum's | 80 // For enums nested within a message, generate code to import all the enum's |
82 // symbols (e.g. the enum type name, all its values, etc.) into the class's | 81 // symbols (e.g. the enum type name, all its values, etc.) into the class's |
83 // namespace. This should be placed inside the class definition in the | 82 // namespace. This should be placed inside the class definition in the |
84 // header. | 83 // header. |
85 void GenerateSymbolImports(io::Printer* printer); | 84 void GenerateSymbolImports(io::Printer* printer); |
86 | 85 |
87 // Source file stuff. | 86 // Source file stuff. |
88 | 87 |
89 // Generate code that initializes the global variable storing the enum's | 88 // Generate code that initializes the global variable storing the enum's |
90 // descriptor. | 89 // descriptor. |
91 void GenerateDescriptorInitializer(io::Printer* printer); | 90 void GenerateDescriptorInitializer(io::Printer* printer, int index); |
92 | 91 |
93 // Generate non-inline methods related to the enum, such as IsValidValue(). | 92 // Generate non-inline methods related to the enum, such as IsValidValue(). |
94 // Goes in the .cc file. | 93 // Goes in the .cc file. |
95 void GenerateMethods(io::Printer* printer); | 94 void GenerateMethods(io::Printer* printer); |
96 | 95 |
97 private: | 96 private: |
98 const EnumDescriptor* descriptor_; | 97 const EnumDescriptor* descriptor_; |
99 const string classname_; | 98 const string classname_; |
100 const Options& options_; | 99 const Options& options_; |
101 // whether to generate the *_ARRAYSIZE constant. | 100 // whether to generate the *_ARRAYSIZE constant. |
102 const bool generate_array_size_; | 101 const bool generate_array_size_; |
103 | 102 |
104 int index_in_metadata_; | |
105 | |
106 friend class FileGenerator; | |
107 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); | 103 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); |
108 }; | 104 }; |
109 | 105 |
110 } // namespace cpp | 106 } // namespace cpp |
111 } // namespace compiler | 107 } // namespace compiler |
112 } // namespace protobuf | 108 } // namespace protobuf |
113 | 109 |
114 } // namespace google | 110 } // namespace google |
115 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__ | 111 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__ |
OLD | NEW |