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

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

rusty-packets: rename packets & add packet child enums

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost SimpleHalTest
Change-Id: Ib8d0227e6d51d4bebbe28ddf61e957c943824185
parent f7cbf549
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -47,7 +47,7 @@ class Declarations {
    return it->second;
    return it->second;
  }
  }


  void AddPacketDef(std::string name, PacketDef def) {
  void AddPacketDef(std::string name, PacketDef* def) {
    auto it = packet_defs_.find(name);
    auto it = packet_defs_.find(name);
    if (it != packet_defs_.end()) {
    if (it != packet_defs_.end()) {
      ERROR() << "Redefinition of Packet " << name;
      ERROR() << "Redefinition of Packet " << name;
@@ -62,7 +62,7 @@ class Declarations {
      return nullptr;
      return nullptr;
    }
    }


    return &(it->second);
    return it->second;
  }
  }


  void AddGroupDef(std::string name, FieldList* group_def) {
  void AddGroupDef(std::string name, FieldList* group_def) {
@@ -85,7 +85,7 @@ class Declarations {


  std::map<std::string, TypeDef*> type_defs_;
  std::map<std::string, TypeDef*> type_defs_;
  std::deque<std::pair<std::string, TypeDef*>> type_defs_queue_;
  std::deque<std::pair<std::string, TypeDef*>> type_defs_queue_;
  std::map<std::string, PacketDef> packet_defs_;
  std::map<std::string, PacketDef*> packet_defs_;
  std::deque<std::pair<std::string, PacketDef>> packet_defs_queue_;
  std::deque<std::pair<std::string, PacketDef*>> packet_defs_queue_;
  bool is_little_endian;
  bool is_little_endian;
};
};
+4 −4
Original line number Original line Diff line number Diff line
@@ -197,12 +197,12 @@ using ::bluetooth::packet::parser::ChecksumTypeChecker;
  }
  }


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


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


@@ -331,14 +331,14 @@ bool generate_pybind11_sources_one_file(


  for (const auto& packet_def : decls.packet_defs_queue_) {
  for (const auto& packet_def : decls.packet_defs_queue_) {
    auto& out_file = get_out_file(symbol_count, symbol_total, &out_file_shards);
    auto& out_file = get_out_file(symbol_count, symbol_total, &out_file_shards);
    packet_def.second.GenParserDefinitionPybind11(out_file);
    packet_def.second->GenParserDefinitionPybind11(out_file);
    out_file << "\n\n";
    out_file << "\n\n";
    symbol_count++;
    symbol_count++;
  }
  }


  for (const auto& p : decls.packet_defs_queue_) {
  for (const auto& p : decls.packet_defs_queue_) {
    auto& out_file = get_out_file(symbol_count, symbol_total, &out_file_shards);
    auto& out_file = get_out_file(symbol_count, symbol_total, &out_file_shards);
    p.second.GenBuilderDefinitionPybind11(out_file);
    p.second->GenBuilderDefinitionPybind11(out_file);
    out_file << "\n\n";
    out_file << "\n\n";
    symbol_count++;
    symbol_count++;
  }
  }
+1 −1
Original line number Original line Diff line number Diff line
@@ -63,7 +63,7 @@ bool generate_rust_source_one_file(
  }
  }


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


+2 −2
Original line number Original line Diff line number Diff line
@@ -122,8 +122,7 @@ declaration
  | packet_definition
  | packet_definition
    {
    {
      DEBUG() << "FOUND PACKET\n\n";
      DEBUG() << "FOUND PACKET\n\n";
      decls->AddPacketDef($1->name_, std::move(*$1));
      decls->AddPacketDef($1->name_, $1);
      delete $1;
    }
    }
  | struct_definition
  | struct_definition
    {
    {
@@ -318,6 +317,7 @@ packet_definition
                  << " used as parent for " << packet_name;
                  << " used as parent for " << packet_name;
      }
      }



      auto packet_definition = new PacketDef(std::move(packet_name), std::move(field_definition_list), parent_packet);
      auto packet_definition = new PacketDef(std::move(packet_name), std::move(field_definition_list), parent_packet);
      packet_definition->AssignSizeFields();
      packet_definition->AssignSizeFields();


+4 −1
Original line number Original line Diff line number Diff line
@@ -88,7 +88,10 @@ bool parse_declarations_one_file(const std::filesystem::path& input_file, Declar
  }
  }


  for (auto& packet_def : declarations->packet_defs_queue_) {
  for (auto& packet_def : declarations->packet_defs_queue_) {
    packet_def.second.SetEndianness(declarations->is_little_endian);
    packet_def.second->SetEndianness(declarations->is_little_endian);
    if (packet_def.second->parent_ != nullptr) {
      packet_def.second->parent_->children_.push_back(packet_def.second);
    }
  }
  }


  return true;
  return true;
Loading