def prune_in_file(filepath, funclist): tree = delphiparser.read_file(filepath) trans = transformer.Transformer() trans.remove_funcs(tree, funclist) delphiparser.write_file(filepath, tree)
def inject_into_file(filepath, localname): tree = delphiparser.read_file(filepath) trans = transformer.Transformer() trans.listify_stmlist(tree) pairs = trans.inject_writeln(tree) delphiparser.write_file(filepath, tree) for (guid, funcname) in pairs: io.output("%s %s\n %s\n\n" % (guid, localname, funcname))
def trans_unit(filepath): tree = delphiparser.read_file(filepath) trans = transformer.Transformer() trans.listify_ast(tree) # trans.resolve(tree) # sys.exit() handlers = trans.remote(tree) trans.add_uses(tree, ['SocketClient', 'SocketMarshall', 'SocketTypes']) delphiparser.write_file(filepath, tree) return handlers
def new_unit(handlers): trans = transformer.Transformer() unitname = 'SocketServiceHandlers' tree = trans.mk_unit(unitname) trans.listify_ast(tree) uses = ['SysUtils', 'Classes', 'IdTCPConnection', 'SocketServer', 'SocketMarshall', 'SocketTypes', 'Core'] trans.add_uses(tree, uses) t = trans.mk_type_spec('TServiceHandlerIndex') vardecl = trans.mk_var_decl(['HandlerIndex'], t) trans.add_var_decl(tree, vardecl) for handler in handlers: trans.add_func(tree, handler) delphiparser.write_file(unitname+'.pas', tree)