def load(self,unnamed_hack=True,elim_fwdrefs=True): import tpi tpis = tpi.parse_stream(self.stream_file,unnamed_hack,elim_fwdrefs) self.header = tpis.TPIHeader self.num_types = self.header.ti_max - self.header.ti_min self.types = tpis.types self.structures = dict((s.name, s) for s in tpis.types.values() if s.leaf_type == "LF_STRUCTURE" or s.leaf_type == "LF_STRUCTURE_ST") del tpis
return '%s' % (con_base_type[lf] % name) elif lf.leaf_type == 'LF_POINTER': if hasattr(lf.utype, 'name'): return 'ULInt32("%s-%s")' % (name or "ptr", lf.utype.name) else: return 'ULInt32("%s-%s_%s")' % (name or "ptr", lf.utype.leaf_type, lf.utype.tpi_idx) elif lf.leaf_type == 'LF_STRUCTURE': return 'Struct("%s", # %s\n%s\n)' % (name or lf.name, lf.name, construct(lf.fieldlist)) elif lf.leaf_type == 'LF_FIELDLIST': return ',\n'.join(construct(l) for l in lf.substructs) elif lf.leaf_type == "LF_MEMBER": return construct(lf.index, lf.name) elif lf.leaf_type == "LF_BITFIELD": if lf.length == 1: return 'Flag("%s")' % name else: return 'Mask("%s", %d)' % (name, lf.length) elif lf.leaf_type == "LF_ARRAY": count = get_size(lf) / get_size(lf.element_type) return 'Array(%d, %s)' % (count, construct(lf.element_type, name or lf.name)) else: return "Unimplemented %s" % lf.leaf_type tpi_stream = tpi.parse_stream(open(sys.argv[1])) structs = [ t for t in tpi_stream.types.values() if t.leaf_type == 'LF_STRUCTURE' and not t.prop.fwdref ] for s in structs: if s.name == "_EPROCESS": print construct(s)
else: return 'ULInt32("%s-%s_%s")' % (name or "ptr", lf.utype.leaf_type, lf.utype.tpi_idx) elif lf.leaf_type == 'LF_STRUCTURE': return 'Struct("%s", # %s\n%s\n)' % (name or lf.name, lf.name, construct(lf.fieldlist)) elif lf.leaf_type == 'LF_FIELDLIST': return ',\n'.join(construct(l) for l in lf.substructs) elif lf.leaf_type == "LF_MEMBER": return construct(lf.index, lf.name) elif lf.leaf_type == "LF_BITFIELD": if lf.length == 1: return 'Flag("%s")' % name else: return 'Mask("%s", %d)' % (name, lf.length) elif lf.leaf_type == "LF_ARRAY": count = get_size(lf) / get_size(lf.element_type) return 'Array(%d, %s)' % (count, construct(lf.element_type, name or lf.name)) else: return "Unimplemented %s" % lf.leaf_type tpi_stream = tpi.parse_stream(open(sys.argv[1])) structs = [ t for t in tpi_stream.types.values() if t.leaf_type == 'LF_STRUCTURE' and not t.prop.fwdref ] for s in structs: if s.name == "_EPROCESS": print construct(s)