Loading system/gd/packet/parser/fields/vector_field.cc +1 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,7 @@ void VectorField::GenExtractor(std::ostream& s, int num_leading_bits, bool for_s } } s << "while ("; s << "while ("; if (size_field_ != nullptr && size_field_->GetFieldType() == CountField::kFieldType) { if (size_field_ != nullptr && size_field_->GetFieldType() == CountField::kFieldType) { s << "(" << element_field_->GetName() << "_count > 0) && "; s << "(" << element_field_->GetName() << "_count-- > 0) && "; s << "(" << element_field_->GetName() << "_count-- > 0) && "; } } if (!element_size_.empty()) { if (!element_size_.empty()) { Loading system/gd/packet/parser/test/test_packets.pdl +20 −0 Original line number Original line Diff line number Diff line Loading @@ -135,11 +135,24 @@ packet SizedArrayEnum { enum_array : ForArrays[], enum_array : ForArrays[], } } test SizedArrayEnum { "\x00\x00", "\x02\x00\x01\x02", "\x04\x00\x01\x02\x11\x12", "\x06\x00\x01\x02\x11\x12\x21\x22", } packet CountArrayEnum { packet CountArrayEnum { _count_(enum_array) : 8, _count_(enum_array) : 8, enum_array : ForArrays[], enum_array : ForArrays[], } } test CountArrayEnum { "\x01\x01\x02", "\x02\x01\x02\x11\x12", "\x03\x01\x02\x11\x12\x21\x22", } packet SizedArrayCustom { packet SizedArrayCustom { _size_(six_bytes_array) : 8, _size_(six_bytes_array) : 8, an_extra_byte : 8, an_extra_byte : 8, Loading Loading @@ -197,6 +210,13 @@ packet VectorOfStruct { array : TwoRelatedNumbers[], array : TwoRelatedNumbers[], } } test VectorOfStruct { "\x00", "\x01\x01\x02\x03", "\x02\x01\x02\x03\x11\x12\x13", "\x03\x01\x02\x03\x11\x12\x13\x21\x22\x23", } packet ArrayOfStruct { packet ArrayOfStruct { the_count : 8, the_count : 8, array : TwoRelatedNumbers[4], array : TwoRelatedNumbers[4], Loading Loading
system/gd/packet/parser/fields/vector_field.cc +1 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,7 @@ void VectorField::GenExtractor(std::ostream& s, int num_leading_bits, bool for_s } } s << "while ("; s << "while ("; if (size_field_ != nullptr && size_field_->GetFieldType() == CountField::kFieldType) { if (size_field_ != nullptr && size_field_->GetFieldType() == CountField::kFieldType) { s << "(" << element_field_->GetName() << "_count > 0) && "; s << "(" << element_field_->GetName() << "_count-- > 0) && "; s << "(" << element_field_->GetName() << "_count-- > 0) && "; } } if (!element_size_.empty()) { if (!element_size_.empty()) { Loading
system/gd/packet/parser/test/test_packets.pdl +20 −0 Original line number Original line Diff line number Diff line Loading @@ -135,11 +135,24 @@ packet SizedArrayEnum { enum_array : ForArrays[], enum_array : ForArrays[], } } test SizedArrayEnum { "\x00\x00", "\x02\x00\x01\x02", "\x04\x00\x01\x02\x11\x12", "\x06\x00\x01\x02\x11\x12\x21\x22", } packet CountArrayEnum { packet CountArrayEnum { _count_(enum_array) : 8, _count_(enum_array) : 8, enum_array : ForArrays[], enum_array : ForArrays[], } } test CountArrayEnum { "\x01\x01\x02", "\x02\x01\x02\x11\x12", "\x03\x01\x02\x11\x12\x21\x22", } packet SizedArrayCustom { packet SizedArrayCustom { _size_(six_bytes_array) : 8, _size_(six_bytes_array) : 8, an_extra_byte : 8, an_extra_byte : 8, Loading Loading @@ -197,6 +210,13 @@ packet VectorOfStruct { array : TwoRelatedNumbers[], array : TwoRelatedNumbers[], } } test VectorOfStruct { "\x00", "\x01\x01\x02\x03", "\x02\x01\x02\x03\x11\x12\x13", "\x03\x01\x02\x03\x11\x12\x13\x21\x22\x23", } packet ArrayOfStruct { packet ArrayOfStruct { the_count : 8, the_count : 8, array : TwoRelatedNumbers[4], array : TwoRelatedNumbers[4], Loading