{"id":21641,"url":"https://patchwork.libcamera.org/api/1.1/patches/21641/?format=json","web_url":"https://patchwork.libcamera.org/patch/21641/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241016115130.1508308-1-paul.elder@ideasonboard.com>","date":"2024-10-16T11:51:30","name":"[v2] py: Add bindings for ControlId array information","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"94c44e890274aaf1191bf892b581d77ab0fd7168","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21641/mbox/","series":[{"id":4705,"url":"https://patchwork.libcamera.org/api/1.1/series/4705/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4705","date":"2024-10-16T11:51:30","name":"[v2] py: Add bindings for ControlId array information","version":2,"mbox":"https://patchwork.libcamera.org/series/4705/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21641/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21641/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E3A94C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Oct 2024 11:51:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A606C65383;\n\tWed, 16 Oct 2024 13:51:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 429616537E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Oct 2024 13:51:44 +0200 (CEST)","from neptunite.flets-east.jp (unknown\n\t[IPv6:2404:7a81:160:2100:b5b2:fcb4:385e:af78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D0483A57;\n\tWed, 16 Oct 2024 13:50:00 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"G4vLW2g2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729079401;\n\tbh=O40L6TO6S8rmwUsuRold0X3uyhw/9wQJBT1jU0tbeAY=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=G4vLW2g2nCnFcLAVSv7UUaDpGUGZmRfQDt/GMJaDXoUKyFrgro2Rf6qXshdIH6PV3\n\t+7LtzfI/TZ0qcs3cNOGRJ6ZQmbe1LEQV17Mc85FDjmOCzGizqvYuMlyWpnw006SdLp\n\t4m7gKeIwc4s6VSBOY4ern3np+nmDxt25ot7jZKYs=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Paul Elder <paul.elder@ideasonboard.com>","Subject":"[PATCH v2] py: Add bindings for ControlId array information","Date":"Wed, 16 Oct 2024 20:51:30 +0900","Message-Id":"<20241016115130.1508308-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.39.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add python bindings for querying whether or not a ControlId is an array\ntype, and the size.\n\nExample usage:\n>>> cid\nlibcamera.ControlId(28, FrameDurationLimits[2], ControlType.Integer64)\n>>> cid.isArray\nTrue\n>>> cid.size\n2\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\nChanges in v2:\n- add size to __repr__\n---\n src/py/libcamera/py_main.cpp | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)","diff":"diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\nindex 983b76f6e998..cbde8be16d43 100644\n--- a/src/py/libcamera/py_main.cpp\n+++ b/src/py/libcamera/py_main.cpp\n@@ -7,6 +7,7 @@\n \n #include \"py_main.h\"\n \n+#include <limits>\n #include <memory>\n #include <stdexcept>\n #include <string>\n@@ -400,10 +401,22 @@ PYBIND11_MODULE(_libcamera, m)\n \t\t.def_property_readonly(\"id\", &ControlId::id)\n \t\t.def_property_readonly(\"name\", &ControlId::name)\n \t\t.def_property_readonly(\"type\", &ControlId::type)\n+\t\t.def_property_readonly(\"isArray\", &ControlId::isArray)\n+\t\t.def_property_readonly(\"size\", &ControlId::size)\n \t\t.def(\"__str__\", [](const ControlId &self) { return self.name(); })\n \t\t.def(\"__repr__\", [](const ControlId &self) {\n-\t\t\treturn py::str(\"libcamera.ControlId({}, {}, {})\")\n-\t\t\t\t.format(self.id(), self.name(), self.type());\n+\t\t\tstd::string sizeStr = \"\";\n+\t\t\tif (self.isArray()) {\n+\t\t\t\tsizeStr = \"[\";\n+\t\t\t\tsize_t size = self.size();\n+\t\t\t\tif (size == std::numeric_limits<size_t>::max())\n+\t\t\t\t\tsizeStr += \"n\";\n+\t\t\t\telse\n+\t\t\t\t\tsizeStr += std::to_string(size);\n+\t\t\t\tsizeStr += \"]\";\n+\t\t\t}\n+\t\t\treturn py::str(\"libcamera.ControlId({}, {}{}, {})\")\n+\t\t\t\t.format(self.id(), self.name(), sizeStr, self.type());\n \t\t})\n \t\t.def(\"enumerators\", &ControlId::enumerators);\n \n","prefixes":["v2"]}