~widelands-dev/widelands/bug-1808169-disable-focus

« back to all changes in this revision

Viewing changes to cmake/codecheck/rules/upcast_without_macro

  • Committer: qcs
  • Date: 2010-02-05 01:13:20 UTC
  • Revision ID: git-v1:136d6c48811c97ec1f98301726134b0de66f868c
Manual merge of cmake-migration branch to trunk

git-svn-id: https://widelands.svn.sourceforge.net/svnroot/widelands/trunk@5030 37b2a8de-5219-0410-9f54-a31bc463ab9c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
"""
 
4
This catches upcasts like this: Some_Type * const an_identifier =
 
5
dynamic_cast<Some_Type *>(source) This is unnecessarily verbose and should be
 
6
abbreviated with the upcast macro: upcast(Some_Type, an_identifier, source)
 
7
"""
 
8
 
 
9
 
 
10
regexp=r"""(^\w*|[^:][^_a-zA-Z0-9]|:[^: ]) *(([_a-zA-Z][_a-zA-Z0-9]* *::)* *[_a-zA-Z][_a-zA-Z0-9]*(( +const)? *\*)*) *(const *)?\* *const +[_a-zA-Z][_a-zA-Z0-9]* *= *dynamic_cast *< *\2 *(const *)?\* *>"""
 
11
 
 
12
error_msg = "Your upcast is ugly. Use upcast() macro!"
 
13
 
 
14
forbidden = [ 
 
15
    'if (B_t const * const hej = dynamic_cast<B_t *>(du)) {',
 
16
    'B_t const*const hej=dynamic_cast  < B_t* >(du)) {',
 
17
    'const B_t *const hej=dynamic_cast<B_t*>',
 
18
    'MN:B_t *const hej=dynamic_cast<B_t*>',
 
19
    'MN::B_t *const hej=dynamic_cast<MN::B_t*>',
 
20
    ' B_t const * const hej=dynamic_cast<B_t const*>',
 
21
    'B_t const * const hej=dynamic_cast<B_t const*>',
 
22
]
 
23
 
 
24
 
 
25
allowed = [
 
26
    'Some_Type ha = dynamic_cast<Some_Type>',
 
27
    'Some_Type ha = dynamic_cast<Some_Typ>',
 
28
    'const B_t * hej = dymamic_cast<B_t *>',
 
29
    'MN::B_t *const hej=dynamic_cast<B_t*>',
 
30
]
 
31
 
 
32