[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

levin at chromium.org levin at chromium.org
Sun Feb 20 22:58:18 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 5fe2bcb0f241ef459396a66e981830378cab8388
Author: levin at chromium.org <levin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 14 21:30:09 2011 +0000

    2011-01-14  David Levin  <levin at chromium.org>
    
            Reviewed by Eric Seidel.
    
            check-webkit-style: _FunctionState should keep track of where the function name starts.
            https://bugs.webkit.org/show_bug.cgi?id=52454
    
            * Scripts/webkitpy/style/checkers/cpp.py: Added function_name_start_position to
            _FunctionState and logic for setting it correctly.
            * Scripts/webkitpy/style/checkers/cpp_unittest.py: Added tests.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75813 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index d4be04e..b39c3cb 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-14  David Levin  <levin at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        check-webkit-style: _FunctionState should keep track of where the function name starts.
+        https://bugs.webkit.org/show_bug.cgi?id=52454
+
+        * Scripts/webkitpy/style/checkers/cpp.py: Added function_name_start_position to
+        _FunctionState and logic for setting it correctly.
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Added tests.
+
 2011-01-14  Vincent Scheib  <scheib at chromium.org>
 
         Reviewed by David Levin.
diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp.py b/Tools/Scripts/webkitpy/style/checkers/cpp.py
index 2f6dab2..250b9ee 100644
--- a/Tools/Scripts/webkitpy/style/checkers/cpp.py
+++ b/Tools/Scripts/webkitpy/style/checkers/cpp.py
@@ -497,12 +497,13 @@ class _FunctionState(object):
         self.body_start_position = Position(-1000, 0)
         self.end_position = Position(-1000, 0)
 
-    def begin(self, function_name, body_start_position, end_position,
+    def begin(self, function_name, function_name_start_position, body_start_position, end_position,
               parameter_start_position, parameter_end_position, clean_lines):
         """Start analyzing function body.
 
         Args:
             function_name: The name of the function being tracked.
+            function_name_start_position: Position in elided where the function name starts.
             body_start_position: Position in elided of the { or the ; for a prototype.
             end_position: Position in elided just after the final } (or ; is.
             parameter_start_position: Position in elided of the '(' for the parameters.
@@ -512,6 +513,7 @@ class _FunctionState(object):
         self.in_a_function = True
         self.lines_in_function = -1  # Don't count the open brace line.
         self.current_function = function_name
+        self.function_name_start_position = function_name_start_position
         self.body_start_position = body_start_position
         self.end_position = end_position
         self.is_declaration = clean_lines.elided[body_start_position.row][body_start_position.column] == ';'
@@ -1441,6 +1443,7 @@ def detect_functions(clean_lines, line_number, function_state, error):
             # Use the column numbers from the modified line to find the
             # function name in the original line.
             function = line[match_function.start(1):match_function.end(1)]
+            function_name_start_position = Position(line_number, match_function.start(1))
 
             if match(r'TEST', function):    # Handle TEST... macros
                 parameter_regexp = search(r'(\(.*\))', joined_line)
@@ -1464,7 +1467,7 @@ def detect_functions(clean_lines, line_number, function_state, error):
             if parameter_end_position > body_start_position:
                 return
 
-            function_state.begin(function, body_start_position, end_position,
+            function_state.begin(function, function_name_start_position, body_start_position, end_position,
                                  parameter_start_position, parameter_end_position, clean_lines)
             return
 
diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
index d3601a2..868d3f6 100644
--- a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
+++ b/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
@@ -364,6 +364,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.assertEquals(function_state.current_function, function_information['name'] + '()')
         self.assertEquals(function_state.is_pure, function_information['is_pure'])
         self.assertEquals(function_state.is_declaration, function_information['is_declaration'])
+        self.assert_positions_equal(function_state.function_name_start_position, function_information['function_name_start_position'])
         self.assert_positions_equal(function_state.parameter_start_position, function_information['parameter_start_position'])
         self.assert_positions_equal(function_state.parameter_end_position, function_information['parameter_end_position'])
         self.assert_positions_equal(function_state.body_start_position, function_information['body_start_position'])
@@ -384,6 +385,7 @@ class FunctionDetectionTest(CppStyleTestBase):
             ['void theTestFunctionName(int) {',
              '}'],
             {'name': 'theTestFunctionName',
+             'function_name_start_position': (0, 5),
              'parameter_start_position': (0, 24),
              'parameter_end_position': (0, 29),
              'body_start_position': (0, 30),
@@ -395,6 +397,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['void aFunctionName(int);'],
             {'name': 'aFunctionName',
+             'function_name_start_position': (0, 5),
              'parameter_start_position': (0, 18),
              'parameter_end_position': (0, 23),
              'body_start_position': (0, 23),
@@ -405,6 +408,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['CheckedInt<T> operator /(const CheckedInt<T> &lhs, const CheckedInt<T> &rhs);'],
             {'name': 'operator /',
+             'function_name_start_position': (0, 14),
              'parameter_start_position': (0, 24),
              'parameter_end_position': (0, 76),
              'body_start_position': (0, 76),
@@ -415,6 +419,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['CheckedInt<T> operator -(const CheckedInt<T> &lhs, const CheckedInt<T> &rhs);'],
             {'name': 'operator -',
+             'function_name_start_position': (0, 14),
              'parameter_start_position': (0, 24),
              'parameter_end_position': (0, 76),
              'body_start_position': (0, 76),
@@ -425,6 +430,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['CheckedInt<T> operator !=(const CheckedInt<T> &lhs, const CheckedInt<T> &rhs);'],
             {'name': 'operator !=',
+             'function_name_start_position': (0, 14),
              'parameter_start_position': (0, 25),
              'parameter_end_position': (0, 77),
              'body_start_position': (0, 77),
@@ -435,6 +441,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['CheckedInt<T> operator +(const CheckedInt<T> &lhs, const CheckedInt<T> &rhs);'],
             {'name': 'operator +',
+             'function_name_start_position': (0, 14),
              'parameter_start_position': (0, 24),
              'parameter_end_position': (0, 76),
              'body_start_position': (0, 76),
@@ -446,6 +453,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['virtual void theTestFunctionName(int = 0);'],
             {'name': 'theTestFunctionName',
+             'function_name_start_position': (0, 13),
              'parameter_start_position': (0, 32),
              'parameter_end_position': (0, 41),
              'body_start_position': (0, 41),
@@ -456,6 +464,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         self.perform_function_detection(
             ['virtual void theTestFunctionName(int) = 0;'],
             {'name': 'theTestFunctionName',
+             'function_name_start_position': (0, 13),
              'parameter_start_position': (0, 32),
              'parameter_end_position': (0, 37),
              'body_start_position': (0, 41),
@@ -469,6 +478,7 @@ class FunctionDetectionTest(CppStyleTestBase):
              ' = ',
              ' 0 ;'],
             {'name': 'theTestFunctionName',
+             'function_name_start_position': (0, 13),
              'parameter_start_position': (0, 32),
              'parameter_end_position': (0, 37),
              'body_start_position': (2, 3),
@@ -488,6 +498,7 @@ class FunctionDetectionTest(CppStyleTestBase):
             # This isn't a function but it looks like one to our simple
             # algorithm and that is ok.
             {'name': 'asm',
+             'function_name_start_position': (0, 0),
              'parameter_start_position': (0, 3),
              'parameter_end_position': (2, 1),
              'body_start_position': (2, 1),
@@ -503,6 +514,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         function_state = self.perform_function_detection(
             ['void functionName();'],
             {'name': 'functionName',
+             'function_name_start_position': (0, 5),
              'parameter_start_position': (0, 17),
              'parameter_end_position': (0, 19),
              'body_start_position': (0, 19),
@@ -515,6 +527,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         function_state = self.perform_function_detection(
             ['void functionName(int);'],
             {'name': 'functionName',
+             'function_name_start_position': (0, 5),
              'parameter_start_position': (0, 17),
              'parameter_end_position': (0, 22),
              'body_start_position': (0, 22),
@@ -528,6 +541,7 @@ class FunctionDetectionTest(CppStyleTestBase):
         function_state = self.perform_function_detection(
             ['void functionName(unsigned a, short b, long c, long long short unsigned int);'],
             {'name': 'functionName',
+             'function_name_start_position': (0, 5),
              'parameter_start_position': (0, 17),
              'parameter_end_position': (0, 76),
              'body_start_position': (0, 76),
@@ -545,6 +559,7 @@ class FunctionDetectionTest(CppStyleTestBase):
             ['virtual void determineARIADropEffects(Vector<String>*&, const unsigned long int*&, const MediaPlayer::Preload, Other<Other2, Other3<P1, P2> >, int);'],
             {'name': 'determineARIADropEffects',
              'parameter_start_position': (0, 37),
+             'function_name_start_position': (0, 13),
              'parameter_end_position': (0, 147),
              'body_start_position': (0, 147),
              'end_position': (0, 148),
@@ -564,6 +579,7 @@ class FunctionDetectionTest(CppStyleTestBase):
              'const ComplexTemplate<Class1, NestedTemplate<P1, P2> >* const * param = new ComplexTemplate<Class1, NestedTemplate<P1, P2> >(34, 42),',
              'int* myCount = 0);'],
             {'name': 'aFunctionName',
+             'function_name_start_position': (0, 32),
              'parameter_start_position': (0, 45),
              'parameter_end_position': (3, 17),
              'body_start_position': (3, 17),

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list