Message ID | 20250806154842.597155-1-barnabas.pocze@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Quoting Barnabás Pőcze (2025-08-07 00:48:40) > Instead of generating a constructor to initialize each member > to its default value, simply specify the default values in > the declaration of the member. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > .../libcamera_templates/definition_functions.tmpl | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl > index 8b8509f3d..16d11c309 100644 > --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl > +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl > @@ -26,13 +26,7 @@ struct {{struct.mojom_name}} > { > public: > #ifndef __DOXYGEN__ > - {{struct.mojom_name}}() {%- if struct|has_default_fields %} > - :{% endif %} > -{%- for field in struct.fields|with_default_values -%} > -{{" " if loop.first}}{{field.mojom_name}}({{field|default_value}}){{", " if not loop.last}} > -{%- endfor %} > - { > - } > + {{struct.mojom_name}}() = default; > > {{struct.mojom_name}}( > {%- for field in struct.fields -%} > @@ -48,9 +42,7 @@ public: > #endif > > {% for field in struct.fields %} > - {{field|name}} {{field.mojom_name}}; > + {{field|name}} {{field.mojom_name}}{% if field|default_value %}{ {{field|default_value}} }{% endif %}; > {%- endfor %} > }; > {%- endmacro -%} > - > - > -- > 2.50.1 >
diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl index 8b8509f3d..16d11c309 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl @@ -26,13 +26,7 @@ struct {{struct.mojom_name}} { public: #ifndef __DOXYGEN__ - {{struct.mojom_name}}() {%- if struct|has_default_fields %} - :{% endif %} -{%- for field in struct.fields|with_default_values -%} -{{" " if loop.first}}{{field.mojom_name}}({{field|default_value}}){{", " if not loop.last}} -{%- endfor %} - { - } + {{struct.mojom_name}}() = default; {{struct.mojom_name}}( {%- for field in struct.fields -%} @@ -48,9 +42,7 @@ public: #endif {% for field in struct.fields %} - {{field|name}} {{field.mojom_name}}; + {{field|name}} {{field.mojom_name}}{% if field|default_value %}{ {{field|default_value}} }{% endif %}; {%- endfor %} }; {%- endmacro -%} - -
Instead of generating a constructor to initialize each member to its default value, simply specify the default values in the declaration of the member. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- .../libcamera_templates/definition_functions.tmpl | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)