예제 #1
0
def prune_in_file(filepath, funclist):
    tree = delphiparser.read_file(filepath)

    trans = transformer.Transformer()
    trans.remove_funcs(tree, funclist)

    delphiparser.write_file(filepath, tree)
예제 #2
0
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))
예제 #3
0
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
예제 #4
0
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)