From e4ea6c5eeec1ddcb40d674f03dac27fa40bda72b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 10 Jul 2025 15:42:48 -1000 Subject: [PATCH] preen --- esphome/components/api/proto.cpp | 9 ----- esphome/components/api/proto_templates.h | 43 +----------------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/esphome/components/api/proto.cpp b/esphome/components/api/proto.cpp index 5535813487..52214ac405 100644 --- a/esphome/components/api/proto.cpp +++ b/esphome/components/api/proto.cpp @@ -374,16 +374,7 @@ static bool decode_length_field(ProtoFieldType type, void *field_addr, const Pro } } -// ============================================================================ -// ProtoMessage Implementation - Simplified with Unified Helpers -// ============================================================================ - void ProtoMessage::decode(const uint8_t *buffer, size_t length) { - if (buffer == nullptr && length > 0) { - ESP_LOGW(TAG, "decode called with nullptr buffer but length=%zu", length); - return; - } - uint8_t *base = reinterpret_cast(this); // Get metadata diff --git a/esphome/components/api/proto_templates.h b/esphome/components/api/proto_templates.h index 7453dd89de..96f37a5654 100644 --- a/esphome/components/api/proto_templates.h +++ b/esphome/components/api/proto_templates.h @@ -6,25 +6,6 @@ namespace esphome { namespace api { -// Template enum field functions (must be in header for instantiation) -template -inline void encode_enum_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) { - const auto *val = static_cast(field_ptr); - buffer.encode_enum(field_num, *val); -} - -template -inline void size_enum_field(uint32_t &total_size, const void *field_ptr, uint8_t precalced_field_id_size, bool force) { - const auto *val = static_cast(field_ptr); - ProtoSize::add_enum_field(total_size, precalced_field_id_size, static_cast(*val), force); -} - -template inline bool decode_enum_field(void *field_ptr, ProtoVarInt value) { - auto *val = static_cast(field_ptr); - *val = value.as_enum(); - return true; -} - // Template functions for message field handling (regular fields) template inline void encode_message_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) { @@ -46,14 +27,6 @@ template inline bool decode_message_field(void *field_ptr, } // Template repeated field functions (must be in header for instantiation) -template -inline void encode_repeated_enum_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) { - const auto *vec = static_cast *>(field_ptr); - for (const auto &val : *vec) { - buffer.encode_enum(field_num, val, true); - } -} - template inline void encode_repeated_message_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) { const auto *vec = static_cast *>(field_ptr); @@ -63,14 +36,6 @@ inline void encode_repeated_message_field(ProtoWriteBuffer &buffer, const void * } // Template size functions for repeated fields (must be in header for instantiation) -template -inline void size_repeated_enum_field(uint32_t &total_size, const void *field_ptr, uint8_t precalced_field_id_size) { - const auto *vec = static_cast *>(field_ptr); - for (const auto &val : *vec) { - ProtoSize::add_enum_field(total_size, precalced_field_id_size, static_cast(val), true); - } -} - template inline void size_repeated_message_field(uint32_t &total_size, const void *field_ptr, uint8_t precalced_field_id_size) { const auto *vec = static_cast *>(field_ptr); @@ -78,12 +43,6 @@ inline void size_repeated_message_field(uint32_t &total_size, const void *field_ } // Template decode functions for repeated fields -template inline bool decode_repeated_enum_field(void *field_ptr, ProtoVarInt value) { - auto *vec = static_cast *>(field_ptr); - vec->push_back(value.as_enum()); - return true; -} - template inline bool decode_repeated_message_field(void *field_ptr, ProtoLengthDelimited value) { auto *vec = static_cast *>(field_ptr); vec->push_back(value.as_message()); @@ -91,4 +50,4 @@ template inline bool decode_repeated_message_field(void *f } } // namespace api -} // namespace esphome \ No newline at end of file +} // namespace esphome