Пример #1
0
def Main(args):
    filenames = ParseOptions(args)
    if GetOption('test'):
        return TestFiles(filenames)
    ast = ParseFiles(filenames)
    for f in ast.GetListOf('File'):
        if f.GetProperty('ERRORS') > 0:
            print 'Skipping %s' % f.GetName()
            continue
        print DefineDepends(node)
        for node in f.GetChildren()[2:]:
            print Define(node, comment=True, prefix='tst_')
Пример #2
0
def main(args):
    filenames = ParseOptions(args)
    if GetOption('test'):
        return TestFiles(filenames)
    ast = ParseFiles(filenames)
    cgen = CSGen()
    for f in ast.GetListOf('File'):
        if f.GetProperty('ERRORS') > 0:
            print 'Skipping %s' % f.GetName()
            continue
        for node in f.GetChildren()[2:]:
            print cgen.Define(node, ast.releases, comment=True, prefix='tst_')
Пример #3
0
def main(args):
    filenames = ParseOptions(args)
    ast = ParseFiles(filenames)
    rpcgen = RPCGen()
    files = ast.GetListOf('File')
    outname = GetOption('out')
    if outname == '':
        outname = 'out.cc'
    outfile = IDLOutFile(outname)
    emitted = set()
    for f in files:
        if f.GetName() == 'pp_macros.idl':
            GenerateDep(outfile, emitted, f, ast.releases)
    for f in files:
        GenerateDep(outfile, emitted, f, ast.releases)
    out = ''
    out += '#include "host/rpc.h"\n'
    out += '#include "json/json.cpp"\n'
    out += 'using namespace std;\n'
    out += 'using namespace JSON;\n'
    for declareOnly in [True, False]:
        for f in files:
            if f.GetProperty('ERRORS') > 0:
                print 'Skipping %s' % f.GetName()
                continue
            for node in f.GetChildren()[2:]:
                out += rpcgen.Define(node, ast.releases, declareOnly)
    out += 'static map<string, void*> gInterfaces;\n'
    out += '\n'
    out += 'typedef char* (*InterfaceMemberCallFunc)(const void*, JSONIterator&);\n'
    out += 'static map<string, InterfaceMemberCallFunc> gInterfaceMemberCallers;\n'
    out += '\n'
    out += 'void InitializeInterfaceList() {\n'
    for (interfaceString, interfaceStruct) in rpcgen.interfaceStructs:
        if interfaceString == "PPB_Flash_File_FileRef;2.0":
            interfaceString = "PPB_Flash_File_FileRef;2"
        elif interfaceString == "PPB_Flash_File_ModuleLocal;3.0":
            interfaceString = "PPB_Flash_File_ModuleLocal;3"
        elif interfaceString == "PPB_PDF;0.1":
            interfaceString = "PPB_PDF;1"
        out += '  gInterfaces.insert(pair<string, void*>("' + interfaceString + '", &' + interfaceStruct + '));\n'
    for (interfaceString, caller) in rpcgen.pppInterfaceGetters:
        out += '  gInterfaceMemberCallers.insert(pair<string, InterfaceMemberCallFunc>("' + interfaceString + '", ' + caller + '));\n'
    out += '};\n'
    out += '\n'
    outfile.Write(out)
    outfile.Close()
Пример #4
0
def TestFiles(filenames):
    if not filenames:
        idldir = os.path.split(sys.argv[0])[0]
        idldir = os.path.join(idldir, 'test_cgen', '*.idl')
        filenames = glob.glob(idldir)

    filenames = sorted(filenames)
    ast = ParseFiles(filenames)

    total_errs = 0
    for filenode in ast.GetListOf('File'):
        errs = TestFile(filenode)
        if errs:
            ErrOut.Log('%s test failed with %d error(s).' %
                       (filenode.GetName(), errs))
            total_errs += errs

    if total_errs:
        ErrOut.Log('Failed generator test.')
    else:
        InfoOut.Log('Passed generator test.')
    return total_errs