{"id":10313,"url":"https://patchwork.libcamera.org/api/1.1/patches/10313/?format=json","web_url":"https://patchwork.libcamera.org/patch/10313/","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":"<20201103010251.14689-2-laurent.pinchart@ideasonboard.com>","date":"2020-11-03T01:02:48","name":"[libcamera-devel,v3,1/4] utils: checkstyle.py: Add d-pointer formatter","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1c4918e7ed3d3711ffe7cc9044e209a54e99e22a","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10313/mbox/","series":[{"id":1437,"url":"https://patchwork.libcamera.org/api/1.1/series/1437/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1437","date":"2020-11-03T01:02:47","name":"libcamera: Implement d-pointer design pattern","version":3,"mbox":"https://patchwork.libcamera.org/series/1437/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10313/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10313/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 7287ABDB1E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  3 Nov 2020 01:03:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CBA6062B9B;\n\tTue,  3 Nov 2020 02:03:45 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AAEFD62B92\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  3 Nov 2020 02:03:43 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4634651D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  3 Nov 2020 02:03:43 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Qph9K8/n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1604365423;\n\tbh=TDOaxCLPkl0LOejtjmUQ1g66C5louBpLBS/9Dv5thes=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Qph9K8/nZKDdTu3K1vfsfEli2Y1wz3GgFx6bw889qlyS8Li7uL27ncZVHl5yQ+jPW\n\thQZRA3NvUqNrzxwbQKUx6XXCwWBrH4bqR+TnQSmfH+TF0SNrfpXqEHr9Cf+YRI4nrr\n\tqVuS0FXnb8YPc5r8okzahsQkWtORWBeHiB5HZpUk=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  3 Nov 2020 03:02:48 +0200","Message-Id":"<20201103010251.14689-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20201103010251.14689-1-laurent.pinchart@ideasonboard.com>","References":"<20201103010251.14689-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 1/4] utils: checkstyle.py: Add\n\td-pointer formatter","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>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a formatter to ensure consistent naming of 'd' and 'o' variables\nrelated to the d-pointer design pattern, as implemented by the\nExtensible class. The formatter also ensures that the pointer is always\nconst. const-correctness issues related to the data pointed to will be\ncaught by the compiler, and thus don't need to be checked here.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n utils/checkstyle.py | 32 ++++++++++++++++++++++++++++++++\n 1 file changed, 32 insertions(+)","diff":"diff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex d5dc26c0f666..7225cac47a4e 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -481,6 +481,38 @@ class DoxygenFormatter(Formatter):\n         return '\\n'.join(lines)\n \n \n+class DPointerFormatter(Formatter):\n+    # Ensure consistent naming of variables related to the d-pointer design\n+    # pattern.\n+    patterns = ('*.cpp', '*.h')\n+\n+    # The clang formatter runs first, we can thus rely on appropriate coding\n+    # style.\n+    declare_regex = re.compile(r'^(\\t*)(const )?([a-zA-Z0-9_]+) \\*( ?const )?([a-zA-Z0-9_]+) = (LIBCAMERA_[DO]_PTR)\\(([a-zA-Z0-9_]+)\\);$')\n+\n+    @classmethod\n+    def format(cls, filename, data):\n+        lines = []\n+\n+        for line in data.split('\\n'):\n+            match = cls.declare_regex.match(line)\n+            if match:\n+                indent = match.group(1) or ''\n+                const = match.group(2) or ''\n+                macro = match.group(6)\n+                klass = match.group(7)\n+                if macro == 'LIBCAMERA_D_PTR':\n+                    var = 'Private *const d'\n+                else:\n+                    var = f'{klass} *const o'\n+\n+                line = f'{indent}{const}{var} = {macro}({klass});'\n+\n+            lines.append(line)\n+\n+        return '\\n'.join(lines)\n+\n+\n class IncludeOrderFormatter(Formatter):\n     patterns = ('*.cpp', '*.h')\n \n","prefixes":["libcamera-devel","v3","1/4"]}