""" t3MACR.py Provides a class representing a macro symbol table block in a t3 image file. """ import struct, cStringIO from t3Block import * class MACR_Block(Block): """ A preprocessor macro symbol table block. This is normally only included if the image file was compiled for debugging. """ name = "Preprocessor Macro Symbol Table Block" debug = True def __init__(self, datastream, image, attribs): Block.__init__(self, datastream, image, attribs) self.read_block() def read_block(self): """ Reads the data included in the block. """ n = struct.unpack(" delimiter: substr.append(c) else: # the end of the text decodeddata.write("".join(substr) + "}") delimiter = None substr = [] mode = "normal" elif mode == "normal": if cintval == 1: mode = "formalid" decodeddata.write("{arg: ") elif cintval == 5: mode = "foreach" decodeddata.write("{#foreach: ") elif cintval == 6: decodeddata.write("{#argcount}") elif cintval == 7: mode = "ifempty" decodeddata.write("{#ifempty:") elif cintval == 8: mode = "ifnempty" decodeddata.write("{#ifnempty:") else: decodeddata.write(c) dd = decodeddata.getvalue() decodeddata.close() return dd def report_data(self): sl = [] for entry in self.data["l_entries"]: sl.append("\n") sl.append("symbol name: " + entry["s_symbolName"] + "\n") sl.append("is function-like: ") sl.append(str(entry["b_isFunctionLike"]) + "\n") sl.append("takes varying number of arguments: ") sl.append(str(entry["b_takesVaryingNumberOfArgs"]) + "\n") sl.append("number of parameters: ") sl.append(str(entry["i_numberOfParameters"]) + "\n") sl.append("parameters: ") sl.append(str(entry["l_parameters"]) + "\n") sl.append("expansion text: ") sl.append(repr(entry["s_expansiontext"]) + "\n") return "".join(sl)