[RFC,v1,5/8] utils: codegen: ipc: Simplify `return` statements
diff mbox series

Message ID 20250515120012.3127231-6-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • utils: codegen: ipc: Simplify deserialization
Related show

Commit Message

Barnabás Pőcze May 15, 2025, noon UTC
Returning an expression of type `void` from a function returning `void`
is legal, so do not handle those cases specially.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 .../libcamera_templates/module_ipa_proxy.cpp.tmpl      | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Paul Elder May 15, 2025, 12:27 p.m. UTC | #1
Quoting Barnabás Pőcze (2025-05-15 14:00:09)
> Returning an expression of type `void` from a function returning `void`
> is legal, so do not handle those cases specially.

Oh I didn't know that, neat.

> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  .../libcamera_templates/module_ipa_proxy.cpp.tmpl      | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
> index effc8f7dd..9a3aadbd2 100644
> --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
> +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
> @@ -127,13 +127,13 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
>  {{proxy_funcs.func_sig(proxy_name, method)}}
>  {
>         if (isolate_)
> -               {{"return " if method|method_return_value != "void"}}{{method.mojom_name}}IPC(
> +               return {{method.mojom_name}}IPC(
>  {%- for param in method|method_param_names -%}
>                 {{param}}{{- ", " if not loop.last}}
>  {%- endfor -%}
>  );
>         else
> -               {{"return " if method|method_return_value != "void"}}{{method.mojom_name}}Thread(
> +               return {{method.mojom_name}}Thread(
>  {%- for param in method|method_param_names -%}
>                 {{param}}{{- ", " if not loop.last}}
>  {%- endfor -%}
> @@ -159,16 +159,14 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
>         state_ = ProxyRunning;
>         thread_.start();
>  
> -       {{ "return " if method|method_return_value != "void" -}}
> -       proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking
> +       return proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking
>         {{- ", " if method|method_param_names}}
>         {%- for param in method|method_param_names -%}
>                 {{param}}{{- ", " if not loop.last}}
>         {%- endfor -%}
>  );
>  {%- elif not method|is_async %}
> -       {{ "return " if method|method_return_value != "void" -}}
> -       ipa_->{{method.mojom_name}}(
> +       return ipa_->{{method.mojom_name}}(
>         {%- for param in method|method_param_names -%}
>                 {{param}}{{- ", " if not loop.last}}
>         {%- endfor -%}
> -- 
> 2.49.0
>

Patch
diff mbox series

diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
index effc8f7dd..9a3aadbd2 100644
--- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
+++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
@@ -127,13 +127,13 @@  void {{proxy_name}}::recvMessage(const IPCMessage &data)
 {{proxy_funcs.func_sig(proxy_name, method)}}
 {
 	if (isolate_)
-		{{"return " if method|method_return_value != "void"}}{{method.mojom_name}}IPC(
+		return {{method.mojom_name}}IPC(
 {%- for param in method|method_param_names -%}
 		{{param}}{{- ", " if not loop.last}}
 {%- endfor -%}
 );
 	else
-		{{"return " if method|method_return_value != "void"}}{{method.mojom_name}}Thread(
+		return {{method.mojom_name}}Thread(
 {%- for param in method|method_param_names -%}
 		{{param}}{{- ", " if not loop.last}}
 {%- endfor -%}
@@ -159,16 +159,14 @@  void {{proxy_name}}::recvMessage(const IPCMessage &data)
 	state_ = ProxyRunning;
 	thread_.start();
 
-	{{ "return " if method|method_return_value != "void" -}}
-	proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking
+	return proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking
 	{{- ", " if method|method_param_names}}
 	{%- for param in method|method_param_names -%}
 		{{param}}{{- ", " if not loop.last}}
 	{%- endfor -%}
 );
 {%- elif not method|is_async %}
-	{{ "return " if method|method_return_value != "void" -}}
-	ipa_->{{method.mojom_name}}(
+	return ipa_->{{method.mojom_name}}(
 	{%- for param in method|method_param_names -%}
 		{{param}}{{- ", " if not loop.last}}
 	{%- endfor -%}