Patch Detail
Show a patch.
GET /api/1.1/patches/25734/?format=api
{ "id": 25734, "url": "https://patchwork.libcamera.org/api/1.1/patches/25734/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25734/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260113000808.15395-15-laurent.pinchart@ideasonboard.com>", "date": "2026-01-13T00:07:46", "name": "[14/36] libcamera: yaml_parser: Un-friend YamlParserContext from YamlObject", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "54ad316aaa3d24a8dc12299241d9ba5b609183b2", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/25734/mbox/", "series": [ { "id": 5703, "url": "https://patchwork.libcamera.org/api/1.1/series/5703/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5703", "date": "2026-01-13T00:07:32", "name": "libcamera: Global configuration file improvements", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5703/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25734/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25734/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 E0BFDC32C1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 00:08:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B44961FD7;\n\tTue, 13 Jan 2026 01:08:52 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0AA0D61FE4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:51 +0100 (CET)", "from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 65DDF50A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:25 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kOVOTwCj\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768262905;\n\tbh=R+H6T+pUNrJoWHVo2S6YDj3RoWmlhMcmwmzu+gsvK6o=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=kOVOTwCjHCoufQNUYRHX1filVvyqVm2DcOQwaFOMXlBu5Te2PvC6oHRkWnbnkaECs\n\t6Uq+dGDOW9et44RAxH8LwkbJdBSZyHBUgYbtWwvSoabZitTdKpZ03x3e2oa2VPF4Xh\n\t09bV/ygPX+pJ0sTjT0kqpoSZ6D+B0T6Hi6AGLTeQ=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH 14/36] libcamera: yaml_parser: Un-friend YamlParserContext\n\tfrom YamlObject", "Date": "Tue, 13 Jan 2026 02:07:46 +0200", "Message-ID": "<20260113000808.15395-15-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.51.2", "In-Reply-To": "<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>", "References": "<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>", "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": "YamlParserContext is a friend of the YamlObject class to access private\nmember variables. Now that YamlObject exposes functions to set a value\nand add children, this is not needed anymore. Decouple the two classes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/yaml_parser.h | 1 -\n src/libcamera/yaml_parser.cpp | 56 +++++++++---------------\n 2 files changed, 21 insertions(+), 36 deletions(-)", "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex ede2c3de687c..02e39e4cd7a1 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -204,7 +204,6 @@ private:\n \n \ttemplate<typename T>\n \tfriend struct Accessor;\n-\tfriend class YamlParserContext;\n \n \tenum class Type {\n \t\tDictionary,\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex 7462e2d74179..fa1a487a13dc 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -530,8 +530,8 @@ private:\n \n \tEventPtr nextEvent();\n \n-\tvoid readValue(std::string &value, EventPtr event);\n-\tint parseDictionaryOrList(YamlObject::Type type,\n+\tstd::string readValue(EventPtr event);\n+\tint parseDictionaryOrList(yaml_event_type_t endEventType,\n \t\t\t\t const std::function<int(EventPtr event)> &parseItem);\n \tint parseNextYamlObject(YamlObject &yamlObject, EventPtr event);\n \n@@ -673,22 +673,22 @@ int YamlParserContext::parseContent(YamlObject &yamlObject)\n /**\n * \\fn YamlParserContext::readValue()\n * \\brief Parse event scalar and fill its content into a string\n- * \\param[in] value The string reference to fill value\n *\n * A helper function to parse a scalar event as string. The caller needs to\n- * guarantee the event is of scaler type.\n+ * guarantee the event is of scalar type.\n+ *\n+ * \\return The scalar event value as a string\n */\n-void YamlParserContext::readValue(std::string &value, EventPtr event)\n+std::string YamlParserContext::readValue(EventPtr event)\n {\n-\tvalue.assign(reinterpret_cast<char *>(event->data.scalar.value),\n-\t\t event->data.scalar.length);\n+\treturn std::string{ reinterpret_cast<char *>(event->data.scalar.value),\n+\t\t\t event->data.scalar.length };\n }\n \n /**\n * \\fn YamlParserContext::parseDictionaryOrList()\n * \\brief A helper function to abstract the common part of parsing dictionary or list\n- *\n- * \\param[in] isDictionary True for parsing a dictionary, and false for a list\n+ * \\param[in] endEventType The YAML end event type (sequence or mapping)\n * \\param[in] parseItem The callback to handle an item\n *\n * A helper function to abstract parsing an item from a dictionary or a list.\n@@ -703,13 +703,9 @@ void YamlParserContext::readValue(std::string &value, EventPtr event)\n * \\return 0 on success or a negative error code otherwise\n * \\retval -EINVAL The parser is failed to initialize\n */\n-int YamlParserContext::parseDictionaryOrList(YamlObject::Type type,\n+int YamlParserContext::parseDictionaryOrList(yaml_event_type_t endEventType,\n \t\t\t\t\t const std::function<int(EventPtr event)> &parseItem)\n {\n-\tyaml_event_type_t endEventType = YAML_SEQUENCE_END_EVENT;\n-\tif (type == YamlObject::Type::Dictionary)\n-\t\tendEventType = YAML_MAPPING_END_EVENT;\n-\n \t/*\n \t * Add a safety counter to make sure we don't loop indefinitely in case\n \t * the YAML file is malformed.\n@@ -751,24 +747,19 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even\n \n \tswitch (event->type) {\n \tcase YAML_SCALAR_EVENT:\n-\t\tyamlObject.type_ = YamlObject::Type::Value;\n-\t\treadValue(yamlObject.value_, std::move(event));\n+\t\tyamlObject.set(readValue(std::move(event)));\n \t\treturn 0;\n \n \tcase YAML_SEQUENCE_START_EVENT: {\n-\t\tyamlObject.type_ = YamlObject::Type::List;\n-\t\tauto &list = yamlObject.list_;\n-\t\tauto handler = [this, &list](EventPtr evt) {\n-\t\t\tlist.emplace_back(std::string{}, std::make_unique<YamlObject>());\n-\t\t\treturn parseNextYamlObject(*list.back().value, std::move(evt));\n+\t\tauto handler = [this, &yamlObject](EventPtr evt) {\n+\t\t\tYamlObject *child = yamlObject.add(std::make_unique<YamlObject>());\n+\t\t\treturn parseNextYamlObject(*child, std::move(evt));\n \t\t};\n-\t\treturn parseDictionaryOrList(YamlObject::Type::List, handler);\n+\t\treturn parseDictionaryOrList(YAML_SEQUENCE_END_EVENT, handler);\n \t}\n \n \tcase YAML_MAPPING_START_EVENT: {\n-\t\tyamlObject.type_ = YamlObject::Type::Dictionary;\n-\t\tauto &list = yamlObject.list_;\n-\t\tauto handler = [this, &list](EventPtr evtKey) {\n+\t\tauto handler = [this, &yamlObject](EventPtr evtKey) {\n \t\t\t/* Parse key */\n \t\t\tif (evtKey->type != YAML_SCALAR_EVENT) {\n \t\t\t\tLOG(YamlParser, Error) << \"Expect key at line: \"\n@@ -778,26 +769,21 @@ int YamlParserContext::parseNextYamlObject(YamlObject &yamlObject, EventPtr even\n \t\t\t\treturn -EINVAL;\n \t\t\t}\n \n-\t\t\tstd::string key;\n-\t\t\treadValue(key, std::move(evtKey));\n+\t\t\tstd::string key = readValue(std::move(evtKey));\n \n \t\t\t/* Parse value */\n \t\t\tEventPtr evtValue = nextEvent();\n \t\t\tif (!evtValue)\n \t\t\t\treturn -EINVAL;\n \n-\t\t\tauto &elem = list.emplace_back(std::move(key),\n-\t\t\t\t\t\t std::make_unique<YamlObject>());\n-\t\t\treturn parseNextYamlObject(*elem.value, std::move(evtValue));\n+\t\t\tYamlObject *child = yamlObject.add(std::move(key),\n+\t\t\t\t\t\t\t std::make_unique<YamlObject>());\n+\t\t\treturn parseNextYamlObject(*child, std::move(evtValue));\n \t\t};\n-\t\tint ret = parseDictionaryOrList(YamlObject::Type::Dictionary, handler);\n+\t\tint ret = parseDictionaryOrList(YAML_MAPPING_END_EVENT, handler);\n \t\tif (ret)\n \t\t\treturn ret;\n \n-\t\tauto &dictionary = yamlObject.dictionary_;\n-\t\tfor (const auto &elem : list)\n-\t\t\tdictionary.emplace(elem.key, elem.value.get());\n-\n \t\treturn 0;\n \t}\n \n", "prefixes": [ "14/36" ] }