def ParseUnion(self, tinfo, ta): union_name, doc, helpcntext, helpfile = tinfo.GetDocumentation(-1) members = [] union = typedesc.Union(union_name, align=ta.cbAlignment*8, members=members, bases=[], size=ta.cbSizeInstance*8) self._register(union_name, union) tlib, _ = tinfo.GetContainingTypeLib() tlib_ta = tlib.GetLibAttr() # If this is a 32-bit typlib being loaded in a 64-bit process, then the # size and alignment are incorrect. Set the size to None to disable # size checks and correct the alignment. if is_64bits and tlib_ta.syskind == typeinfo.SYS_WIN32: union.size = None union.align = 64 for i in range(ta.cVars): vd = tinfo.GetVarDesc(i) name = tinfo.GetDocumentation(vd.memid)[0] offset = vd._.oInst * 8 assert vd.varkind == typeinfo.VAR_PERINSTANCE typ = self.make_type(vd.elemdescVar.tdesc, tinfo) field = typedesc.Field(name, typ, None, # bits offset) members.append(field) return union
def ParseUnion(self, tinfo, ta): union_name, doc, helpcntext, helpfile = tinfo.GetDocumentation(-1) members = [] union = typedesc.Union(union_name, align=ta.cbAlignment * 8, members=members, bases=[], size=ta.cbSizeInstance * 8) self._register(union_name, union) for i in range(ta.cVars): vd = tinfo.GetVarDesc(i) name = tinfo.GetDocumentation(vd.memid)[0] offset = vd._.oInst * 8 assert vd.varkind == typeinfo.VAR_PERINSTANCE typ = self.make_type(vd.elemdescVar.tdesc, tinfo) field = typedesc.Field( name, typ, None, # bits offset) members.append(field) return union