[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
|
|
@ -20,7 +20,8 @@ struct ExtPointer {
|
|||
|
||||
{%- for message in messages %}
|
||||
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
||||
yunq::MessageView message(bytes, offset);
|
||||
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||
|
||||
{%- for field in message.fields %}
|
||||
{%- if field.type == Type.CAPABILITY %}
|
||||
|
|
@ -33,7 +34,8 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
|
|||
}
|
||||
|
||||
glcr::Status {{message.name}}::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));
|
||||
|
||||
{%- for field in message.fields %}
|
||||
{%- if field.type == Type.CAPABILITY %}
|
||||
|
|
@ -46,19 +48,17 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
|
|||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status {{message.name}}::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
||||
|
||||
yunq::MessageView view(bytes, offset);
|
||||
glcr::Status {{message.name}}::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||
RETURN_ERROR(message.CheckHeader());
|
||||
|
||||
{%- for field in message.fields %}
|
||||
// Parse {{field.name}}.
|
||||
{%- if field.type != Type.CAPABILITY %}
|
||||
|
||||
{%- if not field.repeated %}
|
||||
ASSIGN_OR_RETURN({{field.name}}_, view.ReadField<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
ASSIGN_OR_RETURN({{field.name}}_, message.ReadField<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
{%- else %}
|
||||
ASSIGN_OR_RETURN({{field.name}}_, view.ReadRepeated<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
ASSIGN_OR_RETURN({{field.name}}_, message.ReadRepeated<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
{% endif %}
|
||||
|
||||
{%- endif %}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
{% if package != None %}
|
||||
|
|
@ -45,7 +46,7 @@ class {{message.name}} {
|
|||
{%- endfor %}
|
||||
|
||||
// Parses everything except for caps.
|
||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||
};
|
||||
{%- endfor %}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue