diff --git a/sys/denali/lib/denali/denali.yunq.client.cpp b/sys/denali/lib/denali/denali.yunq.client.cpp index af49317..09e6f6a 100644 --- a/sys/denali/lib/denali/denali.yunq.client.cpp +++ b/sys/denali/lib/denali/denali.yunq.client.cpp @@ -48,7 +48,8 @@ glcr::Status DenaliClient::Read(const ReadRequest& request, ReadResponse& respon RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; @@ -87,7 +88,8 @@ glcr::Status DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; diff --git a/sys/denali/lib/denali/denali.yunq.cpp b/sys/denali/lib/denali/denali.yunq.cpp index 9a56e3a..ffdc39a 100644 --- a/sys/denali/lib/denali/denali.yunq.cpp +++ b/sys/denali/lib/denali/denali.yunq.cpp @@ -15,14 +15,12 @@ struct ExtPointer { }; } // namespace -glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status ReadRequest::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status ReadRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } @@ -71,14 +69,12 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, return next_extension; } -glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status ReadManyRequest::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status ReadManyRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } @@ -173,16 +169,14 @@ uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off return next_extension; } -glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status ReadResponse::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse memory. ASSIGN_OR_RETURN(memory_, message.ReadCapability(2)); return glcr::Status::Ok(); } -glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status ReadResponse::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse memory. ASSIGN_OR_RETURN(memory_, message.ReadCapability(2, caps)); diff --git a/sys/denali/lib/denali/denali.yunq.h b/sys/denali/lib/denali/denali.yunq.h index 3e5973f..a32d782 100644 --- a/sys/denali/lib/denali/denali.yunq.h +++ b/sys/denali/lib/denali/denali.yunq.h @@ -17,8 +17,8 @@ class ReadRequest { ReadRequest(const ReadRequest&) = delete; ReadRequest(ReadRequest&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -43,8 +43,8 @@ class ReadManyRequest { ReadManyRequest(const ReadManyRequest&) = delete; ReadManyRequest(ReadManyRequest&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -69,8 +69,8 @@ class ReadResponse { ReadResponse(const ReadResponse&) = delete; ReadResponse(ReadResponse&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } diff --git a/sys/denali/lib/denali/denali.yunq.server.cpp b/sys/denali/lib/denali/denali.yunq.server.cpp index 9f9764e..4fe21f5 100644 --- a/sys/denali/lib/denali/denali.yunq.server.cpp +++ b/sys/denali/lib/denali/denali.yunq.server.cpp @@ -104,7 +104,8 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request, ReadRequest yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); @@ -124,7 +125,8 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request, ReadManyRequest yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); diff --git a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.client.cpp b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.client.cpp index aa289d2..dec023a 100644 --- a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.client.cpp +++ b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.client.cpp @@ -48,7 +48,8 @@ glcr::Status VFSClient::OpenFile(const OpenFileRequest& request, OpenFileRespons RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; @@ -87,7 +88,8 @@ glcr::Status VFSClient::GetDirectory(const GetDirectoryRequest& request, Directo RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; diff --git a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.cpp b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.cpp index 5bf0b5d..0c0d70b 100644 --- a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.cpp +++ b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.cpp @@ -15,14 +15,12 @@ struct ExtPointer { }; } // namespace -glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status OpenFileRequest::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status OpenFileRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } @@ -77,16 +75,14 @@ uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off return next_extension; } -glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status OpenFileResponse::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse memory. ASSIGN_OR_RETURN(memory_, message.ReadCapability(2)); return glcr::Status::Ok(); } -glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status OpenFileResponse::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse memory. ASSIGN_OR_RETURN(memory_, message.ReadCapability(2, caps)); @@ -156,14 +152,12 @@ uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of return next_extension; } -glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status GetDirectoryRequest::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status GetDirectoryRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } @@ -218,14 +212,12 @@ uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t return next_extension; } -glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status Directory::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status Directory::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } diff --git a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h index 0b54d3b..5a294fc 100644 --- a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h +++ b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h @@ -17,8 +17,8 @@ class OpenFileRequest { OpenFileRequest(const OpenFileRequest&) = delete; OpenFileRequest(OpenFileRequest&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -37,8 +37,8 @@ class OpenFileResponse { OpenFileResponse(const OpenFileResponse&) = delete; OpenFileResponse(OpenFileResponse&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -63,8 +63,8 @@ class GetDirectoryRequest { GetDirectoryRequest(const GetDirectoryRequest&) = delete; GetDirectoryRequest(GetDirectoryRequest&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -83,8 +83,8 @@ class Directory { Directory(const Directory&) = delete; Directory(Directory&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } diff --git a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.server.cpp b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.server.cpp index 85a8a73..f5e7061 100644 --- a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.server.cpp +++ b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.server.cpp @@ -104,7 +104,8 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request, OpenFileRequest yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); @@ -124,7 +125,8 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request, GetDirectoryRequest yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); diff --git a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.cpp b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.cpp index 1214c2f..863a0d9 100644 --- a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.cpp +++ b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.cpp @@ -15,16 +15,14 @@ struct ExtPointer { }; } // namespace -glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status KeyboardListener::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse port_capability. ASSIGN_OR_RETURN(port_capability_, message.ReadCapability(0)); return glcr::Status::Ok(); } -glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status KeyboardListener::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse port_capability. ASSIGN_OR_RETURN(port_capability_, message.ReadCapability(0, caps)); diff --git a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h index 7abc356..727b31b 100644 --- a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h +++ b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h @@ -17,8 +17,8 @@ class KeyboardListener { KeyboardListener(const KeyboardListener&) = delete; KeyboardListener(KeyboardListener&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } diff --git a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.server.cpp b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.server.cpp index f8376dc..80fa141 100644 --- a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.server.cpp +++ b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.server.cpp @@ -104,7 +104,8 @@ glcr::Status VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request, KeyboardListener yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); diff --git a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.client.cpp b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.client.cpp index d7baf54..03352e1 100644 --- a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.client.cpp +++ b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.client.cpp @@ -87,7 +87,8 @@ glcr::Status YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, E RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; @@ -126,7 +127,8 @@ glcr::Status YellowstoneClient::GetAhciInfo(AhciInfo& response) { RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; @@ -165,7 +167,8 @@ glcr::Status YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) { RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; @@ -204,7 +207,8 @@ glcr::Status YellowstoneClient::GetDenali(DenaliInfo& response) { RET_ERR(buffer_.At(8)); - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); return glcr::OK; diff --git a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.cpp b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.cpp index ec2dffa..0b21546 100644 --- a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.cpp +++ b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.cpp @@ -17,16 +17,14 @@ struct ExtPointer { }; } // namespace -glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status RegisterEndpointRequest::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse endpoint_capability. ASSIGN_OR_RETURN(endpoint_capability_, message.ReadCapability(1)); return glcr::Status::Ok(); } -glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status RegisterEndpointRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse endpoint_capability. ASSIGN_OR_RETURN(endpoint_capability_, message.ReadCapability(1, caps)); @@ -90,14 +88,12 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint return next_extension; } -glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status GetEndpointRequest::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status GetEndpointRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } @@ -152,16 +148,14 @@ uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t return next_extension; } -glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status Endpoint::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse endpoint. ASSIGN_OR_RETURN(endpoint_, message.ReadCapability(0)); return glcr::Status::Ok(); } -glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status Endpoint::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse endpoint. ASSIGN_OR_RETURN(endpoint_, message.ReadCapability(0, caps)); @@ -201,16 +195,14 @@ uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl return next_extension; } -glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status AhciInfo::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse ahci_region. ASSIGN_OR_RETURN(ahci_region_, message.ReadCapability(0)); return glcr::Status::Ok(); } -glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status AhciInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse ahci_region. ASSIGN_OR_RETURN(ahci_region_, message.ReadCapability(0, caps)); @@ -256,14 +248,12 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl return next_extension; } -glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status FramebufferInfo::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } -glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status FramebufferInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); return glcr::Status::Ok(); } @@ -366,16 +356,14 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off return next_extension; } -glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status DenaliInfo::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse denali_endpoint. ASSIGN_OR_RETURN(denali_endpoint_, message.ReadCapability(0)); return glcr::Status::Ok(); } -glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status DenaliInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); // Parse denali_endpoint. ASSIGN_OR_RETURN(denali_endpoint_, message.ReadCapability(0, caps)); diff --git a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h index 01af62b..c69b5a2 100644 --- a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h +++ b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h @@ -19,8 +19,8 @@ class RegisterEndpointRequest { RegisterEndpointRequest(const RegisterEndpointRequest&) = delete; RegisterEndpointRequest(RegisterEndpointRequest&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -42,8 +42,8 @@ class GetEndpointRequest { GetEndpointRequest(const GetEndpointRequest&) = delete; GetEndpointRequest(GetEndpointRequest&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -62,8 +62,8 @@ class Endpoint { Endpoint(const Endpoint&) = delete; Endpoint(Endpoint&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -82,8 +82,8 @@ class AhciInfo { AhciInfo(const AhciInfo&) = delete; AhciInfo(AhciInfo&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -105,8 +105,8 @@ class FramebufferInfo { FramebufferInfo(const FramebufferInfo&) = delete; FramebufferInfo(FramebufferInfo&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } @@ -158,8 +158,8 @@ class DenaliInfo { DenaliInfo(const DenaliInfo&) = delete; DenaliInfo(DenaliInfo&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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_; } diff --git a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.server.cpp b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.server.cpp index c0205ae..d410658 100644 --- a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.server.cpp +++ b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.server.cpp @@ -106,7 +106,8 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques RegisterEndpointRequest yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); @@ -124,7 +125,8 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques GetEndpointRequest yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); diff --git a/yunq/client.cpp.jinja b/yunq/client.cpp.jinja index 0643ad6..63721e0 100644 --- a/yunq/client.cpp.jinja +++ b/yunq/client.cpp.jinja @@ -56,7 +56,8 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}& RET_ERR(buffer_.At(8)); {% if method.response != None %} - RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_)); + yunq::MessageView resp_view(buffer_, 16); + RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_)); {% endif %} return glcr::OK; diff --git a/yunq/message.cpp.jinja b/yunq/message.cpp.jinja index 67919e9..403188e 100644 --- a/yunq/message.cpp.jinja +++ b/yunq/message.cpp.jinja @@ -19,8 +19,7 @@ struct ExtPointer { } // namespace {%- for message in messages %} -glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) { - yunq::MessageView message(bytes, offset); +glcr::Status {{message.name}}::ParseFromBytes(const yunq::MessageView& message) { RETURN_ERROR(ParseFromBytesInternal(message)); {%- for field in message.fields %} @@ -37,8 +36,7 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin return glcr::Status::Ok(); } -glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) { - yunq::MessageView message(bytes, offset); +glcr::Status {{message.name}}::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) { RETURN_ERROR(ParseFromBytesInternal(message)); {%- for field in message.fields %} diff --git a/yunq/message.h.jinja b/yunq/message.h.jinja index e98cfb5..79d47cd 100644 --- a/yunq/message.h.jinja +++ b/yunq/message.h.jinja @@ -21,8 +21,8 @@ class {{message.name}} { {{message.name}}(const {{message.name}}&) = delete; {{message.name}}({{message.name}}&&) = delete; - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset); - [[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&); + [[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; diff --git a/yunq/server.cpp.jinja b/yunq/server.cpp.jinja index 6f8a712..734166d 100644 --- a/yunq/server.cpp.jinja +++ b/yunq/server.cpp.jinja @@ -107,7 +107,8 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer& {% if method.request != None %} {{method.request}} yunq_request; - RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps)); + yunq::MessageView request_view(request, kHeaderSize); + RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps)); {% endif %} {% if method.response != None %}