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

Commit b931c50a authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes Ib8d0227e,I2bcd02ea

* changes:
  rusty-packets: rename packets & add packet child enums
  rusty-packets: stub out struct & packet generation
parents 9e87c2fd de782cd2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class Declarations {
    return it->second;
  }

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

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

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

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

  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";
  }

  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";
  }

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

  for (const auto& packet_def : decls.packet_defs_queue_) {
    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";
    symbol_count++;
  }

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


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

+4 −1
Original line number 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_) {
    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;
Loading