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

Commit ad2baba3 authored by Zach Johnson's avatar Zach Johnson Committed by Automerger Merge Worker
Browse files

Merge "rusty-gd: Fix offsets for scalar fields." am: 48c2f68e am: 35ba87d7

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1526341

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ibb8887208a6c20f81c34bb4c35a8c6692ead746f
parents c4fa4de1 35ba87d7
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -156,13 +156,16 @@ int ScalarField::GetRustBitOffset(

void ScalarField::GenRustGetter(std::ostream& s, Size start_offset, Size end_offset) const {
  Size size = GetSize();

  int num_leading_bits = GetRustBitOffset(s, start_offset, end_offset, GetSize());

  s << "let " << GetName() << " = ";
  if (num_leading_bits == 0) {
    s << GetRustDataType() << "::from_le_bytes(bytes[" << start_offset.bytes() << "..";
  s << start_offset.bytes() + GetSize().bytes() << "].try_into().unwrap());";

  if (num_leading_bits != 0) {
    s << start_offset.bytes() + size.bytes() << "].try_into().unwrap());";
  } else {
    s << GetRustDataType() << "::from_le_bytes(bytes[" << start_offset.bytes() - 1 << "..";
    s << start_offset.bytes() + size.bytes() - 1 << "].try_into().unwrap());";
    s << "let " << GetName() << " = " << GetName() << " >> " << num_leading_bits << ";";
  }