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