From patchwork Fri Aug 15 12:31:36 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: 24139 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 B6DC6BDCC1 for ; Fri, 15 Aug 2025 12:31:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D688A6925D; Fri, 15 Aug 2025 14:31:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Re9KQEn4"; 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 C030561443 for ; Fri, 15 Aug 2025 14:31:42 +0200 (CEST) Received: from pb-laptop.local (185.221.141.188.nat.pool.zt.hu [185.221.141.188]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AD34D56D; Fri, 15 Aug 2025 14:30:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755261047; bh=WNkUQ+Q5XAw9ynxLKWUi3+LZdMgea8NIBuB6pCh5mBQ=; h=From:To:Subject:Date:From; b=Re9KQEn4rAw9a7T5TK+0FSG2Il05bMv6AxS4G9mU5Knbf9jZkoFbf/FzkhK6ckute fOJBgFxlLMMbFMjftQ4cl2P/Oe82t1vnHleMmbcOBjwTRHWUi0caM4nWI5dxDKNbsA rT58Xa0m1JJWVWuhZSSbxAS2TjUqWSzOUT9P/wgs= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder , Laurent Pinchart Subject: [RFC PATCH v2 1/3] utils: codegen: ipc: Put default values in declaration Date: Fri, 15 Aug 2025 14:31:36 +0200 Message-ID: <20250815123138.2213654-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 Reviewed-by: Laurent Pinchart --- changes in v2: none --- .../libcamera_templates/definition_functions.tmpl | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) -- 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 -%} - - From patchwork Fri Aug 15 12:31:37 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: 24140 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 25EEBBDCC1 for ; Fri, 15 Aug 2025 12:31:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 255DF69259; Fri, 15 Aug 2025 14:31:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QsalsLYz"; 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 1048F6924E for ; Fri, 15 Aug 2025 14:31:43 +0200 (CEST) Received: from pb-laptop.local (185.221.141.188.nat.pool.zt.hu [185.221.141.188]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C6FB63B; Fri, 15 Aug 2025 14:30:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755261048; bh=184HUgCoMcq401l6660AonJKHgbcZ6p+pB4xZviEhgA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QsalsLYzBmGF5leE7bjRd1wiZiyyVtNMHs5UQh5TP1KnaqsnTWGfMRH5RAXBXbJWc yKvnS7CrfeuwTrd5rA66GUpz2jr/eZbGualjhPK4sU0IBoP70kFGYUxVVI8VDU/e+1 JbbenweIKz9J9/IfYCRWjFdBDi4OrGojsNVZs13c= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder , Laurent Pinchart Subject: [RFC PATCH v2 2/3] utils: codegen: ipc: Default special member ops Date: Fri, 15 Aug 2025 14:31:37 +0200 Message-ID: <20250815123138.2213654-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250815123138.2213654-1-barnabas.pocze@ideasonboard.com> References: <20250815123138.2213654-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 --- changes in v2: none --- .../libcamera_templates/definition_functions.tmpl | 6 ++++++ 1 file changed, 6 insertions(+) -- 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 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 Fri Aug 15 12:31:38 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: 24141 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 3D3C5C3295 for ; Fri, 15 Aug 2025 12:31:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CDD7B6925F; Fri, 15 Aug 2025 14:31:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jtE2w+SH"; 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 5AA0B61443 for ; Fri, 15 Aug 2025 14:31:43 +0200 (CEST) Received: from pb-laptop.local (185.221.141.188.nat.pool.zt.hu [185.221.141.188]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D7106A8; Fri, 15 Aug 2025 14:30:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755261048; bh=eChmiVSgIH2h0YYqRMrCyKfGiAnQdeqwwBcOWSwAYHk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jtE2w+SH6XkvUNh1FsQWUAEkbfLMRqOP5X3fkneIL0QyYSMgRkdQJZoJZFdIVQ8hW hd9yO0yO7jOo5bs6K0iow5yyqNfCclrIoWZASNv3CekSa1iTQKN0dwwo48Pu/P8qk6 A+tMgoPrxoqQoDumSzepFn8ZViq2/jw12lOshuxQ= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Paul Elder , Laurent Pinchart Subject: [RFC PATCH v2 3/3] utils: codegen: ipc: Generate templated constructor Date: Fri, 15 Aug 2025 14:31:38 +0200 Message-ID: <20250815123138.2213654-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250815123138.2213654-1-barnabas.pocze@ideasonboard.com> References: <20250815123138.2213654-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 Reviewed-by: Laurent Pinchart --- changes in v2: * use `std::is_convertible_v` to avoid accidental use of explicit constructors/conversion operators --- .../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(-) -- 2.50.1 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..dec25558f 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}} &&_{{field.mojom_name}}{{ ", " 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(_{{field.mojom_name}})) {%- 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