diff options
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_message.h')
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_message.h | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index ca2ca2c9..6bef8d56 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -45,37 +45,33 @@ namespace google { namespace protobuf { - namespace io { - class Printer; // printer.h - } +namespace io { +class Printer; // printer.h } +} // namespace protobuf +} // namespace google +namespace google { namespace protobuf { namespace compiler { namespace cpp { -class EnumGenerator; // enum.h -class ExtensionGenerator; // extension.h +class EnumGenerator; // enum.h +class ExtensionGenerator; // extension.h class MessageGenerator { public: // See generator.cc for the meaning of dllexport_decl. - MessageGenerator(const Descriptor* descriptor, int index_in_file_messages, - const Options& options, SCCAnalyzer* scc_analyzer); + MessageGenerator(const Descriptor* descriptor, + const std::map<std::string, std::string>& vars, + int index_in_file_messages, const Options& options, + MessageSCCAnalyzer* scc_analyzer); ~MessageGenerator(); // Append the two types of nested generators to the corresponding vector. - void AddGenerators(std::vector<EnumGenerator*>* enum_generators, - std::vector<ExtensionGenerator*>* extension_generators); - - // Header stuff. - - // Return names for forward declarations of this class and all its nested - // types. A given key in {class,enum}_names will map from a class name to the - // descriptor that was responsible for its inclusion in the map. This can be - // used to associate the descriptor with the code generated for it. - void FillMessageForwardDeclarations( - std::map<string, const Descriptor*>* class_names); + void AddGenerators( + std::vector<std::unique_ptr<EnumGenerator>>* enum_generators, + std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators); // Generate definitions for this class and all its nested types. void GenerateClassDefinition(io::Printer* printer); @@ -112,8 +108,8 @@ class MessageGenerator { // generated. size_t GenerateParseOffsets(io::Printer* printer); size_t GenerateParseAuxTable(io::Printer* printer); - // Generates a ParseTable entry. Returns whether the proto uses table-driven - // parsing. + // Generates a ParseTable entry. Returns whether the proto uses + // table-driven parsing. bool GenerateParseTable(io::Printer* printer, size_t offset, size_t aux_offset); @@ -140,8 +136,8 @@ class MessageGenerator { void GenerateArenaDestructorCode(io::Printer* printer); // Helper for GenerateClear and others. Optionally emits a condition that - // assumes the existence of the cached_has_bits variable, and returns true if - // the condition was printed. + // assumes the existence of the cached_has_bits variable, and returns true + // if the condition was printed. bool MaybeGenerateOptionalFieldCondition(io::Printer* printer, const FieldDescriptor* field, int expected_has_bits_index); @@ -166,8 +162,7 @@ class MessageGenerator { // cached_has_bits = _has_bits_[cached_has_bit_index] // for cached_has_bit_index >= 0 void GenerateSerializeOneField(io::Printer* printer, - const FieldDescriptor* field, - bool unbounded, + const FieldDescriptor* field, bool unbounded, int cached_has_bits_index); // Generate a switch statement to serialize 2+ fields from the same oneof. // Or, if fields.size() == 1, just call GenerateSerializeOneField(). @@ -180,19 +175,15 @@ class MessageGenerator { // Generates has_foo() functions and variables for singular field has-bits. void GenerateSingularFieldHasBits(const FieldDescriptor* field, - std::map<string, string> vars, - io::Printer* printer); + Formatter format); // Generates has_foo() functions and variables for oneof field has-bits. void GenerateOneofHasBits(io::Printer* printer); // Generates has_foo_bar() functions for oneof members. void GenerateOneofMemberHasBits(const FieldDescriptor* field, - const std::map<string, string>& vars, - io::Printer* printer); + const Formatter& format); // Generates the clear_foo() method for a field. - void GenerateFieldClear(const FieldDescriptor* field, - const std::map<string, string>& vars, - bool is_inline, - io::Printer* printer); + void GenerateFieldClear(const FieldDescriptor* field, bool is_inline, + Formatter format); void GenerateConstructorBody(io::Printer* printer, std::vector<bool> already_processed, @@ -203,18 +194,19 @@ class MessageGenerator { const Descriptor* descriptor_; int index_in_file_messages_; - string classname_; + std::string classname_; Options options_; FieldGeneratorMap field_generators_; - // optimized_order_ is the order we layout the message's fields in the class. - // This is reused to initialize the fields in-order for cache efficiency. + // optimized_order_ is the order we layout the message's fields in the + // class. This is reused to initialize the fields in-order for cache + // efficiency. // // optimized_order_ excludes oneof fields and weak fields. - std::vector<const FieldDescriptor *> optimized_order_; + std::vector<const FieldDescriptor*> optimized_order_; std::vector<int> has_bit_indices_; int max_has_bit_index_; - std::unique_ptr<std::unique_ptr<EnumGenerator> []> enum_generators_; - std::unique_ptr<std::unique_ptr<ExtensionGenerator> []> extension_generators_; + std::vector<const EnumGenerator*> enum_generators_; + std::vector<const ExtensionGenerator*> extension_generators_; int num_required_fields_; int num_weak_fields_; // table_driven_ indicates the generated message uses table-driven parsing. @@ -222,8 +214,9 @@ class MessageGenerator { std::unique_ptr<MessageLayoutHelper> message_layout_helper_; - SCCAnalyzer* scc_analyzer_; - string scc_name_; + MessageSCCAnalyzer* scc_analyzer_; + + std::map<std::string, std::string> variables_; friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); @@ -232,6 +225,6 @@ class MessageGenerator { } // namespace cpp } // namespace compiler } // namespace protobuf - } // namespace google + #endif // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__ |