3 stdcl = re.compile(
"^std::(.*)[^>]$")
4 stdptr = re.compile(
"(.*)_ptr$")
5 datacl = re.compile(
"^class ")
6 bfunc = re.compile(
"^function ")
7 mbcl = re.compile(
"(base|data) class")
8 farg = re.compile(
"(.*)\(\w+\)")
9 nsep = re.compile(
"\:\:")
10 topfunc = re.compile(
"::(produce|analyze|filter|beginLuminosityBlock|beginRun)\(")
11 baseclass = re.compile(
"edm::(one::|stream::|global::)?ED(Producer|Filter|Analyzer)(Base)?")
12 getfunc = re.compile(
"edm::eventsetup::EventSetupRecord::get<.*>\((.*)&\) const")
13 handle = re.compile(
"(.*),?class edm::ES(.*)Handle<(.*)>")
17 dataclassfuncs = set()
24 flaggedclasses = set()
26 derivedclasses = set()
34 f = open(
'classes.txt.dumperall')
36 if mbcl.search(line) :
37 fields = line.split(
"'")
38 if fields[2] ==
' member data class ':
39 if not stdcl.search(fields[2]) : H.add_edge(fields[1],fields[3],kind=fields[2])
40 if fields[2] ==
' templated member data class ':
41 H.add_edge(fields[1],fields[5],kind=fields[3])
42 if fields[2] ==
' base class ':
43 H.add_edge(fields[1],fields[3],kind=fields[2])
44 I.add_edge(fields[3],fields[1],kind=
' derived class')
47 f = open(
'function-calls-db.txt')
50 if not bfunc.search(line) :
continue
51 fields = line.split(
"'")
52 if fields[2] ==
' calls function ' :
53 G.add_edge(fields[1],fields[3],kind=
' calls function ')
54 if getfunc.search(fields[3]) :
55 dataclassfuncs.add(fields[3])
56 m = getfunc.match(fields[3])
57 n = handle.match(m.group(1))
60 p = re.sub(
"class ",
"",o)
61 dataclass = re.sub(
"struct ",
"",p)
62 dataclasses.add(dataclass)
63 if fields[2] ==
' overrides function ' :
64 if baseclass.search(fields[3]) :
65 G.add_edge(fields[1],fields[3],kind=
' overrides function ')
66 if topfunc.search(fields[3]) : toplevelfuncs.add(fields[1])
67 else : G.add_edge(fields[3],fields[1], kind=
' calls override function ')
68 if fields[2] ==
' static variable ' :
69 G.add_edge(fields[1],fields[3],kind=
' static variable ')
70 statics.add(fields[3])
74 nodes = sorted(dataclasses)
79 if node
in H : stack = [(node,iter(H[node]))]
81 Q=nx.dfs_preorder_nodes(I,node)
85 stack.append( ( q, iter( H[q] ) ) )
87 parent,children = stack[-1]
88 print "class '"+parent+
"'"
91 if child
not in visited:
93 if not stdcl.search(child):
94 print "class '"+child+
"'"
95 stack.append( ( child, iter( H[child] ) ) )
96 kind=H[parent][child][
'kind']
97 print parent, kind, child
98 if stdptr.search(kind):
100 Q=nx.dfs_preorder_nodes(I,child)
102 print "class '"+q+
"'"
104 stack.append( ( q, iter( H[q] ) ) )
105 except StopIteration: