def CreateCCodeDB(FileNameList): FileObjList = [] ParseErrorFileList = [] for FullName in FileNameList: if os.path.splitext(FullName)[1] in ('.h', '.c'): EdkLogger.info("Parsing " + FullName) model = FullName.endswith( 'c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H collector = CodeFragmentCollector.CodeFragmentCollector(FullName) try: collector.ParseFile() except UnicodeError: ParseErrorFileList.append(FullName) BaseName = os.path.basename(FullName) DirName = os.path.dirname(FullName) Ext = os.path.splitext(BaseName)[1].lstrip('.') ModifiedTime = os.path.getmtime(FullName) FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), []) FileObjList.append(FileObj) collector.CleanFileProfileBuffer() if len(ParseErrorFileList) > 0: EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n" % "\n\t".join(ParseErrorFileList)) Db = EotGlobalData.gDb for file in FileObjList: Db.InsertOneFile(file) Db.UpdateIdentifierBelongsToFunction()
Db.QueryTable(Db.TblDataModel) identifier1 = DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 32, 43, 54, 43) identifier2 = DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 15, 43, 20, 43) identifier3 = DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 55, 43, 58, 43) identifier4 = DataClass.IdentifierClass(-1, '', '', "i1'", 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 77, 43, 88, 43) fun1 = DataClass.FunctionClass(-1, '', '', 'fun1', '', 21, 2, 60, 45, 1, 23, 0, [], []) file = DataClass.FileClass( -1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', DataClass.MODEL_FILE_C, '2007-12-28', [fun1], [identifier1, identifier2, identifier3, identifier4], []) Db.InsertOneFile(file) Db.UpdateIdentifierBelongsToFunction() Db.QueryTable(Db.TblFile) Db.QueryTable(Db.TblFunction) Db.QueryTable(Db.TblPcd) Db.QueryTable(Db.TblIdentifier) Db.Close() EdkLogger.verbose("End at " + time.strftime('%H:%M:%S', time.localtime()))