Beispiel #1
0
def RunCommand(args,
               data,
               importList,
               hashValue):

    ProcessArguments(args)

    # Process all the imported files first, and get the corresponding code objects
    importedCodeList = GetImportedCodeList(importList)

    # Reset the import name, since this is the main file.
    codeTypes.SetImportName("")

    # Parse the API file and get all the code objects
    parsedCode = interfaceParser.ParseCode(data, args.interfaceFile)
    allCodeList = importedCodeList + parsedCode['codeList']

    # Dump info on the parsed file.  No need to generate any code.
    if args.dump:
        # Print out info on all the types, functions and handlers
        codeTypes.PrintCode(allCodeList)

        # Print out the type dictionary.
        print '='*40 + '\n'
        codeTypes.PrintDefinedTypes()
        sys.exit(0)

    # Pass 'args' so that the function can determine what needs to be output
    codeGen.WriteAllCode(args, parsedCode, hashValue)
Beispiel #2
0
def GetImportedCodeList(importList):
    #print importList
    importedCodeList = []

    for path in importList:
        fullname = os.path.basename(path)
        name = os.path.splitext(fullname)[0]

        data = open(path, 'r').read()

        # In the current .api file, the imported types will be referenced using "name.",
        codeTypes.SetImportName(name)

        # Parse the imported file, which implicitly populates the type translation data
        parsedCode = interfaceParser.ParseCode(data, path)
        codeList = parsedCode['codeList']
        importedCodeList += codeList

    return importedCodeList