[Yunq] Move message parser to shared internal function.
This commit is contained in:
parent
a71d5e9d24
commit
984d8b143e
|
@ -39,20 +39,15 @@ glcr::Status ReadRequest::ParseFromBytesInternal(const yunq::MessageView& messag
|
|||
|
||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3);
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(0, device_id_);
|
||||
// Write lba.
|
||||
serializer.WriteField<uint64_t>(1, lba_);
|
||||
// Write size.
|
||||
serializer.WriteField<uint64_t>(2, size_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(0, device_id_);
|
||||
// Write lba.
|
||||
|
@ -90,20 +85,15 @@ glcr::Status ReadManyRequest::ParseFromBytesInternal(const yunq::MessageView& me
|
|||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3);
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(0, device_id_);
|
||||
// Write lba.
|
||||
serializer.WriteRepeated<uint64_t>(1, lba_);
|
||||
// Write sector_cnt.
|
||||
serializer.WriteRepeated<uint64_t>(2, sector_cnt_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(0, device_id_);
|
||||
// Write lba.
|
||||
|
@ -142,20 +132,15 @@ glcr::Status ReadResponse::ParseFromBytesInternal(const yunq::MessageView& messa
|
|||
|
||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3);
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(0, device_id_);
|
||||
// Write size.
|
||||
serializer.WriteField<uint64_t>(1, size_);
|
||||
// Write memory.
|
||||
serializer.WriteCapability(2, memory_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadResponse::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(0, device_id_);
|
||||
// Write size.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <yunq/message_view.h>
|
||||
#include <yunq/serialize.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
|
||||
|
@ -35,6 +36,8 @@ class ReadRequest {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class ReadManyRequest {
|
||||
public:
|
||||
|
@ -61,6 +64,8 @@ class ReadManyRequest {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class ReadResponse {
|
||||
public:
|
||||
|
@ -87,5 +92,7 @@ class ReadResponse {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,16 +35,15 @@ glcr::Status OpenFileRequest::ParseFromBytesInternal(const yunq::MessageView& me
|
|||
|
||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
// Write path.
|
||||
serializer.WriteField<glcr::String>(0, path_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t OpenFileRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write path.
|
||||
serializer.WriteField<glcr::String>(0, path_);
|
||||
|
||||
|
@ -79,20 +78,15 @@ glcr::Status OpenFileResponse::ParseFromBytesInternal(const yunq::MessageView& m
|
|||
|
||||
uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3);
|
||||
// Write path.
|
||||
serializer.WriteField<glcr::String>(0, path_);
|
||||
// Write size.
|
||||
serializer.WriteField<uint64_t>(1, size_);
|
||||
// Write memory.
|
||||
serializer.WriteCapability(2, memory_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t OpenFileResponse::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write path.
|
||||
serializer.WriteField<glcr::String>(0, path_);
|
||||
// Write size.
|
||||
|
@ -124,16 +118,15 @@ glcr::Status GetDirectoryRequest::ParseFromBytesInternal(const yunq::MessageView
|
|||
|
||||
uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
// Write path.
|
||||
serializer.WriteField<glcr::String>(0, path_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t GetDirectoryRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write path.
|
||||
serializer.WriteField<glcr::String>(0, path_);
|
||||
|
||||
|
@ -161,16 +154,15 @@ glcr::Status Directory::ParseFromBytesInternal(const yunq::MessageView& message)
|
|||
|
||||
uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
// Write filenames.
|
||||
serializer.WriteField<glcr::String>(0, filenames_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t Directory::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write filenames.
|
||||
serializer.WriteField<glcr::String>(0, filenames_);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <yunq/message_view.h>
|
||||
#include <yunq/serialize.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
|
||||
|
@ -29,6 +30,8 @@ class OpenFileRequest {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class OpenFileResponse {
|
||||
public:
|
||||
|
@ -55,6 +58,8 @@ class OpenFileResponse {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class GetDirectoryRequest {
|
||||
public:
|
||||
|
@ -75,6 +80,8 @@ class GetDirectoryRequest {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class Directory {
|
||||
public:
|
||||
|
@ -95,5 +102,7 @@ class Directory {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,16 +38,15 @@ glcr::Status KeyboardListener::ParseFromBytesInternal(const yunq::MessageView& m
|
|||
|
||||
uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
// Write port_capability.
|
||||
serializer.WriteCapability(0, port_capability_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t KeyboardListener::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write port_capability.
|
||||
serializer.WriteCapability(0, port_capability_);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <yunq/message_view.h>
|
||||
#include <yunq/serialize.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
|
||||
|
@ -29,5 +30,7 @@ class KeyboardListener {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -42,18 +42,15 @@ glcr::Status RegisterEndpointRequest::ParseFromBytesInternal(const yunq::Message
|
|||
|
||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 2);
|
||||
// Write endpoint_name.
|
||||
serializer.WriteField<glcr::String>(0, endpoint_name_);
|
||||
// Write endpoint_capability.
|
||||
serializer.WriteCapability(1, endpoint_capability_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 2, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t RegisterEndpointRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write endpoint_name.
|
||||
serializer.WriteField<glcr::String>(0, endpoint_name_);
|
||||
// Write endpoint_capability.
|
||||
|
@ -83,16 +80,15 @@ glcr::Status GetEndpointRequest::ParseFromBytesInternal(const yunq::MessageView&
|
|||
|
||||
uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
// Write endpoint_name.
|
||||
serializer.WriteField<glcr::String>(0, endpoint_name_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t GetEndpointRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write endpoint_name.
|
||||
serializer.WriteField<glcr::String>(0, endpoint_name_);
|
||||
|
||||
|
@ -123,16 +119,15 @@ glcr::Status Endpoint::ParseFromBytesInternal(const yunq::MessageView& message)
|
|||
|
||||
uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1);
|
||||
// Write endpoint.
|
||||
serializer.WriteCapability(0, endpoint_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 1, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t Endpoint::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write endpoint.
|
||||
serializer.WriteCapability(0, endpoint_);
|
||||
|
||||
|
@ -165,18 +160,15 @@ glcr::Status AhciInfo::ParseFromBytesInternal(const yunq::MessageView& message)
|
|||
|
||||
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 2);
|
||||
// Write ahci_region.
|
||||
serializer.WriteCapability(0, ahci_region_);
|
||||
// Write region_length.
|
||||
serializer.WriteField<uint64_t>(1, region_length_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 2, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t AhciInfo::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write ahci_region.
|
||||
serializer.WriteCapability(0, ahci_region_);
|
||||
// Write region_length.
|
||||
|
@ -228,38 +220,15 @@ glcr::Status FramebufferInfo::ParseFromBytesInternal(const yunq::MessageView& me
|
|||
|
||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 12);
|
||||
// Write address_phys.
|
||||
serializer.WriteField<uint64_t>(0, address_phys_);
|
||||
// Write width.
|
||||
serializer.WriteField<uint64_t>(1, width_);
|
||||
// Write height.
|
||||
serializer.WriteField<uint64_t>(2, height_);
|
||||
// Write pitch.
|
||||
serializer.WriteField<uint64_t>(3, pitch_);
|
||||
// Write bpp.
|
||||
serializer.WriteField<uint64_t>(4, bpp_);
|
||||
// Write memory_model.
|
||||
serializer.WriteField<uint64_t>(5, memory_model_);
|
||||
// Write red_mask_size.
|
||||
serializer.WriteField<uint64_t>(6, red_mask_size_);
|
||||
// Write red_mask_shift.
|
||||
serializer.WriteField<uint64_t>(7, red_mask_shift_);
|
||||
// Write green_mask_size.
|
||||
serializer.WriteField<uint64_t>(8, green_mask_size_);
|
||||
// Write green_mask_shift.
|
||||
serializer.WriteField<uint64_t>(9, green_mask_shift_);
|
||||
// Write blue_mask_size.
|
||||
serializer.WriteField<uint64_t>(10, blue_mask_size_);
|
||||
// Write blue_mask_shift.
|
||||
serializer.WriteField<uint64_t>(11, blue_mask_shift_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 12, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t FramebufferInfo::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write address_phys.
|
||||
serializer.WriteField<uint64_t>(0, address_phys_);
|
||||
// Write width.
|
||||
|
@ -316,20 +285,15 @@ glcr::Status DenaliInfo::ParseFromBytesInternal(const yunq::MessageView& message
|
|||
|
||||
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3);
|
||||
// Write denali_endpoint.
|
||||
serializer.WriteCapability(0, denali_endpoint_);
|
||||
// Write device_id.
|
||||
serializer.WriteField<uint64_t>(1, device_id_);
|
||||
// Write lba_offset.
|
||||
serializer.WriteField<uint64_t>(2, lba_offset_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t DenaliInfo::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// Write denali_endpoint.
|
||||
serializer.WriteCapability(0, denali_endpoint_);
|
||||
// Write device_id.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <yunq/message_view.h>
|
||||
#include <yunq/serialize.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
|
||||
|
@ -34,6 +35,8 @@ class RegisterEndpointRequest {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class GetEndpointRequest {
|
||||
public:
|
||||
|
@ -54,6 +57,8 @@ class GetEndpointRequest {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class Endpoint {
|
||||
public:
|
||||
|
@ -74,6 +79,8 @@ class Endpoint {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class AhciInfo {
|
||||
public:
|
||||
|
@ -97,6 +104,8 @@ class AhciInfo {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class FramebufferInfo {
|
||||
public:
|
||||
|
@ -150,6 +159,8 @@ class FramebufferInfo {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
class DenaliInfo {
|
||||
public:
|
||||
|
@ -176,6 +187,8 @@ class DenaliInfo {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,36 +74,15 @@ glcr::Status {{message.name}}::ParseFromBytesInternal(const yunq::MessageView& m
|
|||
|
||||
uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, {{ message.fields | length }});
|
||||
|
||||
{%- for field in message.fields %}
|
||||
// Write {{field.name}}.
|
||||
{%- if not field.repeated %}
|
||||
|
||||
{%- if field.type != Type.CAPABILITY %}
|
||||
serializer.WriteField<{{field.cpp_type()}}>({{loop.index0}}, {{field.name}}_);
|
||||
{%- else %}
|
||||
serializer.WriteCapability({{loop.index0}}, {{field.name}}_);
|
||||
{%- endif %}
|
||||
|
||||
{%- else %}
|
||||
|
||||
{%- if field.type != Type.CAPABILITY %}
|
||||
serializer.WriteRepeated<{{field.cpp_type()}}>({{loop.index0}}, {{field.name}}_);
|
||||
{%- else %}
|
||||
serializer.WriteRepeatedCapability({{loop.index0}}, {{field.name}}_);
|
||||
{%- endif %}
|
||||
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
return serializer.size();
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, {{ message.fields | length }}, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t {{message.name}}::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
{%- for field in message.fields %}
|
||||
// Write {{field.name}}.
|
||||
{%- if not field.repeated %}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <yunq/message_view.h>
|
||||
#include <yunq/serialize.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
{% if package != None %}
|
||||
|
@ -47,6 +48,8 @@ class {{message.name}} {
|
|||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
||||
uint64_t SerializeInternal(yunq::Serializer& serializer) const;
|
||||
};
|
||||
{%- endfor %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue