[Yunq] Add support for repeated nested fields
This commit is contained in:
parent
05f2403dc2
commit
9c860dd6a4
|
@ -47,6 +47,7 @@ class Vector {
|
|||
template <typename... Args>
|
||||
void EmplaceBack(Args&&... args);
|
||||
|
||||
T& PeekBack();
|
||||
T&& PopBack();
|
||||
|
||||
typedef ArrayIterator<T> Iterator;
|
||||
|
@ -130,6 +131,11 @@ void Vector<T>::EmplaceBack(Args&&... args) {
|
|||
data_[size_++] = T(args...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& Vector<T>::PeekBack() {
|
||||
return data_[size_ - 1];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T&& Vector<T>::PopBack() {
|
||||
size_--;
|
||||
|
|
|
@ -19,6 +19,10 @@ glcr::Status MessageView::CheckHeader() const {
|
|||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
uint32_t MessageView::MessageLength() const {
|
||||
return buffer_.At<uint32_t>(offset_ + 8);
|
||||
}
|
||||
|
||||
template <>
|
||||
glcr::ErrorOr<uint64_t> MessageView::ReadField<uint64_t>(
|
||||
uint64_t field_index) const {
|
||||
|
|
|
@ -16,6 +16,7 @@ class MessageView {
|
|||
: buffer_(buffer), offset_(offset) {}
|
||||
|
||||
[[nodiscard]] glcr::Status CheckHeader() const;
|
||||
uint32_t MessageLength() const;
|
||||
|
||||
// TODO: Implement glcr::StatusOr
|
||||
template <typename T>
|
||||
|
@ -31,6 +32,10 @@ class MessageView {
|
|||
template <typename T>
|
||||
glcr::Status ReadMessage(uint64_t field_index, T& message) const;
|
||||
|
||||
template <typename T>
|
||||
glcr::Status ReadRepeatedMessage(uint64_t field_index,
|
||||
glcr::Vector<T>& messages) const;
|
||||
|
||||
private:
|
||||
const glcr::ByteBuffer& buffer_;
|
||||
uint64_t offset_;
|
||||
|
@ -61,4 +66,22 @@ glcr::Status MessageView::ReadMessage(uint64_t field_index, T& message) const {
|
|||
return message.ParseFromBytes(subview);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
glcr::Status MessageView::ReadRepeatedMessage(uint64_t field_index,
|
||||
glcr::Vector<T>& messages) const {
|
||||
ExtensionPointer ptr =
|
||||
buffer_.At<ExtensionPointer>(field_offset(field_index));
|
||||
|
||||
uint64_t ext_offset = ptr.offset;
|
||||
|
||||
while (ext_offset < ptr.offset + ptr.length) {
|
||||
MessageView subview(buffer_, offset_ + ext_offset);
|
||||
messages.EmplaceBack();
|
||||
RETURN_ERROR(messages.PeekBack().ParseFromBytes(subview));
|
||||
ext_offset += subview.MessageLength();
|
||||
}
|
||||
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
} // namespace yunq
|
||||
|
|
|
@ -41,6 +41,9 @@ class Serializer {
|
|||
template <typename T>
|
||||
void WriteMessage(uint64_t field_index, const T& value);
|
||||
|
||||
template <typename T>
|
||||
void WriteRepeatedMessage(uint64_t field_index, const glcr::Vector<T>& value);
|
||||
|
||||
void WriteHeader();
|
||||
|
||||
uint64_t size() const { return next_extension_; }
|
||||
|
@ -90,4 +93,32 @@ void Serializer::WriteMessage(uint64_t field_index, const T& value) {
|
|||
buffer_.WriteAt<ExtensionPointer>(field_offset(field_index), ptr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Serializer::WriteRepeatedMessage(uint64_t field_index,
|
||||
const glcr::Vector<T>& value) {
|
||||
uint64_t next_offset = next_extension_;
|
||||
uint64_t length = 0;
|
||||
|
||||
for (T& message : value) {
|
||||
uint64_t msg_length = 0;
|
||||
if (caps_) {
|
||||
msg_length = message.SerializeToBytes(buffer_, offset_ + next_offset,
|
||||
caps_.value().get());
|
||||
} else {
|
||||
msg_length = message.SerializeToBytes(buffer_, offset_ + next_offset);
|
||||
}
|
||||
length += msg_length;
|
||||
next_offset += msg_length;
|
||||
}
|
||||
|
||||
ExtensionPointer ptr{
|
||||
.offset = (uint32_t)next_extension_,
|
||||
.length = (uint32_t)length,
|
||||
};
|
||||
|
||||
next_extension_ += length;
|
||||
|
||||
buffer_.WriteAt<ExtensionPointer>(field_offset(field_index), ptr);
|
||||
}
|
||||
|
||||
} // namespace yunq
|
||||
|
|
|
@ -35,26 +35,21 @@ glcr::Status DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
|||
ReadResponse& resp) {
|
||||
ASSIGN_OR_RETURN(AhciPort * device, driver_.GetDevice(req.device_id()));
|
||||
|
||||
if (req.lba().size() != req.sector_cnt().size()) {
|
||||
return glcr::InvalidArgument("LBA and Sector Cnt must be the same length.");
|
||||
}
|
||||
|
||||
uint64_t sector_cnt = 0;
|
||||
for (uint64_t cnt : req.sector_cnt()) {
|
||||
sector_cnt += cnt;
|
||||
for (auto& block : req.blocks()) {
|
||||
sector_cnt += block.size();
|
||||
}
|
||||
uint64_t region_paddr;
|
||||
mmth::OwnedMemoryRegion region = mmth::OwnedMemoryRegion::ContiguousPhysical(
|
||||
sector_cnt * 512, ®ion_paddr);
|
||||
|
||||
for (uint64_t i = 0; i < req.lba().size(); i++) {
|
||||
uint64_t lba = req.lba().at(i);
|
||||
uint64_t size = req.sector_cnt().at(i);
|
||||
ASSIGN_OR_RETURN(auto semaphore,
|
||||
device->IssueRead(lba, size, region_paddr));
|
||||
for (auto& block : req.blocks()) {
|
||||
ASSIGN_OR_RETURN(
|
||||
auto semaphore,
|
||||
device->IssueRead(block.lba(), block.size(), region_paddr));
|
||||
semaphore->Wait();
|
||||
|
||||
region_paddr += size * 512;
|
||||
region_paddr += block.size() * 512;
|
||||
}
|
||||
|
||||
resp.set_device_id(req.device_id());
|
||||
|
|
|
@ -16,10 +16,7 @@ message ReadRequest {
|
|||
|
||||
message ReadManyRequest {
|
||||
u64 device_id;
|
||||
// FIXME: Add repeated message fields.
|
||||
// Must be the same length.
|
||||
repeated u64 lba;
|
||||
repeated u64 sector_cnt;
|
||||
repeated DiskBlock blocks;
|
||||
}
|
||||
|
||||
message ReadResponse {
|
||||
|
|
|
@ -109,33 +109,28 @@ glcr::Status ReadManyRequest::ParseFromBytesInternal(const yunq::MessageView& me
|
|||
RETURN_ERROR(message.CheckHeader());
|
||||
// Parse device_id.
|
||||
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||
// Parse lba.
|
||||
ASSIGN_OR_RETURN(lba_, message.ReadRepeated<uint64_t>(1));
|
||||
|
||||
// Parse sector_cnt.
|
||||
ASSIGN_OR_RETURN(sector_cnt_, message.ReadRepeated<uint64_t>(2));
|
||||
// Parse blocks.
|
||||
message.ReadRepeatedMessage<DiskBlock>(1, blocks_);
|
||||
|
||||
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3);
|
||||
yunq::Serializer serializer(bytes, offset, 2);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
yunq::Serializer serializer(bytes, offset, 3, caps);
|
||||
yunq::Serializer serializer(bytes, offset, 2, caps);
|
||||
return SerializeInternal(serializer);
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeInternal(yunq::Serializer& serializer) const {
|
||||
// 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_);
|
||||
// Write blocks.
|
||||
serializer.WriteRepeatedMessage<DiskBlock>(1, blocks_);
|
||||
|
||||
serializer.WriteHeader();
|
||||
|
||||
|
|
|
@ -16,15 +16,20 @@ class DiskBlock {
|
|||
DiskBlock() {}
|
||||
// Delete copy and move until implemented.
|
||||
DiskBlock(const DiskBlock&) = delete;
|
||||
DiskBlock(DiskBlock&&) = delete;
|
||||
DiskBlock(DiskBlock&&) = default;
|
||||
DiskBlock& operator=(DiskBlock&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const uint64_t& lba() const { return lba_; }
|
||||
uint64_t& mutable_lba() { return lba_; }
|
||||
void set_lba(const uint64_t& value) { lba_ = value; }
|
||||
|
||||
const uint64_t& size() const { return size_; }
|
||||
uint64_t& mutable_size() { return size_; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -41,14 +46,18 @@ class ReadRequest {
|
|||
ReadRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
ReadRequest(const ReadRequest&) = delete;
|
||||
ReadRequest(ReadRequest&&) = delete;
|
||||
ReadRequest(ReadRequest&&) = default;
|
||||
ReadRequest& operator=(ReadRequest&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const uint64_t& device_id() const { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
uint64_t& mutable_device_id() { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
|
||||
const DiskBlock& block() const { return block_; }
|
||||
DiskBlock& mutable_block() { return block_; }
|
||||
|
||||
|
@ -66,23 +75,25 @@ class ReadManyRequest {
|
|||
ReadManyRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
ReadManyRequest(const ReadManyRequest&) = delete;
|
||||
ReadManyRequest(ReadManyRequest&&) = delete;
|
||||
ReadManyRequest(ReadManyRequest&&) = default;
|
||||
ReadManyRequest& operator=(ReadManyRequest&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const uint64_t& device_id() const { return device_id_; }
|
||||
uint64_t& mutable_device_id() { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
const glcr::Vector<uint64_t>& lba() const { return lba_; }
|
||||
void add_lba(const uint64_t& value) { lba_.PushBack(value); }
|
||||
const glcr::Vector<uint64_t>& sector_cnt() const { return sector_cnt_; }
|
||||
void add_sector_cnt(const uint64_t& value) { sector_cnt_.PushBack(value); }
|
||||
|
||||
const glcr::Vector<DiskBlock>& blocks() const { return blocks_; }
|
||||
glcr::Vector<DiskBlock>& mutable_blocks() { return blocks_; }
|
||||
void add_blocks(DiskBlock&& value) { blocks_.PushBack(glcr::Move(value)); }
|
||||
|
||||
private:
|
||||
uint64_t device_id_;
|
||||
glcr::Vector<uint64_t> lba_;
|
||||
glcr::Vector<uint64_t> sector_cnt_;
|
||||
glcr::Vector<DiskBlock> blocks_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
|
@ -94,17 +105,24 @@ class ReadResponse {
|
|||
ReadResponse() {}
|
||||
// Delete copy and move until implemented.
|
||||
ReadResponse(const ReadResponse&) = delete;
|
||||
ReadResponse(ReadResponse&&) = delete;
|
||||
ReadResponse(ReadResponse&&) = default;
|
||||
ReadResponse& operator=(ReadResponse&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const uint64_t& device_id() const { return device_id_; }
|
||||
uint64_t& mutable_device_id() { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
|
||||
const uint64_t& size() const { return size_; }
|
||||
uint64_t& mutable_size() { return size_; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
|
||||
const z_cap_t& memory() const { return memory_; }
|
||||
z_cap_t& mutable_memory() { return memory_; }
|
||||
void set_memory(const z_cap_t& value) { memory_ = value; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -94,8 +94,10 @@ glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
|||
i++;
|
||||
curr_run_len++;
|
||||
}
|
||||
req.add_lba(curr_start);
|
||||
req.add_sector_cnt(curr_run_len * SectorsPerBlock());
|
||||
DiskBlock block;
|
||||
block.set_lba(curr_start);
|
||||
block.set_size(curr_run_len * SectorsPerBlock());
|
||||
req.add_blocks(glcr::Move(block));
|
||||
}
|
||||
ReadResponse resp;
|
||||
auto status = denali_.ReadMany(req, resp);
|
||||
|
|
|
@ -16,13 +16,16 @@ class OpenFileRequest {
|
|||
OpenFileRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
OpenFileRequest(const OpenFileRequest&) = delete;
|
||||
OpenFileRequest(OpenFileRequest&&) = delete;
|
||||
OpenFileRequest(OpenFileRequest&&) = default;
|
||||
OpenFileRequest& operator=(OpenFileRequest&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const glcr::String& path() const { return path_; }
|
||||
glcr::String& mutable_path() { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -38,17 +41,24 @@ class OpenFileResponse {
|
|||
OpenFileResponse() {}
|
||||
// Delete copy and move until implemented.
|
||||
OpenFileResponse(const OpenFileResponse&) = delete;
|
||||
OpenFileResponse(OpenFileResponse&&) = delete;
|
||||
OpenFileResponse(OpenFileResponse&&) = default;
|
||||
OpenFileResponse& operator=(OpenFileResponse&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const glcr::String& path() const { return path_; }
|
||||
glcr::String& mutable_path() { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
|
||||
const uint64_t& size() const { return size_; }
|
||||
uint64_t& mutable_size() { return size_; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
|
||||
const z_cap_t& memory() const { return memory_; }
|
||||
z_cap_t& mutable_memory() { return memory_; }
|
||||
void set_memory(const z_cap_t& value) { memory_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -66,13 +76,16 @@ class GetDirectoryRequest {
|
|||
GetDirectoryRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
GetDirectoryRequest(const GetDirectoryRequest&) = delete;
|
||||
GetDirectoryRequest(GetDirectoryRequest&&) = delete;
|
||||
GetDirectoryRequest(GetDirectoryRequest&&) = default;
|
||||
GetDirectoryRequest& operator=(GetDirectoryRequest&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const glcr::String& path() const { return path_; }
|
||||
glcr::String& mutable_path() { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -88,13 +101,16 @@ class Directory {
|
|||
Directory() {}
|
||||
// Delete copy and move until implemented.
|
||||
Directory(const Directory&) = delete;
|
||||
Directory(Directory&&) = delete;
|
||||
Directory(Directory&&) = default;
|
||||
Directory& operator=(Directory&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const glcr::String& filenames() const { return filenames_; }
|
||||
glcr::String& mutable_filenames() { return filenames_; }
|
||||
void set_filenames(const glcr::String& value) { filenames_ = value; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -16,13 +16,16 @@ class KeyboardListener {
|
|||
KeyboardListener() {}
|
||||
// Delete copy and move until implemented.
|
||||
KeyboardListener(const KeyboardListener&) = delete;
|
||||
KeyboardListener(KeyboardListener&&) = delete;
|
||||
KeyboardListener(KeyboardListener&&) = default;
|
||||
KeyboardListener& operator=(KeyboardListener&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const z_cap_t& port_capability() const { return port_capability_; }
|
||||
z_cap_t& mutable_port_capability() { return port_capability_; }
|
||||
void set_port_capability(const z_cap_t& value) { port_capability_ = value; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,15 +18,20 @@ class RegisterEndpointRequest {
|
|||
RegisterEndpointRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
RegisterEndpointRequest(const RegisterEndpointRequest&) = delete;
|
||||
RegisterEndpointRequest(RegisterEndpointRequest&&) = delete;
|
||||
RegisterEndpointRequest(RegisterEndpointRequest&&) = default;
|
||||
RegisterEndpointRequest& operator=(RegisterEndpointRequest&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const glcr::String& endpoint_name() const { return endpoint_name_; }
|
||||
glcr::String& mutable_endpoint_name() { return endpoint_name_; }
|
||||
void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; }
|
||||
|
||||
const z_cap_t& endpoint_capability() const { return endpoint_capability_; }
|
||||
z_cap_t& mutable_endpoint_capability() { return endpoint_capability_; }
|
||||
void set_endpoint_capability(const z_cap_t& value) { endpoint_capability_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -43,13 +48,16 @@ class GetEndpointRequest {
|
|||
GetEndpointRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
GetEndpointRequest(const GetEndpointRequest&) = delete;
|
||||
GetEndpointRequest(GetEndpointRequest&&) = delete;
|
||||
GetEndpointRequest(GetEndpointRequest&&) = default;
|
||||
GetEndpointRequest& operator=(GetEndpointRequest&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const glcr::String& endpoint_name() const { return endpoint_name_; }
|
||||
glcr::String& mutable_endpoint_name() { return endpoint_name_; }
|
||||
void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -65,13 +73,16 @@ class Endpoint {
|
|||
Endpoint() {}
|
||||
// Delete copy and move until implemented.
|
||||
Endpoint(const Endpoint&) = delete;
|
||||
Endpoint(Endpoint&&) = delete;
|
||||
Endpoint(Endpoint&&) = default;
|
||||
Endpoint& operator=(Endpoint&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const z_cap_t& endpoint() const { return endpoint_; }
|
||||
z_cap_t& mutable_endpoint() { return endpoint_; }
|
||||
void set_endpoint(const z_cap_t& value) { endpoint_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -87,15 +98,20 @@ class AhciInfo {
|
|||
AhciInfo() {}
|
||||
// Delete copy and move until implemented.
|
||||
AhciInfo(const AhciInfo&) = delete;
|
||||
AhciInfo(AhciInfo&&) = delete;
|
||||
AhciInfo(AhciInfo&&) = default;
|
||||
AhciInfo& operator=(AhciInfo&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const z_cap_t& ahci_region() const { return ahci_region_; }
|
||||
z_cap_t& mutable_ahci_region() { return ahci_region_; }
|
||||
void set_ahci_region(const z_cap_t& value) { ahci_region_ = value; }
|
||||
|
||||
const uint64_t& region_length() const { return region_length_; }
|
||||
uint64_t& mutable_region_length() { return region_length_; }
|
||||
void set_region_length(const uint64_t& value) { region_length_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -112,35 +128,60 @@ class FramebufferInfo {
|
|||
FramebufferInfo() {}
|
||||
// Delete copy and move until implemented.
|
||||
FramebufferInfo(const FramebufferInfo&) = delete;
|
||||
FramebufferInfo(FramebufferInfo&&) = delete;
|
||||
FramebufferInfo(FramebufferInfo&&) = default;
|
||||
FramebufferInfo& operator=(FramebufferInfo&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const uint64_t& address_phys() const { return address_phys_; }
|
||||
uint64_t& mutable_address_phys() { return address_phys_; }
|
||||
void set_address_phys(const uint64_t& value) { address_phys_ = value; }
|
||||
|
||||
const uint64_t& width() const { return width_; }
|
||||
uint64_t& mutable_width() { return width_; }
|
||||
void set_width(const uint64_t& value) { width_ = value; }
|
||||
|
||||
const uint64_t& height() const { return height_; }
|
||||
uint64_t& mutable_height() { return height_; }
|
||||
void set_height(const uint64_t& value) { height_ = value; }
|
||||
|
||||
const uint64_t& pitch() const { return pitch_; }
|
||||
uint64_t& mutable_pitch() { return pitch_; }
|
||||
void set_pitch(const uint64_t& value) { pitch_ = value; }
|
||||
|
||||
const uint64_t& bpp() const { return bpp_; }
|
||||
uint64_t& mutable_bpp() { return bpp_; }
|
||||
void set_bpp(const uint64_t& value) { bpp_ = value; }
|
||||
|
||||
const uint64_t& memory_model() const { return memory_model_; }
|
||||
uint64_t& mutable_memory_model() { return memory_model_; }
|
||||
void set_memory_model(const uint64_t& value) { memory_model_ = value; }
|
||||
|
||||
const uint64_t& red_mask_size() const { return red_mask_size_; }
|
||||
uint64_t& mutable_red_mask_size() { return red_mask_size_; }
|
||||
void set_red_mask_size(const uint64_t& value) { red_mask_size_ = value; }
|
||||
|
||||
const uint64_t& red_mask_shift() const { return red_mask_shift_; }
|
||||
uint64_t& mutable_red_mask_shift() { return red_mask_shift_; }
|
||||
void set_red_mask_shift(const uint64_t& value) { red_mask_shift_ = value; }
|
||||
|
||||
const uint64_t& green_mask_size() const { return green_mask_size_; }
|
||||
uint64_t& mutable_green_mask_size() { return green_mask_size_; }
|
||||
void set_green_mask_size(const uint64_t& value) { green_mask_size_ = value; }
|
||||
|
||||
const uint64_t& green_mask_shift() const { return green_mask_shift_; }
|
||||
uint64_t& mutable_green_mask_shift() { return green_mask_shift_; }
|
||||
void set_green_mask_shift(const uint64_t& value) { green_mask_shift_ = value; }
|
||||
|
||||
const uint64_t& blue_mask_size() const { return blue_mask_size_; }
|
||||
uint64_t& mutable_blue_mask_size() { return blue_mask_size_; }
|
||||
void set_blue_mask_size(const uint64_t& value) { blue_mask_size_ = value; }
|
||||
|
||||
const uint64_t& blue_mask_shift() const { return blue_mask_shift_; }
|
||||
uint64_t& mutable_blue_mask_shift() { return blue_mask_shift_; }
|
||||
void set_blue_mask_shift(const uint64_t& value) { blue_mask_shift_ = value; }
|
||||
|
||||
private:
|
||||
|
@ -167,17 +208,24 @@ class DenaliInfo {
|
|||
DenaliInfo() {}
|
||||
// Delete copy and move until implemented.
|
||||
DenaliInfo(const DenaliInfo&) = delete;
|
||||
DenaliInfo(DenaliInfo&&) = delete;
|
||||
DenaliInfo(DenaliInfo&&) = default;
|
||||
DenaliInfo& operator=(DenaliInfo&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
const z_cap_t& denali_endpoint() const { return denali_endpoint_; }
|
||||
z_cap_t& mutable_denali_endpoint() { return denali_endpoint_; }
|
||||
void set_denali_endpoint(const z_cap_t& value) { denali_endpoint_ = value; }
|
||||
|
||||
const uint64_t& device_id() const { return device_id_; }
|
||||
uint64_t& mutable_device_id() { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
|
||||
const uint64_t& lba_offset() const { return lba_offset_; }
|
||||
uint64_t& mutable_lba_offset() { return lba_offset_; }
|
||||
void set_lba_offset(const uint64_t& value) { lba_offset_ = value; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -63,7 +63,7 @@ glcr::Status {{message.name}}::ParseFromBytesInternal(const yunq::MessageView& m
|
|||
{%- if not field.repeated %}
|
||||
message.ReadMessage<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_);
|
||||
{%- else %}
|
||||
message.ReadMessageRepeated<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_);
|
||||
message.ReadRepeatedMessage<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_);
|
||||
{% endif %}
|
||||
|
||||
{%- elif field.type != Type.CAPABILITY %}
|
||||
|
@ -105,10 +105,12 @@ uint64_t {{message.name}}::SerializeInternal(yunq::Serializer& serializer) const
|
|||
|
||||
{%- else %}
|
||||
|
||||
{%- if field.type != Type.CAPABILITY %}
|
||||
serializer.WriteRepeated<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_);
|
||||
{%- else %}
|
||||
{%- if field.type == Type.MESSAGE %}
|
||||
serializer.WriteRepeatedMessage<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_);
|
||||
{%- elif field.type != Type.CAPABILITY %}
|
||||
serializer.WriteRepeatedCapability({{field.number}}, {{field.name}}_);
|
||||
{%- else %}
|
||||
serializer.WriteRepeated<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_);
|
||||
{%- endif %}
|
||||
|
||||
{%- endif %}
|
||||
|
|
|
@ -20,7 +20,8 @@ class {{message.name}} {
|
|||
{{message.name}}() {}
|
||||
// Delete copy and move until implemented.
|
||||
{{message.name}}(const {{message.name}}&) = delete;
|
||||
{{message.name}}({{message.name}}&&) = delete;
|
||||
{{message.name}}({{message.name}}&&) = default;
|
||||
{{message.name}}& operator=({{message.name}}&&) = default;
|
||||
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
|
||||
|
@ -28,19 +29,24 @@ class {{message.name}} {
|
|||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
{%- for field in message.fields %}
|
||||
{%- if field.type == Type.MESSAGE %}
|
||||
{%- if not field.repeated %}
|
||||
|
||||
const {{field.cpp_type()}}& {{field.name}}() const { return {{field.name}}_; }
|
||||
{{field.cpp_type()}}& mutable_{{field.name}}() { return {{field.name}}_; }
|
||||
|
||||
{%- if field.type != Type.MESSAGE %}
|
||||
void set_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_ = value; }
|
||||
{%- endif %}
|
||||
|
||||
{%- else %}
|
||||
|
||||
{%- if not field.repeated %}
|
||||
const {{field.cpp_type()}}& {{field.name}}() const { return {{field.name}}_; }
|
||||
void set_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_ = value; }
|
||||
{%- else %}
|
||||
const glcr::Vector<{{field.cpp_type()}}>& {{field.name}}() const { return {{field.name}}_; }
|
||||
glcr::Vector<{{field.cpp_type()}}>& mutable_{{field.name}}() { return {{field.name}}_; }
|
||||
|
||||
{%- if field.type != Type.MESSAGE %}
|
||||
void add_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_.PushBack(value); }
|
||||
{%- endif %}
|
||||
void add_{{field.name}}({{field.cpp_type()}}&& value) { {{field.name}}_.PushBack(glcr::Move(value)); }
|
||||
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
|
Loading…
Reference in New Issue