mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 21:04:23 +08:00
protoc-c/c_field.cc: Fix proto3 field packing #330
Fixes #330 and makes scalar repeated fields packed by default in proto3. https://developers.google.com/protocol-buffers/docs/encoding#packed: In proto3, repeated fields of scalar numeric types are packed by default.
This commit is contained in:
parent
6aa7dc7a10
commit
69c39824cf
@ -140,8 +140,14 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
|
||||
|
||||
if (descriptor_->label() == FieldDescriptor::LABEL_REPEATED
|
||||
&& is_packable_type (descriptor_->type())
|
||||
&& descriptor_->options().packed())
|
||||
&& descriptor_->options().packed()) {
|
||||
variables["flags"] += " | PROTOBUF_C_FIELD_FLAG_PACKED";
|
||||
} else if (descriptor_->label() == FieldDescriptor::LABEL_REPEATED
|
||||
&& is_packable_type (descriptor_->type())
|
||||
&& FieldSyntax(descriptor_) == 3
|
||||
&& !descriptor_->options().has_packed()) {
|
||||
variables["flags"] += " | PROTOBUF_C_FIELD_FLAG_PACKED";
|
||||
}
|
||||
|
||||
if (descriptor_->options().deprecated())
|
||||
variables["flags"] += " | PROTOBUF_C_FIELD_FLAG_DEPRECATED";
|
||||
|
Loading…
x
Reference in New Issue
Block a user