""" t3dataholder.py Abstraction classes for the T3 Data Holder structure. Also provides a get_data_holder(bytes) function that returns a data holder of the appropriate class. """ import struct, cStringIO from t3Function import T3Function class T3DataHolder: """ Base class for all Data Holder value types. Any data holder can be initialised by passing it the five bytes of which it is made. Typical usage, however, will involve calling the utility function get_data_holder, also defined in this module. """ def __init__(self, s): self.typecode = struct.unpack("= len(image.codePool): return "[invalid code offset]" pagestream = cStringIO.StringIO( image.codePool[p].data["s_pageData"]) pagestream.seek(offset) func = T3Function(pagestream.read(), len(image.functionList)) pagestream.close() image.functionList.append(func) return func class VM_FUNCPTR(VM_CODEOFS): def __init__(self, s): T3DataHolder.__init__(self, s) self.stringvalue = "(function pointer: " + str(self.intvalue) + ")" class VM_EMPTY(T3DataHolder): def __init__(self, s): T3DataHolder.__init__(self, s) self.stringvalue = "(empty)" def to_pyval(self): return None class VM_ENUM(T3DataHolder): def __init__(self, s): T3DataHolder.__init__(self, s) self.stringvalue = "(enumerated constant: " + str(self.intvalue) + ")" DataHolderTypedict = {1: VM_NIL, 2: VM_TRUE, 5: VM_OBJ, 6: VM_PROP, 7: VM_INT, 8: VM_SSTRING, 9: VM_DSTRING, 10: VM_LIST, 11: VM_CODEOFS, 12: VM_FUNCPTR, 13: VM_EMPTY, 15: VM_ENUM} def get_data_holder(bytes): return DataHolderTypedict[struct.unpack("