aboutsummaryrefslogtreecommitdiff
path: root/contrib/protoc-bnet/google/protobuf/compiler
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-01-19 17:36:30 +0100
committerShauren <shauren.trinity@gmail.com>2017-01-19 17:36:30 +0100
commitcdbe140f91d62447c060744b5de58f4d010f93ce (patch)
treedc591b68786aa328699799fe86ff91c93fb11cdb /contrib/protoc-bnet/google/protobuf/compiler
parenteccbbe304ca277ec86dc16f3fe9b1c746748cba1 (diff)
Contrib: Fix protoc-bnet generator to initialize all fields in the constructor
Diffstat (limited to 'contrib/protoc-bnet/google/protobuf/compiler')
-rw-r--r--contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.cc4
-rw-r--r--contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.cc4
2 files changed, 6 insertions, 2 deletions
diff --git a/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.cc b/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 72f363bb378..ea15fd74744 100644
--- a/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -285,7 +285,9 @@ GenerateSwappingCode(io::Printer* printer) const {
void RepeatedEnumFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
- // Not needed for repeated fields.
+ if (descriptor_->options().packed()) {
+ printer->Print(variables_, "_$name$_cached_byte_size_ = 0;\n");
+ }
}
void RepeatedEnumFieldGenerator::
diff --git a/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index f9f13cee742..244a7f178d9 100644
--- a/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -335,7 +335,9 @@ GenerateSwappingCode(io::Printer* printer) const {
void RepeatedPrimitiveFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
- // Not needed for repeated fields.
+ if (descriptor_->options().packed()) {
+ printer->Print(variables_, "_$name$_cached_byte_size_ = 0;\n");
+ }
}
void RepeatedPrimitiveFieldGenerator::