Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8cf69e75 authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "PDL: Exit early when parsing counted vectors" into main

parents 1a01f525 123801b1
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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()) {
+20 −0
Original line number Original line Diff line number Diff line
@@ -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,
@@ -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],