Title: [89497] trunk/Tools
- Revision
- 89497
- Author
- le...@chromium.org
- Date
- 2011-06-22 16:56:22 -0700 (Wed, 22 Jun 2011)
Log Message
2011-06-22 David Levin <le...@chromium.org>
Reviewed by Adam Barth.
check-webkit-style should check for invalid uses of RefPtr/OwnPtr as parameters.
https://bugs.webkit.org/show_bug.cgi?id=63188
* Scripts/webkitpy/style/checkers/cpp.py: Added the check.
* Scripts/webkitpy/style/checkers/cpp_unittest.py: Added tests.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (89496 => 89497)
--- trunk/Tools/ChangeLog 2011-06-22 23:55:53 UTC (rev 89496)
+++ trunk/Tools/ChangeLog 2011-06-22 23:56:22 UTC (rev 89497)
@@ -1,3 +1,13 @@
+2011-06-22 David Levin <le...@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ check-webkit-style should check for invalid uses of RefPtr/OwnPtr as parameters.
+ https://bugs.webkit.org/show_bug.cgi?id=63188
+
+ * Scripts/webkitpy/style/checkers/cpp.py: Added the check.
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py: Added tests.
+
2011-06-22 Tony Chang <t...@chromium.org>
Reviewed by Ojan Vafai.
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (89496 => 89497)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2011-06-22 23:55:53 UTC (rev 89496)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py 2011-06-22 23:56:22 UTC (rev 89497)
@@ -1597,12 +1597,16 @@
error(function_state.function_name_start_position.row, 'readability/webkit_api', 5,
'WEBKIT_API should not be used with a pure virtual function.')
- # Do checks specific to function declaractions.
- if not function_state.is_declaration:
- return
parameter_list = function_state.parameter_list()
for parameter in parameter_list:
- if not parameter.name:
+ bad_parameter_type = search('(?=\W|^)(Ref|Own)Ptr(?=\W)', parameter.type)
+ if bad_parameter_type:
+ type_name = bad_parameter_type.group(0)
+ error(parameter.row, 'readability/pass_ptr', 5,
+ 'The parameter type should use Pass%s instead of %s.' % (type_name, type_name))
+
+ # Do checks specific to function declarations and parameter names.
+ if not function_state.is_declaration or not parameter.name:
continue
# Check the parameter name against the function name for single parameter set functions.
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (89496 => 89497)
--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2011-06-22 23:55:53 UTC (rev 89496)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py 2011-06-22 23:56:22 UTC (rev 89497)
@@ -3257,6 +3257,20 @@
'}',
'')
+ def test_ref_ptr_parameter_value(self):
+ self.assert_pass_ptr_check(
+ 'int myFunction(RefPtr<Type1>)\n'
+ '{\n'
+ '}',
+ 'The parameter type should use PassRefPtr instead of RefPtr. [readability/pass_ptr] [5]')
+
+ def test_own_ptr_parameter_value(self):
+ self.assert_pass_ptr_check(
+ 'int myFunction(OwnPtr<Type1>)\n'
+ '{\n'
+ '}',
+ 'The parameter type should use PassOwnPtr instead of OwnPtr. [readability/pass_ptr] [5]')
+
def test_ref_ptr_member_variable(self):
self.assert_pass_ptr_check(
'class Foo {'
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes