OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # | 2 # |
3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. | 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. |
4 # Copyright (C) 2009 Torch Mobile Inc. | 4 # Copyright (C) 2009 Torch Mobile Inc. |
5 # Copyright (C) 2009 Apple Inc. All rights reserved. | 5 # Copyright (C) 2009 Apple Inc. All rights reserved. |
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
7 # | 7 # |
8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
9 # modification, are permitted provided that the following conditions are | 9 # modification, are permitted provided that the following conditions are |
10 # met: | 10 # met: |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 | 1262 |
1263 def __init__(self): | 1263 def __init__(self): |
1264 self.in_enum_decl = False | 1264 self.in_enum_decl = False |
1265 self.is_webidl_enum = False | 1265 self.is_webidl_enum = False |
1266 | 1266 |
1267 def process_clean_line(self, line): | 1267 def process_clean_line(self, line): |
1268 # FIXME: The regular expressions for expr_all_uppercase and expr_enum_en
d only accept integers | 1268 # FIXME: The regular expressions for expr_all_uppercase and expr_enum_en
d only accept integers |
1269 # and identifiers for the value of the enumerator, but do not accept any
other constant | 1269 # and identifiers for the value of the enumerator, but do not accept any
other constant |
1270 # expressions. However, this is sufficient for now (11/27/2012). | 1270 # expressions. However, this is sufficient for now (11/27/2012). |
1271 expr_all_uppercase = r'\s*[A-Z0-9_]+\s*(?:=\s*[a-zA-Z0-9]+\s*)?,?\s*$' | 1271 expr_all_uppercase = r'\s*[A-Z0-9_]+\s*(?:=\s*[a-zA-Z0-9]+\s*)?,?\s*$' |
1272 expr_starts_lowercase = r'\s*[a-z]' | 1272 expr_starts_lowercase = r'\s*[a-jl-z]|k[a-z]' |
1273 expr_enum_end = r'}\s*(?:[a-zA-Z0-9]+\s*(?:=\s*[a-zA-Z0-9]+)?)?\s*;\s*' | 1273 expr_enum_end = r'}\s*(?:[a-zA-Z0-9]+\s*(?:=\s*[a-zA-Z0-9]+)?)?\s*;\s*' |
1274 expr_enum_start = r'\s*enum(?:\s+[a-zA-Z0-9]+)?\s*\{?\s*' | 1274 expr_enum_start = r'\s*enum(?:\s+[a-zA-Z0-9]+)?\s*\{?\s*' |
1275 if self.in_enum_decl: | 1275 if self.in_enum_decl: |
1276 if match(r'\s*' + expr_enum_end + r'$', line): | 1276 if match(r'\s*' + expr_enum_end + r'$', line): |
1277 self.in_enum_decl = False | 1277 self.in_enum_decl = False |
1278 self.is_webidl_enum = False | 1278 self.is_webidl_enum = False |
1279 elif match(expr_all_uppercase, line): | 1279 elif match(expr_all_uppercase, line): |
1280 return self.is_webidl_enum | 1280 return self.is_webidl_enum |
1281 elif match(expr_starts_lowercase, line): | 1281 elif match(expr_starts_lowercase, line): |
1282 return False | 1282 return False |
(...skipping 2899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4182 | 4182 |
4183 def check(self, lines): | 4183 def check(self, lines): |
4184 _process_lines(self.file_path, self.file_extension, lines, | 4184 _process_lines(self.file_path, self.file_extension, lines, |
4185 self.handle_style_error, self.min_confidence) | 4185 self.handle_style_error, self.min_confidence) |
4186 | 4186 |
4187 | 4187 |
4188 # FIXME: Remove this function (requires refactoring unit tests). | 4188 # FIXME: Remove this function (requires refactoring unit tests). |
4189 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 4189 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
4190 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 4190 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
4191 checker.check(lines) | 4191 checker.check(lines) |
OLD | NEW |