utils: ipc: Support custom parameters to init()

Add support to the mojom-based code generator for custom parameters to
init(). Remove the parameter type and count validation as well.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Paul Elder 2021-03-08 16:48:26 +09:00
parent 3a59555414
commit 51e5d67f8e
3 changed files with 13 additions and 27 deletions

View file

@ -141,10 +141,19 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
{{proxy_funcs.func_sig(proxy_name, method, "Thread")}} {{proxy_funcs.func_sig(proxy_name, method, "Thread")}}
{ {
{%- if method.mojom_name == "init" %} {%- if method.mojom_name == "stop" %}
{{proxy_funcs.init_thread_body()}}
{%- elif method.mojom_name == "stop" %}
{{proxy_funcs.stop_thread_body()}} {{proxy_funcs.stop_thread_body()}}
{%- elif method.mojom_name == "init" %}
{{ method|method_return_value + " _ret = " if method|method_return_value != "void" -}}
ipa_->{{method.mojom_name}}(
{%- for param in method|method_param_names -%}
{{param}}{{- ", " if not loop.last}}
{%- endfor -%}
);
proxy_.moveToThread(&thread_);
return {{ "_ret" if method|method_return_value != "void" }};
{%- elif method.mojom_name == "start" %} {%- elif method.mojom_name == "start" %}
running_ = true; running_ = true;
thread_.start(); thread_.start();

View file

@ -19,19 +19,6 @@
){{" override" if override}} ){{" override" if override}}
{%- endmacro -%} {%- endmacro -%}
{#
# \brief Generate function body for IPA init() function for thread
#}
{%- macro init_thread_body() -%}
int ret = ipa_->init(settings);
if (ret)
return ret;
proxy_.moveToThread(&thread_);
return 0;
{%- endmacro -%}
{# {#
# \brief Generate function body for IPA stop() function for thread # \brief Generate function body for IPA stop() function for thread
#} #}

View file

@ -341,19 +341,9 @@ def ValidateInterfaces(interfaces):
ValidateSingleLength(f_start, 'start()', False) ValidateSingleLength(f_start, 'start()', False)
ValidateSingleLength(f_stop, 'stop()', False) ValidateSingleLength(f_stop, 'stop()', False)
f_init = f_init[0]
f_start = f_start[0]
f_stop = f_stop[0] f_stop = f_stop[0]
# Validate parameters to init() # No need to validate init() and start() as they are customizable
ValidateSingleLength(f_init.parameters, 'input parameter to init()')
ValidateSingleLength(f_init.response_parameters, 'output parameter from init()')
if f_init.parameters[0].kind.mojom_name != 'IPASettings':
raise Exception('init() must have single IPASettings input parameter')
if f_init.response_parameters[0].kind.spec != 'i32':
raise Exception('init() must have single int32 output parameter')
# No need to validate start() as it is customizable
# Validate parameters to stop() # Validate parameters to stop()
ValidateZeroLength(f_stop.parameters, 'input parameter to stop()') ValidateZeroLength(f_stop.parameters, 'input parameter to stop()')