Incremental migration of message.cc to Emit

PiperOrigin-RevId: 530663959
pull/12724/head
Matt Kulukundis 2 years ago committed by Copybara-Service
parent b928629253
commit e75529d9a0
  1. 16
      src/google/protobuf/compiler/cpp/message.cc
  2. 8
      src/google/protobuf/compiler/plugin.pb.cc
  3. 56
      src/google/protobuf/descriptor.pb.cc

@ -1878,9 +1878,6 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* p) {
void MessageGenerator::GenerateSchema(io::Printer* p, int offset, void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
int has_offset) { int has_offset) {
auto v = p->WithVars(ClassVars(descriptor_, options_));
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
Formatter format(p);
has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_) has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)
? offset + has_offset ? offset + has_offset
: -1; : -1;
@ -1892,8 +1889,17 @@ void MessageGenerator::GenerateSchema(io::Printer* p, int offset,
ABSL_DCHECK(!IsMapEntryMessage(descriptor_)); ABSL_DCHECK(!IsMapEntryMessage(descriptor_));
inlined_string_indices_offset = has_offset + has_bit_indices_.size(); inlined_string_indices_offset = has_offset + has_bit_indices_.size();
} }
format("{ $1$, $2$, $3$, sizeof($classtype$)},\n", offset, has_offset,
inlined_string_indices_offset); auto v = p->WithVars(ClassVars(descriptor_, options_));
p->Emit(
{
{"offset", offset},
{"has_offset", has_offset},
{"string_offsets", inlined_string_indices_offset},
},
R"cc(
{$offset$, $has_offset$, $string_offsets$, sizeof($classtype$)},
)cc");
} }
void MessageGenerator::GenerateClassMethods(io::Printer* p) { void MessageGenerator::GenerateClassMethods(io::Printer* p) {

@ -189,10 +189,10 @@ const ::uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offs
static const ::_pbi::MigrationSchema static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, 12, -1, sizeof(::google::protobuf::compiler::Version)}, {0, 12, -1, sizeof(::google::protobuf::compiler::Version)},
{ 16, 28, -1, sizeof(::google::protobuf::compiler::CodeGeneratorRequest)}, {16, 28, -1, sizeof(::google::protobuf::compiler::CodeGeneratorRequest)},
{ 32, 44, -1, sizeof(::google::protobuf::compiler::CodeGeneratorResponse_File)}, {32, 44, -1, sizeof(::google::protobuf::compiler::CodeGeneratorResponse_File)},
{ 48, 59, -1, sizeof(::google::protobuf::compiler::CodeGeneratorResponse)}, {48, 59, -1, sizeof(::google::protobuf::compiler::CodeGeneratorResponse)},
}; };
static const ::_pb::Message* const file_default_instances[] = { static const ::_pb::Message* const file_default_instances[] = {

@ -1390,34 +1390,34 @@ const ::uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] P
static const ::_pbi::MigrationSchema static const ::_pbi::MigrationSchema
schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, -1, sizeof(::google::protobuf::FileDescriptorSet)}, {0, -1, -1, sizeof(::google::protobuf::FileDescriptorSet)},
{ 9, 30, -1, sizeof(::google::protobuf::FileDescriptorProto)}, {9, 30, -1, sizeof(::google::protobuf::FileDescriptorProto)},
{ 43, 54, -1, sizeof(::google::protobuf::DescriptorProto_ExtensionRange)}, {43, 54, -1, sizeof(::google::protobuf::DescriptorProto_ExtensionRange)},
{ 57, 67, -1, sizeof(::google::protobuf::DescriptorProto_ReservedRange)}, {57, 67, -1, sizeof(::google::protobuf::DescriptorProto_ReservedRange)},
{ 69, 87, -1, sizeof(::google::protobuf::DescriptorProto)}, {69, 87, -1, sizeof(::google::protobuf::DescriptorProto)},
{ 97, 111, -1, sizeof(::google::protobuf::ExtensionRangeOptions_Declaration)}, {97, 111, -1, sizeof(::google::protobuf::ExtensionRangeOptions_Declaration)},
{ 117, 128, -1, sizeof(::google::protobuf::ExtensionRangeOptions)}, {117, 128, -1, sizeof(::google::protobuf::ExtensionRangeOptions)},
{ 131, 150, -1, sizeof(::google::protobuf::FieldDescriptorProto)}, {131, 150, -1, sizeof(::google::protobuf::FieldDescriptorProto)},
{ 161, 171, -1, sizeof(::google::protobuf::OneofDescriptorProto)}, {161, 171, -1, sizeof(::google::protobuf::OneofDescriptorProto)},
{ 173, 183, -1, sizeof(::google::protobuf::EnumDescriptorProto_EnumReservedRange)}, {173, 183, -1, sizeof(::google::protobuf::EnumDescriptorProto_EnumReservedRange)},
{ 185, 198, -1, sizeof(::google::protobuf::EnumDescriptorProto)}, {185, 198, -1, sizeof(::google::protobuf::EnumDescriptorProto)},
{ 203, 214, -1, sizeof(::google::protobuf::EnumValueDescriptorProto)}, {203, 214, -1, sizeof(::google::protobuf::EnumValueDescriptorProto)},
{ 217, 228, -1, sizeof(::google::protobuf::ServiceDescriptorProto)}, {217, 228, -1, sizeof(::google::protobuf::ServiceDescriptorProto)},
{ 231, 245, -1, sizeof(::google::protobuf::MethodDescriptorProto)}, {231, 245, -1, sizeof(::google::protobuf::MethodDescriptorProto)},
{ 251, 280, -1, sizeof(::google::protobuf::FileOptions)}, {251, 280, -1, sizeof(::google::protobuf::FileOptions)},
{ 301, 315, -1, sizeof(::google::protobuf::MessageOptions)}, {301, 315, -1, sizeof(::google::protobuf::MessageOptions)},
{ 321, 341, -1, sizeof(::google::protobuf::FieldOptions)}, {321, 341, -1, sizeof(::google::protobuf::FieldOptions)},
{ 353, -1, -1, sizeof(::google::protobuf::OneofOptions)}, {353, -1, -1, sizeof(::google::protobuf::OneofOptions)},
{ 362, 374, -1, sizeof(::google::protobuf::EnumOptions)}, {362, 374, -1, sizeof(::google::protobuf::EnumOptions)},
{ 378, 388, -1, sizeof(::google::protobuf::EnumValueOptions)}, {378, 388, -1, sizeof(::google::protobuf::EnumValueOptions)},
{ 390, 400, -1, sizeof(::google::protobuf::ServiceOptions)}, {390, 400, -1, sizeof(::google::protobuf::ServiceOptions)},
{ 402, 413, -1, sizeof(::google::protobuf::MethodOptions)}, {402, 413, -1, sizeof(::google::protobuf::MethodOptions)},
{ 416, 426, -1, sizeof(::google::protobuf::UninterpretedOption_NamePart)}, {416, 426, -1, sizeof(::google::protobuf::UninterpretedOption_NamePart)},
{ 428, 443, -1, sizeof(::google::protobuf::UninterpretedOption)}, {428, 443, -1, sizeof(::google::protobuf::UninterpretedOption)},
{ 450, 463, -1, sizeof(::google::protobuf::SourceCodeInfo_Location)}, {450, 463, -1, sizeof(::google::protobuf::SourceCodeInfo_Location)},
{ 468, -1, -1, sizeof(::google::protobuf::SourceCodeInfo)}, {468, -1, -1, sizeof(::google::protobuf::SourceCodeInfo)},
{ 477, 490, -1, sizeof(::google::protobuf::GeneratedCodeInfo_Annotation)}, {477, 490, -1, sizeof(::google::protobuf::GeneratedCodeInfo_Annotation)},
{ 495, -1, -1, sizeof(::google::protobuf::GeneratedCodeInfo)}, {495, -1, -1, sizeof(::google::protobuf::GeneratedCodeInfo)},
}; };
static const ::_pb::Message* const file_default_instances[] = { static const ::_pb::Message* const file_default_instances[] = {

Loading…
Cancel
Save