WebKit Objective-C++ style, pointer and reference placement
Currently we have this: https://webkit.org/code-style-guidelines/#pointers-and-references <https://webkit.org/code-style-guidelines/#pointers-and-references> Pointers and References Pointer types in non-C++ code Pointer types should be written with a space between the type and the * (so the * is adjacent to the following identifier if any). This is not what was originally intended, and I’m planning to fix the document. The original idea was to say: “Objective-C classes should have space between the type name and the *”. I can update the document to reflect this. However, this rule is a bit difficult to enforce and quite difficult to format automatically. Also, subjectively for me, it is a bit hard to remember. Maybe also for other people, as current Objective-C++ is formatted inconsistently in this regard. To enforce this, I’d imagine we hardcode a semi-comprehensive list of Objective-C class names to check-webkit-style. For automatic formatting, the scripts can fix up clang-format diffs based on the hardcoded list. An alternative suggestion would be to change the rule and document as follows: * All pointers, references and rvalue-references in Objective-C++ are formatted as current C++ style mandates * All C and Objective-C code should be formatted with rules consistent to the C++ rules * The exception would be public Objective-C headers and WebKit SPI headers, which would be formatted as part of Apple internal API definition process The change above would be fitting to programmatic formatting and format verification, as it simplifies the rules and avoids the need of semantic analysis of the code for the formatting purposes. Please reply to this to discuss which way would be preferable. The bug: https://bugs.webkit.org/show_bug.cgi?id=234294 <https://bugs.webkit.org/show_bug.cgi?id=234294> Br, Kimmo
On Tue, Dec 21 2021 at 02:08:42 PM +0200, Kimmo Kinnunen via webkit-dev <webkit-dev@lists.webkit.org> wrote:
* All C and Objective-C code should be formatted with rules consistent to the C++ rules
Unfortunately all of the WPE/GTK C code intentionally uses a space between the type and the asterisk * (for example, WebKit/Tools/MiniBrowser/gtk/BrowserWindow.c). I guess we could just omit all these files from style checker, or reformat them all, but it's going to be annoying to change either way. Michael
participants (2)
-
Kimmo Kinnunen
-
Michael Catanzaro