mirror of
https://github.com/esphome/esphome.git
synced 2025-07-30 15:16:37 +00:00
Make ProtoSize an object
This commit is contained in:
parent
d111b84ca4
commit
1032e5c220
@ -53,9 +53,7 @@ bool ConnectRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void ConnectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->invalid_password); }
|
void ConnectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->invalid_password); }
|
||||||
}
|
|
||||||
void ConnectResponse::calculate_size(ProtoSize &size) const { size.add_bool_field(1, this->invalid_password); }
|
void ConnectResponse::calculate_size(ProtoSize &size) const { size.add_bool_field(1, this->invalid_password); }
|
||||||
}
|
|
||||||
#ifdef USE_AREAS
|
#ifdef USE_AREAS
|
||||||
void AreaInfo::encode(ProtoWriteBuffer buffer) const {
|
void AreaInfo::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_uint32(1, this->area_id);
|
buffer.encode_uint32(1, this->area_id);
|
||||||
@ -839,9 +837,7 @@ bool NoiseEncryptionSetKeyRequest::decode_length(uint32_t field_id, ProtoLengthD
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void NoiseEncryptionSetKeyResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
|
void NoiseEncryptionSetKeyResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
|
||||||
}
|
|
||||||
void NoiseEncryptionSetKeyResponse::calculate_size(ProtoSize &size) const { size.add_bool_field(1, this->success); }
|
void NoiseEncryptionSetKeyResponse::calculate_size(ProtoSize &size) const { size.add_bool_field(1, this->success); }
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
void HomeassistantServiceMap::encode(ProtoWriteBuffer buffer) const {
|
void HomeassistantServiceMap::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_string(1, this->key_ref_);
|
buffer.encode_string(1, this->key_ref_);
|
||||||
@ -910,9 +906,7 @@ bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
|
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
|
||||||
}
|
|
||||||
void GetTimeResponse::calculate_size(ProtoSize &size) const { size.add_fixed32_field(1, this->epoch_seconds); }
|
void GetTimeResponse::calculate_size(ProtoSize &size) const { size.add_fixed32_field(1, this->epoch_seconds); }
|
||||||
}
|
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const {
|
void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_string(1, this->name_ref_);
|
buffer.encode_string(1, this->name_ref_);
|
||||||
@ -2317,9 +2311,7 @@ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLength
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
|
void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); }
|
||||||
}
|
|
||||||
void VoiceAssistantAnnounceFinished::calculate_size(ProtoSize &size) const { size.add_bool_field(1, this->success); }
|
void VoiceAssistantAnnounceFinished::calculate_size(ProtoSize &size) const { size.add_bool_field(1, this->success); }
|
||||||
}
|
|
||||||
void VoiceAssistantWakeWord::encode(ProtoWriteBuffer buffer) const {
|
void VoiceAssistantWakeWord::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_string(1, this->id_ref_);
|
buffer.encode_string(1, this->id_ref_);
|
||||||
buffer.encode_string(2, this->wake_word_ref_);
|
buffer.encode_string(2, this->wake_word_ref_);
|
||||||
|
@ -334,6 +334,9 @@ class ProtoWriteBuffer {
|
|||||||
std::vector<uint8_t> *buffer_;
|
std::vector<uint8_t> *buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Forward declaration
|
||||||
|
class ProtoSize;
|
||||||
|
|
||||||
class ProtoMessage {
|
class ProtoMessage {
|
||||||
public:
|
public:
|
||||||
virtual ~ProtoMessage() = default;
|
virtual ~ProtoMessage() = default;
|
||||||
|
@ -1687,7 +1687,7 @@ def build_message_type(
|
|||||||
else:
|
else:
|
||||||
o += "\n"
|
o += "\n"
|
||||||
o += indent("\n".join(encode)) + "\n"
|
o += indent("\n".join(encode)) + "\n"
|
||||||
o += "}\n"
|
o += "}\n"
|
||||||
cpp += o
|
cpp += o
|
||||||
prot = "void encode(ProtoWriteBuffer buffer) const override;"
|
prot = "void encode(ProtoWriteBuffer buffer) const override;"
|
||||||
public_content.append(prot)
|
public_content.append(prot)
|
||||||
@ -1703,7 +1703,7 @@ def build_message_type(
|
|||||||
# For multiple fields
|
# For multiple fields
|
||||||
o += "\n"
|
o += "\n"
|
||||||
o += indent("\n".join(size_calc)) + "\n"
|
o += indent("\n".join(size_calc)) + "\n"
|
||||||
o += "}\n"
|
o += "}\n"
|
||||||
cpp += o
|
cpp += o
|
||||||
prot = "void calculate_size(ProtoSize &size) const override;"
|
prot = "void calculate_size(ProtoSize &size) const override;"
|
||||||
public_content.append(prot)
|
public_content.append(prot)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user