From patchwork Thu May 15 12:00:07 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: 23368 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 426D8C3220 for ; Thu, 15 May 2025 12:00:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B38768D72; Thu, 15 May 2025 14:00:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YW6wJd6F"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4041468B6F for ; Thu, 15 May 2025 14:00:17 +0200 (CEST) Received: from pb-laptop.local (185.221.142.248.nat.pool.zt.hu [185.221.142.248]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 34FA0A98; Thu, 15 May 2025 14:00:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1747310400; bh=/B3sXhpwkTa5Gg7mdJMHshgtvVqSlm4UlwZ4Fsaw5Cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YW6wJd6FelkBbcRCTVmV28Nog00My/9EQqd7bnmYcg2K8Rf+majKhO6/zv6hwefb7 NaIgDED4QaJn2Uq1ysPKWvNsjJ6T/Dv3iEfzSa0KLO77gG8uzJu/dRfXigVFLedw0I eaNOGsAb//8aK/LuJUqopFysWJJ2GwcPhShEpD7U= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Paul Elder Subject: [RFC PATCH v1 3/8] utils: codegen: ipc: Add `deserializer()` function Date: Thu, 15 May 2025 14:00:07 +0200 Message-ID: <20250515120012.3127231-4-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250515120012.3127231-1-barnabas.pocze@ideasonboard.com> References: <20250515120012.3127231-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" Add `deserializer()` in `serializer.tmpl` to have a single function that generates all the necessary functions into the template specialization like `serializer()`. This also avoids the duplication of some conditional logic. Signed-off-by: Barnabás Pőcze Reviewed-by: Paul Elder --- .../libcamera_templates/core_ipa_serializer.h.tmpl | 7 +------ .../module_ipa_serializer.h.tmpl | 7 +------ .../generators/libcamera_templates/serializer.tmpl | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/utils/codegen/ipc/generators/libcamera_templates/core_ipa_serializer.h.tmpl b/utils/codegen/ipc/generators/libcamera_templates/core_ipa_serializer.h.tmpl index cbb35ef51..ac84963dc 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/core_ipa_serializer.h.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/core_ipa_serializer.h.tmpl @@ -32,12 +32,7 @@ class IPADataSerializer<{{struct|name}}> { public: {{- serializer.serializer(struct)}} -{%- if struct|has_fd %} -{{serializer.deserializer_fd(struct)}} -{%- else %} -{{serializer.deserializer_no_fd(struct)}} -{{serializer.deserializer_fd_simple(struct)}} -{%- endif %} +{{- serializer.deserializer(struct)}} }; {% endfor %} diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl index f3b8e3b15..65a7dd11c 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl @@ -33,12 +33,7 @@ class IPADataSerializer<{{struct|name_full}}> { public: {{- serializer.serializer(struct)}} -{%- if struct|has_fd %} -{{serializer.deserializer_fd(struct)}} -{%- else %} -{{serializer.deserializer_no_fd(struct)}} -{{serializer.deserializer_fd_simple(struct)}} -{%- endif %} +{{- serializer.deserializer(struct)}} }; {% endfor %} diff --git a/utils/codegen/ipc/generators/libcamera_templates/serializer.tmpl b/utils/codegen/ipc/generators/libcamera_templates/serializer.tmpl index 114e349c9..d07836cc1 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/serializer.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/serializer.tmpl @@ -317,3 +317,17 @@ return ret; } {%- endmacro %} + +{# + # \brief Deserialize a struct + # + # Generate code for IPADataSerializer specialization, for deserializing \a struct. + #} +{%- macro deserializer(struct) %} +{%- if struct|has_fd %} +{{deserializer_fd(struct)}} +{%- else %} +{{deserializer_no_fd(struct)}} +{{deserializer_fd_simple(struct)}} +{%- endif %} +{%- endmacro %}