From patchwork Wed Aug 6 15:48:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 24066 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9795FBDCC1 for ; Wed, 6 Aug 2025 15:48:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8C76169224; Wed, 6 Aug 2025 17:48:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Zdv3rygU"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CCA45691F5 for ; Wed, 6 Aug 2025 17:48:46 +0200 (CEST) Received: from pb-laptop.local (185.182.215.213.nat.pool.zt.hu [185.182.215.213]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 44D361249; Wed, 6 Aug 2025 17:47:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1754495278; bh=wOy7DUm0AgjVIbGWO8WE6CzuWqdOtZjV2/exTN58kzA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Zdv3rygUBhgLzjDXWD5J2aGepr+8YphOHQVGZLucf0Z2eeqicNjXqGNvCdocoLRhH 8kZWX7zzTV3Gw1Szye+3144Z+gwjIqporxo9gJ1D8fCpKdKaAndO1OjLV0YMm6sYTi GjP8UTvzQLStEKi5eMcFM2SipQ3DLgZ2g2FU+tig= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder Subject: [RFC PATCH v1 3/3] utils: codegen: ipc: Generate templated constructor Date: Wed, 6 Aug 2025 17:48:42 +0200 Message-ID: <20250806154842.597155-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250806154842.597155-1-barnabas.pocze@ideasonboard.com> References: <20250806154842.597155-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Forcing the "non-pod" members to be initialized from `const T&` is not the ideal solution because it disallows e.g. move constructors. So generate a templated constructor, which members to be initialized more freely, e.g. using move constructors. Signed-off-by: Barnabás Pőcze Reviewed-by: Paul Elder --- .../libcamera_templates/core_ipa_interface.h.tmpl | 2 ++ .../libcamera_templates/definition_functions.tmpl | 15 +++++++++++---- .../module_ipa_interface.h.tmpl | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/utils/codegen/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl b/utils/codegen/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl index 3942e5708..93f988cd9 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl @@ -16,6 +16,8 @@ {% if has_map %}#include {% endif %} {% if has_string %}#include {% endif %} +#include +#include {% if has_array %}#include {% endif %} #include diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl index 3a57a3c2c..0b5bbd933 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl @@ -28,14 +28,21 @@ public: #ifndef __DOXYGEN__ {{struct.mojom_name}}() = default; + template< + {%- for field in struct.fields %} + typename T{{loop.index}} = {{field|name}}, + {%- endfor %} + {%- for field in struct.fields %} + std::enable_if_t> * = nullptr{{"," if not loop.last}} + {%- endfor %} + > {{struct.mojom_name}}( {%- for field in struct.fields -%} -{{"const " if not field|is_pod}}{{field|name}} {{"&" if not field|is_pod}}_{{field.mojom_name}}{{", " if not loop.last}} + T{{loop.index}} &&arg{{loop.index}}{{ ", " if not loop.last }} {%- endfor -%} ) - : -{%- for field in struct.fields -%} -{{" " if loop.first}}{{field.mojom_name}}(_{{field.mojom_name}}){{", " if not loop.last}} +{%- for field in struct.fields %} + {{": " if loop.first else ", "}}{{field.mojom_name}}(std::forward(arg{{loop.index}})) {%- endfor %} { } diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_interface.h.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_interface.h.tmpl index 5d70ea6a2..3913eb1fb 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_interface.h.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_interface.h.tmpl @@ -16,6 +16,8 @@ {% if has_map %}#include {% endif %} {% if has_string %}#include {% endif %} +#include +#include {% if has_array %}#include {% endif %} #include