utils: ipc: Add support for enums in function parameters
There is already support for enums as struct members, but there was no support for enums in function parameters. Add it. This does not add support for returning enums as direct return values. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
44eb16fb18
commit
3f9da2a71e
1 changed files with 14 additions and 2 deletions
|
@ -52,6 +52,9 @@
|
||||||
#}
|
#}
|
||||||
{%- macro serialize_call(params, buf, fds) %}
|
{%- macro serialize_call(params, buf, fds) %}
|
||||||
{%- for param in params %}
|
{%- for param in params %}
|
||||||
|
{%- if param|is_enum %}
|
||||||
|
static_assert(sizeof({{param|name_full}}) <= 4);
|
||||||
|
{%- endif %}
|
||||||
std::vector<uint8_t> {{param.mojom_name}}Buf;
|
std::vector<uint8_t> {{param.mojom_name}}Buf;
|
||||||
{%- if param|has_fd %}
|
{%- if param|has_fd %}
|
||||||
std::vector<SharedFD> {{param.mojom_name}}Fds;
|
std::vector<SharedFD> {{param.mojom_name}}Fds;
|
||||||
|
@ -59,7 +62,11 @@
|
||||||
{%- else %}
|
{%- else %}
|
||||||
std::tie({{param.mojom_name}}Buf, std::ignore) =
|
std::tie({{param.mojom_name}}Buf, std::ignore) =
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if param|is_enum %}
|
||||||
|
IPADataSerializer<uint32_t>::serialize(static_cast<uint32_t>({{param.mojom_name}})
|
||||||
|
{%- else %}
|
||||||
IPADataSerializer<{{param|name}}>::serialize({{param.mojom_name}}
|
IPADataSerializer<{{param|name}}>::serialize({{param.mojom_name}}
|
||||||
|
{% endif -%}
|
||||||
{{- ", &controlSerializer_" if param|needs_control_serializer -}}
|
{{- ", &controlSerializer_" if param|needs_control_serializer -}}
|
||||||
);
|
);
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -97,7 +104,12 @@
|
||||||
# This code is meant to be used by macro deserialize_call.
|
# This code is meant to be used by macro deserialize_call.
|
||||||
#}
|
#}
|
||||||
{%- macro deserialize_param(param, pointer, loop, buf, fds, iter, data_size) -%}
|
{%- macro deserialize_param(param, pointer, loop, buf, fds, iter, data_size) -%}
|
||||||
{{"*" if pointer}}{{param.mojom_name}} = IPADataSerializer<{{param|name}}>::deserialize(
|
{{"*" if pointer}}{{param.mojom_name}} =
|
||||||
|
{%- if param|is_enum %}
|
||||||
|
static_cast<{{param|name_full}}>(IPADataSerializer<uint32_t>::deserialize(
|
||||||
|
{%- else %}
|
||||||
|
IPADataSerializer<{{param|name}}>::deserialize(
|
||||||
|
{%- endif %}
|
||||||
{{buf}}{{- ".cbegin()" if not iter}} + {{param.mojom_name}}Start,
|
{{buf}}{{- ".cbegin()" if not iter}} + {{param.mojom_name}}Start,
|
||||||
{%- if loop.last and not iter %}
|
{%- if loop.last and not iter %}
|
||||||
{{buf}}.cend()
|
{{buf}}.cend()
|
||||||
|
@ -121,7 +133,7 @@
|
||||||
{%- if param|needs_control_serializer %}
|
{%- if param|needs_control_serializer %}
|
||||||
&controlSerializer_
|
&controlSerializer_
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
);
|
){{")" if param|is_enum}};
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue