22 def inspect(self, typename):
23 if self.debug:
print(
'inspecting ', typename)
24
25 dontAdd = False
26
27 for b in self.blocklist:
28 if typename.find(b) == 0:
29 if self.debug:
print(
'blocklisted ', typename)
30 dontAdd = True
31
32
33 if typename in self.classlist:
34 if self.debug:
print(
'seen before ', typename)
35 dontAdd = True
36
37 try:
38 t = self.type.ByName(typename)
40 if t.IsFundamental():
41 if self.debug:
print(typename,
' is fundamental')
42 return
43 if t.IsAbstract():
44 dontAdd = True
45 except Exception:
46 pass
47
48
49 exceptions = ["string::(anonymous)","string::(unnamed)"]
50 try:
51
52
53
54 bind_name = typename
55
56 bind_name = bind_name.replace(
"<",
"['", 1)[::-1].
replace(
">",
"]'", 1)[::-1]
57
58 base_and_arg = bind_name.split("[")
59 base_and_arg[0] = base_and_arg[0].
replace(
"::",
".")
60 bind_name = "[".join(base_and_arg)
61 bind_name = "ROOT." + bind_name
62 if self.debug:
63 print(
"Making class {} -> {}".format(typename, bind_name))
64 print(
"cl = " + bind_name)
65 exec("cl = " + bind_name, globals())
66 if self.debug:
print(cl)
67 if not dontAdd:
68 self.classlist.append(typename)
69 if self.debug:
print(
"appended type to the classlist")
70 except Exception as ex:
71 if self.debug:
print(
'Cannot create class of {}: {}'.format(typename, ex))
72 if typename not in exceptions:
73 raise ex
74
75 t = self.type.ByName(typename)
76
77 if t.IsComplete():
78 if self.debug:
print(typename,
'is complete')
79 else:
80 if self.debug:
print(typename,
' isn\'t complete')
81
82 if t.IsPointer():
83 if self.debug:
print(typename,
' is a pointer')
84 elif t.IsTypedef():
85 if self.debug:
print(typename,
' is typedef')
86 underlying = t.ToType()
87 if (underlying):
88 self.inspect(underlying.Name(7))
89 elif t.IsArray():
90 if self.debug:
print(typename,
' is an array')
91 elif t.IsTemplateInstance():
92 if self.debug:
print(typename,
' is template')
93 if typename.find('std::')==0:
94 if self.debug:
print(
'std::business removed')
95 try:
96 self.classlist.remove(typename)
97 except Exception:
98 pass
99 for i in range(t.TemplateArgumentSize()):
100 tt = t.TemplateArgumentAt(i)
101 ttname = tt.Name(7)
102 if tt.IsPointer() or tt.IsArray() or tt.IsTypedef():
103 ttname = tt.ToType().Name(7)
104 self.inspect(ttname)
105 elif t.IsClass():
106 if self.debug:
print(typename,
' is a class')
107 cname = t.Name(7)
108 if self.debug:
print(cname)
109
110 for i in range(t.DataMemberSize()):
111 d = t.DataMemberAt(i)
112 dname = d.Name()
113 dtype = d.TypeOf().Name(7)
114 if self.debug:
115 print(
'DataMember: ', dname,
' ', dtype,
' transient=', d.IsTransient())
116 if not d.IsTransient():
117 self.inspect(dtype)
118
119 else:
120 print(
'what to do about ', typename,
'?')
121 self.problemclasses.append( typename )
122 return
123
124
125
std::string replace(std::string s, const std::string &s2, const std::string &s3)