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

Commit 210d9ebf authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge changes I389b26d7,I0a668115,I75ef0b5c

* changes:
  Alias iterator in packet-gen
  Use generic type for JsonParser
  Change dynamic_cast to static_cast
parents ded5762c 9132f167
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ void ArrayField::GenExtractor(std::ostream& s, int num_leading_bits, bool for_st
  if (element_field_->BuilderParameterMustBeMoved()) {
    s << element_field_->GetDataType() << " " << element_field_->GetName() << "_ptr;";
  } else {
    s << element_field_->GetDataType() << "* " << element_field_->GetName() << "_ptr = ret_it;";
    s << "auto " << element_field_->GetName() << "_ptr = ret_it;";
  }
  element_field_->GenExtractor(s, num_leading_bits, for_struct);
  if (element_field_->BuilderParameterMustBeMoved()) {
+10 −10
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ using ::bluetooth::packet::parser::ChecksumTypeChecker;

  for (const auto& e : decls.type_defs_queue_) {
    if (e.second->GetDefinitionType() == TypeDef::Type::ENUM) {
      const auto* enum_def = dynamic_cast<const EnumDef*>(e.second);
      const auto* enum_def = static_cast<const EnumDef*>(e.second);
      EnumGen gen(*enum_def);
      gen.GenDefinition(out_file);
      out_file << "\n\n";
@@ -155,7 +155,7 @@ using ::bluetooth::packet::parser::ChecksumTypeChecker;
  }
  for (const auto& e : decls.type_defs_queue_) {
    if (e.second->GetDefinitionType() == TypeDef::Type::ENUM) {
      const auto* enum_def = dynamic_cast<const EnumDef*>(e.second);
      const auto* enum_def = static_cast<const EnumDef*>(e.second);
      EnumGen gen(*enum_def);
      gen.GenLogging(out_file);
      out_file << "\n\n";
@@ -163,7 +163,7 @@ using ::bluetooth::packet::parser::ChecksumTypeChecker;
  }
  for (const auto& ch : decls.type_defs_queue_) {
    if (ch.second->GetDefinitionType() == TypeDef::Type::CHECKSUM) {
      const auto* checksum_def = dynamic_cast<const ChecksumDef*>(ch.second);
      const auto* checksum_def = static_cast<const ChecksumDef*>(ch.second);
      checksum_def->GenChecksumCheck(out_file);
    }
  }
@@ -172,10 +172,10 @@ using ::bluetooth::packet::parser::ChecksumTypeChecker;
  for (const auto& c : decls.type_defs_queue_) {
    if (c.second->GetDefinitionType() == TypeDef::Type::CUSTOM) {
      if (c.second->size_ == -1 /* Variable Size */) {
        const auto* custom_field_def = dynamic_cast<const CustomFieldDef*>(c.second);
        const auto* custom_field_def = static_cast<const CustomFieldDef*>(c.second);
        custom_field_def->GenCustomFieldCheck(out_file, decls.is_little_endian);
      } else {  // fixed size
        const auto* custom_field_def = dynamic_cast<const CustomFieldDef*>(c.second);
        const auto* custom_field_def = static_cast<const CustomFieldDef*>(c.second);
        custom_field_def->GenFixedSizeCustomFieldCheck(out_file);
      }
    }
@@ -184,7 +184,7 @@ using ::bluetooth::packet::parser::ChecksumTypeChecker;

  for (auto& s : decls.type_defs_queue_) {
    if (s.second->GetDefinitionType() == TypeDef::Type::STRUCT) {
      const auto* struct_def = dynamic_cast<const StructDef*>(s.second);
      const auto* struct_def = static_cast<const StructDef*>(s.second);
      struct_def->GenDefinition(out_file);
      out_file << "\n";
    }
@@ -293,7 +293,7 @@ bool generate_pybind11_sources_one_file(

    for (const auto& c : decls.type_defs_queue_) {
      if (c.second->GetDefinitionType() == TypeDef::Type::CUSTOM) {
        const auto* custom_def = dynamic_cast<const CustomFieldDef*>(c.second);
        const auto* custom_def = static_cast<const CustomFieldDef*>(c.second);
        custom_def->GenPyBind11Include(out_file);
      }
    }
@@ -306,7 +306,7 @@ bool generate_pybind11_sources_one_file(
    for (const auto& c : decls.type_defs_queue_) {
      if (c.second->GetDefinitionType() == TypeDef::Type::CUSTOM ||
          c.second->GetDefinitionType() == TypeDef::Type::CHECKSUM) {
        const auto* custom_def = dynamic_cast<const CustomFieldDef*>(c.second);
        const auto* custom_def = static_cast<const CustomFieldDef*>(c.second);
        custom_def->GenUsing(out_file);
      }
    }
@@ -344,7 +344,7 @@ bool generate_pybind11_sources_one_file(

  for (const auto& e : decls.type_defs_queue_) {
    if (e.second->GetDefinitionType() == TypeDef::Type::ENUM) {
      const auto* enum_def = dynamic_cast<const EnumDef*>(e.second);
      const auto* enum_def = static_cast<const EnumDef*>(e.second);
      EnumGen gen(*enum_def);
      auto& out_file = get_out_file(symbol_count, symbol_total, &out_file_shards);
      gen.GenDefinitionPybind11(out_file);
@@ -355,7 +355,7 @@ bool generate_pybind11_sources_one_file(

  for (const auto& s : decls.type_defs_queue_) {
    if (s.second->GetDefinitionType() == TypeDef::Type::STRUCT) {
      const auto* struct_def = dynamic_cast<const StructDef*>(s.second);
      const auto* struct_def = static_cast<const StructDef*>(s.second);
      auto& out_file = get_out_file(symbol_count, symbol_total, &out_file_shards);
      struct_def->GenDefinitionPybind11(out_file);
      out_file << "\n";
+3 −3
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ bool generate_rust_source_one_file(
    EnumDef* opcode_index = nullptr;
    for (const auto& e : decls.type_defs_queue_) {
      if (e.second->GetDefinitionType() == TypeDef::Type::ENUM) {
        auto* enum_def = dynamic_cast<EnumDef*>(e.second);
        auto* enum_def = static_cast<EnumDef*>(e.second);
        if (enum_def->name_ == "OpCode") {
          opcode = enum_def;
        } else if (enum_def->name_ == "OpCodeIndex") {
@@ -143,7 +143,7 @@ bool generate_rust_source_one_file(

  for (const auto& e : decls.type_defs_queue_) {
    if (e.second->GetDefinitionType() == TypeDef::Type::ENUM) {
      const auto* enum_def = dynamic_cast<const EnumDef*>(e.second);
      const auto* enum_def = static_cast<const EnumDef*>(e.second);
      EnumGen gen(*enum_def);
      gen.GenRustDef(out_file);
      out_file << "\n\n";
@@ -152,7 +152,7 @@ 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);
      const auto* struct_def = static_cast<const StructDef*>(s.second);
      struct_def->GenRustDef(out_file);
      out_file << "\n\n";
    }
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ bool parse_declarations_one_file(const std::filesystem::path& input_file, Declar
  // Set endianess before returning
  for (auto& s : declarations->type_defs_queue_) {
    if (s.second->GetDefinitionType() == TypeDef::Type::STRUCT) {
      auto* struct_def = dynamic_cast<StructDef*>(s.second);
      auto* struct_def = static_cast<StructDef*>(s.second);
      struct_def->SetEndianness(declarations->is_little_endian);
    }
  }
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ StructParserGenerator::StructParserGenerator(const Declarations& decls) {
  is_little_endian = decls.is_little_endian;
  for (const auto& s : decls.type_defs_queue_) {
    if (s.second->GetDefinitionType() == TypeDef::Type::STRUCT) {
      const auto* struct_def = dynamic_cast<const StructDef*>(s.second);
      const auto* struct_def = static_cast<const StructDef*>(s.second);
      variable_struct_fields_.emplace_back(struct_def);
    }
  }
Loading