codegen changes

pull/7351/head
Jan Tattermusch 5 years ago
parent 220e7be708
commit f6bdd7d479
  1. 2
      src/google/protobuf/compiler/csharp/csharp_map_field.cc
  2. 14
      src/google/protobuf/compiler/csharp/csharp_message.cc
  3. 2
      src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
  4. 2
      src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
  5. 2
      src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
  6. 4
      src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc

@ -96,7 +96,7 @@ void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) {
void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _map_$name$_codec);\n");
"$name$_.AddEntriesFrom(ref input, _map_$name$_codec);\n");
}
void MapFieldGenerator::GenerateSerializationCode(io::Printer* printer) {

@ -132,6 +132,7 @@ void MessageGenerator::Generate(io::Printer* printer) {
else {
printer->Print(vars, "pb::IMessage<$class_name$>");
}
printer->Print(", pb::IBufferMessage");
printer->Print(" {\n");
printer->Indent();
@ -634,6 +635,13 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
WriteGeneratedCodeAttributes(printer);
printer->Print("public void MergeFrom(pb::CodedInputStream input) {\n");
printer->Indent();
printer->Print("input.ReadRawMessage(this);\n");
printer->Outdent();
printer->Print("}\n\n");
WriteGeneratedCodeAttributes(printer);
printer->Print("public void MergeFrom_Internal(ref pb::ParseContext input) {\n");
printer->Indent();
printer->Print(
"uint tag;\n"
"while ((tag = input.ReadTag()) != 0) {\n"
@ -649,14 +657,14 @@ void MessageGenerator::GenerateMergingMethods(io::Printer* printer) {
if (has_extension_ranges_) {
printer->Print(
"default:\n"
" if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, input)) {\n"
" _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n"
" if (!pb::ExtensionSet.TryMergeFieldFrom(ref _extensions, ref input)) {\n"
" _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);\n"
" }\n"
" break;\n");
} else {
printer->Print(
"default:\n"
" _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);\n"
" _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);\n"
" break;\n");
}
for (int i = 0; i < fields_by_number().size(); i++) {

@ -80,7 +80,7 @@ void RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) {
void RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
"$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n");
}
void RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) {

@ -95,7 +95,7 @@ void RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) {
void RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
"$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n");
}
void RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) {

@ -80,7 +80,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer)
void RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\n");
"$name$_.AddEntriesFrom(ref input, _repeated_$name$_codec);\n");
}
void RepeatedPrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) {

@ -116,7 +116,7 @@ void WrapperFieldGenerator::GenerateMergingCode(io::Printer* printer) {
void WrapperFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$type_name$ value = _single_$name$_codec.Read(input);\n"
"$type_name$ value = _single_$name$_codec.Read(ref input);\n"
"if ($has_not_property_check$ || value != $default_value$) {\n"
" $property_name$ = value;\n"
"}\n");
@ -250,7 +250,7 @@ void WrapperOneofFieldGenerator::GenerateMergingCode(io::Printer* printer) {
void WrapperOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
"$property_name$ = _oneof_$name$_codec.Read(input);\n");
"$property_name$ = _oneof_$name$_codec.Read(ref input);\n");
}
void WrapperOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {

Loading…
Cancel
Save