aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
diff options
context:
space:
mode:
authorGravatar Jon Skeet <skeet@pobox.com>2015-06-12 09:53:12 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2015-06-12 09:53:12 +0100
commit96ddf01aed1a49d73a7fda50e28c431ffc977e5a (patch)
tree4f603245ff514486481f126ca8d81deeff572534 /src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
parent39aaf21d5194fdc07c296847def8e7795279e041 (diff)
Coded*Stream streamlining.
Remove ICodedInputStream and ICodedOutputStream, and rewrite CodedInputStream and CodedOutputStream to be specific to the binary format. If we want to support text-based formats, that can be a whole different serialization mechanism.
Diffstat (limited to 'src/google/protobuf/compiler/csharp/csharp_primitive_field.cc')
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_primitive_field.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
index f2b66a00..cb7e1b5a 100644
--- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
@@ -73,7 +73,6 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {
printer->Print(
variables_,
" set { $name$_ = value; }\n");
-
} else {
printer->Print(
variables_,
@@ -93,14 +92,14 @@ void PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) {
void PrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) {
printer->Print(
variables_,
- "input.Read$capitalized_type_name$(ref $name$_);\n");
+ "$name$_ = input.Read$capitalized_type_name$();\n");
}
void PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) {
printer->Print(
variables_,
"if ($has_property_check$) {\n"
- " output.Write$capitalized_type_name$($number$, fieldNames[$field_ordinal$], $property_name$);\n"
+ " output.Write$capitalized_type_name$($number$, $property_name$);\n"
"}\n");
}
@@ -169,13 +168,10 @@ void PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) {
void PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {
// TODO(jonskeet): What if the value we read is the default value for the type?
- printer->Print(
- variables_,
- "$type_name$ value = $default_value$;\n"
- "if (input.Read$capitalized_type_name$(ref value)) {\n"
- " $oneof_name$_ = value;\n"
- " $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "$oneof_name$_ = input.Read$capitalized_type_name$()\n;"
+ "$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\n");
}
} // namespace csharp