bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / finalclasses.py
blobf6c15ca2c87df27fc5d5c15392f6a366da856df6
1 #!/usr/bin/python
3 import re
4 import sys
6 definitionSet = set()
7 inheritFromSet = set()
8 definitionToFileDict = {}
10 with open("workdir/loplugin.finalclasses.log") as txt:
11 for line in txt:
12 tokens = line.strip().split("\t")
14 if len(tokens) == 1:
15 pass
17 elif tokens[0] == "definition:":
18 clazzName = tokens[1]
19 # the 1.. is so we skip the leading /
20 fileName = tokens[2][1:]
21 definitionSet.add(clazzName)
22 definitionToFileDict[clazzName] = fileName
24 elif tokens[0] == "inherited-from:":
25 parent = tokens[1]
26 if (parent.startswith("class ")):
27 parent = parent[6:]
28 elif (parent.startswith("struct ")):
29 parent = parent[7:]
30 inheritFromSet.add(parent);
32 else:
33 print( "unknown line: " + line)
35 tmpset = set()
36 for clazz in sorted(definitionSet - inheritFromSet):
37 file = definitionToFileDict[clazz]
38 # ignore classes defined inside compilation units, the compiler knows they are final already
39 if (".cxx" in file): continue
40 # ignore test and external code
41 if ("/qa/" in file): continue
42 if (file.startswith("workdir/")): continue
43 tmpset.add((clazz, file))
45 # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
46 def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
47 return [int(text) if text.isdigit() else text.lower()
48 for text in re.split(_nsre, s)]
49 def sort_set_by_natural_key(s):
50 return sorted(s, key=lambda v: natural_sort_key(v[1]))
52 # print output, sorted by name and line number
53 with open("compilerplugins/clang/finalclasses.results", "wt") as f:
54 for t in sort_set_by_natural_key(tmpset):
55 f.write(t[1] + "\n")
56 f.write(" " + t[0] + "\n")