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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 class MessageGenerator; // message.h | 61 class MessageGenerator; // message.h |
62 class ServiceGenerator; // service.h | 62 class ServiceGenerator; // service.h |
63 class ExtensionGenerator; // extension.h | 63 class ExtensionGenerator; // extension.h |
64 | 64 |
65 class FileGenerator { | 65 class FileGenerator { |
66 public: | 66 public: |
67 // See generator.cc for the meaning of dllexport_decl. | 67 // See generator.cc for the meaning of dllexport_decl. |
68 FileGenerator(const FileDescriptor* file, const Options& options); | 68 FileGenerator(const FileDescriptor* file, const Options& options); |
69 ~FileGenerator(); | 69 ~FileGenerator(); |
70 | 70 |
71 // Shared code between the two header generators below. | |
72 void GenerateHeader(io::Printer* printer); | |
73 | |
74 // info_path, if non-empty, should be the path (relative to printer's output) | 71 // info_path, if non-empty, should be the path (relative to printer's output) |
75 // to the metadata file describing this proto header. | 72 // to the metadata file describing this proto header. |
76 void GenerateProtoHeader(io::Printer* printer, | 73 void GenerateProtoHeader(io::Printer* printer, |
77 const string& info_path); | 74 const string& info_path); |
78 // info_path, if non-empty, should be the path (relative to printer's output) | 75 // info_path, if non-empty, should be the path (relative to printer's output) |
79 // to the metadata file describing this PB header. | 76 // to the metadata file describing this PB header. |
80 void GeneratePBHeader(io::Printer* printer, | 77 void GeneratePBHeader(io::Printer* printer, |
81 const string& info_path); | 78 const string& info_path); |
82 void GenerateSource(io::Printer* printer); | 79 void GenerateSource(io::Printer* printer); |
83 | 80 |
(...skipping 29 matching lines...) Expand all Loading... |
113 // Generate a pragma to pull in metadata using the given info_path (if | 110 // Generate a pragma to pull in metadata using the given info_path (if |
114 // non-empty). info_path should be relative to printer's output. | 111 // non-empty). info_path should be relative to printer's output. |
115 void GenerateMetadataPragma(io::Printer* printer, const string& info_path); | 112 void GenerateMetadataPragma(io::Printer* printer, const string& info_path); |
116 | 113 |
117 // Generates a couple of different pieces before definitions: | 114 // Generates a couple of different pieces before definitions: |
118 void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); | 115 void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); |
119 | 116 |
120 // Generates types for classes. | 117 // Generates types for classes. |
121 void GenerateMessageDefinitions(io::Printer* printer); | 118 void GenerateMessageDefinitions(io::Printer* printer); |
122 | 119 |
| 120 // Generates forward-declarations for just this file's classes. This is |
| 121 // used for .pb.h headers, but not in proto_h mode. |
| 122 void GenerateMessageForwardDeclarations(io::Printer* printer); |
| 123 |
| 124 // Fills in types for forward declarations. This is used internally, and |
| 125 // also by other FileGenerators to determine imports' declarations. |
| 126 void FillMessageForwardDeclarations(ForwardDeclarations* decls); |
| 127 void FillMessageDefinitions(ForwardDeclarations* decls); |
| 128 |
| 129 // Generates enum definitions. |
| 130 void GenerateEnumForwardDeclarations(io::Printer* printer); |
| 131 void FillEnumForwardDeclarations(ForwardDeclarations* decls); |
123 void GenerateEnumDefinitions(io::Printer* printer); | 132 void GenerateEnumDefinitions(io::Printer* printer); |
124 | 133 |
125 // Generates generic service definitions. | 134 // Generates generic service definitions. |
126 void GenerateServiceDefinitions(io::Printer* printer); | 135 void GenerateServiceDefinitions(io::Printer* printer); |
127 | 136 |
128 // Generates extension identifiers. | 137 // Generates extension identifiers. |
129 void GenerateExtensionIdentifiers(io::Printer* printer); | 138 void GenerateExtensionIdentifiers(io::Printer* printer); |
130 | 139 |
131 // Generates inline function defintions. | 140 // Generates inline function defintions. |
132 void GenerateInlineFunctionDefinitions(io::Printer* printer); | 141 void GenerateInlineFunctionDefinitions(io::Printer* printer); |
133 | 142 |
134 void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); | 143 void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); |
135 | 144 |
136 const FileDescriptor* file_; | 145 const FileDescriptor* file_; |
137 const Options options_; | 146 const Options options_; |
138 | 147 |
139 // Contains the post-order walk of all the messages (and child messages) in | 148 google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator>
> message_generators_; |
140 // this file. If you need a pre-order walk just reverse iterate. | 149 google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > e
num_generators_; |
141 std::vector<MessageGenerator*> message_generators_; | 150 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator>
> service_generators_; |
142 std::vector<EnumGenerator*> enum_generators_; | 151 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator
> > extension_generators_; |
143 std::vector<ServiceGenerator*> service_generators_; | |
144 std::vector<ExtensionGenerator*> extension_generators_; | |
145 | |
146 // These members are just for owning (and thus proper deleting). Some of the | |
147 // message_ and enum_generators above are owned by child messages. | |
148 google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator>
> | |
149 message_generators_owner_; | |
150 google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > e
num_generators_owner_; | |
151 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator>
> | |
152 service_generators_owner_; | |
153 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator
> > | |
154 extension_generators_owner_; | |
155 | 152 |
156 // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. | 153 // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. |
157 std::vector<string> package_parts_; | 154 vector<string> package_parts_; |
158 | 155 |
159 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); | 156 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); |
160 }; | 157 }; |
161 | 158 |
162 } // namespace cpp | 159 } // namespace cpp |
163 } // namespace compiler | 160 } // namespace compiler |
164 } // namespace protobuf | 161 } // namespace protobuf |
165 | 162 |
166 } // namespace google | 163 } // namespace google |
167 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ | 164 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ |
OLD | NEW |