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

Commit f7cbf549 authored by Zach Johnson's avatar Zach Johnson
Browse files

rusty-packets: stub out struct & packet generation

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost SimpleHalTest
Change-Id: I2bcd02ea82f0e128e3125d93cacc4c2950ac1330
parent 0131ce5d
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -54,6 +54,19 @@ bool generate_rust_source_one_file(
    }
  }

  for (auto& s : decls.type_defs_queue_) {
    if (s.second->GetDefinitionType() == TypeDef::Type::STRUCT) {
      const auto* struct_def = dynamic_cast<const StructDef*>(s.second);
      struct_def->GenRustDef(out_file);
      out_file << "\n\n";
    }
  }

  for (const auto& packet_def : decls.packet_defs_queue_) {
    packet_def.second.GenRustDef(out_file);
    out_file << "\n\n";
  }

  out_file.close();
  return true;
}
+4 −0
Original line number Diff line number Diff line
@@ -739,3 +739,7 @@ void PacketDef::GenBuilderConstructor(std::ostream& s) const {

  s << "}\n";
}

void PacketDef::GenRustDef(std::ostream& s) const {
  s << "pub struct " << name_ << " {}";
}
+2 −0
Original line number Diff line number Diff line
@@ -64,4 +64,6 @@ class PacketDef : public ParentDef {
  void GenBuilderConstructor(std::ostream& s) const;

  void GenTestingFromView(std::ostream& s) const;

  void GenRustDef(std::ostream& s) const;
};
+4 −0
Original line number Diff line number Diff line
@@ -310,3 +310,7 @@ Size StructDef::GetStructOffsetForField(std::string field_name) const {

  return size;
}

void StructDef::GenRustDef(std::ostream& s) const {
  s << "pub struct " << name_ << " {}";
}
+2 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ class StructDef : public ParentDef {

  Size GetStructOffsetForField(std::string field_name) const;

  void GenRustDef(std::ostream& s) const;

 private:
  Size total_size_;
};