def yacheck_enums(self): values = yaunit.load('enums') for flag in flags: for prefix, enum_width, is_bitfield, num_fields in tests: name, ea, values = str(values[0][0]), values[0][1], values[1:] eid = idc.GetEnum(name) self.assertNotEqual(eid, idaapi.BADADDR) self.assertEqual(idc.GetEnumFlag(eid), flag) self.assertEqual(idc.GetEnumName(eid), name) self.assertEqual(idc.IsBitfield(eid), is_bitfield) self.assertEqual(idc.GetEnumCmt(eid, False), prefix + 'cmt') self.assertEqual(idc.GetEnumCmt(eid, True), prefix + 'rpt') if enum_width != 0: self.assertEqual(idc.GetEnumWidth(eid), enum_width) n = 0 for value, bmask in walk_enum(eid): self.assertLessEqual(n, num_fields) v = 1 << n if is_bitfield else n self.assertEqual(value, value, v) cid = idc.GetConstEx(eid, v, 0, bmask) self.assertNotEqual(cid, idaapi.BADADDR) field = '%s_%d' % (name, n) self.assertEqual(idc.GetConstName(cid), field) # FIXME comments are not working #self.assertEqual(idc.GetConstCmt(cid, False), field + 'cmt') #self.assertEqual(idc.GetConstCmt(cid, True), field + 'rpt') n += 1 self.assertEqual(n, num_fields) if ea != None: self.assertEqual(idaapi.get_enum_id(ea, 1)[0], eid)
def gather_enum_info(ea, n): id = idaapi.get_enum_id(ea, n)[0] serial = idaapi.get_enum_idx(id) return id, serial