Modified: trunk/Tools/ChangeLog (290783 => 290784)
--- trunk/Tools/ChangeLog 2022-03-03 18:01:07 UTC (rev 290783)
+++ trunk/Tools/ChangeLog 2022-03-03 18:20:43 UTC (rev 290784)
@@ -1,3 +1,19 @@
+2022-03-03 Myles C. Maxfield <[email protected]>
+
+ [Style] Forbid spaces between type names and protocol names in Objective-C
+ https://bugs.webkit.org/show_bug.cgi?id=237406
+
+ Reviewed by Darin Adler.
+
+ According to https://lists.webkit.org/pipermail/webkit-dev/2022-February/032130.html.
+
+ Because the style checker uses regexes, we don't know what's a type name and what's
+ a protocol name, so the checker simplifies the problem and just checks for "id <".
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_objc_protocol):
+ (check_style):
+
2022-03-03 Jonathan Bedard <[email protected]>
[Python-3] Invoke webkit-patch with Python 3 by default (Follow-up fix)
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (290783 => 290784)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2022-03-03 18:01:07 UTC (rev 290783)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2022-03-03 18:20:43 UTC (rev 290784)
@@ -2,7 +2,7 @@
#
# Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved.
# Copyright (C) 2009 Torch Mobile Inc.
-# Copyright (C) 2009-2021 Apple Inc. All rights reserved.
+# Copyright (C) 2009-2022 Apple Inc. All rights reserved.
# Copyright (C) 2010 Chris Jerdonek ([email protected])
#
# Redistribution and use in source and binary forms, with or without
@@ -3399,6 +3399,31 @@
check_version_string(wk_api_available.group(1), "ios")
+def check_objc_protocol(clean_lines, line_number, file_extension, error):
+ """Looks for spaces between type names and protocol names.
+
+ Because the style checker uses regexes, we don't know what's a type and what's a protocol.
+ So, this check is a simplification and just checks for "id <"
+
+ Args:
+ clean_lines: A CleansedLines instance containing the file.
+ line_number: The number of the line to check.
+ file_extension: The extension (without the dot) of the filename.
+ error: The function to call with any errors found.
+ """
+
+ if file_extension != "m" and file_extension != "mm":
+ return
+
+ line = clean_lines.elided[line_number] # Get rid of comments and strings.
+
+ using_space_with_protocol = search(r'\bid <', line)
+ if not using_space_with_protocol:
+ return
+
+ error(line_number, 'spacing/objc-protocol', 2, "Protocol names shouldn't have a space before them.")
+
+
def check_style(clean_lines, line_number, file_extension, class_state, file_state, enum_state, error):
"""Checks rules from the 'C++ style rules' section of cppguide.html.
@@ -3480,6 +3505,7 @@
check_enum_casing(clean_lines, line_number, enum_state, error)
check_once_flag(clean_lines, line_number, file_state, error)
check_arguments_for_wk_api_available(clean_lines, line_number, error)
+ check_objc_protocol(clean_lines, line_number, file_extension, error)
_RE_PATTERN_INCLUDE_NEW_STYLE = re.compile(r'#(?:include|import) +"[^/]+\.h"')
Modified: trunk/Websites/webkit.org/ChangeLog (290783 => 290784)
--- trunk/Websites/webkit.org/ChangeLog 2022-03-03 18:01:07 UTC (rev 290783)
+++ trunk/Websites/webkit.org/ChangeLog 2022-03-03 18:20:43 UTC (rev 290784)
@@ -1,3 +1,14 @@
+2022-03-03 Myles C. Maxfield <[email protected]>
+
+ [Style] Forbid spaces between type names and protocol names in Objective-C
+ https://bugs.webkit.org/show_bug.cgi?id=237406
+
+ Reviewed by Darin Adler.
+
+ According to https://lists.webkit.org/pipermail/webkit-dev/2022-February/032130.html.
+
+ * code-style.md:
+
2022-02-15 Jon Davis <[email protected]>
Fix WordPress wpautop to account for the Dialog element.
Modified: trunk/Websites/webkit.org/code-style.md (290783 => 290784)
--- trunk/Websites/webkit.org/code-style.md 2022-03-03 18:01:07 UTC (rev 290783)
+++ trunk/Websites/webkit.org/code-style.md 2022-03-03 18:20:43 UTC (rev 290784)
@@ -320,6 +320,20 @@
```
+[](#spacing-objc-protocol) In Objective-C, do not place a space between the type name and the protocol name.
+
+###### Right:
+
+```cpp
+id<MTLDevice> device = ...;
+```
+
+###### Wrong:
+
+```cpp
+id <MTLDevice> device = ...;
+```
+
### Line breaking
[](#linebreaking-multiple-statements) Each statement should get its own line.