From patchwork Wed Aug 6 15:48:40 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: 24064 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 68DC2BDCC1 for ; Wed, 6 Aug 2025 15:48:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4AB66691F5; Wed, 6 Aug 2025 17:48:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NZjQ34az"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 49E59691F5 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 9A0E1EBA; Wed, 6 Aug 2025 17:47:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1754495277; bh=go0PzicxPC7NFbMrKSJiidOh5KZ6u9wdXCJZYNJ5K1Q=; h=From:To:Subject:Date:From; b=NZjQ34azzg7zSRkU002xr6P6uVf9eA5v2d9yX2ox17P6ZfuR71Rgfx74tMxwuI55J JU6l2rruIuHx1pP6iAtKs3cRT+V0tg8wkvYpnHdJDbKUDWWFDgrRJee9t/Ot3jrAvp ISNv7Fn+yUPVNjOPq/sCR/s89+kbdZKsd6ZI6zLQ= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder Subject: [RFC PATCH v1 1/3] utils: codegen: ipc: Put default values in declaration Date: Wed, 6 Aug 2025 17:48:40 +0200 Message-ID: <20250806154842.597155-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.50.1 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" 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 Reviewed-by: Paul Elder --- .../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 -%} - - From patchwork Wed Aug 6 15:48:41 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: 24065 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 4A6CABDCC1 for ; Wed, 6 Aug 2025 15:48:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 01FD46921E; 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="LklMv5KE"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 88AC66921A 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 EFFBF1026; Wed, 6 Aug 2025 17:47:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1754495278; bh=UYdTJ5UPoeIp2IuBOhgfsAiXAdAJXg1zWNqN1bDLrVw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LklMv5KEBFTpQr2V2mGLTENdNORa3C8qGXxtUGsOVnefr78xBd5UQVcW1v4kXN1/1 Seow3uUTNyDQVPByDArxBmGGbpD6L/H1uV2fyx9Uycy17J2lPGLLToSns7JBZbtWh3 SIf+4ILMJdJafZio2q1V1hGAA9/KFWpJWi+/ZUM4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder Subject: [RFC PATCH v1 2/3] utils: codegen: ipc: Default special member ops Date: Wed, 6 Aug 2025 17:48:41 +0200 Message-ID: <20250806154842.597155-2-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" Default the copy/move constructor/assignment operators so that they are available if possible. This can allow more efficient passing and construction of these objects. Signed-off-by: Barnabás Pőcze Reviewed-by: Paul Elder --- .../libcamera_templates/definition_functions.tmpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl index 16d11c309..3a57a3c2c 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl @@ -39,6 +39,12 @@ public: {%- endfor %} { } + + {{struct.mojom_name}}(const {{struct.mojom_name}} &) = default; + {{struct.mojom_name}} &operator=(const {{struct.mojom_name}} &) = default; + {{struct.mojom_name}}({{struct.mojom_name}} &&) = default; + {{struct.mojom_name}} &operator=({{struct.mojom_name}} &&) = default; + ~{{struct.mojom_name}}() = default; #endif {% for field in struct.fields %} 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