| 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 |
| 71 // info_path, if non-empty, should be the path (relative to printer's output) | 74 // info_path, if non-empty, should be the path (relative to printer's output) |
| 72 // to the metadata file describing this proto header. | 75 // to the metadata file describing this proto header. |
| 73 void GenerateProtoHeader(io::Printer* printer, | 76 void GenerateProtoHeader(io::Printer* printer, |
| 74 const string& info_path); | 77 const string& info_path); |
| 75 // info_path, if non-empty, should be the path (relative to printer's output) | 78 // info_path, if non-empty, should be the path (relative to printer's output) |
| 76 // to the metadata file describing this PB header. | 79 // to the metadata file describing this PB header. |
| 77 void GeneratePBHeader(io::Printer* printer, | 80 void GeneratePBHeader(io::Printer* printer, |
| 78 const string& info_path); | 81 const string& info_path); |
| 79 void GenerateSource(io::Printer* printer); | 82 void GenerateSource(io::Printer* printer); |
| 80 | 83 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 110 // Generate a pragma to pull in metadata using the given info_path (if | 113 // Generate a pragma to pull in metadata using the given info_path (if |
| 111 // non-empty). info_path should be relative to printer's output. | 114 // non-empty). info_path should be relative to printer's output. |
| 112 void GenerateMetadataPragma(io::Printer* printer, const string& info_path); | 115 void GenerateMetadataPragma(io::Printer* printer, const string& info_path); |
| 113 | 116 |
| 114 // Generates a couple of different pieces before definitions: | 117 // Generates a couple of different pieces before definitions: |
| 115 void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); | 118 void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); |
| 116 | 119 |
| 117 // Generates types for classes. | 120 // Generates types for classes. |
| 118 void GenerateMessageDefinitions(io::Printer* printer); | 121 void GenerateMessageDefinitions(io::Printer* printer); |
| 119 | 122 |
| 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); | |
| 132 void GenerateEnumDefinitions(io::Printer* printer); | 123 void GenerateEnumDefinitions(io::Printer* printer); |
| 133 | 124 |
| 134 // Generates generic service definitions. | 125 // Generates generic service definitions. |
| 135 void GenerateServiceDefinitions(io::Printer* printer); | 126 void GenerateServiceDefinitions(io::Printer* printer); |
| 136 | 127 |
| 137 // Generates extension identifiers. | 128 // Generates extension identifiers. |
| 138 void GenerateExtensionIdentifiers(io::Printer* printer); | 129 void GenerateExtensionIdentifiers(io::Printer* printer); |
| 139 | 130 |
| 140 // Generates inline function defintions. | 131 // Generates inline function defintions. |
| 141 void GenerateInlineFunctionDefinitions(io::Printer* printer); | 132 void GenerateInlineFunctionDefinitions(io::Printer* printer); |
| 142 | 133 |
| 143 void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); | 134 void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); |
| 144 | 135 |
| 145 const FileDescriptor* file_; | 136 const FileDescriptor* file_; |
| 146 const Options options_; | 137 const Options options_; |
| 147 | 138 |
| 148 google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator>
> message_generators_; | 139 // Contains the post-order walk of all the messages (and child messages) in |
| 149 google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > e
num_generators_; | 140 // this file. If you need a pre-order walk just reverse iterate. |
| 150 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator>
> service_generators_; | 141 std::vector<MessageGenerator*> message_generators_; |
| 151 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator
> > extension_generators_; | 142 std::vector<EnumGenerator*> enum_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_; |
| 152 | 155 |
| 153 // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. | 156 // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. |
| 154 vector<string> package_parts_; | 157 std::vector<string> package_parts_; |
| 155 | 158 |
| 156 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); | 159 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); |
| 157 }; | 160 }; |
| 158 | 161 |
| 159 } // namespace cpp | 162 } // namespace cpp |
| 160 } // namespace compiler | 163 } // namespace compiler |
| 161 } // namespace protobuf | 164 } // namespace protobuf |
| 162 | 165 |
| 163 } // namespace google | 166 } // namespace google |
| 164 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ | 167 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ |
| OLD | NEW |