mirror of
https://github.com/esphome/esphome.git
synced 2025-08-03 08:57:47 +00:00
Reduce API Flash
This commit is contained in:
parent
a240f0af90
commit
78a82ed46e
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@
|
||||
|
||||
#include "proto.h"
|
||||
#include "api_pb2_size.h"
|
||||
#include "proto_templates.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace api {
|
||||
@ -338,6 +339,9 @@ class HelloResponse : public ProtoMessage {
|
||||
uint32_t api_version_minor{0};
|
||||
std::string server_info{};
|
||||
std::string name{};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -373,6 +377,9 @@ class ConnectResponse : public ProtoMessage {
|
||||
const char *message_name() const override { return "connect_response"; }
|
||||
#endif
|
||||
bool invalid_password{false};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -402,6 +409,8 @@ class DisconnectResponse : public ProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "disconnect_response"; }
|
||||
#endif
|
||||
static constexpr size_t FIELD_COUNT = 0;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void dump_to(std::string &out) const override;
|
||||
#endif
|
||||
@ -428,6 +437,8 @@ class PingResponse : public ProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "ping_response"; }
|
||||
#endif
|
||||
static constexpr size_t FIELD_COUNT = 0;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void dump_to(std::string &out) const override;
|
||||
#endif
|
||||
@ -505,6 +516,10 @@ class DeviceInfoResponse : public ProtoMessage {
|
||||
std::vector<DeviceInfo> devices{};
|
||||
std::vector<AreaInfo> areas{};
|
||||
AreaInfo area{};
|
||||
static const FieldMeta FIELDS[19];
|
||||
static constexpr size_t FIELD_COUNT = 19;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[2];
|
||||
static constexpr size_t REPEATED_COUNT = 2;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -535,6 +550,8 @@ class ListEntitiesDoneResponse : public ProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "list_entities_done_response"; }
|
||||
#endif
|
||||
static constexpr size_t FIELD_COUNT = 0;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void dump_to(std::string &out) const override;
|
||||
#endif
|
||||
@ -564,6 +581,9 @@ class ListEntitiesBinarySensorResponse : public InfoResponseProtoMessage {
|
||||
#endif
|
||||
std::string device_class{};
|
||||
bool is_status_binary_sensor{false};
|
||||
static const FieldMeta FIELDS[10];
|
||||
static constexpr size_t FIELD_COUNT = 10;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -584,6 +604,9 @@ class BinarySensorStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
bool state{false};
|
||||
bool missing_state{false};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -608,6 +631,9 @@ class ListEntitiesCoverResponse : public InfoResponseProtoMessage {
|
||||
bool supports_tilt{false};
|
||||
std::string device_class{};
|
||||
bool supports_stop{false};
|
||||
static const FieldMeta FIELDS[13];
|
||||
static constexpr size_t FIELD_COUNT = 13;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -630,6 +656,9 @@ class CoverStateResponse : public StateResponseProtoMessage {
|
||||
float position{0.0f};
|
||||
float tilt{0.0f};
|
||||
enums::CoverOperation current_operation{};
|
||||
static const FieldMeta FIELDS[6];
|
||||
static constexpr size_t FIELD_COUNT = 6;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -679,6 +708,10 @@ class ListEntitiesFanResponse : public InfoResponseProtoMessage {
|
||||
bool supports_direction{false};
|
||||
int32_t supported_speed_count{0};
|
||||
std::vector<std::string> supported_preset_modes{};
|
||||
static const FieldMeta FIELDS[12];
|
||||
static constexpr size_t FIELD_COUNT = 12;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -703,6 +736,9 @@ class FanStateResponse : public StateResponseProtoMessage {
|
||||
enums::FanDirection direction{};
|
||||
int32_t speed_level{0};
|
||||
std::string preset_mode{};
|
||||
static const FieldMeta FIELDS[8];
|
||||
static constexpr size_t FIELD_COUNT = 8;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -762,6 +798,10 @@ class ListEntitiesLightResponse : public InfoResponseProtoMessage {
|
||||
float min_mireds{0.0f};
|
||||
float max_mireds{0.0f};
|
||||
std::vector<std::string> effects{};
|
||||
static const FieldMeta FIELDS[14];
|
||||
static constexpr size_t FIELD_COUNT = 14;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[2];
|
||||
static constexpr size_t REPEATED_COUNT = 2;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -792,6 +832,9 @@ class LightStateResponse : public StateResponseProtoMessage {
|
||||
float cold_white{0.0f};
|
||||
float warm_white{0.0f};
|
||||
std::string effect{};
|
||||
static const FieldMeta FIELDS[14];
|
||||
static constexpr size_t FIELD_COUNT = 14;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -863,6 +906,9 @@ class ListEntitiesSensorResponse : public InfoResponseProtoMessage {
|
||||
std::string device_class{};
|
||||
enums::SensorStateClass state_class{};
|
||||
enums::SensorLastResetType legacy_last_reset_type{};
|
||||
static const FieldMeta FIELDS[14];
|
||||
static constexpr size_t FIELD_COUNT = 14;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -883,6 +929,9 @@ class SensorStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
float state{0.0f};
|
||||
bool missing_state{false};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -904,6 +953,9 @@ class ListEntitiesSwitchResponse : public InfoResponseProtoMessage {
|
||||
#endif
|
||||
bool assumed_state{false};
|
||||
std::string device_class{};
|
||||
static const FieldMeta FIELDS[10];
|
||||
static constexpr size_t FIELD_COUNT = 10;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -923,6 +975,9 @@ class SwitchStateResponse : public StateResponseProtoMessage {
|
||||
const char *message_name() const override { return "switch_state_response"; }
|
||||
#endif
|
||||
bool state{false};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -962,6 +1017,9 @@ class ListEntitiesTextSensorResponse : public InfoResponseProtoMessage {
|
||||
const char *message_name() const override { return "list_entities_text_sensor_response"; }
|
||||
#endif
|
||||
std::string device_class{};
|
||||
static const FieldMeta FIELDS[9];
|
||||
static constexpr size_t FIELD_COUNT = 9;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -982,6 +1040,9 @@ class TextSensorStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
std::string state{};
|
||||
bool missing_state{false};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1022,6 +1083,9 @@ class SubscribeLogsResponse : public ProtoMessage {
|
||||
enums::LogLevel level{};
|
||||
std::string message{};
|
||||
bool send_failed{false};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1058,6 +1122,9 @@ class NoiseEncryptionSetKeyResponse : public ProtoMessage {
|
||||
const char *message_name() const override { return "noise_encryption_set_key_response"; }
|
||||
#endif
|
||||
bool success{false};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1106,6 +1173,10 @@ class HomeassistantServiceResponse : public ProtoMessage {
|
||||
std::vector<HomeassistantServiceMap> data_template{};
|
||||
std::vector<HomeassistantServiceMap> variables{};
|
||||
bool is_event{false};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[3];
|
||||
static constexpr size_t REPEATED_COUNT = 3;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1139,6 +1210,9 @@ class SubscribeHomeAssistantStateResponse : public ProtoMessage {
|
||||
std::string entity_id{};
|
||||
std::string attribute{};
|
||||
bool once{false};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1159,6 +1233,9 @@ class HomeAssistantStateResponse : public ProtoMessage {
|
||||
std::string entity_id{};
|
||||
std::string state{};
|
||||
std::string attribute{};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1189,6 +1266,9 @@ class GetTimeResponse : public ProtoMessage {
|
||||
const char *message_name() const override { return "get_time_response"; }
|
||||
#endif
|
||||
uint32_t epoch_seconds{0};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1222,6 +1302,10 @@ class ListEntitiesServicesResponse : public ProtoMessage {
|
||||
std::string name{};
|
||||
uint32_t key{0};
|
||||
std::vector<ListEntitiesServicesArgument> args{};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1281,6 +1365,9 @@ class ListEntitiesCameraResponse : public InfoResponseProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "list_entities_camera_response"; }
|
||||
#endif
|
||||
static const FieldMeta FIELDS[8];
|
||||
static constexpr size_t FIELD_COUNT = 8;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1302,6 +1389,9 @@ class CameraImageResponse : public ProtoMessage {
|
||||
uint32_t key{0};
|
||||
std::string data{};
|
||||
bool done{false};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1358,6 +1448,10 @@ class ListEntitiesClimateResponse : public InfoResponseProtoMessage {
|
||||
bool supports_target_humidity{false};
|
||||
float visual_min_humidity{0.0f};
|
||||
float visual_max_humidity{0.0f};
|
||||
static const FieldMeta FIELDS[20];
|
||||
static constexpr size_t FIELD_COUNT = 20;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[6];
|
||||
static constexpr size_t REPEATED_COUNT = 6;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1390,6 +1484,9 @@ class ClimateStateResponse : public StateResponseProtoMessage {
|
||||
std::string custom_preset{};
|
||||
float current_humidity{0.0f};
|
||||
float target_humidity{0.0f};
|
||||
static const FieldMeta FIELDS[16];
|
||||
static constexpr size_t FIELD_COUNT = 16;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1457,6 +1554,9 @@ class ListEntitiesNumberResponse : public InfoResponseProtoMessage {
|
||||
std::string unit_of_measurement{};
|
||||
enums::NumberMode mode{};
|
||||
std::string device_class{};
|
||||
static const FieldMeta FIELDS[14];
|
||||
static constexpr size_t FIELD_COUNT = 14;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1477,6 +1577,9 @@ class NumberStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
float state{0.0f};
|
||||
bool missing_state{false};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1515,6 +1618,10 @@ class ListEntitiesSelectResponse : public InfoResponseProtoMessage {
|
||||
const char *message_name() const override { return "list_entities_select_response"; }
|
||||
#endif
|
||||
std::vector<std::string> options{};
|
||||
static const FieldMeta FIELDS[8];
|
||||
static constexpr size_t FIELD_COUNT = 8;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1535,6 +1642,9 @@ class SelectStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
std::string state{};
|
||||
bool missing_state{false};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1577,6 +1687,10 @@ class ListEntitiesSirenResponse : public InfoResponseProtoMessage {
|
||||
std::vector<std::string> tones{};
|
||||
bool supports_duration{false};
|
||||
bool supports_volume{false};
|
||||
static const FieldMeta FIELDS[10];
|
||||
static constexpr size_t FIELD_COUNT = 10;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1596,6 +1710,9 @@ class SirenStateResponse : public StateResponseProtoMessage {
|
||||
const char *message_name() const override { return "siren_state_response"; }
|
||||
#endif
|
||||
bool state{false};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1646,6 +1763,9 @@ class ListEntitiesLockResponse : public InfoResponseProtoMessage {
|
||||
bool supports_open{false};
|
||||
bool requires_code{false};
|
||||
std::string code_format{};
|
||||
static const FieldMeta FIELDS[12];
|
||||
static constexpr size_t FIELD_COUNT = 12;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1665,6 +1785,9 @@ class LockStateResponse : public StateResponseProtoMessage {
|
||||
const char *message_name() const override { return "lock_state_response"; }
|
||||
#endif
|
||||
enums::LockState state{};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1707,6 +1830,9 @@ class ListEntitiesButtonResponse : public InfoResponseProtoMessage {
|
||||
const char *message_name() const override { return "list_entities_button_response"; }
|
||||
#endif
|
||||
std::string device_class{};
|
||||
static const FieldMeta FIELDS[9];
|
||||
static constexpr size_t FIELD_COUNT = 9;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1763,6 +1889,10 @@ class ListEntitiesMediaPlayerResponse : public InfoResponseProtoMessage {
|
||||
#endif
|
||||
bool supports_pause{false};
|
||||
std::vector<MediaPlayerSupportedFormat> supported_formats{};
|
||||
static const FieldMeta FIELDS[9];
|
||||
static constexpr size_t FIELD_COUNT = 9;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1784,6 +1914,9 @@ class MediaPlayerStateResponse : public StateResponseProtoMessage {
|
||||
enums::MediaPlayerState state{};
|
||||
float volume{0.0f};
|
||||
bool muted{false};
|
||||
static const FieldMeta FIELDS[5];
|
||||
static constexpr size_t FIELD_COUNT = 5;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1869,6 +2002,10 @@ class BluetoothLEAdvertisementResponse : public ProtoMessage {
|
||||
std::vector<BluetoothServiceData> service_data{};
|
||||
std::vector<BluetoothServiceData> manufacturer_data{};
|
||||
uint32_t address_type{0};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[3];
|
||||
static constexpr size_t REPEATED_COUNT = 3;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1903,6 +2040,9 @@ class BluetoothLERawAdvertisementsResponse : public ProtoMessage {
|
||||
const char *message_name() const override { return "bluetooth_le_raw_advertisements_response"; }
|
||||
#endif
|
||||
std::vector<BluetoothLERawAdvertisement> advertisements{};
|
||||
static constexpr size_t FIELD_COUNT = 0;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -1943,6 +2083,9 @@ class BluetoothDeviceConnectionResponse : public ProtoMessage {
|
||||
bool connected{false};
|
||||
uint32_t mtu{0};
|
||||
int32_t error{0};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2022,6 +2165,10 @@ class BluetoothGATTGetServicesResponse : public ProtoMessage {
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
std::vector<BluetoothGATTService> services{};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2040,6 +2187,9 @@ class BluetoothGATTGetServicesDoneResponse : public ProtoMessage {
|
||||
const char *message_name() const override { return "bluetooth_gatt_get_services_done_response"; }
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2077,6 +2227,9 @@ class BluetoothGATTReadResponse : public ProtoMessage {
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
std::string data{};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2175,6 +2328,9 @@ class BluetoothGATTNotifyDataResponse : public ProtoMessage {
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
std::string data{};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2208,6 +2364,10 @@ class BluetoothConnectionsFreeResponse : public ProtoMessage {
|
||||
uint32_t free{0};
|
||||
uint32_t limit{0};
|
||||
std::vector<uint64_t> allocated{};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2227,6 +2387,9 @@ class BluetoothGATTErrorResponse : public ProtoMessage {
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
int32_t error{0};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2245,6 +2408,9 @@ class BluetoothGATTWriteResponse : public ProtoMessage {
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2263,6 +2429,9 @@ class BluetoothGATTNotifyResponse : public ProtoMessage {
|
||||
#endif
|
||||
uint64_t address{0};
|
||||
uint32_t handle{0};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2282,6 +2451,9 @@ class BluetoothDevicePairingResponse : public ProtoMessage {
|
||||
uint64_t address{0};
|
||||
bool paired{false};
|
||||
int32_t error{0};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2301,6 +2473,9 @@ class BluetoothDeviceUnpairingResponse : public ProtoMessage {
|
||||
uint64_t address{0};
|
||||
bool success{false};
|
||||
int32_t error{0};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2333,6 +2508,9 @@ class BluetoothDeviceClearCacheResponse : public ProtoMessage {
|
||||
uint64_t address{0};
|
||||
bool success{false};
|
||||
int32_t error{0};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2351,6 +2529,9 @@ class BluetoothScannerStateResponse : public ProtoMessage {
|
||||
#endif
|
||||
enums::BluetoothScannerState state{};
|
||||
enums::BluetoothScannerMode mode{};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2443,6 +2624,9 @@ class VoiceAssistantResponse : public ProtoMessage {
|
||||
#endif
|
||||
uint32_t port{0};
|
||||
bool error{false};
|
||||
static const FieldMeta FIELDS[2];
|
||||
static constexpr size_t FIELD_COUNT = 2;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2474,6 +2658,10 @@ class VoiceAssistantEventResponse : public ProtoMessage {
|
||||
#endif
|
||||
enums::VoiceAssistantEvent event_type{};
|
||||
std::vector<VoiceAssistantEventData> data{};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2516,6 +2704,9 @@ class VoiceAssistantTimerEventResponse : public ProtoMessage {
|
||||
uint32_t total_seconds{0};
|
||||
uint32_t seconds_left{0};
|
||||
bool is_active{false};
|
||||
static const FieldMeta FIELDS[6];
|
||||
static constexpr size_t FIELD_COUNT = 6;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2601,6 +2792,10 @@ class VoiceAssistantConfigurationResponse : public ProtoMessage {
|
||||
std::vector<VoiceAssistantWakeWord> available_wake_words{};
|
||||
std::vector<std::string> active_wake_words{};
|
||||
uint32_t max_active_wake_words{0};
|
||||
static const FieldMeta FIELDS[1];
|
||||
static constexpr size_t FIELD_COUNT = 1;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[2];
|
||||
static constexpr size_t REPEATED_COUNT = 2;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2640,6 +2835,9 @@ class ListEntitiesAlarmControlPanelResponse : public InfoResponseProtoMessage {
|
||||
uint32_t supported_features{0};
|
||||
bool requires_code{false};
|
||||
bool requires_code_to_arm{false};
|
||||
static const FieldMeta FIELDS[11];
|
||||
static constexpr size_t FIELD_COUNT = 11;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2659,6 +2857,9 @@ class AlarmControlPanelStateResponse : public StateResponseProtoMessage {
|
||||
const char *message_name() const override { return "alarm_control_panel_state_response"; }
|
||||
#endif
|
||||
enums::AlarmControlPanelState state{};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2703,6 +2904,9 @@ class ListEntitiesTextResponse : public InfoResponseProtoMessage {
|
||||
uint32_t max_length{0};
|
||||
std::string pattern{};
|
||||
enums::TextMode mode{};
|
||||
static const FieldMeta FIELDS[12];
|
||||
static constexpr size_t FIELD_COUNT = 12;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2723,6 +2927,9 @@ class TextStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
std::string state{};
|
||||
bool missing_state{false};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2762,6 +2969,9 @@ class ListEntitiesDateResponse : public InfoResponseProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "list_entities_date_response"; }
|
||||
#endif
|
||||
static const FieldMeta FIELDS[8];
|
||||
static constexpr size_t FIELD_COUNT = 8;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2784,6 +2994,9 @@ class DateStateResponse : public StateResponseProtoMessage {
|
||||
uint32_t year{0};
|
||||
uint32_t month{0};
|
||||
uint32_t day{0};
|
||||
static const FieldMeta FIELDS[6];
|
||||
static constexpr size_t FIELD_COUNT = 6;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2824,6 +3037,9 @@ class ListEntitiesTimeResponse : public InfoResponseProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "list_entities_time_response"; }
|
||||
#endif
|
||||
static const FieldMeta FIELDS[8];
|
||||
static constexpr size_t FIELD_COUNT = 8;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2846,6 +3062,9 @@ class TimeStateResponse : public StateResponseProtoMessage {
|
||||
uint32_t hour{0};
|
||||
uint32_t minute{0};
|
||||
uint32_t second{0};
|
||||
static const FieldMeta FIELDS[6];
|
||||
static constexpr size_t FIELD_COUNT = 6;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2888,6 +3107,10 @@ class ListEntitiesEventResponse : public InfoResponseProtoMessage {
|
||||
#endif
|
||||
std::string device_class{};
|
||||
std::vector<std::string> event_types{};
|
||||
static const FieldMeta FIELDS[9];
|
||||
static constexpr size_t FIELD_COUNT = 9;
|
||||
static const RepeatedFieldMeta REPEATED_FIELDS[1];
|
||||
static constexpr size_t REPEATED_COUNT = 1;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2907,6 +3130,9 @@ class EventResponse : public StateResponseProtoMessage {
|
||||
const char *message_name() const override { return "event_response"; }
|
||||
#endif
|
||||
std::string event_type{};
|
||||
static const FieldMeta FIELDS[3];
|
||||
static constexpr size_t FIELD_COUNT = 3;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2931,6 +3157,9 @@ class ListEntitiesValveResponse : public InfoResponseProtoMessage {
|
||||
bool assumed_state{false};
|
||||
bool supports_position{false};
|
||||
bool supports_stop{false};
|
||||
static const FieldMeta FIELDS[12];
|
||||
static constexpr size_t FIELD_COUNT = 12;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2951,6 +3180,9 @@ class ValveStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
float position{0.0f};
|
||||
enums::ValveOperation current_operation{};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -2991,6 +3223,9 @@ class ListEntitiesDateTimeResponse : public InfoResponseProtoMessage {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
const char *message_name() const override { return "list_entities_date_time_response"; }
|
||||
#endif
|
||||
static const FieldMeta FIELDS[8];
|
||||
static constexpr size_t FIELD_COUNT = 8;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -3011,6 +3246,9 @@ class DateTimeStateResponse : public StateResponseProtoMessage {
|
||||
#endif
|
||||
bool missing_state{false};
|
||||
uint32_t epoch_seconds{0};
|
||||
static const FieldMeta FIELDS[4];
|
||||
static constexpr size_t FIELD_COUNT = 4;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -3049,6 +3287,9 @@ class ListEntitiesUpdateResponse : public InfoResponseProtoMessage {
|
||||
const char *message_name() const override { return "list_entities_update_response"; }
|
||||
#endif
|
||||
std::string device_class{};
|
||||
static const FieldMeta FIELDS[9];
|
||||
static constexpr size_t FIELD_COUNT = 9;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
@ -3076,6 +3317,9 @@ class UpdateStateResponse : public StateResponseProtoMessage {
|
||||
std::string title{};
|
||||
std::string release_summary{};
|
||||
std::string release_url{};
|
||||
static const FieldMeta FIELDS[11];
|
||||
static constexpr size_t FIELD_COUNT = 11;
|
||||
static constexpr size_t REPEATED_COUNT = 0;
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
void calculate_size(uint32_t &total_size) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <cinttypes>
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "api_pb2_size.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace api {
|
||||
@ -89,5 +90,362 @@ std::string ProtoMessage::dump() const {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Type-specific encoding functions
|
||||
void encode_string_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *str = static_cast<const std::string *>(field_ptr);
|
||||
buffer.encode_string(field_num, *str);
|
||||
}
|
||||
|
||||
void encode_fixed32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const uint32_t *>(field_ptr);
|
||||
buffer.encode_fixed32(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_bool_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const bool *>(field_ptr);
|
||||
buffer.encode_bool(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_float_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const float *>(field_ptr);
|
||||
buffer.encode_float(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_int32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const int32_t *>(field_ptr);
|
||||
buffer.encode_int32(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_uint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const uint32_t *>(field_ptr);
|
||||
buffer.encode_uint32(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_int64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const int64_t *>(field_ptr);
|
||||
buffer.encode_int64(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_uint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const uint64_t *>(field_ptr);
|
||||
buffer.encode_uint64(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_sint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const int32_t *>(field_ptr);
|
||||
buffer.encode_sint32(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_sint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const int64_t *>(field_ptr);
|
||||
buffer.encode_sint64(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_fixed64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const uint64_t *>(field_ptr);
|
||||
buffer.encode_fixed64(field_num, *val);
|
||||
}
|
||||
|
||||
void encode_double_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const double *>(field_ptr);
|
||||
union {
|
||||
double value;
|
||||
uint64_t raw;
|
||||
} u{};
|
||||
u.value = *val;
|
||||
buffer.encode_fixed64(field_num, u.raw);
|
||||
}
|
||||
|
||||
void encode_bytes_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *str = static_cast<const std::string *>(field_ptr);
|
||||
buffer.encode_bytes(field_num, reinterpret_cast<const uint8_t *>(str->data()), str->size());
|
||||
}
|
||||
|
||||
// Type-specific size calculation functions
|
||||
void size_string_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *str = static_cast<const std::string *>(field_ptr);
|
||||
ProtoSize::add_string_field(total_size, 1, *str, force);
|
||||
}
|
||||
|
||||
void size_fixed32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const uint32_t *>(field_ptr);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, *val != 0 || force, force);
|
||||
}
|
||||
|
||||
void size_bool_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const bool *>(field_ptr);
|
||||
ProtoSize::add_bool_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_float_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const float *>(field_ptr);
|
||||
ProtoSize::add_fixed_field<4>(total_size, 1, *val != 0.0f || force, force);
|
||||
}
|
||||
|
||||
void size_int32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const int32_t *>(field_ptr);
|
||||
ProtoSize::add_int32_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_uint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const uint32_t *>(field_ptr);
|
||||
ProtoSize::add_uint32_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_int64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const int64_t *>(field_ptr);
|
||||
ProtoSize::add_int64_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_uint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const uint64_t *>(field_ptr);
|
||||
ProtoSize::add_uint64_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_sint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const int32_t *>(field_ptr);
|
||||
ProtoSize::add_sint32_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_sint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const int64_t *>(field_ptr);
|
||||
ProtoSize::add_sint64_field(total_size, 1, *val, force);
|
||||
}
|
||||
|
||||
void size_fixed64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const uint64_t *>(field_ptr);
|
||||
ProtoSize::add_fixed_field<8>(total_size, 1, *val != 0 || force, force);
|
||||
}
|
||||
|
||||
void size_double_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const double *>(field_ptr);
|
||||
ProtoSize::add_fixed_field<8>(total_size, 1, *val != 0.0 || force, force);
|
||||
}
|
||||
|
||||
void size_bytes_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *str = static_cast<const std::string *>(field_ptr);
|
||||
ProtoSize::add_string_field(total_size, 1, *str, force);
|
||||
}
|
||||
|
||||
// Template functions are now in the header file for proper instantiation
|
||||
|
||||
// Repeated field encoding functions
|
||||
void encode_repeated_string_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<std::string> *>(field_ptr);
|
||||
for (const auto &item : *vec) {
|
||||
buffer.encode_string(field_num, item, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_bool_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<bool> *>(field_ptr);
|
||||
for (bool val : *vec) {
|
||||
buffer.encode_bool(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_uint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_uint32(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_int32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_int32(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_uint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_uint64(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_int64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_int64(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_sint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_sint32(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_sint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_sint64(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_fixed32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_fixed32(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_fixed64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_fixed64(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_float_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<float> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_float(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void encode_repeated_double_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<double> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
union {
|
||||
double value;
|
||||
uint64_t raw;
|
||||
} u{};
|
||||
u.value = val;
|
||||
buffer.encode_fixed64(field_num, u.raw, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Template repeated field functions moved to header
|
||||
|
||||
// Repeated field size calculation functions
|
||||
void size_repeated_string_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<std::string> *>(field_ptr);
|
||||
for (const auto &item : *vec) {
|
||||
ProtoSize::add_string_field(total_size, 1, item, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_bool_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<bool> *>(field_ptr);
|
||||
for (bool val : *vec) {
|
||||
ProtoSize::add_bool_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_uint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_uint32_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_int32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_int32_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_uint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_uint64_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_int64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_int64_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_sint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int32_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_sint32_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_sint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<int64_t> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_sint64_field(total_size, 1, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_fixed32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint32_t> *>(field_ptr);
|
||||
size_t count = vec->size();
|
||||
if (count > 0) {
|
||||
total_size += count * (1 + 4); // field_id + 4 bytes per item
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_fixed64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<uint64_t> *>(field_ptr);
|
||||
size_t count = vec->size();
|
||||
if (count > 0) {
|
||||
total_size += count * (1 + 8); // field_id + 8 bytes per item
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_float_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<float> *>(field_ptr);
|
||||
size_t count = vec->size();
|
||||
if (count > 0) {
|
||||
total_size += count * (1 + 4); // field_id + 4 bytes per item
|
||||
}
|
||||
}
|
||||
|
||||
void size_repeated_double_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<double> *>(field_ptr);
|
||||
size_t count = vec->size();
|
||||
if (count > 0) {
|
||||
total_size += count * (1 + 8); // field_id + 8 bytes per item
|
||||
}
|
||||
}
|
||||
|
||||
// Template size functions moved to header
|
||||
|
||||
// Core shared functions
|
||||
void encode_from_metadata(ProtoWriteBuffer buffer, const void *obj, const FieldMeta *fields, size_t field_count,
|
||||
const RepeatedFieldMeta *repeated_fields, size_t repeated_count) {
|
||||
const uint8_t *base = static_cast<const uint8_t *>(obj);
|
||||
|
||||
// Encode regular fields
|
||||
for (size_t i = 0; i < field_count; i++) {
|
||||
const void *field_addr = base + fields[i].offset;
|
||||
fields[i].encoder(buffer, field_addr, fields[i].field_num);
|
||||
}
|
||||
|
||||
// Encode repeated fields
|
||||
for (size_t i = 0; i < repeated_count; i++) {
|
||||
const void *field_addr = base + repeated_fields[i].offset;
|
||||
repeated_fields[i].encoder(buffer, field_addr, repeated_fields[i].field_num);
|
||||
}
|
||||
}
|
||||
|
||||
void calculate_size_from_metadata(uint32_t &total_size, const void *obj, const FieldMeta *fields, size_t field_count,
|
||||
const RepeatedFieldMeta *repeated_fields, size_t repeated_count) {
|
||||
const uint8_t *base = static_cast<const uint8_t *>(obj);
|
||||
|
||||
// Calculate size for regular fields
|
||||
for (size_t i = 0; i < field_count; i++) {
|
||||
const void *field_addr = base + fields[i].offset;
|
||||
fields[i].sizer(total_size, field_addr, fields[i].field_num, fields[i].force_encode);
|
||||
}
|
||||
|
||||
// Calculate size for repeated fields
|
||||
for (size_t i = 0; i < repeated_count; i++) {
|
||||
const void *field_addr = base + repeated_fields[i].offset;
|
||||
repeated_fields[i].sizer(total_size, field_addr, repeated_fields[i].field_num);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace esphome
|
||||
|
@ -13,6 +13,34 @@
|
||||
namespace esphome {
|
||||
namespace api {
|
||||
|
||||
// Forward declarations
|
||||
class ProtoWriteBuffer;
|
||||
|
||||
// Function pointer types for encoding and size calculation
|
||||
using EncodeFunc = void (*)(ProtoWriteBuffer &, const void *field_ptr, uint8_t field_num);
|
||||
using SizeFunc = void (*)(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
|
||||
// Metadata structure describing each field
|
||||
struct FieldMeta {
|
||||
uint8_t field_num; // Protobuf field number (1-255)
|
||||
uint16_t offset; // offsetof(Class, field_name)
|
||||
EncodeFunc encoder; // Function to encode this field type
|
||||
SizeFunc sizer; // Function to calculate size for this field type
|
||||
bool force_encode; // If true, encode even if value is default/empty
|
||||
};
|
||||
|
||||
// Function pointer types for repeated fields
|
||||
using RepeatedEncodeFunc = void (*)(ProtoWriteBuffer &, const void *field_ptr, uint8_t field_num);
|
||||
using RepeatedSizeFunc = void (*)(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
// Special metadata for repeated fields
|
||||
struct RepeatedFieldMeta {
|
||||
uint8_t field_num;
|
||||
uint16_t offset;
|
||||
RepeatedEncodeFunc encoder; // Encoder for the entire vector
|
||||
RepeatedSizeFunc sizer; // Sizer for the entire vector
|
||||
};
|
||||
|
||||
/// Representation of a VarInt - in ProtoBuf should be 64bit but we only use 32bit
|
||||
class ProtoVarInt {
|
||||
public:
|
||||
@ -402,5 +430,88 @@ class ProtoService {
|
||||
}
|
||||
};
|
||||
|
||||
// Type-specific encoding functions
|
||||
void encode_string_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_fixed32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_bool_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_float_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_int32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_uint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_int64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_uint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_sint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_sint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_fixed64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_double_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_bytes_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
// Type-specific size calculation functions
|
||||
void size_string_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_fixed32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_bool_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_float_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_int32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_uint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_int64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_uint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_sint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_sint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_fixed64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_double_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
void size_bytes_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
|
||||
// Template enum field functions
|
||||
template<typename EnumType> void encode_enum_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
template<typename EnumType>
|
||||
void size_enum_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force);
|
||||
|
||||
// Repeated field handling functions
|
||||
void encode_repeated_string_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_bool_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_uint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_int32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_uint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_int64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_sint32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_sint64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_fixed32_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_fixed64_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_float_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
void encode_repeated_double_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
template<typename EnumType>
|
||||
void encode_repeated_enum_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
template<typename MessageType>
|
||||
void encode_repeated_message_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
// Size calculation for repeated fields
|
||||
void size_repeated_string_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_bool_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_uint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_int32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_uint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_int64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_sint32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_sint64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_fixed32_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_fixed64_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_float_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
void size_repeated_double_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
template<typename EnumType>
|
||||
void size_repeated_enum_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
template<typename MessageType>
|
||||
void size_repeated_message_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num);
|
||||
|
||||
// Core shared functions
|
||||
void encode_from_metadata(ProtoWriteBuffer buffer, const void *obj, const FieldMeta *fields, size_t field_count,
|
||||
const RepeatedFieldMeta *repeated_fields = nullptr, size_t repeated_count = 0);
|
||||
|
||||
void calculate_size_from_metadata(uint32_t &total_size, const void *obj, const FieldMeta *fields, size_t field_count,
|
||||
const RepeatedFieldMeta *repeated_fields = nullptr, size_t repeated_count = 0);
|
||||
|
||||
} // namespace api
|
||||
} // namespace esphome
|
||||
|
55
esphome/components/api/proto_templates.h
Normal file
55
esphome/components/api/proto_templates.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "proto.h"
|
||||
#include "api_pb2_size.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace api {
|
||||
|
||||
// Template enum field functions (must be in header for instantiation)
|
||||
template<typename EnumType>
|
||||
inline void encode_enum_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *val = static_cast<const EnumType *>(field_ptr);
|
||||
buffer.encode_enum<EnumType>(field_num, *val);
|
||||
}
|
||||
|
||||
template<typename EnumType>
|
||||
inline void size_enum_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num, bool force) {
|
||||
const auto *val = static_cast<const EnumType *>(field_ptr);
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(*val), force);
|
||||
}
|
||||
|
||||
// Template repeated field functions (must be in header for instantiation)
|
||||
template<typename EnumType>
|
||||
inline void encode_repeated_enum_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<EnumType> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
buffer.encode_enum<EnumType>(field_num, val, true);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename MessageType>
|
||||
inline void encode_repeated_message_field(ProtoWriteBuffer &buffer, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<MessageType> *>(field_ptr);
|
||||
for (const auto &msg : *vec) {
|
||||
buffer.encode_message<MessageType>(field_num, msg, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Template size functions for repeated fields (must be in header for instantiation)
|
||||
template<typename EnumType>
|
||||
inline void size_repeated_enum_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<EnumType> *>(field_ptr);
|
||||
for (const auto &val : *vec) {
|
||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(val), true);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename MessageType>
|
||||
inline void size_repeated_message_field(uint32_t &total_size, const void *field_ptr, uint8_t field_num) {
|
||||
const auto *vec = static_cast<const std::vector<MessageType> *>(field_ptr);
|
||||
ProtoSize::add_repeated_message<MessageType>(total_size, 1, *vec);
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace esphome
|
@ -962,10 +962,104 @@ def calculate_message_estimated_size(desc: descriptor.DescriptorProto) -> int:
|
||||
return total_size
|
||||
|
||||
|
||||
def get_encoder_function(type_info: TypeInfo) -> str | None:
|
||||
"""Get the encoder function name for a given type."""
|
||||
type_map = {
|
||||
"StringType": "&encode_string_field",
|
||||
"BoolType": "&encode_bool_field",
|
||||
"FloatType": "&encode_float_field",
|
||||
"DoubleType": "&encode_double_field",
|
||||
"Int32Type": "&encode_int32_field",
|
||||
"UInt32Type": "&encode_uint32_field",
|
||||
"Int64Type": "&encode_int64_field",
|
||||
"UInt64Type": "&encode_uint64_field",
|
||||
"SInt32Type": "&encode_sint32_field",
|
||||
"SInt64Type": "&encode_sint64_field",
|
||||
"Fixed32Type": "&encode_fixed32_field",
|
||||
"Fixed64Type": "&encode_fixed64_field",
|
||||
"SFixed32Type": "&encode_int32_field", # sfixed32 uses same as int32
|
||||
"SFixed64Type": "&encode_int64_field", # sfixed64 uses same as int64
|
||||
"BytesType": "&encode_bytes_field",
|
||||
}
|
||||
|
||||
type_name = type_info.__class__.__name__
|
||||
return type_map.get(type_name, None)
|
||||
|
||||
|
||||
def get_sizer_function(type_info: TypeInfo) -> str | None:
|
||||
"""Get the sizer function name for a given type."""
|
||||
type_map = {
|
||||
"StringType": "&size_string_field",
|
||||
"BoolType": "&size_bool_field",
|
||||
"FloatType": "&size_float_field",
|
||||
"DoubleType": "&size_double_field",
|
||||
"Int32Type": "&size_int32_field",
|
||||
"UInt32Type": "&size_uint32_field",
|
||||
"Int64Type": "&size_int64_field",
|
||||
"UInt64Type": "&size_uint64_field",
|
||||
"SInt32Type": "&size_sint32_field",
|
||||
"SInt64Type": "&size_sint64_field",
|
||||
"Fixed32Type": "&size_fixed32_field",
|
||||
"Fixed64Type": "&size_fixed64_field",
|
||||
"SFixed32Type": "&size_int32_field", # sfixed32 uses same as int32
|
||||
"SFixed64Type": "&size_int64_field", # sfixed64 uses same as int64
|
||||
"BytesType": "&size_bytes_field",
|
||||
}
|
||||
|
||||
type_name = type_info.__class__.__name__
|
||||
return type_map.get(type_name, None)
|
||||
|
||||
|
||||
def get_repeated_encoder_function(type_info: RepeatedTypeInfo) -> str | None:
|
||||
"""Get the repeated encoder function name for a given type."""
|
||||
type_map = {
|
||||
"StringType": "&encode_repeated_string_field",
|
||||
"BoolType": "&encode_repeated_bool_field",
|
||||
"FloatType": "&encode_repeated_float_field",
|
||||
"DoubleType": "&encode_repeated_double_field",
|
||||
"Int32Type": "&encode_repeated_int32_field",
|
||||
"UInt32Type": "&encode_repeated_uint32_field",
|
||||
"Int64Type": "&encode_repeated_int64_field",
|
||||
"UInt64Type": "&encode_repeated_uint64_field",
|
||||
"SInt32Type": "&encode_repeated_sint32_field",
|
||||
"SInt64Type": "&encode_repeated_sint64_field",
|
||||
"Fixed32Type": "&encode_repeated_fixed32_field",
|
||||
"Fixed64Type": "&encode_repeated_fixed64_field",
|
||||
"SFixed32Type": "&encode_repeated_int32_field", # sfixed32 uses same as int32
|
||||
"SFixed64Type": "&encode_repeated_int64_field", # sfixed64 uses same as int64
|
||||
}
|
||||
|
||||
type_name = type_info._ti.__class__.__name__
|
||||
return type_map.get(type_name, None)
|
||||
|
||||
|
||||
def get_repeated_sizer_function(type_info: RepeatedTypeInfo) -> str | None:
|
||||
"""Get the repeated sizer function name for a given type."""
|
||||
type_map = {
|
||||
"StringType": "&size_repeated_string_field",
|
||||
"BoolType": "&size_repeated_bool_field",
|
||||
"FloatType": "&size_repeated_float_field",
|
||||
"DoubleType": "&size_repeated_double_field",
|
||||
"Int32Type": "&size_repeated_int32_field",
|
||||
"UInt32Type": "&size_repeated_uint32_field",
|
||||
"Int64Type": "&size_repeated_int64_field",
|
||||
"UInt64Type": "&size_repeated_uint64_field",
|
||||
"SInt32Type": "&size_repeated_sint32_field",
|
||||
"SInt64Type": "&size_repeated_sint64_field",
|
||||
"Fixed32Type": "&size_repeated_fixed32_field",
|
||||
"Fixed64Type": "&size_repeated_fixed64_field",
|
||||
"SFixed32Type": "&size_repeated_int32_field", # sfixed32 uses same as int32
|
||||
"SFixed64Type": "&size_repeated_int64_field", # sfixed64 uses same as int64
|
||||
}
|
||||
|
||||
type_name = type_info._ti.__class__.__name__
|
||||
return type_map.get(type_name, None)
|
||||
|
||||
|
||||
def build_message_type(
|
||||
desc: descriptor.DescriptorProto,
|
||||
base_class_fields: dict[str, list[descriptor.FieldDescriptorProto]] = None,
|
||||
) -> tuple[str, str, str]:
|
||||
) -> tuple[str, str, str, dict | None]:
|
||||
public_content: list[str] = []
|
||||
protected_content: list[str] = []
|
||||
decode_varint: list[str] = []
|
||||
@ -1073,8 +1167,90 @@ def build_message_type(
|
||||
prot = "bool decode_64bit(uint32_t field_id, Proto64Bit value) override;"
|
||||
protected_content.insert(0, prot)
|
||||
|
||||
# Check if this is a Response message and use metadata approach
|
||||
is_response = desc.name.endswith("Response")
|
||||
metadata_info = None
|
||||
|
||||
# Generate metadata arrays for Response classes
|
||||
if is_response:
|
||||
regular_fields = []
|
||||
repeated_fields = []
|
||||
|
||||
for field in desc.field:
|
||||
if field.label == 3: # Repeated field
|
||||
ti = RepeatedTypeInfo(field)
|
||||
encoder = get_repeated_encoder_function(ti)
|
||||
sizer = get_repeated_sizer_function(ti)
|
||||
|
||||
if encoder and sizer:
|
||||
repeated_fields.append(
|
||||
f"{{{field.number}, offsetof({desc.name}, {ti.field_name}), {encoder}, {sizer}}}"
|
||||
)
|
||||
elif isinstance(ti._ti, EnumType):
|
||||
# Handle enum repeated fields with template
|
||||
enum_type = ti._ti.cpp_type
|
||||
repeated_fields.append(
|
||||
f"{{{field.number}, offsetof({desc.name}, {ti.field_name}), "
|
||||
f"&encode_repeated_enum_field<{enum_type}>, &size_repeated_enum_field<{enum_type}>}}"
|
||||
)
|
||||
elif isinstance(ti._ti, MessageType):
|
||||
# Handle message repeated fields with template
|
||||
msg_type = ti._ti.cpp_type
|
||||
repeated_fields.append(
|
||||
f"{{{field.number}, offsetof({desc.name}, {ti.field_name}), "
|
||||
f"&encode_repeated_message_field<{msg_type}>, &size_repeated_message_field<{msg_type}>}}"
|
||||
)
|
||||
else:
|
||||
ti = TYPE_INFO[field.type](field)
|
||||
encoder = get_encoder_function(ti)
|
||||
sizer = get_sizer_function(ti)
|
||||
force = "true" if field.label == 2 else "false" # Required fields
|
||||
|
||||
if encoder and sizer:
|
||||
regular_fields.append(
|
||||
f"{{{field.number}, offsetof({desc.name}, {ti.field_name}), {encoder}, {sizer}, {force}}}"
|
||||
)
|
||||
elif isinstance(ti, EnumType):
|
||||
# Handle enum fields with template
|
||||
enum_type = ti.cpp_type
|
||||
regular_fields.append(
|
||||
f"{{{field.number}, offsetof({desc.name}, {ti.field_name}), "
|
||||
f"&encode_enum_field<{enum_type}>, &size_enum_field<{enum_type}>, {force}}}"
|
||||
)
|
||||
elif isinstance(ti, MessageType):
|
||||
# Skip nested messages for now - they need special handling
|
||||
pass
|
||||
|
||||
# Store metadata info for later generation outside the class
|
||||
metadata_info = {
|
||||
"regular_fields": regular_fields,
|
||||
"repeated_fields": repeated_fields,
|
||||
"class_name": desc.name,
|
||||
}
|
||||
|
||||
# Add static declarations inside the class (definitions will be in cpp file)
|
||||
if regular_fields:
|
||||
public_content.append(
|
||||
f"static const FieldMeta FIELDS[{len(regular_fields)}];"
|
||||
)
|
||||
public_content.append(
|
||||
f"static constexpr size_t FIELD_COUNT = {len(regular_fields)};"
|
||||
)
|
||||
else:
|
||||
public_content.append("static constexpr size_t FIELD_COUNT = 0;")
|
||||
|
||||
if repeated_fields:
|
||||
public_content.append(
|
||||
f"static const RepeatedFieldMeta REPEATED_FIELDS[{len(repeated_fields)}];"
|
||||
)
|
||||
public_content.append(
|
||||
f"static constexpr size_t REPEATED_COUNT = {len(repeated_fields)};"
|
||||
)
|
||||
else:
|
||||
public_content.append("static constexpr size_t REPEATED_COUNT = 0;")
|
||||
|
||||
# Only generate encode method if there are fields to encode
|
||||
if encode:
|
||||
if encode and not is_response:
|
||||
o = f"void {desc.name}::encode(ProtoWriteBuffer buffer) const {{"
|
||||
if len(encode) == 1 and len(encode[0]) + len(o) + 3 < 120:
|
||||
o += f" {encode[0]} "
|
||||
@ -1086,9 +1262,23 @@ def build_message_type(
|
||||
prot = "void encode(ProtoWriteBuffer buffer) const override;"
|
||||
public_content.append(prot)
|
||||
# If no fields to encode, the default implementation in ProtoMessage will be used
|
||||
elif is_response and (regular_fields or repeated_fields):
|
||||
# Generate metadata-based encode method for Response classes
|
||||
prot = "void encode(ProtoWriteBuffer buffer) const override;"
|
||||
public_content.append(prot)
|
||||
|
||||
o = f"void {desc.name}::encode(ProtoWriteBuffer buffer) const {{\n"
|
||||
if regular_fields and repeated_fields:
|
||||
o += " encode_from_metadata(buffer, this, FIELDS, FIELD_COUNT, REPEATED_FIELDS, REPEATED_COUNT);\n"
|
||||
elif regular_fields:
|
||||
o += " encode_from_metadata(buffer, this, FIELDS, FIELD_COUNT, nullptr, 0);\n"
|
||||
else:
|
||||
o += " encode_from_metadata(buffer, this, nullptr, 0, REPEATED_FIELDS, REPEATED_COUNT);\n"
|
||||
o += "}\n"
|
||||
cpp += o
|
||||
|
||||
# Add calculate_size method only if there are fields
|
||||
if size_calc:
|
||||
if size_calc and not is_response:
|
||||
o = f"void {desc.name}::calculate_size(uint32_t &total_size) const {{"
|
||||
# For a single field, just inline it for simplicity
|
||||
if len(size_calc) == 1 and len(size_calc[0]) + len(o) + 3 < 120:
|
||||
@ -1102,6 +1292,20 @@ def build_message_type(
|
||||
prot = "void calculate_size(uint32_t &total_size) const override;"
|
||||
public_content.append(prot)
|
||||
# If no fields to calculate size for, the default implementation in ProtoMessage will be used
|
||||
elif is_response and (regular_fields or repeated_fields):
|
||||
# Generate metadata-based calculate_size method for Response classes
|
||||
prot = "void calculate_size(uint32_t &total_size) const override;"
|
||||
public_content.append(prot)
|
||||
|
||||
o = f"void {desc.name}::calculate_size(uint32_t &total_size) const {{\n"
|
||||
if regular_fields and repeated_fields:
|
||||
o += " calculate_size_from_metadata(total_size, this, FIELDS, FIELD_COUNT, REPEATED_FIELDS, REPEATED_COUNT);\n"
|
||||
elif regular_fields:
|
||||
o += " calculate_size_from_metadata(total_size, this, FIELDS, FIELD_COUNT, nullptr, 0);\n"
|
||||
else:
|
||||
o += " calculate_size_from_metadata(total_size, this, nullptr, 0, REPEATED_FIELDS, REPEATED_COUNT);\n"
|
||||
o += "}\n"
|
||||
cpp += o
|
||||
|
||||
# dump_to method declaration in header
|
||||
prot = "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
|
||||
@ -1145,7 +1349,10 @@ def build_message_type(
|
||||
# Build dump_cpp content with dump_to implementation
|
||||
dump_cpp = dump_impl
|
||||
|
||||
return out, cpp, dump_cpp
|
||||
# Return metadata info for Response classes
|
||||
metadata_return = metadata_info if is_response else None
|
||||
|
||||
return out, cpp, dump_cpp, metadata_return
|
||||
|
||||
|
||||
SOURCE_BOTH = 0
|
||||
@ -1367,6 +1574,7 @@ def main() -> None:
|
||||
|
||||
#include "proto.h"
|
||||
#include "api_pb2_size.h"
|
||||
#include "proto_templates.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace api {
|
||||
@ -1377,6 +1585,7 @@ namespace api {
|
||||
cpp += """\
|
||||
#include "api_pb2.h"
|
||||
#include "api_pb2_size.h"
|
||||
#include "proto_templates.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
@ -1456,8 +1665,11 @@ namespace api {
|
||||
# Simple grouping by ifdef
|
||||
current_ifdef = None
|
||||
|
||||
# Collect metadata for Response classes
|
||||
response_metadata = []
|
||||
|
||||
for m in mt:
|
||||
s, c, dc = build_message_type(m, base_class_fields)
|
||||
s, c, dc, metadata = build_message_type(m, base_class_fields)
|
||||
msg_ifdef = message_ifdef_map.get(m.name)
|
||||
|
||||
# Handle ifdef changes
|
||||
@ -1478,17 +1690,75 @@ namespace api {
|
||||
cpp += c
|
||||
dump_cpp += dc
|
||||
|
||||
# Collect metadata for later generation
|
||||
if metadata:
|
||||
metadata["ifdef"] = msg_ifdef
|
||||
response_metadata.append(metadata)
|
||||
|
||||
# Close last ifdef
|
||||
if current_ifdef is not None:
|
||||
content += "#endif\n"
|
||||
cpp += "#endif\n"
|
||||
dump_cpp += "#endif\n"
|
||||
|
||||
# No definitions in header - they'll be in cpp file
|
||||
|
||||
content += """\
|
||||
|
||||
} // namespace api
|
||||
} // namespace esphome
|
||||
"""
|
||||
|
||||
# Generate metadata definitions in cpp file for Response classes
|
||||
if response_metadata:
|
||||
cpp += "\n// Metadata definitions for Response classes\n"
|
||||
cpp += "#ifdef __GNUC__\n"
|
||||
cpp += "#pragma GCC diagnostic push\n"
|
||||
cpp += '#pragma GCC diagnostic ignored "-Winvalid-offsetof"\n'
|
||||
cpp += "#endif\n"
|
||||
current_ifdef = None
|
||||
|
||||
for meta in response_metadata:
|
||||
class_name = meta["class_name"]
|
||||
regular_fields = meta["regular_fields"]
|
||||
repeated_fields = meta["repeated_fields"]
|
||||
msg_ifdef = meta["ifdef"]
|
||||
|
||||
# Handle ifdef changes
|
||||
if msg_ifdef != current_ifdef:
|
||||
if current_ifdef is not None:
|
||||
cpp += "#endif\n"
|
||||
if msg_ifdef is not None:
|
||||
cpp += f"#ifdef {msg_ifdef}\n"
|
||||
current_ifdef = msg_ifdef
|
||||
|
||||
if regular_fields:
|
||||
cpp += f"const FieldMeta {class_name}::FIELDS[{len(regular_fields)}] = {{\n"
|
||||
for i, field in enumerate(regular_fields):
|
||||
if i < len(regular_fields) - 1:
|
||||
cpp += f" {field},\n"
|
||||
else:
|
||||
cpp += f" {field}\n"
|
||||
cpp += "};\n"
|
||||
|
||||
if repeated_fields:
|
||||
cpp += f"const RepeatedFieldMeta {class_name}::REPEATED_FIELDS[{len(repeated_fields)}] = {{\n"
|
||||
for i, field in enumerate(repeated_fields):
|
||||
if i < len(repeated_fields) - 1:
|
||||
cpp += f" {field},\n"
|
||||
else:
|
||||
cpp += f" {field}\n"
|
||||
cpp += "};\n"
|
||||
|
||||
# Close last ifdef for metadata
|
||||
if current_ifdef is not None:
|
||||
cpp += "#endif\n"
|
||||
|
||||
# Re-enable the warning
|
||||
cpp += "#ifdef __GNUC__\n"
|
||||
cpp += "#pragma GCC diagnostic pop\n"
|
||||
cpp += "#endif\n"
|
||||
|
||||
cpp += """\
|
||||
|
||||
} // namespace api
|
||||
|
Loading…
x
Reference in New Issue
Block a user