webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
cpp_file.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
36 #define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
37 
38 #include <memory>
39 #ifndef _SHARED_PTR_H
41 #endif
42 #include <string>
43 #include <vector>
47 
48 namespace google {
49 namespace protobuf {
50  class FileDescriptor; // descriptor.h
51  namespace io {
52  class Printer; // printer.h
53  }
54 }
55 
56 namespace protobuf {
57 namespace compiler {
58 namespace cpp {
59 
60 class EnumGenerator; // enum.h
61 class MessageGenerator; // message.h
62 class ServiceGenerator; // service.h
63 class ExtensionGenerator; // extension.h
64 
66  public:
67  // See generator.cc for the meaning of dllexport_decl.
69  ~FileGenerator();
70 
71  // info_path, if non-empty, should be the path (relative to printer's output)
72  // to the metadata file describing this proto header.
73  void GenerateProtoHeader(io::Printer* printer,
74  const string& info_path);
75  // info_path, if non-empty, should be the path (relative to printer's output)
76  // to the metadata file describing this PB header.
77  void GeneratePBHeader(io::Printer* printer,
78  const string& info_path);
79  void GenerateSource(io::Printer* printer);
80 
81  private:
82  // Internal type used by GenerateForwardDeclarations (defined in file.cc).
83  class ForwardDeclarations;
84 
85  // Generate the BuildDescriptors() procedure, which builds all descriptors
86  // for types defined in the file.
87  void GenerateBuildDescriptors(io::Printer* printer);
88 
89  void GenerateNamespaceOpeners(io::Printer* printer);
90  void GenerateNamespaceClosers(io::Printer* printer);
91 
92  // For other imports, generates their forward-declarations.
93  void GenerateForwardDeclarations(io::Printer* printer);
94 
95  // Internal helper used by GenerateForwardDeclarations: fills 'decls'
96  // with all necessary forward-declarations for this file and its
97  // transient depednencies.
98  void FillForwardDeclarations(ForwardDeclarations* decls);
99 
100  // Generates top or bottom of a header file.
101  void GenerateTopHeaderGuard(io::Printer* printer,
102  const string& filename_identifier);
103  void GenerateBottomHeaderGuard(io::Printer* printer,
104  const string& filename_identifier);
105 
106  // Generates #include directives.
107  void GenerateLibraryIncludes(io::Printer* printer);
108  void GenerateDependencyIncludes(io::Printer* printer);
109 
110  // 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.
112  void GenerateMetadataPragma(io::Printer* printer, const string& info_path);
113 
114  // Generates a couple of different pieces before definitions:
115  void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);
116 
117  // Generates types for classes.
118  void GenerateMessageDefinitions(io::Printer* printer);
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);
132  void GenerateEnumDefinitions(io::Printer* printer);
133 
134  // Generates generic service definitions.
135  void GenerateServiceDefinitions(io::Printer* printer);
136 
137  // Generates extension identifiers.
138  void GenerateExtensionIdentifiers(io::Printer* printer);
139 
140  // Generates inline function defintions.
141  void GenerateInlineFunctionDefinitions(io::Printer* printer);
142 
143  void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);
144 
145  const FileDescriptor* file_;
146  const Options options_;
147 
152 
153  // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}.
154  vector<string> package_parts_;
155 
157 };
158 
159 } // namespace cpp
160 } // namespace compiler
161 } // namespace protobuf
162 
163 } // namespace google
164 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
Definition: upb.c:6604
Definition: printer.h:164
Definition: cpp_options.h:45
#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)
Definition: macros.h:40
options
Definition: CodeGeneratorReplayInputs.py:1046
Definition: descriptor.h:1156
VoEFile * file
Definition: voe_cmd_test.cc:59
Definition: scoped_ptr.h:49
Definition: __init__.py:1
Definition: gflags_completions.h:115