summaryrefslogtreecommitdiffstats
path: root/tools/buildscripts/find-mocables
blob: 6c709399c8f44a48135d5e7cbe4129efb72898cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

import re, sys, os

mocables = set()
for f in filter(os.path.isfile, sys.argv[1:]):
    inBlockComment = False
    for line in open(f).readlines():
        # Block comments handling
        if "/*" in line:
            inBlockComment = True
        if inBlockComment and "*/" in line:
            inBlockComment = False
            if line.find("*/") != len(line) - 3:
                line = line[line.find("*/")+2:]
            else:
                continue
        if inBlockComment:
            continue
        #simple comments handling
        if "//" in line:
            line = line.partition("//")[0]
        if re.match(".*Q_OBJECT", line):
            mocables.add(f)
for mocable in mocables:
    print(mocable)