Commit eb26a1ef authored by kenton@google.com's avatar kenton@google.com

Commit Michael Poole's patch for explicitly constructing all class fields in

generated code.
parent e59427a6
......@@ -22,6 +22,8 @@
* GzipInputStream and GzipOutputStream support reading/writing gzip- or
zlib-compressed streams if zlib is available.
(google/protobuf/io/gzip_stream.h)
* Generated constructors explicitly initialize all fields (to avoid warnings
with certain compiler settings).
Java
* Fixed bug where Message.mergeFrom(Message) failed to merge extensions.
......
......@@ -59,3 +59,6 @@ Patch contributors:
* MS Visual Studio error format option.
Brian Olson <brianolson@google.com>
* gzip/zlib I/O support.
Michael Poole <mdpoole@troilus.org>
* Fixed warnings about generated constructors not explicitly initializing
all fields (only present with certain compiler settings).
......@@ -218,7 +218,11 @@ GenerateSwappingCode(io::Printer* printer) const {
void RepeatedEnumFieldGenerator::
GenerateInitializer(io::Printer* printer) const {
// Not needed for repeated fields.
printer->Print(variables_, ",\n$name$_()");
if (descriptor_->options().packed() &&
descriptor_->file()->options().optimize_for() == FileOptions::SPEED) {
printer->Print(variables_, ",\n_$name$_cached_byte_size_()");
}
}
void RepeatedEnumFieldGenerator::
......
......@@ -753,6 +753,7 @@ GenerateInitializerList(io::Printer* printer) {
}
printer->Print(
"_unknown_fields_(),\n"
"_cached_size_(0)");
// Write the initializers for each field.
......
......@@ -213,7 +213,7 @@ GenerateSwappingCode(io::Printer* printer) const {
void RepeatedMessageFieldGenerator::
GenerateInitializer(io::Printer* printer) const {
// Not needed for repeated fields.
printer->Print(variables_, ",\n$name$_()");
}
void RepeatedMessageFieldGenerator::
......
......@@ -283,7 +283,11 @@ GenerateSwappingCode(io::Printer* printer) const {
void RepeatedPrimitiveFieldGenerator::
GenerateInitializer(io::Printer* printer) const {
// Not needed for repeated fields.
printer->Print(variables_, ",\n$name$_()");
if (descriptor_->options().packed() &&
descriptor_->file()->options().optimize_for() == FileOptions::SPEED) {
printer->Print(variables_, ",\n_$name$_cached_byte_size_()");
}
}
void RepeatedPrimitiveFieldGenerator::
......
......@@ -361,7 +361,7 @@ GenerateSwappingCode(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateInitializer(io::Printer* printer) const {
// Not needed for repeated fields.
printer->Print(variables_, ",\n$name$_()");
}
void RepeatedStringFieldGenerator::
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment