From 5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 17 Nov 2016 16:48:38 -0800 Subject: Integrated internal changes from Google --- src/google/protobuf/compiler/cpp/cpp_message.h | 51 ++++++++++++++------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'src/google/protobuf/compiler/cpp/cpp_message.h') diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index 3bdc0ed3..c5efff12 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -64,6 +64,12 @@ class MessageGenerator { MessageGenerator(const Descriptor* descriptor, const Options& options); ~MessageGenerator(); + // Appends the pre-order walk of the nested generators to list. + void Flatten(std::vector* list); + // Append the two types of nested generators to the corresponding vector. + void AddGenerators(std::vector* enum_generators, + std::vector* extension_generators); + // Header stuff. // Return names for forward declarations of this class and all its nested @@ -71,17 +77,7 @@ class MessageGenerator { // 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( - map* class_names); - void FillEnumForwardDeclarations( - map* enum_names); - - // Generate definitions of all nested enums (must come before class - // definitions because those classes use the enums definitions). - void GenerateEnumDefinitions(io::Printer* printer); - - // Generate specializations of GetEnumDescriptor(). - // Precondition: in ::google::protobuf namespace. - void GenerateGetEnumDescriptorSpecializations(io::Printer* printer); + std::map* class_names); // Generate definitions for this class and all its nested types. void GenerateClassDefinition(io::Printer* printer); @@ -99,10 +95,6 @@ class MessageGenerator { // will be initialized by the methods below. void GenerateDescriptorDeclarations(io::Printer* printer); - // Generate code that initializes the global variable storing the message's - // descriptor. - void GenerateDescriptorInitializer(io::Printer* printer, int index); - // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage() // for all types. void GenerateTypeRegistrations(io::Printer* printer); @@ -130,8 +122,10 @@ class MessageGenerator { void GenerateDependentFieldAccessorDefinitions(io::Printer* printer); void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline); - // Generate the field offsets array. - void GenerateOffsets(io::Printer* printer); + // Generate the field offsets array. Returns the a pair of the total numer + // of entries generated and the index of the first has_bit entry. + std::pair GenerateOffsets(io::Printer* printer); + void GenerateSchema(io::Printer* printer, int offset, int has_offset); // Generate constructors and destructor. void GenerateStructors(io::Printer* printer); @@ -168,7 +162,7 @@ class MessageGenerator { // Generate a switch statement to serialize 2+ fields from the same oneof. // Or, if fields.size() == 1, just call GenerateSerializeOneField(). void GenerateSerializeOneofFields( - io::Printer* printer, const vector& fields, + io::Printer* printer, const std::vector& fields, bool to_array); void GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range, @@ -177,19 +171,26 @@ class MessageGenerator { // Generates has_foo() functions and variables for singular field has-bits. void GenerateSingularFieldHasBits(const FieldDescriptor* field, - map vars, + std::map vars, io::Printer* printer); // Generates has_foo() functions and variables for oneof field has-bits. void GenerateOneofHasBits(io::Printer* printer, bool is_inline); // Generates has_foo_bar() functions for oneof members. void GenerateOneofMemberHasBits(const FieldDescriptor* field, - const map& vars, + const std::map& vars, io::Printer* printer); // Generates the clear_foo() method for a field. void GenerateFieldClear(const FieldDescriptor* field, - const map& vars, + const std::map& vars, io::Printer* printer); + void GenerateConstructorBody(io::Printer* printer, + std::vector already_processed, + bool copy_constructor) const; + + size_t HasBitsSize() const; + std::vector RequiredFieldsBitMask() const; + const Descriptor* descriptor_; string classname_; Options options_; @@ -198,15 +199,17 @@ class MessageGenerator { // This is reused to initialize the fields in-order for cache efficiency. // // optimized_order_ excludes oneof fields. - vector optimized_order_; - vector< vector > runs_of_fields_; // that might be trivially cleared + std::vector optimized_order_; + std::vector has_bit_indices_; google::protobuf::scoped_array > nested_generators_; google::protobuf::scoped_array > enum_generators_; google::protobuf::scoped_array > extension_generators_; int num_required_fields_; - bool uses_string_; bool use_dependent_base_; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; -- cgit v1.2.3