{"id":38,"url":"https://patchwork.libcamera.org/api/1.1/patches/38/?format=json","web_url":"https://patchwork.libcamera.org/patch/38/","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":"<1544612976-27101-2-git-send-email-jacopo@jmondi.org>","date":"2018-12-12T11:09:35","name":"[libcamera-devel,v4,1/2] Documentation: Add coding style document","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fba7b1aa73d3a99f586451426ac915ab77d2c79e","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/38/mbox/","series":[{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/series/17/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=17","date":"2018-12-12T11:09:34","name":"Documentation: coding style and style checker tool","version":4,"mbox":"https://patchwork.libcamera.org/series/17/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/38/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/38/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B566060B13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Dec 2018 12:09:54 +0100 (CET)","from w540.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 3C77E24000E;\n\tWed, 12 Dec 2018 11:09:54 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 12 Dec 2018 12:09:35 +0100","Message-Id":"<1544612976-27101-2-git-send-email-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1544612976-27101-1-git-send-email-jacopo@jmondi.org>","References":"<1544612976-27101-1-git-send-email-jacopo@jmondi.org>","Subject":"[libcamera-devel] [PATCH v4 1/2] Documentation: Add coding style\n\tdocument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Wed, 12 Dec 2018 11:09:54 -0000"},"content":"Add document to summarize the coding style adopted by libcamera.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n Documentation/coding-style.rst | 80 ++++++++++++++++++++++++++++++++++++++++++\n Documentation/index.rst        |  1 +\n Documentation/meson.build      |  1 +\n 3 files changed, 82 insertions(+)\n create mode 100644 Documentation/coding-style.rst","diff":"diff --git a/Documentation/coding-style.rst b/Documentation/coding-style.rst\nnew file mode 100644\nindex 0000000..4747927\n--- /dev/null\n+++ b/Documentation/coding-style.rst\n@@ -0,0 +1,80 @@\n+Coding Style Guidelines\n+=======================\n+\n+The libcamera project has high standards of stability, efficiency and\n+reliability. To achieve those, the project goes to great length to produce\n+code that is as easy to read, understand and maintain as possible.\n+\n+These coding guidelines are meant to ensure code quality. As a contributor\n+you are expected to follow them in all code submitted to the project. While\n+strict compliance is desired, exceptions are tolerated when justified with\n+good reasons. Please read the whole coding guidelines and use common sense\n+to decide when departing from them is appropriate.\n+\n+libcamera is written in C++, a language that has seen many revisions and\n+offers an extensive set of features that are easy to abuse. These coding\n+guidelines establish the subset of C++ used by the project.\n+\n+\n+Coding Style\n+------------\n+\n+Even if the programming language in use is different, the project embraces the\n+`Linux Kernel Coding Style`_ with a few exception and some C++ specificities.\n+\n+.. _Linux Kernel Coding Style: https://www.kernel.org/doc/html/latest/process/coding-style.html\n+\n+In particular, from the kernel style document, the following section are adopted:\n+\n+  * 1 \"Indentation\"\n+  * 2 \"Breaking Long Lines\" with the maximum line length set to 120 columns\n+  * 3 \"Placing Braces and Spaces\"\n+  * 3.1 \"Spaces\"\n+  * 8 \"Commenting\" with the exception that in-function comments are not\n+       always un-welcome.\n+\n+While libcamera uses the kernel coding style for all typographic matters, the\n+project is a user space library, developed in a different programming language,\n+and the kernel guidelines fall short for this use case.\n+\n+For this reason, rules and guidelines from the `Google C++ Style Guide`_ have\n+been adopted as well as most coding principles specified therein, with a\n+few exceptions and relaxed limitations on some subjects.\n+\n+.. _Google C++ Style Guide: https://google.github.io/styleguide/cppguide.html\n+\n+The following exceptions apply to the naming conventions specified in the\n+document:\n+\n+  * File names: libcamera uses the .cpp extensions for C++ source files and\n+    the .h extension for header files.\n+  * Variables, function parameters, function names and class members use\n+    camel case style, with the first letter in lower-case (as in 'camelCase'\n+    and not 'CamelCase')\n+  * Types (classes, structs, type aliases, and type template parameters) use\n+    camel case, with the first letter in capital case (as in 'CamelCase' and\n+    not 'camelCase').\n+  * Enum members use 'CamelCase', while macros are in capital case with\n+    underscores in between.\n+  * All formatting rules specified in the selected sections of the Linux kernel\n+    Code Style for indentation, braces, spacing, etc\n+  * Header guards are formatted as '__LIBCAMERA_FILE_NAME_H__'\n+\n+\n+C++ Specific Rules\n+------------------\n+\n+The code shall be implemented in C++03, extended with the following\n+C++-11-specific features:\n+\n+  * Initializer lists\n+  * Type inference (auto and decltype)\n+    Type inference shall be used with caution, to avoid drifting towards an\n+    untyped language.\n+  * Range-based for loop\n+  * Lambda functions\n+  * Explicit overrides and final\n+  * Null pointer constant\n+  * General-purpose smart pointers (std::unique_ptr), deprecating std::auto_ptr\n+    Smart pointers, as well as shared pointers and weak pointers, shall not be\n+    overused.\ndiff --git a/Documentation/index.rst b/Documentation/index.rst\nindex c9b7c1c..ba6c6c6 100644\n--- a/Documentation/index.rst\n+++ b/Documentation/index.rst\n@@ -20,6 +20,7 @@ systems, including traditional Linux distributions, ChromeOS and Android.\n    :maxdepth: 2\n    :caption: Contents:\n \n+   coding-style\n    contributing\n \n \ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 578c1ca..3b87619 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -5,6 +5,7 @@ endif\n \n if sphinx.found()\n     docs_sources = [\n+        'coding-style.rst',\n         'conf.py',\n         'contributing.rst',\n         'index.rst',\n","prefixes":["libcamera-devel","v4","1/2"]}