Changeset 200859 in webkit
- Timestamp:
- May 13, 2016, 9:16:51 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r200747 r200859 1 2016-05-13 Brady Eidson <beidson@apple.com> 2 3 Protector Ref/RefPtrs should have a specified naming style. 4 https://bugs.webkit.org/show_bug.cgi?id=157591 5 6 Reviewed by Darin Adler. 7 8 * Scripts/webkitpy/style/checkers/cpp.py: 9 (check_identifier_name_in_declaration): 10 (CppChecker): 11 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 12 (WebKitStyleTest.test_names): 13 1 14 2016-05-12 Csaba Osztrogonác <ossy@webkit.org> 2 15 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r200059 r200859 3292 3292 return 3293 3293 3294 # Make sure Ref/RefPtrs used as protectors are named correctly, and do this before we start stripping things off the input. 3295 ref_regexp = r'^\s*Ref(Ptr)?<([\w_]|::)+> (?P<protector_name>[\w_]+)\((\*|&)*(m_)?(?P<protected_name>[\w_]+)\);' 3296 ref_check = match(ref_regexp, line) 3297 if ref_check: 3298 protector_name = ref_check.group('protector_name') 3299 protected_name = ref_check.group('protected_name') 3300 cap_protected_name = protected_name[0].upper() + protected_name[1:] 3301 expected_protector_name = 'protected' + cap_protected_name 3302 if protected_name == 'this' and protector_name != 'protectedThis': 3303 error(line_number, 'readability/naming/protected', 4, "\'" + protector_name + "\' is incorrectly named. It should be named \'protectedThis\'.") 3304 elif protector_name == expected_protector_name or protector_name == 'protector': 3305 return 3306 else: 3307 error(line_number, 'readability/naming/protected', 4, "\'" + protector_name + "\' is incorrectly named. It should be named \'protector\' or \'" + expected_protector_name + "\'.") 3308 3294 3309 # Basically, a declaration is a type name followed by whitespaces 3295 3310 # followed by an identifier. The type name can be complicated … … 3847 3862 'readability/parameter_name', 3848 3863 'readability/naming', 3864 'readability/naming/protected', 3849 3865 'readability/naming/underscores', 3850 3866 'readability/null', -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r200059 r200859 5180 5180 '_fillRule' + name_underscore_error_message) 5181 5181 5182 # Valid protector RefPtr/Ref variable names. 5183 self.assert_lint('RefPtr<Node> protectedThis(this);', '') 5184 self.assert_lint('Ref<Node> protectedThis(*this);', '') 5185 self.assert_lint('RefPtr<Node> protectedNode(node);', '') 5186 self.assert_lint('RefPtr<Node> protectedNode(&node);', '') 5187 self.assert_lint('RefPtr<Node> protector(node);', '') 5188 self.assert_lint('RefPtr<Node> protector(&node);', '') 5189 self.assert_lint('Ref<Node> protectedNode(node);', '') 5190 self.assert_lint('Ref<Node> protectedNode(*node);', '') 5191 self.assert_lint('Ref<Node> protector(node);', '') 5192 self.assert_lint('Ref<Node> protector(*node);', '') 5193 self.assert_lint('RefPtr<Node> protectedOtherNode(otherNode);', '') 5194 self.assert_lint('RefPtr<Node> protectedOtherNode(&otherNode);', '') 5195 self.assert_lint('Ref<Node> protectedOtherNode(otherNode);', '') 5196 self.assert_lint('Ref<Node> protectedOtherNode(*otherNode);', '') 5197 self.assert_lint('RefPtr<Widget> protectedWidget(m_widget);', '') 5198 self.assert_lint('RefPtr<Widget> protectedWidget(&m_widget);', '') 5199 self.assert_lint('Ref<Widget> protectedWidget(m_widget);', '') 5200 self.assert_lint('Ref<Widget> protectedWidget(*m_widget);', '') 5201 self.assert_lint('RefPtr<Widget> protector(m_widget);', '') 5202 self.assert_lint('RefPtr<Widget> protector(&m_widget);', '') 5203 self.assert_lint('Ref<Widget> protector(m_widget);', '') 5204 self.assert_lint('Ref<Widget> protector(*m_widget);', '') 5205 self.assert_lint('RefPtr<SomeNamespace::Node> protectedThis(this);', '') 5206 self.assert_lint('RefPtr<SomeClass::InternalClass::Node> protectedThis(this);', '') 5207 5208 # Invalid protector RefPtr/Ref variable names. 5209 self.assert_lint('RefPtr<Node> protector(this);', "'protector' is incorrectly named. It should be named 'protectedThis'. [readability/naming/protected] [4]") 5210 self.assert_lint('Ref<Node> protector(*this);', "'protector' is incorrectly named. It should be named 'protectedThis'. [readability/naming/protected] [4]") 5211 self.assert_lint('RefPtr<Node> self(this);', "'self' is incorrectly named. It should be named 'protectedThis'. [readability/naming/protected] [4]") 5212 self.assert_lint('Ref<Node> self(*this);', "'self' is incorrectly named. It should be named 'protectedThis'. [readability/naming/protected] [4]") 5213 self.assert_lint('RefPtr<Node> protectedThis(node);', "'protectedThis' is incorrectly named. It should be named 'protector' or 'protectedNode'. [readability/naming/protected] [4]") 5214 self.assert_lint('RefPtr<Node> protectedThis(&node);', "'protectedThis' is incorrectly named. It should be named 'protector' or 'protectedNode'. [readability/naming/protected] [4]") 5215 self.assert_lint('Ref<Node> protectedThis(node);', "'protectedThis' is incorrectly named. It should be named 'protector' or 'protectedNode'. [readability/naming/protected] [4]") 5216 self.assert_lint('Ref<Node> protectedThis(*node);', "'protectedThis' is incorrectly named. It should be named 'protector' or 'protectedNode'. [readability/naming/protected] [4]") 5217 self.assert_lint('RefPtr<Node> protectedNode(otherNode);', "'protectedNode' is incorrectly named. It should be named 'protector' or 'protectedOtherNode'. [readability/naming/protected] [4]") 5218 self.assert_lint('RefPtr<Node> protectedNode(&otherNode);', "'protectedNode' is incorrectly named. It should be named 'protector' or 'protectedOtherNode'. [readability/naming/protected] [4]") 5219 self.assert_lint('Ref<Node> protectedNode(otherNode);', "'protectedNode' is incorrectly named. It should be named 'protector' or 'protectedOtherNode'. [readability/naming/protected] [4]") 5220 self.assert_lint('Ref<Node> protectedNode(*otherNode);', "'protectedNode' is incorrectly named. It should be named 'protector' or 'protectedOtherNode'. [readability/naming/protected] [4]") 5221 self.assert_lint('RefPtr<Node> nodeRef(node);', "'nodeRef' is incorrectly named. It should be named 'protector' or 'protectedNode'. [readability/naming/protected] [4]") 5222 self.assert_lint('Ref<Node> nodeRef(*node);', "'nodeRef' is incorrectly named. It should be named 'protector' or 'protectedNode'. [readability/naming/protected] [4]") 5223 5224 # Lines that look like a protector variable declaration but aren't. 5225 self.assert_lint('static RefPtr<Widget> doSomethingWith(widget);', '') 5226 self.assert_lint('RefPtr<Widget> create();', '') 5227 5182 5228 def test_parameter_names(self): 5183 5229 # Leave meaningless variable names out of function declarations. -
trunk/Websites/webkit.org/ChangeLog
r200082 r200859 1 2016-05-13 Brady Eidson <beidson@apple.com> 2 3 Protector Ref/RefPtrs should have a specified naming style. 4 https://bugs.webkit.org/show_bug.cgi?id=157591 5 6 Reviewed by Darin Adler. 7 8 * code-style.md: 9 1 10 2016-04-26 Timothy Hatcher <timothy@apple.com> 2 11 -
trunk/Websites/webkit.org/code-style.md
r197643 r200859 712 712 #ifndef _HTML_DOCUMENT_H_ 713 713 #define _HTML_DOCUMENT_H_ 714 ``` 715 716 [](#names-protectors-this) Ref and RefPtr objects meant to protect `this` from deletion should be named "protectedThis". 717 718 ###### Right: 719 720 ```cpp 721 RefPtr<Node> protectedThis(this); 722 Ref<Element> protectedThis(*this); 723 ``` 724 725 ###### Wrong: 726 727 ```cpp 728 RefPtr<Node> protector(this); 729 RefPtr<Widget> self(this); 730 Ref<Element> elementRef(*this); 731 ``` 732 733 [](#names-protectors) Ref and RefPtr objects meant to protect variables other than `this` from deletion should be named either "protector", or "protected" combined with the capitalized form of the variable name. 734 735 ###### Right: 736 737 ```cpp 738 RefPtr<Element> protector(&element); 739 RefPtr<Node> protectedNode(node); 740 RefPtr<Widget> protectedMainWidget(m_mainWidget); 741 ``` 742 743 ###### Wrong: 744 745 ```cpp 746 RefPtr<Node> nodeRef(&rootNode); 747 Ref<Element> protect(*element); 748 RefPtr<Widget> protected(widget); 749 RefPtr<Node> protectorNode(node); 714 750 ``` 715 751
Note:
See TracChangeset
for help on using the changeset viewer.