Clear oneofs.

This commit is contained in:
Jisi Liu 2015-02-18 13:52:37 -08:00
parent f173cdeb02
commit 3accf81ea9

View File

@ -508,6 +508,14 @@ void MessageGenerator::GenerateClear(io::Printer* printer) {
field_generators_.get(field).GenerateClearCode(printer);
}
// Clear oneofs.
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
printer->Print(
"clear$oneof_capitalized_name$();\n",
"oneof_capitalized_name", UnderscoresToCapitalizedCamelCase(
descriptor_->oneof_decl(i)));
}
// Clear unknown fields.
if (params_.store_unknown_fields()) {
printer->Print("unknownFieldData = null;\n");