diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-01-29 08:26:00 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-29 08:26:00 -0800 |
commit | 2b62fbce6734eb672ae6ff6fcf258bfff4267ae8 (patch) | |
tree | c39dd54ef29a0b6610ebd4794b1646c83c66357a /upbc/message_layout.cc | |
parent | c7870e0f77d6331babfdb89f8c83e4e0279b5e70 (diff) | |
parent | 3d931557907307ecc19b74e8f3188301b149e99a (diff) |
Merge pull request #145 from haberman/arrayapi
Generated code API changes for array and hazzers.
Diffstat (limited to 'upbc/message_layout.cc')
-rw-r--r-- | upbc/message_layout.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/upbc/message_layout.cc b/upbc/message_layout.cc index b6614f0..5956424 100644 --- a/upbc/message_layout.cc +++ b/upbc/message_layout.cc @@ -30,16 +30,20 @@ bool MessageLayout::HasHasbit(const protobuf::FieldDescriptor* field) { MessageLayout::SizeAndAlign MessageLayout::SizeOf( const protobuf::FieldDescriptor* field) { - if (field->label() == protobuf::FieldDescriptor::LABEL_REPEATED || - field->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { - return {{4, 8}, {4, 8}}; + if (field->is_repeated()) { + return {{4, 8}, {4, 8}}; // Pointer to array object. + } else { + return SizeOfUnwrapped(field); } +} +MessageLayout::SizeAndAlign MessageLayout::SizeOfUnwrapped( + const protobuf::FieldDescriptor* field) { switch (field->cpp_type()) { + case protobuf::FieldDescriptor::CPPTYPE_MESSAGE: + return {{4, 8}, {4, 8}}; // Pointer to message. case protobuf::FieldDescriptor::CPPTYPE_STRING: - // upb_stringview - // return {{8, 16}, {4, 8}}; - return {{8, 16}, {8, 16}}; + return {{8, 16}, {4, 8}}; // upb_stringview case protobuf::FieldDescriptor::CPPTYPE_BOOL: return {{1, 1}, {1, 1}}; case protobuf::FieldDescriptor::CPPTYPE_FLOAT: |