[{"id":13300,"web_url":"https://patchwork.libcamera.org/comment/13300/","msgid":"<20201020105944.GB1680262@oden.dyn.berto.se>","date":"2020-10-20T10:59:44","subject":"Re: [libcamera-devel] [PATCH v2 1/5] utils: checkstyle.py: Add\n\td-pointer formatter","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-10-20 04:40:01 +0300, Laurent Pinchart wrote:\n> Add a formatter to ensure consistent naming of 'd' and 'o' variables\n> related to the d-pointer design pattern, as implemented by the\n> Extensible class. The formatter also ensures that the pointer is always\n> const. const-correctness issues related to the data pointed to will be\n> caught by the compiler, and thus don't need to be checked here.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  utils/checkstyle.py | 32 ++++++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 5CE5EBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Oct 2020 10:59:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D910560357;\n\tTue, 20 Oct 2020 12:59:47 +0200 (CEST)","from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 263BE60357\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Oct 2020 12:59:46 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id a5so1499633ljj.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Oct 2020 03:59:46 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tc18sm250394lfh.98.2020.10.20.03.59.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 20 Oct 2020 03:59:44 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"E0bB8CTx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=IsyZ25M1c4lwF2tzFjXjVnjraFABJD9l71vrCwY4peI=;\n\tb=E0bB8CTxdIOzO6fkJ7n1KQ4NzyMgnNGtI0KzxpT5HbnVIxyt9/C3Hb+DHuugrbz2XG\n\t8qQeMJ12GsCKOqu/UvVg/PXOF4q6Ea3pm+aKaeK4Je/cm1XGwnxegFM9H6WWACrAjVUI\n\t/rNTWs7KJSxX0AFF7hBSrjKZk/RInqwPCQDhctrkOxGNBaMFAuJRNyBcjdKKbWXcd9S8\n\tsiPjrI+jTV1ZqN3d6PLPftfRfPrtVZp12R50VJe4mYVNV+vw3mLVMpX4lfe+wjwNRhZi\n\t/Jh7TaqI1YEiNp8iuLTNgGujfR9Z2jkzzr8B3G6tv6x4loPnyfdsa1rPBIq4+/ETWG7I\n\t8sAA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=IsyZ25M1c4lwF2tzFjXjVnjraFABJD9l71vrCwY4peI=;\n\tb=HCFf3aZol02ZwoqJ808+ZOFvxnCEH1vaht5if5Mki1y5yJmNCvq/8esG0hQ1ZgSP4s\n\t7eeyW/TeUr4IDG/92KMGV6rwJDv2nPLQ/rzCEBEBwOpJnl4sMvMPehHdRpivGN9VIKe4\n\tK870tFJMngBPZYa2JUt+hzPXXbx4eRNFwPJ+IDLYxyKIQ2LiNRSPCVJ8SW3riOIdQ4l1\n\tPfQaOkRPiKsTV26gslzE+O9LUBBpYOicfu7wuAzexGCaTar3nqzH0FbxOwVX56DTEm/+\n\tgm4RjGfQoYVw686dh8xntY++eTmJTZ6KTp22lN1uJ8MF12wOg7a+doP9qPvct7vqPRVe\n\tDSbg==","X-Gm-Message-State":"AOAM532sVudNK+xMKrlr6sh+cx+8Eh4ybtn+qhn7sqpPZ2ZBDPXmn0QP\n\tLQlOJr7AZzTDmoLABx3ee05T/T4ldlbaMQ==","X-Google-Smtp-Source":"ABdhPJxyN37xW5Uk3RgU3TLLLV8ttDed0vXVLDinGH9vqVUAXx6+Ad2+5B2w5Wi7sJIUaRs5FHuJkQ==","X-Received":"by 2002:a2e:2a86:: with SMTP id\n\tq128mr890849ljq.158.1603191585516; \n\tTue, 20 Oct 2020 03:59:45 -0700 (PDT)","Date":"Tue, 20 Oct 2020 12:59:44 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201020105944.GB1680262@oden.dyn.berto.se>","References":"<20201020014005.12783-1-laurent.pinchart@ideasonboard.com>\n\t<20201020014005.12783-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201020014005.12783-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/5] 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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]