mirror of
https://github.com/esphome/esphome.git
synced 2025-08-03 00:47:47 +00:00
Merge branch 'proto_size_remove_cond' into integration
This commit is contained in:
commit
fd13ed78ab
@ -244,7 +244,7 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
ProtoSize::add_string_field(total_size, 1, this->device_class);
|
||||
@ -265,7 +265,7 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
@ -293,7 +293,7 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
|
||||
@ -319,10 +319,10 @@ void CoverStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(6, this->device_id);
|
||||
}
|
||||
void CoverStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_state));
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->position);
|
||||
ProtoSize::add_float_field(total_size, 1, this->tilt);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -394,7 +394,7 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation);
|
||||
@ -428,7 +428,7 @@ void FanStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
#endif
|
||||
}
|
||||
void FanStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->oscillating);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->speed));
|
||||
@ -532,7 +532,7 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
if (!this->supported_color_modes.empty()) {
|
||||
@ -544,8 +544,8 @@ void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->min_mireds != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->max_mireds != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->min_mireds);
|
||||
ProtoSize::add_float_field(total_size, 1, this->max_mireds);
|
||||
if (!this->effects.empty()) {
|
||||
for (const auto &it : this->effects) {
|
||||
ProtoSize::add_string_field_repeated(total_size, 1, it);
|
||||
@ -577,18 +577,18 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(14, this->device_id);
|
||||
}
|
||||
void LightStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->brightness);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->color_mode));
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->color_brightness != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->cold_white != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->warm_white != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->color_brightness);
|
||||
ProtoSize::add_float_field(total_size, 1, this->red);
|
||||
ProtoSize::add_float_field(total_size, 1, this->green);
|
||||
ProtoSize::add_float_field(total_size, 1, this->blue);
|
||||
ProtoSize::add_float_field(total_size, 1, this->white);
|
||||
ProtoSize::add_float_field(total_size, 1, this->color_temperature);
|
||||
ProtoSize::add_float_field(total_size, 1, this->cold_white);
|
||||
ProtoSize::add_float_field(total_size, 1, this->warm_white);
|
||||
ProtoSize::add_string_field(total_size, 1, this->effect);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -719,7 +719,7 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -742,8 +742,8 @@ void SensorStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void SensorStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_float_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -767,7 +767,7 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -787,7 +787,7 @@ void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(3, this->device_id);
|
||||
}
|
||||
void SwitchStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -833,7 +833,7 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -853,7 +853,7 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void TextSensorStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
@ -977,7 +977,7 @@ bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
||||
}
|
||||
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
|
||||
void GetTimeResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds);
|
||||
}
|
||||
#ifdef USE_API_SERVICES
|
||||
bool ListEntitiesServicesArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||
@ -1017,7 +1017,7 @@ void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_repeated_message(total_size, 1, this->args);
|
||||
}
|
||||
bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||
@ -1090,7 +1090,7 @@ void ExecuteServiceArgument::encode(ProtoWriteBuffer buffer) const {
|
||||
void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_bool_field(total_size, 1, this->bool_);
|
||||
ProtoSize::add_int32_field(total_size, 1, this->legacy_int);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->float_ != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->float_);
|
||||
ProtoSize::add_string_field(total_size, 1, this->string_);
|
||||
ProtoSize::add_sint32_field(total_size, 1, this->int_);
|
||||
if (!this->bool_array.empty()) {
|
||||
@ -1151,7 +1151,7 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||
@ -1170,7 +1170,7 @@ void CameraImageResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void CameraImageResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->data);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->done);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
@ -1236,7 +1236,7 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature);
|
||||
@ -1246,9 +1246,9 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
|
||||
}
|
||||
}
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_min_temperature != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_max_temperature != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_target_temperature_step != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->visual_min_temperature);
|
||||
ProtoSize::add_float_field(total_size, 1, this->visual_max_temperature);
|
||||
ProtoSize::add_float_field(total_size, 1, this->visual_target_temperature_step);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->supports_action);
|
||||
if (!this->supported_fan_modes.empty()) {
|
||||
@ -1281,11 +1281,11 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 2, this->icon);
|
||||
#endif
|
||||
ProtoSize::add_enum_field(total_size, 2, static_cast<uint32_t>(this->entity_category));
|
||||
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_current_temperature_step != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 2, this->visual_current_temperature_step);
|
||||
ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity);
|
||||
ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_min_humidity != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_max_humidity != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 2, this->visual_min_humidity);
|
||||
ProtoSize::add_float_field(total_size, 2, this->visual_max_humidity);
|
||||
#ifdef USE_DEVICES
|
||||
ProtoSize::add_uint32_field(total_size, 2, this->device_id);
|
||||
#endif
|
||||
@ -1311,12 +1311,12 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
#endif
|
||||
}
|
||||
void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->current_temperature != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->current_temperature);
|
||||
ProtoSize::add_float_field(total_size, 1, this->target_temperature);
|
||||
ProtoSize::add_float_field(total_size, 1, this->target_temperature_low);
|
||||
ProtoSize::add_float_field(total_size, 1, this->target_temperature_high);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->action));
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->fan_mode));
|
||||
@ -1324,8 +1324,8 @@ void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->preset));
|
||||
ProtoSize::add_string_field(total_size, 1, this->custom_preset);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->current_humidity != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_humidity != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->current_humidity);
|
||||
ProtoSize::add_float_field(total_size, 1, this->target_humidity);
|
||||
#ifdef USE_DEVICES
|
||||
ProtoSize::add_uint32_field(total_size, 2, this->device_id);
|
||||
#endif
|
||||
@ -1445,15 +1445,15 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||
#endif
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->min_value != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->max_value != 0.0f);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->step != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->min_value);
|
||||
ProtoSize::add_float_field(total_size, 1, this->max_value);
|
||||
ProtoSize::add_float_field(total_size, 1, this->step);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||
ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
|
||||
@ -1468,8 +1468,8 @@ void NumberStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void NumberStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_float_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -1517,7 +1517,7 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -1541,7 +1541,7 @@ void SelectStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void SelectStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
@ -1599,7 +1599,7 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -1624,7 +1624,7 @@ void SirenStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(3, this->device_id);
|
||||
}
|
||||
void SirenStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -1703,7 +1703,7 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -1725,7 +1725,7 @@ void LockStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(3, this->device_id);
|
||||
}
|
||||
void LockStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -1784,7 +1784,7 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -1882,7 +1882,7 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -1904,9 +1904,9 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(5, this->device_id);
|
||||
}
|
||||
void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->volume);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->muted);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -2508,7 +2508,7 @@ void VoiceAssistantAudioSettings::encode(ProtoWriteBuffer buffer) const {
|
||||
void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->auto_gain);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->volume_multiplier != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->volume_multiplier);
|
||||
}
|
||||
void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_bool(1, this->start);
|
||||
@ -2750,7 +2750,7 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons
|
||||
}
|
||||
void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -2771,7 +2771,7 @@ void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(3, this->device_id);
|
||||
}
|
||||
void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -2830,7 +2830,7 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -2853,7 +2853,7 @@ void TextStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void TextStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
@ -2906,7 +2906,7 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -2927,7 +2927,7 @@ void DateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(6, this->device_id);
|
||||
}
|
||||
void DateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->year);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->month);
|
||||
@ -2981,7 +2981,7 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -3002,7 +3002,7 @@ void TimeStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(6, this->device_id);
|
||||
}
|
||||
void TimeStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->hour);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->minute);
|
||||
@ -3060,7 +3060,7 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -3084,7 +3084,7 @@ void EventResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(3, this->device_id);
|
||||
}
|
||||
void EventResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->event_type);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -3110,7 +3110,7 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -3133,8 +3133,8 @@ void ValveStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void ValveStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_float_field(total_size, 1, this->position);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
@ -3185,7 +3185,7 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -3204,9 +3204,9 @@ void DateTimeStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_uint32(4, this->device_id);
|
||||
}
|
||||
void DateTimeStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds);
|
||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||
}
|
||||
bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||
@ -3251,7 +3251,7 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
}
|
||||
void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
||||
#ifdef USE_ENTITY_ICON
|
||||
@ -3280,11 +3280,11 @@ void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||
#endif
|
||||
}
|
||||
void UpdateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
||||
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->in_progress);
|
||||
ProtoSize::add_bool_field(total_size, 1, this->has_progress);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->progress != 0.0f);
|
||||
ProtoSize::add_float_field(total_size, 1, this->progress);
|
||||
ProtoSize::add_string_field(total_size, 1, this->current_version);
|
||||
ProtoSize::add_string_field(total_size, 1, this->latest_version);
|
||||
ProtoSize::add_string_field(total_size, 1, this->title);
|
||||
|
@ -540,6 +540,60 @@ class ProtoSize {
|
||||
total_size += field_id_size + NumBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of a float field to the total message size
|
||||
*/
|
||||
static inline void add_float_field(uint32_t &total_size, uint32_t field_id_size, float value) {
|
||||
if (value != 0.0f) {
|
||||
total_size += field_id_size + 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of a double field to the total message size
|
||||
*/
|
||||
static inline void add_double_field(uint32_t &total_size, uint32_t field_id_size, double value) {
|
||||
if (value != 0.0) {
|
||||
total_size += field_id_size + 8;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of a fixed32 field to the total message size
|
||||
*/
|
||||
static inline void add_fixed32_field(uint32_t &total_size, uint32_t field_id_size, uint32_t value) {
|
||||
if (value != 0) {
|
||||
total_size += field_id_size + 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of a fixed64 field to the total message size
|
||||
*/
|
||||
static inline void add_fixed64_field(uint32_t &total_size, uint32_t field_id_size, uint64_t value) {
|
||||
if (value != 0) {
|
||||
total_size += field_id_size + 8;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of a sfixed32 field to the total message size
|
||||
*/
|
||||
static inline void add_sfixed32_field(uint32_t &total_size, uint32_t field_id_size, int32_t value) {
|
||||
if (value != 0) {
|
||||
total_size += field_id_size + 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of a sfixed64 field to the total message size
|
||||
*/
|
||||
static inline void add_sfixed64_field(uint32_t &total_size, uint32_t field_id_size, int64_t value) {
|
||||
if (value != 0) {
|
||||
total_size += field_id_size + 8;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculates and adds the size of an enum field to the total message size
|
||||
*
|
||||
|
@ -264,26 +264,6 @@ class TypeInfo(ABC):
|
||||
value = value_expr if value_expr else name
|
||||
return f"ProtoSize::{method}(total_size, {field_id_size}, {value});"
|
||||
|
||||
def _get_fixed_size_calculation(
|
||||
self, name: str, force: bool, num_bytes: int, zero_check: str
|
||||
) -> str:
|
||||
"""Helper for fixed-size field calculations.
|
||||
|
||||
Args:
|
||||
name: Field name
|
||||
force: Whether this is for a repeated field
|
||||
num_bytes: Number of bytes (4 or 8)
|
||||
zero_check: Expression to check for zero value (e.g., "!= 0.0f")
|
||||
"""
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
# Fixed-size repeated fields are handled differently in RepeatedTypeInfo
|
||||
# so we should never get force=True here
|
||||
assert not force, (
|
||||
"Fixed-size repeated fields should be handled by RepeatedTypeInfo"
|
||||
)
|
||||
method = f"add_fixed_field<{num_bytes}>"
|
||||
return f"ProtoSize::{method}(total_size, {field_id_size}, {name} {zero_check});"
|
||||
|
||||
@abstractmethod
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
"""Calculate the size needed for encoding this field.
|
||||
@ -369,7 +349,8 @@ class DoubleType(TypeInfo):
|
||||
return o
|
||||
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
return self._get_fixed_size_calculation(name, force, 8, "!= 0.0")
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
return f"ProtoSize::add_double_field(total_size, {field_id_size}, {name});"
|
||||
|
||||
def get_fixed_size_bytes(self) -> int:
|
||||
return 8
|
||||
@ -392,7 +373,8 @@ class FloatType(TypeInfo):
|
||||
return o
|
||||
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
return self._get_fixed_size_calculation(name, force, 4, "!= 0.0f")
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
return f"ProtoSize::add_float_field(total_size, {field_id_size}, {name});"
|
||||
|
||||
def get_fixed_size_bytes(self) -> int:
|
||||
return 4
|
||||
@ -475,7 +457,8 @@ class Fixed64Type(TypeInfo):
|
||||
return o
|
||||
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
return self._get_fixed_size_calculation(name, force, 8, "!= 0")
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
return f"ProtoSize::add_fixed64_field(total_size, {field_id_size}, {name});"
|
||||
|
||||
def get_fixed_size_bytes(self) -> int:
|
||||
return 8
|
||||
@ -498,7 +481,8 @@ class Fixed32Type(TypeInfo):
|
||||
return o
|
||||
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
return self._get_fixed_size_calculation(name, force, 4, "!= 0")
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
return f"ProtoSize::add_fixed32_field(total_size, {field_id_size}, {name});"
|
||||
|
||||
def get_fixed_size_bytes(self) -> int:
|
||||
return 4
|
||||
@ -687,7 +671,8 @@ class SFixed32Type(TypeInfo):
|
||||
return o
|
||||
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
return self._get_fixed_size_calculation(name, force, 4, "!= 0")
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
return f"ProtoSize::add_sfixed32_field(total_size, {field_id_size}, {name});"
|
||||
|
||||
def get_fixed_size_bytes(self) -> int:
|
||||
return 4
|
||||
@ -710,7 +695,8 @@ class SFixed64Type(TypeInfo):
|
||||
return o
|
||||
|
||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||
return self._get_fixed_size_calculation(name, force, 8, "!= 0")
|
||||
field_id_size = self.calculate_field_id_size()
|
||||
return f"ProtoSize::add_sfixed64_field(total_size, {field_id_size}, {name});"
|
||||
|
||||
def get_fixed_size_bytes(self) -> int:
|
||||
return 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user