[Yunq] Move MessageView higher in call stack.
This commit is contained in:
parent
30b220b2fb
commit
0e6aa532a1
14 changed files with 181 additions and 160 deletions
|
|
@ -16,25 +16,25 @@ struct ExtPointer {
|
|||
|
||||
} // namespace
|
||||
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
||||
|
||||
yunq::MessageView view(bytes, offset);
|
||||
glcr::Status ReadRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||
RETURN_ERROR(message.CheckHeader());
|
||||
// Parse device_id.
|
||||
ASSIGN_OR_RETURN(device_id_, view.ReadField<uint64_t>(0));
|
||||
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||
// Parse lba.
|
||||
ASSIGN_OR_RETURN(lba_, view.ReadField<uint64_t>(1));
|
||||
ASSIGN_OR_RETURN(lba_, message.ReadField<uint64_t>(1));
|
||||
// Parse size.
|
||||
ASSIGN_OR_RETURN(size_, view.ReadField<uint64_t>(2));
|
||||
ASSIGN_OR_RETURN(size_, message.ReadField<uint64_t>(2));
|
||||
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
|
@ -72,26 +72,26 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
|||
return next_extension;
|
||||
}
|
||||
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
||||
|
||||
yunq::MessageView view(bytes, offset);
|
||||
glcr::Status ReadManyRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||
RETURN_ERROR(message.CheckHeader());
|
||||
// Parse device_id.
|
||||
ASSIGN_OR_RETURN(device_id_, view.ReadField<uint64_t>(0));
|
||||
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||
// Parse lba.
|
||||
ASSIGN_OR_RETURN(lba_, view.ReadRepeated<uint64_t>(1));
|
||||
ASSIGN_OR_RETURN(lba_, message.ReadRepeated<uint64_t>(1));
|
||||
|
||||
// Parse sector_cnt.
|
||||
ASSIGN_OR_RETURN(sector_cnt_, view.ReadRepeated<uint64_t>(2));
|
||||
ASSIGN_OR_RETURN(sector_cnt_, message.ReadRepeated<uint64_t>(2));
|
||||
|
||||
|
||||
return glcr::Status::Ok();
|
||||
|
|
@ -174,7 +174,8 @@ uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
|||
return next_extension;
|
||||
}
|
||||
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
// Parse memory.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_memory(0);
|
||||
|
|
@ -182,7 +183,8 @@ glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_
|
|||
}
|
||||
|
||||
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
// Parse memory.
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||
|
||||
|
|
@ -190,14 +192,12 @@ glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_
|
|||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
||||
|
||||
yunq::MessageView view(bytes, offset);
|
||||
glcr::Status ReadResponse::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||
RETURN_ERROR(message.CheckHeader());
|
||||
// Parse device_id.
|
||||
ASSIGN_OR_RETURN(device_id_, view.ReadField<uint64_t>(0));
|
||||
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||
// Parse size.
|
||||
ASSIGN_OR_RETURN(size_, view.ReadField<uint64_t>(1));
|
||||
ASSIGN_OR_RETURN(size_, message.ReadField<uint64_t>(1));
|
||||
// Parse memory.
|
||||
|
||||
return glcr::Status::Ok();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <glacier/status/status.h>
|
||||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <yunq/message_view.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ class ReadRequest {
|
|||
uint64_t size_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
};
|
||||
class ReadManyRequest {
|
||||
public:
|
||||
|
|
@ -59,7 +60,7 @@ class ReadManyRequest {
|
|||
glcr::Vector<uint64_t> sector_cnt_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
};
|
||||
class ReadResponse {
|
||||
public:
|
||||
|
|
@ -85,6 +86,6 @@ class ReadResponse {
|
|||
z_cap_t memory_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue