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 30 matching lines...) Expand all Loading... |
41 #include <google/protobuf/stubs/mutex.h> | 41 #include <google/protobuf/stubs/mutex.h> |
42 #include <google/protobuf/stubs/common.h> | 42 #include <google/protobuf/stubs/common.h> |
43 | 43 |
44 namespace google { | 44 namespace google { |
45 namespace protobuf { | 45 namespace protobuf { |
46 | 46 |
47 class Descriptor; | 47 class Descriptor; |
48 class EnumDescriptor; | 48 class EnumDescriptor; |
49 class EnumValueDescriptor; | 49 class EnumValueDescriptor; |
50 class FieldDescriptor; | 50 class FieldDescriptor; |
51 class OneofDescriptor; | |
52 class ServiceDescriptor; | 51 class ServiceDescriptor; |
53 | 52 |
54 namespace io { class Printer; } | 53 namespace io { class Printer; } |
55 | 54 |
56 namespace compiler { | 55 namespace compiler { |
57 namespace python { | 56 namespace python { |
58 | 57 |
59 // CodeGenerator implementation for generated Python protocol buffer classes. | 58 // CodeGenerator implementation for generated Python protocol buffer classes. |
60 // If you create your own protocol compiler binary and you want it to support | 59 // If you create your own protocol compiler binary and you want it to support |
61 // Python output, you can do so by registering an instance of this | 60 // Python output, you can do so by registering an instance of this |
(...skipping 28 matching lines...) Expand all Loading... |
90 int (Descriptor::*CountFn)() const, | 89 int (Descriptor::*CountFn)() const, |
91 const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const; | 90 const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const; |
92 void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; | 91 void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const; |
93 void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; | 92 void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const; |
94 void PrintMessageDescriptors() const; | 93 void PrintMessageDescriptors() const; |
95 void PrintDescriptor(const Descriptor& message_descriptor) const; | 94 void PrintDescriptor(const Descriptor& message_descriptor) const; |
96 void PrintNestedDescriptors(const Descriptor& containing_descriptor) const; | 95 void PrintNestedDescriptors(const Descriptor& containing_descriptor) const; |
97 | 96 |
98 void PrintMessages() const; | 97 void PrintMessages() const; |
99 void PrintMessage(const Descriptor& message_descriptor, const string& prefix, | 98 void PrintMessage(const Descriptor& message_descriptor, const string& prefix, |
100 std::vector<string>* to_register) const; | 99 vector<string>* to_register) const; |
101 void PrintNestedMessages(const Descriptor& containing_descriptor, | 100 void PrintNestedMessages(const Descriptor& containing_descriptor, |
102 const string& prefix, | 101 const string& prefix, |
103 std::vector<string>* to_register) const; | 102 vector<string>* to_register) const; |
104 | 103 |
105 void FixForeignFieldsInDescriptors() const; | 104 void FixForeignFieldsInDescriptors() const; |
106 void FixForeignFieldsInDescriptor( | 105 void FixForeignFieldsInDescriptor( |
107 const Descriptor& descriptor, | 106 const Descriptor& descriptor, |
108 const Descriptor* containing_descriptor) const; | 107 const Descriptor* containing_descriptor) const; |
109 void FixForeignFieldsInField(const Descriptor* containing_type, | 108 void FixForeignFieldsInField(const Descriptor* containing_type, |
110 const FieldDescriptor& field, | 109 const FieldDescriptor& field, |
111 const string& python_dict_name) const; | 110 const string& python_dict_name) const; |
112 void AddMessageToFileDescriptor(const Descriptor& descriptor) const; | 111 void AddMessageToFileDescriptor(const Descriptor& descriptor) const; |
113 void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; | 112 void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; |
(...skipping 28 matching lines...) Expand all Loading... |
142 string ModuleLevelMessageName(const Descriptor& descriptor) const; | 141 string ModuleLevelMessageName(const Descriptor& descriptor) const; |
143 string ModuleLevelServiceDescriptorName( | 142 string ModuleLevelServiceDescriptorName( |
144 const ServiceDescriptor& descriptor) const; | 143 const ServiceDescriptor& descriptor) const; |
145 | 144 |
146 template <typename DescriptorT, typename DescriptorProtoT> | 145 template <typename DescriptorT, typename DescriptorProtoT> |
147 void PrintSerializedPbInterval( | 146 void PrintSerializedPbInterval( |
148 const DescriptorT& descriptor, DescriptorProtoT& proto) const; | 147 const DescriptorT& descriptor, DescriptorProtoT& proto) const; |
149 | 148 |
150 void FixAllDescriptorOptions() const; | 149 void FixAllDescriptorOptions() const; |
151 void FixOptionsForField(const FieldDescriptor& field) const; | 150 void FixOptionsForField(const FieldDescriptor& field) const; |
152 void FixOptionsForOneof(const OneofDescriptor& oneof) const; | |
153 void FixOptionsForEnum(const EnumDescriptor& descriptor) const; | 151 void FixOptionsForEnum(const EnumDescriptor& descriptor) const; |
154 void FixOptionsForMessage(const Descriptor& descriptor) const; | 152 void FixOptionsForMessage(const Descriptor& descriptor) const; |
155 | 153 |
156 void CopyPublicDependenciesAliases( | 154 void CopyPublicDependenciesAliases( |
157 const string& copy_from, const FileDescriptor* file) const; | 155 const string& copy_from, const FileDescriptor* file) const; |
158 | 156 |
159 // Very coarse-grained lock to ensure that Generate() is reentrant. | 157 // Very coarse-grained lock to ensure that Generate() is reentrant. |
160 // Guards file_, printer_ and file_descriptor_serialized_. | 158 // Guards file_, printer_ and file_descriptor_serialized_. |
161 mutable Mutex mutex_; | 159 mutable Mutex mutex_; |
162 mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. | 160 mutable const FileDescriptor* file_; // Set in Generate(). Under mutex_. |
163 mutable string file_descriptor_serialized_; | 161 mutable string file_descriptor_serialized_; |
164 mutable io::Printer* printer_; // Set in Generate(). Under mutex_. | 162 mutable io::Printer* printer_; // Set in Generate(). Under mutex_. |
165 | 163 |
166 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); | 164 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator); |
167 }; | 165 }; |
168 | 166 |
169 } // namespace python | 167 } // namespace python |
170 } // namespace compiler | 168 } // namespace compiler |
171 } // namespace protobuf | 169 } // namespace protobuf |
172 | 170 |
173 } // namespace google | 171 } // namespace google |
174 #endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ | 172 #endif // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__ |
OLD | NEW |