18 from __future__
import print_function
23 __author__ =
"Sebastien Binet"
33 'char',
'unsigned char',
'signed char',
34 'short',
'unsigned short',
35 'int',
'unsigned int',
36 'long',
'unsigned long',
37 'long long',
'unsigned long long',
'ulonglong',
62 print (
"## initializing...")
65 self.
Type = cppyy.gbl.RootType
71 klassNames = [klassName]
72 print (
"## loading dictionary... [%s]" % klassName)
75 if klassName.startswith(
"std::_"):
80 if klassName
in _cpp_builtins:
85 loaded = getattr (self.
gbl, klassName)
86 except Exception
as e:
87 print (
"Error loading dict. for [%s]" % klassName)
90 print (
"Failed to load dict for [%s]" % klassName)
92 klass = self.
Type.ByName(klassName)
94 if not klass.IsStruct()
and not klass.IsClass():
97 for i
in range(klass.BaseSize()):
98 baseKlassName = klass.BaseAt(i).Name()
99 klassNames.extend (self.
loadDicts(baseKlassName))
108 for i
in range(klass.DataMemberSize()):
109 d = klass.DataMemberAt(i)
111 offset =
'<s>' if d.IsStatic()
else d.Offset()
112 fullname =
'::'.
join([scope, d.Name(SFQ)])
113 typename = d.TypeOf().Name(SFQ)
114 dataMembers.append(
DataMember(offset, fullname, typename) )
119 for i
in range(klass.FunctionMemberSize()):
120 f = klass.FunctionMemberAt(i)
121 fctMembers.append(
FctMember( f.Name(SFQ),
122 f.TypeOf().Name(SFQ) ) )
130 print (
"## loading all relevant dictionaries...")
132 klassNames = self.loadDicts(klassName)
134 except Exception
as err:
137 print (
"## ERROR while trying to load dict for [%s]" % klassName)
138 print (
"## -Most probably you DIDN'T give a fully qualified name !")
139 print (
"## Ex: try 'Analysis::Muon' instead of 'Muon'")
141 print (
"## -Could also mean that you are missing a dictionary ")
142 print (
"## of one of the base classes...")
150 print (
"## infos for class [%s]:" % klassName)
151 print (
"## sizeof(%s) = %i" % \
153 self.Type.SizeOf(self.Type.ByName(klassName))))
155 print (
"## (offset, data member name, data member type)")
159 for klass
in klassNames:
160 line =
"%s %s %s" % (
161 "-" * (40-len(klass)//2-1),
163 "-" * (40-len(klass)//2-1) )
167 dataMembers = self.dumpDataMembers( self.Type.ByName(klass) )
168 for i
in dataMembers:
169 line =
"%3s %s %-50s %s %s" % (
str(i.offset),
178 def save(self, fileName = "./columbo.out" ):
179 file =
open(os.path.expandvars(os.path.expanduser(fileName)),
181 for line
in self.report:
182 file.writelines(line + os.linesep)
189 if __name__ ==
'__main__':
190 if len(sys.argv) > 1:
191 klassName = sys.argv[1]
193 klassName =
"xAOD::TruthParticle_v1"
197 columbo.inspect(klassName)