From daf2e6ecc8eb0af5b1245eac26aff3e7599876ce Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 3 Mar 2026 20:21:25 -1000 Subject: [PATCH] naming --- esphome/components/api/api_pb2.cpp | 1044 +++++++++++++-------------- esphome/components/api/proto.h | 60 +- script/api_protobuf/api_protobuf.py | 34 +- 3 files changed, 574 insertions(+), 564 deletions(-) diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index a138168ca1..d60ef1acd0 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -39,10 +39,10 @@ void HelloResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t HelloResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, this->api_version_major); - size += ProtoSize::uint32(1, this->api_version_minor); - size += ProtoSize::length(1, this->server_info.size()); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_uint32(1, this->api_version_major); + size += ProtoSize::calc_uint32(1, this->api_version_minor); + size += ProtoSize::calc_length(1, this->server_info.size()); + size += ProtoSize::calc_length(1, this->name.size()); return size; } #ifdef USE_AREAS @@ -52,8 +52,8 @@ void AreaInfo::encode(ProtoWriteBuffer &buffer) const { } uint32_t AreaInfo::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, this->area_id); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_uint32(1, this->area_id); + size += ProtoSize::calc_length(1, this->name.size()); return size; } #endif @@ -65,9 +65,9 @@ void DeviceInfo::encode(ProtoWriteBuffer &buffer) const { } uint32_t DeviceInfo::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, this->device_id); - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::uint32(1, this->area_id); + size += ProtoSize::calc_uint32(1, this->device_id); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_uint32(1, this->area_id); return size; } #endif @@ -128,58 +128,58 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t DeviceInfoResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::length(1, this->mac_address.size()); - size += ProtoSize::length(1, this->esphome_version.size()); - size += ProtoSize::length(1, this->compilation_time.size()); - size += ProtoSize::length(1, this->model.size()); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->mac_address.size()); + size += ProtoSize::calc_length(1, this->esphome_version.size()); + size += ProtoSize::calc_length(1, this->compilation_time.size()); + size += ProtoSize::calc_length(1, this->model.size()); #ifdef USE_DEEP_SLEEP - size += ProtoSize::bool_(1, this->has_deep_sleep); + size += ProtoSize::calc_bool_(1, this->has_deep_sleep); #endif #ifdef ESPHOME_PROJECT_NAME - size += ProtoSize::length(1, this->project_name.size()); + size += ProtoSize::calc_length(1, this->project_name.size()); #endif #ifdef ESPHOME_PROJECT_NAME - size += ProtoSize::length(1, this->project_version.size()); + size += ProtoSize::calc_length(1, this->project_version.size()); #endif #ifdef USE_WEBSERVER - size += ProtoSize::uint32(1, this->webserver_port); + size += ProtoSize::calc_uint32(1, this->webserver_port); #endif #ifdef USE_BLUETOOTH_PROXY - size += ProtoSize::uint32(1, this->bluetooth_proxy_feature_flags); + size += ProtoSize::calc_uint32(1, this->bluetooth_proxy_feature_flags); #endif - size += ProtoSize::length(1, this->manufacturer.size()); - size += ProtoSize::length(1, this->friendly_name.size()); + size += ProtoSize::calc_length(1, this->manufacturer.size()); + size += ProtoSize::calc_length(1, this->friendly_name.size()); #ifdef USE_VOICE_ASSISTANT - size += ProtoSize::uint32(2, this->voice_assistant_feature_flags); + size += ProtoSize::calc_uint32(2, this->voice_assistant_feature_flags); #endif #ifdef USE_AREAS - size += ProtoSize::length(2, this->suggested_area.size()); + size += ProtoSize::calc_length(2, this->suggested_area.size()); #endif #ifdef USE_BLUETOOTH_PROXY - size += ProtoSize::length(2, this->bluetooth_mac_address.size()); + size += ProtoSize::calc_length(2, this->bluetooth_mac_address.size()); #endif #ifdef USE_API_NOISE - size += ProtoSize::bool_(2, this->api_encryption_supported); + size += ProtoSize::calc_bool_(2, this->api_encryption_supported); #endif #ifdef USE_DEVICES for (const auto &it : this->devices) { - size += ProtoSize::message_force(2, it.calculate_size()); + size += ProtoSize::calc_message_force(2, it.calculate_size()); } #endif #ifdef USE_AREAS for (const auto &it : this->areas) { - size += ProtoSize::message_force(2, it.calculate_size()); + size += ProtoSize::calc_message_force(2, it.calculate_size()); } #endif #ifdef USE_AREAS - size += ProtoSize::message(2, this->area.calculate_size()); + size += ProtoSize::calc_message(2, this->area.calculate_size()); #endif #ifdef USE_ZWAVE_PROXY - size += ProtoSize::uint32(2, this->zwave_proxy_feature_flags); + size += ProtoSize::calc_uint32(2, this->zwave_proxy_feature_flags); #endif #ifdef USE_ZWAVE_PROXY - size += ProtoSize::uint32(2, this->zwave_home_id); + size += ProtoSize::calc_uint32(2, this->zwave_home_id); #endif return size; } @@ -201,18 +201,18 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesBinarySensorResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::length(1, this->device_class.size()); - size += ProtoSize::bool_(1, this->is_status_binary_sensor); - size += ProtoSize::bool_(1, this->disabled_by_default); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->is_status_binary_sensor); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -226,11 +226,11 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BinarySensorStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->state); - size += ProtoSize::bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->state); + size += ProtoSize::calc_bool_(1, this->missing_state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -256,21 +256,21 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesCoverResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::bool_(1, this->assumed_state); - size += ProtoSize::bool_(1, this->supports_position); - size += ProtoSize::bool_(1, this->supports_tilt); - size += ProtoSize::length(1, this->device_class.size()); - size += ProtoSize::bool_(1, this->disabled_by_default); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_bool_(1, this->assumed_state); + size += ProtoSize::calc_bool_(1, this->supports_position); + size += ProtoSize::calc_bool_(1, this->supports_tilt); + size += ProtoSize::calc_length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::bool_(1, this->supports_stop); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->supports_stop); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -285,12 +285,12 @@ void CoverStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t CoverStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::float_(1, this->position); - size += ProtoSize::float_(1, this->tilt); - size += ProtoSize::uint32(1, static_cast(this->current_operation)); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_float(1, this->position); + size += ProtoSize::calc_float(1, this->tilt); + size += ProtoSize::calc_uint32(1, static_cast(this->current_operation)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -355,25 +355,25 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesFanResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::bool_(1, this->supports_oscillation); - size += ProtoSize::bool_(1, this->supports_speed); - size += ProtoSize::bool_(1, this->supports_direction); - size += ProtoSize::int32(1, this->supported_speed_count); - size += ProtoSize::bool_(1, this->disabled_by_default); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_bool_(1, this->supports_oscillation); + size += ProtoSize::calc_bool_(1, this->supports_speed); + size += ProtoSize::calc_bool_(1, this->supports_direction); + size += ProtoSize::calc_int32(1, this->supported_speed_count); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); if (!this->supported_preset_modes->empty()) { for (const char *it : *this->supported_preset_modes) { - size += ProtoSize::length_force(1, strlen(it)); + size += ProtoSize::calc_length_force(1, strlen(it)); } } #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -390,14 +390,14 @@ void FanStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t FanStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->state); - size += ProtoSize::bool_(1, this->oscillating); - size += ProtoSize::uint32(1, static_cast(this->direction)); - size += ProtoSize::int32(1, this->speed_level); - size += ProtoSize::length(1, this->preset_mode.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->state); + size += ProtoSize::calc_bool_(1, this->oscillating); + size += ProtoSize::calc_uint32(1, static_cast(this->direction)); + size += ProtoSize::calc_int32(1, this->speed_level); + size += ProtoSize::calc_length(1, this->preset_mode.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -486,28 +486,28 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesLightResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); if (!this->supported_color_modes->empty()) { for (const auto &it : *this->supported_color_modes) { - size += ProtoSize::uint32_force(1, static_cast(it)); + size += ProtoSize::calc_uint32_force(1, static_cast(it)); } } - size += ProtoSize::float_(1, this->min_mireds); - size += ProtoSize::float_(1, this->max_mireds); + size += ProtoSize::calc_float(1, this->min_mireds); + size += ProtoSize::calc_float(1, this->max_mireds); if (!this->effects->empty()) { for (const char *it : *this->effects) { - size += ProtoSize::length_force(1, strlen(it)); + size += ProtoSize::calc_length_force(1, strlen(it)); } } - size += ProtoSize::bool_(1, this->disabled_by_default); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(2, this->device_id); + size += ProtoSize::calc_uint32(2, this->device_id); #endif return size; } @@ -531,21 +531,21 @@ void LightStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t LightStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->state); - size += ProtoSize::float_(1, this->brightness); - size += ProtoSize::uint32(1, static_cast(this->color_mode)); - size += ProtoSize::float_(1, this->color_brightness); - size += ProtoSize::float_(1, this->red); - size += ProtoSize::float_(1, this->green); - size += ProtoSize::float_(1, this->blue); - size += ProtoSize::float_(1, this->white); - size += ProtoSize::float_(1, this->color_temperature); - size += ProtoSize::float_(1, this->cold_white); - size += ProtoSize::float_(1, this->warm_white); - size += ProtoSize::length(1, this->effect.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->state); + size += ProtoSize::calc_float(1, this->brightness); + size += ProtoSize::calc_uint32(1, static_cast(this->color_mode)); + size += ProtoSize::calc_float(1, this->color_brightness); + size += ProtoSize::calc_float(1, this->red); + size += ProtoSize::calc_float(1, this->green); + size += ProtoSize::calc_float(1, this->blue); + size += ProtoSize::calc_float(1, this->white); + size += ProtoSize::calc_float(1, this->color_temperature); + size += ProtoSize::calc_float(1, this->cold_white); + size += ProtoSize::calc_float(1, this->warm_white); + size += ProtoSize::calc_length(1, this->effect.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -679,21 +679,21 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesSensorResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::length(1, this->unit_of_measurement.size()); - size += ProtoSize::int32(1, this->accuracy_decimals); - size += ProtoSize::bool_(1, this->force_update); - size += ProtoSize::length(1, this->device_class.size()); - size += ProtoSize::uint32(1, static_cast(this->state_class)); - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->unit_of_measurement.size()); + size += ProtoSize::calc_int32(1, this->accuracy_decimals); + size += ProtoSize::calc_bool_(1, this->force_update); + size += ProtoSize::calc_length(1, this->device_class.size()); + size += ProtoSize::calc_uint32(1, static_cast(this->state_class)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -707,11 +707,11 @@ void SensorStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t SensorStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::float_(1, this->state); - size += ProtoSize::bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_float(1, this->state); + size += ProtoSize::calc_bool_(1, this->missing_state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -734,18 +734,18 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesSwitchResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->assumed_state); - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->assumed_state); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->device_class.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -758,10 +758,10 @@ void SwitchStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t SwitchStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -808,17 +808,17 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesTextSensorResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->device_class.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -832,11 +832,11 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t TextSensorStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->state.size()); - size += ProtoSize::bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->state.size()); + size += ProtoSize::calc_bool_(1, this->missing_state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -860,8 +860,8 @@ void SubscribeLogsResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t SubscribeLogsResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, static_cast(this->level)); - size += ProtoSize::length(1, this->message_len_); + size += ProtoSize::calc_uint32(1, static_cast(this->level)); + size += ProtoSize::calc_length(1, this->message_len_); return size; } #ifdef USE_API_NOISE @@ -880,7 +880,7 @@ bool NoiseEncryptionSetKeyRequest::decode_length(uint32_t field_id, ProtoLengthD void NoiseEncryptionSetKeyResponse::encode(ProtoWriteBuffer &buffer) const { buffer.encode_bool(1, this->success); } uint32_t NoiseEncryptionSetKeyResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::bool_(1, this->success); + size += ProtoSize::calc_bool_(1, this->success); return size; } #endif @@ -891,8 +891,8 @@ void HomeassistantServiceMap::encode(ProtoWriteBuffer &buffer) const { } uint32_t HomeassistantServiceMap::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->key.size()); - size += ProtoSize::length(1, this->value.size()); + size += ProtoSize::calc_length(1, this->key.size()); + size += ProtoSize::calc_length(1, this->value.size()); return size; } void HomeassistantActionRequest::encode(ProtoWriteBuffer &buffer) const { @@ -919,31 +919,31 @@ void HomeassistantActionRequest::encode(ProtoWriteBuffer &buffer) const { } uint32_t HomeassistantActionRequest::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->service.size()); + size += ProtoSize::calc_length(1, this->service.size()); if (!this->data.empty()) { for (const auto &it : this->data) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } if (!this->data_template.empty()) { for (const auto &it : this->data_template) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } if (!this->variables.empty()) { for (const auto &it : this->variables) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } - size += ProtoSize::bool_(1, this->is_event); + size += ProtoSize::calc_bool_(1, this->is_event); #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES - size += ProtoSize::uint32(1, this->call_id); + size += ProtoSize::calc_uint32(1, this->call_id); #endif #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON - size += ProtoSize::bool_(1, this->wants_response); + size += ProtoSize::calc_bool_(1, this->wants_response); #endif #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON - size += ProtoSize::length(1, this->response_template.size()); + size += ProtoSize::calc_length(1, this->response_template.size()); #endif return size; } @@ -989,9 +989,9 @@ void SubscribeHomeAssistantStateResponse::encode(ProtoWriteBuffer &buffer) const } uint32_t SubscribeHomeAssistantStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->entity_id.size()); - size += ProtoSize::length(1, this->attribute.size()); - size += ProtoSize::bool_(1, this->once); + size += ProtoSize::calc_length(1, this->entity_id.size()); + size += ProtoSize::calc_length(1, this->attribute.size()); + size += ProtoSize::calc_bool_(1, this->once); return size; } bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDelimited value) { @@ -1096,8 +1096,8 @@ void ListEntitiesServicesArgument::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesServicesArgument::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::uint32(1, static_cast(this->type)); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_uint32(1, static_cast(this->type)); return size; } void ListEntitiesServicesResponse::encode(ProtoWriteBuffer &buffer) const { @@ -1110,14 +1110,14 @@ void ListEntitiesServicesResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesServicesResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_fixed32(1, this->key); if (!this->args.empty()) { for (const auto &it : this->args) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } - size += ProtoSize::uint32(1, static_cast(this->supports_response)); + size += ProtoSize::calc_uint32(1, static_cast(this->supports_response)); return size; } bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -1235,11 +1235,11 @@ void ExecuteServiceResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ExecuteServiceResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, this->call_id); - size += ProtoSize::bool_(1, this->success); - size += ProtoSize::length(1, this->error_message.size()); + size += ProtoSize::calc_uint32(1, this->call_id); + size += ProtoSize::calc_bool_(1, this->success); + size += ProtoSize::calc_length(1, this->error_message.size()); #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON - size += ProtoSize::length(1, this->response_data_len); + size += ProtoSize::calc_length(1, this->response_data_len); #endif return size; } @@ -1260,16 +1260,16 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesCameraResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::bool_(1, this->disabled_by_default); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1283,11 +1283,11 @@ void CameraImageResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t CameraImageResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->data_len_); - size += ProtoSize::bool_(1, this->done); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->data_len_); + size += ProtoSize::calc_bool_(1, this->done); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1351,59 +1351,59 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesClimateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); - size += ProtoSize::bool_(1, this->supports_current_temperature); - size += ProtoSize::bool_(1, this->supports_two_point_target_temperature); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); + size += ProtoSize::calc_bool_(1, this->supports_current_temperature); + size += ProtoSize::calc_bool_(1, this->supports_two_point_target_temperature); if (!this->supported_modes->empty()) { for (const auto &it : *this->supported_modes) { - size += ProtoSize::uint32_force(1, static_cast(it)); + size += ProtoSize::calc_uint32_force(1, static_cast(it)); } } - size += ProtoSize::float_(1, this->visual_min_temperature); - size += ProtoSize::float_(1, this->visual_max_temperature); - size += ProtoSize::float_(1, this->visual_target_temperature_step); - size += ProtoSize::bool_(1, this->supports_action); + size += ProtoSize::calc_float(1, this->visual_min_temperature); + size += ProtoSize::calc_float(1, this->visual_max_temperature); + size += ProtoSize::calc_float(1, this->visual_target_temperature_step); + size += ProtoSize::calc_bool_(1, this->supports_action); if (!this->supported_fan_modes->empty()) { for (const auto &it : *this->supported_fan_modes) { - size += ProtoSize::uint32_force(1, static_cast(it)); + size += ProtoSize::calc_uint32_force(1, static_cast(it)); } } if (!this->supported_swing_modes->empty()) { for (const auto &it : *this->supported_swing_modes) { - size += ProtoSize::uint32_force(1, static_cast(it)); + size += ProtoSize::calc_uint32_force(1, static_cast(it)); } } if (!this->supported_custom_fan_modes->empty()) { for (const char *it : *this->supported_custom_fan_modes) { - size += ProtoSize::length_force(1, strlen(it)); + size += ProtoSize::calc_length_force(1, strlen(it)); } } if (!this->supported_presets->empty()) { for (const auto &it : *this->supported_presets) { - size += ProtoSize::uint32_force(2, static_cast(it)); + size += ProtoSize::calc_uint32_force(2, static_cast(it)); } } if (!this->supported_custom_presets->empty()) { for (const char *it : *this->supported_custom_presets) { - size += ProtoSize::length_force(2, strlen(it)); + size += ProtoSize::calc_length_force(2, strlen(it)); } } - size += ProtoSize::bool_(2, this->disabled_by_default); + size += ProtoSize::calc_bool_(2, this->disabled_by_default); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(2, this->icon.size()); + size += ProtoSize::calc_length(2, this->icon.size()); #endif - size += ProtoSize::uint32(2, static_cast(this->entity_category)); - size += ProtoSize::float_(2, this->visual_current_temperature_step); - size += ProtoSize::bool_(2, this->supports_current_humidity); - size += ProtoSize::bool_(2, this->supports_target_humidity); - size += ProtoSize::float_(2, this->visual_min_humidity); - size += ProtoSize::float_(2, this->visual_max_humidity); + size += ProtoSize::calc_uint32(2, static_cast(this->entity_category)); + size += ProtoSize::calc_float(2, this->visual_current_temperature_step); + size += ProtoSize::calc_bool_(2, this->supports_current_humidity); + size += ProtoSize::calc_bool_(2, this->supports_target_humidity); + size += ProtoSize::calc_float(2, this->visual_min_humidity); + size += ProtoSize::calc_float(2, this->visual_max_humidity); #ifdef USE_DEVICES - size += ProtoSize::uint32(2, this->device_id); + size += ProtoSize::calc_uint32(2, this->device_id); #endif - size += ProtoSize::uint32(2, this->feature_flags); + size += ProtoSize::calc_uint32(2, this->feature_flags); return size; } void ClimateStateResponse::encode(ProtoWriteBuffer &buffer) const { @@ -1427,22 +1427,22 @@ void ClimateStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ClimateStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::uint32(1, static_cast(this->mode)); - size += ProtoSize::float_(1, this->current_temperature); - size += ProtoSize::float_(1, this->target_temperature); - size += ProtoSize::float_(1, this->target_temperature_low); - size += ProtoSize::float_(1, this->target_temperature_high); - size += ProtoSize::uint32(1, static_cast(this->action)); - size += ProtoSize::uint32(1, static_cast(this->fan_mode)); - size += ProtoSize::uint32(1, static_cast(this->swing_mode)); - size += ProtoSize::length(1, this->custom_fan_mode.size()); - size += ProtoSize::uint32(1, static_cast(this->preset)); - size += ProtoSize::length(1, this->custom_preset.size()); - size += ProtoSize::float_(1, this->current_humidity); - size += ProtoSize::float_(1, this->target_humidity); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_uint32(1, static_cast(this->mode)); + size += ProtoSize::calc_float(1, this->current_temperature); + size += ProtoSize::calc_float(1, this->target_temperature); + size += ProtoSize::calc_float(1, this->target_temperature_low); + size += ProtoSize::calc_float(1, this->target_temperature_high); + size += ProtoSize::calc_uint32(1, static_cast(this->action)); + size += ProtoSize::calc_uint32(1, static_cast(this->fan_mode)); + size += ProtoSize::calc_uint32(1, static_cast(this->swing_mode)); + size += ProtoSize::calc_length(1, this->custom_fan_mode.size()); + size += ProtoSize::calc_uint32(1, static_cast(this->preset)); + size += ProtoSize::calc_length(1, this->custom_preset.size()); + size += ProtoSize::calc_float(1, this->current_humidity); + size += ProtoSize::calc_float(1, this->target_humidity); #ifdef USE_DEVICES - size += ProtoSize::uint32(2, this->device_id); + size += ProtoSize::calc_uint32(2, this->device_id); #endif return size; } @@ -1561,26 +1561,26 @@ void ListEntitiesWaterHeaterResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesWaterHeaterResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif - size += ProtoSize::float_(1, this->min_temperature); - size += ProtoSize::float_(1, this->max_temperature); - size += ProtoSize::float_(1, this->target_temperature_step); + size += ProtoSize::calc_float(1, this->min_temperature); + size += ProtoSize::calc_float(1, this->max_temperature); + size += ProtoSize::calc_float(1, this->target_temperature_step); if (!this->supported_modes->empty()) { for (const auto &it : *this->supported_modes) { - size += ProtoSize::uint32_force(1, static_cast(it)); + size += ProtoSize::calc_uint32_force(1, static_cast(it)); } } - size += ProtoSize::uint32(1, this->supported_features); + size += ProtoSize::calc_uint32(1, this->supported_features); return size; } void WaterHeaterStateResponse::encode(ProtoWriteBuffer &buffer) const { @@ -1597,16 +1597,16 @@ void WaterHeaterStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t WaterHeaterStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::float_(1, this->current_temperature); - size += ProtoSize::float_(1, this->target_temperature); - size += ProtoSize::uint32(1, static_cast(this->mode)); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_float(1, this->current_temperature); + size += ProtoSize::calc_float(1, this->target_temperature); + size += ProtoSize::calc_uint32(1, static_cast(this->mode)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif - size += ProtoSize::uint32(1, this->state); - size += ProtoSize::float_(1, this->target_temperature_low); - size += ProtoSize::float_(1, this->target_temperature_high); + size += ProtoSize::calc_uint32(1, this->state); + size += ProtoSize::calc_float(1, this->target_temperature_low); + size += ProtoSize::calc_float(1, this->target_temperature_high); return size; } bool WaterHeaterCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -1672,22 +1672,22 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesNumberResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::float_(1, this->min_value); - size += ProtoSize::float_(1, this->max_value); - size += ProtoSize::float_(1, this->step); - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->unit_of_measurement.size()); - size += ProtoSize::uint32(1, static_cast(this->mode)); - size += ProtoSize::length(1, this->device_class.size()); + size += ProtoSize::calc_float(1, this->min_value); + size += ProtoSize::calc_float(1, this->max_value); + size += ProtoSize::calc_float(1, this->step); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->unit_of_measurement.size()); + size += ProtoSize::calc_uint32(1, static_cast(this->mode)); + size += ProtoSize::calc_length(1, this->device_class.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1701,11 +1701,11 @@ void NumberStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t NumberStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::float_(1, this->state); - size += ProtoSize::bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_float(1, this->state); + size += ProtoSize::calc_bool_(1, this->missing_state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1754,21 +1754,21 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesSelectResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif if (!this->options->empty()) { for (const char *it : *this->options) { - size += ProtoSize::length_force(1, strlen(it)); + size += ProtoSize::calc_length_force(1, strlen(it)); } } - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1782,11 +1782,11 @@ void SelectStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t SelectStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->state.size()); - size += ProtoSize::bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->state.size()); + size += ProtoSize::calc_bool_(1, this->missing_state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1845,23 +1845,23 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesSirenResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); if (!this->tones->empty()) { for (const char *it : *this->tones) { - size += ProtoSize::length_force(1, strlen(it)); + size += ProtoSize::calc_length_force(1, strlen(it)); } } - size += ProtoSize::bool_(1, this->supports_duration); - size += ProtoSize::bool_(1, this->supports_volume); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->supports_duration); + size += ProtoSize::calc_bool_(1, this->supports_volume); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1874,10 +1874,10 @@ void SirenStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t SirenStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1956,20 +1956,20 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesLockResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::bool_(1, this->assumed_state); - size += ProtoSize::bool_(1, this->supports_open); - size += ProtoSize::bool_(1, this->requires_code); - size += ProtoSize::length(1, this->code_format.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->assumed_state); + size += ProtoSize::calc_bool_(1, this->supports_open); + size += ProtoSize::calc_bool_(1, this->requires_code); + size += ProtoSize::calc_length(1, this->code_format.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -1982,10 +1982,10 @@ void LockStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t LockStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::uint32(1, static_cast(this->state)); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_uint32(1, static_cast(this->state)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -2046,17 +2046,17 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesButtonResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->device_class.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -2093,11 +2093,11 @@ void MediaPlayerSupportedFormat::encode(ProtoWriteBuffer &buffer) const { } uint32_t MediaPlayerSupportedFormat::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->format.size()); - size += ProtoSize::uint32(1, this->sample_rate); - size += ProtoSize::uint32(1, this->num_channels); - size += ProtoSize::uint32(1, static_cast(this->purpose)); - size += ProtoSize::uint32(1, this->sample_bytes); + size += ProtoSize::calc_length(1, this->format.size()); + size += ProtoSize::calc_uint32(1, this->sample_rate); + size += ProtoSize::calc_uint32(1, this->num_channels); + size += ProtoSize::calc_uint32(1, static_cast(this->purpose)); + size += ProtoSize::calc_uint32(1, this->sample_bytes); return size; } void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2120,24 +2120,24 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesMediaPlayerResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::bool_(1, this->supports_pause); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->supports_pause); if (!this->supported_formats.empty()) { for (const auto &it : this->supported_formats) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif - size += ProtoSize::uint32(1, this->feature_flags); + size += ProtoSize::calc_uint32(1, this->feature_flags); return size; } void MediaPlayerStateResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2151,12 +2151,12 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t MediaPlayerStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::uint32(1, static_cast(this->state)); - size += ProtoSize::float_(1, this->volume); - size += ProtoSize::bool_(1, this->muted); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_uint32(1, static_cast(this->state)); + size += ProtoSize::calc_float(1, this->volume); + size += ProtoSize::calc_bool_(1, this->muted); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -2234,10 +2234,10 @@ void BluetoothLERawAdvertisement::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothLERawAdvertisement::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::sint32(1, this->rssi); - size += ProtoSize::uint32(1, this->address_type); - size += ProtoSize::length(1, this->data_len); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_sint32(1, this->rssi); + size += ProtoSize::calc_uint32(1, this->address_type); + size += ProtoSize::calc_length(1, this->data_len); return size; } void BluetoothLERawAdvertisementsResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2248,7 +2248,7 @@ void BluetoothLERawAdvertisementsResponse::encode(ProtoWriteBuffer &buffer) cons uint32_t BluetoothLERawAdvertisementsResponse::calculate_size() const { uint32_t size = 0; for (uint16_t i = 0; i < this->advertisements_len; i++) { - size += ProtoSize::message_force(1, this->advertisements[i].calculate_size()); + size += ProtoSize::calc_message_force(1, this->advertisements[i].calculate_size()); } return size; } @@ -2279,10 +2279,10 @@ void BluetoothDeviceConnectionResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothDeviceConnectionResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::bool_(1, this->connected); - size += ProtoSize::uint32(1, this->mtu); - size += ProtoSize::int32(1, this->error); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_bool_(1, this->connected); + size += ProtoSize::calc_uint32(1, this->mtu); + size += ProtoSize::calc_int32(1, this->error); return size; } bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2306,11 +2306,11 @@ void BluetoothGATTDescriptor::encode(ProtoWriteBuffer &buffer) const { uint32_t BluetoothGATTDescriptor::calculate_size() const { uint32_t size = 0; if (this->uuid[0] != 0 || this->uuid[1] != 0) { - size += ProtoSize::uint64_force(1, this->uuid[0]); - size += ProtoSize::uint64_force(1, this->uuid[1]); + size += ProtoSize::calc_uint64_force(1, this->uuid[0]); + size += ProtoSize::calc_uint64_force(1, this->uuid[1]); } - size += ProtoSize::uint32(1, this->handle); - size += ProtoSize::uint32(1, this->short_uuid); + size += ProtoSize::calc_uint32(1, this->handle); + size += ProtoSize::calc_uint32(1, this->short_uuid); return size; } void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer &buffer) const { @@ -2328,17 +2328,17 @@ void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer &buffer) const { uint32_t BluetoothGATTCharacteristic::calculate_size() const { uint32_t size = 0; if (this->uuid[0] != 0 || this->uuid[1] != 0) { - size += ProtoSize::uint64_force(1, this->uuid[0]); - size += ProtoSize::uint64_force(1, this->uuid[1]); + size += ProtoSize::calc_uint64_force(1, this->uuid[0]); + size += ProtoSize::calc_uint64_force(1, this->uuid[1]); } - size += ProtoSize::uint32(1, this->handle); - size += ProtoSize::uint32(1, this->properties); + size += ProtoSize::calc_uint32(1, this->handle); + size += ProtoSize::calc_uint32(1, this->properties); if (!this->descriptors.empty()) { for (const auto &it : this->descriptors) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } - size += ProtoSize::uint32(1, this->short_uuid); + size += ProtoSize::calc_uint32(1, this->short_uuid); return size; } void BluetoothGATTService::encode(ProtoWriteBuffer &buffer) const { @@ -2355,16 +2355,16 @@ void BluetoothGATTService::encode(ProtoWriteBuffer &buffer) const { uint32_t BluetoothGATTService::calculate_size() const { uint32_t size = 0; if (this->uuid[0] != 0 || this->uuid[1] != 0) { - size += ProtoSize::uint64_force(1, this->uuid[0]); - size += ProtoSize::uint64_force(1, this->uuid[1]); + size += ProtoSize::calc_uint64_force(1, this->uuid[0]); + size += ProtoSize::calc_uint64_force(1, this->uuid[1]); } - size += ProtoSize::uint32(1, this->handle); + size += ProtoSize::calc_uint32(1, this->handle); if (!this->characteristics.empty()) { for (const auto &it : this->characteristics) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } - size += ProtoSize::uint32(1, this->short_uuid); + size += ProtoSize::calc_uint32(1, this->short_uuid); return size; } void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2375,10 +2375,10 @@ void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothGATTGetServicesResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); + size += ProtoSize::calc_uint64(1, this->address); if (!this->services.empty()) { for (const auto &it : this->services) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } return size; @@ -2388,7 +2388,7 @@ void BluetoothGATTGetServicesDoneResponse::encode(ProtoWriteBuffer &buffer) cons } uint32_t BluetoothGATTGetServicesDoneResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); + size += ProtoSize::calc_uint64(1, this->address); return size; } bool BluetoothGATTReadRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2411,9 +2411,9 @@ void BluetoothGATTReadResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothGATTReadResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::uint32(1, this->handle); - size += ProtoSize::length(1, this->data_len_); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_uint32(1, this->handle); + size += ProtoSize::calc_length(1, this->data_len_); return size; } bool BluetoothGATTWriteRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2505,9 +2505,9 @@ void BluetoothGATTNotifyDataResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothGATTNotifyDataResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::uint32(1, this->handle); - size += ProtoSize::length(1, this->data_len_); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_uint32(1, this->handle); + size += ProtoSize::calc_length(1, this->data_len_); return size; } void BluetoothConnectionsFreeResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2521,11 +2521,11 @@ void BluetoothConnectionsFreeResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothConnectionsFreeResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, this->free); - size += ProtoSize::uint32(1, this->limit); + size += ProtoSize::calc_uint32(1, this->free); + size += ProtoSize::calc_uint32(1, this->limit); for (const auto &it : this->allocated) { if (it != 0) { - size += ProtoSize::uint64_force(1, it); + size += ProtoSize::calc_uint64_force(1, it); } } return size; @@ -2537,9 +2537,9 @@ void BluetoothGATTErrorResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothGATTErrorResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::uint32(1, this->handle); - size += ProtoSize::int32(1, this->error); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_uint32(1, this->handle); + size += ProtoSize::calc_int32(1, this->error); return size; } void BluetoothGATTWriteResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2548,8 +2548,8 @@ void BluetoothGATTWriteResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothGATTWriteResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::uint32(1, this->handle); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_uint32(1, this->handle); return size; } void BluetoothGATTNotifyResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2558,8 +2558,8 @@ void BluetoothGATTNotifyResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothGATTNotifyResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::uint32(1, this->handle); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_uint32(1, this->handle); return size; } void BluetoothDevicePairingResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2569,9 +2569,9 @@ void BluetoothDevicePairingResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothDevicePairingResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::bool_(1, this->paired); - size += ProtoSize::int32(1, this->error); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_bool_(1, this->paired); + size += ProtoSize::calc_int32(1, this->error); return size; } void BluetoothDeviceUnpairingResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2581,9 +2581,9 @@ void BluetoothDeviceUnpairingResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothDeviceUnpairingResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::bool_(1, this->success); - size += ProtoSize::int32(1, this->error); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_bool_(1, this->success); + size += ProtoSize::calc_int32(1, this->error); return size; } void BluetoothDeviceClearCacheResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2593,9 +2593,9 @@ void BluetoothDeviceClearCacheResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothDeviceClearCacheResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint64(1, this->address); - size += ProtoSize::bool_(1, this->success); - size += ProtoSize::int32(1, this->error); + size += ProtoSize::calc_uint64(1, this->address); + size += ProtoSize::calc_bool_(1, this->success); + size += ProtoSize::calc_int32(1, this->error); return size; } void BluetoothScannerStateResponse::encode(ProtoWriteBuffer &buffer) const { @@ -2605,9 +2605,9 @@ void BluetoothScannerStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t BluetoothScannerStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, static_cast(this->state)); - size += ProtoSize::uint32(1, static_cast(this->mode)); - size += ProtoSize::uint32(1, static_cast(this->configured_mode)); + size += ProtoSize::calc_uint32(1, static_cast(this->state)); + size += ProtoSize::calc_uint32(1, static_cast(this->mode)); + size += ProtoSize::calc_uint32(1, static_cast(this->configured_mode)); return size; } bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2642,9 +2642,9 @@ void VoiceAssistantAudioSettings::encode(ProtoWriteBuffer &buffer) const { } uint32_t VoiceAssistantAudioSettings::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, this->noise_suppression_level); - size += ProtoSize::uint32(1, this->auto_gain); - size += ProtoSize::float_(1, this->volume_multiplier); + size += ProtoSize::calc_uint32(1, this->noise_suppression_level); + size += ProtoSize::calc_uint32(1, this->auto_gain); + size += ProtoSize::calc_float(1, this->volume_multiplier); return size; } void VoiceAssistantRequest::encode(ProtoWriteBuffer &buffer) const { @@ -2656,11 +2656,11 @@ void VoiceAssistantRequest::encode(ProtoWriteBuffer &buffer) const { } uint32_t VoiceAssistantRequest::calculate_size() const { uint32_t size = 0; - size += ProtoSize::bool_(1, this->start); - size += ProtoSize::length(1, this->conversation_id.size()); - size += ProtoSize::uint32(1, this->flags); - size += ProtoSize::message(1, this->audio_settings.calculate_size()); - size += ProtoSize::length(1, this->wake_word_phrase.size()); + size += ProtoSize::calc_bool_(1, this->start); + size += ProtoSize::calc_length(1, this->conversation_id.size()); + size += ProtoSize::calc_uint32(1, this->flags); + size += ProtoSize::calc_message(1, this->audio_settings.calculate_size()); + size += ProtoSize::calc_length(1, this->wake_word_phrase.size()); return size; } bool VoiceAssistantResponse::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2740,8 +2740,8 @@ void VoiceAssistantAudio::encode(ProtoWriteBuffer &buffer) const { } uint32_t VoiceAssistantAudio::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->data_len); - size += ProtoSize::bool_(1, this->end); + size += ProtoSize::calc_length(1, this->data_len); + size += ProtoSize::calc_bool_(1, this->end); return size; } bool VoiceAssistantTimerEventResponse::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2810,7 +2810,7 @@ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLength void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer &buffer) const { buffer.encode_bool(1, this->success); } uint32_t VoiceAssistantAnnounceFinished::calculate_size() const { uint32_t size = 0; - size += ProtoSize::bool_(1, this->success); + size += ProtoSize::calc_bool_(1, this->success); return size; } void VoiceAssistantWakeWord::encode(ProtoWriteBuffer &buffer) const { @@ -2822,11 +2822,11 @@ void VoiceAssistantWakeWord::encode(ProtoWriteBuffer &buffer) const { } uint32_t VoiceAssistantWakeWord::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->id.size()); - size += ProtoSize::length(1, this->wake_word.size()); + size += ProtoSize::calc_length(1, this->id.size()); + size += ProtoSize::calc_length(1, this->wake_word.size()); if (!this->trained_languages.empty()) { for (const auto &it : this->trained_languages) { - size += ProtoSize::length_force(1, it.size()); + size += ProtoSize::calc_length_force(1, it.size()); } } return size; @@ -2895,15 +2895,15 @@ uint32_t VoiceAssistantConfigurationResponse::calculate_size() const { uint32_t size = 0; if (!this->available_wake_words.empty()) { for (const auto &it : this->available_wake_words) { - size += ProtoSize::message_force(1, it.calculate_size()); + size += ProtoSize::calc_message_force(1, it.calculate_size()); } } if (!this->active_wake_words->empty()) { for (const auto &it : *this->active_wake_words) { - size += ProtoSize::length_force(1, it.size()); + size += ProtoSize::calc_length_force(1, it.size()); } } - size += ProtoSize::uint32(1, this->max_active_wake_words); + size += ProtoSize::calc_uint32(1, this->max_active_wake_words); return size; } bool VoiceAssistantSetConfiguration::decode_length(uint32_t field_id, ProtoLengthDelimited value) { @@ -2936,19 +2936,19 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer &buffer) con } uint32_t ListEntitiesAlarmControlPanelResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::uint32(1, this->supported_features); - size += ProtoSize::bool_(1, this->requires_code); - size += ProtoSize::bool_(1, this->requires_code_to_arm); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_uint32(1, this->supported_features); + size += ProtoSize::calc_bool_(1, this->requires_code); + size += ProtoSize::calc_bool_(1, this->requires_code_to_arm); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -2961,10 +2961,10 @@ void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t AlarmControlPanelStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::uint32(1, static_cast(this->state)); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_uint32(1, static_cast(this->state)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3025,20 +3025,20 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesTextResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::uint32(1, this->min_length); - size += ProtoSize::uint32(1, this->max_length); - size += ProtoSize::length(1, this->pattern.size()); - size += ProtoSize::uint32(1, static_cast(this->mode)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_uint32(1, this->min_length); + size += ProtoSize::calc_uint32(1, this->max_length); + size += ProtoSize::calc_length(1, this->pattern.size()); + size += ProtoSize::calc_uint32(1, static_cast(this->mode)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3052,11 +3052,11 @@ void TextStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t TextStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->state.size()); - size += ProtoSize::bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->state.size()); + size += ProtoSize::calc_bool_(1, this->missing_state); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3110,16 +3110,16 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesDateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3135,13 +3135,13 @@ void DateStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t DateStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->missing_state); - size += ProtoSize::uint32(1, this->year); - size += ProtoSize::uint32(1, this->month); - size += ProtoSize::uint32(1, this->day); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->missing_state); + size += ProtoSize::calc_uint32(1, this->year); + size += ProtoSize::calc_uint32(1, this->month); + size += ProtoSize::calc_uint32(1, this->day); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3193,16 +3193,16 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesTimeResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3218,13 +3218,13 @@ void TimeStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t TimeStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->missing_state); - size += ProtoSize::uint32(1, this->hour); - size += ProtoSize::uint32(1, this->minute); - size += ProtoSize::uint32(1, this->second); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->missing_state); + size += ProtoSize::calc_uint32(1, this->hour); + size += ProtoSize::calc_uint32(1, this->minute); + size += ProtoSize::calc_uint32(1, this->second); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3280,22 +3280,22 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesEventResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->device_class.size()); if (!this->event_types->empty()) { for (const char *it : *this->event_types) { - size += ProtoSize::length_force(1, strlen(it)); + size += ProtoSize::calc_length_force(1, strlen(it)); } } #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3308,10 +3308,10 @@ void EventResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t EventResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->event_type.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->event_type.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3336,20 +3336,20 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesValveResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->device_class.size()); - size += ProtoSize::bool_(1, this->assumed_state); - size += ProtoSize::bool_(1, this->supports_position); - size += ProtoSize::bool_(1, this->supports_stop); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->assumed_state); + size += ProtoSize::calc_bool_(1, this->supports_position); + size += ProtoSize::calc_bool_(1, this->supports_stop); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3363,11 +3363,11 @@ void ValveStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ValveStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::float_(1, this->position); - size += ProtoSize::uint32(1, static_cast(this->current_operation)); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_float(1, this->position); + size += ProtoSize::calc_uint32(1, static_cast(this->current_operation)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3419,16 +3419,16 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesDateTimeResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3442,11 +3442,11 @@ void DateTimeStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t DateTimeStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->missing_state); - size += ProtoSize::fixed32(1, this->epoch_seconds); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->missing_state); + size += ProtoSize::calc_fixed32(1, this->epoch_seconds); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3493,17 +3493,17 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesUpdateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); - size += ProtoSize::length(1, this->device_class.size()); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_length(1, this->device_class.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3524,18 +3524,18 @@ void UpdateStateResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t UpdateStateResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::bool_(1, this->missing_state); - size += ProtoSize::bool_(1, this->in_progress); - size += ProtoSize::bool_(1, this->has_progress); - size += ProtoSize::float_(1, this->progress); - size += ProtoSize::length(1, this->current_version.size()); - size += ProtoSize::length(1, this->latest_version.size()); - size += ProtoSize::length(1, this->title.size()); - size += ProtoSize::length(1, this->release_summary.size()); - size += ProtoSize::length(1, this->release_url.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_bool_(1, this->missing_state); + size += ProtoSize::calc_bool_(1, this->in_progress); + size += ProtoSize::calc_bool_(1, this->has_progress); + size += ProtoSize::calc_float(1, this->progress); + size += ProtoSize::calc_length(1, this->current_version.size()); + size += ProtoSize::calc_length(1, this->latest_version.size()); + size += ProtoSize::calc_length(1, this->title.size()); + size += ProtoSize::calc_length(1, this->release_summary.size()); + size += ProtoSize::calc_length(1, this->release_url.size()); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif return size; } @@ -3581,7 +3581,7 @@ bool ZWaveProxyFrame::decode_length(uint32_t field_id, ProtoLengthDelimited valu void ZWaveProxyFrame::encode(ProtoWriteBuffer &buffer) const { buffer.encode_bytes(1, this->data, this->data_len); } uint32_t ZWaveProxyFrame::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->data_len); + size += ProtoSize::calc_length(1, this->data_len); return size; } bool ZWaveProxyRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -3612,8 +3612,8 @@ void ZWaveProxyRequest::encode(ProtoWriteBuffer &buffer) const { } uint32_t ZWaveProxyRequest::calculate_size() const { uint32_t size = 0; - size += ProtoSize::uint32(1, static_cast(this->type)); - size += ProtoSize::length(1, this->data_len); + size += ProtoSize::calc_uint32(1, static_cast(this->type)); + size += ProtoSize::calc_length(1, this->data_len); return size; } #endif @@ -3634,18 +3634,18 @@ void ListEntitiesInfraredResponse::encode(ProtoWriteBuffer &buffer) const { } uint32_t ListEntitiesInfraredResponse::calculate_size() const { uint32_t size = 0; - size += ProtoSize::length(1, this->object_id.size()); - size += ProtoSize::fixed32(1, this->key); - size += ProtoSize::length(1, this->name.size()); + size += ProtoSize::calc_length(1, this->object_id.size()); + size += ProtoSize::calc_fixed32(1, this->key); + size += ProtoSize::calc_length(1, this->name.size()); #ifdef USE_ENTITY_ICON - size += ProtoSize::length(1, this->icon.size()); + size += ProtoSize::calc_length(1, this->icon.size()); #endif - size += ProtoSize::bool_(1, this->disabled_by_default); - size += ProtoSize::uint32(1, static_cast(this->entity_category)); + size += ProtoSize::calc_bool_(1, this->disabled_by_default); + size += ProtoSize::calc_uint32(1, static_cast(this->entity_category)); #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif - size += ProtoSize::uint32(1, this->capabilities); + size += ProtoSize::calc_uint32(1, this->capabilities); return size; } #endif @@ -3703,12 +3703,12 @@ void InfraredRFReceiveEvent::encode(ProtoWriteBuffer &buffer) const { uint32_t InfraredRFReceiveEvent::calculate_size() const { uint32_t size = 0; #ifdef USE_DEVICES - size += ProtoSize::uint32(1, this->device_id); + size += ProtoSize::calc_uint32(1, this->device_id); #endif - size += ProtoSize::fixed32(1, this->key); + size += ProtoSize::calc_fixed32(1, this->key); if (!this->timings->empty()) { for (const auto &it : *this->timings) { - size += ProtoSize::sint32_force(1, it); + size += ProtoSize::calc_sint32_force(1, it); } } return size; diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index 410e604b99..cf03f48be8 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -596,59 +596,69 @@ class ProtoSize { // Static methods that RETURN size contribution (no ProtoSize object needed). // Used by generated calculate_size() methods to accumulate into a plain uint32_t register. - static constexpr uint32_t int32(uint32_t field_id_size, int32_t value) { + static constexpr uint32_t calc_int32(uint32_t field_id_size, int32_t value) { return value ? field_id_size + (value < 0 ? 10 : varint(static_cast(value))) : 0; } - static constexpr uint32_t int32_force(uint32_t field_id_size, int32_t value) { + static constexpr uint32_t calc_int32_force(uint32_t field_id_size, int32_t value) { return field_id_size + (value < 0 ? 10 : varint(static_cast(value))); } - static constexpr uint32_t uint32(uint32_t field_id_size, uint32_t value) { + static constexpr uint32_t calc_uint32(uint32_t field_id_size, uint32_t value) { return value ? field_id_size + varint(value) : 0; } - static constexpr uint32_t uint32_force(uint32_t field_id_size, uint32_t value) { + static constexpr uint32_t calc_uint32_force(uint32_t field_id_size, uint32_t value) { return field_id_size + varint(value); } - static constexpr uint32_t bool_(uint32_t field_id_size, bool value) { return value ? field_id_size + 1 : 0; } - static constexpr uint32_t bool_force(uint32_t field_id_size) { return field_id_size + 1; } - static constexpr uint32_t float_(uint32_t field_id_size, float value) { + static constexpr uint32_t calc_bool(uint32_t field_id_size, bool value) { return value ? field_id_size + 1 : 0; } + static constexpr uint32_t calc_bool_force(uint32_t field_id_size) { return field_id_size + 1; } + static constexpr uint32_t calc_float(uint32_t field_id_size, float value) { return value != 0.0f ? field_id_size + 4 : 0; } - static constexpr uint32_t fixed32(uint32_t field_id_size, uint32_t value) { return value ? field_id_size + 4 : 0; } - static constexpr uint32_t sfixed32(uint32_t field_id_size, int32_t value) { return value ? field_id_size + 4 : 0; } - static constexpr uint32_t sint32(uint32_t field_id_size, int32_t value) { + static constexpr uint32_t calc_fixed32(uint32_t field_id_size, uint32_t value) { + return value ? field_id_size + 4 : 0; + } + static constexpr uint32_t calc_sfixed32(uint32_t field_id_size, int32_t value) { + return value ? field_id_size + 4 : 0; + } + static constexpr uint32_t calc_sint32(uint32_t field_id_size, int32_t value) { return value ? field_id_size + varint(encode_zigzag32(value)) : 0; } - static constexpr uint32_t sint32_force(uint32_t field_id_size, int32_t value) { + static constexpr uint32_t calc_sint32_force(uint32_t field_id_size, int32_t value) { return field_id_size + varint(encode_zigzag32(value)); } - static constexpr uint32_t int64(uint32_t field_id_size, int64_t value) { + static constexpr uint32_t calc_int64(uint32_t field_id_size, int64_t value) { return value ? field_id_size + varint(value) : 0; } - static constexpr uint32_t int64_force(uint32_t field_id_size, int64_t value) { return field_id_size + varint(value); } - static constexpr uint32_t uint64(uint32_t field_id_size, uint64_t value) { - return value ? field_id_size + varint(value) : 0; - } - static constexpr uint32_t uint64_force(uint32_t field_id_size, uint64_t value) { + static constexpr uint32_t calc_int64_force(uint32_t field_id_size, int64_t value) { return field_id_size + varint(value); } - static constexpr uint32_t length(uint32_t field_id_size, size_t len) { + static constexpr uint32_t calc_uint64(uint32_t field_id_size, uint64_t value) { + return value ? field_id_size + varint(value) : 0; + } + static constexpr uint32_t calc_uint64_force(uint32_t field_id_size, uint64_t value) { + return field_id_size + varint(value); + } + static constexpr uint32_t calc_length(uint32_t field_id_size, size_t len) { return len ? field_id_size + varint(static_cast(len)) + static_cast(len) : 0; } - static constexpr uint32_t length_force(uint32_t field_id_size, size_t len) { + static constexpr uint32_t calc_length_force(uint32_t field_id_size, size_t len) { return field_id_size + varint(static_cast(len)) + static_cast(len); } - static constexpr uint32_t sint64(uint32_t field_id_size, int64_t value) { + static constexpr uint32_t calc_sint64(uint32_t field_id_size, int64_t value) { return value ? field_id_size + varint(encode_zigzag64(value)) : 0; } - static constexpr uint32_t sint64_force(uint32_t field_id_size, int64_t value) { + static constexpr uint32_t calc_sint64_force(uint32_t field_id_size, int64_t value) { return field_id_size + varint(encode_zigzag64(value)); } - static constexpr uint32_t fixed64(uint32_t field_id_size, uint64_t value) { return value ? field_id_size + 8 : 0; } - static constexpr uint32_t sfixed64(uint32_t field_id_size, int64_t value) { return value ? field_id_size + 8 : 0; } - static constexpr uint32_t message(uint32_t field_id_size, uint32_t nested_size) { + static constexpr uint32_t calc_fixed64(uint32_t field_id_size, uint64_t value) { + return value ? field_id_size + 8 : 0; + } + static constexpr uint32_t calc_sfixed64(uint32_t field_id_size, int64_t value) { + return value ? field_id_size + 8 : 0; + } + static constexpr uint32_t calc_message(uint32_t field_id_size, uint32_t nested_size) { return nested_size ? field_id_size + varint(nested_size) + nested_size : 0; } - static constexpr uint32_t message_force(uint32_t field_id_size, uint32_t nested_size) { + static constexpr uint32_t calc_message_force(uint32_t field_id_size, uint32_t nested_size) { return field_id_size + varint(nested_size) + nested_size; } }; diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index e5106c8500..039222b7c2 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -279,7 +279,7 @@ class TypeInfo(ABC): value_expr: Optional value expression (defaults to name) """ field_id_size = self.calculate_field_id_size() - method = f"{base_method}_force" if force else base_method + method = f"calc_{base_method}_force" if force else f"calc_{base_method}" value = value_expr or name return f"size += ProtoSize::{method}({field_id_size}, {value});" @@ -410,7 +410,7 @@ class DoubleType(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::fixed64({field_id_size}, {name});" + return f"size += ProtoSize::calc_fixed64({field_id_size}, {name});" def get_fixed_size_bytes(self) -> int: return 8 @@ -434,7 +434,7 @@ class FloatType(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::float_({field_id_size}, {name});" + return f"size += ProtoSize::calc_float({field_id_size}, {name});" def get_fixed_size_bytes(self) -> int: return 4 @@ -518,7 +518,7 @@ class Fixed64Type(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::fixed64({field_id_size}, {name});" + return f"size += ProtoSize::calc_fixed64({field_id_size}, {name});" def get_fixed_size_bytes(self) -> int: return 8 @@ -542,7 +542,7 @@ class Fixed32Type(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::fixed32({field_id_size}, {name});" + return f"size += ProtoSize::calc_fixed32({field_id_size}, {name});" def get_fixed_size_bytes(self) -> int: return 4 @@ -654,11 +654,11 @@ class StringType(TypeInfo): if name == "it": # For repeated fields, we need to use length_force which includes field ID field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::length_force({field_id_size}, it.size());" + return f"size += ProtoSize::calc_length_force({field_id_size}, it.size());" # For messages that need encoding, use the StringRef size field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::length({field_id_size}, this->{self.field_name}_ref_.size());" + return f"size += ProtoSize::calc_length({field_id_size}, this->{self.field_name}_ref_.size());" def get_estimated_size(self) -> int: return self.calculate_field_id_size() + 8 # field ID + 8 bytes typical string @@ -722,7 +722,7 @@ class MessageType(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - method = "message_force" if force else "message" + method = "calc_message_force" if force else "calc_message" return f"size += ProtoSize::{method}({field_id_size}, {name}.calculate_size());" def get_estimated_size(self) -> int: @@ -824,7 +824,7 @@ class BytesType(TypeInfo): ) def get_size_calculation(self, name: str, force: bool = False) -> str: - return f"size += ProtoSize::length({self.calculate_field_id_size()}, this->{self.field_name}_len_);" + return f"size += ProtoSize::calc_length({self.calculate_field_id_size()}, this->{self.field_name}_len_);" def get_estimated_size(self) -> int: return self.calculate_field_id_size() + 8 # field ID + 8 bytes typical bytes @@ -899,7 +899,7 @@ class PointerToBytesBufferType(PointerToBufferTypeBase): ) def get_size_calculation(self, name: str, force: bool = False) -> str: - return f"size += ProtoSize::length({self.calculate_field_id_size()}, this->{self.field_name}_len);" + return f"size += ProtoSize::calc_length({self.calculate_field_id_size()}, this->{self.field_name}_len);" class PointerToStringBufferType(PointerToBufferTypeBase): @@ -941,7 +941,7 @@ class PointerToStringBufferType(PointerToBufferTypeBase): return f'dump_field(out, "{self.name}", this->{self.field_name});' def get_size_calculation(self, name: str, force: bool = False) -> str: - return f"size += ProtoSize::length({self.calculate_field_id_size()}, this->{self.field_name}.size());" + return f"size += ProtoSize::calc_length({self.calculate_field_id_size()}, this->{self.field_name}.size());" def get_estimated_size(self) -> int: return self.calculate_field_id_size() + 8 # field ID + 8 bytes typical string @@ -1105,9 +1105,9 @@ class FixedArrayBytesType(TypeInfo): if force: # For repeated fields, always calculate size (no zero check) - return f"size += ProtoSize::length_force({field_id_size}, {length_field});" + return f"size += ProtoSize::calc_length_force({field_id_size}, {length_field});" # For non-repeated fields, length already checks for zero - return f"size += ProtoSize::length({field_id_size}, {length_field});" + return f"size += ProtoSize::calc_length({field_id_size}, {length_field});" def get_estimated_size(self) -> int: # Estimate based on typical BLE advertisement size @@ -1192,7 +1192,7 @@ class SFixed32Type(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::sfixed32({field_id_size}, {name});" + return f"size += ProtoSize::calc_sfixed32({field_id_size}, {name});" def get_fixed_size_bytes(self) -> int: return 4 @@ -1216,7 +1216,7 @@ class SFixed64Type(TypeInfo): def get_size_calculation(self, name: str, force: bool = False) -> str: field_id_size = self.calculate_field_id_size() - return f"size += ProtoSize::sfixed64({field_id_size}, {name});" + return f"size += ProtoSize::calc_sfixed64({field_id_size}, {name});" def get_fixed_size_bytes(self) -> int: return 8 @@ -1703,7 +1703,7 @@ class RepeatedTypeInfo(TypeInfo): empty_check = f"{name}->empty()" if self._use_pointer else f"{name}.empty()" o = f"if (!{empty_check}) {{\n" o += f" for (const auto &it : {container_ref}) {{\n" - o += f" size += ProtoSize::message_force({field_id_size}, it.calculate_size());\n" + o += f" size += ProtoSize::calc_message_force({field_id_size}, it.calculate_size());\n" o += " }\n" o += "}" return o @@ -1728,7 +1728,7 @@ class RepeatedTypeInfo(TypeInfo): if self._use_pointer and "const char" in self._container_no_template: field_id_size = self.calculate_field_id_size() o += f" for (const char *it : {container_ref}) {{\n" - o += f" size += ProtoSize::length_force({field_id_size}, strlen(it));\n" + o += f" size += ProtoSize::calc_length_force({field_id_size}, strlen(it));\n" else: auto_ref = "" if self._ti_is_bool else "&" o += f" for (const auto {auto_ref}it : {container_ref}) {{\n"