[Yunq] Read capabilities using the parsing library.

This commit is contained in:
Drew Galbraith 2024-01-11 19:59:36 -08:00
parent 0e6aa532a1
commit 75d84a0fa5
7 changed files with 41 additions and 40 deletions

View file

@ -25,9 +25,13 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
{%- for field in message.fields %}
{%- if field.type == Type.CAPABILITY %}
{%- if not field.repeated %}
// Parse {{field.name}}.
// FIXME: Implement in-buffer capabilities for inprocess serialization.
set_{{field.name}}(0);
ASSIGN_OR_RETURN({{field.name}}_, message.ReadCapability({{loop.index0}}));
{%- else %}
// Parse {{field.name}}.
ASSIGN_OR_RETURN({{field.name}}_, message.ReadRepeatedCapability({{loop.index0}}));
{%- endif %}
{%- endif %}
{%- endfor %}
return glcr::Status::Ok();
@ -39,10 +43,13 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
{%- for field in message.fields %}
{%- if field.type == Type.CAPABILITY %}
{%- if not field.repeated %}
// Parse {{field.name}}.
uint64_t {{field.name}}_ptr = bytes.At<uint64_t>(offset + header_size + (8 * {{loop.index0}}));
set_{{field.name}}(caps.At({{field.name}}_ptr));
ASSIGN_OR_RETURN({{field.name}}_, message.ReadCapability({{loop.index0}}, caps));
{%- else %}
// Parse {{field.name}}.
ASSIGN_OR_RETURN({{field.name}}_, message.ReadRepeatedCapability({{loop.index0}}, caps));
{%- endif %}
{%- endif %}
{%- endfor %}
return glcr::Status::Ok();